-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2353 from oat-sa/hotfix/AUT-2882/categories-in-su…
…bsections Backport AUT-2882 categories in subsections to November 2022
- Loading branch information
Showing
13 changed files
with
456 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,16 +13,14 @@ | |
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2017 (original work) Open Assessment Technologies SA ; | ||
* Copyright (c) 2017-2023 (original work) Open Assessment Technologies SA ; | ||
*/ | ||
/** | ||
* Helper that provides a way to browse all categories attached to a test model at the item level. | ||
* | ||
* @author Jean-Sébastien Conan <[email protected]> | ||
*/ | ||
define([ | ||
'lodash' | ||
], function (_) { | ||
define(['lodash'], function (_) { | ||
'use strict'; | ||
|
||
/** | ||
|
@@ -41,13 +39,21 @@ define([ | |
* @param {Function} cb | ||
*/ | ||
function eachCategories(testModel, cb) { | ||
const getCategoriesRecursively = section => { | ||
_.forEach(section.sectionParts, function (sectionPart) { | ||
if (sectionPart['qti-type'] === 'assessmentItemRef') { | ||
_.forEach(sectionPart.categories, function (category) { | ||
cb(category, sectionPart); | ||
}); | ||
} | ||
if (sectionPart['qti-type'] === 'assessmentSection') { | ||
getCategoriesRecursively(sectionPart); | ||
} | ||
}); | ||
}; | ||
_.forEach(testModel.testParts, function (testPart) { | ||
_.forEach(testPart.assessmentSections, function (assessmentSection) { | ||
_.forEach(assessmentSection.sectionParts, function (itemRef) { | ||
_.forEach(itemRef.categories, function(category) { | ||
cb(category, itemRef); | ||
}); | ||
}); | ||
getCategoriesRecursively(assessmentSection); | ||
}); | ||
}); | ||
} | ||
|
@@ -70,7 +76,7 @@ define([ | |
*/ | ||
listCategories: function listCategories(testModel) { | ||
var categories = {}; | ||
eachCategories(testModel, function(category) { | ||
eachCategories(testModel, function (category) { | ||
if (!isCategoryOption(category)) { | ||
categories[category] = true; | ||
} | ||
|
@@ -86,7 +92,7 @@ define([ | |
*/ | ||
listOptions: function listOptions(testModel) { | ||
var options = {}; | ||
eachCategories(testModel, function(category) { | ||
eachCategories(testModel, function (category) { | ||
if (isCategoryOption(category)) { | ||
options[category] = true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.