Skip to content

Commit

Permalink
Merge pull request #4245 from bjester/merge-down-abc
Browse files Browse the repository at this point in the history
Merge down hotfixes into unstable
  • Loading branch information
bjester authored Jul 27, 2023
2 parents 5ab69cb + a0d657a commit 212b46b
Show file tree
Hide file tree
Showing 76 changed files with 2,237 additions and 562 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
root = true

[*]
max_line_length = 100

[*.js]
indent_size = 2

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ migrate:
# 4) Remove the management command from this `deploy-migrate` recipe
# 5) Repeat!
deploy-migrate:
python contentcuration/manage.py export_channels_to_kolibri_public
echo "Nothing to do here!"

contentnodegc:
python contentcuration/manage.py garbage_collect
Expand Down
6 changes: 5 additions & 1 deletion contentcuration/contentcuration/db/models/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ def _copy_tags(self, source_copy_id_map):
tag_id_map[tag.id] = new_tag.id
tags_to_create.append(new_tag)

# TODO: Can cleanup the above and change the below to use ignore_conflicts=True
ContentTag.objects.bulk_create(tags_to_create)

mappings_to_create = [
Expand All @@ -499,7 +500,10 @@ def _copy_tags(self, source_copy_id_map):
for mapping in node_tags_mappings
]

self.model.tags.through.objects.bulk_create(mappings_to_create)
# In the case that we are copying a node that is in the weird state of having a tag
# that is duplicated (with a channel tag and a null channel tag) this can cause an error
# so we ignore conflicts here to ignore the duplicate tags.
self.model.tags.through.objects.bulk_create(mappings_to_create, ignore_conflicts=True)

def _copy_assessment_items(self, source_copy_id_map):
from contentcuration.models import File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
channel() {
return this.getChannel(this.channelId);
},
name() {
return this.channel.name;
},
searchChannelEditorsLink() {
return {
name: RouteNames.USERS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</template>
<LoadingText v-if="loading" absolute />
<VCardText v-else>
<Banner error :value="channel.deleted" class="mb-4">
<Banner error :value="isDeleted" class="mb-4">
This channel has been deleted
</Banner>
<VTabsItems v-model="tab">
Expand Down Expand Up @@ -102,6 +102,9 @@
channel() {
return this.getChannel(this.channelId);
},
isDeleted() {
return this.channel && Boolean(this.channel?.deleted);
},
channelWithDetails() {
if (!this.channel || !this.details) {
return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
importedChannelLink,
secondsToHms,
getCompletionCriteriaLabels,
getCompletionDataFromNode,
} from '../utils';
import router from '../router';
import { RouteNames } from '../constants';
Expand Down Expand Up @@ -475,6 +476,76 @@ describe('channelEdit utils', () => {
});

describe(`getCompletionCriteriaLabels`, () => {
describe(`setting default values for completion and duration`, () => {
describe(`for audio and video content`, () => {
it(`returns 'When time spent is equal to duration' completion label and duration label equal to the file length in hh:mm:ss format`, () => {
expect(
getCompletionCriteriaLabels(
{
extra_fields: {
options: {},
},
kind: 'audio',
},
[{ duration: 100 }]
)
).toEqual({
completion: 'When time spent is equal to duration',
duration: '01:40',
});
});
it(`returns 'When time spent is equal to duration' completion label and duration label equal to the file length in hh:mm:ss format`, () => {
expect(
getCompletionCriteriaLabels(
{
extra_fields: {
options: {},
},
kind: 'video',
},
[{ duration: 100 }]
)
).toEqual({
completion: 'When time spent is equal to duration',
duration: '01:40',
});
});
});
describe(`for documents`, () => {
it(`returns 'Viewed in its entirety' completion label and empty duration label`, () => {
expect(
getCompletionCriteriaLabels(
{
extra_fields: {
options: {},
},
kind: 'document',
},
[]
)
).toEqual({
completion: 'Viewed in its entirety',
duration: '-',
});
});
});
describe(`for exercises`, () => {
it(`sets the Completion Criteria model to 'mastery'`, () => {
expect(
getCompletionDataFromNode(
{
extra_fields: {
options: {},
},
kind: 'exercise',
},
[]
).completionModel
).toEqual('mastery');
});
});
});

describe(`for 'reference' completion criteria`, () => {
it(`returns 'Reference material' completion label and empty duration label`, () => {
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
v-on="on"
@click="clickItem(action)"
>
<Icon :color="iconColor(action)">
<Icon v-if="config[action] && config[action].icon" :color="iconColor(action)">
{{ config[action].icon }}
</Icon>
</VBtn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
>
{{ category(node.categories) }}
</span>
<span v-if="(isTopic && node.coach_count) || isCoach">
<span v-if="isTopic && node.coach_count">
<!-- for each learning activity -->
<VTooltip bottom lazy>
<template #activator="{ on }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<ResourcePanel
:nodeId="nodeId"
:channelId="channelId"
:useRouting="useRouting"
@close="$emit('close')"
>
<template #navigation>
Expand Down Expand Up @@ -66,6 +67,10 @@
type: Boolean,
default: true,
},
useRouting: {
type: Boolean,
default: true,
},
},
methods: {
// @public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
>
<VTab
class="px-2"
:to="{ query: { tab: 'questions' } }"
exact
@change="tab = 'questions'"
>
{{ $tr('questions') }}
<Icon
Expand All @@ -90,8 +90,8 @@
</VTab>
<VTab
class="px-2"
:to="{ query: { tab: 'details' } }"
exact
@change="tab = 'details'"
>
{{ $tr('details') }}
<Icon
Expand Down Expand Up @@ -587,11 +587,16 @@
type: Boolean,
default: false,
},
useRouting: {
type: Boolean,
default: true,
},
},
data() {
return {
loading: false,
showAnswers: false,
currentTab: 'details',
};
},
computed: {
Expand All @@ -609,7 +614,7 @@
return getCompletionCriteriaLabels(this.node).completion;
},
duration() {
return getCompletionCriteriaLabels(this.node).duration;
return getCompletionCriteriaLabels(this.node, this.files).duration;
},
files() {
return sortBy(this.getContentNodeFiles(this.nodeId), f => f.preset.order);
Expand All @@ -619,6 +624,10 @@
if (!this.isExercise) {
return;
}
if (!this.useRouting) {
this.currentTab = value;
return;
}
// If viewing an exercise, we need to synchronize the the route's
// query params with the 'tab' value
const newRoute = { query: { tab: value } };
Expand All @@ -629,8 +638,8 @@
}
},
get() {
if (!this.isExercise) {
return 'details';
if (!this.isExercise || !this.useRouting) {
return this.currentTab;
}
return this.$route.query.tab || 'questions';
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
<script>
import get from 'lodash/get';
import {
defaultCompletionCriteriaModels,
defaultCompletionCriteriaThresholds,
CompletionOptionsDropdownMap,
completionCriteriaToDropdownMap,
} from '../../utils';
import MasteryCriteriaMofNFields from './MasteryCriteriaMofNFields';
import ActivityDuration from './ActivityDuration.vue';
import MasteryCriteriaGoal from './MasteryCriteriaGoal';
Expand All @@ -125,59 +131,6 @@
const DEFAULT_SHORT_ACTIVITY = 600;
const DEFAULT_LONG_ACTIVITY = 3000;
const defaultCompletionCriteriaModels = {
[ContentKindsNames.VIDEO]: CompletionCriteriaModels.TIME,
[ContentKindsNames.AUDIO]: CompletionCriteriaModels.TIME,
[ContentKindsNames.DOCUMENT]: CompletionCriteriaModels.PAGES,
[ContentKindsNames.H5P]: CompletionCriteriaModels.DETERMINED_BY_RESOURCE,
[ContentKindsNames.HTML5]: CompletionCriteriaModels.APPROX_TIME,
[ContentKindsNames.EXERCISE]: CompletionCriteriaModels.MASTERY,
};
const defaultCompletionCriteriaThresholds = {
// Audio and Video threshold defaults are dynamic based
// on the duration of the file itself.
[ContentKindsNames.DOCUMENT]: '100%',
[ContentKindsNames.HTML5]: 300,
// We cannot set an automatic default threshold for exercises.
};
const completionCriteriaToDropdownMap = {
[CompletionCriteriaModels.TIME]: CompletionDropdownMap.completeDuration,
[CompletionCriteriaModels.APPROX_TIME]: CompletionDropdownMap.completeDuration,
[CompletionCriteriaModels.PAGES]: CompletionDropdownMap.allContent,
[CompletionCriteriaModels.DETERMINED_BY_RESOURCE]: CompletionDropdownMap.determinedByResource,
[CompletionCriteriaModels.MASTERY]: CompletionDropdownMap.goal,
[CompletionCriteriaModels.REFERENCE]: CompletionDropdownMap.reference,
};
const CompletionOptionsDropdownMap = {
[ContentKindsNames.DOCUMENT]: [
CompletionDropdownMap.allContent,
CompletionDropdownMap.completeDuration,
CompletionDropdownMap.reference,
],
[ContentKindsNames.EXERCISE]: [CompletionDropdownMap.goal, CompletionDropdownMap.practiceQuiz],
[ContentKindsNames.HTML5]: [
CompletionDropdownMap.completeDuration,
CompletionDropdownMap.determinedByResource,
CompletionDropdownMap.reference,
],
[ContentKindsNames.H5P]: [
CompletionDropdownMap.determinedByResource,
CompletionDropdownMap.completeDuration,
CompletionDropdownMap.reference,
],
[ContentKindsNames.VIDEO]: [
CompletionDropdownMap.completeDuration,
CompletionDropdownMap.reference,
],
[ContentKindsNames.AUDIO]: [
CompletionDropdownMap.completeDuration,
CompletionDropdownMap.reference,
],
};
export default {
name: 'CompletionOptions',
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
ref="author"
:items="authors"
:label="$tr('authorLabel')"
:readonly="disableAuthEdits"
:disabled="disableSourceEdits"
maxlength="200"
counter
autoSelectFirst
Expand All @@ -267,7 +267,7 @@
ref="provider"
:items="providers"
:label="$tr('providerLabel')"
:readonly="disableAuthEdits"
:disabled="disableSourceEdits"
maxlength="200"
counter
:placeholder="getPlaceholder('provider')"
Expand All @@ -288,7 +288,7 @@
ref="aggregator"
:items="aggregators"
:label="$tr('aggregatorLabel')"
:readonly="disableAuthEdits"
:disabled="disableSourceEdits"
maxlength="200"
counter
autoSelectFirst
Expand All @@ -309,7 +309,7 @@
ref="license"
v-model="licenseItem"
:required="isUnique(license) && isUnique(license_description) && !disableAuthEdits"
:readonly="disableAuthEdits"
:disabled="disableSourceEdits"
:placeholder="getPlaceholder('license')"
:descriptionPlaceholder="getPlaceholder('license_description')"
@focus="trackClick('License')"
Expand All @@ -328,7 +328,7 @@
:rules="copyrightHolderRules"
:placeholder="getPlaceholder('copyright_holder')"
autoSelectFirst
:readonly="disableAuthEdits"
:disabled="disableSourceEdits"
box
:value="copyright_holder && copyright_holder.toString()"
@input.native="(e) => (copyright_holder = e.srcElement.value)"
Expand Down Expand Up @@ -658,6 +658,9 @@
disableAuthEdits() {
return this.nodes.some(node => node.freeze_authoring_data);
},
disableSourceEdits() {
return this.disableAuthEdits || this.isImported;
},
detectedImportText() {
const count = this.nodes.filter(node => node.freeze_authoring_data).length;
return this.$tr('detectedImportText', { count });
Expand Down
Loading

0 comments on commit 212b46b

Please sign in to comment.