mumuki-laboratory 7.6.2 → 7.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +203 -2
- data/Rakefile +9 -0
- data/app/assets/javascripts/mumuki_laboratory/application.js +0 -1
- data/app/assets/javascripts/mumuki_laboratory/application/alias-modes.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/assets-loader.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/bridge.js +82 -47
- data/app/assets/javascripts/mumuki_laboratory/application/button.js +90 -1
- data/app/assets/javascripts/mumuki_laboratory/application/codemirror-builder.js +28 -25
- data/app/assets/javascripts/mumuki_laboratory/application/codemirror.js +8 -9
- data/app/assets/javascripts/mumuki_laboratory/application/confirmation.js +2 -2
- data/app/assets/javascripts/mumuki_laboratory/application/console.js +41 -43
- data/app/assets/javascripts/mumuki_laboratory/application/csrf-token.js +9 -12
- data/app/assets/javascripts/mumuki_laboratory/application/custom-editor.js +46 -8
- data/app/assets/javascripts/mumuki_laboratory/application/discussions.js +15 -16
- data/app/assets/javascripts/mumuki_laboratory/application/editors.js +104 -0
- data/app/assets/javascripts/mumuki_laboratory/application/elipsis.js +5 -4
- data/app/assets/javascripts/mumuki_laboratory/application/exercise.js +32 -0
- data/app/assets/javascripts/mumuki_laboratory/application/inputs.js +4 -2
- data/app/assets/javascripts/mumuki_laboratory/application/interval.js +2 -4
- data/app/assets/javascripts/mumuki_laboratory/application/kids.js +74 -37
- data/app/assets/javascripts/mumuki_laboratory/application/load-analytics.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/load-error-svg.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/messages.js +2 -2
- data/app/assets/javascripts/mumuki_laboratory/application/multiple-choice.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/multiple-scenarios.js +3 -6
- data/app/assets/javascripts/mumuki_laboratory/application/pin.js +3 -5
- data/app/assets/javascripts/mumuki_laboratory/application/progress.js +27 -6
- data/app/assets/javascripts/mumuki_laboratory/application/results-renderer.js +60 -0
- data/app/assets/javascripts/mumuki_laboratory/application/speech-bubble-renderer.js +12 -5
- data/app/assets/javascripts/mumuki_laboratory/application/submission.js +122 -55
- data/app/assets/javascripts/mumuki_laboratory/application/submissions-store.js +93 -0
- data/app/assets/javascripts/mumuki_laboratory/application/sync-mode.js +75 -0
- data/app/assets/javascripts/mumuki_laboratory/application/timer.js +5 -6
- data/app/assets/javascripts/mumuki_laboratory/application/tooltip.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/upload.js +1 -1
- data/app/assets/javascripts/mumuki_laboratory/application/user.js +1 -1
- data/app/assets/stylesheets/mumuki_laboratory/application/_modules.scss +1 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_discussion.scss +43 -5
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_gs-board.scss +3 -0
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kids.scss +3 -4
- data/app/assets/stylesheets/mumuki_laboratory/application/modules/_kindergarten.scss +55 -0
- data/app/controllers/application_controller.rb +1 -0
- data/app/controllers/assets_controller.rb +2 -0
- data/app/controllers/concerns/with_authorization.rb +4 -0
- data/app/controllers/concerns/with_user_discussion_validation.rb +14 -0
- data/app/controllers/discussions_controller.rb +6 -14
- data/app/controllers/discussions_messages_controller.rb +10 -1
- data/app/controllers/exercise_solutions_controller.rb +4 -2
- data/app/helpers/application_helper.rb +9 -5
- data/app/helpers/discussions_helper.rb +37 -23
- data/app/helpers/exercise_input_helper.rb +1 -1
- data/app/helpers/{locale_helper.rb → globals_helper.rb} +6 -2
- data/app/helpers/icons_helper.rb +3 -3
- data/app/mailers/user_mailer.rb +24 -11
- data/app/views/book/show.html.erb +1 -1
- data/app/views/book_discussions/index.html.erb +3 -3
- data/app/views/discussions/_message.html.erb +20 -8
- data/app/views/discussions/index.html.erb +0 -1
- data/app/views/discussions/new.html.erb +33 -0
- data/app/views/discussions/show.html.erb +18 -46
- data/app/views/exercise_solutions/_contextualization_results_container.html.erb +1 -1
- data/app/views/exercise_solutions/_results_title.html.erb +2 -2
- data/app/views/exercises/_read_only.html.erb +33 -6
- data/app/views/exercises/show.html.erb +2 -0
- data/app/views/layouts/_copyright.html.erb +1 -1
- data/app/views/layouts/_discussions.html.erb +21 -3
- data/app/views/layouts/_main.html.erb +1 -2
- data/app/views/layouts/_progress.html.erb +1 -1
- data/app/views/layouts/_progress_bar.html.erb +7 -1
- data/app/views/layouts/_test_results.html.erb +1 -1
- data/app/views/layouts/application.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/editors/_custom.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/forms/_kids_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/forms/_problem_form.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/layouts/_input_bottom.html.erb +1 -1
- data/app/views/layouts/exercise_inputs/layouts/_input_kindergarten.html.erb +40 -0
- data/app/views/layouts/exercise_inputs/layouts/{_input_kids.html.erb → _input_primary.html.erb} +1 -1
- data/app/views/layouts/exercise_inputs/layouts/_input_right.html.erb +1 -1
- data/app/views/layouts/modals/_kids_context.html.erb +1 -8
- data/app/views/user_mailer/1st_reminder.html.erb +1 -1
- data/app/views/user_mailer/1st_reminder.text.erb +1 -1
- data/app/views/user_mailer/2nd_reminder.html.erb +1 -1
- data/app/views/user_mailer/2nd_reminder.text.erb +1 -1
- data/app/views/user_mailer/3rd_reminder.html.erb +1 -1
- data/app/views/user_mailer/3rd_reminder.text.erb +1 -1
- data/app/views/user_mailer/no_submissions_reminder.html.erb +1 -1
- data/app/views/user_mailer/no_submissions_reminder.text.erb +1 -1
- data/config/routes.rb +2 -1
- data/lib/mumuki/laboratory/controllers.rb +1 -0
- data/lib/mumuki/laboratory/controllers/incognito_mode.rb +28 -0
- data/lib/mumuki/laboratory/controllers/results_rendering.rb +1 -2
- data/lib/mumuki/laboratory/locales/en.yml +14 -6
- data/lib/mumuki/laboratory/locales/es-CL.yml +292 -0
- data/lib/mumuki/laboratory/locales/es.yml +13 -5
- data/lib/mumuki/laboratory/locales/pt.yml +12 -6
- data/lib/mumuki/laboratory/version.rb +1 -1
- data/spec/controllers/confirmations_controller_spec.rb +1 -1
- data/spec/controllers/discussions_messages_controller_spec.rb +73 -0
- data/spec/controllers/exercise_solutions_controller_spec.rb +41 -6
- data/spec/dummy/db/schema.rb +13 -1
- data/spec/features/chapter_spec.rb +17 -0
- data/spec/features/discussion_flow_spec.rb +190 -0
- data/spec/features/exercise_flow_spec.rb +48 -3
- data/spec/features/home_public_flow_spec.rb +16 -0
- data/spec/features/menu_bar_spec.rb +88 -7
- data/spec/helpers/breadcrumbs_helper_spec.rb +1 -1
- data/spec/javascripts/bridge-spec.js +5 -0
- data/spec/javascripts/csrf-token-spec.js +7 -0
- data/spec/javascripts/editors-spec.js +54 -0
- data/spec/javascripts/elipsis-spec.js +25 -0
- data/spec/javascripts/exercise-spec.js +22 -0
- data/spec/javascripts/global-spec.js +6 -0
- data/spec/javascripts/results-renderers-spec.js +17 -0
- data/spec/javascripts/spec-helper.js +34 -0
- data/spec/javascripts/speech-bubble-renderer-spec.js +11 -0
- data/spec/javascripts/submissions-store-spec.js +44 -0
- data/spec/javascripts/sync-mode-spec.js +15 -0
- data/spec/javascripts/timeout-spec.js +5 -0
- data/spec/javascripts/timer-spec.js +5 -0
- data/spec/mailers/user_mailer_spec.rb +18 -3
- data/spec/teaspoon_env.rb +193 -0
- metadata +50 -11
- data/app/helpers/version_helper.rb +0 -5
- data/app/views/layouts/modals/_new_discussion.html.erb +0 -27
- data/vendor/assets/javascripts/hotjar.js +0 -8
@@ -15,6 +15,6 @@ describe ExerciseConfirmationsController, organization_workspace: :test do
|
|
15
15
|
before { post :create, params: { exercise_id: reading.id } }
|
16
16
|
|
17
17
|
it { expect(response.status).to eq 200 }
|
18
|
-
it { expect(response.body).to json_like(guide_finished_by_solution: true
|
18
|
+
it { expect(response.body).to json_like(guide_finished_by_solution: true) }
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DiscussionsMessagesController, organization_workspace: :test do
|
4
|
+
let(:student) { create(:user, permissions: {student: 'test/*'}) }
|
5
|
+
let(:moderator) { create(:user, permissions: {moderator: 'test/*', student: 'test/*'}) }
|
6
|
+
|
7
|
+
let(:exercise) { create(:exercise) }
|
8
|
+
let(:discussion) { create(:discussion, item: exercise, organization: Organization.current) }
|
9
|
+
|
10
|
+
before { Organization.current.update! forum_enabled: true }
|
11
|
+
|
12
|
+
describe 'post' do
|
13
|
+
describe 'for student' do
|
14
|
+
before { set_current_user! student }
|
15
|
+
before { allow_any_instance_of(DiscussionsMessagesController).to receive(:message_params).and_return content: 'Need help' }
|
16
|
+
before { post :create, params: {discussion_id: discussion.id} }
|
17
|
+
|
18
|
+
it { expect(response.status).to eq 302 }
|
19
|
+
it { expect(discussion.messages.size).to eq 1 }
|
20
|
+
it { expect(discussion.messages.last.content).to eq 'Need help' }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'for moderator' do
|
24
|
+
before { set_current_user! moderator }
|
25
|
+
before { allow_any_instance_of(DiscussionsMessagesController).to receive(:message_params).and_return content: 'Do this!' }
|
26
|
+
before { post :create, params: {discussion_id: discussion.id} }
|
27
|
+
|
28
|
+
it { expect(response.status).to eq 302 }
|
29
|
+
it { expect(discussion.messages.size).to eq 1 }
|
30
|
+
it { expect(discussion.messages.last.content).to eq 'Do this!' }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'approve' do
|
35
|
+
let(:message) { create(:message, discussion: discussion, sender: student.uid) }
|
36
|
+
|
37
|
+
describe 'for student' do
|
38
|
+
before { set_current_user! student }
|
39
|
+
before { post :approve, params: {id: message.id, discussion_id: discussion.id} }
|
40
|
+
|
41
|
+
it { expect(response.status).to eq 403 }
|
42
|
+
it { expect(message.reload.approved).to be false }
|
43
|
+
end
|
44
|
+
|
45
|
+
describe 'for student' do
|
46
|
+
before { set_current_user! moderator }
|
47
|
+
before { post :approve, params: {id: message.id, discussion_id: discussion.id} }
|
48
|
+
|
49
|
+
it { expect(response.status).to eq 200 }
|
50
|
+
it { expect(message.reload.approved).to be true }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'question' do
|
55
|
+
let(:message) { create(:message, discussion: discussion, sender: student.uid) }
|
56
|
+
|
57
|
+
describe 'for student' do
|
58
|
+
before { set_current_user! student }
|
59
|
+
before { post :question, params: {id: message.id, discussion_id: discussion.id} }
|
60
|
+
|
61
|
+
it { expect(response.status).to eq 403 }
|
62
|
+
it { expect(message.reload.not_actually_a_question).to be false }
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'for student' do
|
66
|
+
before { set_current_user! moderator }
|
67
|
+
before { post :question, params: {id: message.id, discussion_id: discussion.id} }
|
68
|
+
|
69
|
+
it { expect(response.status).to eq 200 }
|
70
|
+
it { expect(message.reload.not_actually_a_question).to be true }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe ExerciseSolutionsController, organization_workspace: :test do
|
4
4
|
let(:user) { create(:user) }
|
5
5
|
let(:problem) { create(:problem) }
|
6
|
-
let(:kids_problem) { create(:problem, layout: :
|
6
|
+
let(:kids_problem) { create(:problem, layout: :input_primary) }
|
7
7
|
let!(:chapter) {
|
8
8
|
create(:chapter, name: 'Functional Programming', lessons: [
|
9
9
|
create(:lesson, exercises: [problem, kids_problem])
|
@@ -13,21 +13,56 @@ describe ExerciseSolutionsController, organization_workspace: :test do
|
|
13
13
|
before { set_current_user! user }
|
14
14
|
|
15
15
|
def post_problem(problem)
|
16
|
-
post :create, params: { exercise_id: problem.id, solution: { content: '
|
16
|
+
post :create, params: { exercise_id: problem.id, solution: { content: 'the content' } }
|
17
17
|
end
|
18
18
|
|
19
19
|
|
20
|
-
|
20
|
+
context 'when submission contains client_result' do
|
21
|
+
let(:problem) { create(:problem) }
|
22
|
+
let(:assignment) { Assignment.last }
|
23
|
+
|
24
|
+
before { expect_any_instance_of(Language).to receive(:run_tests!).with(bridge_request) }
|
25
|
+
before do
|
26
|
+
post :create, params: {
|
27
|
+
exercise_id: problem.id,
|
28
|
+
solution: { content: 'the content' },
|
29
|
+
client_result: {
|
30
|
+
status: :passed_with_warnings,
|
31
|
+
test_results: [{title: 'everything works', status: 'passed'}]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:bridge_request) do
|
37
|
+
{
|
38
|
+
content: 'the content',
|
39
|
+
custom_expectations: "\n",
|
40
|
+
expectations: [],
|
41
|
+
extra: "",
|
42
|
+
locale: "en",
|
43
|
+
settings: {},
|
44
|
+
test: "dont care",
|
45
|
+
client_result: {
|
46
|
+
status: 'passed_with_warnings',
|
47
|
+
test_results: [{title: 'everything works', status: 'passed'}]
|
48
|
+
}
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
it { expect(assignment.solution).to eq 'the content' }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when simple content is sent' do
|
21
56
|
context 'for a non-kids exercise' do
|
22
57
|
before { post_problem(problem) }
|
23
58
|
let(:assignment) { Assignment.last }
|
24
59
|
|
25
60
|
context 'without client-side interpolations' do
|
26
61
|
it { expect(response.status).to eq 200 }
|
27
|
-
it { expect(assignment.solution).to eq('
|
62
|
+
it { expect(assignment.solution).to eq('the content')}
|
28
63
|
|
29
64
|
it { expect(response.body).to json_eq({ status: :failed, guide_finished_by_solution: false },
|
30
|
-
except: [:
|
65
|
+
except: [:html, :remaining_attempts_html]) }
|
31
66
|
|
32
67
|
|
33
68
|
it 'does not include kids specific renders' do
|
@@ -54,7 +89,7 @@ describe ExerciseSolutionsController, organization_workspace: :test do
|
|
54
89
|
before { post_problem(kids_problem) }
|
55
90
|
|
56
91
|
it { expect(response.body).to json_eq({ status: :failed, guide_finished_by_solution: false },
|
57
|
-
except: [:
|
92
|
+
except: [:html, :remaining_attempts_html,
|
58
93
|
:title_html, :button_html, :expectations, :test_results, :tips]) }
|
59
94
|
|
60
95
|
it 'includes kids specific renders' do
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 20200804191643) do
|
14
14
|
|
15
15
|
# These are extensions that must be enabled in order to support this database
|
16
16
|
enable_extension "plpgsql"
|
@@ -117,6 +117,11 @@ ActiveRecord::Schema.define(version: 20200608132959) do
|
|
117
117
|
t.text "manual_evaluation_comment"
|
118
118
|
t.integer "upvotes_count", default: 0
|
119
119
|
t.bigint "organization_id"
|
120
|
+
t.integer "messages_count", default: 0
|
121
|
+
t.integer "validated_messages_count", default: 0
|
122
|
+
t.boolean "requires_moderator_response", default: true
|
123
|
+
t.string "last_moderator_access_by_id"
|
124
|
+
t.datetime "last_moderator_access_at"
|
120
125
|
t.index ["initiator_id"], name: "index_discussions_on_initiator_id"
|
121
126
|
t.index ["item_type", "item_id"], name: "index_discussions_on_item_type_and_item_id"
|
122
127
|
t.index ["organization_id"], name: "index_discussions_on_organization_id"
|
@@ -143,7 +148,11 @@ ActiveRecord::Schema.define(version: 20200608132959) do
|
|
143
148
|
t.integer "max_problem_submissions"
|
144
149
|
t.integer "max_choice_submissions"
|
145
150
|
t.boolean "results_hidden_for_choices", default: false
|
151
|
+
t.bigint "course_id"
|
152
|
+
t.integer "passing_criterion_type", default: 0
|
153
|
+
t.integer "passing_criterion_value"
|
146
154
|
t.index ["classroom_id"], name: "index_exams_on_classroom_id", unique: true
|
155
|
+
t.index ["course_id"], name: "index_exams_on_course_id"
|
147
156
|
t.index ["guide_id"], name: "index_exams_on_guide_id"
|
148
157
|
t.index ["organization_id"], name: "index_exams_on_organization_id"
|
149
158
|
end
|
@@ -288,6 +297,7 @@ ActiveRecord::Schema.define(version: 20200608132959) do
|
|
288
297
|
t.boolean "read", default: false
|
289
298
|
t.integer "discussion_id"
|
290
299
|
t.boolean "approved", default: false
|
300
|
+
t.boolean "not_actually_a_question", default: false
|
291
301
|
end
|
292
302
|
|
293
303
|
create_table "organizations", id: :serial, force: :cascade do |t|
|
@@ -299,6 +309,7 @@ ActiveRecord::Schema.define(version: 20200608132959) do
|
|
299
309
|
t.text "theme", default: "{}", null: false
|
300
310
|
t.text "profile", default: "{}", null: false
|
301
311
|
t.integer "progressive_display_lookahead"
|
312
|
+
t.boolean "incognito_mode_enabled"
|
302
313
|
t.index ["book_id"], name: "index_organizations_on_book_id"
|
303
314
|
t.index ["name"], name: "index_organizations_on_name", unique: true
|
304
315
|
end
|
@@ -375,6 +386,7 @@ ActiveRecord::Schema.define(version: 20200608132959) do
|
|
375
386
|
t.string "verified_last_name"
|
376
387
|
t.bigint "avatar_id"
|
377
388
|
t.datetime "disabled_at"
|
389
|
+
t.boolean "trusted_for_forum"
|
378
390
|
t.index ["disabled_at"], name: "index_users_on_disabled_at"
|
379
391
|
t.index ["last_organization_id"], name: "index_users_on_last_organization_id"
|
380
392
|
t.index ["uid"], name: "index_users_on_uid", unique: true
|
@@ -50,4 +50,21 @@ feature 'Chapters flow', organization_workspace: :test do
|
|
50
50
|
expect(page).to have_text('endofunctors')
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
context 'incognito user' do
|
55
|
+
before { Organization.current.update! incognito_mode_enabled: true }
|
56
|
+
scenario 'show chapter, no appendix' do
|
57
|
+
visit "/chapters/#{chapter.id}"
|
58
|
+
|
59
|
+
expect(page).to have_text('Functional Programming')
|
60
|
+
expect(page).to have_text('The Basic Values')
|
61
|
+
|
62
|
+
expect(page).to have_text('Monads and Functors')
|
63
|
+
expect(page).to have_text('The Maybe Functor')
|
64
|
+
|
65
|
+
expect(page).to_not have_text('Appendix')
|
66
|
+
|
67
|
+
expect(page).to have_text('Sign in')
|
68
|
+
end
|
69
|
+
end
|
53
70
|
end
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Discussion Flow', organization_workspace: :test do
|
4
|
+
|
5
|
+
## =============
|
6
|
+
## Users
|
7
|
+
## =============
|
8
|
+
|
9
|
+
let(:student) { create(:user, permissions: {student: 'test/*:other/*:empty/*'}) }
|
10
|
+
let(:another_student) { create(:user, permissions: {student: 'test/*:other/*:empty/*'}) }
|
11
|
+
let(:moderator) { create(:user, permissions: {moderator: 'test/*:other/*:empty/*', student: 'test/*:other/*:empty/*'}) }
|
12
|
+
|
13
|
+
## =================
|
14
|
+
## Organizations
|
15
|
+
## =================
|
16
|
+
|
17
|
+
let(:test_organization) { Organization.locate! 'test' }
|
18
|
+
let(:other_organization) { create(:organization, name: 'other') }
|
19
|
+
let!(:empty_organization) { create(:organization, name: 'empty') }
|
20
|
+
|
21
|
+
## ================================
|
22
|
+
## Content for test_organization
|
23
|
+
## ================================
|
24
|
+
|
25
|
+
let(:problem_1) { create(:problem) }
|
26
|
+
let(:problem_2) { create(:problem) }
|
27
|
+
let(:problem_3) { create(:problem) }
|
28
|
+
|
29
|
+
let!(:chapter) {
|
30
|
+
create(:chapter, lessons: [create(:lesson, exercises: [ problem_1, problem_2, problem_3])])
|
31
|
+
}
|
32
|
+
|
33
|
+
## =====================================
|
34
|
+
## Discussions for test_organization
|
35
|
+
## =====================================
|
36
|
+
|
37
|
+
let(:problem_2_discussions) { create_list(:discussion, 5, initiator: another_student, item: problem_2, organization: test_organization) }
|
38
|
+
let(:problem_3_discussions) { create_list(:discussion, 5, initiator: student, item: problem_2, organization: test_organization) }
|
39
|
+
let!(:test_organization_discussions) { problem_2_discussions + problem_3_discussions }
|
40
|
+
|
41
|
+
## ===================================
|
42
|
+
## Content for other_organization
|
43
|
+
## ===================================
|
44
|
+
|
45
|
+
let(:other_problem) { create(:problem) }
|
46
|
+
let!(:other_chapter) {
|
47
|
+
create(:chapter, book: other_organization.book, lessons: [create(:lesson, exercises: [other_problem])])
|
48
|
+
}
|
49
|
+
|
50
|
+
## =====================================
|
51
|
+
## Discussions for other_organization
|
52
|
+
## =====================================
|
53
|
+
|
54
|
+
let(:other_problem_discussions) { create_list(:discussion, 5, initiator: student, item: problem_2, organization: other_organization) }
|
55
|
+
let!(:other_organization_discussions) { other_problem_discussions }
|
56
|
+
|
57
|
+
before { reindex_current_organization! }
|
58
|
+
before { reindex_organization! other_organization }
|
59
|
+
before { reindex_organization! empty_organization }
|
60
|
+
|
61
|
+
shared_examples 'no forum access' do
|
62
|
+
scenario 'has no forum access' do
|
63
|
+
visit current_path
|
64
|
+
expect(page).to have_text('You may have mistyped the address or the page may have moved')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'exercise discussions' do
|
69
|
+
let(:current_path) { "/exercises/#{problem_1.id}/discussions" }
|
70
|
+
|
71
|
+
context 'with no current user' do
|
72
|
+
it_behaves_like 'no forum access'
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with logged user' do
|
76
|
+
before { set_current_user! student }
|
77
|
+
|
78
|
+
context 'but no forum enabled' do
|
79
|
+
it_behaves_like 'no forum access'
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'and forum enabled' do
|
83
|
+
before { Organization.current.update! forum_enabled: true }
|
84
|
+
|
85
|
+
scenario 'empty discussion list for problem 1' do
|
86
|
+
visit "/exercises/#{problem_1.id}/discussions"
|
87
|
+
expect(page).to have_text(problem_1.name)
|
88
|
+
expect(page).to have_text('It seems there isn\'t any question yet.')
|
89
|
+
end
|
90
|
+
|
91
|
+
scenario 'discussion list for problem 2' do
|
92
|
+
visit "/exercises/#{problem_2.id}/discussions"
|
93
|
+
expect(page).to have_text(problem_2.name)
|
94
|
+
problem_2_discussions.each do |discussion|
|
95
|
+
expect(page).to have_text(discussion.description)
|
96
|
+
end
|
97
|
+
expect(page).to have_text('Didn\'t find what you were looking for?')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'book discussions' do
|
104
|
+
let(:current_path) { '/discussions' }
|
105
|
+
|
106
|
+
context 'with no current user' do
|
107
|
+
it_behaves_like 'no forum access'
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'with logged user' do
|
111
|
+
before { set_current_user! student }
|
112
|
+
|
113
|
+
context 'but no forum enabled' do
|
114
|
+
it_behaves_like 'no forum access'
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'and forum enabled' do
|
118
|
+
before { Organization.current.update! forum_enabled: true }
|
119
|
+
|
120
|
+
context 'in empty organization' do
|
121
|
+
before { empty_organization.update! forum_enabled: true }
|
122
|
+
before { set_subdomain_host! 'empty' }
|
123
|
+
after { set_subdomain_host! 'test' }
|
124
|
+
|
125
|
+
scenario 'empty discussion list for book without discussions' do
|
126
|
+
visit current_path
|
127
|
+
expect(page).to have_text(empty_organization.book.name)
|
128
|
+
expect(page).to have_text('It seems there isn\'t any question yet.')
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
scenario 'discussion list for book with discussions' do
|
134
|
+
visit current_path
|
135
|
+
expect(page).to have_text(test_organization.book.name)
|
136
|
+
test_organization_discussions.each do |discussion|
|
137
|
+
expect(page).to have_text(discussion.description)
|
138
|
+
end
|
139
|
+
other_organization_discussions.each do |discussion|
|
140
|
+
expect(page).not_to have_text(discussion.description)
|
141
|
+
end
|
142
|
+
expect(page).not_to have_text('Didn\'t find what you were looking for?')
|
143
|
+
expect(page).not_to have_text('It seems there isn\'t any question yet.')
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context 'exercise discussion' do
|
150
|
+
let(:current_path) { "/exercises/#{problem_2.id}/discussions/#{problem_2_discussions.first.id}" }
|
151
|
+
before { test_organization.switch! }
|
152
|
+
|
153
|
+
context 'with no current user' do
|
154
|
+
it_behaves_like 'no forum access'
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'with logged student' do
|
158
|
+
before { set_current_user! student }
|
159
|
+
|
160
|
+
context 'but no forum enabled' do
|
161
|
+
it_behaves_like 'no forum access'
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'and forum enabled' do
|
165
|
+
before { Organization.current.update! forum_enabled: true }
|
166
|
+
|
167
|
+
scenario 'newly created discussion' do
|
168
|
+
visit current_path
|
169
|
+
expect(page).to have_text(problem_2.name)
|
170
|
+
expect(page).to have_text('Open')
|
171
|
+
expect(page).to have_text('Messages')
|
172
|
+
expect(page).not_to have_xpath("//div[@class='discussion-actions']")
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'for moderator' do
|
176
|
+
before { set_current_user! moderator }
|
177
|
+
|
178
|
+
scenario 'newly created discussion' do
|
179
|
+
visit current_path
|
180
|
+
expect(page).to have_text(problem_2.name)
|
181
|
+
expect(page).to have_text('Open')
|
182
|
+
expect(page).to have_text('Messages')
|
183
|
+
expect(page).to have_xpath("//div[@class='discussion-actions']")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
@@ -13,11 +13,11 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
13
13
|
let(:problem_5) { build(:problem, name: 'Succ5', description: 'Description of Succ5', layout: :input_right, editor: :upload, hint: 'lele', language: gobstones) }
|
14
14
|
let(:problem_6) { build(:problem, name: 'Succ6', description: 'Description of Succ6', layout: :input_right, editor: :hidden, language: haskell) }
|
15
15
|
let(:problem_7) { build(:problem, name: 'Succ7', description: 'Description of Succ7', editor: :single_choice, choices: [{value: 'some choice', checked: true}]) }
|
16
|
-
let(:playground_1) { build(:playground, name: 'Succ5', description: 'Description of Succ4', layout: :
|
17
|
-
let(:playground_2) { build(:playground, name: 'Succ6', description: 'Description of Succ4', layout: :
|
16
|
+
let(:playground_1) { build(:playground, name: 'Succ5', description: 'Description of Succ4', layout: :input_bottom) }
|
17
|
+
let(:playground_2) { build(:playground, name: 'Succ6', description: 'Description of Succ4', layout: :input_bottom, extra: 'x = 4') }
|
18
18
|
let!(:reading) { build(:reading, name: 'Reading about Succ', description: 'Lets understand succ history') }
|
19
19
|
let!(:exercise_not_in_path) { create :exercise }
|
20
|
-
let(:kids_problem) { build(:problem, name: 'Kids prob', description: 'Description of kids prob', layout: :
|
20
|
+
let(:kids_problem) { build(:problem, name: 'Kids prob', description: 'Description of kids prob', layout: :input_primary, hint: 'lele', language: gobstones) }
|
21
21
|
|
22
22
|
let!(:chapter) {
|
23
23
|
create(:chapter, name: 'Functional Programming', lessons: [
|
@@ -129,6 +129,12 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
129
129
|
expect(page).to have_text('Solution')
|
130
130
|
expect(page).to have_text('need a hint?')
|
131
131
|
expect(page).to_not have_selector('.upload')
|
132
|
+
|
133
|
+
expect(page).to have_selector('#mu-exercise-id', )
|
134
|
+
expect(page).to have_selector('#mu-exercise-layout')
|
135
|
+
|
136
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_1.id.to_s)
|
137
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
132
138
|
end
|
133
139
|
|
134
140
|
scenario 'visit exercise by id, hidden layout, no hint, not queriable language' do
|
@@ -142,6 +148,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
142
148
|
expect(page).to_not have_text('Solution')
|
143
149
|
expect(page).to_not have_text('need a hint?')
|
144
150
|
expect(page).to_not have_selector('.upload')
|
151
|
+
|
152
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_2.id.to_s)
|
153
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
145
154
|
end
|
146
155
|
|
147
156
|
scenario 'visit exercise by id, hidden layout, no hint, queriable language' do
|
@@ -152,6 +161,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
152
161
|
expect(page).to_not have_text('Solution')
|
153
162
|
expect(page).to_not have_text('need a hint?')
|
154
163
|
expect(page).to_not have_selector('.upload')
|
164
|
+
|
165
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_6.id.to_s)
|
166
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
155
167
|
end
|
156
168
|
|
157
169
|
|
@@ -163,6 +175,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
163
175
|
expect(page).to have_text('Solution')
|
164
176
|
expect(page).to have_text('need a hint?')
|
165
177
|
expect(page).to have_selector('.upload')
|
178
|
+
|
179
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_3.id.to_s)
|
180
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
166
181
|
end
|
167
182
|
|
168
183
|
scenario 'visit exercise by id, upload layout, not queriable language' do
|
@@ -174,6 +189,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
174
189
|
expect(page).to have_selector('.upload')
|
175
190
|
expect(problem_5.language.extension).to eq('gbs')
|
176
191
|
expect(page.find("//div[@class = 'form-group']/input")['accept']).to eq(".gbs")
|
192
|
+
|
193
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_5.id.to_s)
|
194
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_right')
|
177
195
|
end
|
178
196
|
|
179
197
|
scenario 'visit exercise by id, input_bottom layout, extra, no hint' do
|
@@ -185,6 +203,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
185
203
|
expect(page).to have_text('Solution')
|
186
204
|
expect(page).to_not have_text('need a hint?')
|
187
205
|
expect(page).to_not have_selector('.upload')
|
206
|
+
|
207
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(problem_4.id.to_s)
|
208
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
188
209
|
end
|
189
210
|
|
190
211
|
scenario 'visit playground by id, no extra, no hint' do
|
@@ -195,6 +216,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
195
216
|
expect(page).to_not have_text('Solution')
|
196
217
|
expect(page).to_not have_text('need a hint?')
|
197
218
|
expect(page).to_not have_selector('.upload')
|
219
|
+
|
220
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(playground_1.id.to_s)
|
221
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
198
222
|
end
|
199
223
|
|
200
224
|
scenario 'visit playground by id, with extra, no hint' do
|
@@ -206,6 +230,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
206
230
|
expect(page).to_not have_text('need a hint?')
|
207
231
|
expect(page).to have_text('x = 4')
|
208
232
|
expect(page).to_not have_selector('.upload')
|
233
|
+
|
234
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(playground_2.id.to_s)
|
235
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
209
236
|
end
|
210
237
|
|
211
238
|
scenario 'visit inner reading by id' do
|
@@ -218,6 +245,9 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
218
245
|
expect(page).to_not have_text('Solution')
|
219
246
|
expect(page).to_not have_text('need a hint?')
|
220
247
|
expect(page).to_not have_selector('.upload')
|
248
|
+
|
249
|
+
expect(page.find("#mu-exercise-id")['value']).to eq(reading.id.to_s)
|
250
|
+
expect(page.find("#mu-exercise-layout")['value']).to eq('input_bottom')
|
221
251
|
end
|
222
252
|
|
223
253
|
scenario 'visit solved choices exercise' do
|
@@ -246,4 +276,19 @@ feature 'Exercise Flow', organization_workspace: :test do
|
|
246
276
|
expect(page).to have_xpath("//a[@title='Edit']")
|
247
277
|
end
|
248
278
|
end
|
279
|
+
|
280
|
+
context 'incognito user' do
|
281
|
+
before { Organization.current.update! incognito_mode_enabled: true }
|
282
|
+
|
283
|
+
scenario 'visit exercise transparently' do
|
284
|
+
visit "/exercises/#{problem_1.transparent_id}"
|
285
|
+
|
286
|
+
expect(page).to have_text('Succ1')
|
287
|
+
expect(page).to have_text('Console')
|
288
|
+
expect(page).to have_text('need a hint?')
|
289
|
+
expect(page).to have_text('Description of Succ1')
|
290
|
+
|
291
|
+
expect(page).to have_text('Sign in')
|
292
|
+
end
|
293
|
+
end
|
249
294
|
end
|