Commit 3f903e48 authored by Curtis Adam's avatar Curtis Adam

Display the number of achieved bonus points in the transcript statistics

parent 2c26aa73
......@@ -93,6 +93,7 @@ $themes: (
$transcript_rating_pending_icon: map-get($map, "transcript_rating_pending_icon");
$transcript_rating_accepted_icon: map-get($map, "transcript_rating_accepted_icon");
$transcript_rating_denied_icon: map-get($map, "transcript_rating_denied_icon");
$transcript_achieved_bonus: map-get($map, "transcript_achieved_bonus");
//barfy stars
$barfy_stars_particles_1: map-get($map, "barfy_stars_particles_1");
$barfy_stars_particles_2: map-get($map, "barfy_stars_particles_2");
......@@ -2806,6 +2807,10 @@ $themes: (
color: $transcript_rating_denied_icon !important;
}
.transcript-achieved-bonus::before {
color: $transcript_achieved_bonus !important;
}
.label-count-cards {
background-color: $card_counter_background !important;
color: $card_counter_text!important;
......
......@@ -128,6 +128,7 @@
"transcript_rating_pending_icon": $thm_orange,
"transcript_rating_accepted_icon": $thm_green,
"transcript_rating_denied_icon": $thm_red,
"transcript_achieved_bonus": $thm_orange,
//barfy stars
"barfy_stars_particles_1": $thm_blue,
"barfy_stars_particles_2": $thm_orange,
......
......@@ -736,7 +736,8 @@
"lastSubmission": "Letzte Abgabe",
"pending": "Noch nicht bewertet",
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
"denied": "Abgelehnt",
"bonus": "Erhaltene Bonuspunkte"
}
}
},
......
......@@ -738,7 +738,8 @@
"lastSubmission": "Letzte Abgabe",
"pending": "Noch nicht bewertet",
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
"denied": "Abgelehnt",
"bonus": "Erhaltene Bonuspunkte"
}
}
},
......
......@@ -208,6 +208,22 @@ export let TranscriptBonusList = class TranscriptBonusList {
}
}
static getAchievedBonus (user_id) {
let cardset = Cardsets.findOne({_id: Router.current().params._id}, {fields: {transcriptBonus: 1}});
if (cardset !== undefined) {
let query = {user_id: user_id, rating: 1};
if (Route.isTranscriptBonus()) {
query.cardset_id = Router.current().params._id;
}
let acceptedTranscripts = TranscriptBonus.find(query).count();
if (acceptedTranscripts === 0 || cardset.transcriptBonus.minimumSubmissions === 0) {
return 0;
} else {
return Math.trunc((acceptedTranscripts / cardset.transcriptBonus.minimumSubmissions) * cardset.transcriptBonus.percentage);
}
}
}
static getBonusTranscriptRating (type = 0) {
switch (type) {
case 1:
......
......@@ -23,11 +23,11 @@ Template.cardsetIndexTranscriptSettings.onRendered(function () {
if (dates.length) {
$('#transcript-calendar').multiDatesPicker({
addDates: dates,
numberOfMonths: [1, 6]
numberOfMonths: [1, 3]
});
} else {
$('#transcript-calendar').multiDatesPicker({
numberOfMonths: [1, 6]
numberOfMonths: [1, 3]
});
}
let minimumSubmissions = $('#bonusMinimumSubmissions').val();
......
<template name="cardsetIndexTranscriptStatisticsItemUser">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 transcript-bonus-user-statistics">
<div class="col-xs-12 col-sm-6 transcript-bonus-user-statistics">
<table class="table">
<thead>
{{> cardsetIndexTranscriptStatisticsItemUserAuthor}}
......@@ -9,6 +9,7 @@
{{> cardsetIndexTranscriptStatisticsItemUserPending}}
{{> cardsetIndexTranscriptStatisticsItemUserAccepted}}
{{> cardsetIndexTranscriptStatisticsItemUserDenied}}
{{> cardsetIndexTranscriptStatisticsItemUserBonus}}
{{> cardsetIndexTranscriptStatisticsItemUserLastSubmission}}
</tbody>
</table>
......
import "./user.html";
import "./user/accepted.js";
import "./user/author.js";
import "./user/bonus.js";
import "./user/denied.js";
import "./user/lastSubmission.js";
import "./user/pending.js";
......
<template name="cardsetIndexTranscriptStatisticsItemUserBonus">
<tr>
<td>
<i class="transcript-achieved-bonus fas fa-award"></i>&nbsp;{{_ "transcriptForm.bonus.statistics.bonus"}}:
</td>
<td>
{{getAchievedBonus this._id}}&nbsp;%
</td>
</tr>
</template>
import "./bonus.html";
import {TranscriptBonusList} from "../../../../../../../api/transcriptBonus";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemUserBonus
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemUserBonus.helpers({
getAchievedBonus: function (user_id) {
return TranscriptBonusList.getAchievedBonus(user_id);
}
});
<template name="cardsetIndexTranscriptStatisticsItemUserDenied">
<tr>
<td>
{{{getBonusTranscriptRating 2}}}&nbsp;
{{{getBonusTranscriptRating 2}}}
{{#if (getSubmissions this._id 1)}}
<a href="" class="filterSubmissionsRating cards-filter-element" data-id="{{this._id}}"
data-rating="2">{{_
......
<template name="cardsetIndexTranscript">
<div class="transcriptBonus">
<div class="transcriptBonus container">
{{> cardsetIndexTranscriptNavigation}}
{{#if isViewActive 0}}
{{> cardsetIndexTranscriptSettings}}
......
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