Commit 54bb4535 authored by Curtis Adam's avatar Curtis Adam

Only allow lecturers to create a transcript bonus cardset and auto-set it to uni

parent 3c913a4a
......@@ -216,8 +216,14 @@ export let CardNavigation = class CardNavigation {
Session.set('activeCardsetName', Cardsets.findOne({_id: Router.current().params._id}).name);
}
} else {
cardset_id = Cards.findOne({_id: Session.get('activeCard')}).cardset_id;
Session.set('activeCardsetName', Cardsets.findOne({_id: cardset_id}).name);
let _id;
cardset_id = Cards.findOne({_id: Session.get('activeCard')}, {fields: {cardset_id: 1}});
if (cardset_id === undefined && Router.current().params._id !== undefined) {
_id = Router.current().params._id;
} else {
_id = cardset_id.cardset_id;
}
Session.set('activeCardsetName', Cardsets.findOne({_id: _id}).name);
}
}
......
......@@ -16,6 +16,10 @@ export let CardType = class CardType {
return config.cardTypesWithLearningModes;
}
static isLecturerExclusive () {
return config.lecturerExclusiveCardTypes;
}
static getCardTypesWithDifficultyLevel () {
return config.cardTypesWithDifficultyLevel;
}
......
......@@ -9,6 +9,7 @@ import {CardEditor} from "./cardEditor";
import {UserPermissions} from "./permissions";
import {ServerStyle} from "./styles";
import {TranscriptBonus, TranscriptBonusList} from "./transcriptBonus";
import {CardType} from "./cardTypes";
export const Cards = new Mongo.Collection("cards");
......@@ -392,7 +393,7 @@ Meteor.methods({
let cardset = Cardsets.findOne(card.cardset_id);
if (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner)) {
var countCards = Cards.find({cardset_id: cardset._id}).count();
if (countCards <= 5) {
if (countCards < 1 && !CardType.gotTranscriptBonus(cardset.cardType)) {
Cardsets.update(cardset._id, {
$set: {
kind: 'personal',
......
......@@ -498,6 +498,14 @@ Meteor.methods({
if (cardType < 0) {
cardType = 0;
}
if (CardType.gotTranscriptBonus(cardType)) {
if (UserPermissions.isLecturer() || UserPermissions.isAdmin()) {
kind = "edu";
visible = true;
} else {
throw new Meteor.Error("not-authorized");
}
}
let cardset = Cardsets.insert({
name: name.trim(),
description: description,
......@@ -582,19 +590,32 @@ Meteor.methods({
Cards.remove({
cardset_id: id
});
Cardsets.update({
_id: id
},
{
$set: {
quantity: 0,
kind: 'personal',
reviewed: false,
request: false,
visible: false
if (CardType.gotTranscriptBonus(cardset.cardType)) {
Cardsets.update({
_id: id
},
{
$set: {
quantity: 0
}
}
}
);
);
} else {
Cardsets.update({
_id: id
},
{
$set: {
quantity: 0,
kind: 'personal',
reviewed: false,
request: false,
visible: false
}
}
);
}
Meteor.call('updateShuffledCardsetQuantity', cardset._id);
Leitner.remove({
cardset_id: id
......@@ -803,6 +824,16 @@ Meteor.methods({
if (cardset.learningActive) {
cardType = cardset.cardType;
}
let kind = cardset.kind;
let visible = cardset.visible;
if (CardType.gotTranscriptBonus(cardType)) {
if (UserPermissions.isLecturer() || UserPermissions.isAdmin()) {
kind = "edu";
visible = true;
} else {
throw new Meteor.Error("not-authorized");
}
}
Cardsets.update(id, {
$set: {
......@@ -811,6 +842,8 @@ Meteor.methods({
dateUpdated: new Date(),
cardType: cardType,
difficulty: difficulty,
kind: kind,
visible: visible,
noDifficulty: !CardType.gotDifficultyLevel(cardType),
sortType: sortType
}
......
......@@ -29,6 +29,7 @@ let cardTypesWithSwapAnswerQuestionButton = [1, 17];
let cardTypesWithDefaultMobilePreview = [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
let cardTypesWithMarkdeepHelp = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18];
let cardTypesWithTranscriptBonus = [19];
let lecturerExclusiveCardTypes = [19];
let cardTypesOrder = [
{cardType: 0},
{cardType: 15},
......@@ -433,5 +434,6 @@ module.exports = {
defaultCentered,
swapAnserQuestionCardTypeResult,
cardTypeCubeSides,
cardTypesWithTranscriptBonus
cardTypesWithTranscriptBonus,
lecturerExclusiveCardTypes
};
......@@ -17,7 +17,9 @@
{{/each}}
{{else}}
{{#each getCardTypes}}
<li class="cardType" value="{{this.cardType}}" data="{{this.cardType}}"><a href="#">{{getCardTypeLongName}}</a></li>
{{#if canCreateCardType this.cardType}}
<li class="cardType" value="{{this.cardType}}" data="{{this.cardType}}"><a href="#">{{getCardTypeLongName}}</a></li>
{{/if}}
{{/each}}
{{/if}}
</template>
......@@ -4,6 +4,7 @@ import {CardType} from "../../api/cardTypes";
import {Cardsets} from "../../api/cardsets";
import {Filter} from "../../api/filter";
import {Session} from "meteor/session";
import {UserPermissions} from "../../api/permissions";
/*
* ############################################################################
......@@ -28,5 +29,12 @@ Template.cardTypesList.helpers({
},
resultsFilterCardType: function (cardType) {
return Filter.getFilterQuery().cardType === cardType;
},
canCreateCardType: function (cardType) {
if (CardType.gotTranscriptBonus(cardType)) {
return (UserPermissions.isLecturer() || UserPermissions.isAdmin());
} else {
return true;
}
}
});
//------------------------ IMPORTS
import {Template} from "meteor/templating";
import {CardType} from "../../../../api/cardTypes";
import "../modal/publish.js";
import "./publishCardset.html";
......@@ -11,13 +12,15 @@ import "./publishCardset.html";
Template.cardsetNavigationPublishCardset.helpers({
canPublish: function () {
let cardCount;
if (this.shuffled) {
cardCount = 2;
} else {
cardCount = 1;
if (!CardType.gotTranscriptBonus(this.cardType)) {
let cardCount;
if (this.shuffled) {
cardCount = 2;
} else {
cardCount = 1;
}
return (this.quantity >= cardCount || this.reviewed || this.request);
}
return (this.quantity >= cardCount || this.reviewed || this.request);
},
getStatus: function () {
if (this.visible) {
......
<template name="cardsetNavigationTranscripts">
{{#if this.quantity}}
{{#if isPublished this.kind}}
{{#if isCardsetOwnerAndLecturer _id}}
{{#if gotTranscriptBonus _id}}
<div class="hidden-xs btn-group">
<a type="button" id="transcriptBonus" class="btn btn-sm btn-raised transcriptsBtn"
{{disableIfOffline}}><span class="flex-content">{{{getNavigationIcon "transcript"}}}{{_ "transcriptForm.bonus.button"}}</span>
</a>
</div>
{{/if}}
{{/if}}
{{#if isCardsetOwnerAndLecturer _id}}
{{#if gotTranscriptBonus _id}}
<div class="hidden-xs btn-group">
<a type="button" id="transcriptBonus" class="btn btn-sm btn-raised transcriptsBtn"
{{disableIfOffline}}><span class="flex-content">{{{getNavigationIcon "transcript"}}}{{_ "transcriptForm.bonus.button"}}</span>
</a>
</div>
{{/if}}
{{/if}}
</template>
\ No newline at end of file
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