Commit d616f2c0 authored by Curtis Adam's avatar Curtis Adam

Move personal transcripts out of cardsets

parent c012250b
......@@ -290,8 +290,8 @@
"personal": {
"personal": {
"zero": "Anlegen",
"one": "Meine Karten",
"multiple": "Meine Karten"
"one": "Meine Inhalte",
"multiple": "Meine Inhalte"
},
"cardsets": {
"zero": "Kartei anlegen",
......@@ -302,6 +302,11 @@
"zero": "Repetitorium anlegen",
"one": "Repetitorium",
"multiple": "Repetitorien"
},
"transcripts": {
"zero": "Mitschrift Anlegen",
"one": "Meine Mitschrift",
"multiple": "Meine Mitschriften"
}
},
"learndecks": "Lernpensum",
......@@ -551,7 +556,8 @@
"set-list-empty": {
"emptytextlist": "Eine Kartei besteht aus Karten desselben Typs.",
"emptypooltextlist": "Keine Kartei vorhanden",
"newset": "Kartei anlegen (Kartenbox)"
"newset": "Kartei anlegen (Kartenbox)",
"emptytexttranscripts": "Du hast noch keine Mitschrift erstellt. Informiere dich unter »Hilfe«, was du mit einer eigenen Mitschrift tun kannst."
},
"set-list-learn-empty": {
"emptytextlist": "Zum Lernen wähle ein Thema aus dem Themenpool oder die Karteien eines Repetitoriums.",
......@@ -593,6 +599,7 @@
"personal": {
"create": "Ich will eine Kartei anlegen – 'ne Kartenbox.",
"cardsets": "Ich will zu meinen Kartensätzen.",
"transcripts": "Ich will zu meinen Mitschriften",
"repetitorien": "Ich will zu meinen Repetitorien."
},
"pool": "Ich suche Kartensätze zu einem Thema.",
......@@ -603,6 +610,7 @@
"cancel": "Danke, ich kenne mich aus.",
"personal": {
"cardsets": "Bring mich zu meinen Karteien!",
"transcripts": "Bring mich zu meinen Mitschriften!",
"repetitorien": "Bring mich zu meinen Reps!"
},
"pool": "Bring mich zur Karteien-Suche!",
......@@ -618,6 +626,51 @@
"sortContent": "Nach Inhalt sortieren"
}
},
"transcriptForm": {
"index": {
"create": "Mitschrift erstellen",
"topic": "Thema der Mitschrift",
"tooltip": {
"edit": "Mitschrift bearbeiten",
"delete": "Mitschrift löschen"
},
"modal": {
"title": "Mitschrift löschen",
"description": "Möchtest du wirklich diese Mitschrift löschen?",
"button": {
"delete": "Löschen",
"cancel": "Abbrechen"
}
}
},
"button": {
"modal": "Zugehörigkeit festlegen",
"save": "Speichern"
},
"title": "Zugehörigkeit der Mitschrift verwalten",
"referencesLecture": {
"true": "Mit Vorlesung verknüpfen",
"false": "Private Mitschrift"
},
"selectLecture": "Vorlesung auswählen",
"bonus": {
"button": "Mitschriften",
"form": {
"title": "Bonusvergabe für Mitschriften verwalten",
"lectureTimeEnd": "Vorlesungsende",
"deadline": "Bearbeitungszeit",
"lectureDates": "Termine der Veranstaltungen",
"clock": "Uhr",
"hours": "Stunden",
"button": {
"save": "Speichern",
"cancel": "Abbrechen",
"settings": "Einstellungen",
"list": "Abgaben"
}
}
}
},
"modal-dialog": {
"missingFields": "Bitte fülle die folgenden Felder aus",
"newcarddeck": "Kartei anlegen (Kartenbox)",
......
......@@ -291,8 +291,8 @@
"personal": {
"personal": {
"zero": "Anlegen",
"one": "Meine Karten",
"multiple": "Meine Karten"
"one": "Meine Inhalte",
"multiple": "Meine Inhalte"
},
"cardsets": {
"zero": "Kartei anlegen",
......@@ -303,8 +303,13 @@
"zero": "Repetitorium anlegen",
"one": "Mein Repetitorium",
"multiple": "Meine Repetitorien"
},
"transcripts": {
"zero": "Mitschrift Anlegen",
"one": "Meine Mitschrift",
"multiple": "Meine Mitschriften"
}
},
},
"learndecks": "Lernpensum",
"myprofile": "Konto",
"billing": "Abrechnung",
......@@ -553,7 +558,8 @@
"set-list-empty": {
"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)"
"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."
},
"set-list-learn-empty": {
"emptytextlist": "Zum Lernen wähle ein Thema aus dem Themen-Pool oder die Karteien eines Repetitoriums.",
......@@ -596,6 +602,7 @@
"personal": {
"create": "I want to create a card index with cards of the type:",
"cardsets": "I want to see all my card indexes.",
"transcripts": "I want to see my transcripts.",
"repetitorien": "Ich will Reps verwalten."
},
"pool": "I want to find a card index on a specific topic.",
......@@ -607,6 +614,7 @@
"personal": {
"create": "Go",
"cardsets": "Go",
"transcripts": "Go",
"repetitorien": "Go"
},
"pool": "Go",
......@@ -622,6 +630,51 @@
"sortContent": "Nach Inhalt sortieren"
}
},
"transcriptForm": {
"index": {
"create": "Mitschrift erstellen",
"topic": "Thema der Mitschrift",
"tooltip": {
"edit": "Mitschrift bearbeiten",
"delete": "Mitschrift löschen"
},
"modal": {
"title": "Mitschrift löschen",
"description": "Möchtest du wirklich diese Mitschrift löschen?",
"button": {
"delete": "Löschen",
"cancel": "Abbrechen"
}
}
},
"button": {
"modal": "Zugehörigkeit festlegen",
"save": "Speichern"
},
"title": "Zugehörigkeit der Mitschrift verwalten",
"referencesLecture": {
"true": "Mit Vorlesung verknüpfen",
"false": "Private Mitschrift"
},
"selectLecture": "Vorlesung auswählen",
"bonus": {
"button": "Mitschriften",
"form": {
"title": "Bonusvergabe für Mitschriften verwalten",
"lectureTimeEnd": "Vorlesungsende",
"deadline": "Bearbeitungszeit",
"lectureDates": "Termine der Veranstaltungen",
"clock": "Uhr",
"hours": "Stunden",
"button": {
"save": "Speichern",
"cancel": "Abbrechen",
"settings": "Einstellungen",
"list": "Abgaben"
}
}
}
},
"modal-dialog": {
"missingFields": "Bitte fülle die folgenden Felder aus",
"newcarddeck": "Kartei erstellen (Box für Lernkarten)",
......
......@@ -8,7 +8,7 @@ export let AspectRatio = class AspectRatio {
static isEnabled () {
if ((CardVisuals.isFullscreen() && !MarkdeepEditor.getMobilePreview()) || (Route.isDemo() || Route.isMakingOf())) {
if (Route.isPresentation() && config.aspectRatioEnabled.includes(0)) {
if ((Route.isPresentation() || Route.isPresentationTranscript()) && config.aspectRatioEnabled.includes(0)) {
return true;
}
if ((Route.isDemo() || Route.isMakingOf()) && config.aspectRatioEnabled.includes(1)) {
......@@ -27,7 +27,7 @@ export let AspectRatio = class AspectRatio {
}
static scaleCardNavigationWidth () {
if (Route.isPresentation() && config.scaleCardNavigationWidth.includes(0)) {
if ((Route.isPresentation() || Route.isPresentationTranscript()) && config.scaleCardNavigationWidth.includes(0)) {
return true;
}
if ((Route.isDemo() || Route.isMakingOf()) && config.scaleCardNavigationWidth.includes(1)) {
......@@ -45,7 +45,7 @@ export let AspectRatio = class AspectRatio {
}
static getDefault () {
if (Route.isPresentation() || Route.isCardset()) {
if (Route.isPresentation() || Route.isPresentationTranscript() || Route.isCardset()) {
if (NavigatorCheck.isIOS()) {
return config.defaultAspectRatioTablet[0];
} else {
......
......@@ -145,7 +145,16 @@ export let CardEditor = class CardEditor {
}
static loadEditModeContent (card) {
let cardset = Cardsets.findOne({_id: Router.current().params._id});
let difficulty;
let cardType;
if (Route.isTranscript()) {
difficulty = card.difficulty;
cardType = card.cardType;
} else {
let cardset = Cardsets.findOne({_id: Router.current().params._id});
difficulty = cardset.difficulty;
cardType = cardset.cardType;
}
Session.set('subject', card.subject);
Session.set('content1', card.front);
Session.set('content2', card.back);
......@@ -153,10 +162,10 @@ export let CardEditor = class CardEditor {
Session.set('content4', card.lecture);
Session.set('content5', card.top);
Session.set('content6', card.bottom);
Session.set('cardType', cardset.cardType);
Session.set('cardType', cardType);
Session.set('centerTextElement', card.centerTextElement);
Session.set('alignType', card.alignType);
Session.set('difficultyColor', cardset.difficulty);
Session.set('difficultyColor', difficulty);
Session.set('learningGoalLevel', card.learningGoalLevel);
Session.set('backgroundStyle', card.backgroundStyle);
Session.set('learningUnit', card.learningUnit);
......@@ -292,8 +301,12 @@ export let CardEditor = class CardEditor {
}
let editorsValidLength = (content1.length <= contentMaxLength && content2.length <= contentMaxLength && content3.length <= contentMaxLength && $('#subjectEditor').val().length <= subjectMaxLength && content4.length <= contentMaxLength && content5.length <= contentMaxLength && content6.length <= contentMaxLength);
if (gotSubject && editorsValidLength) {
if (ActiveRoute.name('newCard')) {
Meteor.call("addCard", Router.current().params._id, subject, content1, content2, content3, content4, content5, content6, centerTextElement, alignType, date, Number(learningGoalLevel), Number(backgroundStyle), learningIndex, learningUnit, function (error, result) {
if (Route.isNewCard()) {
let cardset_id = "-1";
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) {
if (result) {
BertAlertVisuals.displayBertAlert(TAPi18n.__('savecardSuccess'), "success", 'growl-top-left');
if (navigationTarget === 0) {
......@@ -304,10 +317,14 @@ export let CardEditor = class CardEditor {
CardEditor.setEditorButtonIndex(CardEditor.getCardNavigationNameIndex(), false);
CardNavigation.selectButton();
} else {
Session.set('activeCard', result);
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
if (Route.isTranscript()) {
Router.go('transcripts');
} else {
Session.set('activeCard', result);
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}
}
}
});
......@@ -316,9 +333,13 @@ export let CardEditor = class CardEditor {
BertAlertVisuals.displayBertAlert(TAPi18n.__('savecardSuccess'), "success", 'growl-top-left');
Session.set('activeCard', Router.current().params.card_id);
if (navigationTarget === 1) {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
if (Route.isTranscript()) {
Router.go('transcripts');
} else {
Router.go('cardsetdetailsid', {
_id: Router.current().params._id
});
}
} else {
CardEditor.setEditorButtonIndex(CardEditor.getCardNavigationNameIndex(), false);
CardNavigation.selectButton();
......
......@@ -59,35 +59,39 @@ export let CardIndex = class CardIndex {
let sortQuery;
let indexCards = [];
let cardset;
if (Route.isDemo()) {
cardset = Cardsets.findOne({kind: 'demo', name: 'DemoCardset', shuffled: true});
} else if (Route.isMakingOf()) {
cardset = Cardsets.findOne({kind: 'demo', name: 'MakingOfCardset', shuffled: true});
if (Route.isTranscript()) {
return 0;
} else {
cardset = Cardsets.findOne(Router.current().params._id);
}
if (cardset.shuffled) {
let cardGroups = Cardsets.find({_id: {$in: cardset.cardGroups}}, {
sort: {name: 1},
fields: {_id: 1, cardType: 1}
});
cardGroups.forEach(function (cardGroup) {
sortQuery = CardType.getSortQuery(cardGroup.cardType, cardGroup.sortType);
indexCards = Cards.find({cardset_id: cardGroup._id}, {
sort: sortQuery, fields: {_id: 1}
if (Route.isDemo()) {
cardset = Cardsets.findOne({kind: 'demo', name: 'DemoCardset', shuffled: true});
} else if (Route.isMakingOf()) {
cardset = Cardsets.findOne({kind: 'demo', name: 'MakingOfCardset', shuffled: true});
} else {
cardset = Cardsets.findOne(Router.current().params._id);
}
if (cardset.shuffled) {
let cardGroups = Cardsets.find({_id: {$in: cardset.cardGroups}}, {
sort: {name: 1},
fields: {_id: 1, cardType: 1}
});
indexCards.forEach(function (indexCard) {
cardIndex.push(indexCard._id);
cardGroups.forEach(function (cardGroup) {
sortQuery = CardType.getSortQuery(cardGroup.cardType, cardGroup.sortType);
indexCards = Cards.find({cardset_id: cardGroup._id}, {
sort: sortQuery, fields: {_id: 1}
});
indexCards.forEach(function (indexCard) {
cardIndex.push(indexCard._id);
});
});
});
} else {
sortQuery = CardType.getSortQuery(cardset.cardType, cardset.sortType);
indexCards = Cards.find({cardset_id: cardset._id}, {sort: sortQuery, fields: {_id: 1}});
indexCards.forEach(function (indexCard) {
cardIndex.push(indexCard._id);}
} else {
sortQuery = CardType.getSortQuery(cardset.cardType, cardset.sortType);
indexCards = Cards.find({cardset_id: cardset._id}, {sort: sortQuery, fields: {_id: 1}});
indexCards.forEach(function (indexCard) {
cardIndex.push(indexCard._id);}
);
}
return cardIndex;
}
return cardIndex;
}
static leitnerIndex () {
......@@ -193,19 +197,23 @@ export let CardIndex = class CardIndex {
*/
static getCardsetCards () {
let query = "";
let cardIndexFilter = this.getCardIndexFilter();
if (Session.get('activeCardset').shuffled) {
query = Cards.find({
_id: {$in: cardIndexFilter},
cardset_id: {$in: Session.get('activeCardset').cardGroups}
}).fetch();
if (Route.isPresentationTranscript()) {
return Cards.find(Router.current().params.card_id).fetch();
} else {
query = Cards.find({
_id: {$in: cardIndexFilter},
cardset_id: Router.current().params._id
}).fetch();
let cardIndexFilter = this.getCardIndexFilter();
if (Session.get('activeCardset').shuffled) {
query = Cards.find({
_id: {$in: cardIndexFilter},
cardset_id: {$in: Session.get('activeCardset').cardGroups}
}).fetch();
} else {
query = Cards.find({
_id: {$in: cardIndexFilter},
cardset_id: Router.current().params._id
}).fetch();
}
return this.sortQueryResult(cardIndexFilter, query);
}
return this.sortQueryResult(cardIndexFilter, query);
}
/**
......@@ -246,6 +254,10 @@ export let CardIndex = class CardIndex {
} else {
Session.set('activeCard', undefined);
}
let cardset_id = -1;
if (!Route.isTranscript()) {
cardset_id = Router.current().params._id;
}
return [{
"_id": id,
"subject": Session.get('subject'),
......@@ -258,7 +270,7 @@ export let CardIndex = class CardIndex {
"lecture": Session.get('content4'),
"top": Session.get('content5'),
"bottom": Session.get('content6'),
"cardset_id": Router.current().params._id,
"cardset_id": cardset_id,
"cardGroup": 0,
"cardType": Session.get('cardType'),
"centerTextElement": Session.get('centerTextElement'),
......@@ -307,7 +319,11 @@ export let CardIndex = class CardIndex {
}
static getActiveCardIndex (card_id) {
let cardIndex = this.getCardIndex();
return cardIndex.findIndex(item => item === card_id) + 1;
if (Route.isTranscript()) {
return 0;
} else {
let cardIndex = this.getCardIndex();
return cardIndex.findIndex(item => item === card_id) + 1;
}
}
};
......@@ -205,11 +205,13 @@ export let CardNavigation = class CardNavigation {
localStorage.setItem(lastActiveCardString, JSON.stringify(lastActiveCard));
}
let cardset_id;
if (Session.get('activeCard') === -1 || Session.get('activeCard') === undefined) {
if (Session.get('activeCard') === -1 || Session.get('activeCard') === undefined || Route.isTranscript()) {
if (Route.isDemo()) {
Session.set('activeCardsetName', Cardsets.findOne({name: "DemoCardset", shuffled: true}).name);
} else if (Route.isMakingOf()) {
Session.set('activeCardsetName', Cardsets.findOne({name: "MakingOfCardset", shuffled: true}).name);
} else if (Route.isTranscript()) {
Session.set('activeCardsetName', "");
} else {
Session.set('activeCardsetName', Cardsets.findOne({_id: Router.current().params._id}).name);
}
......
......@@ -527,20 +527,27 @@ export let CardVisuals = class CardVisuals {
let cardset_id = "";
let cardsetData;
if (cards !== undefined) {
for (let i = 0; i < cards.length; i++) {
if (cardset_id !== cards[i].cardset_id) {
cardset_id = cards[i].cardset_id;
cardsetData = Cardsets.findOne({_id: cardset_id}, {
fields: {
cardType: 1,
difficulty: 1
}
});
if (Route.isTranscript()) {
cards[0].cardType = 2;
cards[0].difficulty = 0;
cards[0].cardset_id = -1;
return cards;
} else {
for (let i = 0; i < cards.length; i++) {
if (cardset_id !== cards[i].cardset_id) {
cardset_id = cards[i].cardset_id;
cardsetData = Cardsets.findOne({_id: cardset_id}, {
fields: {
cardType: 1,
difficulty: 1
}
});
}
cards[i].cardType = cardsetData.cardType;
cards[i].difficulty = cardsetData.difficulty;
}
cards[i].cardType = cardsetData.cardType;
cards[i].difficulty = cardsetData.difficulty;
return cards;
}
return cards;
} else {
return [];
}
......
......@@ -66,6 +66,22 @@ if (Meteor.isServer) {
this.ready();
}
});
Meteor.publish("myTranscriptCards", function () {
if (this.userId) {
return Cards.find({owner: this.userId, cardType: 2, cardset_id: "-1"});
} else {
this.ready();
}
});
Meteor.publish("transcriptCard", function (card_id) {
if (UserPermissions.isAdmin()) {
return Cards.find({_id: card_id, cardType: 2, cardset_id: "-1"});
} else if (this.userId) {
return Cards.find({_id: card_id, owner: this.userId, cardType: 2, cardset_id: "-1"});
} else {
this.ready();
}
});
Meteor.publish("cardsetCards", function (cardset_id) {
let cardset = Cardsets.findOne({_id: cardset_id}, {fields: {_id: 1, owner: 1, cardGroups: 1, kind: 1}});
if ((this.userId || ServerStyle.isLoginEnabled("guest")) && UserPermissions.isNotBlockedOrFirstLogin() && cardset !== undefined) {
......@@ -193,6 +209,14 @@ var CardsSchema = new SimpleSchema({
type: Object,
optional: true,
blackbox: true
},
owner: {
type: String,
optional: true
},
cardType: {
type: Number,
optional: true
}
});
......@@ -217,15 +241,19 @@ Meteor.methods({
check(learningUnit, String);
// Make sure the user is logged in and is authorized
let cardset = Cardsets.findOne(cardset_id);
if (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner)) {
if (cardset.cardType !== 2 || cardset.cardType !== 3 || cardset.cardType !== 5) {
if (subject === "") {
throw new Meteor.Error("Missing subject");
}
} else {
if (subject === "" && learningUnit === "") {
throw new Meteor.Error("Missing subject or reference");
}
let isOwner = false;
let cardType;
if (cardset_id === "-1") {
isOwner = true;
cardType = 2;
} else {
isOwner = UserPermissions.isOwner(cardset.owner);
cardType = cardset.cardType;
}
if (UserPermissions.isAdmin() || isOwner) {
if (subject === "") {
throw new Meteor.Error("Missing subject");
}
let card_id = Cards.insert({
subject: subject.trim(),
......@@ -242,23 +270,30 @@ Meteor.methods({
learningGoalLevel: learningGoalLevel,
backgroundStyle: backgroundStyle,
learningIndex: learningIndex,
learningUnit: learningUnit
learningUnit: learningUnit,
owner: Meteor.userId(),
cardType: cardType,
dateUpdated: new Date()
}, {trimStrings: false});
Cardsets.update(cardset_id, {
$set: {
quantity: Cards.find({cardset_id: cardset_id}).count(),
dateUpdated: new Date()
if (cardset_id !== "-1") {
Cardsets.update(cardset_id, {
$set: {
quantity: Cards.find({cardset_id: cardset_id}).count(),
dateUpdated: new Date()
}
});
Meteor.call('updateShuffledCardsetQuantity', cardset_id);
let cardsets = Cardsets.find({
$or: [
{_id: cardset_id},
{cardGroups: {$in: [cardset_id]}}
]
}, {fields: {_id: 1}}).fetch();
for (let i = 0; i < cardsets.length; i++) {
Meteor.call('updateLeitnerCardIndex', cardsets[i]._id);
}
});
Meteor.call('updateShuffledCardsetQuantity', cardset_id);
let cardsets = Cardsets.find({
$or: [
{_id: cardset_id},
{cardGroups: {$in: [cardset_id]}}
]
}, {fields: {_id: 1}}).fetch();
for (let i = 0; i < cardsets.length; i++) {
Meteor.call('updateLeitnerCardIndex', cardsets[i]._id);
} else {
Meteor.call('updateTranscriptCount', Meteor.userId());
}
return card_id;
} else {
......@@ -270,7 +305,13 @@ Meteor.methods({
check(targetCardset_id, String);
check(card_id, String);
let cardset = Cardsets.findOne(sourceCardset_id);
if (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner)) {
let isOwner = false;
if (sourceCardset_id === "-1") {
isOwner = true;
} else {
isOwner = UserPermissions.isOwner(cardset.owner);
}
if (UserPermissions.isAdmin() || isOwner) {
let card = Cards.findOne(card_id);
if (card !== undefined) {
let content1 = "";
......@@ -309,6 +350,14 @@ Meteor.methods({
throw new Meteor.Error("not-authorized");
}
},
deleteTranscript: function (card_id) {
let card = Cards.findOne(card_id);
if (card.owner === Meteor.userId() || UserPermissions.isAdmin()) {
let result = Cards.remove(card_id);
Meteor.call('updateTranscriptCount', Meteor.userId());
return result;
}
},
deleteCard: function (card_id) {
check(card_id, String);
......@@ -328,14 +377,18 @@ Meteor.methods({
}
let result = Cards.remove(card_id);
Cardsets.update(card.cardset_id, {
$set: {
quantity: Cards.find({cardset_id: card.cardset_id}).count(),
dateUpdated: new Date()
}
});
if (card.cardset_id !== "-1") {
Cardsets.update(card.cardset_id, {
$set: {
quantity: Cards.find({cardset_id: card.cardset_id}).count(),
dateUpdated: new Date()
}
});
Meteor.call('updateShuffledCardsetQuantity', cardset._id);
Meteor.call('updateShuffledCardsetQuantity', cardset._id);
} else {
Meteor.call('updateTranscriptCount', Meteor.userId());
}
Leitner.remove({
card_id: card_id
......@@ -365,15 +418,15 @@ Meteor.methods({
check(learningUnit, String);
let card = Cards.findOne(card_id);
let cardset = Cardsets.findOne(card.cardset_id);
if (UserPermissions.isAdmin() || UserPermissions.isOwner(cardset.owner))