Skip to content

Commit

Permalink
Cleanup strings
Browse files Browse the repository at this point in the history
- move shared strings to metadata strings
- remove unused strings
  • Loading branch information
MisRob committed May 5, 2023
1 parent 74162ca commit 6a82930
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
/>
</DetailsRow>

<DetailsRow :label="$tr('completion')">
<DetailsRow :label="translateMetadataString('completion')">
<span v-if="isExercise && noMasteryModel" class="red--text">
<Icon color="red" small>error</Icon>
<span class="mx-1">{{ $tr('noMasteryModelError') }}</span>
Expand Down Expand Up @@ -663,7 +663,6 @@
$trs: {
questions: 'Questions',
details: 'Details',
completion: 'Completion',
showAnswers: 'Show answers',
questionCount: '{value, number, integer} {value, plural, one {question} other {questions}}',
description: 'Description',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
showCorrectCompletionOptions() {
if (this.kind) {
return CompletionOptionsDropdownMap[this.kind].map(model => ({
text: this.$tr(model),
text: this.translateMetadataString(model),
value: CompletionDropdownMap[model],
}));
}
Expand All @@ -402,7 +402,7 @@
selectableDurationOptions() {
return [
{
text: this.$tr(DurationDropdownMap.EXACT_TIME),
text: this.translateMetadataString(DurationDropdownMap.EXACT_TIME),
value: 'exactTime',
},
{
Expand Down Expand Up @@ -514,15 +514,6 @@
},
},
$trs: {
/* eslint-disable kolibri/vue-no-unused-translations */
allContent: 'Viewed in its entirety',
completeDuration: 'When time spent is equal to duration',
determinedByResource: 'Determined by the resource',
goal: 'When goal is met',
practiceQuiz: 'Practice quiz',
reference: 'Reference material',
/* eslint-enable */
exactTime: 'Time to complete',
referenceHint:
'Progress will not be tracked on reference material unless learners mark it as complete',
learnersCanMarkComplete: 'Allow learners to mark as complete',
Expand Down
22 changes: 6 additions & 16 deletions contentcuration/contentcuration/frontend/channelEdit/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import translator from './translator';
import { RouteNames } from './constants';
import { createTranslator } from 'shared/i18n';
import { MasteryModelsNames } from 'shared/leUtils/MasteryModels';
import { metadataStrings, constantStrings } from 'shared/mixins';
import {
Expand Down Expand Up @@ -158,15 +157,6 @@ export function assessmentItemKey(assessmentItem) {
};
}

// TODO: Rename and move to metadata strings translator
const completionStrings = createTranslator('CompletionStrings', {
reference: 'Reference material',
completeDuration: 'When time spent is equal to duration',
allContent: 'Viewed in its entirety',
determinedByResource: 'Determined by the resource',
masteryMofN: 'Goal: {m} out of {n}',
});

/**
* Converts a value in seconds to a human-readable format.
* If the value is greater than or equal to one hour, the format will be hh:mm:ss.
Expand Down Expand Up @@ -255,18 +245,18 @@ export function getCompletionCriteriaLabels(node) {

switch (completionModel) {
case CompletionCriteriaModels.REFERENCE:
labels.completion = completionStrings.$tr('reference');
labels.completion = metadataStrings.$tr('reference');
break;

case CompletionCriteriaModels.TIME:
labels.completion = completionStrings.$tr('completeDuration');
labels.completion = metadataStrings.$tr('completeDuration');
if (suggestedDuration) {
labels.duration = secondsToHms(suggestedDuration);
}
break;

case CompletionCriteriaModels.APPROX_TIME:
labels.completion = completionStrings.$tr('completeDuration');
labels.completion = metadataStrings.$tr('completeDuration');
if (isLongActivity(node)) {
labels.duration = metadataStrings.$tr('longActivity');
} else {
Expand All @@ -276,7 +266,7 @@ export function getCompletionCriteriaLabels(node) {

case CompletionCriteriaModels.PAGES:
if (completionThreshold === '100%') {
labels.completion = completionStrings.$tr('allContent');
labels.completion = metadataStrings.$tr('allContent');
}
break;

Expand All @@ -285,7 +275,7 @@ export function getCompletionCriteriaLabels(node) {
break;
}
if (masteryModel === MasteryModelsNames.M_OF_N) {
labels.completion = completionStrings.$tr('masteryMofN', {
labels.completion = metadataStrings.$tr('masteryMofN', {
m: completionThreshold.m,
n: completionThreshold.n,
});
Expand All @@ -295,7 +285,7 @@ export function getCompletionCriteriaLabels(node) {
break;

case CompletionCriteriaModels.DETERMINED_BY_RESOURCE:
labels.completion = completionStrings.$tr('determinedByResource');
labels.completion = metadataStrings.$tr('determinedByResource');
break;

default:
Expand Down
42 changes: 42 additions & 0 deletions contentcuration/contentcuration/frontend/shared/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,48 @@ export const metadataStrings = createTranslator('CommonMetadataStrings', {
message: 'Category',
context: 'A title for the metadata that explains the subject matter of an activity',
},
// Completion criteria types
reference: {
message: 'Reference material',
context:
'One of the completion criteria types. Progress made on a resource with this criteria is not tracked.',
},
completeDuration: {
message: 'When time spent is equal to duration',
context:
'One of the completion criteria types. A resource with this criteria is considered complete when learners spent given time studying it.',
},
exactTime: {
message: 'Time to complete',
context:
'One of the completion criteria types. A subset of "When time spent is equal to duration". For example, for an audio resource with this criteria, learnes need to hear the whole length of audio for the resource to be considered complete.',
},
allContent: {
message: 'Viewed in its entirety',
context:
'One of the completion criteria types. A resource with this criteria is considered complete when learners studied it all, for example they saw all pages of a document.',
},
determinedByResource: {
message: 'Determined by the resource',
context:
'One of the completion criteria types. Typically used for embedded html5/h5p resources that contain their own completion criteria, for example reaching a score in an educational game.',
},
masteryMofN: {
message: 'Goal: {m} out of {n}',
context:
'One of the completion criteria types specific to exercises. An exercise with this criteria is considered complete when learners answered m questions out of n correctly.',
},
goal: {
message: 'When goal is met',
context:
'One of the completion criteria types specific to exercises. An exercise with this criteria is considered complete when learners reached a given goal, for example 100% correct.',
},
practiceQuiz: {
message: 'Practice quiz',
context:
'One of the completion criteria types specific to exercises. An exercise with this criteria represents a quiz.',
},

// Learning Activities
all: {
message: 'All',
Expand Down

0 comments on commit 6a82930

Please sign in to comment.