alembic 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/alembic/flows_controller.rb +1 -5
- data/app/controllers/alembic/manage/answer_keys_controller.rb +30 -0
- data/app/controllers/concerns/alembic/summarizes.rb +19 -1
- data/app/models/alembic/flow/answer_key.rb +13 -0
- data/app/views/alembic/flows/_question.html.erb +1 -1
- data/app/views/alembic/flows/complete.html.erb +6 -1
- data/app/views/alembic/flows/one_page.html.erb +5 -1
- data/app/views/alembic/flows/step.html.erb +3 -3
- data/app/views/alembic/manage/flows/edit.html.erb +4 -0
- data/config/routes.rb +3 -0
- data/lib/alembic/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9745fd29a830ce8120e72ac117e6ed70668f620a1a8bd73f016dcca369006c19
|
|
4
|
+
data.tar.gz: 0b4c9f862d77e9841be71f804a6ce7d97d7a2252accca09de540a34ce5588c99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3c136947c2ca35cb00702f965965cd4e73c7a6605c44188f7966062602026fdded09c355723b974531397c5fbd9b7232742118123d25bf8501a645e6ada4c9b
|
|
7
|
+
data.tar.gz: 24920854c0d867b45620284d65823872fd990561bf0fb025b9a73612bb92e75e86c5255b5b7728b73f5167f007d86175702b8467eb43f6a21625d8b3feba85dc
|
|
@@ -2,7 +2,7 @@ module Alembic
|
|
|
2
2
|
class FlowsController < EasyFlow::FlowsController
|
|
3
3
|
hosted_by FLOW_HOST
|
|
4
4
|
include Summarizes
|
|
5
|
-
helper_method :
|
|
5
|
+
helper_method :shows_answer_values?
|
|
6
6
|
|
|
7
7
|
def step
|
|
8
8
|
return super unless asked_on_one_page?
|
|
@@ -32,10 +32,6 @@ module Alembic
|
|
|
32
32
|
Flow::Summaries.new(run&.flow || flow).shows_answer_values?
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def step_category(question)
|
|
36
|
-
EasyFlow::Steps::Question.category_of(@guide.step(question.id)&.config)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
35
|
def run_location(run)
|
|
40
36
|
alembic.run_path(run)
|
|
41
37
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Alembic
|
|
2
|
+
module Manage
|
|
3
|
+
class AnswerKeysController < PreviewsController
|
|
4
|
+
helper_method :shows_answer_values?
|
|
5
|
+
|
|
6
|
+
def self.local_prefixes
|
|
7
|
+
[ "alembic/flows", *super ]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def flow_start_path(_slug)
|
|
13
|
+
alembic.manage_flow_answer_key_path(previewed)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def flow_step_path(_slug)
|
|
17
|
+
alembic.step_manage_flow_answer_key_path(previewed)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def chosen_answer(question)
|
|
21
|
+
step = @guide.step(question.id)
|
|
22
|
+
Flow::AnswerKey.chosen(step.config.merge("type" => step.type))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def shows_answer_values?
|
|
26
|
+
Flow::Summaries.new(previewed).shows_answer_values?
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -10,11 +10,23 @@ module Alembic
|
|
|
10
10
|
helper ContentBlocksHelper
|
|
11
11
|
helper KsBlocks::LayoutHelper
|
|
12
12
|
after_action :keep_ended_inner_run, only: :step
|
|
13
|
-
helper_method :flow_summary, :first_step_path, :summary_values, :intro_values, :start_over_path, :finish_link, :visited_flow_address
|
|
13
|
+
helper_method :flow_summary, :first_step_path, :summary_values, :intro_values, :start_over_path, :finish_link, :visited_flow_address, :answered_right?, :single_choice?, :drawing_of, :chosen_answer, :step_category
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
private
|
|
17
17
|
|
|
18
|
+
def single_choice?(question)
|
|
19
|
+
@guide.step(question.id)&.type == "question"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def step_category(question)
|
|
23
|
+
EasyFlow::Steps::Question.category_of(@guide.step(question.id)&.config)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def drawing_of(question)
|
|
27
|
+
EasyFlow::Drawing.of(@guide.step(question.id))
|
|
28
|
+
end
|
|
29
|
+
|
|
18
30
|
def flow_summary(flow)
|
|
19
31
|
Flow::Summaries.new(flow).text
|
|
20
32
|
end
|
|
@@ -23,6 +35,8 @@ module Alembic
|
|
|
23
35
|
flow_step_path(slug)
|
|
24
36
|
end
|
|
25
37
|
|
|
38
|
+
def chosen_answer(_question); end
|
|
39
|
+
|
|
26
40
|
def start_over_path
|
|
27
41
|
flow_start_path(visited_flow_address)
|
|
28
42
|
end
|
|
@@ -78,6 +92,10 @@ module Alembic
|
|
|
78
92
|
.merge("slug" => @guide.slug, "note" => result_note, "answers" => answers_given)
|
|
79
93
|
end
|
|
80
94
|
|
|
95
|
+
def answered_right?(step, value)
|
|
96
|
+
(run&.flow || flow).scored? && Outputs::WeightedSum.weight_of(@guide.step(step).config, value).positive?
|
|
97
|
+
end
|
|
98
|
+
|
|
81
99
|
def answers_given
|
|
82
100
|
@answered.map { |step, value| [ @guide.question_text(step), @guide.choice_label(step, value) ] }
|
|
83
101
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Alembic
|
|
2
|
+
module Flow
|
|
3
|
+
module AnswerKey
|
|
4
|
+
def self.chosen(step)
|
|
5
|
+
case step["type"]
|
|
6
|
+
when "multiple_select" then Outputs::WeightedSum.right_answers(step)
|
|
7
|
+
when "fill_in_the_blank" then Array(step["accepted_answers"]).first&.fetch("value", nil)
|
|
8
|
+
else Outputs::WeightedSum.right_answers(step).first
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<div class="space-y-3">
|
|
7
7
|
<% question.choices.each do |choice| %>
|
|
8
8
|
<label class="block cursor-pointer">
|
|
9
|
-
<%= radio_button_tag "answers[#{question.id}]", choice.value,
|
|
9
|
+
<%= radio_button_tag "answers[#{question.id}]", choice.value, choice.value == local_assigns[:chosen], class: "peer sr-only", onchange: (local_assigns.fetch(:sends_on_choice, true) ? "this.form.requestSubmit()" : nil) %>
|
|
10
10
|
<span class="ks-radio-card ks-radio-card-highlight flex items-start gap-3 transition hover:border-(color:--ks-color-hover-border)">
|
|
11
11
|
<% if shows_values %>
|
|
12
12
|
<span class="text-xs font-semibold uppercase tracking-wider text-(color:--ks-color-link) dark:text-(color:--ks-color-link-dark) border border-(color:--ks-color-tint-border) rounded px-2 py-0.5 shrink-0 mt-0.5"><%= choice.value %></span>
|
|
@@ -40,7 +40,12 @@
|
|
|
40
40
|
<% @answered.each do |step, value| %>
|
|
41
41
|
<li data-answer="<%= step %>" class="flex items-baseline justify-between gap-6 py-3">
|
|
42
42
|
<span class="ks-tone-muted"><%= @guide.question_text(step) %></span>
|
|
43
|
-
<span class="shrink-0 font-(weight:--ks-font-weight-medium) ks-tone-neutral"
|
|
43
|
+
<span class="flex shrink-0 items-center gap-2 font-(weight:--ks-font-weight-medium) ks-tone-neutral">
|
|
44
|
+
<%= @guide.choice_label(step, value) %>
|
|
45
|
+
<% if answered_right?(step, value) %>
|
|
46
|
+
<svg aria-label="Right" role="img" class="size-5 ks-tone-success" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z" clip-rule="evenodd" /></svg>
|
|
47
|
+
<% end %>
|
|
48
|
+
</span>
|
|
44
49
|
</li>
|
|
45
50
|
<% end %>
|
|
46
51
|
</ul>
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
<% @questions.each_with_index do |question, index| %>
|
|
14
14
|
<div data-one-page-question>
|
|
15
15
|
<div class="mb-8"><%= ui_progress(value: index, max: @questions.size, label: "Question #{index + 1} of #{@questions.size}") %></div>
|
|
16
|
-
|
|
16
|
+
<% if single_choice?(question) %>
|
|
17
|
+
<%= render "alembic/flows/question", question: question, category: step_category(question), shows_values: shows_answer_values?, sends_on_choice: false %>
|
|
18
|
+
<% else %>
|
|
19
|
+
<%= render drawing_of(question), step: question %>
|
|
20
|
+
<% end %>
|
|
17
21
|
<% if index.positive? %>
|
|
18
22
|
<button type="button" data-one-page-previous hidden class="mt-6 ks-tone-muted cursor-pointer text-sm underline underline-offset-2 hover:text-(color:--ks-color-text) dark:hover:text-(color:--ks-color-text-dark)">← Previous</button>
|
|
19
23
|
<% end %>
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
<% end %>
|
|
26
26
|
<% end %>
|
|
27
27
|
|
|
28
|
-
<% if @question
|
|
28
|
+
<% if single_choice?(@question) %>
|
|
29
29
|
<%= render "alembic/flows/question", question: @question, category: step_category(@question),
|
|
30
|
-
shows_values: shows_answer_values
|
|
30
|
+
shows_values: shows_answer_values?, chosen: chosen_answer(@question) %>
|
|
31
31
|
<% else %>
|
|
32
|
-
<%= render @drawing, step: @question %>
|
|
32
|
+
<%= render @drawing, step: @question, chosen: chosen_answer(@question) %>
|
|
33
33
|
<% end %>
|
|
34
34
|
|
|
35
35
|
<div class="mt-8 flex items-center gap-4">
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
<% end %>
|
|
12
12
|
<% end %>
|
|
13
13
|
|
|
14
|
+
<%= ui_section(title: "Answer key") do %>
|
|
15
|
+
<%= link_to "Walk through the answer key", alembic.step_manage_flow_answer_key_path(@flow), class: "text-sm text-(color:--ks-color-link) hover:text-(color:--ks-color-link-hover) dark:text-(color:--ks-color-link-dark) dark:hover:text-(color:--ks-color-link-hover-dark)" %>
|
|
16
|
+
<% end %>
|
|
17
|
+
|
|
14
18
|
<%= ui_form(action: easy_flow.manage_flow_path(@flow), method: :patch) do %>
|
|
15
19
|
<%= ui_section(title: "How this is introduced") do %>
|
|
16
20
|
<label class="ks-label mb-1">Title</label>
|
data/config/routes.rb
CHANGED
data/lib/alembic/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: alembic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tylercschneider
|
|
@@ -57,14 +57,14 @@ dependencies:
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '0.
|
|
60
|
+
version: '0.29'
|
|
61
61
|
type: :runtime
|
|
62
62
|
prerelease: false
|
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '0.
|
|
67
|
+
version: '0.29'
|
|
68
68
|
description: Alembic builds and runs data-driven interactive diagnostics — scored
|
|
69
69
|
assessments and branching guides — that place a visitor on an outcome and capture
|
|
70
70
|
the result. A runtime engine plus a UI builder.
|
|
@@ -83,6 +83,7 @@ files:
|
|
|
83
83
|
- app/assets/stylesheets/alembic/application.css
|
|
84
84
|
- app/controllers/alembic/application_controller.rb
|
|
85
85
|
- app/controllers/alembic/flows_controller.rb
|
|
86
|
+
- app/controllers/alembic/manage/answer_keys_controller.rb
|
|
86
87
|
- app/controllers/alembic/manage/base_controller.rb
|
|
87
88
|
- app/controllers/alembic/manage/flows_controller.rb
|
|
88
89
|
- app/controllers/alembic/manage/page_blocks_controller.rb
|
|
@@ -101,6 +102,7 @@ files:
|
|
|
101
102
|
- app/jobs/alembic/application_job.rb
|
|
102
103
|
- app/mailers/alembic/application_mailer.rb
|
|
103
104
|
- app/models/alembic/application_record.rb
|
|
105
|
+
- app/models/alembic/flow/answer_key.rb
|
|
104
106
|
- app/models/alembic/flow/definition_summary.rb
|
|
105
107
|
- app/models/alembic/flow/output_form.rb
|
|
106
108
|
- app/models/alembic/flow/preview_values.rb
|