Commit 2c26aa73 authored by Curtis Adam's avatar Curtis Adam

Split the cardset transcript view into multiple templates

parent e6d7c17d
......@@ -3,6 +3,7 @@ import {Meteor} from "meteor/meteor";
import {Cardsets} from "./cardsets";
import {UserPermissions} from "./permissions";
import {SimpleSchema} from "meteor/aldeed:simple-schema";
import {Route} from "./route.js";
import {check} from "meteor/check";
import {Utilities} from "./utilities";
import * as config from "../config/transcriptBonus.js";
......@@ -218,6 +219,17 @@ export let TranscriptBonusList = class TranscriptBonusList {
}
}
static getSubmissions (user_id, rating) {
let query = {user_id: user_id};
if (Route.isTranscriptBonus()) {
query.cardset_id = Router.current().params._id;
}
if (rating !== undefined) {
query.rating = rating;
}
return TranscriptBonus.find(query).count();
}
static getBonusTranscriptTooltip (type = 0) {
switch (type) {
case 1:
......
......@@ -449,7 +449,7 @@ Router.route('/cardset/:_id/editshuffle', {
Router.route('/cardset/:_id/transcripts', {
name: 'transcriptBonus',
template: 'cardsetTranscript',
template: 'cardsetIndexTranscript',
subscriptions: function () {
return [Meteor.subscribe('cardsetTranscriptBonus', this.params._id), Meteor.subscribe('cardsetTranscriptBonusCards', this.params._id), Meteor.subscribe('cardset', this.params._id), Meteor.subscribe('paidCardset', this.params._id), Meteor.subscribe('userDataTranscriptBonus', this.params._id)];
},
......
<template name="cardsetIndexTranscriptItemCancel">
<div id="transcript-bonus-cancel" class="btn btn-raised btn-danger pull-left">
<span class="flex-content">
{{#if isShuffledCardset this._id}}
{{_ "transcriptForm.bonus.form.button.cancelRepetitorium"}}
{{else}}
{{_ "transcriptForm.bonus.form.button.cancel"}}
{{/if}}
</span>
</div>
</template>
import "./cancel.html";
import {Template} from "meteor/templating";
/*
* ############################################################################
* cardsetIndexTranscriptItemCancel
* ############################################################################
*/
Template.cardsetIndexTranscriptItemCancel.events({
'click #transcript-bonus-cancel': function () {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}
});
<template name="cardsetIndexTranscriptItemSave">
<div id="transcript-bonus-save" class="btn btn-raised btn-success pull-right">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.save"}}
</span>
</div>
</template>
import "./save.html";
import {Template} from "meteor/templating";
import {Meteor} from "meteor/meteor";
import {BertAlertVisuals} from "../../../../../api/bertAlertVisuals";
/*
* ############################################################################
* cardsetIndexTranscriptItemSave
* ############################################################################
*/
Template.cardsetIndexTranscriptItemSave.events({
'click #transcript-bonus-save': function () {
let isEnabled = $('#enableBonus:checked').is(":checked");
let percentage = $('#bonusPercentage').val();
let lectureEnd = $('#lectureTimeEnd').val();
let deadlineEditing = $('#deadlineHoursEditing').val();
let deadlineSubmission = $('#deadlineHoursSubmission').val();
let dates = $('#transcript-calendar').multiDatesPicker('getDates');
let minimumSubmissions = $('#bonusMinimumSubmissions').val();
let newDates = [];
for (let d = 0; d < dates.length; d++) {
newDates.push(moment(dates[d], "MM/DD/YYYY").toDate());
}
Meteor.call('updateCardsetTranscriptBonus', Router.current().params._id, Boolean(isEnabled), Number(percentage), lectureEnd, Number(deadlineSubmission), Number(deadlineEditing), newDates, Number(minimumSubmissions), function (error, result) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('transcriptForm.bonus.form.alert.save'), "success", 'growl-top-left');
}
});
}
});
<template name="cardsetIndexTranscriptNavigationItemSettings">
<div class="col-xs-12 col-sm-4">
<div id="showTranscriptSettings" class="btn btn-raised btn-block {{#if isViewActive 0}}btn-primary{{else}}btn-default{{/if}}">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.settings"}}
</span>
</div>
</div>
</template>
import "./settings.html";
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
/*
* ############################################################################
* cardsetIndexTranscriptNavigationItemSettings
* ############################################################################
*/
Template.cardsetIndexTranscriptNavigationItemSettings.helpers({
isViewActive: function (id) {
return Session.get('transcriptViewingMode') === id;
}
});
Template.cardsetIndexTranscriptNavigationItemSettings.events({
'click #showTranscriptSettings': function () {
Session.set('transcriptViewingMode', 0);
}
});
<template name="cardsetIndexTranscriptNavigationItemStatistics">
<div class="col-xs-12 col-sm-4">
<div id="showTranscriptStatistics" class="btn btn-raised btn-block {{#if isViewActive 1}}btn-primary{{else}}btn-default{{/if}}">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.statistics"}}
</span>
</div>
</div>
</template>
import "./statistics.html";
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
/*
* ############################################################################
* cardsetIndexTranscriptNavigationItemStatistics
* ############################################################################
*/
Template.cardsetIndexTranscriptNavigationItemStatistics.helpers({
isViewActive: function (id) {
return Session.get('transcriptViewingMode') === id;
}
});
Template.cardsetIndexTranscriptNavigationItemStatistics.events({
'click #showTranscriptStatistics': function () {
Session.set('transcriptViewingMode', 1);
}
});
<template name="cardsetIndexTranscriptNavigationItemSubmissions">
<div class="col-xs-12 col-sm-4">
<div id="showTranscriptSubmissions" class="btn btn-raised btn-block {{#if isViewActive 2}}btn-primary{{else}}btn-default{{/if}}">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.list"}}
</span>
</div>
</div>
</template>
import "./submissions.html";
import {Session} from "meteor/session";
import {Template} from "meteor/templating";
/*
* ############################################################################
* cardsetIndexTranscriptNavigationItemSubmissions
* ############################################################################
*/
Template.cardsetIndexTranscriptNavigationItemSubmissions.helpers({
isViewActive: function (id) {
return Session.get('transcriptViewingMode') === id;
}
});
Template.cardsetIndexTranscriptNavigationItemSubmissions.events({
'click #showTranscriptSubmissions': function () {
Session.set('transcriptViewingMode', 2);
}
});
<template name="cardsetIndexTranscriptNavigation">
{{> cardsetIndexTranscriptNavigationItemStatistics}}
{{> cardsetIndexTranscriptNavigationItemSubmissions}}
{{> cardsetIndexTranscriptNavigationItemSettings}}
<br>
</template>
import "./item/settings.js";
import "./item/statistics.js";
import "./item/submissions.js";
import "./navigation.html";
<template name="cardsetTranscriptStatistics">
<div id="cardsetInfoDetail" class="col-xs-12">
<br>
<div class="panel panel-default cardsetInfo">
<div class="panel-body">
<h4>{{this.name}}</h4>
<hr>
<div class="row">
<span class="col-sm-6 collapseCardsetInfoContainer">
{{> cardsetInfoBox}}
</span>
<span class="col-sm-6 collapseCardsetInfoContainer">
{{> bonusTranscriptInfoBox}}
</span>
</div>
</div>
</div>
</div>
{{#each transcriptBonusUser}}
<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">
{{getAuthorName this._id}}
</th>
</tr>
</thead>
<tbody>
<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>
{{/each}}
</template>
<template name="cardsetTranscriptSettings">
<template name="cardsetIndexTranscriptSettings">
<div class="col-xs-12">
<h2 id="transcriptBonusTitle" class="modal-title">{{_ "transcriptForm.bonus.form.title"}}</h2>
</div>
......@@ -31,16 +31,4 @@
<label>{{_ "transcriptForm.bonus.form.lectureDates"}}:</label>
<div id="transcript-calendar"></div>
</div>
</template>
<template name="cardsetTranscriptSettingsCancel">
<div id="transcript-bonus-cancel" class="btn btn-raised btn-danger pull-left">
<span class="flex-content">
{{#if isShuffledCardset this._id}}
{{_ "transcriptForm.bonus.form.button.cancelRepetitorium"}}
{{else}}
{{_ "transcriptForm.bonus.form.button.cancel"}}
{{/if}}
</span>
</div>
</template>
\ No newline at end of file
......@@ -3,11 +3,11 @@ import {Template} from "meteor/templating";
/*
* ############################################################################
* cardsetTranscriptSettings
* cardsetIndexTranscriptSettings
* ############################################################################
*/
Template.cardsetTranscriptSettings.onRendered(function () {
Template.cardsetIndexTranscriptSettings.onRendered(function () {
let dates = [];
if (this.data.transcriptBonus !== undefined) {
$('#enableBonus').prop('checked', this.data.transcriptBonus.enabled);
......
<template name="cardsetIndexTranscriptStatisticsItemCardset">
<div id="cardsetInfoDetail" class="col-xs-12">
<br>
<div class="panel panel-default cardsetInfo">
<div class="panel-body">
<h4>{{this.name}}</h4>
<hr>
<div class="row">
<span class="col-sm-6 collapseCardsetInfoContainer">
{{> cardsetInfoBox}}
</span>
<span class="col-sm-6 collapseCardsetInfoContainer">
{{> bonusTranscriptInfoBox}}
</span>
</div>
</div>
</div>
</div>
</template>
<template name="cardsetIndexTranscriptStatisticsItemUser">
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3 transcript-bonus-user-statistics">
<table class="table">
<thead>
{{> cardsetIndexTranscriptStatisticsItemUserAuthor}}
</thead>
<tbody>
{{> cardsetIndexTranscriptStatisticsItemUserSubmissions}}
{{> cardsetIndexTranscriptStatisticsItemUserPending}}
{{> cardsetIndexTranscriptStatisticsItemUserAccepted}}
{{> cardsetIndexTranscriptStatisticsItemUserDenied}}
{{> cardsetIndexTranscriptStatisticsItemUserLastSubmission}}
</tbody>
</table>
</div>
</template>
import "./user.html";
import "./user/accepted.js";
import "./user/author.js";
import "./user/denied.js";
import "./user/lastSubmission.js";
import "./user/pending.js";
import "./user/submissions.js";
import {FilterNavigation} from "../../../../../../api/filterNavigation";
import {Filter} from "../../../../../../api/filter";
import {Session} from "meteor/session";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemUser
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemUser.events({
'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();
}
});
<template name="cardsetIndexTranscriptStatisticsItemUserAccepted">
<tr>
<td>
{{{getBonusTranscriptRating 1}}}
{{#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>
</template>
import "./accepted.html";
import {TranscriptBonusList} from "../../../../../../../api/transcriptBonus";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemUserAccepted
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemUserAccepted.helpers({
getBonusTranscriptRating: function (type) {
return TranscriptBonusList.getBonusTranscriptRating(type);
},
getSubmissions: function (user_id, type) {
return TranscriptBonusList.getSubmissions(user_id, type);
}
});
<template name="cardsetIndexTranscriptStatisticsItemUserAuthor">
<tr>
<th colspan="2">
{{getAuthorName this._id}}
</th>
</tr>
</template>
<template name="cardsetIndexTranscriptStatisticsItemUserDenied">
<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>
</template>
import "./denied.html";
import {TranscriptBonusList} from "../../../../../../../api/transcriptBonus";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemUserDenied
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemUserDenied.helpers({
getBonusTranscriptRating: function (type) {
return TranscriptBonusList.getBonusTranscriptRating(type);
},
getSubmissions: function (user_id, type) {
return TranscriptBonusList.getSubmissions(user_id, type);
}
});
<template name="cardsetIndexTranscriptStatisticsItemUserLastSubmission">
<tr>
<td>
<i class="far fa-calendar"></i>&nbsp;{{_ "transcriptForm.bonus.statistics.lastSubmission"}}:
</td>
<td>
{{lastSubmission this._id}}
</td>
</tr>
</template>
import "./lastSubmission.html";
import {TranscriptBonus, TranscriptBonusList} from "../../../../../../../api/transcriptBonus";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemUserLastSubmission
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemUserLastSubmission.helpers({
lastSubmission: function (id) {
let bonusTranscript = TranscriptBonus.findOne({user_id: id}, {sort: {date: -1}});
if (bonusTranscript !== undefined) {
return TranscriptBonusList.getLectureName(bonusTranscript, false);
}
}
});
<template name="cardsetIndexTranscriptStatisticsItemUserPending">
<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>
</template>
import "./pending.html";
import {TranscriptBonusList} from "../../../../../../../api/transcriptBonus";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemUserPending
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemUserPending.helpers({
getBonusTranscriptRating: function (type) {
return TranscriptBonusList.getBonusTranscriptRating(type);
},
getSubmissions: function (user_id, type) {
return TranscriptBonusList.getSubmissions(user_id, type);
}
});
<template name="cardsetIndexTranscriptStatisticsItemUserSubmissions">
<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>
</template>
import "./submissions.html";
import {TranscriptBonusList} from "../../../../../../../api/transcriptBonus";
/*
* ############################################################################
* cardsetIndexTranscriptStatisticsItemUserSubmissions
* ############################################################################
*/
Template.cardsetIndexTranscriptStatisticsItemUserSubmissions.helpers({
getSubmissions: function (user_id, type) {
return TranscriptBonusList.getSubmissions(user_id, type);
}
});
<template name="cardsetIndexTranscriptStatistics">
{{> cardsetIndexTranscriptStatisticsItemCardset}}
{{#each transcriptBonusUser}}
{{> cardsetIndexTranscriptStatisticsItemUser}}
{{/each}}
</template>
import "./statistics.html";
import "./item/cardset.js";
import "./item/user.js";
import {TranscriptBonus, TranscriptBonusList} from "../../../../../api/transcriptBonus";
import {Template} from "meteor/templating";
import {Filter} from "../../../../../api/filter";
......@@ -12,7 +14,7 @@ import {Session} from "meteor/session";
*/
Template.cardsetTranscriptStatistics.events({
Template.cardsetIndexTranscriptStatistics.events({
'click .filterTranscriptSubmissions': function (event) {
Session.set('transcriptViewingMode', 2);
Filter.setActiveFilter($(event.target).data('id'), "author", 30);
......@@ -26,7 +28,7 @@ Template.cardsetTranscriptStatistics.events({
}
});
Template.cardsetTranscriptStatistics.helpers({
Template.cardsetIndexTranscriptStatistics.helpers({
transcriptBonusUser: function () {
let transcriptBonusUsers = _.uniq(TranscriptBonus.find({cardset_id: Router.current().params._id}, {
fields: {user_id: 1}
......
<template name="cardsetIndexTranscriptSubmissions">
{{> filterIndex}}
</template>
<template name="cardsetTranscript">
<template name="cardsetIndexTranscript">
<div class="transcriptBonus">
<div class="col-xs-12 col-sm-4">
<div id="showTranscriptStatistics" class="btn btn-raised btn-block {{#if isViewActive 1}}btn-primary{{else}}btn-default{{/if}}">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.statistics"}}
</span>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div id="showTranscriptList" class="btn btn-raised btn-block {{#if isViewActive 2}}btn-primary{{else}}btn-default{{/if}}">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.list"}}
</span>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div id="showTranscriptSettings" class="btn btn-raised btn-block {{#if isViewActive 0}}btn-primary{{else}}btn-default{{/if}}">
<span class="flex-content">
{{_ "transcriptForm.bonus.form.button.settings"}}
</span>
</div>
</div>
<br>
{{> cardsetIndexTranscriptNavigation}}
{{#if isViewActive 0}}
{{> cardsetTranscriptSettings}}
{{> cardsetIndexTranscriptSettings}}
{{else if isViewActive 1}}
{{> cardsetTranscriptStatistics}}
{{> cardsetIndexTranscriptStatistics}}
{{else}}
{{> filterIndex}}
{{> cardsetIndexTranscriptSubmissions}}