Skip to content

Commit

Permalink
issue/2884 Automatic detection of view-only question models (#2885)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Aug 24, 2020
1 parent 021daed commit 90dc249
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/js/adapt.js
Expand Up @@ -270,6 +270,14 @@ define([
nameModelOrData = nameModelOrData.toJSON();
}
if (nameModelOrData instanceof Object) {
const name = nameModelOrData._component;
const entry = this.store[name];
const isViewOnlyQuestion = entry && !entry.model && entry.view && entry.view._isQuestionType;
if (isViewOnlyQuestion) {
// Use question model by default
this.log && this.log.deprecated(`Assuming a question model for a view-only question: ${name}`);
return 'question';
}
const names = [
typeof nameModelOrData._model === 'string' && nameModelOrData._model,
typeof nameModelOrData._component === 'string' && nameModelOrData._component,
Expand Down
3 changes: 3 additions & 0 deletions src/core/js/models/questionModel.js
Expand Up @@ -335,6 +335,9 @@ define([

}

// This abstract model needs to registered to support deprecated view-only questions
Adapt.register('question', { model: QuestionModel });

return QuestionModel;

});

0 comments on commit 90dc249

Please sign in to comment.