Commit ecf57671 authored by Curtis Adam's avatar Curtis Adam

Only show the bonus bert alert if there are active cards and redirect to the users workload

parent 7eb81cc6
......@@ -1803,6 +1803,7 @@
"subjectInfo_plural": "Karten in der Box __box__ werden nach __count__ Tagen wieder vorgelegt.",
"leitnerCard": "Karte für derzeitige Lernphase",
"backbutton": " Zur Kartei",
"backbuttonWorkload": "Zum Lernpensum",
"backbuttonStatistics": " Zurück zur Lernstatistik",
"know": "Gewusst",
"notknow": "Nicht gewusst",
......
......@@ -1804,6 +1804,7 @@
"subjectInfo_plural": "Karten in der Box __box__ werden nach __count__ Tagen wieder vorgelegt.",
"leitnerCard": "Karte für derzeitige Lernphase",
"backbutton": " Zur Kartei",
"backbuttonWorkload": "Zum Lernpensum",
"backbuttonStatistics": " Zurück zur Lernstatistik",
"know": "Gewusst",
"notknow": "Nicht gewusst",
......
......@@ -3,7 +3,6 @@ import {Meteor} from "meteor/meteor";
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
import {Workload} from "../../../../api/learned";
import {Cardsets} from "../../../../api/cardsets";
import {CardsetNavigation} from "../../../../api/cardsetNavigation";
import {BertAlertVisuals} from "../../../../api/bertAlertVisuals";
import "./learning.html";
......@@ -41,39 +40,16 @@ Template.cardsetNavigationLearning.onRendered(function () {
let workload = Workload.findOne({cardset_id: Session.get('activeCardset')._id, user_id: Meteor.userId()});
let text = "";
if (workload.leitner.activeCount) {
var deadline = new Date(workload.leitner.activeDate.getTime() + Session.get('activeCardset').daysBeforeReset * 86400000);
let deadline = new Date(workload.leitner.activeDate.getTime() + Session.get('activeCardset').daysBeforeReset * 86400000);
if (deadline.getTime() > Session.get('activeCardset').learningEnd.getTime()) {
text += (TAPi18n.__('deadlinePrologue') + moment(Session.get('activeCardset').learningEnd).format("DD.MM.YYYY") + TAPi18n.__('deadlineEpilogue1'));
} else {
text += (TAPi18n.__('deadlinePrologue') + moment(deadline).format("DD.MM.YYYY") + TAPi18n.__('deadlineEpilogue2'));
}
bertType = "warning";
} else {
if (workload.leitner.finished) {
text += TAPi18n.__('bonus.message.learnedEverything');
} else {
let learningEnd = Cardsets.findOne({_id: Router.current().params._id}).learningEnd;
if (workload.leitner.nextDate.getTime() > learningEnd.getTime()) {
text += TAPi18n.__('noMoreCardsBeforeEnd');
}
let nextDate;
if (workload.leitner.nextDate.getTime() < new Date().getTime()) {
nextDate = moment(new Date()).locale(Session.get('activeLanguage'));
} else {
nextDate = moment(workload.leitner.nextDate).locale(Session.get('activeLanguage'));
}
if (nextDate.get('hour') >= Meteor.settings.public.dailyCronjob.executeAtHour) {
nextDate.add(1, 'day');
}
nextDate.hour(Meteor.settings.public.dailyCronjob.executeAtHour);
nextDate.minute(0);
text += TAPi18n.__('noCardsToLearn') + nextDate.format("D. MMMM") + TAPi18n.__('at') + nextDate.format("HH:mm") + TAPi18n.__('released');
}
BertAlertVisuals.displayBertAlert(text, bertType, 'growl-top-left');
}
BertAlertVisuals.displayBertAlert(text, bertType, 'growl-top-left');
} else {
BertAlertVisuals.displayBertAlert(TAPi18n.__('bonus.message.bonusEnded'), bertType, 'growl-top-left');
}
Bert.defaults.hideDelay = 10000;
}, 2000);
}, 1000);
});
......@@ -144,6 +144,6 @@
<template name="learnBackButton">
<br>
<button class="btn btn-block btn-raised btn-danger" id="backButton">
<span class="pull-left"><i class="fa fa-arrow-left"></i> {{_ "backbutton"}}</span>
<span class="pull-left"><i class="fa fa-arrow-left"></i> {{_ "backbuttonWorkload"}}</span>
</button>
</template>
......@@ -157,8 +157,7 @@ Template.learnAnswerOptions.events({
Template.learnBackButton.events({
"click #backButton": function () {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
Router.go('learn', {
});
}
});
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