Skip to content

Commit

Permalink
Merge branch 'fix/TAO-2515/error_saving_category' into release-2.16.8
Browse files Browse the repository at this point in the history
  • Loading branch information
krampstudio committed Jul 15, 2016
2 parents fdf3e58 + 190dae3 commit 6fd2c9d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'label' => 'QTI test model',
'description' => 'TAO QTI test implementation',
'license' => 'GPL-2.0',
'version' => '2.16.7',
'version' => '2.16.8',
'author' => 'Open Assessment Technologies',
'requires' => array(
'taoTests' => '>=2.6',
Expand Down
2 changes: 1 addition & 1 deletion scripts/update/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function update($initialVersion) {
}

$this->setVersion($currentVersion);
$this->skip('2.16.4', '2.16.7');
$this->skip('2.16.4', '2.16.8');

}
}
69 changes: 41 additions & 28 deletions views/js/controller/creator/helpers/qtiTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,38 +157,51 @@ define(['lodash', 'i18n'], function(_, __){
* @returns {Object}
*/
consolidateModel : function consolidateModel(model){
if(model && model.testParts && _.isArray(model.testParts) && model.testParts[0]){
var testPart = model.testParts[0];
if(testPart.assessmentSections && _.isArray(testPart.assessmentSections)){
_.forEach(testPart.assessmentSections, function(assessmentSection, key) {

//remove ordering is shuffle is false
if(assessmentSection.ordering &&
assessmentSection.ordering.shuffle !== undefined && assessmentSection.ordering.shuffle === false){
delete assessmentSection.ordering;
}

if(assessmentSection.rubricBlocks && _.isArray(assessmentSection.rubricBlocks)) {

//remove rubrick blocks if empty
if (assessmentSection.rubricBlocks.length === 0 ||
(assessmentSection.rubricBlocks.length === 1 && assessmentSection.rubricBlocks[0].content.length === 0) ) {

delete assessmentSection.rubricBlocks;
}
//ensure the view attribute is present
else if(assessmentSection.rubricBlocks.length > 0){
_.forEach(assessmentSection.rubricBlocks, function(rubricBlock){
if(model && model.testParts && _.isArray(model.testParts)){

_.forEach(model.testParts, function(testPart) {

if(testPart.assessmentSections && _.isArray(testPart.assessmentSections)){

_.forEach(testPart.assessmentSections, function(assessmentSection) {

//remove ordering is shuffle is false
if(assessmentSection.ordering &&
assessmentSection.ordering.shuffle !== undefined && assessmentSection.ordering.shuffle === false){
delete assessmentSection.ordering;
}

// clean categories (QTI identifier can't be empty string)
if(assessmentSection.sectionParts && _.isArray(assessmentSection.sectionParts)) {
_.forEach(assessmentSection.sectionParts, function(part) {
if(part.categories && _.isArray(part.categories) && (part.categories.length === 0 || part.categories[0].length === 0)) {
part.categories = [];
}
});
}

if(assessmentSection.rubricBlocks && _.isArray(assessmentSection.rubricBlocks)) {

//remove rubrick blocks if empty
if (assessmentSection.rubricBlocks.length === 0 ||
(assessmentSection.rubricBlocks.length === 1 && assessmentSection.rubricBlocks[0].content.length === 0) ) {

delete assessmentSection.rubricBlocks;
}
//ensure the view attribute is present
else if(assessmentSection.rubricBlocks.length > 0){
_.forEach(assessmentSection.rubricBlocks, function(rubricBlock){
rubricBlock.views = ['candidate'];
//change once views are supported
//if(rubricBlock && rubricBlock.content && (!rubricBlock.views || (_.isArray(rubricBlock.views) && rubricBlock.views.length === 0))){
//rubricBlock.views = ['candidate'];
//rubricBlock.views = ['candidate'];
//}
});
}
}
});
}
});
}
}
});
}
});
}
return model;
}
Expand Down

0 comments on commit 6fd2c9d

Please sign in to comment.