Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
components
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wandelwerk-Software
libraries
components
Commits
95de2c3e
Commit
95de2c3e
authored
Sep 14, 2020
by
Bruno Burke
😁
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'converge-calculation-and-multistep-calculation-exercise' into develop
parents
02a3dea7
5853174c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
21 deletions
+25
-21
src/cljs/lernmeister/components/exercise_types/calculation/views/edit.cljs
...ter/components/exercise_types/calculation/views/edit.cljs
+22
-18
src/cljs/lernmeister/components/exercise_types/calculation/views/show.cljs
...ter/components/exercise_types/calculation/views/show.cljs
+3
-3
No files found.
src/cljs/lernmeister/components/exercise_types/calculation/views/edit.cljs
View file @
95de2c3e
...
...
@@ -5,6 +5,9 @@
[
lernmeister.components.exercise-types.calchelper
:refer
[
calc-change-fn
get-collats-for-vec
]]
[
lernmeister.components.exercise-types.multistep-calculation.check
:refer
[
number-obj
]]
[
lernmeister.components.exercise-types.calculation.components.migration
:refer
[
migrate-exercise-atom
]]
...
...
@@ -22,13 +25,15 @@
(
def
modal-state-atom
(
reagent/atom
{}))
(
defn
get-new-calculation
[]
{
:id
(
get-unique-id
"ae"
)
:name
nil
:number
{
:significand
nil
:order-of-magnitude
"0"
}
: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
...
...
@@ -68,14 +73,11 @@
:on-change
#
(
change-fn
(
conj
base-path
:name
)
(
str/triml
%
))}]]]
[
:div.column.is-half
[
ui/field
{
:label
"Fehler (in %)"
}
[
ui/input-text
{
:value
(
:error-relative
calculation
"1"
)
:on-change
(
fn
[
value
]
(
when-let
[
v
(
->
value
(
->>
(
re-matches
#
"^\-?(0*)(([1-9]\d*)|0)$"
))
(
nth
2
))]
(
change-fn
(
conj
base-path
:error-relative
)
(
edn/read-string
v
))))}]]]
[
ui/input-range
{
:value
(
:error-relative
calculation
)
:min
0
:max
5
:on-change
#
(
change-fn
(
conj
base-path
:error-relative
)
%
)}]]]
[
:div.column.is-half
[
ui/field
{
:label
"Punkte (korrekt)"
}
[
ui/input-text
...
...
@@ -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
]
...
...
src/cljs/lernmeister/components/exercise_types/calculation/views/show.cljs
View file @
95de2c3e
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment