From d7968895b28f509ea58a90eefc9bc15b40e39a81 Mon Sep 17 00:00:00 2001 From: Rotimi Best Date: Sat, 10 Jul 2021 15:47:43 +0000 Subject: [PATCH] Student result page of questionnaire --- .../Lecture/Homework/ViewMode.svelte | 120 +++++++++++++----- .../Lecture/Homework/store/answers.js | 9 ++ .../Question/CheckboxQuestion/index.svelte | 3 +- .../Question/RadioQuestion/index.svelte | 3 +- 4 files changed, 100 insertions(+), 35 deletions(-) create mode 100644 src/components/Course/components/Lecture/Homework/store/answers.js diff --git a/src/components/Course/components/Lecture/Homework/ViewMode.svelte b/src/components/Course/components/Lecture/Homework/ViewMode.svelte index 6456e380..a599bfb1 100644 --- a/src/components/Course/components/Lecture/Homework/ViewMode.svelte +++ b/src/components/Course/components/Lecture/Homework/ViewMode.svelte @@ -1,5 +1,6 @@ -{#if !preview && currentQuestionIndex > 0} - +{#if !preview && !$userQuestionniareAnswers.isFinished} + {/if} {#if preview} {#each questions as currentQuestion, currentQuestionIndex} {#if QUESTION_TYPE.RADIO === currentQuestion.type} {:else if QUESTION_TYPE.CHECKBOX === currentQuestion.type} {:else if QUESTION_TYPE.TEXTAREA === currentQuestion.type} {/if} {/each} -{:else if currentQuestionIndex === 0} +{:else if $userQuestionniareAnswers.currentQuestionIndex === 0}

{title}

{description}

@@ -177,20 +202,49 @@ type="button" />
-{:else if isFinished} -

Congratulations you have completed your task

+{:else if $userQuestionniareAnswers.isFinished} +
+
+

{title}

+ + Pending Review + +
+ + + {getTotalScores($userQuestionniareAnswers.scores)}/100 + +
{#each questions as currentQuestion, currentQuestionIndex} {#if QUESTION_TYPE.RADIO === currentQuestion.type} {:else if QUESTION_TYPE.CHECKBOX === currentQuestion.type} {:else if QUESTION_TYPE.TEXTAREA === currentQuestion.type} {/if} {/each} diff --git a/src/components/Course/components/Lecture/Homework/store/answers.js b/src/components/Course/components/Lecture/Homework/store/answers.js new file mode 100644 index 00000000..d954a7db --- /dev/null +++ b/src/components/Course/components/Lecture/Homework/store/answers.js @@ -0,0 +1,9 @@ +import { writable } from "svelte/store"; + +export const userQuestionniareAnswers = writable({ + answers: {}, + scores: {}, + currentQuestionIndex: 5, + isFinished: true, + progressValue: 100, +}); diff --git a/src/components/Question/CheckboxQuestion/index.svelte b/src/components/Question/CheckboxQuestion/index.svelte index 7e9e5fd7..5fe80129 100644 --- a/src/components/Question/CheckboxQuestion/index.svelte +++ b/src/components/Question/CheckboxQuestion/index.svelte @@ -13,6 +13,7 @@ export let onPrevious = () => {}; export let defaultValue = []; export let disablePreviousButton = false; + export let disabled = false; export let isPreview = false; export let nextButtonProps = {}; @@ -74,7 +75,7 @@ value={option.id} checked={defaultValue.includes(option.id)} label={option.label || option.value} - disabled={nextButtonProps.disableOptionSelect} + {disabled} /> {/each} diff --git a/src/components/Question/RadioQuestion/index.svelte b/src/components/Question/RadioQuestion/index.svelte index 5789bf43..1b9f15a3 100644 --- a/src/components/Question/RadioQuestion/index.svelte +++ b/src/components/Question/RadioQuestion/index.svelte @@ -13,6 +13,7 @@ export let onPrevious = () => {}; export let defaultValue = ""; export let disablePreviousButton = false; + export let disabled = false; export let isPreview = false; export let nextButtonProps = {}; @@ -75,7 +76,7 @@ checked={defaultValue.includes(option.id) && answers.includes(option.id)} label={option.label || option.value} - disabled={nextButtonProps.disableOptionSelect} + {disabled} /> {/each}