Commit e61d0d8f authored by Curtis Adam's avatar Curtis Adam

Transcript bonus: Add a stars filter and label

parent 3b442372
......@@ -94,6 +94,9 @@ $themes: (
$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");
$transcript_rating_stars_label_background: map-get($map, "transcript_rating_stars_label_background");
$transcript_rating_stars_icon: map-get($map, "transcript_rating_stars_icon");
$transcript_rating_stars_icon_rated: map-get($map, "transcript_rating_stars_icon_rated");
//barfy stars
$barfy_stars_particles_1: map-get($map, "barfy_stars_particles_1");
$barfy_stars_particles_2: map-get($map, "barfy_stars_particles_2");
......@@ -2792,6 +2795,25 @@ $themes: (
color: $transcript_rating_label_text !important;
}
.label-transcript-rating-stars {
background-color: $transcript_rating_stars_label_background !important;
i, i:hover {
color: $transcript_rating_stars_icon !important;
}
}
.transcript-bonus-statistics-info {
.fa-star, fa-star:hover {
color: $transcript_rating_stars_icon_rated !important;
}
}
.label-transcript-rating-stars {
i.rated, i.rated:hover {
color: $transcript_rating_stars_icon_rated !important;
}
}
.transcript-rating-pending::before {
color: $transcript_rating_pending_icon !important;
}
......
......@@ -129,6 +129,9 @@
"transcript_rating_accepted_icon": $thm_green,
"transcript_rating_denied_icon": $thm_red,
"transcript_achieved_bonus": $thm_orange,
"transcript_rating_stars_label_background": transparent,
"transcript_rating_stars_icon": white,
"transcript_rating_stars_icon_rated": $thm_orange,
//barfy stars
"barfy_stars_particles_1": $thm_blue,
"barfy_stars_particles_2": $thm_orange,
......
......@@ -739,7 +739,8 @@
"denied": "Abgelehnt",
"bonus": "Erhaltene Bonuspunkte",
"export": "Statistik exportieren",
"exportName": "Mitschriften_Statistik"
"exportName": "Mitschriften_Statistik",
"starsTotal": "Gesammelte Sterne"
},
"submissions": {
"button": {
......@@ -1232,6 +1233,13 @@
},
"transcriptBonusRating": {
"label": "Status",
"starsLabel": {
"stars1": "Diese Mitschrift wurde mit einem Stern bewertet",
"stars2": "Diese Mitschrift wurde mit zwei Sternen bewertet",
"stars3": "Diese Mitschrift wurde mit drei Sternen bewertet",
"stars4": "Diese Mitschrift wurde mit vier Sternen bewertet",
"stars5": "Diese Mitschrift wurde mit fünf Sternen bewertet"
},
"tooltip": {
"pending": "Die Mitschrift wurde noch nicht bewertet",
"accepted": "Die Mitschrift wurde akzeptiert",
......@@ -1367,6 +1375,15 @@
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
},
"stars": {
"title": "Sterne",
"all": "Alle",
"1": ">= 1",
"2": ">= 2",
"3": ">= 3",
"4": ">= 4",
"5": "5"
},
"transcriptLecture": {
"title": "Vorlesungen",
"all": "Alle"
......
......@@ -741,7 +741,8 @@
"denied": "Abgelehnt",
"bonus": "Erhaltene Bonuspunkte",
"export": "Statistik exportieren",
"exportName": "Mitschriften_Statistik"
"exportName": "Mitschriften_Statistik",
"starsTotal": "Collected Stars"
},
"submissions": {
"button": {
......@@ -1234,6 +1235,13 @@
},
"transcriptBonusRating": {
"label": "Status",
"starsLabel": {
"stars1": "This transcript has been rated one star",
"stars2": "This transcript has been rated two stars",
"stars3": "This transcript has been rated three stars",
"stars4": "This transcript has been rated four stars",
"stars5": "This transcript has been rated five stars"
},
"tooltip": {
"pending": "Die Mitschrift wurde noch nicht bewertet",
"accepted": "Die Mitschrift wurde akzeptiert",
......@@ -1369,6 +1377,15 @@
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
},
"stars": {
"title": "Stars",
"all": "All",
"1": ">= 1",
"2": ">= 2",
"3": ">= 3",
"4": ">= 4",
"5": "5"
},
"transcriptLecture": {
"title": "Vorlesungen",
"all": "Alle"
......
......@@ -157,6 +157,13 @@ export let Filter = class Filter {
filter.rating = Number(content);
}
break;
case "stars":
if (content === undefined) {
delete filter.stars;
} else {
filter.stars = Number(content);
}
break;
}
}
switch (FilterNavigation.getRouteId()) {
......@@ -317,7 +324,7 @@ export let Filter = class Filter {
if (!Route.isWorkload() && activeFilter !== undefined && !Route.isTranscript() && !Route.isTranscriptBonus()) {
query.shuffled = activeFilter.shuffled;
}
if (FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId()) || FilterNavigation.gotTranscriptLectureFilter(FilterNavigation.getRouteId())) {
if (FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId()) || FilterNavigation.gotTranscriptLectureFilter(FilterNavigation.getRouteId()) || FilterNavigation.gotStarsFilter(FilterNavigation.getRouteId())) {
let ratingQuery = {};
if (activeFilter.rating !== undefined) {
ratingQuery.rating = activeFilter.rating;
......@@ -325,6 +332,9 @@ export let Filter = class Filter {
if (activeFilter.user_id !== undefined) {
ratingQuery.user_id = activeFilter.user_id;
}
if (activeFilter.stars !== undefined) {
ratingQuery.stars = {$gte: activeFilter.stars};
}
if (activeFilter.cardset_id !== undefined) {
ratingQuery.cardset_id = activeFilter.cardset_id;
}
......
......@@ -56,6 +56,10 @@ export let FilterNavigation = class FilterNavigation {
return config.filtersWithRating.includes(filterType);
}
static gotStarsFilter (filterType) {
return config.filtersWithStars.includes(filterType);
}
static gotBonusFilter (filterType) {
return config.filtersWithBonus.includes(filterType);
}
......
......@@ -98,14 +98,17 @@ export let TranscriptBonusList = class TranscriptBonusList {
}
}
static getDeadlineEditing (transcriptBonus, date_id, reviewMode = false) {
static getDeadlineEditing (transcriptBonus, date_id, displayMode = 0) {
if (transcriptBonus.lectureEnd !== undefined) {
let deadlineEditing = this.addLectureEndTime(transcriptBonus, date_id);
deadlineEditing.add(transcriptBonus.deadlineEditing, 'hours');
if (reviewMode) {
return Utilities.getMomentsDate(deadlineEditing, true, 2, false);
} else {
return TAPi18n.__('transcriptForm.deadline.editing') + ": " + Utilities.getMomentsDate(deadlineEditing, true, 1);
switch (displayMode) {
case 0:
return TAPi18n.__('transcriptForm.deadline.editing') + ": " + Utilities.getMomentsDate(deadlineEditing, true, 1);
case 1:
return Utilities.getMomentsDate(deadlineEditing, true, 2, false);
case 2:
return Utilities.getMomentsDate(deadlineEditing, true, 1);
}
}
}
......@@ -153,6 +156,20 @@ export let TranscriptBonusList = class TranscriptBonusList {
return TranscriptBonus.find(query).count();
}
static getStarsTotal (cardset_id, user_id, rating) {
let query = {cardset_id: cardset_id, user_id: user_id};
query.rating = rating;
if (query.stars !== undefined) {
delete query.stars;
}
let transcripts = TranscriptBonus.find(query, {fields: {stars: 1}}).fetch();
let stars = 0;
for (let i = 0; i < transcripts.length; i++) {
stars += transcripts[i].stars;
}
return stars;
}
static getBonusTranscriptTooltip (type = 0) {
switch (type) {
case 1:
......
......@@ -26,6 +26,7 @@ let filtersWithCardType = [0, 1, 3, 4, 5];
let filtersWithDifficulty = [0, 1, 3, 4, 5];
let filtersWithTranscriptLecture = [9, 10];
let filtersWithRating = [9, 10];
let filtersWithStars = [9, 10];
let filtersWithTargetAudience = [];
let filtersWithSemester = [];
let filtersWithCollege = [];
......@@ -66,5 +67,6 @@ module.exports = {
filtersWithEduKind,
filtersWithProKind,
filtersWithRating,
filtersWithTranscriptLecture
filtersWithTranscriptLecture,
filtersWithStars
};
......@@ -133,6 +133,10 @@ Template.registerHelper('gotRatingFilter', function () {
return FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId());
});
Template.registerHelper('gotStarsFilter', function () {
return FilterNavigation.gotStarsFilter(FilterNavigation.getRouteId());
});
Template.registerHelper('isFilterIndex', function () {
return Route.isFilterIndex();
});
......
<template name="cardsetIndexTranscriptStatisticsItemBoxStarsTotal">
<tr>
<td>
<i class="fas fa-star"></i>
{{_ "transcriptForm.bonus.statistics.starsTotal"}}:
</td>
<td>
{{getStarsTotal this.cardset_id this.user_id 1}}
</td>
</tr>
</template>
import "./starsTotal.html";
import {TranscriptBonusList} from "../../../../../../../api/transcriptBonus";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemBoxStarsTotal
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemBoxStarsTotal.helpers({
getStarsTotal: function (cardset_id, user_id, type) {
return TranscriptBonusList.getStarsTotal(cardset_id, user_id, type);
}
});
......@@ -14,6 +14,7 @@
{{> cardsetIndexTranscriptStatisticsItemBoxAccepted}}
{{> cardsetIndexTranscriptStatisticsItemBoxDenied}}
{{> cardsetIndexTranscriptStatisticsItemBoxBonus}}
{{> cardsetIndexTranscriptStatisticsItemBoxStarsTotal}}
{{> cardsetIndexTranscriptStatisticsItemBoxLastSubmission}}
</tbody>
</table>
......
......@@ -7,6 +7,7 @@ import "./box/denied.js";
import "./box/lastSubmission.js";
import "./box/pending.js";
import "./box/submissions.js";
import "./box/starsTotal.js";
import {FilterNavigation} from "../../../../../../api/filterNavigation";
import {Filter} from "../../../../../../api/filter";
import {Route} from "../../../../../../api/route";
......
......@@ -24,7 +24,7 @@ Template.cardsetIndexTranscriptSubmissionsItemReviewButton.helpers({
if (count === 0) {
if (TranscriptBonus.find({cardset_id: Router.current().params._id, rating: 0}).count()) {
let bonusTranscript = TranscriptBonus.findOne({cardset_id: Router.current().params._id, rating: 0});
let nextDate = TranscriptBonusList.getDeadlineEditing(bonusTranscript, bonusTranscript.date, true);
let nextDate = TranscriptBonusList.getDeadlineEditing(bonusTranscript, bonusTranscript.date, 1);
return TAPi18n.__('transcriptForm.bonus.submissions.info.next', {date: nextDate}, Session.get('activeLanguage'));
}
}
......
......@@ -30,5 +30,6 @@
{{{getTranscriptBonusLabel this}}}
{{> filterIndexItemBottomDeadline}}
{{> filterIndexItemBottomTranscriptRating}}
{{> filterIndexItemBottomStarsRating}}
</span>
</template>
......@@ -32,6 +32,7 @@ import "./item/bottom/editTranscript.js";
import "./item/bottom/export.js";
import "./item/bottom/leaveWorkload.js";
import "./item/bottom/shuffle.js";
import "./item/bottom/starsRating.js";
import "./item/bottom/workloadProgress.js";
import "./item/bottom/transcriptRating.js";
import "./item/collapse/collapse.js";
......@@ -108,6 +109,10 @@ Template.filterIndex.events({
Filter.setActiveFilter($(event.target).data('id'), "transcriptLecture");
Filter.setActiveFilter($(event.target).data('cardset'), "cardset_id");
FilterNavigation.showDropdown();
},
'click .resultItemHeaderBottomAreaLabels .label-transcript-rating-stars': function (evt) {
Filter.setActiveFilter($(evt.currentTarget).data("stars"), "stars");
FilterNavigation.showDropdown();
}
});
......
<template name="filterIndexItemBottomDeadline">
{{#if isBonusTranscriptsRoute}}
<span class="hidden-xs hidden-sm label label-transcript-info" data-id="{{getLectureDate}}" data-cardset="{{getCardset}}">
{{getBonusLectureDeadline}}
<span class="hidden-xs hidden-sm label label-transcript-info" title="{{getBonusLectureDeadline}}" data-id="{{getLectureDate}}" data-cardset="{{getCardset}}">
{{getBonusLectureDeadline 2}}
</span>
{{/if}}
</template>
......@@ -9,10 +9,10 @@ import {TranscriptBonus, TranscriptBonusList} from "../../../../../api/transcrip
*/
Template.filterIndexItemBottomDeadline.helpers({
getBonusLectureDeadline: function () {
getBonusLectureDeadline: function (displayMode = 0) {
let bonusTranscript = TranscriptBonus.findOne({card_id: this._id});
if (bonusTranscript !== undefined) {
return TranscriptBonusList.getDeadlineEditing(bonusTranscript, bonusTranscript.date);
return TranscriptBonusList.getDeadlineEditing(bonusTranscript, bonusTranscript.date, displayMode);
}
},
getLectureDate: function () {
......
<template name="filterIndexItemBottomStarsRating">
{{#if isBonusTranscriptsRoute}}
{{#if gotAccepted this._id}}
<span class="label label-transcript-rating-stars" title="{{getBonusTranscriptStarsTooltip this._id}}"
data-stars="{{getBonusTranscriptStarsNumber this._id}}">
{{#each getBonusTranscriptStars this._id}}
<i class="fas fa-star {{this.status}}"></i>
{{/each}}
</span>
{{/if}}
{{/if}}
</template>
import "./starsRating.html";
import {Template} from "meteor/templating";
import {TranscriptBonus} from "../../../../../api/transcriptBonus";
/*
* ############################################################################
* filterIndexItemBottomStarsRating
* ############################################################################
*/
Template.filterIndexItemBottomStarsRating.helpers({
getBonusTranscriptStarsNumber: function (id) {
return TranscriptBonus.findOne({card_id: id}).stars;
},
getBonusTranscriptStars: function (id) {
let stars = TranscriptBonus.findOne({card_id: id}).stars;
let starData = [];
for (let i = 0; i < 5; i++) {
let star = {};
if (i < stars) {
star.status = "rated";
} else {
star.status = "";
}
starData.push(star);
}
return starData;
},
getBonusTranscriptStarsTooltip: function (id) {
let stars = TranscriptBonus.findOne({card_id: id}).stars;
return TAPi18n.__('cardset.transcriptBonusRating.starsLabel.stars' + stars);
},
gotAccepted: function (id) {
let transcriptBonus = TranscriptBonus.findOne({card_id: id});
if (transcriptBonus !== undefined) {
return transcriptBonus.rating === 1;
}
}
});
<template name="filterItemFilterStars">
<li class="dropdown cards-filter-element">
<a href="#" class="dropdown-toggle bonusFilter cards-filter-element" data-toggle="dropdown"
role="button"
aria-haspopup="true" aria-expanded="false">
{{_ "filter-pool.stars.title"}}
{{#if hasRatingFilter}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a>
<ul class="dropdown-menu cards-filter-element">
<li class="cards-filter-element">
<a href="#" class="noFilterStars active cards-filter-element" data-id="reset">{{_
"filter-pool.stars.all"}}</a>
</li>
{{#if gotStars 1}}
<li class="cards-filter-element" data-stars="1"><a href="#" class="filterStars cards-filter-element" data-stars="1">
{{_ "filter-pool.stars.1"}}
{{#if resultsFilterStars 1}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
{{#if gotStars 2}}
<li class="cards-filter-element" data-stars="1"><a href="#" class="filterStars cards-filter-element" data-stars="1">
{{_ "filter-pool.stars.2"}}
{{#if resultsFilterStars 2}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
{{#if gotStars 3}}
<li class="cards-filter-element" data-stars="3"><a href="#" class="filterStars cards-filter-element" data-stars="3">
{{_ "filter-pool.stars.3"}}
{{#if resultsFilterStars 3}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
{{#if gotStars 4}}
<li class="cards-filter-element" data-stars="4"><a href="#" class="filterStars cards-filter-element" data-stars="4">
{{_ "filter-pool.stars.4"}}
{{#if resultsFilterStars 4}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
{{#if gotStars 5}}
<li class="cards-filter-element" data-stars="5"><a href="#" class="filterStars cards-filter-element" data-stars="5">
{{_ "filter-pool.stars.5"}}
{{#if resultsFilterStars 5}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
</ul>
</li>
</template>
import "./filterStars.html";
import {Filter} from "../../../../api/filter";
import {TranscriptBonus} from "../../../../api/transcriptBonus";
/*
* ############################################################################
* filterItemFilterStars
* ############################################################################
*/
Template.filterItemFilterStars.helpers({
hasRatingFilter: function () {
return Filter.getActiveFilter().stars !== undefined;
},
gotStars: function (rating) {
let activeFilter = Filter.getActiveFilter();
let query = {};
query.stars = rating;
if (activeFilter.user_id !== undefined) {
query.user_id = activeFilter.user_id;
}
if (activeFilter.transcriptDate !== undefined) {
query.date = new Date(activeFilter.transcriptDate);
}
return TranscriptBonus.findOne(query);
},
resultsFilterStars: function (rating) {
let activeFilter = Filter.getActiveFilter();
if (activeFilter.stars !== undefined) {
return rating === activeFilter.stars;
}
}
});
Template.filterItemFilterStars.events({
'click .noFilterStars': function () {
Filter.setActiveFilter(undefined, "stars");
},
'click .filterStars': function (evt) {
Filter.setActiveFilter($(evt.target).data("stars"), "stars");
}
});
......@@ -35,6 +35,9 @@
{{#if gotRatingFilter}}
{{> filterItemFilterRating}}
{{/if}}
{{#if gotStarsFilter}}
{{> filterItemFilterStars}}
{{/if}}
</ul>
</template>
......
......@@ -16,6 +16,7 @@ import './item/filterDifficulty.js';
import './item/filterBonus.js';
import './item/filterLecturerAuthorized.js';
import './item/filterRating.js';
import "./item/filterStars.js";
import './item/filterWordcloud.js';
import './item/filterKind.js';
import './item/filterTranscriptLecture.js';
......
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