From 445858f4bb183bd90e4d177f888ff14c4d294ad9 Mon Sep 17 00:00:00 2001 From: rotimi-best Date: Sat, 26 Jun 2021 21:32:42 +0300 Subject: [PATCH] Complete questionnaire builder --- src/components/Apps/index.svelte | 75 +++---- src/components/Buttons/Close/index.svelte | 3 +- .../Lecture/Homework/EditMode.svelte | 188 ++++++++++-------- .../Course/components/Lecture/Readme.svelte | 94 --------- .../Course/components/Lecture/index.svelte | 2 +- src/components/Form/TextArea.svelte | 8 +- src/components/IconButton/index.svelte | 7 +- .../{EditMode => MarkdownEditor}/index.svelte | 0 src/components/PageNav/index.svelte | 45 +++-- src/components/PrimaryButton/constants.js | 10 + src/components/PrimaryButton/index.svelte | 6 +- src/components/Question/constants.js | 12 ++ src/components/QuestionContainer/index.svelte | 39 ++++ src/components/ToolTip/index.svelte | 34 ++-- 14 files changed, 269 insertions(+), 254 deletions(-) delete mode 100644 src/components/Course/components/Lecture/Readme.svelte rename src/components/{EditMode => MarkdownEditor}/index.svelte (100%) create mode 100644 src/components/PrimaryButton/constants.js create mode 100644 src/components/QuestionContainer/index.svelte diff --git a/src/components/Apps/index.svelte b/src/components/Apps/index.svelte index 729df164..97b06e64 100644 --- a/src/components/Apps/index.svelte +++ b/src/components/Apps/index.svelte @@ -48,64 +48,41 @@ }); - -
+ selected={APPS_CONSTANTS.APPS.LIVE_CHAT === selectedApp} + > + selected={APPS_CONSTANTS.APPS.QANDA === selectedApp} + > + selected={APPS_CONSTANTS.APPS.NOTES === selectedApp} + > + selected={APPS_CONSTANTS.APPS.POLL === selectedApp} + >
@@ -124,3 +101,31 @@
{/if} + + diff --git a/src/components/Buttons/Close/index.svelte b/src/components/Buttons/Close/index.svelte index 11311f9b..1408df47 100644 --- a/src/components/Buttons/Close/index.svelte +++ b/src/components/Buttons/Close/index.svelte @@ -3,8 +3,9 @@ import IconButton from "../../IconButton/index.svelte"; export let onClick; + export let contained; - + diff --git a/src/components/Course/components/Lecture/Homework/EditMode.svelte b/src/components/Course/components/Lecture/Homework/EditMode.svelte index 6046acf1..aa3e9a9c 100644 --- a/src/components/Course/components/Lecture/Homework/EditMode.svelte +++ b/src/components/Course/components/Lecture/Homework/EditMode.svelte @@ -3,38 +3,34 @@ import AddFilled24 from "carbon-icons-svelte/lib/AddFilled24"; import TextField from "../../../../Form/TextField.svelte"; + import TextArea from "../../../../Form/TextArea.svelte"; import Checkbox from "../../../../Form/Checkbox.svelte"; import RadioItem from "../../../../Form/RadioItem.svelte"; import IconButton from "../../../../IconButton/index.svelte"; import Select from "../../../../Form/Select.svelte"; import PrimaryButton from "../../../../PrimaryButton/index.svelte"; + import { VARIANTS } from "../../../../PrimaryButton/constants"; + import QuestionContainer from "../../../../QuestionContainer/index.svelte"; import { QUESTION_TYPE, QUESTION_TYPES, + QUESTION_TEMPLATE, } from "../../../../Question/constants"; // import EditContent from "../../../../EditContent/index.svelte"; // import readme from "../../readme.js"; // let value = readme; - let questions = [ - { - id: 1, - title: "", - type: QUESTION_TYPE.RADIO, - options: [ - { - id: 1, - value: "", - }, - ], - }, - ]; + let task = { + title: "", + description: null, + }; + let questions = []; - function handleAddOption(id) { + function handleAddOption(questionId) { return () => { questions = questions.map((question) => { - if (question.id === id) { + if (question.id === questionId) { return { ...question, options: [ @@ -73,78 +69,108 @@ questions = [ ...questions, { + ...QUESTION_TEMPLATE, id: questions.length + 1, - title: "", - type: QUESTION_TYPE.RADIO, - options: [ - { - id: 1, - value: "", - }, - ], }, ]; } + + function handleRemoveQuestion(questionId) { + return () => { + questions = questions.filter((q) => q.id !== questionId); + }; + } -{#each questions as question} -
-
-
- -
-