Commit 68a0343c authored by Bruno Burke's avatar Bruno Burke 🍔
Browse files

rename question-type titles; add editing stages to question-editor

parent 9bc66bc6
Pipeline #109554 passed with stages
in 5 minutes and 55 seconds
......@@ -6,7 +6,7 @@
)
(def export {:type :binary-choice
:title "Binary-Choice"
:title "Binärfrage (Binary-Choice)"
:edit {:settings #?(:cljs edit-view/settings :clj nil)
:additional-forms #?(:cljs edit-view/additional-forms :clj nil)}
;; :prepare prepare/prepare
......
......@@ -6,7 +6,7 @@
)
(def export {:type :free-text
:title "Free-Text"
:title "Freitext (Free Text)"
:edit {:settings #?(:cljs edit-view/settings :clj nil)
:additional-forms #?(:cljs edit-view/additional-forms :clj nil)}
;; :prepare prepare/prepare
......
......@@ -6,7 +6,7 @@
))
(def export {:type :multiple-choice
:title "Multiple-Choice"
:title "Mehrfachauswahl (Multiple-Choice)"
:edit {:settings #?(:cljs edit-view/settings :clj nil)
:additional-forms #?(:cljs edit-view/additional-forms :clj nil)}
;; :prepare prepare/prepare
......
......@@ -2,11 +2,10 @@
#?(:cljs
(:require
[leukipp.components.question-types.scaled.views.edit :as edit-view]
[leukipp.components.question-types.scaled.views.show :as show-view])
))
[leukipp.components.question-types.scaled.views.show :as show-view])))
(def export {:type :scaled
:title "Scaled Question"
:title "Skalierte Frage (Scale)"
:edit {:settings #?(:cljs edit-view/settings :clj nil)
:additional-forms #?(:cljs edit-view/additional-forms :clj nil)}
;; :prepare prepare/prepare
......
......@@ -73,10 +73,9 @@
(reset! answer new-value))}]
[:p "No valid Survey-Renderer"]))
#_[:a.btn.btn-flat {:on-click #(reset! result (q-check/check-answer
question
@answer
println
))} "Aufgabe überprüfen"][:br]
question
@answer
println))} "Aufgabe überprüfen"] [:br]
(when @result
[:strong {:class (case (/ (:points @result)
(:points-max @result))
......@@ -98,9 +97,12 @@
:reagent-render
(fn [& {:keys [title question add-fn! discard-url options question-options]}]
(let [id (:id @question)
{:keys [answers shuffled voting type]} (:core @question)
{:keys [answers shuffled voting type] :as core} (:core @question)
type (get-question-type @question)
question-data (question-types/get-question type)]
question-data (question-types/get-question type)
type-selected? (some? type)
questiontext-defined? (and type-selected?
(pos? (count (i18n/i18n-get (:question core) :lang @language))))]
[:div {:id "edit-question"}
[:div
[:div
......@@ -118,7 +120,6 @@
:title "EN"}]
:on-change #(reset! language %)
:value @language}]]]]
[:div.card-content
(when (not-empty @error)
[:div.card-panel
......@@ -128,39 +129,53 @@
(for [line lines]
[:p {:key (hash line)} line]))]])
(when question-types
[ui/field {:label "Typ"}
[ui/select*
{:expanded? true
:cursor (reagent/cursor question [:core :type])
:options (mapv #(hash-map :key (first %)
:title (second %)) question-types)}]])
[:div
[:label "Frage"]
(let [{:keys [allowed-types forbidden-types]} question-options]
[content-editor/editor
(i18n/get-cursor question [:core :question]
:lang @language)
:allowed-types allowed-types
:forbidden-types forbidden-types])]
(when-let [settings-dialog (get-method q-edit/show-settings type)]
^{:key (str "settings-" type)}
[settings-dialog question (merge options
{:language @language})])]]
(when-let [additional-forms-dialog (get-method q-edit/show-additional-forms type)]
^{:key (str "aforms-" type)}
[additional-forms-dialog question (merge options
{:language @language})])
[ui/collapsible
{:elements
[{:label "EDN"
:icon "code"
:content [edn-code @question]}
{:label "Schlagwörter / Tags"
:icon "code"
:content [tag-editor question]}
{:label "Vorschau"
:icon "video_label"
:content
(when (and @question type)
[question-preview @question])}]}]]]]))})))
[:div.block
(when-not type-selected?
[:div.notification.is-warning
"Bitte wähle einen Fragetyp."])
[ui/field {:label "Typ"}
[ui/select*
{:expanded? true
:cursor (reagent/cursor question [:core :type])
:options (mapv #(hash-map :key (first %)
:title (second %)) question-types)}]]])
(when type-selected?
[:div
(when-not questiontext-defined?
[:div.notification.is-warning
"Bitte füge Text- und andere Elemente als Frage hinzu. Anschließend kannst du Antwortmöglichkeiten definieren."])
[:div.block
[ui/field {:label "Frage"}
(let [{:keys [allowed-types forbidden-types]} question-options]
[content-editor/editor
(i18n/get-cursor question [:core :question]
:lang @language)
:allowed-types allowed-types
:forbidden-types forbidden-types])]]
(when-let [settings-dialog (get-method q-edit/show-settings type)]
^{:key (str "settings-" type)}
[:div.block
[settings-dialog question (merge options
{:language @language})]])])]]
(when (and type-selected?
questiontext-defined?)
(when-let [additional-forms-dialog (get-method q-edit/show-additional-forms type)]
^{:key (str "aforms-" type)}
[additional-forms-dialog question (merge options
{:language @language})]))
(when (and type-selected?
questiontext-defined?)
[ui/collapsible
{:elements
[{:label "EDN"
:icon "code"
:content [edn-code @question]}
{:label "Schlagwörter / Tags"
:icon "code"
:content [tag-editor question]}
{:label "Vorschau"
:icon "video_label"
:content
(when (and @question type)
[question-preview @question])}]}])]]]))})))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment