GitLab steht Mittwoch, den 08. Juli, zwischen 09:00 und 13:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit d755483d authored by Curtis Adam's avatar Curtis Adam

Fix deadline checks and update the info description

parent 3a3e51f1
......@@ -672,6 +672,9 @@
"description": "Verknüpfte Mitschriften können nach Ablauf der Abgabe nicht mehr bearbeitet werden",
"placeholder": "Wähle eine Vorlesung mit Bonusvergabe aus…",
"lecture": "Vorlesung",
"deadline": "Abgabefrist",
"clock": "Uhr",
"until": "bis",
"referencesLecture": {
"true": "Mit Vorlesung verknüpfen",
"false": "Lose Mitschrift"
......@@ -683,7 +686,7 @@
"title": "Bonusvergabe für Mitschriften verwalten",
"percentage": "Maximale Bonuspunkte",
"enable": "Bonus aktivieren",
"lectureTimeEnd": "Deadline für fotografierte Mitschrift",
"lectureTimeEnd": "Freischaltung für Abgabe",
"deadline": "Bearbeitungszeit",
"lectureDates": "Termine für das Bonus-Mitschreiben",
"clock": "Uhr",
......
......@@ -674,6 +674,9 @@
"title": "Mitschrift mit einer Vorlesung koppeln",
"description": "Gekoppelte Mitschriften können nach Ablauf der Abgabe nicht mehr bearbeitet werden",
"lecture": "Vorlesung",
"deadline": "Abgabefrist",
"clock": "Uhr",
"until": "bis",
"referencesLecture": {
"true": "Mit Vorlesung koppeln",
"false": "Private Mitschrift"
......
......@@ -80,14 +80,21 @@ Meteor.methods({
});
export let TranscriptBonusList = class TranscriptBonusList {
static addLectureEndTime (transcriptBonus, date) {
let hours = Number(transcriptBonus.lectureEnd.substring(0, 2));
let minutes = Number(transcriptBonus.lectureEnd.substring(3, 5));
return moment(date).add(hours, 'hours').add(minutes, 'minutes');
}
static isDeadlineExpired (transcriptBonus) {
return moment(transcriptBonus.date).add(transcriptBonus.deadline, 'hours') < new Date();
return this.addLectureEndTime(transcriptBonus, transcriptBonus.date).add(transcriptBonus.deadline, 'hours') < new Date();
}
static canBeSubmittedToLecture (transcriptBonus, date_id) {
if (transcriptBonus !== undefined && date_id !== undefined) {
let cardset = Cardsets.findOne(transcriptBonus.cardset_id, {fields: {transcriptBonus: 1}});
return cardset.transcriptBonus.enabled && moment(cardset.transcriptBonus.dates[date_id]).add(cardset.transcriptBonus.deadline, 'hours') > new Date() && cardset.transcriptBonus.dates[date_id] < new Date();
let startDate = this.addLectureEndTime(cardset.transcriptBonus, cardset.transcriptBonus.dates[date_id]);
return cardset.transcriptBonus.enabled && startDate < new Date() && startDate.add(cardset.transcriptBonus.deadline, 'hours') > new Date();
}
}
......@@ -122,18 +129,15 @@ export let TranscriptBonusList = class TranscriptBonusList {
static getLectureInfo (transcriptBonus, date_id, isList = true, displayDeadline = true) {
if (transcriptBonus.lectureEnd !== undefined) {
let hours = Number(transcriptBonus.lectureEnd.substring(0, 2));
let minutes = Number(transcriptBonus.lectureEnd.substring(4, 6));
let lectureEnd;
if (isList) {
lectureEnd = moment(transcriptBonus.dates[date_id]).add(hours, 'hours').add(minutes, 'minutes');
lectureEnd = this.addLectureEndTime(transcriptBonus, transcriptBonus.dates[date_id]);
} else {
lectureEnd = moment(date_id).add(hours, 'hours').add(minutes, 'minutes');
lectureEnd = this.addLectureEndTime(transcriptBonus, date_id);
}
let lectureStart = moment(lectureEnd).subtract(90, 'minutes');
let info = TAPi18n.__('transcriptForm.lecture') + ": " + Utilities.getMomentsDate(lectureStart, true) + " - " + Utilities.getMomentsTime(lectureEnd);
let info = TAPi18n.__('transcriptForm.lecture') + ": " + Utilities.getMomentsDate(lectureEnd, false);
if (displayDeadline) {
info += ", " + TAPi18n.__('transcriptForm.bonus.form.deadline') + ": " + transcriptBonus.deadline + " " + TAPi18n.__('transcriptForm.bonus.form.hours');
info += ", " + TAPi18n.__('transcriptForm.deadline') + ": " + Utilities.getMomentsTime(lectureEnd) + " " + TAPi18n.__('transcriptForm.until') + " " + Utilities.getMomentsDate(lectureEnd.add(transcriptBonus.deadline, 'hours'), true);
}
return info;
}
......
......@@ -24,10 +24,11 @@ export let Utilities = class Utilities {
}
static getMomentsDate (date, displayMinutes = false) {
let minutes = "H:mm";
let minutes = "";
let dateFormat = "D. MMMM YYYY";
if (displayMinutes === true) {
dateFormat = "D. MMM YY " + minutes;
minutes = "H:mm";
}
return moment(date).locale(Session.get('activeLanguage')).calendar(null, {
sameDay: this.getCalendarString("today", minutes),
......
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