Commit 08a1d912 authored by Curtis Adam's avatar Curtis Adam

Offer an input field for max. bonus points to be acquired as an integer and display this number

parent 301a4977
......@@ -387,8 +387,12 @@
"ratingFilterPlural": "> __rating__ Sterne",
"moreResults": "Zeige weitere Einträge",
"learnphase": "Bonusphase",
"bonusPoints": "FAQ zu Bonuspunkten",
"bonusPointsPercentage": "Prüfungsamt THM",
"bonusPointsFAQ": "FAQ zu Bonuspunkten",
"bonusPointsPercentageFAQ": "Prüfungsamt THM",
"bonusMaxPoints": {
"label": "Maximale Bonuspunkte",
"content": "__count__%"
},
"activeLearnphase": "Bonusphase aktiv",
"inactiveLearnphase": "Bonusphase beendet",
"learnphaseInfo": "Über diese Bonus-Lernphase",
......@@ -788,6 +792,9 @@
"label": "Tagespensum",
"placeholder": "maximal täglich zu lernende Karten"
},
"maxPoints": {
"label": "Maximal erreichbare Bonuspunkte in Prozent"
},
"daysBeforeReset": {
"label": "Überschreitungsfrist",
"placeholder": "in Tagen bis alle Karten wieder in Box 1"
......
......@@ -8,6 +8,8 @@ let defaultMaxWorkload = 30;
let minDaysBeforeReset = 3;
let maxDaysBeforeReset = 31;
let defaultDaysBeforeReset = 7;
let defaultMinBonusPoints = 1;
let defaultMaxBonusPoints = 10;
let dateFormat = "YYYY-MM-DD";
let defaultRegistrationPeriod = [31, 'days'];
......@@ -91,6 +93,14 @@ export let BonusForm = class BonusForm {
}
}
static adjustMaxBonusPoints () {
if (parseInt($('#bonusFormModal #maxBonusPoints').val()) <= (defaultMinBonusPoints - 1)) {
$('#bonusFormModal #maxBonusPoints').val(defaultMinBonusPoints);
} else if (parseInt($('#bonusFormModal #maxBonusPoints').val()) > defaultMaxBonusPoints) {
$('#bonusFormModal #maxBonusPoints').val(defaultMaxBonusPoints);
}
}
static adjustMaxWorkload () {
if (parseInt($('#bonusFormModal #maxWorkload').val()) <= (minWorkloadCap - 1)) {
$('#bonusFormModal #maxWorkload').val(minWorkloadCap);
......@@ -154,9 +164,16 @@ export let BonusForm = class BonusForm {
}
return registrationPeriod;
}
static getMaxBonusPoints () {
let maxBonusPoints = Number($('#bonusFormModal #maxBonusPoints').val());
if (!maxBonusPoints) {
maxBonusPoints = Number(defaultMaxWorkload);
}
return maxBonusPoints;
}
static startBonus () {
Meteor.call("activateBonus", Session.get('activeCardset')._id, this.getMaxWorkload(), this.getDaysBeforeReset(), this.getDateStart(), this.getDateEnd(), this.getIntervals(), this.getRegistrationPeriod(), function (error, result) {
Meteor.call("activateBonus", Session.get('activeCardset')._id, this.getMaxWorkload(), this.getDaysBeforeReset(), this.getDateStart(), this.getDateEnd(), this.getIntervals(), this.getRegistrationPeriod(), this.getMaxBonusPoints(), function (error, result) {
if (result) {
Session.set('activeCardset', Cardsets.findOne(result));
Meteor.call("updateBonusPomodoroTimer", Session.get('activeCardset')._id, PomodoroTimer.getGoalPoms(), PomodoroTimer.getPomLength(), PomodoroTimer.getBreakLength(), PomodoroTimer.getSoundConfig(), function (error, result) {
......@@ -169,7 +186,7 @@ export let BonusForm = class BonusForm {
}
static updateBonus () {
Meteor.call("updateBonus", Session.get('activeCardset')._id, this.getMaxWorkload(), this.getDaysBeforeReset(), this.getDateStart(), this.getDateEnd(), this.getIntervals(), this.getRegistrationPeriod(), function (error, result) {
Meteor.call("updateBonus", Session.get('activeCardset')._id, this.getMaxWorkload(), this.getDaysBeforeReset(), this.getDateStart(), this.getDateEnd(), this.getIntervals(), this.getRegistrationPeriod(), this.getMaxBonusPoints(), function (error, result) {
if (result) {
Session.set('activeCardset', Cardsets.findOne(result));
Meteor.call("updateBonusPomodoroTimer", Session.get('activeCardset')._id, PomodoroTimer.getGoalPoms(), PomodoroTimer.getPomLength(), PomodoroTimer.getBreakLength(), PomodoroTimer.getSoundConfig(), function (error, result) {
......@@ -180,4 +197,20 @@ export let BonusForm = class BonusForm {
}
});
}
static getDefaultMaxBonusPoints () {
return defaultMaxBonusPoints;
}
static getDefaultMinBonusPoints () {
return defaultMinBonusPoints;
}
static getCurrentMaxBonusPoints (cardset) {
if (cardset.workload.bonus.maxPoints === undefined) {
return this.getDefaultMaxBonusPoints();
} else {
return cardset.workload.bonus.maxPoints;
}
}
};
......@@ -26,12 +26,21 @@ function getCardsetInfo(cardset) {
];
}
function getCurrentMaxBonusPoints(cardset) {
if (cardset.workload.bonus.maxPoints === undefined) {
return 10;
} else {
return cardset.workload.bonus.maxPoints;
}
}
function getLearningPhaseInfo(cardset) {
return [
["", ""],
[TAPi18n.__('set-list.learnphaseInfo', {}, "de"), ""],
[TAPi18n.__('set-list.learnphase', {}, "de"), getLearningStatus(cardset.learningEnd)],
[TAPi18n.__('cardset.info.workload.bonus.count', {}, "de"), cardset.workload.bonus.count],
[TAPi18n.__('set-list.bonusMaxPoints.label', {}, "de"), TAPi18n.__('set-list.bonusMaxPoints.content', {count: getCurrentMaxBonusPoints(cardset)}, "de")],
[TAPi18n.__('bonus.form.maxWorkload.label', {}, "de"), cardset.maxCards],
[TAPi18n.__('bonus.form.daysBeforeReset.label', {}, "de"), cardset.daysBeforeReset],
[TAPi18n.__('bonus.form.startDate.label', {}, "de"), moment(cardset.learningStart).locale("de").format('LL')],
......@@ -110,7 +119,7 @@ Meteor.methods({
let infoCardsetCounter = 0;
let infoCardsetLength = 6;
let infoLearningPhaseCounter = 0;
let infoLearningPhaseLength = 8;
let infoLearningPhaseLength = 9;
content = header[6] + colSep + header[7] + colSep + header[8] + colSep;
for (let i = 0; i <= 4; i++) {
content += header[i] + " [" + cardset.learningInterval[i] + "]" + colSep;
......
......@@ -444,8 +444,9 @@ Meteor.methods({
* @param {Date} dateEnd - End date of the learning phase
* @param {Number} intervals - Learning interval in days
* @param {Date} registrationPeriod - Period in which new users can join the bonus phase
* @param {Number} maxBonusPoints - The maximum achieveable bonus points
*/
activateBonus: function (id, maxWorkload, daysBeforeReset, dateStart, dateEnd, intervals, registrationPeriod) {
activateBonus: function (id, maxWorkload, daysBeforeReset, dateStart, dateEnd, intervals, registrationPeriod, maxBonusPoints) {
check(id, String);
check(maxWorkload, Number);
check(daysBeforeReset, Number);
......@@ -453,6 +454,7 @@ Meteor.methods({
check(dateEnd, Date);
check(intervals, [Number]);
check(registrationPeriod, Date);
check(maxBonusPoints, Number);
let cardset = Cardsets.findOne(id);
if (cardset !== undefined && !cardset.learningActive && (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner))) {
......@@ -469,7 +471,8 @@ Meteor.methods({
learningStart: dateStart,
learningEnd: dateEnd,
learningInterval: intervals,
registrationPeriod: registrationPeriod
registrationPeriod: registrationPeriod,
"workload.bonus.maxPoints": Math.floor(maxBonusPoints)
}
});
return cardset._id;
......@@ -486,8 +489,9 @@ Meteor.methods({
* @param {Date} dateEnd - End date of the learning phase
* @param {Number} intervals - Learning interval in days
* @param {Date} registrationPeriod - Period in which new users can join the bonus phase
* @param {Number} maxBonusPoints - The maximum achieveable bonus points
*/
updateBonus: function (id, maxWorkload, daysBeforeReset, dateStart, dateEnd, intervals, registrationPeriod) {
updateBonus: function (id, maxWorkload, daysBeforeReset, dateStart, dateEnd, intervals, registrationPeriod, maxBonusPoints) {
check(id, String);
check(maxWorkload, Number);
check(daysBeforeReset, Number);
......@@ -495,6 +499,7 @@ Meteor.methods({
check(dateEnd, Date);
check(intervals, [Number]);
check(registrationPeriod, Date);
check(maxBonusPoints, Number);
let cardset = Cardsets.findOne(id);
if (cardset !== undefined && cardset.learningActive && (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner))) {
......@@ -510,7 +515,8 @@ Meteor.methods({
learningStart: dateStart,
learningEnd: dateEnd,
learningInterval: intervals,
registrationPeriod: registrationPeriod
registrationPeriod: registrationPeriod,
"workload.bonus.maxPoints": Math.floor(maxBonusPoints)
}
});
return cardset._id;
......
......@@ -17,6 +17,7 @@ import {CardVisuals} from "../../api/cardVisuals";
import {UserPermissions} from "../../api/permissions";
import {Bonus} from "../../api/bonus";
import {Profile} from "../../api/profile";
import {BonusForm} from "../../api/bonusForm";
Meteor.subscribe("collegesCourses");
Template.registerHelper('isSelectingCardsetToLearn', function () {
......@@ -593,6 +594,18 @@ Template.registerHelper("getLearnphase", function (state) {
}
});
Template.registerHelper("getDefaultMaxBonusPoints", function () {
return BonusForm.getDefaultMaxBonusPoints();
});
Template.registerHelper("getDefaultMinBonusPoints", function () {
return BonusForm.getDefaultMinBonusPoints();
});
Template.registerHelper("getCurrentMaxBonusPoints", function (cardset) {
return BonusForm.getCurrentMaxBonusPoints(cardset);
});
Template.registerHelper("getCardsetBackground", function (difficulty, cardType, backgroundStyle) {
switch (cardType) {
case 8:
......
......@@ -9,7 +9,8 @@
<table class="table table-condensed table-striped table-hover infoBoxTable">
<tbody>
{{> cardsetInfoBoxItemBonusStatus}}
{{> cardsetInfoBoxItemBonusPoints}}
{{> cardsetInfoBoxItemBonusMaxPoints}}
{{> cardsetInfoBoxItemBonusPointsFAQ}}
{{> cardsetInfoBoxItemBonusWorkload}}
{{> cardsetInfoBoxItemPomodoroCount}}
{{> cardsetInfoBoxItemPomodoroWorkTime}}
......
......@@ -4,7 +4,8 @@ import {CardsetVisuals} from "../../../../api/cardsetVisuals";
import "./item/bonusButton.js";
import "./item/bonusDeadline.js";
import "./item/bonusEnd.js";
import "./item/bonusPoints.js";
import "./item/bonusMaxPoints.js";
import "./item/bonusPointsFAQ.js";
import "./item/bonusRegistrationPeriod.js";
import "./item/bonusStart.js";
import "./item/bonusStatus.js";
......
<template name="cardsetInfoBoxItemBonusMaxPoints">
<tr>
<td>{{_ "set-list.bonusMaxPoints.label"}}:</td>
<td>{{_ "set-list.bonusMaxPoints.content" count=(getCurrentMaxBonusPoints this)}}</td>
</tr>
</template>
//------------------------ IMPORTS
import "./bonusPoints.html";
import "./bonusMaxPoints.html";
<template name="cardsetInfoBoxItemBonusPoints">
<template name="cardsetInfoBoxItemBonusPointsFAQ">
<tr>
<td>{{_ "set-list.bonusPoints"}}:</td>
<td>{{_ "set-list.bonusPointsFAQ"}}:</td>
<td>
<a href="https://www.thm.de/site/hochschule/zentrale-bereiche/pruefungsamt/faq.html#bonuspunkte-an-der-thm"
target="_blank">{{_ "set-list.bonusPointsPercentage"}}</a></td>
target="_blank">{{_ "set-list.bonusPointsPercentageFAQ"}}</a></td>
</tr>
</template>
//------------------------ IMPORTS
import "./bonusPointsFAQ.html";
......@@ -17,6 +17,7 @@
{{> bonusFormEndDate}}
{{> bonusFormRegistrationPeriod}}
{{> bonusFormIntervals}}
{{> bonusFormMaxPoints}}
{{> pomodoroTimerModalContent}}
</div>
</div>
......@@ -120,6 +121,18 @@
</template>
<template name="bonusFormMaxPoints">
<div class="form-group row">
<label class="col-md-3 control-label">{{_ "bonus.form.maxPoints.label"}}</label>
<div class="col-md-9 form-inline">
<input type="number" min="{{getDefaultMinBonusPoints}}" max="{{getDefaultMaxBonusPoints}}" data-bind="value:replyNumber"
onkeypress="return (event.charCode === 8 || event.charCode === 0) ? null : event.charCode >= 48 && event.charCode <= 57"
class="form-control interval" id="maxBonusPoints"
placeholder="{{getDefaultMaxBonusPoints}}" value="{{getCurrentMaxBonusPoints this}}">
</div>
</div>
</template>
<template name="joinBonusForm">
<div class="modal fade" id="joinBonusModal" tabindex="-1" role="dialog" aria-labelledby="joinBonusTitle">
<div class="modal-dialog">
......
......@@ -94,6 +94,18 @@ Template.bonusFormEndDate.events({
}
});
/*
* ############################################################################
* bonusFormMaxPoints
* ############################################################################
*/
Template.bonusFormMaxPoints.events({
"input #maxBonusPoints": function () {
BonusForm.adjustMaxBonusPoints();
}
});
/*
* ############################################################################
* bonusFormIntervals
......
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