Commit 44d50278 authored by Curtis Adam's avatar Curtis Adam

Transcript bonus info: Add participants, submissions and median

parent 8ce0c18f
...@@ -645,6 +645,9 @@ ...@@ -645,6 +645,9 @@
"transcriptForm": { "transcriptForm": {
"info": { "info": {
"title": "Über die Bonusschreibphase", "title": "Über die Bonusschreibphase",
"participants": "Anzahl der Teilnehmer am Bonusverfahren",
"submissions": "Anzahl aller eingereichten Mitschriften",
"median": "Durchschnittliche Anzahl der Mitschriften pro Teilnehmer",
"tooltip": { "tooltip": {
"lecture": { "lecture": {
"past": "Der Termin für die Abgabe ist bereits abgelaufen.", "past": "Der Termin für die Abgabe ist bereits abgelaufen.",
......
...@@ -648,6 +648,9 @@ ...@@ -648,6 +648,9 @@
"transcriptForm": { "transcriptForm": {
"info": { "info": {
"title": "About the Bonus Writing Phase", "title": "About the Bonus Writing Phase",
"participants": "Number of participants in the bonus procedure",
"submissions": "Number of all submitted transcripts",
"median": "Average number of transcripts per participant",
"tooltip": { "tooltip": {
"lecture": { "lecture": {
"past": "Der Termin für die Abgabe ist bereits abgelaufen.", "past": "Der Termin für die Abgabe ist bereits abgelaufen.",
......
...@@ -5,6 +5,7 @@ import {UserPermissions} from "./permissions"; ...@@ -5,6 +5,7 @@ import {UserPermissions} from "./permissions";
import {SimpleSchema} from "meteor/aldeed:simple-schema"; import {SimpleSchema} from "meteor/aldeed:simple-schema";
import {check} from "meteor/check"; import {check} from "meteor/check";
import {Utilities} from "./utilities"; import {Utilities} from "./utilities";
import * as config from "../config/transcriptBonus.js";
export const TranscriptBonus = new Mongo.Collection("transcriptBonus"); export const TranscriptBonus = new Mongo.Collection("transcriptBonus");
...@@ -79,6 +80,28 @@ Meteor.methods({ ...@@ -79,6 +80,28 @@ Meteor.methods({
} }
}); });
} }
Meteor.call('updateTranscriptBonusStats', cardset._id);
}
},
updateTranscriptBonusStats: function (cardset_id) {
if (Meteor.isServer) {
check(cardset_id, String);
let cardset = Cardsets.findOne({_id: cardset_id});
if (cardset !== undefined && cardset.transcriptBonus !== undefined) {
let bonusTranscripts = TranscriptBonus.find({cardset_id: cardset._id}).fetch();
let submissions = TranscriptBonus.find({cardset_id: cardset._id}).count();
let userFilter = [];
for (let i = 0; i < bonusTranscripts.length; i++) {
userFilter.push(bonusTranscripts[i].user_id);
}
let participants = Meteor.users.find({_id: {$in: userFilter}}).count();
Cardsets.update({_id: cardset._id}, {
$set: {
'transcriptBonus.stats.submissions': submissions,
'transcriptBonus.stats.participants': participants
}
});
}
} }
} }
}); });
...@@ -161,4 +184,12 @@ export let TranscriptBonusList = class TranscriptBonusList { ...@@ -161,4 +184,12 @@ export let TranscriptBonusList = class TranscriptBonusList {
return TAPi18n.__('transcriptForm.deadline.editing') + ": " + Utilities.getMomentsDate(deadlineEditing, true, true); return TAPi18n.__('transcriptForm.deadline.editing') + ": " + Utilities.getMomentsDate(deadlineEditing, true, true);
} }
} }
static transformMedian (median) {
if (config.roundTheMedian) {
return Math.round(median);
} else {
return median.toFixed(2);
}
}
}; };
...@@ -45,6 +45,7 @@ export let Utilities = class Utilities { ...@@ -45,6 +45,7 @@ export let Utilities = class Utilities {
minutes = "H:mm"; minutes = "H:mm";
} }
if (!transformToSpeech) { if (!transformToSpeech) {
dateFormat = "D. MMMM";
return moment(date).locale(Session.get('activeLanguage')).calendar(null, { return moment(date).locale(Session.get('activeLanguage')).calendar(null, {
sameDay: dateFormat, sameDay: dateFormat,
lastDay: dateFormat, lastDay: dateFormat,
......
let roundTheMedian = false;
module.exports = {
roundTheMedian
};
...@@ -814,6 +814,9 @@ Meteor.startup(function () { ...@@ -814,6 +814,9 @@ Meteor.startup(function () {
} }
); );
} }
if (cardsets[i].transcriptBonus.stats === undefined) {
Meteor.call('updateTranscriptBonusStats', cardsets[i]._id);
}
} }
let transcriptBonus = TranscriptBonus.find({deadlineEditing: {$exists: false}}, {fields: {_id: 1, deadline: 1}}).fetch(); let transcriptBonus = TranscriptBonus.find({deadlineEditing: {$exists: false}}, {fields: {_id: 1, deadline: 1}}).fetch();
......
...@@ -580,7 +580,6 @@ th .field-tip { ...@@ -580,7 +580,6 @@ th .field-tip {
} }
.bonusTranscriptInfoLectureDates { .bonusTranscriptInfoLectureDates {
text-align: right;
.active, .past, .future { .active, .past, .future {
display: block; display: block;
width: 100%; width: 100%;
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
{{> cardsetInfoBoxItemTranscriptLectureEnd}} {{> cardsetInfoBoxItemTranscriptLectureEnd}}
{{> cardsetInfoBoxItemTranscriptSubmissionDeadline}} {{> cardsetInfoBoxItemTranscriptSubmissionDeadline}}
{{> cardsetInfoBoxItemTranscriptEditDeadline}} {{> cardsetInfoBoxItemTranscriptEditDeadline}}
{{> cardsetInfoBoxItemTranscriptParticipants}}
{{> cardsetInfoBoxItemTranscriptSubmissions}}
{{> cardsetInfoBoxItemTranscriptMedian}}
</tbody> </tbody>
</table> </table>
</div> </div>
......
...@@ -7,6 +7,9 @@ import "./item/transcript/editDeadline.js"; ...@@ -7,6 +7,9 @@ import "./item/transcript/editDeadline.js";
import "./item/transcript/lectureDates.js"; import "./item/transcript/lectureDates.js";
import "./item/transcript/submissionDeadline.js"; import "./item/transcript/submissionDeadline.js";
import "./item/transcript/lectureEnd.js"; import "./item/transcript/lectureEnd.js";
import "./item/transcript/participants.js";
import "./item/transcript/submissions.js";
import "./item/transcript/median.js";
import "./bonusTranscript.html"; import "./bonusTranscript.html";
/* /*
......
<template name="cardsetInfoBoxItemTranscriptMedian">
<tr>
<td>{{_ "transcriptForm.info.median"}}:</td>
<td>{{getMedian this}}</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import {TranscriptBonusList} from "../../../../../../api/transcriptBonus";
import "./median.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptMedian
* ############################################################################
*/
Template.cardsetInfoBoxItemTranscriptMedian.helpers({
getMedian: function (cardset) {
if (cardset.transcriptBonus !== undefined && cardset.transcriptBonus.stats !== undefined) {
return TranscriptBonusList.transformMedian(cardset.transcriptBonus.stats.submissions / cardset.transcriptBonus.stats.participants);
}
}
});
<template name="cardsetInfoBoxItemTranscriptParticipants">
<tr>
<td>{{_ "transcriptForm.info.participants"}}:</td>
<td>{{getParticipants this}}</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import "./participants.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptParticipants
* ############################################################################
*/
Template.cardsetInfoBoxItemTranscriptParticipants.helpers({
getParticipants: function (cardset) {
if (cardset.transcriptBonus !== undefined && cardset.transcriptBonus.stats !== undefined) {
return cardset.transcriptBonus.stats.participants;
}
}
});
<template name="cardsetInfoBoxItemTranscriptSubmissions">
<tr>
<td>{{_ "transcriptForm.info.submissions"}}:</td>
<td>{{getSubmissions this}}</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import "./submissions.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptSubmissions
* ############################################################################
*/
Template.cardsetInfoBoxItemTranscriptSubmissions.helpers({
getSubmissions: function (cardset) {
if (cardset.transcriptBonus !== undefined && cardset.transcriptBonus.stats !== undefined) {
return cardset.transcriptBonus.stats.submissions;
}
}
});
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