Skip to content

Commit

Permalink
only pass IDs to API in resource_pool
Browse files Browse the repository at this point in the history
  • Loading branch information
nucleogenesis committed Jan 26, 2024
1 parent f9e66da commit 2cbd234
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion kolibri/plugins/coach/assets/src/composables/useQuizCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,19 @@ export default function useQuizCreation(DEBUG = false) {
if (!validateQuiz(get(_quiz))) {
throw new Error(`Quiz is not valid: ${JSON.stringify(get(_quiz))}`);
}
return ExamResource.saveModel({ data: get(_quiz) });

// Here we update each section's `resource_pool` to only be the IDs of the resources
const sectionsWithResourcePoolAsIDs = get(allSections).map(section => {
const resourcePoolAsIds = get(section).resource_pool.map(content => content.id);
section.resource_pool = resourcePoolAsIds;
return section;
});

const finalQuiz = get(_quiz);

finalQuiz.question_sources = sectionsWithResourcePoolAsIDs;

return ExamResource.saveModel({ data: finalQuiz });
}

/**
Expand Down

0 comments on commit 2cbd234

Please sign in to comment.