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

Commit c44e1a04 authored by Joachim Schunk's avatar Joachim Schunk

Merge branch 'bulma-css' into 28-create-new-multistep-calculation-exercise-type

parents 838441a0 c13e1295
......@@ -3,20 +3,20 @@
:username "anonymous"}]]
:dependencies [[org.clojure/clojure "1.10.0"]
[org.clojure/clojurescript "1.10.439"]
[org.clojure/tools.logging "0.4.0"]
[org.clojure/tools.logging "1.1.0"]
[org.clojure/math.numeric-tower "0.0.4"]
[binaryage/oops "0.7.0"]
[reagent "0.8.1"]
[garden "1.3.5"]
[reagent "0.10.0"]
[garden "1.3.10"]
[hickory "0.7.1"]
[binaryage/oops "0.7.0"]
[cljsjs/katex "0.9.0-0"]
[clj-http "3.9.0"]
[cljsjs/katex "0.11.1-0"]
[clj-http "3.10.1"]
[wwsoftware/clj-helper "0.0.3.2"]
[cljs-ajax "0.7.3"]
[cljsjs/codemirror "5.31.0-0"]
[cheshire "5.8.0"] ;;; clj-http json support
[devcards "0.2.6" :exclusions [cljsjs/react]]
[cljs-ajax "0.8.0"]
[cljsjs/codemirror "5.44.0-1"]
[cheshire "5.10.0"] ;;; clj-http json support
[devcards "0.2.7" :exclusions [cljsjs/react]]
[cljsjs/react-json-view "1.19.1-0"]]
:aliases {"fig" ["trampoline" "run" "-m" "figwheel.main"]
......@@ -51,8 +51,8 @@
:profiles
{:dev
{:dependencies [[lein-doo "0.1.10"]
[com.bhauman/figwheel-main "0.2.0"]
{:dependencies [[lein-doo "0.1.11"]
[com.bhauman/figwheel-main "0.2.11"]
[com.bhauman/rebel-readline "0.1.4"]
;; [cider/piggieback "0.3.6"]
;; [figwheel-sidecar "0.5.16"]
......@@ -61,9 +61,9 @@
:plugins [;; [lein-figwheel "0.5.16"]
[lein-doo "0.1.10"]]}
:clj-dev
{:dependencies [[lein-doo "0.1.10"]
[org.clojure/data.json "0.2.6"]
[metosin/spec-tools "0.10.0"]]
{:dependencies [[lein-doo "0.1.11"]
[org.clojure/data.json "1.0.0"]
[metosin/spec-tools "0.10.3"]]
:plugins [[lein-doo "0.1.10"]]}}
:cljsbuild
......
......@@ -104,10 +104,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(== (:points result) (:points-max result))) "green lighten-4"
(== (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......
......@@ -46,10 +46,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title (:title exercise)]
......
......@@ -148,10 +148,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......
......@@ -69,10 +69,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......
......@@ -57,10 +57,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......
......@@ -57,10 +57,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......
......@@ -113,10 +113,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......
......@@ -40,10 +40,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......
......@@ -48,10 +48,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title (:title exercise)]
......
(ns lernmeister.components.exercise-types.sorting.views.show
(:require [reagent.core :as reagent]
[reagent.dom :as rdom]
[clj-helper.vector :refer [move get-by]]
[lernmeister.components.content-elements.core :as content-manager]
[lernmeister.components.content-elements.exercise.show :as ce-ex]
[lernmeister.components.content-elements.exercise.task-description :refer [default-task-description]]
[lernmeister.components.common :as common]
[lernmeister.components.ui :as ui]
[clojure.string]))
[clojure.string]
[oops.core :refer [oset!]]
))
(defn answer-input [answer & {:keys [on-change-fn delete-fn idx ordered? result]}]
(fn [answer & {:keys [on-change-fn delete-fn idx ordered? result]}]
......@@ -32,58 +35,59 @@
(take (:element-count exercise) (conj answer new))
(conj answer new))))
(defn answers [exercise & {:keys [result answer on-change-fn]}]
(defn answers [{:keys [exercise result answer on-change-fn]}]
(let [id (gensym (:id exercise))
instance (reagent/atom nil)
answer-list (reagent/atom nil)]
(reagent/create-class
{:component-did-mount
(fn []
(js/Sortable.create (.getElementById js/document id)
(clj->js {:onEnd #(on-change-fn (move @answer-list (.-oldIndex %) (.-newIndex %)))})))
:component-did-update
(fn []
(js/Sortable.create (.getElementById js/document id)
(clj->js {:onEnd #(on-change-fn (move @answer-list (.-oldIndex %) (.-newIndex %)))})))
(fn [this]
(reset! instance
(js/Sortable.create
(rdom/dom-node this)
(clj->js {:direction "vertical"
:sort true
:disabled (some? result)
:store {"get" (fn [sortable]
(clj->js
(or answer
(mapv :id
(:answers exercise)))))
"set" (fn [sortable]
(on-change-fn (vec (.toArray sortable))))}}))))
:component-did-update (fn [this _]
(let [{new-result :result} (reagent/props this)]
(oset! @instance "options.disabled" (some? new-result))))
:component-will-unmount (fn [this]
(js/console.debug "Shutdown js/Sortable")
(.destroy @instance))
:reagent-render
(fn [exercise & {:keys [result answer on-change-fn]}]
(reset! answer-list (vec (or answer (map :id (:answers exercise)))))
[:div.answers
(when (empty? answer)
[:span "(Bitte nehmen Sie eine Sortierung vor)"])
(fn [{:keys [exercise result answer on-change-fn]}]
[:div.list (merge {:id id}
(when (empty? answer)
{:style {:list-style-type :none}}))
(doall
(map-indexed
(fn [idx a]
^{:key (str (:id exercise) a)}
[:a.list-item {:style {:padding-left "15px"
[:a {:key (str (:id exercise) a)
:data-id a
:style {:display :block
:padding-left "15px"
:padding-bottom "2px"
:padding-top "2px"}} [:p.btn (:text (get-by (:answers exercise) :id a))]])
@answer-list)
#_(map-indexed
(fn [idx a]
^{:key (str (:id exercise) idx)}
[:p]
#_[answer-input
a
:on-change-fn #(on-change-fn (assoc answer idx %))
:delete-fn #(on-change-fn (vec (concat (subvec answer 0 idx) (subvec answer (inc idx)))))
:idx idx
:ordered? (:ordered exercise)
:result (when result (if (:ordered exercise)
(or (nth (:answers result) idx) {:text a :correct false})
(or (first (filter #(= (:text %) a) (:answers result))) {:text a :correct false})))])
answer)]])})))
:padding-top "2px"}}
[:p.button (:text (get-by (:answers exercise) :id a))]])
(or answer (mapv :id (:answers exercise)))))])})))
(defn print-sorting-exercise [exercise & {:keys [result answer on-change-fn]}]
(fn [exercise & {:keys [result answer on-change-fn]}]
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title [:b (:title exercise)]]
......@@ -92,7 +96,15 @@
(when (pos? (:element-count exercise))
[:strong (str "(" (:element-count exercise) " Antworten)")])
[:br]
[answers exercise :result result :answer answer :on-change-fn on-change-fn]
[:div.answers.content
(when (empty? answer)
[:span "(Bitte nehmen Sie eine Sortierung vor)"])
[answers
{:exercise exercise
:result result
:answer answer
:on-change-fn #(on-change-fn %)}]
]
(when result
[:span.secondary-content [:b (str (:points result) "P")]])]]))
......
......@@ -71,10 +71,10 @@
[:div.card {:class
(cond
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
(= (:points result) (:points-max result))) "has-background-success"
(and (:points result) (:points-max result)
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
(< 0 (:points result) (:points-max result))) "has-background-warning"
(and (:points result) (<= (:points result) 0)) "has-background-danger"
:else "")}
[:div.card-content
[:span.card-title (:title exercise)]
......
(ns lernmeister.components.material-design
(:require [reagent.core :as reagent]
[reagent.dom :as rdom]
[clojure.string :refer [lower-case split]]))
(defn icon [ligature & {:keys [class]}]
......@@ -402,7 +403,7 @@
(reagent/create-class
{:component-did-mount
(fn [comp]
(let [elem (reagent/dom-node comp)]
(let [elem (rdom/dom-node comp)]
(js/M.Collapsible.init elem (clj->js {}))))
:reagent-render
(fn [{:keys [elements]}]
......
......@@ -7,6 +7,7 @@
[cljsjs.react-json-view]
[lernmeister.components.core :refer [init-exercise-types]]
[reagent.core :as r]
[reagent.dom :as rdom]
))
(defn clj->json
......@@ -124,7 +125,7 @@
(defn ^:export init-showcase [element-id atom-text type]
(case type
"exercise" (r/render [atom-showcase (read-string atom-text)]
(.getElementById js/document element-id))
"content-object" (r/render [ce-showcase (read-string atom-text)]
(.getElementById js/document element-id))))
"exercise" (rdom/render [atom-showcase (read-string atom-text)]
(.getElementById js/document element-id))
"content-object" (rdom/render [ce-showcase (read-string atom-text)]
(.getElementById js/document element-id))))
......@@ -30,21 +30,20 @@
(defcard "## Spec")
(defn exercise []
(defcard-rg mc-exercise-sorting
(fn []
[:div
[exercise/render-exercise @exercise-data
{:answer @answer
:result @result
:on-change #(reset! answer %)}]
[:a.btn {:on-click #(do (reset! result nil)
(reset! answer nil))} "RESET"]
[:a.btn {:on-click #(reset! result (generic-check/check-answer @exercise-data @answer identity))} "Check"]
]
)
(defcard-rg mc-exercise-sorting
[exercise]
[:a.button
{:on-click #(do (reset! result nil)
(reset! answer nil))} "RESET"]
[:a.button
{:on-click #(reset! result
(generic-check/check-answer
@exercise-data @answer identity))} "Check"]])
answer
{:inspect-data true})
......
......@@ -700,19 +700,19 @@
:value "<p>Sortiere Sie die folgenden Zahlen aufsteigend.</p>",
:type :section}],
:answers
[{:id "a2018-10-10T08-00-51-G__36",
[{:id "a1",
:text "1sfsv",
:points 1,
:missed-points 0}
{:id "a2018-10-10T08-01-42-G__37",
{:id "a2",
:text "2djhdshj",
:points 1,
:missed-points 0}
{:id "a2018-10-10T08-01-46-G__38",
{:id "a3",
:text "3nmhjkhj",
:points 1,
:missed-points 0}
{:id "a2018-10-10T08-01-51-G__39",
{:id "a4",
:text "4ztuzttzutzu",
:points 1,
:missed-points 0}]},
......
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