diff --git a/junior/app/models/challenge.js b/junior/app/models/challenge.js index 03f7f068257..8577f4fb5e2 100644 --- a/junior/app/models/challenge.js +++ b/junior/app/models/challenge.js @@ -30,6 +30,8 @@ export default class Challenge extends Model { @attr('boolean') shuffled; @attr() webComponentProps; @attr('string') webComponentTagName; + @attr('boolean') hasEmbedInternalValidation; + @attr('boolean') noValidationNeeded; @hasMany('activity-answer', { async: true, inverse: 'challenge' }) activityAnswers; @@ -44,7 +46,7 @@ export default class Challenge extends Model { } get isLesson() { - return !!this.focused; + return !!this.focused || this.noValidationNeeded; } get isQROC() { @@ -72,7 +74,7 @@ export default class Challenge extends Model { } get isEmbedAutoValidated() { - return this.timer !== null && this.timer >= 0; + return (this.timer !== null && this.timer >= 0) || this.hasEmbedInternalValidation; } get hasMedia() { diff --git a/junior/tests/unit/models/challenge-test.js b/junior/tests/unit/models/challenge-test.js index 3319fdf751b..7e16b21b801 100644 --- a/junior/tests/unit/models/challenge-test.js +++ b/junior/tests/unit/models/challenge-test.js @@ -40,6 +40,56 @@ module('Unit | Model | Challenge', function (hooks) { }); }); + module('#isLesson', function () { + test('should be true if focused is true', function (assert) { + const challenge = store.createRecord('challenge', { + focused: true, + }); + assert.true(challenge.isLesson); + }); + test('should be true if noValidationNeeded is true', function (assert) { + const challenge = store.createRecord('challenge', { + noValidationNeeded: true, + }); + assert.true(challenge.isLesson); + }); + test('should be false if noValidationNeeded & focused are not set', function (assert) { + const challenge = store.createRecord('challenge'); + assert.false(challenge.isLesson); + }); + test('should be false if noValidationNeeded & focused are false', function (assert) { + const challenge = store.createRecord('challenge', { + focused: false, + noValidationNeeded: false, + }); + assert.false(challenge.isLesson); + }); + }); + module('#isEmbedAutoValidated', function () { + test('should be true if timer is set', function (assert) { + const challenge = store.createRecord('challenge', { + timer: 1, + }); + assert.true(challenge.isEmbedAutoValidated); + }); + test('should be true if hasEmbedInternalValidation is true', function (assert) { + const challenge = store.createRecord('challenge', { + hasEmbedInternalValidation: true, + }); + assert.true(challenge.isEmbedAutoValidated); + }); + test('should be false if timer & hasEmbedInternalValidation are not set', function (assert) { + const challenge = store.createRecord('challenge'); + assert.false(challenge.isEmbedAutoValidated); + }); + test('should be false hasEmbedInternalValidation is false', function (assert) { + const challenge = store.createRecord('challenge', { + hasEmbedInternalValidation: false, + }); + assert.false(challenge.isEmbedAutoValidated); + }); + }); + module('#hasWebComponent', function () { test('should be true when web component name and web component props are fields', function (assert) { const challenge = store.createRecord('challenge', {