Ab sofort ist der Login auf der Weboberfläche von git.fh-muenster.de bevorzugt über FH Muenster SSO möglich.

Commit 41a8aac5 authored by Joachim Schunk's avatar Joachim Schunk

make modal-state-atom more local

parent 70085955
Pipeline #47833 passed with stages
in 2 minutes and 25 seconds
......@@ -37,8 +37,6 @@
[lernmeister.components.ui :as ui]
[reagent.core :as reagent]))
(def modal-state-atom (reagent/atom {}))
(defn sort-names-mapping [names-map]
(sort-by #(:name-text %)
(into [] (map (fn [item]
......@@ -67,7 +65,7 @@
:change-fn change-fn}]))
names-mapping)]])
(defn new-exercise-form [{:keys [exercise-atom change-fn phrase-fn]}]
(defn new-exercise-form [{:keys [exercise-atom change-fn phrase-fn modal-state-atom]}]
(let [exercise @exercise-atom
exercise-core (:core exercise)
with-oom (get-in exercise [:core :with-oom])
......@@ -245,12 +243,14 @@
exercise-scheme-version)))))}))
(defn additional-forms [exercise-atom]
(when (= :current (get-in @exercise-atom [:authoring :migration-status]))
[new-exercise-form {:exercise-atom exercise-atom
:change-fn (partial calc-change-fn
(fn [exercise] (reset! exercise-atom exercise))
@exercise-atom)
:phrase-fn (partial get-phrase @exercise-atom [:core :phrasing] names-map)}]))
(reagent/with-let [modal-state-atom (reagent/atom {})]
(when (= :current (get-in @exercise-atom [:authoring :migration-status]))
[new-exercise-form {:exercise-atom exercise-atom
:change-fn (partial calc-change-fn
(fn [exercise] (reset! exercise-atom exercise))
@exercise-atom)
:phrase-fn (partial get-phrase @exercise-atom [:core :phrasing] names-map)
:modal-state-atom modal-state-atom}])))
(defmethod e-edit/show-settings :multistep-calculation [exercise-atom options]
(fn [exercise-atom options]
......
......@@ -36,8 +36,6 @@
(def selectable-units (reagent/atom {}))
(def modal-state-atom (reagent/atom {}))
(defn b-crumb-step [{:keys [position current-position phrase-fn on-click-fn]}]
[:<>
[:li {:class (when (= position current-position) "is-active")}
......@@ -109,7 +107,7 @@
[:p "-"])))
(defn multistep-calculation-answer-form [{:keys [answer exercise-core change-fn phrase-fn current-position
result]}]
result modal-state-atom]}]
(let [path (:path @modal-state-atom)
description-ids (:description-ids exercise-core)
steps (:steps answer)
......@@ -208,7 +206,8 @@
[result-view {:step-result (:step-result @modal-state-atom)
:assignment-type (:assignment-type @modal-state-atom)}])]]]))
(defn print-multistep-calculation-exercise [{:keys [answer exercise change-fn phrase-fn result]}]
(defn print-multistep-calculation-exercise [{:keys [answer exercise change-fn phrase-fn result
modal-state-atom]}]
(reagent/with-let [current-position (reagent/atom :task)]
(let [exercise-core (:core exercise)
positions (as-> [:task] v
......@@ -233,7 +232,8 @@
:change-fn change-fn
:phrase-fn phrase-fn
:current-position @current-position
:result result}]]]
:result result
:modal-state-atom modal-state-atom}]]]
(if result
[:span.is-pulled-right [point-result {:result result}]]
(when-not (= @current-position :steps)
......@@ -243,15 +243,17 @@
:on-click-fn #(reset! current-position %)}]))]])))
(defn exercise-renderer [exercise {:keys [result answer on-change]}]
(if-let [migrated-answer (migrate-if-necessary answer :answer-scheme "multistep-calculation"
answer-scheme-version migrate-answer)]
[print-multistep-calculation-exercise
{:answer migrated-answer
:exercise exercise
:change-fn (partial calc-change-fn on-change migrated-answer)
:phrase-fn (partial get-phrase exercise [:core :phrasing] names-map)
:result result}]
[unmigrateable-answer]))
(reagent/with-let [modal-state-atom (reagent/atom {})]
(if-let [migrated-answer (migrate-if-necessary answer :answer-scheme "multistep-calculation"
answer-scheme-version migrate-answer)]
[print-multistep-calculation-exercise
{:answer migrated-answer
:exercise exercise
:change-fn (partial calc-change-fn on-change migrated-answer)
:phrase-fn (partial get-phrase exercise [:core :phrasing] names-map)
:result result
:modal-state-atom modal-state-atom}]
[unmigrateable-answer])))
(defmethod ce-ex/render-exercise :multistep-calculation [_ _]
(fn [exercise data]
......
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