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

reload on connect in quizsummarypage; avoid possible error w/ missing… #12554

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions kolibri/plugins/coach/assets/src/routes/examRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export default [
name: PageNames.EXAM_CREATION_ROOT,
path: CLASS + QUIZ + '/edit/:sectionIndex',
component: CreateExamPage,
meta: {
Copy link
Member Author

Choose a reason for hiding this comment

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

This silences an error message

titleParts: [],
},
children: [
{
name: PageNames.QUIZ_SECTION_EDITOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</KGrid>
<ManageExamModals
:currentAction="currentAction"
:quiz="quiz"
:quiz="exam"
@submit_delete="handleSubmitDelete"
@submit_copy="handleSubmitCopy"
@cancel="closeModal"
Expand All @@ -100,7 +100,7 @@
import ExamResource from 'kolibri-common/apiResources/ExamResource';
import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings';
import useSnackbar from 'kolibri/composables/useSnackbar';
import { PageNames } from '../../../constants';
import { convertExamQuestionSources } from 'kolibri-common/quizzes/utils';
import { QUIZZES_TABS_ID, QuizzesTabs } from '../../../constants/tabsConstants';
import { useCoachTabs } from '../../../composables/useCoachTabs';

Expand Down Expand Up @@ -148,19 +148,11 @@
},
data() {
return {
quiz: {
active: false,
assignments: [],
learners_see_fixed_order: false,
question_sources: [],
title: '',
},
loading: true,
currentAction: '',
QUIZZES_TABS_ID,
QuizzesTabs,
difficultQuestions: [],
PageNames,
};
},
computed: {
Expand Down Expand Up @@ -208,7 +200,7 @@

tabsList.forEach(tab => {
tab.to = this.classRoute(
this.group ? PageNames.GROUP_EXAM_SUMMARY : PageNames.EXAM_SUMMARY,
this.group ? this.PageNames.GROUP_EXAM_SUMMARY : this.PageNames.EXAM_SUMMARY,
{ tabId: tab.id },
);
});
Expand Down Expand Up @@ -260,8 +252,7 @@
methods: {
// @public
setData(data) {
const { exam, difficultQuestions } = data;
this.quiz = exam;
const { difficultQuestions } = data;
Copy link
Member Author

@nucleogenesis nucleogenesis Dec 16, 2024

Choose a reason for hiding this comment

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

exam is removed here because we have a computed property exam which gets the data from examMap for us

this.difficultQuestions = difficultQuestions;
this.loading = false;
this.$store.dispatch('notLoading');
Expand All @@ -275,7 +266,7 @@
setCurrentAction(action) {
if (action === 'EDIT_DETAILS') {
this.$router.push({
name: PageNames.EXAM_CREATION_ROOT,
name: this.PageNames.EXAM_CREATION_ROOT,
params: { ...this.$route.params, sectionIndex: 0 },
});
} else {
Expand All @@ -285,7 +276,7 @@
closeModal() {
this.currentAction = '';
},
handleSubmitCopy({ classroomId, groupIds, adHocLearnerIds, examTitle }) {
async handleSubmitCopy({ classroomId, groupIds, adHocLearnerIds, examTitle }) {
const title = examTitle.trim().substring(0, 100).trim();

const assignments = serverAssignmentPayload(groupIds, classroomId);
Expand All @@ -296,7 +287,8 @@
collection: classroomId,
assignments,
learner_ids: adHocLearnerIds,
question_sources: this.quiz.question_sources,
// This ensures backward compatibility for all question_sources versions
question_sources: (await convertExamQuestionSources(this.exam)).question_sources,
};

ExamResource.saveModel({ data: newQuiz })
Expand Down Expand Up @@ -339,10 +331,10 @@
});
},
handleSubmitDelete() {
return deleteExam(this.quiz.id)
return deleteExam(this.quizId)
.then(() => {
this.$store.commit('classSummary/DELETE_ITEM', { map: 'examMap', id: this.quiz.id });
this.$router.replace(this.classRoute(PageNames.EXAMS_ROOT), () => {
this.$store.commit('classSummary/DELETE_ITEM', { map: 'examMap', id: this.quizId });
this.$router.replace(this.classRoute(this.PageNames.EXAMS_ROOT), () => {
this.showSnackbarNotification('quizDeleted');
});
})
Expand All @@ -351,7 +343,7 @@
});
},
detailLink(learnerId) {
return this.classRoute(PageNames.QUIZ_LEARNER_PAGE_ROOT, {
return this.classRoute(this.PageNames.QUIZ_LEARNER_PAGE_ROOT, {
Copy link
Member Author

Choose a reason for hiding this comment

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

This was weird to find but it's because we don't import PageNames here, but rather, we get it from the commonCoach mixin

learnerId,
});
},
Expand Down
Loading