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

Add filter support to transcript ratings

parent 6a6325e3
......@@ -1280,6 +1280,13 @@
"cardset": "Nach Autor/in \"__name__\" filtern",
"rep": "Nach Editor/in \"__name__\" filtern"
}
},
"rating": {
"title": "Bewertung",
"all": "Alle",
"notRated": "Nicht bewertet",
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
}
},
"infinite-scroll": {
......
......@@ -1282,6 +1282,13 @@
"cardset": "Nach Autor/in \"__name__\" filtern",
"rep": "Nach Editor/in \"__name__\" filtern"
}
},
"rating": {
"title": "Bewertung",
"all": "Alle",
"notRated": "Nicht bewertet",
"accepted": "Akzeptiert",
"denied": "Abgelehnt"
}
},
"infinite-scroll": {
......
......@@ -5,6 +5,7 @@ import {Route} from "./route";
import {WordcloudCanvas} from "./wordcloudCanvas";
import {Leitner, Wozniak} from "./learned";
import * as config from "../config/filter.js";
import {TranscriptBonus} from "./transcriptBonus";
Session.setDefault('maxItemsCounter', config.itemStartingValue);
Session.setDefault('poolFilter', undefined);
......@@ -88,7 +89,6 @@ export let Filter = class Filter {
this.setDefaultFilter(FilterNavigation.getRouteId());
}
return Session.get('transcriptsBonusCardsetFilter');
}
}
......@@ -141,6 +141,13 @@ export let Filter = class Filter {
delete filter.learningActive;
filter['transcriptBonus.enabled'] = true;
break;
case "rating":
if (content === undefined) {
delete filter.rating;
} else {
filter.rating = Number(content);
}
break;
}
}
switch (FilterNavigation.getRouteId()) {
......@@ -301,6 +308,20 @@ export let Filter = class Filter {
if (!Route.isWorkload() && activeFilter !== undefined && !Route.isTranscript() && !Route.isTranscriptBonus()) {
query.shuffled = activeFilter.shuffled;
}
if (FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId()) && activeFilter.rating !== undefined) {
let ratingQuery = {rating: activeFilter.rating};
if (Route.isMyBonusTranscripts()) {
ratingQuery.user_id = Meteor.userId();
} else {
ratingQuery.cardset_id = Router.current().params._id;
}
let cardsWithRating = _.uniq(TranscriptBonus.find(ratingQuery, {
fields: {card_id: 1}
}).fetch().map(function (x) {
return x.card_id;
}), true);
query._id = {$in: cardsWithRating};
}
return query;
}
......
......@@ -48,6 +48,10 @@ export let FilterNavigation = class FilterNavigation {
return config.filtersWithDifficulty.includes(filterType);
}
static gotRatingFilter (filterType) {
return config.filtersWithRating.includes(filterType);
}
static gotBonusFilter (filterType) {
return config.filtersWithBonus.includes(filterType);
}
......
......@@ -24,6 +24,7 @@ let filtersWithDefaultSortDateCreated = [];
let filtersWithAuthor = [0, 2, 3, 4, 5, 10];
let filtersWithCardType = [0, 1, 3, 4, 5];
let filtersWithDifficulty = [0, 1, 3, 4, 5];
let filtersWithRating = [9, 10];
let filtersWithTargetAudience = [];
let filtersWithSemester = [];
let filtersWithCollege = [];
......@@ -62,5 +63,6 @@ module.exports = {
filtersWithPersonalKind,
filtersWithFreeKind,
filtersWithEduKind,
filtersWithProKind
filtersWithProKind,
filtersWithRating
};
......@@ -87,9 +87,9 @@ let useCasesIcons = {
};
let transcriptIcons = {
"ratingPending": '<i class="transcript-rating-pending fas fa-hourglass"></i>',
"ratingAccepted": '<i class="transcript-rating-accepted fas fa-check-circle"></i>',
"ratingDenied": '<i class="transcript-rating-denied fas fa-times-circle"></i>'
"ratingPending": '<i class="transcript-rating-pending fas fa-hourglass" data-rating="0"></i>',
"ratingAccepted": '<i class="transcript-rating-accepted fas fa-check-circle" data-rating="1"></i>',
"ratingDenied": '<i class="transcript-rating-denied fas fa-times-circle" data-rating="2"></i>'
};
module.exports = {
......
......@@ -125,6 +125,11 @@ Template.registerHelper('gotKindFilter', function () {
return FilterNavigation.gotKindFilter(FilterNavigation.getRouteId());
});
Template.registerHelper('gotRatingFilter', function () {
return FilterNavigation.gotRatingFilter(FilterNavigation.getRouteId());
});
Template.registerHelper('isFilterIndex', function () {
return Route.isFilterIndex();
});
......
......@@ -20,53 +20,80 @@
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 transcript-bonus-user-statistics">
<table class="table">
<thead>
<tr>
<th colspan="2">
<a href="" class="filterAuthorTranscripts cards-filter-element" data-id="{{this._id}}">{{getAuthorName this._id}}</a>
</th>
</tr>
<tr>
<th colspan="2">
{{getAuthorName this._id}}
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<i class="fas fa-clipboard"></i>&nbsp;{{_ "transcriptForm.info.submissions"}}:
</td>
<td>
{{getSubmissions this._id undefined}}
</td>
</tr>
<tr>
<td>
{{{getBonusTranscriptRating 0}}}&nbsp;{{_ "transcriptForm.bonus.statistics.pending"}}:
</td>
<td>
{{getSubmissions this._id 0}}
</td>
</tr>
<tr>
<td>
{{{getBonusTranscriptRating 1}}}&nbsp;{{_ "transcriptForm.bonus.statistics.accepted"}}:
</td>
<td>
{{getSubmissions this._id 1}}
</td>
</tr>
<tr>
<td>
{{{getBonusTranscriptRating 2}}}&nbsp;{{_ "transcriptForm.bonus.statistics.denied"}}:
</td>
<td>
{{getSubmissions this._id 2}}
</td>
</tr>
<tr>
<td>
<i class="far fa-calendar"></i>&nbsp;{{_ "transcriptForm.bonus.statistics.lastSubmission"}}:
</td>
<td>
{{lastSubmission this._id}}
</td>
</tr>
<tr>
<td>
<i class="fas fa-clipboard"></i>&nbsp;
{{#if (getSubmissions this._id undefined)}}
<a href="" class="filterTranscriptSubmissions cards-filter-element"
data-id="{{this._id}}">{{_ "transcriptForm.info.submissions"}}:</a>
{{else}}
{{_ "transcriptForm.info.submissions"}}:
{{/if}}
</td>
<td>
{{getSubmissions this._id undefined}}
</td>
</tr>
<tr>
<td>
{{{getBonusTranscriptRating 0}}}&nbsp;
{{#if (getSubmissions this._id 0)}}
<a href="" class="filterSubmissionsRating cards-filter-element" data-id="{{this._id}}"
data-rating="0">{{_ "transcriptForm.bonus.statistics.pending"}}:</a>
{{else}}
{{_ "transcriptForm.bonus.statistics.pending"}}:
{{/if}}
</td>
<td>
{{getSubmissions this._id 0}}
</td>
</tr>
<tr>
<td>
{{{getBonusTranscriptRating 1}}}&nbsp;
{{#if (getSubmissions this._id 1)}}
<a href=""
class="filterSubmissionsRating cards-filter-element"
data-id="{{this._id}}" data-rating="1">{{_
"transcriptForm.bonus.statistics.accepted"}}:</a>
{{else}}
{{_ "transcriptForm.bonus.statistics.accepted"}}:
{{/if}}
</td>
<td>
{{getSubmissions this._id 1}}
</td>
</tr>
<tr>
<td>
{{{getBonusTranscriptRating 2}}}&nbsp;
{{#if (getSubmissions this._id 1)}}
<a href="" class="filterSubmissionsRating cards-filter-element" data-id="{{this._id}}"
data-rating="2">{{_
"transcriptForm.bonus.statistics.denied"}}:</a>
{{else}}
{{_ "transcriptForm.bonus.statistics.denied"}}:
{{/if}}
</td>
<td>
{{getSubmissions this._id 2}}
</td>
</tr>
<tr>
<td>
<i class="far fa-calendar"></i>&nbsp;{{_ "transcriptForm.bonus.statistics.lastSubmission"}}:
</td>
<td>
{{lastSubmission this._id}}
</td>
</tr>
</tbody>
</table>
</div>
......
......@@ -13,10 +13,16 @@ import {Session} from "meteor/session";
Template.cardsetTranscriptStatistics.events({
'click .filterAuthorTranscripts': function (event) {
'click .filterTranscriptSubmissions': function (event) {
Session.set('transcriptViewingMode', 2);
Filter.setActiveFilter($(event.target).data('id'), "author", 30);
FilterNavigation.showDropdown();
},
'click .filterSubmissionsRating': function (event) {
Session.set('transcriptViewingMode', 2);
Filter.setActiveFilter($(event.target).data('id'), "author", 30);
Filter.setActiveFilter($(event.target).data('rating'), "rating", 30);
FilterNavigation.showDropdown();
}
});
......
......@@ -27,7 +27,7 @@
{{else if isViewActive 1}}
{{> cardsetTranscriptStatistics}}
{{else}}
{{> filterIndexTranscripts}}
{{> filterIndex}}
{{/if}}
<div class="col-xs-12">
<br>
......
<template name="filterIndex">
{{> showLicense}}
{{> filterItemSelectCardsetToLearnCallout}}
{{#if gotBackendAccess}}
{{> cardsetFormAdmin}}
{{/if}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{#unless isCardsetTranscriptBonusRoute}}
{{> filterItemSelectCardsetToLearnCallout}}
{{#if gotBackendAccess}}
{{> cardsetFormAdmin}}
{{/if}}
{{> cardsetDeleteForm}}
{{> cardsetForm}}
{{/unless}}
<div id="set-list-region">
{{#if isActiveRoute regex='alldecks|create'}}
{{> filterIndexCreate}}
......@@ -32,6 +34,9 @@
{{#if isActiveRoute regex='transcriptsPersonal|transcriptsBonus'}}
{{> filterIndexTranscripts}}
{{/if}}
{{#if isCardsetTranscriptBonusRoute}}
{{> filterIndexTranscripts}}
{{/if}}
</div>
</template>
......
......@@ -91,6 +91,10 @@ Template.filterIndex.events({
'click .resultItemHeaderAuthor a': function (event) {
Filter.setActiveFilter($(event.target).data('id'), "author");
FilterNavigation.showDropdown();
},
'click .resultItemHeaderBottomAreaLabels .label-transcript-rating': function (event) {
Filter.setActiveFilter($(event.target).data('rating'), "rating");
FilterNavigation.showDropdown();
}
});
......
<template name="filterIndexItemBottomTranscriptRating">
{{#if isBonusTranscriptsRoute}}
<span class="label label-transcript-rating" title="{{getBonusTranscriptTooltip this._id}}">
<span class="hidden-xs">{{_ "cardset.transcriptBonusRating.long"}}:</span>
<span class="visible-xs">{{_ "cardset.transcriptBonusRating.short"}}:</span>
<span class="label label-transcript-rating" title="{{getBonusTranscriptTooltip this._id}}" data-rating="{{getBonusTranscriptRatingNumber this._id}}">
<span class="hidden-xs" data-rating="{{getBonusTranscriptRatingNumber this._id}}">{{_ "cardset.transcriptBonusRating.long"}}:</span>
<span class="visible-xs" data-rating="{{getBonusTranscriptRatingNumber this._id}}">{{_ "cardset.transcriptBonusRating.short"}}:</span>
&nbsp;{{{getBonusTranscriptRating this._id}}}
</span>
{{/if}}
......
......@@ -16,5 +16,8 @@ Template.filterIndexItemBottomTranscriptRating.helpers({
getBonusTranscriptTooltip: function (id) {
let rating = TranscriptBonus.findOne({card_id: id}).rating;
return TranscriptBonusList.getBonusTranscriptTooltip(rating);
},
getBonusTranscriptRatingNumber: function (id) {
return TranscriptBonus.findOne({card_id: id}).rating;
}
});
<template name="filterItemFilterRating">
<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.rating.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="noFilterRating active cards-filter-element" data-id="reset">{{_
"filter-pool.rating.all"}}</a>
</li>
{{#if gotRating 0}}
<li class="cards-filter-element" data-rating="0"><a href="#" class="filterRating cards-filter-element" data-rating="0">
{{_ "filter-pool.rating.notRated"}}
{{#if resultsFilterRating 0}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
{{#if gotRating 1}}
<li class="cards-filter-element" data-rating="1"><a href="#" class="filterRating cards-filter-element" data-rating="1">
{{_ "filter-pool.rating.accepted"}}
{{#if resultsFilterRating 1}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
{{#if gotRating 2}}
<li class="cards-filter-element" data-rating="2"><a href="#" class="filterRating cards-filter-element" data-rating="2">
{{_ "filter-pool.rating.denied"}}
{{#if resultsFilterRating 2}}
<i class="fas fa-filter navigationFilterIcon cards-filter-element"></i>
{{/if}}
</a></li>
{{/if}}
</ul>
</li>
</template>
import "./filterRating.html";
import {FilterNavigation} from "../../../../api/filterNavigation";
import {Filter} from "../../../../api/filter";
import {TranscriptBonus} from "../../../../api/transcriptBonus";
/*
* ############################################################################
* filterItemFilterRating
* ############################################################################
*/
Template.filterItemFilterRating.helpers({
hasRatingFilter: function () {
return Filter.getActiveFilter(FilterNavigation.getRouteId()).rating !== undefined;
},
gotRating: function (rating) {
let query = Filter.getFilterQuery(FilterNavigation.getRouteId());
delete query._id;
query.rating = rating;
if (query.owner !== undefined) {
query.user_id = query.owner;
delete query.owner;
}
return TranscriptBonus.findOne(query);
},
resultsFilterRating: function (rating) {
let activeFilter = Filter.getActiveFilter(FilterNavigation.getRouteId());
if (activeFilter.rating !== undefined) {
return rating === activeFilter.rating;
}
}
});
Template.filterItemFilterRating.events({
'click .noFilterRating': function () {
Filter.setActiveFilter(undefined, "rating");
},
'click .filterRating': function (evt) {
Filter.setActiveFilter($(evt.target).data("rating"), "rating");
}
});
......@@ -29,6 +29,9 @@
{{#if gotBonusFilter}}
{{> filterItemFilterBonus}}
{{/if}}
{{#if gotRatingFilter}}
{{> filterItemFilterRating}}
{{/if}}
</ul>
</template>
......@@ -60,6 +63,9 @@
{{#if gotKindFilter}}
{{> filterItemFilterKind}}
{{/if}}
{{#if gotRatingFilter}}
{{> filterItemFilterRating}}
{{/if}}
</template>
<template name="infiniteScroll">
......
......@@ -15,6 +15,7 @@ import './item/filterCardType.js';
import './item/filterDifficulty.js';
import './item/filterBonus.js';
import './item/filterLecturerAuthorized.js';
import './item/filterRating.js';
import './item/filterWordcloud.js';
import './item/filterKind.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