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

Commit 7f8ae3e7 authored by Joachim Schunk's avatar Joachim Schunk

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

parents 7e6cb357 f5e5ae0b
......@@ -15,8 +15,7 @@
"quill": "^1.3.5",
"prismjs": "1.19.0",
"katex": "0.12.0",
"bulma": "0.9.0",
"bulma-calendar": "6.0.0"
"bulma": "0.9.0"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.0"
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="node_modules/tinymce/tinymce.js"></script>
<link rel="stylesheet" href="node_modules/bulma/css/bulma.min.css">
<link rel="stylesheet" href="node_modules/bulma-calendar/dist/css/bulma-calendar.min.css">
<script src="node_modules/bulma-calendar/dist/js/bulma-calendar.min.js"></script>
<link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="css/screen.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="node_modules/codemirror/mode/python/python.js"></script>
<script src="node_modules/katex/dist/katex.js"></script>
<script src="node_modules/katex/dist/contrib/auto-render.min.js"></script>
<link rel="stylesheet" href="node_modules/katex/dist/katex.css">
<script src="node_modules/mathjs/dist/math.min.js"></script>
<link rel="stylesheet" href="node_modules/codemirror/lib/codemirror.css">
<style id="com-rigsomelight-devcards-addons-css"></style>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
</title>
</head>
<body>
<div id="app">
</div>
<script src="cljs-out/dev-main-devcards.js"></script>
</body>
<head>
<meta charset='utf-8'>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="node_modules/tinymce/tinymce.js"></script>
<link rel="stylesheet" href="node_modules/bulma/css/bulma.min.css">
<link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="css/screen.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="node_modules/quill/dist/quill.snow.css">
<script src="node_modules/sortablejs/Sortable.js"></script>
<script src="node_modules/codemirror/lib/codemirror.js"></script>
<script src="node_modules/codemirror/mode/python/python.js"></script>
<script src="node_modules/katex/dist/katex.js"></script>
<script src="node_modules/katex/dist/contrib/auto-render.min.js"></script>
<link rel="stylesheet" href="node_modules/katex/dist/katex.css">
<script src="node_modules/mathjs/dist/math.min.js"></script>
<link rel="stylesheet" href="node_modules/codemirror/lib/codemirror.css">
<style id="com-rigsomelight-devcards-addons-css"></style>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div id="app"></div>
<script src="cljs-out/dev-main-devcards.js"></script>
</body>
</html>
......@@ -16,8 +16,8 @@
[:input {:color "inherit"}]
;; [:.shifttotop {:margin-top "-1rem"}]
[:.expo-input-container {:display "grid"
:grid-template-rows "auto 5.0rem auto"
:grid-template-columns "6.0rem 1.0rem 3.0rem 4.0rem 1fr"
;;;:grid-template-rows "auto 5.0rem auto"
:grid-template-columns "6.0rem 2.0rem 3.0rem 4.0rem 1fr"
:grid-column-gap "0.3em"}
[:.mantisse {:grid-column "1 / 2"
:grid-row "2 / 4"}]
......@@ -28,6 +28,21 @@
[:.exponent {:align-self "end"
:grid-column "4 / 5"
:grid-row "1 / 3"}]]
[:.unit-input-container {:display "grid"
;;;:grid-template-rows "auto 5.0rem auto"
:grid-template-columns "8.0rem 4.0rem 4.0rem 4.0rem"
:grid-column-gap "0.3em"
:justify-content :center}
[:.prefix {:grid-column "1 / 2"
:grid-row "2 / 4"}]
[:.unit {:grid-column "2 / 3"
:grid-row "2 / 4"}]
[:.exponent {:align-self "end"
:grid-column "3 / 4"
:grid-row "1 / 3"}]
[:.action {:align-self "end"
:grid-column "4 / 5"
:grid-row "1 / 3"}]]
[:.no-border {:border-bottom "none !important"}]
[:div.col.unit-chip {:border "1px solid grey"
:border-radius "2px"}
......
......@@ -26,69 +26,84 @@
"" 0
nil 0})
(def unit-mapping {"m" [{:factor 1 :oom 0 :unit "m" :expo 1}]
"g" [{:factor 1 :oom 0 :unit "g" :expo 1}]
"s" [{:factor 1 :oom 0 :unit "s" :expo 1}]
"A" [{:factor 1 :oom 0 :unit "A" :expo 1}]
"K" [{:factor 1 :oom 0 :unit "K" :expo 1}]
"mol" [{:factor 1 :oom 0 :unit "mol" :expo 1}]
"cd" [{:factor 1 :oom 0 :unit "cd" :expo 1}]
"rad" []
"sr" []
"Hz" [{:factor 1 :oom 0 :unit "s" :expo -1}]
"N" [{:factor 1 :oom 0 :unit "m" :expo 1}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"Pa" [{:factor 1 :oom 0 :unit "m" :expo -1}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"J" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"W" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -3}]
"C" [{:factor 1 :oom 0 :unit "s" :expo 1}
{:factor 1 :oom 0 :unit "A" :expo 1}]
"V" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -3}
{:factor 1 :oom 0 :unit "A" :expo -1}]
"F" [{:factor 1 :oom 0 :unit "m" :expo -2}
{:factor 1 :oom 3 :unit "g" :expo -1}
{:factor 1 :oom 0 :unit "s" :expo 4}
{:factor 1 :oom 0 :unit "A" :expo 2}]
"Ω" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -3}
{:factor 1 :oom 0 :unit "A" :expo -2}]
"S" [{:factor 1 :oom 0 :unit "m" :expo -2}
{:factor 1 :oom 3 :unit "g" :expo -1}
{:factor 1 :oom 0 :unit "s" :expo 3}
{:factor 1 :oom 0 :unit "A" :expo 2}]
"Wb" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}
{:factor 1 :oom 0 :unit "A" :expo -2}]
"T" [{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}
{:factor 1 :oom 0 :unit "A" :expo -1}]
"H" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 3 :unit "g" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}
{:factor 1 :oom 0 :unit "A" :expo -2}]
"lm" [{:factor 1 :oom 0 :unit "cd" :expo 1}]
"lx" [{:factor 1 :oom 0 :unit "m" :expo -2}
{:factor 1 :oom 0 :unit "cd" :expo 1}]
"Bq" [{:factor 1 :oom 0 :unit "s" :expo -1}]
"Gy" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"Sv" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"kat" [{:factor 1 :oom 0 :unit "s" :expo -1}
{:factor 1 :oom 0 :unit "mol" :expo 1}]
"h" [{:factor 3.6 :oom 3 :unit "s" :expo 1}]
"l" [{:factor 1 :oom -1 :unit "m" :expo 3}]})
(def si-unit-mapping {"m" [{:factor 1 :oom 0 :unit "m" :expo 1}]
"g" [{:factor 1 :oom -3 :unit "kg" :expo 1}]
"s" [{:factor 1 :oom 0 :unit "s" :expo 1}]
"A" [{:factor 1 :oom 0 :unit "A" :expo 1}]
"K" [{:factor 1 :oom 0 :unit "K" :expo 1}]
"mol" [{:factor 1 :oom 0 :unit "mol" :expo 1}]
"cd" [{:factor 1 :oom 0 :unit "cd" :expo 1}]
"rad" []
"sr" []
"Hz" [{:factor 1 :oom 0 :unit "s" :expo -1}]
"N" [{:factor 1 :oom 0 :unit "m" :expo 1}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"Pa" [{:factor 1 :oom 0 :unit "m" :expo -1}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"J" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"W" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -3}]
"C" [{:factor 1 :oom 0 :unit "s" :expo 1}
{:factor 1 :oom 0 :unit "A" :expo 1}]
"V" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -3}
{:factor 1 :oom 0 :unit "A" :expo -1}]
"F" [{:factor 1 :oom 0 :unit "m" :expo -2}
{:factor 1 :oom 0 :unit "kg" :expo -1}
{:factor 1 :oom 0 :unit "s" :expo 4}
{:factor 1 :oom 0 :unit "A" :expo 2}]
"Ω" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -3}
{:factor 1 :oom 0 :unit "A" :expo -2}]
"S" [{:factor 1 :oom 0 :unit "m" :expo -2}
{:factor 1 :oom 0 :unit "kg" :expo -1}
{:factor 1 :oom 0 :unit "s" :expo 3}
{:factor 1 :oom 0 :unit "A" :expo 2}]
"Wb" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}
{:factor 1 :oom 0 :unit "A" :expo -2}]
"T" [{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}
{:factor 1 :oom 0 :unit "A" :expo -1}]
"H" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "kg" :expo 1}
{:factor 1 :oom 0 :unit "s" :expo -2}
{:factor 1 :oom 0 :unit "A" :expo -2}]
"lm" [{:factor 1 :oom 0 :unit "cd" :expo 1}]
"lx" [{:factor 1 :oom 0 :unit "m" :expo -2}
{:factor 1 :oom 0 :unit "cd" :expo 1}]
"Bq" [{:factor 1 :oom 0 :unit "s" :expo -1}]
"Gy" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"Sv" [{:factor 1 :oom 0 :unit "m" :expo 2}
{:factor 1 :oom 0 :unit "s" :expo -2}]
"kat" [{:factor 1 :oom 0 :unit "s" :expo -1}
{:factor 1 :oom 0 :unit "mol" :expo 1}]
"h" [{:factor 3.6 :oom 3 :unit "s" :expo 1}]
"d" [{:factor 8.64 :oom 4 :unit "s" :expo 1}]
"l" [{:factor 1 :oom -1 :unit "m" :expo 3}]})
(def additional-unit-mappings {"B" [{:factor 1 :oom 1 :unit "dB" :expo 1}]
"°" [{:factor 1 :oom 0 :unit "°" :expo 1}]})
(def base-unit-set #{"m" "kg" "s" "A" "K" "mol" "cd" "dB" "°"})
(def unit-replace-map {"kg" {:unit "g" :prefix "k"}
"dB" {:unit "B" :prefix "d"}})
(def unit-replace-set (set (keys unit-replace-map)))
(def base-unit-map (reduce (fn [res-map base-unit] (assoc res-map (keyword base-unit) 0)) {} base-unit-set))
(def unit-mapping (merge si-unit-mapping additional-unit-mappings))
(def prefix-set (set (keys prefix-mapping)))
......@@ -127,7 +142,7 @@
(get unit-mapping (:unit unit))))))
(defn reduce-units [units]
(let [result-map {:m 0 :g 0 :s 0 :A 0 :K 0 :mol 0 :cd 0 :factor 1 :oom 0}]
(let [result-map (merge base-unit-map {:factor 1 :oom 0})]
(reduce reduce-unit-mapping
result-map
units)))
......@@ -135,7 +150,8 @@
(defn get-units-part [units with-units target result]
(if with-units
(let [reduced-units (reduce-units units)
base-units (select-keys reduced-units [:m :g :s :A :K :mol :cd])
base-units (select-keys reduced-units
(reduce (fn [res base-unit] (conj res (keyword base-unit))) [] base-unit-set))
units-factor (:factor reduced-units)
units-oom (:oom reduced-units)]
(update result target merge {:base-units base-units :units-factor units-factor :units-oom units-oom}))
......
......@@ -566,7 +566,41 @@
:parse parseDate
:showDaysInNextAndPreviousMonths true})
(defn datepicker
(defn format-date [date]
(let [month (+ (.getMonth date) 1)
day (.getDate date)]
(str (.getFullYear date)
"-"
(when-not (>= month 10)
0)
(+ (.getMonth date) 1)
"-"
(when-not (>= day 10)
0)
day)))
(defn datepicker [{:keys [field-class icon input-class input-size
label-icon value placeholder on-change
label disabled tooltip autocomplete]}]
(fn [{:keys [field-class icon input-class input-size
label-icon value placeholder on-change
label disabled tooltip autocomplete]}]
[:div.field
[:label.label
label]
[:div.control
[:input {:type :date
:disabled disabled
:value (when value
(format-date value))
:on-change #(on-change
(-> %
.-target
.-valueAsDate))}]
]]))
#_(defn datepicker
[{:keys [field-class icon input-class input-size
label-icon value placeholder on-change
label disabled tooltip autocomplete]}]
......@@ -614,7 +648,26 @@
;;:on-change #(on-change (js/Date. (-> % .-target .-value)))
}]]])})))
(defn timepicker
(defn timepicker [{:keys [field-class icon input-class input-size
label-icon value placeholder on-change
label disabled tooltip autocomplete]}]
(fn [{:keys [field-class icon input-class input-size
label-icon value placeholder on-change
label disabled tooltip autocomplete]}]
[:div.field
[:label.label
label]
[:div.control
[:input {:type :time
:value value
:on-change #(on-change
(-> %
.-target
.-value))}]
]]))
#_(defn timepicker
[{:keys [field-class icon input-class input-size
value on-change placeholder label
disabled tooltip autocomplete]}]
......
......@@ -64,13 +64,17 @@
[:table.table.is-striped.is-fullwidth
[:thead
[:tr
(doall (for [h head]
^{:key (str table-id (:id h))} [:th {:on-click #(set-sort-status sort-status h)} (:label h)
(when (and (= (:column @sort-status) (:id h)) (:order @sort-status))
(case (:order @sort-status)
:asc [icon "fa-sort-up"]
:desc [icon "fa-sort-down"]
))]))]]
(doall
(for [h head]
^{:key (str table-id (:id h))}
[:th {:on-click #(set-sort-status sort-status h)}
(:label h (:id h))
(when (and (= (:column @sort-status) (:id h))
(:order @sort-status))
(case (:order @sort-status)
:asc [icon "fa-sort-up"]
:desc [icon "fa-sort-down"]
))]))]]
[:tbody
(let [data (if-let [order (:order @sort-status)]
(sort-by (fn [data]
......@@ -90,9 +94,12 @@
(for [d data]
(let [row-id (:id d)
row-data d]
^{:key row-id} [:tr
(for [h head]
^{:key (str row-id "-" (:id h))} [:td (let [data (get row-data (:id h))]
(if (is-labeled? data)
(:label data)
data))])])))]]])))
^{:key row-id}
[:tr (when-let [row-class (:_row-class d)]
{:class row-class})
(for [h head]
^{:key (str row-id "-" (:id h))}
[:td (let [data (get row-data (:id h))]
(if (is-labeled? data)
(:label data)
data))])])))]]])))
......@@ -31,15 +31,15 @@
(defn correct-tick []
(fn []
[:span.light-green-text "✔ "]))
[:span.has-text-info "✔ "]))
(defn neutral-tick []
(fn []
[:span.blue-text "◌ "]))
[:span.has-text-info "😐 "]))
(defn wrong-tick []
(fn []
[:span.red-text "✘ "]))
[:span.has-text-info "✘ "]))
(defn binary-input [{:keys [default-bits result on-change-fn bitcount]
:or {bitcount 8}}]
......
......@@ -22,17 +22,16 @@
(let [difficulty (get-in @metadata [:difficulty])]
[:div.exercise-metadata
[:div
[:p.range-field
[:label.active {:for "exercise-difficulty"} "Schwierigkeitsgrad " difficulty " "]
[:div.range-field
[:span (when difficulty
[:a {:on-click #(swap! metadata dissoc :difficulty)} "(zurücksetzen)"])]
[:input {:id "exercise-difficulty"
:type "range"
:min 0
:max 100
:step 10
:value (get-in @metadata [:difficulty])
:on-change #(swap! metadata assoc :difficulty (-> % .-target .-value))}]]]]))}))
[ui/input-range
{:min 0
:max 100
:step 10
:label "Schwierigkeitsgrad"
:value (get-in @metadata [:difficulty])
:on-change #(swap! metadata assoc :difficulty %)}]]]]))}))
(defn exercise-preview [exercise answer]
(let [result (reagent/atom nil)
......@@ -71,17 +70,17 @@
[:p.flow-text "Bitte generieren Sie eine Beispielaufgabe."])
(if @modified?
[:a.button {:on-click #(do
(reset! answer nil)
(reset! built-exercise (e-build/build exercise))
(reset! prepared-exercise (e-prepare/prepare @built-exercise))
(reset! modified? false))}
(reset! answer nil)
(reset! built-exercise (e-build/build exercise))
(reset! prepared-exercise (e-prepare/prepare @built-exercise))
(reset! modified? false))}
"Beispielaufgabe generieren"]
[:a.button {:on-click #(if @result
(reset! result nil)
(reset! result (e-check/check-answer
@built-exercise
@answer
println)))}
(reset! result nil)
(reset! result (e-check/check-answer
@built-exercise
@answer
println)))}
(if @result
"Ergebnis zurücksetzen"
"Aufgabe überprüfen")])
......@@ -113,16 +112,16 @@
(fn [exercise]
[:div {:style {:padding "15px"}}
[:a.button {:on-click #(reset! generated
(try
(string/replace
(with-out-str
(-> exercise
pprint))
;;#"\"data:([A-Za-z])*\;base64\,([A-Za-z0-9\/\+\=])*\""
#"\"data\:.{45,}\""
"\"%%%BASE64 DATA%%%\"")
(catch js/Error e
(str "ERROR - " e))))}
(try
(string/replace
(with-out-str
(-> exercise
pprint))
;;#"\"data:([A-Za-z])*\;base64\,([A-Za-z0-9\/\+\=])*\""
#"\"data\:.{45,}\""
"\"%%%BASE64 DATA%%%\"")
(catch js/Error e
(str "ERROR - " e))))}
[ui/icon "fa-code"]
[:span "EDN Code generieren"]]
[:pre {:style {:overflow :auto}}
......@@ -151,38 +150,38 @@
"Einstellungen"
]]
[:div.card-content
(when (not-empty @error)
[:div.card-panel
[:span
[:p.red-text "ERROR"]
(let [lines (clojure.string/split-lines @error)]
(for [line lines]
[:p {:key (hash line)} line]))]])
(when exercise-types
[ui/select*
{:cursor (reagent/cursor exercise [:core :type])
:options (mapv #(hash-map :key (first %) :title (second %)) exercise-types)
:label "Typ"}])
[:div
[:label "Aufgabenstellung"]
[content-editor/editor (reagent/cursor exercise [:core :task-description])]]
(when-let [settings-dialog (get-method ex-edit/show-settings type)]
^{:key (str "settings-" type)}
[settings-dialog exercise options])]]
(when (not-empty @error)
[:div.card-panel
[:span
[:p.red-text "ERROR"]
(let [lines (clojure.string/split-lines @error)]
(for [line lines]
[:p {:key (hash line)} line]))]])
(when exercise-types
[ui/select*
{:cursor (reagent/cursor exercise [:core :type])
:options (mapv #(hash-map :key (first %) :title (second %)) exercise-types)
:label "Typ"}])
[:div
[:label "Aufgabenstellung"]
[content-editor/editor (reagent/cursor exercise [:core :task-description])]]
(when-let [settings-dialog (get-method ex-edit/show-settings type)]
^{:key (str "settings-" type)}
[settings-dialog exercise options])]]
(when-let [additional-forms-dialog (get-method ex-edit/show-additional-forms type)]
^{:key (str "aforms-" type)}
[additional-forms-dialog exercise options])
[ui/collapsible
{:elements
[{:label "EDN"
:icon "code"
:content [edn-code @exercise]}
{:label "Vorschau"
:icon "video_label"
:content (when (and @exercise type)
[exercise-preview @exercise (or answer answer-local)])}
{:label "Metainformationen"
:icon "settings_ethernet"
:content [metadata-settings (reagent/cursor exercise [:metadata])]}]}]
[{:label "EDN"
:icon "code"
:content [edn-code @exercise]}
{:label "Vorschau"
:icon "video_label"
:content (when (and @exercise type)
[exercise-preview @exercise (or answer answer-local)])}
{:label "Metainformationen"
:icon "settings_ethernet"
:content [metadata-settings (reagent/cursor exercise [:metadata])]}]}]
]]]))})))
......@@ -4,11 +4,12 @@
:refer [prefix-mapping prefix-set unit-set not-empty-or-minus]]
[reagent.core :as reagent]
[reagent.dom :as rdom]
[lernmeister.components.ui :as ui]
[lernmeister.components.helper :refer [vec-remove]]))