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