Commit de5974b0 authored by Curtis Adam's avatar Curtis Adam

Merge branch '250-implement-an-info-drop-down-menu-about-the-bonus-writing-phase' into 'staging'

Resolve "Implement an info drop-down menu "About the Bonus Writing Phase""

Closes #250

See merge request arsnova/cards!559
parents b69c5416 5ea7eba4
......@@ -549,6 +549,21 @@ $themes: (
//transcript bonus colors
$transcript_bonus_info_text: map-get($map, "transcript_bonus_info_text");
$transcript_bonus_info_background: map-get($map, "transcript_bonus_info_background");
$transcript_bonus_info_lecture_date_year_text: map-get($map, "transcript_bonus_info_lecture_date_year_text");
$transcript_bonus_info_lecture_date_year_background: map-get($map, "transcript_bonus_info_lecture_date_year_background");
$transcript_bonus_info_lecture_date_month_text: map-get($map, "transcript_bonus_info_lecture_date_month_text");
$transcript_bonus_info_lecture_date_month_background: map-get($map, "transcript_bonus_info_lecture_date_month_background");
$transcript_bonus_info_lecture_date_day_border: map-get($map, "transcript_bonus_info_lecture_date_day_border");
$transcript_bonus_info_lecture_date_day_past_text: map-get($map, "transcript_bonus_info_lecture_date_day_past_text");
$transcript_bonus_info_lecture_date_day_past_background: map-get($map, "transcript_bonus_info_lecture_date_day_past_background");
$transcript_bonus_info_lecture_date_day_active_text: map-get($map, "transcript_bonus_info_lecture_date_day_active_text");
$transcript_bonus_info_lecture_date_day_active_background: map-get($map, "transcript_bonus_info_lecture_date_day_active_background");
$transcript_bonus_info_lecture_date_day_future_text: map-get($map, "transcript_bonus_info_lecture_date_day_future_text");
$transcript_bonus_info_lecture_date_day_future_background: map-get($map, "transcript_bonus_info_lecture_date_day_future_background");
$transcript_bonus_info_lecture_date_day_hover_text: map-get($map, "transcript_bonus_info_lecture_date_day_hover_text");
$transcript_bonus_info_lecture_date_day_hover_background: map-get($map, "transcript_bonus_info_lecture_date_day_hover_background");
$transcript_bonus_submission_count_badge_text: map-get($map, "transcript_bonus_submission_count_badge_text");
$transcript_bonus_submission_count_badge_background: map-get($map, "transcript_bonus_submission_count_badge_background");
//markdeep editor colors
$markdeep_help_text: map-get($map, "markdeep_help_text");
$markdeep_help_background: map-get($map, "markdeep_help_background");
......@@ -1620,11 +1635,16 @@ $themes: (
}
#collapseLearningPhaseInfoButton, #collapseManageButton {
background-color: $bonus_background ;
background-color: $bonus_background;
color: $bonus_text;
}
#collapseLearningPhaseInfoButton:hover i, #collapseLearningPhaseInfoButton:focus i, #collapseManageButton:hover i, #collapseManageButton:focus i, #collapseCardsetInfoButton:hover i, #collapseCardsetInfoButton:focus i {
#collapseBonusTranscriptInfoButton {
background-color: $transcript_bonus_info_background;
color: $transcript_bonus_info_text;
}
#collapseLearningPhaseInfoButton:hover i, #collapseLearningPhaseInfoButton:focus i, #collapseManageButton:hover i, #collapseManageButton:focus i, #collapseCardsetInfoButton:hover i, #collapseCardsetInfoButton:focus i, #collapseBonusTranscriptInfoButton:hover i, #collapseBonusTranscriptInfoButton:focus i {
color: $item_icon_hover !important;
}
......@@ -1674,6 +1694,11 @@ $themes: (
color: $primary !important;
}
.cardset-list-badge-transcript {
color: $transcript_bonus_submission_count_badge_text !important;
background-color: $transcript_bonus_submission_count_badge_background !important;
}
//navbar
//navbar all
......@@ -3031,6 +3056,36 @@ $themes: (
color: $transcript_bonus_info_text !important;
background-color: $transcript_bonus_info_background !important;
}
.bonusTranscriptInfoLectureDates {
.year {
color: $transcript_bonus_info_lecture_date_year_text !important;
background-color: $transcript_bonus_info_lecture_date_year_background !important;
}
.month {
color: $transcript_bonus_info_lecture_date_month_text !important;
background-color: $transcript_bonus_info_lecture_date_month_background !important;
}
.day {
border-color: $transcript_bonus_info_lecture_date_day_border !important;
}
.past {
color: $transcript_bonus_info_lecture_date_day_past_text !important;
background-color: $transcript_bonus_info_lecture_date_day_past_background !important;
}
.active {
color: $transcript_bonus_info_lecture_date_day_active_text !important;
background-color: $transcript_bonus_info_lecture_date_day_active_background !important;
}
.future {
color: $transcript_bonus_info_lecture_date_day_future_text !important;
background-color: $transcript_bonus_info_lecture_date_day_future_background !important;
}
.past:hover, .active:hover, .future:hover {
color: $transcript_bonus_info_lecture_date_day_hover_text !important;
background-color: $transcript_bonus_info_lecture_date_day_hover_background !important;
}
}
//presentation colors
.clock {
.circle {
......
......@@ -591,6 +591,21 @@
//transcript bonus colors
"transcript_bonus_info_text": white,
"transcript_bonus_info_background": $thm_red,
"transcript_bonus_info_lecture_date_year_text": white,
"transcript_bonus_info_lecture_date_year_background": $thm_orange,
"transcript_bonus_info_lecture_date_month_text": white,
"transcript_bonus_info_lecture_date_month_background": $thm_gray,
"transcript_bonus_info_lecture_date_day_border": white,
"transcript_bonus_info_lecture_date_day_past_text": white,
"transcript_bonus_info_lecture_date_day_past_background": rgba($thm_red, 0.5),
"transcript_bonus_info_lecture_date_day_active_text": white,
"transcript_bonus_info_lecture_date_day_active_background": $thm_green,
"transcript_bonus_info_lecture_date_day_future_text": white,
"transcript_bonus_info_lecture_date_day_future_background": rgba($thm_gray, 0.5),
"transcript_bonus_info_lecture_date_day_hover_text": black,
"transcript_bonus_info_lecture_date_day_hover_background": LightGoldenRodYellow,
"transcript_bonus_submission_count_badge_text": white,
"transcript_bonus_submission_count_badge_background": $thm_orange,
//markdeep editor colors
"markdeep_help_text": $white,
"markdeep_help_background": $thm_orange,
......
......@@ -643,6 +643,19 @@
}
},
"transcriptForm": {
"info": {
"title": "Über die Bonusschreibphase",
"participants": "Anzahl der Teilnehmer am Bonusverfahren",
"submissions": "Anzahl aller eingereichten Mitschriften",
"median": "Durchschnittliche Anzahl der Mitschriften pro Teilnehmer",
"tooltip": {
"lecture": {
"past": "Der Termin für die Foto-Abgabefrist ist bereits abgelaufen.",
"active": "Der Termin für die Foto-Abgabefrist ist momentan aktiv.",
"future": "Der Termin für die Foto-Abgabefrist wurde noch nicht freigeschaltet."
}
}
},
"index": {
"create": "Mitschrift anlegen",
"topic": "Thema der Mitschrift",
......@@ -689,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",
......@@ -696,7 +710,8 @@
},
"lectureDates": "Termine für das Bonus-Mitschreiben",
"clock": "Uhr",
"hours": "Stunden",
"hours": "Stunde",
"hours_plural": "Stunden",
"button": {
"save": "Speichern",
"cancel": "Zurück zur Kartei",
......
......@@ -646,6 +646,19 @@
}
},
"transcriptForm": {
"info": {
"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": {
"lecture": {
"past": "Der Termin für die Foto-Abgabefrist ist bereits abgelaufen.",
"active": "Der Termin für die Foto-Abgabefrist ist momentan aktiv.",
"future": "Der Termin für die Foto-Abgabefrist wurde noch nicht freigeschaltet."
}
}
},
"index": {
"create": "Mitschrift erstellen",
"topic": "Thema der Mitschrift",
......@@ -691,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",
......@@ -698,7 +712,8 @@
},
"lectureDates": "Termine der Veranstaltungen",
"clock": "Uhr",
"hours": "Stunden",
"hours": "Stunde",
"hours_plural": "Stunden",
"button": {
"save": "Speichern",
"cancel": "Zurück zur Kartei",
......
......@@ -390,7 +390,9 @@ Meteor.methods({
let card = Cards.findOne(card_id);
if (card.owner === Meteor.userId() || UserPermissions.isAdmin()) {
let result = Cards.remove(card_id);
let transcriptBonus = TranscriptBonus.findOne({card_id: card_id});
TranscriptBonus.remove({card_id: card_id});
Meteor.call('updateTranscriptBonusStats', transcriptBonus.cardset_id);
Meteor.call('updateTranscriptCount', Meteor.userId());
return result;
}
......
......@@ -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;
......
......@@ -5,6 +5,7 @@ import {UserPermissions} from "./permissions";
import {SimpleSchema} from "meteor/aldeed:simple-schema";
import {check} from "meteor/check";
import {Utilities} from "./utilities";
import * as config from "../config/transcriptBonus.js";
export const TranscriptBonus = new Mongo.Collection("transcriptBonus");
......@@ -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,15 @@ export let TranscriptBonusList = class TranscriptBonusList {
return TAPi18n.__('transcriptForm.deadline.editing') + ": " + Utilities.getMomentsDate(deadlineEditing, true, true);
}
}
static transformMedian (median) {
if (isNaN(median)) {
return 0;
}
if (config.roundTheMedian) {
return Math.round(median);
} else {
return median.toFixed(2);
}
}
};
......@@ -9,6 +9,8 @@ import {WebPushSubscriptions} from "./webPushSubscriptions";
import {Paid} from "./paid";
import {ServerStyle} from "./styles";
import {TranscriptBonus} from "./transcriptBonus";
import {Utilities} from "./utilities";
import {CardType} from "./cardTypes";
/**
* Returns the degree, the givenname and the birthname from the author of a cardset
......@@ -495,7 +497,22 @@ Meteor.methods({
Paid.remove({
user_id: user_id
});
Cards.remove({
user_id: user_id,
cardType: {$in: CardType.getCardTypesWithTranscriptBonus()}
});
let transcriptBonus = TranscriptBonus.find({user_id: user_id}, {fields: {cardset_id: 1}}).fetch();
if (transcriptBonus !== undefined) {
TranscriptBonus.remove({
user_id: user_id
});
let cardsetsValues = Utilities.getUniqData(transcriptBonus, 'cardset_id');
for (let i = 0; cardsetsValues.length; i++) {
if (cardsetsValues[i] !== undefined) {
Meteor.call('updateTranscriptBonusStats', cardsetsValues[i]);
}
}
}
Meteor.users.remove(user_id);
},
removeFirstLogin: function () {
......
......@@ -37,13 +37,24 @@ export let Utilities = class Utilities {
}
}
static getMomentsDate (date, displayMinutes = false, displayAsDeadline = false) {
static getMomentsDate (date, displayMinutes = false, displayAsDeadline = false, transformToSpeech = true) {
let minutes = "";
let dateFormat = "D. MMMM YYYY";
if (displayMinutes === true) {
dateFormat = "D. MMM YY " + minutes;
minutes = "H:mm";
}
if (!transformToSpeech) {
dateFormat = "DD";
return moment(date).locale(Session.get('activeLanguage')).calendar(null, {
sameDay: dateFormat,
lastDay: dateFormat,
nextDay: dateFormat,
nextWeek: dateFormat,
lastWeek: dateFormat,
sameElse: dateFormat
});
}
if (displayAsDeadline) {
return moment(date).locale(Session.get('activeLanguage')).calendar(null, {
sameDay: this.getCalendarString("today", minutes, displayAsDeadline),
......@@ -78,4 +89,11 @@ export let Utilities = class Utilities {
sameElse: 'D.MMM YY'
});
}
static getUniqData (data, key) {
let distinctArray = _.uniq(data, false, function (item) {
return item[key];
});
return _.pluck(distinctArray, key);
}
};
let roundTheMedian = true;
module.exports = {
roundTheMedian
};
......@@ -28,6 +28,7 @@ import * as FilterConfig from "../../config/filter.js";
import {MainNavigation} from "../../api/mainNavigation";
import {BarfyStarsConfig} from "../../api/barfyStars.js";
import {Utilities} from "../../api/utilities";
import {TranscriptBonus} from "../../api/transcriptBonus";
Meteor.subscribe("collegesCourses");
......@@ -673,14 +674,25 @@ Template.registerHelper("getDate", function () {
return moment(date).locale(Session.get('activeLanguage')).format('LL');
});
Template.registerHelper("getMomentsDate", function (date, displayMinutes = false) {
return Utilities.getMomentsDate(date, displayMinutes);
Template.registerHelper("getMomentsDate", function (date, displayMinutes = false, displayAsDeadline = false, transformToSpeech = true) {
return Utilities.getMomentsDate(date, displayMinutes, displayAsDeadline, transformToSpeech);
});
Template.registerHelper("getMomentsDateShort", function (date) {
return Utilities.getMomentsDateShort(date);
});
Template.registerHelper("getTranscriptSubmissions", function (cardset) {
if (Route.isMyBonusTranscripts() || Route.isTranscriptBonus()) {
let transcriptBonus = TranscriptBonus.findOne({card_id: cardset._id}, {fields: {cardset_id: 1}});
cardset = Cardsets.findOne({_id: transcriptBonus.cardset_id});
}
if (cardset.transcriptBonus !== undefined && cardset.transcriptBonus.stats !== undefined) {
return cardset.transcriptBonus.stats.submissions;
} else {
return 0;
}
});
// Returns the locale date
Template.registerHelper("getDateUpdated", function () {
......
......@@ -366,6 +366,7 @@ function setupDatabaseIndex() {
WebPushSubscriptions._ensureIndex({user_id: 1});
Ratings._ensureIndex({cardset_id: 1, user_id: 1});
Cardsets._ensureIndex({name: 1, owner: 1, kind: 1, shuffled: 1, cardType: 1, difficulty: 1, wordcloud: 1, learningActive: 1});
TranscriptBonus._ensureIndex({cardset_id: 1, user_id: 1});
}
Meteor.startup(function () {
......@@ -814,6 +815,20 @@ 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);
}
}
let transcriptBonus = TranscriptBonus.find({deadlineEditing: {$exists: false}}, {fields: {_id: 1, deadline: 1}}).fetch();
......@@ -970,7 +985,6 @@ Meteor.startup(function () {
);
}
Cardsets.remove({cardType: 2});
Meteor.users.remove(demoCardsetUser[0]._id);
Meteor.users.insert(demoCardsetUser[0]);
Meteor.call('deleteDemoCardsets');
......
......@@ -310,13 +310,7 @@ $padding-card-list-row: 8px;
font-size: 18px;
}
#collapseCardsetInfoButton {
float: none;
z-index: 50;
cursor: pointer;
}
#collapseLearningPhaseInfoButton {
#collapseCardsetInfoButton, #collapseLearningPhaseInfoButton, #collapseBonusTranscriptInfoButton {
float: none;
z-index: 50;
cursor: pointer;
......@@ -584,3 +578,23 @@ th .field-tip {
#exportCSV .glyphicon {
margin-top: -6px !important;
}
.bonusTranscriptInfoLectureDates {
.day, .month, .year {
padding-top: 5px;
padding-bottom: 5px;
}
.day {
border: 3px solid;
text-align: center;
}
.day:hover {
cursor: help;
}
.month {
margin-top: 15px;
}
.year + .month {
margin-top: 5px;
}
}
\ No newline at end of file
<template name="bonusTranscriptInfoBox">
<div id="collapseBonusTranscriptInfoButton" class="col-xs-12 card card-block collapseButton">
<strong>{{_ "transcriptForm.info.title"}}</strong>
<i id="collapseBonusTranscriptInfoIcon" class="glyphicon glyphicon-collapse-down pull-right"></i>
</div>
<div class="collapse" id="collapseBonusTranscriptInfo">
<div class="card card-block">
<table class="table table-condensed table-striped table-hover infoBoxTable">
<tbody>
{{> cardsetInfoBoxItemTranscriptBonusMaxPoints}}
{{> cardsetInfoBoxItemBonusPointsFAQ}}
{{> cardsetInfoBoxItemTranscriptLectureDates}}
{{> cardsetInfoBoxItemTranscriptLectureEnd}}
{{> cardsetInfoBoxItemTranscriptSubmissionDeadline}}
{{> cardsetInfoBoxItemTranscriptEditDeadline}}
{{> cardsetInfoBoxItemTranscriptParticipants}}
{{> cardsetInfoBoxItemTranscriptSubmissions}}
{{> cardsetInfoBoxItemTranscriptMedian}}
{{> cardsetInfoBoxItemTranscriptMinimumSubmissions}}
</tbody>
</table>
</div>
</div>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import {CardsetVisuals} from "../../../../api/cardsetVisuals";
import "./item/bonusPointsFAQ.js";
import "./item/transcript/bonusMaxPoints.js";
import "./item/transcript/editDeadline.js";
import "./item/transcript/lectureDates.js";
import "./item/transcript/submissionDeadline.js";
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";
/*
* ############################################################################
* bonusTranscriptInfoBox
* ############################################################################
*/
Template.bonusTranscriptInfoBox.events({
"click #collapseBonusTranscriptInfoButton": function (event) {
event.preventDefault();
CardsetVisuals.changeCollapseElement("#collapseBonusTranscriptInfo");
}
});
<template name="cardsetInfoBoxItemTranscriptBonusMaxPoints">
<tr>
<td>{{_ "transcriptForm.bonus.form.percentage"}}:</td>
<td>{{getBonusPoints this}} %</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import "./bonusMaxPoints.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptBonusMaxPoints
* ############################################################################
*/
Template.cardsetInfoBoxItemTranscriptBonusMaxPoints.helpers({
getBonusPoints: function (cardset) {
if (cardset.transcriptBonus !== undefined) {
return cardset.transcriptBonus.percentage;
}
}
});
<template name="cardsetInfoBoxItemTranscriptEditDeadline">
<tr>
<td>{{_ "transcriptForm.bonus.form.deadline.editing"}}:</td>
<td>{{getEditDeadline this}} {{_ "transcriptForm.bonus.form.hours" count=(getEditDeadline this)}}</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import "./editDeadline.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptEditDeadline
* ############################################################################
*/
Template.cardsetInfoBoxItemTranscriptEditDeadline.helpers({
getEditDeadline: function (cardset) {
if (cardset.transcriptBonus !== undefined) {
return cardset.transcriptBonus.deadlineEditing;
}
}
});
<template name="cardsetInfoBoxItemTranscriptLectureDates">
<tr>
<td colspan="2">{{_ "transcriptForm.bonus.form.lectureDates"}}:<br>
<div class="bonusTranscriptInfoLectureDates">
{{#each getLectureDates this}}
{{#if isNewYear this}}
<div class="col-xs-12 year">{{getYear}}</div>
{{/if}}
{{#if isNewMonth this}}
<div class="col-xs-12 month">{{getMonth}}</div>
{{/if}}
<div class="{{getStatus this 0}} col-xs-2 day" title="{{getStatus this 1}}">{{getMomentsDate this.date false false false}}</div>
{{/each}}
</div>
</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import {TranscriptBonusList} from "../../../../../../api/transcriptBonus";
import {Session} from "meteor/session";
import "./lectureDates.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptLectureDates
* ############################################################################
*/
let lastMonth;
let lastYear;
Template.cardsetInfoBoxItemTranscriptLectureDates.helpers({
getLectureDates: function (cardset) {
if (cardset.transcriptBonus !== undefined) {
let results = [];
for (let i = 0; i < cardset.transcriptBonus.dates.length; i++) {
let item = JSON.parse(JSON.stringify(cardset.transcriptBonus));
item.date = new Date(cardset.transcriptBonus.dates[i]);
results.push(item);
}
return results;
}
},
isNewMonth: function (transcriptBonus) {
let currentMonth = moment(transcriptBonus.date).month();
if (currentMonth !== lastMonth) {
lastMonth = currentMonth;
return true;
}
},
isNewYear: function (transcriptBonus) {
let currentYear = moment(transcriptBonus.date).year();
if (currentYear !== lastYear) {
lastYear = currentYear;
return true;
}
},
getMonth: function () {
return moment().month(lastMonth).locale(Session.get('activeLanguage')).format('MMMM');
},
getYear: function () {
return lastYear;
},
//returnMode 0 = Return class
//returnMode 1 = Return tooltip
getStatus: function (transcriptBonus, returnMode = 0) {
let current = moment();
let lectureEndDate = TranscriptBonusList.addLectureEndTime(transcriptBonus, transcriptBonus.date);
if (current > lectureEndDate && !TranscriptBonusList.isDeadlineExpired(transcriptBonus)) {
if (returnMode) {
return TAPi18n.__('transcriptForm.info.tooltip.lecture.active');
} else {
return "active";
}
} else if (current > lectureEndDate) {
if (returnMode) {
return TAPi18n.__('transcriptForm.info.tooltip.lecture.past');
} else {
return "past";
}
} else {
if (returnMode) {
return TAPi18n.__('transcriptForm.info.tooltip.lecture.future');
} else {
return "future";
}
}
}
});
Template.cardsetInfoBoxItemTranscriptLectureDates.onCreated(function () {
lastMonth = undefined;
lastYear = undefined;
});
<template name="cardsetInfoBoxItemTranscriptLectureEnd">
<tr>
<td>{{_ "transcriptForm.bonus.form.lectureTimeEnd"}}:</td>
<td >
{{getLectureEnd this}} {{_ "transcriptForm.bonus.form.clock"}}
</td>
</tr>
</template>
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import "./lectureEnd.html";
/*
* ############################################################################
* cardsetInfoBoxItemTranscriptLectureEnd
* ############################################################################
*/
Template.cardsetInfoBoxItemTranscriptLectureEnd.helpers({
getLectureEnd: function (cardset) {
if (cardset.transcriptBonus !== undefined) {
return cardset.transcriptBonus.lectureEnd;
}
}
});