alembic 0.13.0 → 0.15.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: ae4f6fdd30b863971ed64168da8b19b238930a9d6983978e8fd80f5bad0ff206
4
- data.tar.gz: 54d74ca4152be0bee97e02a639b11c240f76bd595523d1a21577b43e062caee0
3
+ metadata.gz: df412b5e51656af183c1272085c276a062e48e21b10c96dc879d64802cc2f1f3
4
+ data.tar.gz: a50967fb05d36e74f384629c4339de6bf1f6a1bfebb555deb125180669fdf65a
5
5
  SHA512:
6
- metadata.gz: 7b507037a195cb807bccae95dbcfbb982a4325e535631fa4e53ba8f21316dca572904e9d2b92fc71b501407819ab1a4dc137718323730829911046af406363fe
7
- data.tar.gz: 0cfdcb1374201572a0fadbd1a9671f2dca43cbedddb8c8e480fa845d415399412883faf53f854bbbc9756b2173766e52f84392ecdf5e85ffed6a7f14c77c86dd
6
+ metadata.gz: 299c2fbfc3638afc343191ae323c59adc0a4198b8f50f393cfdb0b0b61ada4e94117c925171817b980bc06d7a3453da6c87aa6499c4dbb6b4a4ad95c2c986491
7
+ data.tar.gz: 5bf2cf3497adf09bd4b934252b34563e92d54f3466bb4796c548fcf520e8bb93bcb27c17b1038e56aec515bc75228d777a3489d7a9d9fa454c27718c6c509faa
@@ -0,0 +1,21 @@
1
+ module Alembic
2
+ module Manage
3
+ class QuizzesController < EasyFlow::Manage::BaseController
4
+ hosted_by FLOW_HOST
5
+
6
+ def new
7
+ @flow = hosted_flows.new
8
+ end
9
+
10
+ def create
11
+ @flow = hosted_flows.new(params.require(:quiz).permit(:title))
12
+
13
+ if Flow::TitledStart.new(@flow).save
14
+ redirect_to easy_flow.manage_flow_path(@flow), notice: "Quiz created."
15
+ else
16
+ render :new, status: :unprocessable_entity
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -97,7 +97,7 @@ module Alembic
97
97
  end
98
98
 
99
99
  def answered_right?(step, value)
100
- (run&.flow || flow).scored? && Outputs::WeightedSum.weight_of(step_settings(step), value).positive?
100
+ Alembic.marks_right_answers && Outputs::WeightedSum.weight_of(step_settings(step), value).positive?
101
101
  end
102
102
 
103
103
  def step_settings(id)
@@ -0,0 +1,46 @@
1
+ module Alembic
2
+ module Flow
3
+ class TitledStart
4
+ FALLBACK_SLUG = "quiz"
5
+ MADE_SLUG_LENGTH = 100
6
+ TRIES_FOR_A_FREE_SLUG = 3
7
+ SLUGS_THE_ROUTES_USE = %w[manage pages runs].freeze
8
+
9
+ def initialize(flow)
10
+ @flow = flow
11
+ end
12
+
13
+ def save
14
+ return refuse_blank_title if @flow.title.blank?
15
+
16
+ tries = 0
17
+ begin
18
+ @flow.slug = free_slug
19
+ @flow.save
20
+ rescue ActiveRecord::RecordNotUnique
21
+ retry if (tries += 1) < TRIES_FOR_A_FREE_SLUG
22
+ raise
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def refuse_blank_title
29
+ @flow.errors.add(:title, :blank)
30
+ false
31
+ end
32
+
33
+ def free_slug
34
+ made = @flow.title.parameterize.first(MADE_SLUG_LENGTH).chomp("-").presence || FALLBACK_SLUG
35
+ numbered = (2..).lazy.map { |number| "#{made}-#{number}" }
36
+ taken = unavailable
37
+
38
+ [ made ].chain(numbered).find { |candidate| taken.exclude?(candidate) }
39
+ end
40
+
41
+ def unavailable
42
+ EasyFlow::Definition.where(host: @flow.host, owner: @flow.owner).pluck(:slug) + SLUGS_THE_ROUTES_USE
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,11 @@
1
+ <% content_for(:title, "New quiz") %>
2
+
3
+ <%= ui_page(max_width: :md) do %>
4
+ <%= ui_page_header(title: "New quiz") %>
5
+
6
+ <%= ui_form(action: alembic.manage_quizzes_path, method: :post) do %>
7
+ <%= ui_form_field(attribute: "quiz[title]", label: "Title", value: @flow.title, errors: @flow.errors.full_messages_for(:title)) %>
8
+
9
+ <%= ui_button(label: "Create", type: :submit) %>
10
+ <% end %>
11
+ <% end %>
data/config/routes.rb CHANGED
@@ -18,6 +18,8 @@ Alembic::Engine.routes.draw do
18
18
  get :step
19
19
  end
20
20
  end
21
+
22
+ resources :quizzes, only: [ :new, :create ]
21
23
  end
22
24
 
23
25
  constraints(->(request) { request.path_info.match?(%r{\A/manage/flows(/|\z)}) }) do
@@ -130,7 +130,7 @@ class MoveFlowsOntoEasyFlow < ActiveRecord::Migration[8.1]
130
130
 
131
131
  def copy_flows
132
132
  OldFlow.order(:id).to_h do |flow|
133
- [ flow.id, Definition.create!(flow.attributes.slice(*FLOW_COLUMNS).merge("host" => HOST)).id ]
133
+ [ flow.id, Definition.create!(flow.attributes.slice(*FLOW_COLUMNS & Definition.column_names).merge("host" => HOST)).id ]
134
134
  end
135
135
  end
136
136
 
@@ -1,3 +1,3 @@
1
1
  module Alembic
2
- VERSION = "0.13.0"
2
+ VERSION = "0.15.0"
3
3
  end
data/lib/alembic.rb CHANGED
@@ -13,7 +13,7 @@ module Alembic
13
13
  visitor_authorization_method refusal_method owner_method].freeze
14
14
 
15
15
  class << self
16
- attr_accessor :lead_address, :lead_fields_partial, :lead_note, :start_over_address, :finish_link
16
+ attr_accessor :lead_address, :lead_fields_partial, :lead_note, :start_over_address, :finish_link, :marks_right_answers
17
17
  attr_reader :admin_authentication_method, :visitor_authorization_method, :refusal_method, :owner_method
18
18
  attr_writer :finish_title, :finish_subtitle, :finish_answers_heading
19
19
 
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.13.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tylercschneider
@@ -57,14 +57,20 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.30'
60
+ version: '0.32'
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 0.32.1
61
64
  type: :runtime
62
65
  prerelease: false
63
66
  version_requirements: !ruby/object:Gem::Requirement
64
67
  requirements:
65
68
  - - "~>"
66
69
  - !ruby/object:Gem::Version
67
- version: '0.30'
70
+ version: '0.32'
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 0.32.1
68
74
  description: Alembic builds and runs data-driven interactive diagnostics — scored
69
75
  assessments and branching guides — that place a visitor on an outcome and capture
70
76
  the result. A runtime engine plus a UI builder.
@@ -89,6 +95,7 @@ files:
89
95
  - app/controllers/alembic/manage/page_blocks_controller.rb
90
96
  - app/controllers/alembic/manage/pages_controller.rb
91
97
  - app/controllers/alembic/manage/previews_controller.rb
98
+ - app/controllers/alembic/manage/quizzes_controller.rb
92
99
  - app/controllers/alembic/pages_controller.rb
93
100
  - app/controllers/concerns/alembic/manage/authenticates_admin.rb
94
101
  - app/controllers/concerns/alembic/owned_pages.rb
@@ -109,6 +116,7 @@ files:
109
116
  - app/models/alembic/flow/run_summary.rb
110
117
  - app/models/alembic/flow/summaries.rb
111
118
  - app/models/alembic/flow/summary_version.rb
119
+ - app/models/alembic/flow/titled_start.rb
112
120
  - app/models/alembic/flow/uploaded_question.rb
113
121
  - app/models/alembic/flow/uploaded_questions.rb
114
122
  - app/models/alembic/outputs/band.rb
@@ -155,6 +163,7 @@ files:
155
163
  - app/views/alembic/manage/pages/_block_content.html.erb
156
164
  - app/views/alembic/manage/pages/index.html.erb
157
165
  - app/views/alembic/manage/pages/show.html.erb
166
+ - app/views/alembic/manage/quizzes/new.html.erb
158
167
  - app/views/alembic/pages/show.html.erb
159
168
  - app/views/layouts/alembic/application.html.erb
160
169
  - config/routes.rb