Commit 8f56d725 authored by Curtis Adam's avatar Curtis Adam

Add a new input field to set the submission deadline and lock the transcript...

Add a new input field to set the submission deadline and lock the transcript from editing after the editing deadline expired
parent 3edc9aba
......@@ -687,7 +687,10 @@
"percentage": "Maximale Bonuspunkte",
"enable": "Bonus aktivieren",
"lectureTimeEnd": "Freischaltung der Mitschriftenkopplung",
"deadline": "Zeit für die Nachbearbeitung",
"deadline": {
"submission": "Zeit für die Abgabe",
"editing": "Zeit für die Nachbearbeitung"
},
"lectureDates": "Termine für das Bonus-Mitschreiben",
"clock": "Uhr",
"hours": "Stunden",
......
......@@ -674,7 +674,10 @@
"title": "Mitschrift mit einer Vorlesung koppeln",
"description": "Gekoppelte Mitschriften können nach Ablauf der Abgabe nicht mehr bearbeitet werden",
"lecture": "Vorlesung",
"deadline": "Abgabefrist",
"deadline": {
"submission": "Zeit für die Abgabe",
"editing": "Zeit für die Nachbearbeitung"
},
"clock": "Uhr",
"until": "bis",
"referencesLecture": {
......
......@@ -476,6 +476,9 @@ Meteor.methods({
}
Meteor.call("addTranscriptBonus", card_id, transcriptBonusUser.cardset_id, Meteor.userId(), Number(transcriptBonusUser.date_id));
} else {
if (TranscriptBonusList.isDeadlineExpired(transcriptBonusDatabase, true)) {
throw new Meteor.Error(TAPi18n.__('transcriptForm.server.deadlineExpired', {}, Meteor.user().profile.locale));
}
TranscriptBonusList.checkForUpdate(card_id, Meteor.userId(), transcriptBonusUser, transcriptBonusDatabase, transcriptBonusUser.date_id);
}
}
......
......@@ -777,15 +777,17 @@ Meteor.methods({
* @param {Number} isEnabled - Is the transcript bonus enabled?
* @param {Number} percentage - Percentage for maximum achievable bonus points
* @param {String} lectureEnd - Time at which the lectures end
* @param {Number} deadline - Amount of hours that the student got time to submit their transcript
* @param {Number} deadlineSubmission - Amount of hours that the student got time to submit their transcript
* @param {Number} deadlineEditing - Amount of hours that the student got time to edit their transcript
* @param {Date} newDates - Dates at which the individual lectures take place
*/
updateCardsetTranscriptBonus: function (id, isEnabled, percentage, lectureEnd, deadline, newDates) {
updateCardsetTranscriptBonus: function (id, isEnabled, percentage, lectureEnd, deadlineSubmission, deadlineEditing, newDates) {
check(id, String);
check(isEnabled, Boolean);
check(percentage, Number);
check(lectureEnd, String);
check(deadline, Number);
check(deadlineSubmission, Number);
check(deadlineEditing, Number);
check(newDates, [Date]);
let cardset = Cardsets.findOne(id);
if (cardset !== undefined && (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner))) {
......@@ -795,7 +797,8 @@ Meteor.methods({
'transcriptBonus.percentage': percentage,
'transcriptBonus.lectureEnd': lectureEnd,
'transcriptBonus.dates': newDates,
'transcriptBonus.deadline': deadline
'transcriptBonus.deadline': deadlineSubmission,
'transcriptBonus.deadlineEditing': deadlineEditing
}
});
return cardset._id;
......
......@@ -48,6 +48,9 @@ const TranscriptBonusSchema = new SimpleSchema({
},
deadline: {
type: Number
},
deadlineEditing: {
type: Number
}
});
......@@ -71,6 +74,7 @@ Meteor.methods({
date: cardset.transcriptBonus.dates[date_id],
lectureEnd: cardset.transcriptBonus.lectureEnd,
deadline: cardset.transcriptBonus.deadline,
deadlineEditing: cardset.transcriptBonus.deadlineEditing,
dateCreated: new Date()
}
});
......@@ -86,8 +90,14 @@ export let TranscriptBonusList = class TranscriptBonusList {
return moment(date).add(hours, 'hours').add(minutes, 'minutes');
}
static isDeadlineExpired (transcriptBonus) {
return this.addLectureEndTime(transcriptBonus, transcriptBonus.date).add(transcriptBonus.deadline, 'hours') < new Date();
static isDeadlineExpired (transcriptBonus, isEditingDeadline = false) {
let deadline;
if (isEditingDeadline) {
deadline = transcriptBonus.deadlineEditing
} else {
deadline = transcriptBonus.deadline;
}
return this.addLectureEndTime(transcriptBonus, transcriptBonus.date).add(deadline, 'hours') < new Date();
}
static canBeSubmittedToLecture (transcriptBonus, date_id) {
......
......@@ -9,6 +9,7 @@ import {Ratings} from "../../api/ratings";
import {CardType} from "../../api/cardTypes";
import {WebPushSubscriptions} from "../../api/webPushSubscriptions";
import {Paid} from "../../api/paid";
import {TranscriptBonus} from "../../api/transcriptBonus";
var initColorThemes = function () {
return [{
......@@ -800,6 +801,34 @@ Meteor.startup(function () {
);
}
cardsets = Cardsets.find({transcriptBonus: {$exists: true}}, {fields: {_id: 1, transcriptBonus: 1}}).fetch();
for (let i = 0; i < cardsets.length; i++) {
if (cardsets[i].transcriptBonus.deadlineEditing === undefined) {
Cardsets.update({
_id: cardsets[i]._id
},
{
$set: {
"transcriptBonus.deadlineEditing": cardsets[i].transcriptBonus.deadline
}
}
);
}
}
let transcriptBonus = TranscriptBonus.find({deadlineEditing: {$exists: false}}, {fields: {_id: 1, deadline: 1}}).fetch();
for (let i = 0; i < transcriptBonus.length; i++) {
TranscriptBonus.update({
_id: transcriptBonus[i]._id
},
{
$set: {
deadlineEditing: transcriptBonus[i].deadline
}
}
);
}
cardsets = Cardsets.find().fetch();
for (let i = 0; i < cardsets.length; i++) {
Cards.update({
......
......@@ -47,8 +47,13 @@
<span class="unit">{{_ "transcriptForm.bonus.form.clock"}}</span>
</div>
<div class="col-sm-6 col-md-3">
<label>{{_ "transcriptForm.bonus.form.deadline"}}:</label>
<input type="number" id="deadlineHours" min="24" max="168" step="12" value="36" required>
<label>{{_ "transcriptForm.bonus.form.deadline.submission"}}:</label>
<input type="number" id="deadlineHoursSubmission" min="1" max="24" step="1" value="2" required>
<span class="unit">{{_ "transcriptForm.bonus.form.hours"}}</span>
</div>
<div class="col-sm-6 col-md-3">
<label>{{_ "transcriptForm.bonus.form.deadline.editing"}}:</label>
<input type="number" id="deadlineHoursEditing" min="24" max="168" step="12" value="36" required>
<span class="unit">{{_ "transcriptForm.bonus.form.hours"}}</span>
</div>
<div class="col-xs-12">
......
......@@ -38,13 +38,14 @@ Template.cardsetTranscript.events({
let isEnabled = $('#enableBonus:checked').is(":checked");
let percentage = $('#bonusPercentage').val();
let lectureEnd = $('#lectureTimeEnd').val();
let deadline = $('#deadlineHours').val();
let deadlineEditing = $('#deadlineHoursEditing').val();
let deadlineSubmission = $('#deadlineHoursSubmission').val();
let dates = $('#transcript-calendar').multiDatesPicker('getDates');
let newDates = [];
for (let d = 0; d < dates.length; d++) {
newDates.push(moment(dates[d], "MM/DD/YYYY").toDate());
}
Meteor.call('updateCardsetTranscriptBonus', Router.current().params._id, Boolean(isEnabled), Number(percentage), lectureEnd, Number(deadline), newDates, function (error, result) {
Meteor.call('updateCardsetTranscriptBonus', Router.current().params._id, Boolean(isEnabled), Number(percentage), lectureEnd, Number(deadlineSubmission), Number(deadlineEditing), newDates, function (error, result) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('transcriptForm.bonus.form.alert.save'), "success", 'growl-top-left');
}
......@@ -64,7 +65,8 @@ Template.cardsetTranscriptEditor.onRendered(function () {
$('#enableBonus').prop('checked', this.data.transcriptBonus.enabled);
$('#bonusPercentage').val(this.data.transcriptBonus.percentage);
$('#lectureTimeEnd').val(this.data.transcriptBonus.lectureEnd);
$('#deadlineHours').val(this.data.transcriptBonus.deadline);
$('#deadlineHoursSubmission').val(this.data.transcriptBonus.deadline);
$('#deadlineHoursEditing').val(this.data.transcriptBonus.deadlineEditing);
for (let d = 0; d < this.data.transcriptBonus.dates.length; d++) {
dates.push(moment(this.data.transcriptBonus.dates[d]).format("MM/DD/YYYY"));
}
......
......@@ -49,11 +49,13 @@
</div>
<div class="resultItemHeaderRightAreaBottom col-xs-3 col-sm-12">
{{#unless isCardsetTranscriptBonusRoute}}
<a class="resultNavigationElement editCard hidden-xs" {{disableIfOffline}}
title='{{_ "transcriptForm.index.tooltip.edit"}}' data-id="{{this._id}}">
<i class="glyphicon glyphicon-edit" data-id="{{this._id}}"></i>
</a>
<a class="resultNavigationElement deleteCard hidden-xs" {{disableIfOffline}}
{{#unless isMyBonusTranscriptsRouteAndDeadlineExpired}}
<a class="resultNavigationElement editCard hidden-xs" {{disableIfOffline}}
title='{{_ "transcriptForm.index.tooltip.edit"}}' data-id="{{this._id}}">
<i class="glyphicon glyphicon-edit" data-id="{{this._id}}"></i>
</a>
{{/unless}}
<a class="resultNavigationElement deleteCard" {{disableIfOffline}}
title='{{_ "transcriptForm.index.tooltip.delete"}}' data-toggle="modal" data-target="#deleteTranscriptModal" data-id="{{this._id}}">
<i class="result fa fa-trash" data-id="{{this._id}}"></i>
</a>
......
......@@ -49,7 +49,7 @@ Template.filterIndexItemCard.helpers({
if (Route.isMyBonusTranscripts()) {
let bonusTranscript = TranscriptBonus.findOne({card_id: this._id});
if (bonusTranscript !== undefined) {
return TranscriptBonusList.isDeadlineExpired(bonusTranscript);
return TranscriptBonusList.isDeadlineExpired(bonusTranscript, true);
}
}
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment