Commit 59e21fab authored by Curtis Adam's avatar Curtis Adam

Give admins the option to add a "lecturer authorized" label to a cardset

parent d9784f69
......@@ -80,6 +80,8 @@ $themes: (
$input_textarea_text_active: map-get($map, "input_textarea_text_active");
$input_textarea_text_inactive: map-get($map, "input_textarea_text_inactive");
$button_navbar_collapse_text: map-get($map, "button_navbar_collapse_text");
$lecturer_authorized_background: map-get($map, "lecturer_authorized_background");
$lecturer_authorized_text: map-get($map, "lecturer_authorized_text");
//barfy stars
$barfy_stars_particles_1: map-get($map, "barfy_stars_particles_1");
$barfy_stars_particles_2: map-get($map, "barfy_stars_particles_2");
......@@ -2747,6 +2749,14 @@ $themes: (
color: $card_type_text !important;
}
.label-lecturer-authorized {
background-color: $lecturer_authorized_background !important;
color: $lecturer_authorized_text !important;
i:hover {
color: $lecturer_authorized_text !important;
}
}
.moduleRadioButtonLabel {
color: $white !important;
}
......
......@@ -115,6 +115,8 @@
"input_textarea_text_active": $input_textarea_text_active,
"input_textarea_text_inactive": $input_textarea_text_inactive,
"button_navbar_collapse_text": white,
"lecturer_authorized_background": $thm_green,
"lecturer_authorized_text": white,
//barfy stars
"barfy_stars_particles_1": $thm_blue,
"barfy_stars_particles_2": $thm_orange,
......
......@@ -600,6 +600,13 @@
"add": "Hinzufügen",
"remove": "Entfernen"
}
},
"lecturerAuthorized": {
"title": "Zur Prüfungsvorbereitung geeignet-Einstellungen",
"button": {
"add": "Hinzufügen",
"remove": "Entfernen"
}
}
},
"useCases": {
......@@ -2153,6 +2160,11 @@
"cards": "Karten"
}
},
"label": {
"lecturerAuthorized": {
"long": "Besonders geeignet für die Prüfungsvorbereitung"
}
},
"bertAlert": {
"publishBonus": {
"message": "Um die Bonusphase zu starten, müssen mindestens __cardcount__ erstellt und die Kartei als »Frei«, »__edu__« oder »Pro« veröffentlicht worden sein."
......
......@@ -601,6 +601,13 @@
"add": "Hinzufügen",
"remove": "Entfernen"
}
},
"lecturerAuthorized": {
"title": "Zur Prüfungsvorbereitung geeignet-Einstellungen",
"button": {
"add": "Hinzufügen",
"remove": "Entfernen"
}
}
},
"useCases": {
......@@ -2154,6 +2161,11 @@
"cards": "Karten"
}
},
"label": {
"lecturerAuthorized": {
"long": "Besonders geeignet für die Prüfungsvorbereitung"
}
},
"bertAlert": {
"publishBonus": {
"message": "Um die Bonusphase zu starten, müssen mindestens __cardcount__ erstellt und die Kartei als »Frei«, »__edu__« oder »Pro« veröffentlicht worden sein."
......
......@@ -345,6 +345,10 @@ const CardsetsSchema = new SimpleSchema({
gotWorkload: {
type: Boolean,
optional: true
},
lecturerAuthorized: {
type: Boolean,
optional: true
}
});
......@@ -1098,7 +1102,7 @@ Meteor.methods({
},
/**
* Whitelist the cardset for the wordcloud
* * @param {String} id - ID of the cardset to be updated
* @param {String} id - ID of the cardset to be updated
* @param {Boolean} status - Wordcloud status for the cardset: true = Add to wordcloud, false = remove from Wordcloud
*/
updateWordcloudStatus: function (id, status) {
......@@ -1114,5 +1118,24 @@ Meteor.methods({
} else {
throw new Meteor.Error("not-authorized");
}
},
/**
* Whitelist the cardset for the wordcloud
* @param {String} id - ID of the cardset to be updated
* @param {Boolean} status - Lecturer authorized status for the cardset: true = authorized, false = not authorized
*/
updateLecturerAuthorizedStatus: function (id, status) {
check(id, String);
check(status, Boolean);
if (UserPermissions.gotBackendAccess()) {
Cardsets.update(id, {
$set: {
lecturerAuthorized: status
}
});
return id;
} else {
throw new Meteor.Error("not-authorized");
}
}
});
......@@ -390,6 +390,12 @@ Template.registerHelper("getBonusLabel", function (shuffled = false) {
}
});
Template.registerHelper("getLecturerAuthorizedLabel", function (cardset) {
if (cardset.lecturerAuthorized !== undefined) {
return '<span class="label label-lecturer-authorized" data-id="lecturer-authorized" title="' + TAPi18n.__('label.lecturerAuthorized.long') + '"><i class="fa fa-graduation-cap"></i></span>';
}
});
Template.registerHelper("getTranscriptBonusLabel", function (cardset) {
if ((cardset.transcriptBonus !== undefined && cardset.transcriptBonus.enabled) || Route.isMyBonusTranscripts() || Route.isTranscriptBonus() || Route.isPresentationTranscriptBonus() || Route.isPresentationTranscriptBonusCardset()) {
return '<span class="label label-transcript-bonus" data-id="bonus-transcript" title="' + TAPi18n.__('cardset.transcriptBonus.long') + '">' + TAPi18n.__('cardset.transcriptBonus.short') + '</span>';
......
......@@ -804,6 +804,19 @@ Meteor.startup(function () {
);
}
cardsets = Cardsets.find({lecturerAuthorized: {$exists: false}}).fetch();
for (let i = 0; i < cardsets.length; i++) {
Cardsets.update({
_id: cardsets[i]._id
},
{
$set: {
lecturerAuthorized: false
}
}
);
}
cardsets = Cardsets.find({transcriptBonus: {$exists: true}}, {fields: {_id: 1, transcriptBonus: 1}}).fetch();
for (let i = 0; i < cardsets.length; i++) {
if (cardsets[i].transcriptBonus.deadlineEditing === undefined) {
......
......@@ -12,6 +12,7 @@
{{getTranscriptSubmissions this}}
</span>
{{/if}}
{{{getLecturerAuthorizedLabel this}}}
{{#unless isTranscriptRoute}}
{{#unless isBonusTranscriptsRoute}}
{{{getKind this.kind 0}}}
......
......@@ -96,7 +96,19 @@
{{_ "modal-admin-dialog.wordcloud.button.add"}}</button>
{{/if}}
</div>
<div class="panel-heading" id="cardsetLecturerAuthorized">{{_
"modal-admin-dialog.lecturerAuthorized.title"}}</div>
<div class="panel-body">
{{#if isLecturerAuthorized}}
<button id="cardsetRemoveLecturerAuthorized" class="btn btn-raised btn-danger">
{{_ "modal-admin-dialog.lecturerAuthorized.button.remove"}}</button>
{{else}}
<button id="cardsetAddLecturerAuthorized" class="btn btn-raised btn-success">
{{_ "modal-admin-dialog.lecturerAuthorized.button.add"}}</button>
{{/if}}
</div>
</div>
<br>
</div>
</div>
</div>
......
......@@ -209,6 +209,11 @@ Template.cardsetFormAdmin.helpers({
return Session.get('activeCardset').wordcloud;
}
},
isLecturerAuthorized: function () {
if (Session.get('activeCardset') !== undefined) {
return Session.get('activeCardset').lecturerAuthorized;
}
},
getOwnerId: function () {
if (Session.get('activeCardset') !== undefined) {
return Session.get('activeCardset').owner;
......@@ -257,6 +262,24 @@ Template.cardsetFormAdmin.events({
}
});
}
},
'click #cardsetAddLecturerAuthorized': function () {
if (Session.get('activeCardset') !== undefined) {
Meteor.call('updateLecturerAuthorizedStatus', Session.get('activeCardset')._id, true, function (error, result) {
if (result) {
Session.set('activeCardset', Cardsets.findOne(result));
}
});
}
},
'click #cardsetRemoveLecturerAuthorized': function () {
if (Session.get('activeCardset') !== undefined) {
Meteor.call('updateLecturerAuthorizedStatus', Session.get('activeCardset')._id, false, function (error, result) {
if (result) {
Session.set('activeCardset', Cardsets.findOne(result));
}
});
}
}
});
......
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