Commit 1a60cc56 authored by Curtis Adam's avatar Curtis Adam

Add a statistics view for the transcript bonus

parent 6c2d3c17
...@@ -725,11 +725,16 @@ ...@@ -725,11 +725,16 @@
"cancel": "Zurück zur Kartei", "cancel": "Zurück zur Kartei",
"cancelRepetitorium": "Zrück zum Repetitorium", "cancelRepetitorium": "Zrück zum Repetitorium",
"settings": "Einstellungen", "settings": "Einstellungen",
"list": "Abgaben" "list": "Abgaben",
"statistics": "Übersicht"
}, },
"alert": { "alert": {
"save": "Änderungen wurden erfolgreich gespeichert" "save": "Änderungen wurden erfolgreich gespeichert"
} }
},
"statistics": {
"count": "Eingereichte Mitschriften",
"lastSubmission": "Letzte Abgabe"
} }
} }
}, },
......
...@@ -727,11 +727,16 @@ ...@@ -727,11 +727,16 @@
"cancel": "Zurück zur Kartei", "cancel": "Zurück zur Kartei",
"cancelRepetitorium": "Zrück zum Repetitorium", "cancelRepetitorium": "Zrück zum Repetitorium",
"settings": "Einstellungen für die Bonusvergabe", "settings": "Einstellungen für die Bonusvergabe",
"list": "Gekoppelte Abgaben für die Bonusvergabe" "list": "Gekoppelte Abgaben für die Bonusvergabe",
"statistics": "Übersicht"
}, },
"alert": { "alert": {
"save": "Änderungen wurden erfolgreich gespeichert" "save": "Änderungen wurden erfolgreich gespeichert"
} }
},
"statistics": {
"count": "Eingereichte Mitschriften",
"lastSubmission": "Letzte Abgabe"
} }
} }
}, },
......
...@@ -158,8 +158,13 @@ export let TranscriptBonusList = class TranscriptBonusList { ...@@ -158,8 +158,13 @@ export let TranscriptBonusList = class TranscriptBonusList {
} }
} }
static getLectureName (transcriptBonus) { static getLectureName (transcriptBonus, addLectureName = true) {
return transcriptBonus.name + ": " + this.getLectureEnd(transcriptBonus, transcriptBonus.date, false); let name = "";
if (addLectureName) {
name += transcriptBonus.name + ": ";
}
name += this.getLectureEnd(transcriptBonus, transcriptBonus.date, false);
return name;
} }
static getLectureEnd (transcriptBonus, date_id) { static getLectureEnd (transcriptBonus, date_id) {
......
<template name="cardsetTranscriptSettings">
<div class="col-xs-12">
<h2 id="transcriptBonusTitle" class="modal-title">{{_ "transcriptForm.bonus.form.title"}}</h2>
</div>
<div class="col-xs12 col-sm-6">
<label>{{_ "transcriptForm.bonus.form.enable"}}:</label>
<input type="checkbox" id="enableBonus">
<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-xs12 col-sm-6">
<label>{{_ "transcriptForm.bonus.form.deadline.submission"}}:</label>
<input type="number" id="deadlineHoursSubmission" min="1" max="48" step="1" value="2" required>
<span class="unit">{{_ "transcriptForm.bonus.form.hours_plural"}}</span>
<br>
<label>{{_ "transcriptForm.bonus.form.deadline.editing"}}:</label>
<input type="number" id="deadlineHoursEditing" min="48" max="168" step="12" value="36" required>
<span class="unit">{{_ "transcriptForm.bonus.form.hours_plural"}}</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>
<label>{{_ "transcriptForm.bonus.form.lectureDates"}}:</label>
<div id="transcript-calendar"></div>
</div>
</template>
<template name="cardsetTranscriptSettingsCancel">
<div id="transcript-bonus-cancel" class="btn btn-raised btn-danger pull-left">
<span class="flex-content">
{{#if isShuffledCardset this._id}}
{{_ "transcriptForm.bonus.form.button.cancelRepetitorium"}}
{{else}}
{{_ "transcriptForm.bonus.form.button.cancel"}}
{{/if}}
</span>
</div>
</template>
\ No newline at end of file
import "./settings.html";
import {Template} from "meteor/templating";
/*
* ############################################################################
* cardsetTranscriptSettings
* ############################################################################
*/
Template.cardsetTranscriptSettings.onRendered(function () {
let dates = [];
if (this.data.transcriptBonus !== undefined) {
$('#enableBonus').prop('checked', this.data.transcriptBonus.enabled);
$('#bonusPercentage').val(this.data.transcriptBonus.percentage);
$('#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"));
}
}
if (dates.length) {
$('#transcript-calendar').multiDatesPicker({
addDates: dates,
numberOfMonths: [1, 6]
});
} else {
$('#transcript-calendar').multiDatesPicker({
numberOfMonths: [1, 6]
});
}
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);
}
}
});
});
<template name="cardsetTranscriptStatistics">
{{#each transcriptBonusUser}}
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 transcriptBonusUserStatistic">
<table class="table table-dark">
<thead>
<tr>
<th colspan="2">
{{getAuthorName this._id}}
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
{{_ "transcriptForm.bonus.statistics.count"}}:
</td>
<td>
{{getSubmissions this._id}}
</td>
</tr>
<tr>
<td>
{{_ "transcriptForm.bonus.statistics.lastSubmission"}}:
</td>
<td>
{{lastSubmission this._id}}
</td>
</tr>
</tbody>
</table>
</div>
{{/each}}
</template>
import "./statistics.html";
import {TranscriptBonus, TranscriptBonusList} from "../../../../api/transcriptBonus";
import {Template} from "meteor/templating";
/*
* ############################################################################
* cardsetTranscriptStatistics
* ############################################################################
*/
Template.cardsetTranscriptStatistics.helpers({
transcriptBonusUser: function () {
let transcriptBonusUsers = _.uniq(TranscriptBonus.find({cardset_id: Router.current().params._id}, {
fields: {user_id: 1}
}).fetch().map(function (x) {
return x.user_id;
}), true);
return Meteor.users.find({_id: {$in: transcriptBonusUsers}}, {sort: {"profile.birthname": 1}, fields: {_id: 1}}).fetch();
},
getSubmissions: function (id) {
return TranscriptBonus.find({cardset_id: Router.current().params._id, user_id: id}).count();
},
lastSubmission: function (id) {
let bonusTranscript = TranscriptBonus.findOne({user_id: id}, {sort: {date: -1}});
if (bonusTranscript !== undefined) {
return TranscriptBonusList.getLectureName(bonusTranscript, false);
}
}
});
<template name="cardsetTranscript"> <template name="cardsetTranscript">
<div class="transcriptBonus"> <div class="transcriptBonus">
<div class="col-xs-6"> <div class="col-xs-12 col-sm-4">
<div id="showTranscriptSettings" class="btn btn-raised btn-block btn-primary"> <div id="showTranscriptSettings" class="btn btn-raised btn-block btn-primary">
<span class="flex-content"> <span class="flex-content">
{{_ "transcriptForm.bonus.form.button.settings"}} {{_ "transcriptForm.bonus.form.button.settings"}}
</span> </span>
</div> </div>
</div> </div>
<div class="col-xs-6"> <div class="col-xs-12 col-sm-4">
<div id="showTranscriptList" class="btn btn-raised btn-block btn-primary btn-primary"> <div id="showTranscriptList" class="btn btn-raised btn-block btn-primary btn-primary">
<span class="flex-content"> <span class="flex-content">
{{_ "transcriptForm.bonus.form.button.list"}} {{_ "transcriptForm.bonus.form.button.list"}}
</span> </span>
</div> </div>
</div> </div>
<div class="col-xs-12 col-sm-4">
<div id="showTranscriptStatistics" class="btn btn-raised btn-block btn-primary btn-primary">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.statistics"}}
</span>
</div>
</div>
<br> <br>
{{#if isEditViewActive}} {{#if isViewActive 0}}
{{> cardsetTranscriptEditor}} {{> cardsetTranscriptSettings}}
{{else if isViewActive 1}}
{{> cardsetTranscriptStatistics}}
{{else}} {{else}}
{{> filterIndexTranscripts}} {{> filterIndexTranscripts}}
<div class="col-xs-12">
<br>
<br>
{{> cardsetTranscriptEditorCancel}}
</div>
{{/if}} {{/if}}
</div> <div class="col-xs-12">
</template> {{> cardsetTranscriptSettingsCancel}}
{{#if isViewActive 0}}
<template name="cardsetTranscriptEditor"> <div id="transcript-bonus-save" class="btn btn-raised btn-success pull-right">
<div class="col-xs-12">
<h2 id="transcriptBonusTitle" class="modal-title">{{_ "transcriptForm.bonus.form.title"}}</h2>
</div>
<div class="col-xs12 col-sm-6">
<label>{{_ "transcriptForm.bonus.form.enable"}}:</label>
<input type="checkbox" id="enableBonus">
<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-xs12 col-sm-6">
<label>{{_ "transcriptForm.bonus.form.deadline.submission"}}:</label>
<input type="number" id="deadlineHoursSubmission" min="1" max="48" step="1" value="2" required>
<span class="unit">{{_ "transcriptForm.bonus.form.hours_plural"}}</span>
<br>
<label>{{_ "transcriptForm.bonus.form.deadline.editing"}}:</label>
<input type="number" id="deadlineHoursEditing" min="48" max="168" step="12" value="36" required>
<span class="unit">{{_ "transcriptForm.bonus.form.hours_plural"}}</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>
<label>{{_ "transcriptForm.bonus.form.lectureDates"}}:</label>
<div id="transcript-calendar"></div>
</div>
<div class="col-xs-12">
{{> cardsetTranscriptEditorCancel}}
<div id="transcript-bonus-save" class="btn btn-raised btn-success pull-right">
<span class="flex-content"> <span class="flex-content">
{{_ "transcriptForm.bonus.form.button.save"}} {{_ "transcriptForm.bonus.form.button.save"}}
</span> </span>
</div> </div>
</div>
</template>
<template name="cardsetTranscriptEditorCancel">
<div id="transcript-bonus-cancel" class="btn btn-raised btn-danger pull-left">
<span class="flex-content">
{{#if isShuffledCardset this._id}}
{{_ "transcriptForm.bonus.form.button.cancelRepetitorium"}}
{{else}}
{{_ "transcriptForm.bonus.form.button.cancel"}}
{{/if}} {{/if}}
</span> </div>
</div> </div>
</template> </template>
import "./transcript.html"; import "./transcript.html";
import "./pages/settings.js";
import "./pages/statistics.js";
import {Template} from "meteor/templating"; import {Template} from "meteor/templating";
import {Session} from "meteor/session"; import {Session} from "meteor/session";
import {Meteor} from "meteor/meteor"; import {Meteor} from "meteor/meteor";
import {Bonus} from "../../../api/bonus"; import {Bonus} from "../../../api/bonus";
import {BertAlertVisuals} from "../../../api/bertAlertVisuals"; import {BertAlertVisuals} from "../../../api/bertAlertVisuals";
Session.setDefault('transcriptViewingMode', 1); Session.setDefault('transcriptViewingMode', 0);
/* /*
* ############################################################################ * ############################################################################
...@@ -14,8 +16,8 @@ Session.setDefault('transcriptViewingMode', 1); ...@@ -14,8 +16,8 @@ Session.setDefault('transcriptViewingMode', 1);
*/ */
Template.cardsetTranscript.helpers({ Template.cardsetTranscript.helpers({
isEditViewActive: function () { isViewActive: function (id) {
return Session.get('transcriptViewingMode') === 0; return Session.get('transcriptViewingMode') === id;
}, },
isInBonus: function () { isInBonus: function () {
return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId()); return Bonus.isInBonus(Session.get('activeCardset')._id, Meteor.userId());
...@@ -24,6 +26,9 @@ Template.cardsetTranscript.helpers({ ...@@ -24,6 +26,9 @@ Template.cardsetTranscript.helpers({
Template.cardsetTranscript.events({ Template.cardsetTranscript.events({
'click #showTranscriptList': function () { 'click #showTranscriptList': function () {
Session.set('transcriptViewingMode', 2);
},
'click #showTranscriptStatistics': function () {
Session.set('transcriptViewingMode', 1); Session.set('transcriptViewingMode', 1);
}, },
'click #showTranscriptSettings': function () { 'click #showTranscriptSettings': function () {
...@@ -53,63 +58,3 @@ Template.cardsetTranscript.events({ ...@@ -53,63 +58,3 @@ Template.cardsetTranscript.events({
}); });
} }
}); });
/*
* ############################################################################
* cardsetTranscriptEditor
* ############################################################################
*/
Template.cardsetTranscriptEditor.onRendered(function () {
let dates = [];
if (this.data.transcriptBonus !== undefined) {
$('#enableBonus').prop('checked', this.data.transcriptBonus.enabled);
$('#bonusPercentage').val(this.data.transcriptBonus.percentage);
$('#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"));
}
}
if (dates.length) {
$('#transcript-calendar').multiDatesPicker({
addDates: dates,
numberOfMonths: [1, 6]
});
} else {
$('#transcript-calendar').multiDatesPicker({
numberOfMonths: [1, 6]
});
}
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);
}
}
});
});
/*
* ############################################################################
* cardsetTranscriptEditorCancel
* ############################################################################
*/
Template.cardsetTranscriptEditorCancel.events({
'click #transcript-bonus-cancel': function () {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}
});
...@@ -36,5 +36,17 @@ ...@@ -36,5 +36,17 @@
} }
} }
} }
.transcriptBonusUserStatistic {
padding: 5px 15px;
table {
th {
font-size: 16px;
}
padding: 15px;
background-color: white;
border-radius: 15px;
}
}
} }
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