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

Updates to sections in ExamPage #12182

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
10 changes: 7 additions & 3 deletions kolibri/core/assets/src/views/AttemptLogList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
v-for="(section, index) in sections"
:id="`section-questions-${index}`"
:key="`section-questions-${index}`"
:title="section.section_title"
:title="displaySectionTitle(section, index)"
@focus="expand(index)"
>
<template #heading="{ title }">
Expand Down Expand Up @@ -189,9 +189,12 @@

<script>

import {
displaySectionTitle,
enhancedQuizManagementStrings,
} from 'kolibri-common/strings/enhancedQuizManagementStrings';
import useAccordion from 'kolibri-common/components/useAccordion';
import { coreStrings } from 'kolibri.coreVue.mixins.commonCoreStrings';
import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings';
import AccordionItem from 'kolibri-common/components/AccordionItem';
import AccordionContainer from 'kolibri-common/components/AccordionContainer';
import { computed, watch } from 'kolibri.lib.vueCompositionApi';
Expand Down Expand Up @@ -236,7 +239,7 @@
const sectionSelectOptions = computed(() => {
return sections.value.map((section, index) => ({
value: index,
label: section.section_title,
label: displaySectionTitle(section, index),
}));
});

Expand Down Expand Up @@ -305,6 +308,7 @@
return {
handleSectionChange,
handleQuestionChange,
displaySectionTitle,
quizSectionsLabel$,
questionsLabel$,
expand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,11 @@ const coachStrings = createTranslator('CommonCoachStrings', {
context:
"Text shown on a modal pop-up window when the user clicks the 'Start Quiz' button. This explains what will happen when the user confirms the action of starting the quiz.",
},
canNoLongerEditQuizNotice: {
message: 'You will no longer be able to edit the quiz.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inaccurate - it should be something like "You will no longer be able to edit the questions and sections in this quiz" - as they will still be able to edit the title and assignments.

context:
'In the modal pop-up window when the user clicks the "Start Quiz" button, explains that they will not be able to edit the quiz after starting it.',
},
openQuizModalEmptySections: {
message: 'Any sections without questions will be removed from the quiz.',
context:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
@submit="handleOpenQuiz(activeQuiz.id)"
>
<p>{{ openQuizModalDetail$() }}</p>
<p>{{ canNoLongerEditQuizNotice$() }}</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be conditionalized on quiz.draft being true - otherwise we will show this warning for quizzes that couldn't be edited anyway.

<p
v-if="
activeQuiz.data_model_version === 3 &&
Expand Down Expand Up @@ -240,6 +241,7 @@
newQuizAction$,
filterQuizStatus$,
quizClosedLabel$,
canNoLongerEditQuizNotice$,
} = coachStrings;

const statusSelected = ref({
Expand Down Expand Up @@ -275,6 +277,7 @@
titleLabel$,
recipientsLabel$,
sizeLabel$,
canNoLongerEditQuizNotice$,
statusLabel$,
newQuizAction$,
filterQuizStatus$,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@
questionsDeletedNotification$,
expandAll$,
collapseAll$,
questionDeletionConfirmation$,
} = enhancedQuizManagementStrings;

const {
Expand All @@ -404,7 +405,7 @@
setActiveSection,
updateQuiz,
selectAllQuestions,

replacementQuestionPool,
// Computed
toggleQuestionInSelection,
allSections,
Expand Down Expand Up @@ -454,6 +455,7 @@
addQuizSectionQuestionsInstructions$,
editSectionLabel$,
deleteSectionLabel$,
questionDeletionConfirmation$,
replaceAction$,
questionList$,
sectionDeletedNotification$,
Expand All @@ -479,6 +481,7 @@
activeSection,
activeResourceMap,
activeResourcePool,
replacementQuestionPool,
activeQuestions,
selectedActiveQuestions,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1 class="section-header">
{{ replaceQuestions$() }}
</h1>
<p>{{ replaceQuestionsExplaination$() }}</p>
<p>{{ replaceQuestionsHeading$() }}</p>
<span
class="divider"
:style="{ borderTop: `solid 1px ${$themeTokens.fineLine}` }"
Expand Down Expand Up @@ -193,6 +193,7 @@
closeConfirmationMessage$,
closeConfirmationTitle$,
replaceQuestionsExplaination$,
replaceQuestionsHeading$,
numberOfSelectedReplacements$,
numberOfQuestionsReplaced$,
noUndoWarning$,
Expand Down Expand Up @@ -322,6 +323,7 @@
closeConfirmationTitle$,
noUndoWarning$,
replaceQuestionsExplaination$,
replaceQuestionsHeading$,
selectMoreQuestion$,
selectFewerQuestion$,
collapseAll$,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@
@cancel="handleCancelDelete"
@submit="handleConfirmDelete"
>
{{ deleteConfirmation$({ section_title: activeSection.section_title }) }}
{{ deleteConfirmation$(
{ section_title: displaySectionTitle(activeSection, activeSectionIndex) }
) }}
</KModal>
</div>

Expand Down Expand Up @@ -340,7 +342,7 @@
}

function handleConfirmDelete() {
const section_title = activeSection.value.section_title;
const section_title = displaySectionTitle(activeSection.value, activeSectionIndex.value);
removeSection(showDeleteConfirmation.value);
router.replace({
name: PageNames.EXAM_CREATION_ROOT,
Expand Down
15 changes: 11 additions & 4 deletions kolibri/plugins/learn/assets/src/modules/examViewer/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { displaySectionTitle } from 'kolibri-common/strings/enhancedQuizManagementStrings';

function defaultState() {
return {
contentNodeMap: {},
Expand Down Expand Up @@ -27,22 +29,27 @@ export default {
if (state.questions.length === 0) return null;
return state.questions[state.questionNumber];
},
currentSection(state, { currentQuestion, sections }) {
return sections.find(section =>
currentSection(state, { sections, currentSectionIndex }) {
return sections[currentSectionIndex];
},
currentSectionIndex(state, { currentQuestion, sections }) {
return sections.findIndex(section =>
section.questions.map(q => q.item).includes(currentQuestion.item)
);
},
sectionSelectOptions(state, { sections }) {
return (
sections.map((section, i) => ({
label: section.section_title,
label: displaySectionTitle(section, i),
value: i,
})) || []
);
},
currentSectionOption(state, { currentSection, sectionSelectOptions }) {
if (!currentSection) return {};
return sectionSelectOptions.find(opt => opt.label === currentSection.section_title);
return sectionSelectOptions.find(
(opt, i) => opt.label === displaySectionTitle(currentSection, i)
);
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
v-for="(section, index) in sections"
:id="`section-questions-${index}`"
:key="`section-questions-${index}`"
:title="section.section_title"
:title="displaySectionTitle(section, index)"
@focus="expand(index)"
>
<template #heading="{ title }">
Expand Down Expand Up @@ -97,6 +97,7 @@

<script>

import { displaySectionTitle } from 'kolibri-common/strings/enhancedQuizManagementStrings';
import AccordionItem from 'kolibri-common/components/AccordionItem';
import AccordionContainer from 'kolibri-common/components/AccordionContainer';
import isEqual from 'lodash/isEqual';
Expand All @@ -120,6 +121,7 @@
const { collapse, expand, isExpanded, toggle } = useAccordion(sections);

return {
displaySectionTitle,
collapse,
expand,
isExpanded,
Expand Down
5 changes: 4 additions & 1 deletion kolibri/plugins/learn/assets/src/views/ExamPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
:layout12="{ span: 8 }"
>
<h2 class="section-title">
{{ currentSection.section_title }}
{{ displaySectionTitle(currentSection, currentSectionIndex) }}
</h2>
<p> {{ currentSection.description }} </p>
</KGridItem>
Expand Down Expand Up @@ -226,6 +226,7 @@

import { mapGetters, mapState } from 'vuex';
import isEqual from 'lodash/isEqual';
import { displaySectionTitle } from 'kolibri-common/strings/enhancedQuizManagementStrings';
import debounce from 'lodash/debounce';
import BottomAppBar from 'kolibri.coreVue.components.BottomAppBar';
import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow';
Expand Down Expand Up @@ -269,6 +270,7 @@
windowIsSmall,
} = useKResponsiveWindow();
return {
displaySectionTitle,
pastattempts,
time_spent,
initContentSession,
Expand Down Expand Up @@ -296,6 +298,7 @@
...mapGetters('examViewer', [
'currentQuestion',
'currentSection',
'currentSectionIndex',
'sectionSelectOptions',
'currentSectionOption',
'currentQuestionOption',
Expand Down
12 changes: 9 additions & 3 deletions packages/kolibri-common/strings/enhancedQuizManagementStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag
message: 'Add questions',
},
selectFoldersOrExercises: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth changing the message id if we're not only allowing selection of resources?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 good thought richard

message: 'Select folders or exercises from these channels',
message: 'Select resources from these channels',
},
numberOfSelectedBookmarks: {
message: '{ count, number } { count, plural, one { bookmark } other { bookmarks }}',
Expand Down Expand Up @@ -102,6 +102,9 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag
replaceAction: {
message: 'Replace',
},
replaceQuestionsHeading: {
message: 'The new questions you select will replace the current ones.',
},
replaceQuestionsExplaination: {
message: 'The new questions you selected will replace the current ones.',
},
Expand Down Expand Up @@ -220,8 +223,7 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag
context: 'Message of modal when a user tries to replace questions but the pool is empty',
},
addMoreResourcesWithNonEmptyPool: {
message:
'Please add more resources to this section, or go back and only select up to { available, number } { available, plural, one { question } other { questions } } to be replaced.',
message: 'Please add more resources to this section, or go back and select fewer questions',
context:
'Message of modal when a user tries to replace more questions than are available in the pool',
},
Expand All @@ -241,6 +243,10 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag
saveAndClose: {
message: 'Save and close',
},
questionDeletionConfirmation: {
message:
'Are you sure you want to remove { count, number } { count, plural, one { question } other { questions }} from this section?',
},
});

const { sectionLabel$ } = enhancedQuizManagementStrings;
Expand Down