Commit 8022354d authored by Curtis Adam's avatar Curtis Adam

Add an option to set the minimum required submissions for max points and display it in the info box

parent 44d50278
......@@ -702,6 +702,7 @@
"title": "Bonusvergabe konfigurieren",
"percentage": "Maximale Bonuspunkte",
"enable": "Bonus aktivieren",
"minimum": "Anzahl der Mitschriften für die maximale Anzahl von Bonuspunkten",
"lectureTimeEnd": "Freischaltung der Mitschriftenkopplung",
"deadline": {
"submission": "Zeit für die Foto-Abgabe",
......
......@@ -704,6 +704,7 @@
"title": "Bonusvergabe für Mitschriften verwalten",
"percentage": "Maximale Bonuspunkte",
"enable": "Bonus aktivieren",
"minimum": "Number of transcripts for maximum number of bonus points",
"lectureTimeEnd": "Vorlesungsende",
"deadline": {
"submission": "Zeit für die Foto-Abgabe",
......
......@@ -780,8 +780,9 @@ Meteor.methods({
* @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 {Number} minimumSubmissions - The minimum amount of submissions that are required to reach max points
*/
updateCardsetTranscriptBonus: function (id, isEnabled, percentage, lectureEnd, deadlineSubmission, deadlineEditing, newDates) {
updateCardsetTranscriptBonus: function (id, isEnabled, percentage, lectureEnd, deadlineSubmission, deadlineEditing, newDates, minimumSubmissions) {
check(id, String);
check(isEnabled, Boolean);
check(percentage, Number);
......@@ -789,6 +790,7 @@ Meteor.methods({
check(deadlineSubmission, Number);
check(deadlineEditing, Number);
check(newDates, [Date]);
check(minimumSubmissions, Number);
let cardset = Cardsets.findOne(id);
if (cardset !== undefined && (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner))) {
Cardsets.update(id, {
......@@ -798,7 +800,8 @@ Meteor.methods({
'transcriptBonus.lectureEnd': lectureEnd,
'transcriptBonus.dates': newDates,
'transcriptBonus.deadline': deadlineSubmission,
'transcriptBonus.deadlineEditing': deadlineEditing
'transcriptBonus.deadlineEditing': deadlineEditing,
'transcriptBonus.minimumSubmissions': minimumSubmissions
}
});
return cardset._id;
......
......@@ -814,6 +814,17 @@ Meteor.startup(function () {
}
);
}
if (cardsets[i].transcriptBonus.minimumSubmissions === undefined) {
Cardsets.update({
_id: cardsets[i]._id
},
{
$set: {
"transcriptBonus.minimumSubmissions": cardsets[i].transcriptBonus.dates.length
}
}
);
}
if (cardsets[i].transcriptBonus.stats === undefined) {
Meteor.call('updateTranscriptBonusStats', cardsets[i]._id);
}
......
......@@ -16,6 +16,7 @@
{{> cardsetInfoBoxItemTranscriptParticipants}}
{{> cardsetInfoBoxItemTranscriptSubmissions}}
{{> cardsetInfoBoxItemTranscriptMedian}}
{{> cardsetInfoBoxItemTranscriptMinimumSubmissions}}
</tbody>
</table>
</div>
......
......@@ -10,6 +10,7 @@ import "./item/transcript/lectureEnd.js";
import "./item/transcript/participants.js";
import "./item/transcript/submissions.js";
import "./item/transcript/median.js";
import "./item/transcript/minimumSubmissions.js";
import "./bonusTranscript.html";
/*
......
<template name="cardsetInfoBoxItemTranscriptMinimumSubmissions">
<tr>
<td>{{_ "transcriptForm.bonus.form.minimum"}}:</td>
<td>{{getMinimumSubmissions this}}</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import "./minimumSubmissions.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptMinimumSubmissions
* ############################################################################
*/
Template.cardsetInfoBoxItemTranscriptMinimumSubmissions.helpers({
getMinimumSubmissions: function (cardset) {
if (cardset.transcriptBonus !== undefined) {
return cardset.transcriptBonus.minimumSubmissions;
}
}
});
......@@ -32,29 +32,29 @@
<div class="col-xs-12">
<h2 id="transcriptBonusTitle" class="modal-title">{{_ "transcriptForm.bonus.form.title"}}</h2>
</div>
<div class="col-sm-6 col-md-3">
<div class="col-xs12 col-sm-6">
<label>{{_ "transcriptForm.bonus.form.enable"}}:</label>
<input type="checkbox" id="enableBonus">
</div>
<div class="col-sm-6 col-md-3">
<br>
<label>{{_ "transcriptForm.bonus.form.percentage"}}:</label>
<input type="number" id="bonusPercentage" min="1" max="10" step="1" value="10" required>
<span class="unit">%</span>
<br>
<label>{{_ "transcriptForm.bonus.form.minimum"}}:</label>
<input type="number" id="bonusMinimumSubmissions" min="0" max="10" step="1" value="0" required>
</div>
<div class="col-sm-6 col-md-3">
<label>{{_ "transcriptForm.bonus.form.lectureTimeEnd"}}:</label>
<input type="time" id="lectureTimeEnd" min="00:00" max="24:00" step="60" value="08:00" required>
<span class="unit">{{_ "transcriptForm.bonus.form.clock"}}</span>
</div>
<div class="col-sm-6 col-md-3">
<div class="col-xs12 col-sm-6">
<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">
<br>
<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>
<br>
<label>{{_ "transcriptForm.bonus.form.lectureTimeEnd"}}:</label>
<input type="time" id="lectureTimeEnd" min="00:00" max="24:00" step="60" value="08:00" required>
<span class="unit">{{_ "transcriptForm.bonus.form.clock"}}</span>
</div>
<div class="col-xs-12">
<br>
......
......@@ -41,11 +41,12 @@ Template.cardsetTranscript.events({
let deadlineEditing = $('#deadlineHoursEditing').val();
let deadlineSubmission = $('#deadlineHoursSubmission').val();
let dates = $('#transcript-calendar').multiDatesPicker('getDates');
let minimumSubmissions = $('#bonusMinimumSubmissions').val();
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(deadlineSubmission), Number(deadlineEditing), newDates, function (error, result) {
Meteor.call('updateCardsetTranscriptBonus', Router.current().params._id, Boolean(isEnabled), Number(percentage), lectureEnd, Number(deadlineSubmission), Number(deadlineEditing), newDates, Number(minimumSubmissions), function (error, result) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('transcriptForm.bonus.form.alert.save'), "success", 'growl-top-left');
}
......@@ -67,6 +68,7 @@ Template.cardsetTranscriptEditor.onRendered(function () {
$('#lectureTimeEnd').val(this.data.transcriptBonus.lectureEnd);
$('#deadlineHoursSubmission').val(this.data.transcriptBonus.deadline);
$('#deadlineHoursEditing').val(this.data.transcriptBonus.deadlineEditing);
$('#bonusMinimumSubmissions').val(this.data.transcriptBonus.minimumSubmissions);
for (let d = 0; d < this.data.transcriptBonus.dates.length; d++) {
dates.push(moment(this.data.transcriptBonus.dates[d]).format("MM/DD/YYYY"));
}
......@@ -85,6 +87,21 @@ Template.cardsetTranscriptEditor.onRendered(function () {
firstDay: 1
});
}
let minimumSubmissions = $('#bonusMinimumSubmissions').val();
$('#bonusMinimumSubmissions').attr("max", dates.length);
if (minimumSubmissions > dates.length) {
$('#bonusMinimumSubmissions').val(dates.length);
}
$('#transcript-calendar').multiDatesPicker({
onSelect: function () {
let dates = $('#transcript-calendar').multiDatesPicker('getDates');
let minimumSubmissions = $('#bonusMinimumSubmissions').val();
$('#bonusMinimumSubmissions').attr("max", dates.length);
if (minimumSubmissions > dates.length) {
$('#bonusMinimumSubmissions').val(dates.length);
}
}
});
});
/*
......
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