alembic 0.8.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 414b18ccf58a55058214c461aa4fe906fb77c7e1044d749b26e95fd1bf23e982
4
- data.tar.gz: cf244807438a8324fbc6ea2c79822a7921a0760b34b98aa57768d1ab43699475
3
+ metadata.gz: 9745fd29a830ce8120e72ac117e6ed70668f620a1a8bd73f016dcca369006c19
4
+ data.tar.gz: 0b4c9f862d77e9841be71f804a6ce7d97d7a2252accca09de540a34ce5588c99
5
5
  SHA512:
6
- metadata.gz: 24209db470a718be9af4a25a3e4c4223a25c7c80ad493995a277a2052d341ec02389b2f087f6e468dacfdef826115c523b6a65fbee4a1007e864f25cb3b0ad5b
7
- data.tar.gz: 87a2aa618d2ee1ed3adf08fff98f0fb0c25c75768c7da4a931e07310f02005d33933b0f7b02f11c97f57da360761bd4660573ebc6656e57e6892400142de79d7
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 :step_category, :shows_answer_values?
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, :answered_right?
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
@@ -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, false, class: "peer sr-only", onchange: (local_assigns.fetch(:sends_on_choice, true) ? "this.form.requestSubmit()" : nil) %>
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>
@@ -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
- <%= render "alembic/flows/question", question: question, category: step_category(question), shows_values: shows_answer_values?, sends_on_choice: false %>
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.respond_to?(:choices) %>
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
@@ -14,6 +14,9 @@ Alembic::Engine.routes.draw do
14
14
  resource :preview, only: :show, controller: "previews" do
15
15
  get :step
16
16
  end
17
+ resource :answer_key, only: :show, controller: "answer_keys" do
18
+ get :step
19
+ end
17
20
  end
18
21
  end
19
22
 
@@ -1,3 +1,3 @@
1
1
  module Alembic
2
- VERSION = "0.8.3"
2
+ VERSION = "0.9.0"
3
3
  end
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.8.3
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.27'
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.27'
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