Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control group: feedback from challenge configuration #1119

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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