Skip to content

Commit

Permalink
Merge pull request #11277 from nucleogenesis/feature--finalizing-crea…
Browse files Browse the repository at this point in the history
…te-quizz

Quiz foundations & data connection
  • Loading branch information
nucleogenesis authored Oct 3, 2023
2 parents cdd31ba + 528fb28 commit fa3f140
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 944 deletions.
15 changes: 13 additions & 2 deletions kolibri/plugins/coach/assets/src/composables/useQuizCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function isExercise(o) {
/**
* Composable function presenting primary interface for Quiz Creation
*/
export function useQuizCreation() {
export default () => {
// -----------
// Local state
// -----------
Expand Down Expand Up @@ -124,6 +124,12 @@ export function useQuizCreation() {
if (updatedSections.length === get(allSections).length) {
throw new Error(`Section with id ${section_id} not found; cannot be removed.`);
}
if (updatedSections.length === 0) {
const newSection = addSection();
setActiveSection(newSection.section_id);
} else {
setActiveSection(get(updatedSections)[0].section_id);
}
updateQuiz({ question_sources: updatedSections });
}

Expand Down Expand Up @@ -240,6 +246,10 @@ export function useQuizCreation() {
const activeSection = computed(() =>
get(allSections).find(s => s.section_id === get(_activeSectionId))
);
/** @type {ComputedRef<QuizSection[]>} The inactive sections */
const inactiveSections = computed(() =>
get(allSections).filter(s => s.section_id !== get(_activeSectionId))
);
/** @type {ComputedRef<QuizResource[]>} The active section's `resource_pool` */
const activeResourcePool = computed(() => get(activeSection).resource_pool);
/** @type {ComputedRef<ExerciseResource[]>} The active section's `resource_pool` - that is,
Expand Down Expand Up @@ -279,10 +289,11 @@ export function useQuizCreation() {
quiz,
allSections,
activeSection,
inactiveSections,
activeExercisePool,
activeQuestionsPool,
activeQuestions,
selectedActiveQuestions,
replacementQuestionPool,
};
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<style lang="scss" scoped>
.coach-main {
margin: 85px auto 0;
margin: 0 auto;
}
</style>
Loading

0 comments on commit fa3f140

Please sign in to comment.