-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ admin: get most recent flash algo config
- Loading branch information
1 parent
a3b4b4e
commit 55cd423
Showing
9 changed files
with
227 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import ApplicationAdapter from './application'; | ||
|
||
export default class FlashAlgorithmConfigurationAdapter extends ApplicationAdapter { | ||
namespace = 'api/admin'; | ||
|
||
queryRecord() { | ||
const url = `${this.host}/${this.namespace}/flash-assessment-configuration`; | ||
return this.ajax(url, 'GET'); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
admin/app/components/administration/certification/flash-algorithm-configuration.gjs
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import PixBlock from '@1024pix/pix-ui/components/pix-block'; | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixInput from '@1024pix/pix-ui/components/pix-input'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class FlashAlgorithmConfiguration extends Component { | ||
@tracked form = { | ||
maximumAssessmentLength: this.args.model.maximumAssessmentLength, | ||
warmUpLength: this.args.model.warmUpLength, | ||
challengesBetweenSameCompetence: this.args.model.challengesBetweenSameCompetence, | ||
variationPercent: this.args.model.variationPercent, | ||
variationPercentUntil: this.args.model.variationPercentUntil, | ||
doubleMeasuresUntil: this.args.model.doubleMeasuresUntil, | ||
limitToOneQuestionPerTube: this.args.model.limitToOneQuestionPerTube, | ||
enablePassageByAllCompetences: this.args.model.enablePassageByAllCompetences, | ||
}; | ||
|
||
<template> | ||
<PixBlock class="page-section"> | ||
|
||
<h2 class="page-section__title"> | ||
Configuration de l’algorithme de déroulé du test | ||
</h2> | ||
|
||
<form class="flash-algorithm-configuration-form"> | ||
<PixInput @id="maximumAssessmentLength" @value={{this.form.maximumAssessmentLength}} type="number"> | ||
<:label>Nombre de questions</:label> | ||
</PixInput> | ||
|
||
<PixInput @id="warmUpLength" @value={{this.form.warmUpLength}} type="number"> | ||
<:label>Nombre de questions d'entrainement</:label> | ||
</PixInput> | ||
|
||
<PixInput | ||
@id="challengesBetweenSameCompetence" | ||
@value={{this.form.challengesBetweenSameCompetence}} | ||
type="number" | ||
> | ||
<:label>Nombre de questions entre 2 questions de la même compétence</:label> | ||
</PixInput> | ||
|
||
<PixInput @id="variationPercent" @value={{this.form.variationPercent}} type="number"> | ||
<:label>Capage de la capacité (en % )</:label> | ||
</PixInput> | ||
|
||
<PixInput @id="variationPercentUntil" @value={{this.form.variationPercentUntil}} type="number"> | ||
<:label>Nombre de questions pour le capage de la capacité</:label> | ||
</PixInput> | ||
|
||
<PixInput @id="doubleMeasuresUntil" @value={{this.form.doubleMeasuresUntil}} type="number"> | ||
<:label>Nombre de questions pour la double mesure</:label> | ||
</PixInput> | ||
|
||
<PixInput | ||
@id="limitToOneQuestionPerTube" | ||
@value={{this.form.limitToOneQuestionPerTube}} | ||
checked={{this.form.limitToOneQuestionPerTube}} | ||
type="checkbox" | ||
> | ||
<:label>Limiter à une question par sujet</:label> | ||
</PixInput> | ||
|
||
<PixInput | ||
@id="enablePassageByAllCompetences" | ||
@value={{this.form.enablePassageByAllCompetences}} | ||
checked={{this.form.enablePassageByAllCompetences}} | ||
type="checkbox" | ||
> | ||
<:label>Forcer le passage par les 16 compétences</:label> | ||
</PixInput> | ||
|
||
<PixButton class="scoring-simulator__form-button" @type="submit">Créer</PixButton> | ||
</form> | ||
</PixBlock> | ||
</template> | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Model, { attr } from '@ember-data/model'; | ||
|
||
export default class FlashAlgorithmConfiguration extends Model { | ||
@attr('number') warmUpLength; | ||
@attr('number') maximumAssessmentLength; | ||
@attr('number') challengesBetweenSameCompetence; | ||
@attr('number') variationPercent; | ||
@attr('number') variationPercentUntil; | ||
@attr('number') doubleMeasuresUntil; | ||
@attr('boolean') limitToOneQuestionPerTube; | ||
@attr('boolean') enablePassageByAllCompetences; | ||
@attr('array') forcedCompetences; | ||
@attr('array') minimumEstimatedSuccessRateRanges; | ||
} |
12 changes: 12 additions & 0 deletions
12
admin/app/routes/authenticated/administration/certification.js
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Route from '@ember/routing/route'; | ||
import { service } from '@ember/service'; | ||
|
||
export default class CertificationRoute extends Route { | ||
@service store; | ||
|
||
async model() { | ||
return this.store.queryRecord('flash-algorithm-configuration', { | ||
id: 0, | ||
}); | ||
} | ||
} |
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
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
56 changes: 56 additions & 0 deletions
56
...ntegration/components/administration/certification/flash-algorithm-configuration_test.gjs
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { render } from '@1024pix/ember-testing-library'; | ||
import FlashAlgorithmConfiguration from 'pix-admin/components/administration/certification/flash-algorithm-configuration'; | ||
import { module, test } from 'qunit'; | ||
|
||
import setupIntlRenderingTest from '../../../../helpers/setup-intl-rendering'; | ||
|
||
module('Integration | Component | administration/certification/flash-algorithm-configuration', function (hooks) { | ||
setupIntlRenderingTest(hooks); | ||
|
||
test('should display all details', async function (assert) { | ||
// given | ||
const flashAlgorithmConfiguration = { | ||
maximumAssessmentLength: 1, | ||
warmUpLength: 2, | ||
challengesBetweenSameCompetence: 3, | ||
variationPercent: 4, | ||
variationPercentUntil: 5, | ||
doubleMeasuresUntil: 6, | ||
limitToOneQuestionPerTube: true, | ||
enablePassageByAllCompetences: false, | ||
}; | ||
|
||
// when | ||
const screen = await render( | ||
<template><FlashAlgorithmConfiguration @model={{flashAlgorithmConfiguration}} /></template>, | ||
); | ||
|
||
// then | ||
const maximumAssessmentLength = await screen.getByRole('spinbutton', { name: 'Nombre de questions' }).value; | ||
const warmUpLength = await screen.getByRole('spinbutton', { name: "Nombre de questions d'entrainement" }).value; | ||
const challengesBetweenSameCompetence = await screen.getByRole('spinbutton', { | ||
name: 'Nombre de questions entre 2 questions de la même compétence', | ||
}).value; | ||
const variationPercent = await screen.getByRole('spinbutton', { name: 'Capage de la capacité (en % )' }).value; | ||
const variationPercentUntil = await screen.getByRole('spinbutton', { | ||
name: 'Nombre de questions pour le capage de la capacité', | ||
}).value; | ||
const doubleMeasuresUntil = await screen.getByRole('spinbutton', { | ||
name: 'Nombre de questions pour la double mesure', | ||
}).value; | ||
const limitToOneQuestionPerTube = await screen.getByRole('checkbox', { name: 'Limiter à une question par sujet' }) | ||
.value; | ||
const enablePassageByAllCompetences = await screen.getByRole('checkbox', { | ||
name: 'Forcer le passage par les 16 compétences', | ||
}).value; | ||
|
||
assert.strictEqual(maximumAssessmentLength, '1'); | ||
assert.strictEqual(warmUpLength, '2'); | ||
assert.strictEqual(challengesBetweenSameCompetence, '3'); | ||
assert.strictEqual(variationPercent, '4'); | ||
assert.strictEqual(variationPercentUntil, '5'); | ||
assert.strictEqual(doubleMeasuresUntil, '6'); | ||
assert.strictEqual(limitToOneQuestionPerTube, 'true'); | ||
assert.strictEqual(enablePassageByAllCompetences, 'false'); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
admin/tests/unit/adapters/flash-algorithm-configuration_test.js
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { setupTest } from 'ember-qunit'; | ||
import ENV from 'pix-admin/config/environment'; | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
module('Unit | Adapters | flash-algorithm-configuration', function (hooks) { | ||
setupTest(hooks); | ||
|
||
module('#queryRecord', () => { | ||
test('should build query url', async function (assert) { | ||
// given | ||
const adapter = this.owner.lookup('adapter:flash-algorithm-configuration'); | ||
sinon.stub(adapter, 'ajax'); | ||
|
||
// when | ||
adapter.queryRecord(); | ||
|
||
// then | ||
const expectedUrl = `${ENV.APP.API_HOST}/api/admin/flash-assessment-configuration`; | ||
sinon.assert.calledWith(adapter.ajax, expectedUrl, 'GET'); | ||
assert.ok(adapter); | ||
}); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
admin/tests/unit/routes/authenticated/administration/certification_test.js
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Service from '@ember/service'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
module('Unit | Route | authenticated/administration/certification', function (hooks) { | ||
setupTest(hooks); | ||
|
||
module('#model', function () { | ||
test('it should return the correct model', async function (assert) { | ||
// given | ||
const queryRecordStub = sinon.stub(); | ||
class StoreStub extends Service { | ||
queryRecord = queryRecordStub; | ||
} | ||
this.owner.register('service:store', StoreStub); | ||
const route = this.owner.lookup('route:authenticated/administration/certification'); | ||
const expectedModel = Symbol('model'); | ||
queryRecordStub.withArgs('flash-algorithm-configuration', { id: 0 }).resolves(expectedModel); | ||
|
||
// when | ||
const model = await route.model(); | ||
|
||
// then | ||
assert.deepEqual(model, expectedModel); | ||
}); | ||
}); | ||
}); |