Skip to content

Commit

Permalink
Merge pull request #3798 from rtibbles/bulk_completion_criteria
Browse files Browse the repository at this point in the history
Bulk completion criteria fix
  • Loading branch information
marcellamaki committed Nov 7, 2022
2 parents 72acf9e + ace8bac commit b6d632f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<Checkbox
v-model="learnerManaged"
color="primary"
:indeterminate="notUnique"
:disabled="notUnique"
:label="$tr('learnersCanMarkComplete')"
style="padding-bottom: 16px;"
/>
Expand All @@ -17,6 +19,7 @@
ref="completion"
v-model="completionDropdown"
box
:placeholder="getPlaceholder('value')"
:items="showCorrectCompletionOptions"
:label="translateMetadataString('completion')"
:required="required"
Expand Down Expand Up @@ -61,6 +64,7 @@
ref="duration"
v-model="durationDropdown"
box
:placeholder="getPlaceholder('value')"
:items="selectableDurationOptions"
:label="translateMetadataString('duration')"
:required="required"
Expand Down Expand Up @@ -205,6 +209,9 @@
},
},
computed: {
notUnique() {
return this.value === nonUniqueValue;
},
model() {
return this.value.model || defaultCompletionCriteriaModels[this.kind];
},
Expand Down Expand Up @@ -238,6 +245,9 @@
},
completionDropdown: {
get() {
if (this.notUnique) {
return;
}
if (
this.value.modality === ContentModalities.QUIZ &&
this.model === CompletionCriteriaModels.MASTERY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@
import difference from 'lodash/difference';
import get from 'lodash/get';
import intersection from 'lodash/intersection';
import isEqual from 'lodash/isEqual';
import uniq from 'lodash/uniq';
import uniqWith from 'lodash/uniqWith';
import { mapGetters, mapActions } from 'vuex';
import ContentNodeThumbnail from '../../views/files/thumbnails/ContentNodeThumbnail';
import FileUpload from '../../views/files/FileUpload';
Expand Down Expand Up @@ -634,8 +636,11 @@
thumbnailEncoding: generateGetterSetter('thumbnail_encoding'),
completionAndDuration: {
get() {
const { completion_criteria, modality } =
this.getExtraFieldsValueFromNodes('options') || {};
const options = this.getExtraFieldsValueFromNodes('options', {});
if (options === nonUniqueValue) {
return nonUniqueValue;
}
const { completion_criteria, modality } = options;
const suggested_duration_type = this.getExtraFieldsValueFromNodes(
'suggested_duration_type'
);
Expand Down Expand Up @@ -808,7 +813,7 @@
return getValueFromResults(results);
},
getExtraFieldsValueFromNodes(key, defaultValue = null) {
const results = uniq(
const results = uniqWith(
this.nodes.map(node => {
if (
Object.prototype.hasOwnProperty.call(
Expand All @@ -820,7 +825,8 @@
return this.diffTracker[node.id].extra_fields[key];
}
return get(node.extra_fields, key, defaultValue);
})
}),
isEqual
);
return getValueFromResults(results);
},
Expand Down

0 comments on commit b6d632f

Please sign in to comment.