Skip to content

Commit

Permalink
Merge pull request #1119 from Program-AR/show-all-expects
Browse files Browse the repository at this point in the history
Control group: feedback from challenge configuration
  • Loading branch information
asanzo authored Sep 26, 2022
2 parents 6a7e3da + aa70b2f commit 1e35906
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 90 deletions.
11 changes: 8 additions & 3 deletions app/components/non-scored-expectations.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object'
import { expectationDescription } from '../utils/expectations';
export default Component.extend({

expectsScoring: service('expects-scoring'),
challengeExpectations: service('challenge-expectations'),
intl: service(),

expectsResults: computed('expects', function () {
return this.expectsScoring.expectsResults(this.expects).filter(expect => expect.description.forControlGroup)
expectations: computed('challenge', function () {
return this.challengeExpectations.expectationsIdsForControlGroup(this.challenge)
.map(id => ({
id,
description: expectationDescription(this.intl, id, false, { isForControlGroup: true })
}))
}),

});
16 changes: 15 additions & 1 deletion app/services/challenge-expectations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Service from '@ember/service'
import { isEmpty, sum } from 'ramda'
import { allProceduresShould, doesNotUseRecursion, doSomething, isUsed, isUsedFromMain, multiExpect, notTooLong, mainNotTooLong, noExpectation, nameWasChanged, doesNotNestControlStructures } from '../utils/expectations'
import { allProceduresShould, doesNotUseRecursion, doSomething, isUsed, isUsedFromMain, multiExpect, notTooLong, mainNotTooLong, noExpectation, nameWasChanged, doesNotNestControlStructures, decompositionExpectsIdsForControlGroup } from '../utils/expectations'
import { inject as service } from '@ember/service';

// Be careful when adding new expects. idsToScore should be potentially updated too.
Expand Down Expand Up @@ -65,6 +65,14 @@ const idsToScore = {
*/
}

// TODO: DELETE. I cant even...
const idsToExpectationsIdsForControl = {
decomposition: decompositionExpectsIdsForControlGroup,
decomposition9: decompositionExpectsIdsForControlGroup,

// Other configurations, such as conditionals and repetitions, are not used yet.
}


export default Service.extend({
intl: service(),
Expand Down Expand Up @@ -149,5 +157,11 @@ export default Service.extend({

idToScore(id) {
return idsToScore[id] || 0
},

expectationsIdsForControlGroup(challenge) {
return Object.entries(this.allExpectConfigurationsMerged(challenge))
.filter(([, shouldBeApplied]) => shouldBeApplied)
.flatMap(([id,]) => idsToExpectationsIdsForControl[id] || [])
}
})
2 changes: 1 addition & 1 deletion app/templates/components/expectation-modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/>
{{else}}
<NonScoredExpectations
@expects={{expects}}
@challenge={{challenge}}
/>
{{/if}}
</Modal>
2 changes: 1 addition & 1 deletion app/templates/components/non-scored-expectations.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class='expectationResults' >
{{#each expectsResults as |result|}}
{{#each expectations as |result|}}
<p>
{{paper-icon "radio_button_unchecked"}}
{{result.description.forControlGroup}}
Expand Down
6 changes: 4 additions & 2 deletions app/utils/expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const notTooLong = (limit = 7) => (declaration) =>
declarationNotTooLong(limit, declaration, tooLongId)

export const mainNotTooLong = (limit = 7) =>
declarationNotTooLong(limit, entryPointType, "main_too_long")
declarationNotTooLong(limit, entryPointType, mainTooLongId)

export const noExpectation = () => ''

Expand Down Expand Up @@ -127,6 +127,7 @@ export const isUsedFromMainId = 'is_used_from_main'

const doSomethingId = 'do_something'
const tooLongId = 'too_long'
const mainTooLongId = "main_too_long"
const nameWasChangedId = 'name_was_changed'
const conditionalAlternativeId = 'uses_conditional_alternative'
const conditionalRepetitionId = 'uses_conditional_repetition'
Expand All @@ -141,4 +142,5 @@ export const warningInControlStructureBlock = (expectationResult) => expectation

export const isUsageResult = (expectationResult) => expectationResult && expectationResult.isRelatedToUsage


// WARNING: tied to expectations types. Please update both.
export const decompositionExpectsIdsForControlGroup = [mainTooLongId, tooLongId, doSomethingId, nameWasChangedId, doesNotNestControlStructuresId]
Loading

0 comments on commit 1e35906

Please sign in to comment.