Commit a0d496b8 authored by Curtis Adam's avatar Curtis Adam

Add support to connect transcripts to lectures with bonus

parent 74e5fbda
......@@ -72,3 +72,4 @@ mizzao:jquery-ui
dsyko:jquery-ui-touch-punch
simple:json-routes
underscore@1.0.10
yasseraudio:multidatepicker
......@@ -239,4 +239,5 @@ url@1.2.0
webapp@1.7.3
webapp-hashing@1.0.9
wtfzn:dompurify@0.6.1
yasseraudio:multidatepicker@0.0.5
zimme:active-route@2.3.2
......@@ -9,6 +9,7 @@
@import '../imports/ui/wordcloud/wordcloud.scss';
@import '../imports/ui/filter/index/index.scss';
@import '../imports/ui/cardset/cardset.scss';
@import '../imports/ui/cardset/transcript/transcript.scss';
@import '../imports/ui/filter/index/item/cardset.scss';
@import '../imports/ui/card/card.scss';
@import '../imports/ui/card/cube/cube.scss';
......
......@@ -15,6 +15,7 @@ $themes: (
$background_learning: map-get($map, "background_learning");
$background_backend: map-get($map, "background_backend");
$background_editor: map-get($map, "background_editor");
$background_transcript_bonus: map-get($map, "background_transcript_bonus");
//global colors
$thm_dark_blue: map-get($map, "thm_dark_blue");
$thm_blue: map-get($map, "thm_blue");
......@@ -141,6 +142,25 @@ $themes: (
$navbar_all_repetitorien_text: map-get($map, "navbar_all_repetitorien_text");
$navbar_all_repetitorien_text_hover: map-get($map, "navbar_all_repetitorien_text_hover");
$navbar_all_repetitorien_text_active: map-get($map, "navbar_all_repetitorien_text_active");
//navbar transcripts
$navbar_transcripts_background: map-get($map, "navbar_transcripts_background");
$navbar_transcripts_background_hover: map-get($map, "navbar_transcripts_background_hover");
$navbar_transcripts_background_active: map-get($map, "navbar_transcripts_background_active");
$navbar_transcripts_text: map-get($map, "navbar_transcripts_text");
$navbar_transcripts_text_hover: map-get($map, "navbar_transcripts_text_hover");
$navbar_transcripts_text_active: map-get($map, "navbar_transcripts_text_active");
$navbar_transcripts_personal_background: map-get($map, "navbar_transcripts_personal_background");
$navbar_transcripts_personal_background_hover: map-get($map, "navbar_transcripts_personal_background_hover");
$navbar_transcripts_personal_background_active: map-get($map, "navbar_transcripts_personal_background_active");
$navbar_transcripts_personal_text: map-get($map, "navbar_transcripts_personal_text");
$navbar_transcripts_personal_text_hover: map-get($map, "navbar_transcripts_personal_text_hover");
$navbar_transcripts_personal_text_active: map-get($map, "navbar_transcripts_personal_text_active");
$navbar_transcripts_bonus_background: map-get($map, "navbar_transcripts_bonus_background");
$navbar_transcripts_bonus_background_hover: map-get($map, "navbar_transcripts_bonus_background_hover");
$navbar_transcripts_bonus_background_active: map-get($map, "navbar_transcripts_bonus_background_active");
$navbar_transcripts_bonus_text: map-get($map, "navbar_transcripts_bonus_text");
$navbar_transcripts_bonus_text_hover: map-get($map, "navbar_transcripts_bonus_text_hover");
$navbar_transcripts_bonus_text_active: map-get($map, "navbar_transcripts_bonus_text_active");
//navbar personal
$navbar_personal_background: map-get($map, "navbar_personal_background");
$navbar_personal_background_hover: map-get($map, "navbar_personal_background_hover");
......@@ -470,6 +490,10 @@ $themes: (
$cardset_footer_navigation_delete_all_cards_text: map-get($map, "cardset_footer_navigation_delete_all_cards_text");
$cardset_footer_navigation_delete_all_cards_background_hover: map-get($map, "cardset_footer_navigation_delete_all_cards_background_hover");
$cardset_footer_navigation_delete_all_cards_text_hover: map-get($map, "cardset_footer_navigation_delete_all_cards_text_hover");
$cardset_footer_navigation_transcripts_background: map-get($map, "cardset_footer_navigation_transcripts_background");
$cardset_footer_navigation_transcripts_text: map-get($map, "cardset_footer_navigation_transcripts_text");
$cardset_footer_navigation_transcripts_background_hover: map-get($map, "cardset_footer_navigation_transcripts_background_hover");
$cardset_footer_navigation_transcripts_text_hover: map-get($map, "cardset_footer_navigation_transcripts_text_hover");
//card list
$card_list_number_background: map-get($map, "card_list_number_background");
$card_list_number_text: map-get($map, "card_list_number_text");
......@@ -519,6 +543,8 @@ $themes: (
$markdeep_blockquote_text: map-get($map, "markdeep_blockquote_text");
$markdeep_blockquote_author: map-get($map, "markdeep_blockquote_author");
$markdeep_blockquote_quotes: map-get($map, "markdeep_blockquote_quotes");
//transcript bonus colors
$transcript_bonus_info_text: map-get($map, "transcript_bonus_info_text");
//markdeep editor colors
$markdeep_help_text: map-get($map, "markdeep_help_text");
$markdeep_help_background: map-get($map, "markdeep_help_background");
......@@ -680,6 +706,10 @@ $themes: (
background-color: $background_editor !important;
}
body.transcriptBonus {
background-color: $background_transcript_bonus !important;
}
button:hover, button:focus, .btn:hover, .btn:focus {
background-color: $button_background_hover !important;
color: $button_text_hover !important;
......@@ -1463,6 +1493,16 @@ $themes: (
background-color: $cardset_footer_navigation_delete_all_cards_background_hover !important;
color: $cardset_footer_navigation_delete_all_cards_text_hover !important;
}
.transcriptsBtn {
background-color: $cardset_footer_navigation_transcripts_background !important;
color: $cardset_footer_navigation_transcripts_text !important;
}
.transcriptsBtn:hover, .transcriptsBtn:focus {
background-color: $cardset_footer_navigation_transcripts_background_hover !important;
color: $cardset_footer_navigation_transcripts_text_hover !important;
}
}
.panel-body, .cardContent, #showHintModal {
......@@ -1715,6 +1755,46 @@ $themes: (
color: $navbar_public_repetitorien_text_active !important;
}
//navbar transcripts
#navbar-transcripts > a {
background-color: $navbar_transcripts_background !important;
color: $navbar_transcripts_text !important;
}
#navbar-transcripts > a:hover, #navbar-transcripts > a:focus {
background-color: $navbar_transcripts_background_hover !important;
color: $navbar_transcripts_text_hover !important;
}
#navbar-transcripts.active > a, #navbar-transcripts.active > a:hover, #navbar-transcripts.active > a:focus {
background-color: $navbar_transcripts_background_active !important;
color: $navbar_transcripts_text_active !important;
}
#navbar-transcripts-personal a {
background-color: $navbar_transcripts_personal_background !important;
color: $navbar_transcripts_personal_text !important;
}
#navbar-transcripts-personal a:hover, #navbar-transcripts-personal a:focus {
background-color: $navbar_transcripts_personal_background_hover !important;
color: $navbar_transcripts_personal_text_hover !important;
}
#navbar-transcripts-personal.active a, #navbar-transcripts-personal.active a:hover, #navbar-transcripts-personal.active a:focus {
background-color: $navbar_transcripts_personal_background_active !important;
color: $navbar_transcripts_personal_text_active !important;
}
#navbar-transcripts-bonus a {
background-color: $navbar_transcripts_bonus_background !important;
color: $navbar_transcripts_bonus_text !important;
}
#navbar-transcripts-bonus a:hover, #navbar-transcripts-bonus a:focus {
background-color: $navbar_transcripts_bonus_background_hover !important;
color: $navbar_transcripts_bonus_text_hover !important;
}
#navbar-transcripts-bonus.active a, #navbar-transcripts-bonus.active a:hover, #navbar-transcripts-bonus.active a:focus {
background-color: $navbar_transcripts_bonus_background_active !important;
color: $navbar_transcripts_bonus_text_active !important;
}
//navbar personal
#navbar-personal > a {
background-color: $navbar_personal_background !important;
......@@ -2934,6 +3014,10 @@ $themes: (
}
}
//transcript bonus colors
.transcript-info-text {
color: $transcript_bonus_info_text !important;
}
//presentation colors
.clock {
.circle {
......
......@@ -50,6 +50,7 @@
"background_learning": $default_background,
"background_backend" : $default_background,
"background_editor": $default_background,
"background_transcript_bonus": $default_background,
//global colors
"thm_dark_blue":$thm_dark_blue,
"thm_blue":$thm_blue,
......@@ -176,6 +177,25 @@
"navbar_all_repetitorien_text": white,
"navbar_all_repetitorien_text_hover": $button_text_hover,
"navbar_all_repetitorien_text_active": white,
//navbar transcripts
"navbar_transcripts_background": black,
"navbar_transcripts_background_hover": $button_background_hover,
"navbar_transcripts_background_active": black,
"navbar_transcripts_text": white,
"navbar_transcripts_text_hover": $button_text_hover,
"navbar_transcripts_text_active": $thm_green,
"navbar_transcripts_personal_background": $thm_gray,
"navbar_transcripts_personal_background_hover": $button_background_hover,
"navbar_transcripts_personal_background_active": $thm_green,
"navbar_transcripts_personal_text": white,
"navbar_transcripts_personal_text_hover": $button_text_hover,
"navbar_transcripts_personal_text_active": white,
"navbar_transcripts_bonus_background": $thm_gray,
"navbar_transcripts_bonus_background_hover": $button_background_hover,
"navbar_transcripts_bonus_background_active": $thm_green,
"navbar_transcripts_bonus_text": white,
"navbar_transcripts_bonus_text_hover": $button_text_hover,
"navbar_transcripts_bonus_text_active": white,
//navbar personal
"navbar_personal_background": black,
"navbar_personal_background_hover": $button_background_hover,
......@@ -554,6 +574,10 @@
"cardset_footer_navigation_delete_all_cards_text": white,
"cardset_footer_navigation_delete_all_cards_background_hover": $button_background_hover,
"cardset_footer_navigation_delete_all_cards_text_hover": $button_text_hover,
"cardset_footer_navigation_transcripts_background": $thm_green,
"cardset_footer_navigation_transcripts_text": white,
"cardset_footer_navigation_transcripts_background_hover": $button_background_hover,
"cardset_footer_navigation_transcripts_text_hover": $button_text_hover,
//markdeep colors
"markdeep_inline_code_background": yellow,
"markdeep_inline_code_text": black,
......@@ -561,6 +585,8 @@
"markdeep_blockquote_text": $thm_gray,
"markdeep_blockquote_author": $thm_gray,
"markdeep_blockquote_quotes": $thm_orange,
//transcript bonus colors
"transcript_bonus_info_text": $thm_orange,
//markdeep editor colors
"markdeep_help_text": $white,
"markdeep_help_background": $thm_orange,
......
......@@ -302,11 +302,26 @@
"zero": "Repetitorium anlegen",
"one": "Repetitorium",
"multiple": "Repetitorien"
},
"transcripts": {
"zero": "Mitschrift anlegen",
"one": "Mitschriften",
}
},
"transcripts": {
"zero": "Mitschrift anlegen",
"one": "Mitschriften",
"multiple": "Mitschriften",
"short": {
"zero": "Anlegen",
"one": "Mitschrift",
"multiple": "Mitschriften"
},
"personal": {
"zero": "Lose Mitschrift Anlegen",
"one": "Meine lose Mitschrift",
"multiple": "Meine losen Mitschriften"
},
"bonus": {
"zero": "Verknüpfte Mitschrift Anlegen",
"one": "Meine verknüpfte Mitschrift",
"multiple": "Meine verknüpften Mitschriften"
}
},
"learndecks": "Lernpensum",
......@@ -557,7 +572,8 @@
"emptytextlist": "Eine Kartei besteht aus Karten desselben Typs.",
"emptypooltextlist": "Keine Kartei vorhanden",
"newset": "Kartei anlegen (Kartenbox)",
"emptytexttranscripts": "Du hast noch keine Mitschrift erstellt. Informiere dich unter »Hilfe«, wie du für das Mitschreiben auf \uD83C\uDF45cards Bonuspunkte erhalten kannst."
"emptytexttranscripts": "Du hast noch keine Mitschrift erstellt. Informiere dich unter »Hilfe«, wie du für das Mitschreiben auf \uD83C\uDF45cards Bonuspunkte erhalten kannst.",
"emptytexttranscriptBonus": "Keine Abgaben vorhanden."
},
"set-list-learn-empty": {
"emptytextlist": "Zum Lernen wähle ein Thema aus dem Themenpool oder die Karteien eines Repetitoriums.",
......@@ -629,7 +645,8 @@
"transcriptForm": {
"index": {
"create": "Mitschrift erstellen",
"topic": "Thema der Mitschrift",
"topic": "Thema der losen Mitschrift",
"topicBonus": "Thema der verknüpften Mitschrift",
"tooltip": {
"edit": "Mitschrift bearbeiten",
"delete": "Mitschrift löschen"
......@@ -644,19 +661,28 @@
}
},
"button": {
"modal": "Zugehörigkeit festlegen",
"modal": "Mitschrift verknüpfen",
"save": "Speichern"
},
"title": "Zugehörigkeit der Mitschrift verwalten",
"server": {
"deadlineExpired": "Die Karte kann nicht mehr bearbeitet werden. Die Bearbeitungszeit ist abgelaufen.",
"notFound": "Es wurde keine Vorlesung mit Bonusvergabe gefunden."
},
"title": "Mitschrift mit einer Vorlesung verknüpfen",
"description": "Verknüpfte Mitschriften können nach Ablauf der Abgabe nicht mehr bearbeitet werden",
"placeholder": "Wähle eine Vorlesung mit Bonusvergabe aus…",
"lecture": "Vorlesung",
"referencesLecture": {
"true": "Mit Vorlesung verknüpfen",
"false": "Lose Mitschrift"
},
"selectLecture": "Vorlesung auswählen",
"bonus": {
"button": "Mitschriften",
"button": "Bonus-Mitschriften",
"form": {
"title": "Bonusvergabe für Mitschriften verwalten",
"percentage": "Maximale Bonuspunkte",
"enable": "Bonus aktivieren",
"lectureTimeEnd": "Vorlesungsende",
"deadline": "Bearbeitungszeit",
"lectureDates": "Termine der Veranstaltungen",
......@@ -664,9 +690,13 @@
"hours": "Stunden",
"button": {
"save": "Speichern",
"cancel": "Abbrechen",
"settings": "Einstellungen",
"list": "Abgaben"
"cancel": "Zurück zur Kartei",
"cancelRepetitorium": "Zrück zum Repetitorium",
"settings": "Einstellungen für die Bonusvergabe",
"list": "Verknüpfte Abgaben für die Bonusvergabe"
},
"alert": {
"save": "Änderungen wurden erfolgreich gespeichert"
}
}
}
......
......@@ -303,13 +303,28 @@
"zero": "Repetitorium anlegen",
"one": "Mein Repetitorium",
"multiple": "Meine Repetitorien"
},
"transcripts": {
"zero": "Mitschrift Anlegen",
"one": "Meine Mitschrift",
"multiple": "Meine Mitschriften"
}
},
"transcripts": {
"zero": "Mitschrift Anlegen",
"one": "Meine Mitschrift",
"multiple": "Meine Mitschriften",
"short": {
"zero": "Anlegen",
"one": "Mitschrift",
"multiple": "Mitschriften"
},
"personal": {
"zero": "Lose Mitschrift Anlegen",
"one": "Meine lose Mitschrift",
"multiple": "Meine losen Mitschriften"
},
"bonus": {
"zero": "Verknüpfte Mitschrift Anlegen",
"one": "Meine verknüpfte Mitschrift",
"multiple": "Meine verknüpften Mitschriften"
}
},
"learndecks": "Lernpensum",
"myprofile": "Konto",
"billing": "Abrechnung",
......@@ -559,7 +574,8 @@
"emptytextlist": "Du hast noch keine Kartei erstellt. Informiere dich unter »Hilfe«, was du mit einer eigenen Kartei tun kannst.",
"emptypooltextlist": "Keine Kartei vorhanden",
"newset": "Kartei erstellen (Box für Lernkarten)",
"emptytexttranscripts": "Du hast noch keine Mitschrift erstellt. Informiere dich unter »Hilfe«, was du mit einer eigenen Mitschrift tun kannst."
"emptytexttranscripts": "Du hast noch keine Mitschrift erstellt. Informiere dich unter »Hilfe«, was du mit einer eigenen Mitschrift tun kannst.",
"emptytexttranscriptBonus": "Keine Abgaben vorhanden."
},
"set-list-learn-empty": {
"emptytextlist": "Zum Lernen wähle ein Thema aus dem Themen-Pool oder die Karteien eines Repetitoriums.",
......@@ -641,6 +657,7 @@
"modal": {
"title": "Mitschrift löschen",
"description": "Möchtest du wirklich diese Mitschrift löschen?",
"placeholder": "Wähle eine Vorlesung mit Bonusvergabe aus…",
"button": {
"delete": "Löschen",
"cancel": "Abbrechen"
......@@ -648,19 +665,27 @@
}
},
"button": {
"modal": "Zugehörigkeit festlegen",
"modal": "Mitschrift koppeln",
"save": "Speichern"
},
"title": "Zugehörigkeit der Mitschrift verwalten",
"server": {
"deadlineExpired": "Die Karte kann nicht mehr bearbeitet werden. Die Bearbeitungszeit ist abgelaufen.",
"notFound": "Es wurde keine Vorlesung mit Bonusvergabe gefunden."
},
"title": "Mitschrift mit einer Vorlesung koppeln",
"description": "Gekoppelte Mitschriften können nach Ablauf der Abgabe nicht mehr bearbeitet werden",
"lecture": "Vorlesung",
"referencesLecture": {
"true": "Mit Vorlesung verknüpfen",
"true": "Mit Vorlesung koppeln",
"false": "Private Mitschrift"
},
"selectLecture": "Vorlesung auswählen",
"bonus": {
"button": "Mitschriften",
"button": "Bonus-Mitschriften",
"form": {
"title": "Bonusvergabe für Mitschriften verwalten",
"percentage": "Maximale Bonuspunkte",
"enable": "Bonus aktivieren",
"lectureTimeEnd": "Vorlesungsende",
"deadline": "Bearbeitungszeit",
"lectureDates": "Termine der Veranstaltungen",
......@@ -668,9 +693,13 @@
"hours": "Stunden",
"button": {
"save": "Speichern",
"cancel": "Abbrechen",
"settings": "Einstellungen",
"list": "Abgaben"
"cancel": "Zurück zur Kartei",
"cancelRepetitorium": "Zrück zum Repetitorium",
"settings": "Einstellungen für die Bonusvergabe",
"list": "Gekoppelte Abgaben für die Bonusvergabe"
},
"alert": {
"save": "Änderungen wurden erfolgreich gespeichert"
}
}
}
......
......@@ -129,8 +129,6 @@ export let CardEditor = class CardEditor {
static resetSessionData (resetSubject = false) {
if (resetSubject && Session.get('cameFromEditMode') === false) {
Session.set('subject', '');
Session.set('learningUnit', "0");
Session.set('learningIndex', "0");
}
Session.set('content1', '');
Session.set('content2', '');
......@@ -168,8 +166,6 @@ export let CardEditor = class CardEditor {
Session.set('difficultyColor', difficulty);
Session.set('learningGoalLevel', card.learningGoalLevel);
Session.set('backgroundStyle', card.backgroundStyle);
Session.set('learningUnit', card.learningUnit);
Session.set('learningIndex', card.learningIndex);
}
static setEditorContent (index) {
......@@ -224,14 +220,6 @@ export let CardEditor = class CardEditor {
Session.set('bottomText', '');
}
if (Session.get('learningIndex') === undefined) {
Session.set('learningIndex', '0');
}
if (Session.get('learningUnit') === undefined) {
Session.set('learningUnit', '0');
}
if (Session.get('cardDate') === undefined) {
Session.set('cardDate', new Date());
}
......@@ -252,8 +240,6 @@ export let CardEditor = class CardEditor {
let date = Session.get('cardDate');
let learningGoalLevel = Session.get('learningGoalLevel');
let backgroundStyle = Session.get('backgroundStyle');
let learningIndex = Session.get('learningIndex');
let learningUnit = Session.get('learningUnit');
let subject = Session.get('subject');
let gotSubject = true;
if (!CardType.gotLearningUnit(cardType)) {
......@@ -264,7 +250,7 @@ export let CardEditor = class CardEditor {
gotSubject = false;
}
} else {
if (subject === "" && learningUnit === "0") {
if (subject === "" && Session.get('transcriptBonus') === undefined) {
$('#subjectEditor').css('border', '1px solid');
$('#subjectEditor').css('border-color', '#b94a48');
BertAlertVisuals.displayBertAlert(TAPi18n.__('cardsubject_required'), "danger", 'growl-top-left');
......@@ -306,7 +292,7 @@ export let CardEditor = class CardEditor {
if (!Route.isTranscript()) {
cardset_id = Router.current().params._id;
}
Meteor.call("addCard", cardset_id, subject, content1, content2, content3, content4, content5, content6, centerTextElement, alignType, date, Number(learningGoalLevel), Number(backgroundStyle), learningIndex, learningUnit, function (error, result) {
Meteor.call("addCard", cardset_id, subject, content1, content2, content3, content4, content5, content6, centerTextElement, alignType, date, Number(learningGoalLevel), Number(backgroundStyle), Session.get('transcriptBonus'), function (error, result) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('savecardSuccess'), "success", 'growl-top-left');
if (navigationTarget === 0) {
......@@ -318,7 +304,11 @@ export let CardEditor = class CardEditor {
CardNavigation.selectButton();
} else {
if (Route.isTranscript()) {
Router.go('transcripts');
if (Session.get('transcriptBonus') !== undefined) {
Router.go('transcriptsBonus');
} else {
Router.go('transcriptsPersonal');
}
} else {
Session.set('activeCard', result);
Router.go('cardsetdetailsid', {
......@@ -327,31 +317,44 @@ export let CardEditor = class CardEditor {
}
}
}
if (error) {
BertAlertVisuals.displayBertAlert(error.error, "danger", 'growl-top-left');
}
});
} else {
Meteor.call("updateCard", card_id, subject, content1, content2, content3, content4, content5, content6, centerTextElement, alignType, Number(learningGoalLevel), Number(backgroundStyle), learningIndex, learningUnit);
BertAlertVisuals.displayBertAlert(TAPi18n.__('savecardSuccess'), "success", 'growl-top-left');
Session.set('activeCard', Router.current().params.card_id);
if (navigationTarget === 1) {
if (Route.isTranscript()) {
Router.go('transcripts');
} else {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
Meteor.call("updateCard", card_id, subject, content1, content2, content3, content4, content5, content6, centerTextElement, alignType, Number(learningGoalLevel), Number(backgroundStyle), Session.get('transcriptBonus'), function (error, result) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('savecardSuccess'), "success", 'growl-top-left');
Session.set('activeCard', Router.current().params.card_id);
if (navigationTarget === 1) {
if (Route.isTranscript()) {
if (Session.get('transcriptBonus') !== undefined) {
Router.go('transcriptsBonus');
} else {
Router.go('transcriptsPersonal');
}
} else {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}
} else {
CardEditor.setEditorButtonIndex(CardEditor.getCardNavigationNameIndex(), false);
CardNavigation.selectButton();
window.scrollTo(0, 0);
let nextId = CardIndex.getNextCardID(card_id);
Router.go('editCard', {
_id: Router.current().params._id,
card_id: nextId
});
Session.set('activeCard', nextId);
CardEditor.loadEditModeContent(Cards.findOne({_id: nextId, cardset_id: Router.current().params._id}));
}
}
} else {
CardEditor.setEditorButtonIndex(CardEditor.getCardNavigationNameIndex(), false);
CardNavigation.selectButton();
window.scrollTo(0, 0);
let nextId = CardIndex.getNextCardID(card_id);
Router.go('editCard', {
_id: Router.current().params._id,
card_id: nextId
});
Session.set('activeCard', nextId);
CardEditor.loadEditModeContent(Cards.findOne({_id: nextId, cardset_id: Router.current().params._id}));
}
if (error) {
BertAlertVisuals.displayBertAlert(error.error, "danger", 'growl-top-left');
}
});
}
}
}
......
......@@ -275,8 +275,7 @@ export let CardIndex = class CardIndex {
"cardType": Session.get('cardType'),
"centerTextElement": Session.get('centerTextElement'),
"alignType": Session.get('alignType'),
"date": Session.get('cardDate'),
"learningUnit": Session.get('learningUnit')
"date": Session.get('cardDate')
}];
}
......
......@@ -8,6 +8,7 @@ import {check} from "meteor/check";
import {CardEditor} from "./cardEditor";
import {UserPermissions} from "./permissions";
import {ServerStyle} from "./styles";
import {TranscriptBonus, TranscriptBonusList} from "./transcriptBonus";
export const Cards = new Mongo.Collection("cards");
......@@ -68,7 +69,41 @@ if (Meteor.isServer) {
});
Meteor.publish("myTranscriptCards", function () {
if (this.userId) {
return Cards.find({owner: this.userId, cardType: 2, cardset_id: "-1"});
let bonusTranscripts = TranscriptBonus.find({owner: this.user_id}).fetch();
let cardFilter = [];
for (let i = 0; i < bonusTranscripts.length; i++) {
cardFilter.push(bonusTranscripts[i].card_id);
}
return Cards.find({_id: {$nin: cardFilter}, owner: this.userId, cardType: 2, cardset_id: "-1"});
} else {
this.ready();
}
});
Meteor.publish("myBonusTranscriptCards", function () {
if (this.userId) {
let bonusTranscripts = TranscriptBonus.find({owner: this.user_id}).fetch();
let cardFilter = [];
for (let i = 0; i < bonusTranscripts.length; i++) {
cardFilter.push(bonusTranscripts[i].card_id);
}
return Cards.find({_id: {$in: cardFilter}, owner: this.userId, cardType: 2, cardset_id: "-1"});
} else {
this.ready();
}
});
Meteor.publish("cardsetTranscriptBonusCards", function (cardset_id) {
if (this.userId) {
let cardset = Cardsets.findOne({_id: cardset_id}, {fields: {_id: 1, owner: 1}});
if (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner)) {
let bonusTranscripts = TranscriptBonus.find({cardset_id: cardset._id}).fetch();
let cardFilter = [];
for (let i = 0; i < bonusTranscripts.length; i++) {
cardFilter.push(bonusTranscripts[i].card_id);
}
return Cards.find({_id: {$in: cardFilter}, cardType: 2, cardset_id: "-1"});
} else {
this.ready();
}
} else {
this.ready();
}
......@@ -193,14 +228,6 @@ var CardsSchema = new SimpleSchema({
backgroundStyle: {
type: Number
},
learningIndex: {
type: String,
optional: true
},
learningUnit: {
type: String,
optional: true
},
originalAuthor: {
type: String,
optional: true
......@@ -223,7 +250,7 @@ var CardsSchema = new SimpleSchema({
Cards.attachSchema(CardsSchema);
Meteor.methods({
addCard: function (cardset_id, subject, content1, content2, content3, content4, content5, content6, centerTextElement, alignType, date, learningGoalLevel, backgroundStyle, learningIndex, learningUnit) {
addCard: function (cardset_id, subject, content1, content2, content3, content4, content5, content6, centerTextElement, alignType, date, learningGoalLevel, backgroundStyle, transcriptBonusUser) {
check(cardset_id, String);
check(subject, String);
check(content1, String);
......@@ -237,8 +264,6 @@ Meteor.methods({
check(date, Date);
check(learningGoalLevel, Number);
check(backgroundStyle, Number);
check(learningIndex, String);
check(learningUnit, String);
// Make sure the user is logged in and is authorized
let cardset = Cardsets.findOne(cardset_id);
let isOwner = false;
......@@ -252,8 +277,13 @@ Meteor.methods({
}
if (UserPermissions.isAdmin() || isOwner) {
if (subject === "") {
throw new Meteor.Error("Missing subject");
if (subject === "" && transcriptBonusUser === undefined) {
throw new Meteor.Error(TAPi18n.__('cardsubject_required', {}, Meteor.user().profile.locale));
}
if (transcriptBonusUser) {
if (!TranscriptBonusList.canBeSubmittedToLecture(transcriptBonusUser, Number(transcriptBonusUser.date_id))) {
throw new Meteor.Error(TAPi18n.__('transcriptForm.server.notFound', {}, Meteor.user().profile.locale));
}
}
let card_id = Cards.insert({
subject: subject.trim(),
......@@ -269,12 +299,13 @@ Meteor.methods({
date: date,
learningGoalLevel: learningGoalLevel,
backgroundStyle: backgroundStyle,
learningIndex: learningIndex,
learningUnit: learningUnit,
owner: Meteor.userId(),
cardType: cardType,
dateUpdated: new Date()
}, {trimStrings: false});
if (transcriptBonusUser) {
Meteor.call("addTranscriptBonus", card_id, transcriptBonusUser.cardset_id, Meteor.userId(), Number(transcriptBonusUser.date_id));
}
if (cardset_id !== "-1") {
Cardsets.update(cardset_id, {
$set: {
......@@ -320,8 +351,6 @@ Meteor.methods({
let content4 = "";
let content5 = "";
let content6 = "";
let learningUnit = "";
let learningIndex = -1;
if (card.front !== undefined) {
content1 = card.front;
}
......@@ -340,20 +369,18 @@ Meteor.methods({
if (card.bottom !== undefined) {
content6 = card.bottom;
}
if (card.learningUnit !== undefined) {
learningUnit = card.learningUnit;
}
Meteor.call("addCard", targetCardset_id, card.subject, content1, content2, content3, content4, content5, content6, "0", card.centerTextElement, card.alignType, card.date, card.learningGoalLevel, card.backgroundStyle, learningIndex, learningUnit);
Meteor.call("addCard", targetCardset_id, card.subject, content1, content2, content3, content4, content5, content6, "0", card.centerTextElement, card.alignType, card.