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
ce3cee77
Commit
ce3cee77
authored
Oct 02, 2020
by
Bruno Burke
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix updating of question type reports, ensure order in binary questions
parent
440f9b10
Pipeline
#48475
passed with stages
in 3 minutes and 24 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
16 deletions
+63
-16
src/cljs/lernmeister/components/question_types/binary_choice/views/report.cljs
...components/question_types/binary_choice/views/report.cljs
+21
-6
src/cljs/lernmeister/components/question_types/binary_choice/views/show.cljs
...r/components/question_types/binary_choice/views/show.cljs
+2
-2
src/cljs/lernmeister/components/question_types/multiple_choice/views/report.cljs
...mponents/question_types/multiple_choice/views/report.cljs
+16
-2
src/cljs/lernmeister/components/question_types/scaled/views/report.cljs
...eister/components/question_types/scaled/views/report.cljs
+20
-5
src/devcards/lernmeister/components/sample_data.cljs
src/devcards/lernmeister/components/sample_data.cljs
+4
-1
No files found.
src/cljs/lernmeister/components/question_types/binary_choice/views/report.cljs
View file @
ce3cee77
...
...
@@ -7,7 +7,8 @@
[
lernmeister.components.ui
:as
ui
]
[
lernmeister.components.i18n.core
:refer
[
i18n-get
]]
[
reagent.core
:as
reagent
]
[
reagent.dom
:as
rdom
]))
[
reagent.dom
:as
rdom
]
[
oops.core
:refer
[
oget+
oget
oset!
]]))
(
defn
chart
[{
:keys
[
answers
answers-count
]}]
...
...
@@ -16,13 +17,12 @@
(
reagent/create-class
{
:component-did-mount
(
fn
[
comp
]
(
let
[
answers
(
sort-by
:count
>
answers
)]
(
reset!
chart-instance
(
new
js/Chart
(
rdom/dom-node
comp
)
(
clj->js
{
:type
:horizontalBar
:data
{
:labels
(
map
:
text
answers
)
:data
{
:labels
(
map
:
label
answers
)
:datasets
[{
:label
""
:data
(
map
:count
answers
)}]}
...
...
@@ -38,7 +38,18 @@
}]}}
;;:plugins [{:afterDatasetsDraw #(afterDraw % {:mean mean :stdev stdev})}]
})))))
}))))
:component-did-update
(
fn
[
comp
]
(
let
[
answers
(
:answers
(
reagent/props
comp
))
answers-count
(
:answers-count
(
reagent/props
comp
))]
(
oset!
@
chart-instance
"data.labels"
(
clj->js
(
map
:label
answers
)))
(
oset!
@
chart-instance
"data.datasets.0.data"
(
clj->js
(
map
:count
answers
)))
(
oset!
@
chart-instance
"options.scales.xAxes.0.ticks.max"
(
clj->js
answers-count
))
(
.update
@
chart-instance
)))
:component-will-unmount
(
fn
[]
(
when
@
chart-instance
...
...
@@ -52,8 +63,12 @@
(
fn
[
question
{
:keys
[
answers
]}]
(
let
[
freqs
(
frequencies
(
map
:value
answers
))
answers-count
(
count
answers
)
answers
(
map-indexed
#
(
assoc
%2
:count
(
get
freqs
%1
))
(
get
question
:answers
))]
answers
(
sort-by
:index
<
(
mapv
(
fn
[[
idx
answer
]]
(
assoc
answer
:label
(
i18n-get
(
:text
answer
))
:count
(
get
freqs
idx
)
:index
idx
))
(
get
question
:answers
)))]
[
:div
[
:b
(
:title
question
)][
:br
]
[
default-task-description
(
:question
question
)]
...
...
src/cljs/lernmeister/components/question_types/binary_choice/views/show.cljs
View file @
ce3cee77
...
...
@@ -30,11 +30,11 @@
(
let
[
qid
(
:id
question
)
answer-options
(
:answers
question
)]
[
:div
[
sc-input
qid
(
nth
answer-options
0
)
[
sc-input
qid
(
get
answer-options
0
)
:index
0
:answer
answer
:on-change
on-change
]
[
sc-input
qid
(
nth
answer-options
1
)
[
sc-input
qid
(
get
answer-options
1
)
:index
1
:answer
answer
:on-change
on-change
]]))})))
...
...
src/cljs/lernmeister/components/question_types/multiple_choice/views/report.cljs
View file @
ce3cee77
...
...
@@ -8,7 +8,8 @@
[
lernmeister.components.ui
:as
ui
]
[
com.stuartsierra.frequencies
:as
freq
]
[
reagent.core
:as
reagent
]
[
reagent.dom
:as
rdom
]))
[
reagent.dom
:as
rdom
]
[
oops.core
:refer
[
oget+
oget
oset!
]]))
(
defn
chart
[{
:keys
[
answers
answers-count
]}]
...
...
@@ -23,7 +24,8 @@
(
rdom/dom-node
comp
)
(
clj->js
{
:type
:horizontalBar
:data
{
:labels
(
map
:text
answers
)
:data
{
:labels
(
map
(
fn
[
a
]
(
i18n-get
(
:text
a
)))
answers
)
:datasets
[{
:label
""
:data
(
map
:count
answers
)}]}
...
...
@@ -40,6 +42,18 @@
;;:plugins [{:afterDatasetsDraw #(afterDraw % {:mean mean :stdev stdev})}]
})))))
:component-did-update
(
fn
[
comp
]
(
let
[
answers
(
:answers
(
reagent/props
comp
))
answers-count
(
:answers-count
(
reagent/props
comp
))]
(
oset!
@
chart-instance
"data.labels"
(
clj->js
(
map
(
fn
[
a
]
(
i18n-get
(
:text
a
)))
answers
)))
(
oset!
@
chart-instance
"data.datasets.0.data"
(
clj->js
(
map
:count
answers
)))
(
oset!
@
chart-instance
"options.scales.xAxes.0.ticks.max"
(
clj->js
answers-count
))
(
.update
@
chart-instance
)))
:component-will-unmount
(
fn
[]
(
when
@
chart-instance
...
...
src/cljs/lernmeister/components/question_types/scaled/views/report.cljs
View file @
ce3cee77
...
...
@@ -75,7 +75,18 @@
)
)
(
defn
chart
[{
:keys
[
freqs
stats
bars
mean
stdev
]}]
(
defn
get-labels
[
bars
left
right
]
(
let
[
min-idx
0
max-idx
(
dec
(
count
bars
))]
(
map-indexed
(
fn
[
idx
bar
]
(
condp
=
idx
min-idx
(
str
bar
"\n("
(
i18n-get
left
)
")"
)
max-idx
(
str
bar
"\n("
(
i18n-get
right
)
")"
)
bar
))
bars
)))
(
defn
chart
[{
:keys
[
freqs
stats
bars
mean
stdev
text-left
text-right
]}]
(
let
[
chart-id
(
gensym
"scaled-report-chart"
)
chart-instance
(
reagent/atom
nil
)]
(
reagent/create-class
...
...
@@ -86,7 +97,7 @@
(
rdom/dom-node
comp
)
(
clj->js
{
:type
:bar
:data
{
:labels
bars
:data
{
:labels
(
get-labels
bars
text-left
text-right
)
:datasets
[{
:label
""
:data
(
mapv
...
...
@@ -106,8 +117,10 @@
:component-did-update
(
fn
[
comp
]
(
let
[
bars
(
:bars
(
reagent/props
comp
))
freqs
(
:freqs
(
reagent/props
comp
))]
(
oset!
@
chart-instance
"data.labels"
(
clj->js
bars
))
freqs
(
:freqs
(
reagent/props
comp
))
text-left
(
:text-left
(
reagent/props
comp
))
text-right
(
:text-right
(
reagent/props
comp
))]
(
oset!
@
chart-instance
"data.labels"
(
clj->js
(
get-labels
bars
text-left
text-right
)))
(
oset!
@
chart-instance
"data.datasets.0.data"
(
clj->js
(
mapv
#
(
get
freqs
%
0
)
...
...
@@ -143,7 +156,9 @@
:freqs
freqs
:bars
bars
:mean
mean
:stdev
stdev
}]
:stdev
stdev
:text-left
(
:text-left
question
)
:text-right
(
:text-right
question
)}]
]
[
:div.column.is-one-fifth
[
:div
...
...
src/devcards/lernmeister/components/sample_data.cljs
View file @
ce3cee77
...
...
@@ -451,7 +451,10 @@
:type
:survey-question,
:core
{
:answers
[{
:text
"Nein"
,
:id
"first"
,
:explanation
false
}
{
:text
"Ja"
}]
,
{
0
{
:text
"Nein"
,
:id
"first"
,
:explanation
false
}
1
{
:text
"Ja"
}}
,
:type
:binary-choice,
:question
{
:i18n
true,
...
...
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