Commit 5853174c authored by Joachim Schunk's avatar Joachim Schunk

ensure :units is added as vector

parent 1387b895
Pipeline #47694 failed with stages
in 2 minutes and 38 seconds
......@@ -25,13 +25,15 @@
(def modal-state-atom (reagent/atom {}))
(defn get-new-calculation []
{:id (get-unique-id "ae")
:name nil
:number number-obj
:correct-points 0
:incorrect-points 0
:error-relative 1})
(defn get-new-calculation [with-units]
(let [base-object {:id (get-unique-id "ae")
:name nil
:number number-obj
:correct-points 0
:incorrect-points 0
:error-relative 1}]
(if with-units (assoc base-object :units [])
base-object)))
(defn set-prop-in-all-calcs [prop-key value calc-cursor]
(dorun (map-indexed
......@@ -102,13 +104,15 @@
(defn new-exercise-form [{:keys [exercise-atom change-fn]}]
(let [exercise @exercise-atom
exercise-core (:core exercise)
with-units (:with-units exercise-core)
calculations (:calculations exercise-core)]
[:<>
[ui/card
{:title "Berechnungen"
:footer-items [[:a.button.footer-item
{:on-click #(change-fn [:core :calculations] (conj calculations (get-new-calculation)))}
[:span.icon [:i.fas.fa-plus]] [:span "Berechnung"]]]}
:footer-items
[[:a.button.footer-item
{:on-click #(change-fn [:core :calculations] (conj calculations (get-new-calculation with-units)))}
[:span.icon [:i.fas.fa-plus]] [:span "Berechnung"]]]}
[:div.new-question.card-panel.z-depth-3
(map-indexed
(fn [index calculation]
......
......@@ -32,9 +32,9 @@
(def modal-state-atom (reagent/atom {}))
(defn get-new-calculation [with-units]
(if with-units
{:number number-obj :units []}
{:number number-obj}))
(let [base-object {:number number-obj}]
(if with-units (assoc base-object :units [])
base-object)))
(defn fresh-answer-obj [calculation-ids with-units]
{:calculations (reduce (fn [res id] (assoc res id (get-new-calculation with-units))) {} calculation-ids)
......
Markdown is supported
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