-
Notifications
You must be signed in to change notification settings - Fork 733
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
Question sources #11658
Merged
AllanOXDi
merged 17 commits into
learningequality:develop
from
AllanOXDi:question_sources
Jan 3, 2024
Merged
Question sources #11658
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
61a7981
commented out bottombar text
AllanOXDi 4c27e88
cleaned the bottomappbar
AllanOXDi 161fc19
code clean up
AllanOXDi 00da242
code clean up
AllanOXDi 43609a1
removed commented code
AllanOXDi ba44fed
added the quiz description
AllanOXDi c92f831
added css classes
AllanOXDi 8604198
modified the modal
AllanOXDi fac89d6
set questionsourcestoV3
AllanOXDi af90191
code cleanup
AllanOXDi 8c2f050
Delete .trunk/.gitignore
AllanOXDi 912ff82
Delete .trunk/trunk.yaml
AllanOXDi dbbbd5b
removed trunk
AllanOXDi cfc9148
removed trunk
AllanOXDi b2c54e8
add clickable chevron & section title
AllanOXDi 6bb5b9c
remove .trunk
AllanOXDi b164ff3
fixes the accesibility issue
AllanOXDi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { ContentNodeResource, ExamResource } from 'kolibri.resources'; | ||
import samePageCheckGenerator from 'kolibri.utils.samePageCheckGenerator'; | ||
import { convertExamQuestionSources } from 'kolibri.utils.exams'; | ||
import { convertExamQuestionSourcesToV3 } from 'kolibri.utils.exams'; | ||
import shuffled from 'kolibri.utils.shuffled'; | ||
import { ClassesPageNames } from '../../constants'; | ||
import { LearnerClassroomResource } from '../../apiResources'; | ||
|
@@ -30,10 +30,20 @@ export function showExam(store, params, alreadyOnQuiz) { | |
store.commit('classAssignments/SET_CURRENT_CLASSROOM', classroom); | ||
|
||
let contentPromise; | ||
if (exam.question_sources.length) { | ||
let allExerciseIds = []; | ||
if (exam.data_version == 3) { | ||
allExerciseIds = exam.question_sources.reduce((acc, section) => { | ||
console.log(section); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stray console.log |
||
acc = [...acc, ...section.questions.map(q => q.exercise_id)]; | ||
return acc; | ||
}, []); | ||
} else { | ||
allExerciseIds = exam.question_sources.map(q => q.exercise_id); | ||
} | ||
if (allExerciseIds.length) { | ||
contentPromise = ContentNodeResource.fetchCollection({ | ||
getParams: { | ||
ids: exam.question_sources.map(item => item.exercise_id), | ||
ids: allExerciseIds, | ||
}, | ||
}); | ||
} else { | ||
|
@@ -43,26 +53,36 @@ export function showExam(store, params, alreadyOnQuiz) { | |
contentNodes => { | ||
if (shouldResolve()) { | ||
// If necessary, convert the question source info | ||
let questions = convertExamQuestionSources(exam, { contentNodes }); | ||
const question_sources = convertExamQuestionSourcesToV3(exam, { contentNodes }); | ||
|
||
// When necessary, randomize the questions for the learner. | ||
// Seed based on the user ID so they see a consistent order each time. | ||
if (!exam.learners_see_fixed_order) { | ||
questions = shuffled(questions, store.state.core.session.user_id); | ||
} | ||
question_sources.forEach(section => { | ||
if (!section.learners_see_fixed_order) { | ||
section.questions = shuffled( | ||
section.questions, | ||
store.state.core.session.user_id | ||
); | ||
} | ||
}); | ||
|
||
const allQuestions = question_sources.reduce((acc, section) => { | ||
acc = [...acc, ...section.questions]; | ||
return acc; | ||
}, []); | ||
|
||
// Exam is drawing solely on malformed exercise data, best to quit now | ||
if (questions.some(question => !question.question_id)) { | ||
if (allQuestions.some(question => !question.question_id)) { | ||
store.dispatch( | ||
'handleError', | ||
`This quiz cannot be displayed:\nQuestion sources: ${JSON.stringify( | ||
questions | ||
allQuestions | ||
)}\nExam: ${JSON.stringify(exam)}` | ||
); | ||
return; | ||
} | ||
// Illegal question number! | ||
else if (questionNumber >= questions.length) { | ||
else if (questionNumber >= allQuestions.length) { | ||
store.dispatch( | ||
'handleError', | ||
`Question number ${questionNumber} is not valid for this quiz` | ||
|
@@ -76,16 +96,16 @@ export function showExam(store, params, alreadyOnQuiz) { | |
contentNodeMap[node.id] = node; | ||
} | ||
|
||
for (const question of questions) { | ||
for (const question of allQuestions) { | ||
question.missing = !contentNodeMap[question.exercise_id]; | ||
} | ||
|
||
store.commit('examViewer/SET_STATE', { | ||
contentNodeMap, | ||
exam, | ||
questionNumber, | ||
questions, | ||
}); | ||
(exam.question_sources = question_sources), | ||
store.commit('examViewer/SET_STATE', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two lines seem odd like this -- should this instead be two separate lines like:
|
||
contentNodeMap, | ||
exam, | ||
questionNumber, | ||
questions: allQuestions, | ||
}); | ||
store.commit('CORE_SET_PAGE_LOADING', false); | ||
store.commit('CORE_SET_ERROR', null); | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to note is that we should probably revert this. It is causing the tests to fail and if we are going to introduce a title and/or description by default we'll need to use a translated string and account for it in the tests. We can handle this in a separate follow-up issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! I think I missed it before committing.