Skip to content

Commit

Permalink
show all categories, refs opencast#505
Browse files Browse the repository at this point in the history
If an item of type "categories" of a questionnaire omits the field "categories", just show all existing categories.
  • Loading branch information
mlunzena committed Sep 8, 2021
1 parent 38cbb5c commit 498e095
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 10 additions & 1 deletion frontend/js/views/questionnaire-block-categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ define([
this.validationErrors = [];
},
render: function () {
var categories = _.invoke(_.filter(_.map(this.item.categories, getCategoryByName)), "toJSON");
var categories = getCategories(this.item);
this.$el.html(
template(
{
Expand Down Expand Up @@ -88,6 +88,15 @@ define([
}
});

function getCategories(item) {
return _.invoke(
"categories" in item
? _.filter(_.map(item.categories, getCategoryByName))
: annotationTool.video.get("categories").models,
"toJSON"
);
}

function getCategoryByName(name) {
return annotationTool.video.get("categories").models.find(function (category) {
return category.get("name") === name;
Expand Down
10 changes: 5 additions & 5 deletions frontend/js/views/questionnaire.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ function getMockupQuestionnaire() {
"type": "categories",
"title": "2a. Interpretation",
"description": "Interpretieren und erklären Sie möglichst theoriegeleitet die (Re-)Aktion der Lehrperson (und ggf. der SuS) in dieser Unterrichtssequenz. Nutzen Sie die Kategorien des Analysefokus. (Wählen Sie mindestens eine Kategorie aus)",
"categories": [
"KF-MO: Monitoring",
"KF-ST: Strukturierung",
"KF-RR: Regeln und Routinen"
],
// "categories": [
// "KF-MO: Monitoring",
// "KF-ST: Strukturierung",
// "KF-RR: Regeln und Routinen"
// ],
"minItems": 1
},
"item-2": {
Expand Down

0 comments on commit 498e095

Please sign in to comment.