mumuki-laboratory 5.0.12 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +339 -0
  3. data/app/assets/javascripts/application/bridge.js +36 -7
  4. data/app/assets/javascripts/application/kids.js +92 -7
  5. data/app/assets/javascripts/application/submission.js +2 -1
  6. data/app/assets/stylesheets/application/modules/_highlight.scss +8 -0
  7. data/app/assets/stylesheets/application/modules/_kids.scss +92 -27
  8. data/app/controllers/api/base_controller.rb +23 -0
  9. data/app/controllers/api/courses_controller.rb +26 -0
  10. data/app/controllers/api/organizations_controller.rb +28 -0
  11. data/app/controllers/api/roles_controller.rb +47 -0
  12. data/app/controllers/api/students_controller.rb +9 -0
  13. data/app/controllers/api/teachers_controller.rb +9 -0
  14. data/app/controllers/api/users_controller.rb +18 -0
  15. data/app/controllers/assets_controller.rb +2 -1
  16. data/app/controllers/concerns/on_base_organization_only.rb +11 -0
  17. data/app/controllers/concerns/organizations_controller_template.rb +34 -0
  18. data/app/controllers/concerns/users_controller_template.rb +28 -0
  19. data/app/controllers/concerns/with_api_errors.rb +37 -0
  20. data/app/controllers/concerns/with_authorization.rb +19 -0
  21. data/app/controllers/concerns/with_errors_filter.rb +32 -0
  22. data/app/helpers/reset_button_helper.rb +1 -1
  23. data/app/models/api_client.rb +27 -0
  24. data/app/models/api_client_spec.rb +6 -0
  25. data/app/models/concerns/with_assignments.rb +4 -1
  26. data/app/models/course.rb +4 -6
  27. data/app/models/exercise/challenge.rb +5 -6
  28. data/app/models/language.rb +1 -1
  29. data/app/models/organization.rb +4 -0
  30. data/app/models/user.rb +22 -1
  31. data/app/views/exercise_solutions/_kids_results_button.html.erb +11 -0
  32. data/app/views/exercise_solutions/_results.html.erb +1 -7
  33. data/app/views/exercise_solutions/_results_button.html.erb +7 -0
  34. data/app/views/layouts/_kids.html.erb +5 -2
  35. data/app/views/layouts/exercise_inputs/editors/_custom.html.erb +1 -0
  36. data/app/views/layouts/exercise_inputs/forms/_kids_form.html.erb +3 -0
  37. data/app/views/layouts/exercise_inputs/layouts/_input_kids.html.erb +3 -3
  38. data/app/views/layouts/modals/_kids_context.html.erb +0 -3
  39. data/app/views/layouts/modals/_kids_results.html.erb +2 -0
  40. data/config/routes.rb +23 -0
  41. data/db/migrate/20180129142749_add_api_client.rb +11 -0
  42. data/lib/mumuki/laboratory/controllers/results_rendering.rb +7 -1
  43. data/lib/mumuki/laboratory/extensions/string.rb +8 -0
  44. data/lib/mumuki/laboratory/locales/en.yml +4 -0
  45. data/lib/mumuki/laboratory/locales/es.yml +4 -0
  46. data/lib/mumuki/laboratory/locales/pt.yml +4 -0
  47. data/lib/mumuki/laboratory/mumukit/auth.rb +7 -0
  48. data/lib/mumuki/laboratory/version.rb +1 -1
  49. data/public/amarillo_exito.svg +11 -0
  50. data/public/amarillo_fracaso.svg +5 -0
  51. data/public/compass_rose.svg +1417 -0
  52. data/spec/controllers/api_clients_controller.rb +26 -0
  53. data/spec/controllers/confirmations_controller_spec.rb +1 -1
  54. data/spec/controllers/courses_api_controller_spec.rb +28 -0
  55. data/spec/controllers/exercise_solutions_controller_spec.rb +1 -1
  56. data/spec/controllers/messages_controller_spec.rb +1 -1
  57. data/spec/controllers/organizations_api_controller_spec.rb +235 -0
  58. data/spec/controllers/students_api_controller_spec.rb +101 -0
  59. data/spec/controllers/users_api_controller_spec.rb +56 -0
  60. data/spec/dummy/db/schema.rb +9 -0
  61. data/spec/factories/api_client_factory.rb +18 -0
  62. data/spec/factories/course_factory.rb +9 -0
  63. data/spec/features/chapter_spec.rb +1 -1
  64. data/spec/features/complements_flow_spec.rb +1 -1
  65. data/spec/features/exams_flow_spec.rb +1 -1
  66. data/spec/features/exercise_flow_spec.rb +1 -1
  67. data/spec/features/guide_reset_spec.rb +1 -1
  68. data/spec/features/guides_flow_spec.rb +1 -1
  69. data/spec/features/home_public_flow_spec.rb +1 -1
  70. data/spec/features/lessons_flow_spec.rb +1 -1
  71. data/spec/features/links_flow_spec.rb +1 -1
  72. data/spec/features/login_flow_spec.rb +1 -1
  73. data/spec/features/profile_flow_spec.rb +1 -1
  74. data/spec/features/standard_flow_spec.rb +1 -1
  75. data/spec/helpers/application_helper_spec.rb +1 -1
  76. data/spec/helpers/email_helper_spec.rb +1 -1
  77. data/spec/helpers/exercise_input_helper_spec.rb +1 -1
  78. data/spec/helpers/with_breadcrumbs_spec.rb +1 -1
  79. data/spec/helpers/with_navigation_spec.rb +1 -1
  80. data/spec/models/assignment_spec.rb +1 -1
  81. data/spec/models/book_import_spec.rb +1 -1
  82. data/spec/models/book_spec.rb +1 -1
  83. data/spec/models/course_spec.rb +1 -1
  84. data/spec/models/event_generation_spec.rb +1 -1
  85. data/spec/models/exam_spec.rb +1 -1
  86. data/spec/models/exercise_spec.rb +11 -3
  87. data/spec/models/guide_spec.rb +1 -1
  88. data/spec/models/interactive_spec.rb +1 -1
  89. data/spec/models/lesson_spec.rb +1 -1
  90. data/spec/models/message_spec.rb +1 -1
  91. data/spec/models/navigation_spec.rb +1 -1
  92. data/spec/models/organization_spec.rb +1 -1
  93. data/spec/models/problem_spec.rb +1 -1
  94. data/spec/models/question_spec.rb +1 -1
  95. data/spec/models/reading_spec.rb +1 -1
  96. data/spec/models/solution_spec.rb +1 -1
  97. data/spec/models/usage_spec.rb +1 -1
  98. data/spec/models/user_changed_spec.rb +1 -1
  99. data/spec/models/user_spec.rb +5 -5
  100. data/spec/spec_helper.rb +19 -3
  101. metadata +37 -2
@@ -15,6 +15,15 @@ ActiveRecord::Schema.define(version: 20180402015405) do
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
17
17
 
18
+ create_table "api_clients", force: :cascade do |t|
19
+ t.string "description"
20
+ t.string "token"
21
+ t.bigint "user_id"
22
+ t.datetime "created_at", null: false
23
+ t.datetime "updated_at", null: false
24
+ t.index ["user_id"], name: "index_api_clients_on_user_id"
25
+ end
26
+
18
27
  create_table "assignments", id: :serial, force: :cascade do |t|
19
28
  t.text "solution"
20
29
  t.integer "exercise_id"
@@ -0,0 +1,18 @@
1
+ FactoryBot.define do
2
+ factory :api_client do |t|
3
+ transient do
4
+ role :janitor
5
+ grant 'test/*'
6
+ end
7
+
8
+ description "foo"
9
+ user {
10
+ create :user,
11
+ first_name: 'foo',
12
+ last_name: 'bar',
13
+ email: 'foo+1@bar.com',
14
+ uid: 'foo+1@bar.com',
15
+ permissions: { role => grant }
16
+ }
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ FactoryBot.define do
2
+ factory :course do
3
+ period '2016'
4
+ shifts %w(morning)
5
+ days %w(monday wednesday)
6
+ description 'test'
7
+ organization_id 1
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Chapters flow' do
3
+ feature 'Chapters flow', organization_workspace: :test do
4
4
  let(:haskell) { create(:haskell) }
5
5
 
6
6
  let!(:chapter) {
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Complements Flow' do
3
+ feature 'Complements Flow', organization_workspace: :test do
4
4
  let(:complement_not_in_path) { create(:complement) }
5
5
 
6
6
  before { reindex_current_organization! }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Exams Flow' do
3
+ feature 'Exams Flow', organization_workspace: :test do
4
4
  let(:exam) { create(:exam, classroom_id: '12345') }
5
5
  let(:other_exam) { create(:exam, organization: other_organization) }
6
6
  let!(:exam_not_in_path) { create :exam }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Exercise Flow' do
3
+ feature 'Exercise Flow', organization_workspace: :test do
4
4
  let(:user) { create(:user) }
5
5
 
6
6
  let(:haskell) { create(:haskell) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Exercise Flow' do
3
+ feature 'Exercise Flow', organization_workspace: :test do
4
4
  let(:user) { create(:user) }
5
5
 
6
6
  let!(:problem) { build(:problem)}
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Guides Flow' do
3
+ feature 'Guides Flow', organization_workspace: :test do
4
4
  let(:haskell) { create(:haskell) }
5
5
  let!(:exercises) { [
6
6
  create(:exercise, name: 'Foo', guide: guide, number: 1, description: 'Description of foo'),
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'public org' do
3
+ feature 'public org', organization_workspace: :test do
4
4
  let!(:exercise) { build(:exercise) }
5
5
  let(:guide) { create(:guide) }
6
6
  let(:exam) { create(:exam) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Lessons Flow' do
3
+ feature 'Lessons Flow', organization_workspace: :test do
4
4
  let(:lesson_not_in_path) { create(:lesson) }
5
5
 
6
6
  before { reindex_current_organization! }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Lessons Flow' do
3
+ feature 'Lessons Flow', organization_workspace: :test do
4
4
  let(:exercise) { create(:exercise, name: 'E1') }
5
5
  let!(:complement) { create(:complement) }
6
6
  let!(:lesson) { create(:lesson, name: 'L1', exercises: [exercise]) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Login Flow' do
3
+ feature 'Login Flow', organization_workspace: :test do
4
4
  let!(:chapter) do
5
5
  create(:chapter, name: 'C1', lessons: [
6
6
  create(:lesson, language: create(:language), name: 'awesomeRubyGuide', description: 'rubist baz guide', exercises: [
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Standard Flow' do
3
+ feature 'Standard Flow', organization_workspace: :test do
4
4
  let!(:user) { create(:user, uid: 'mumuki@test.com', first_name: nil) }
5
5
  let!(:user2) { create(:user, uid: 'johndoe@test.com') }
6
6
  let(:haskell) { create(:haskell) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- feature 'Standard Flow' do
3
+ feature 'Standard Flow', organization_workspace: :test do
4
4
  let(:haskell) { create(:haskell) }
5
5
 
6
6
  let!(:chapter) {
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ApplicationHelper do
3
+ describe ApplicationHelper, organization_workspace: :test do
4
4
  helper ApplicationHelper
5
5
  helper LinksHelper
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe EmailHelper do
3
+ describe EmailHelper, organization_workspace: :test do
4
4
  helper EmailHelper
5
5
 
6
6
  before { I18n.locale = :en }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ApplicationHelper do
3
+ describe ApplicationHelper, organization_workspace: :test do
4
4
  helper ExerciseInputHelper
5
5
 
6
6
  describe 'should_render_message_input?' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe BreadcrumbsHelper do
3
+ describe BreadcrumbsHelper, organization_workspace: :test do
4
4
 
5
5
  helper BreadcrumbsHelper
6
6
  helper LinksHelper
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe WithStudentPathNavigation do
3
+ describe WithStudentPathNavigation, organization_workspace: :test do
4
4
  helper WithStudentPathNavigation
5
5
  helper FontAwesome::Rails::IconHelper
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Assignment do
3
+ describe Assignment, organization_workspace: :test do
4
4
 
5
5
  describe 'messages' do
6
6
  let(:student) { create(:user) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Book do
3
+ describe Book, organization_workspace: :test do
4
4
  let!(:haskell) { create(:haskell) }
5
5
  let!(:gobstones) { create(:gobstones) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Book do
3
+ describe Book, organization_workspace: :test do
4
4
  let(:book) { Organization.current.book }
5
5
 
6
6
  describe '#next_lesson_for' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'CourseChanged' do
3
+ describe 'CourseChanged', organization_workspace: :test do
4
4
  let(:course_json) do
5
5
  {slug: 'test/bar',
6
6
  shifts: %w(morning),
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe '#as_platform_json' do
3
+ describe '#as_platform_json', organization_workspace: :test do
4
4
  describe Assignment do
5
5
  let(:user) {
6
6
  create(:user,
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Exam do
3
+ describe Exam, organization_workspace: :test do
4
4
  let(:user) { create(:user) }
5
5
  let(:other_user) { create(:user) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Exercise do
3
+ describe Exercise, organization_workspace: :test do
4
4
  let(:exercise) { create(:exercise) }
5
5
  let(:user) { create(:user) }
6
6
 
@@ -88,14 +88,22 @@ describe Exercise do
88
88
  it { expect(exercise_with_extra.extra).to eq "exercise extra code\n" }
89
89
  end
90
90
 
91
- context 'when exercise has extra code and belong to a guide with no extra code' do
91
+ context 'when exercise has extra code and belongs to a guide with no extra code' do
92
92
  let!(:exercise_with_extra) { create(:exercise, guide: guide, extra: 'exercise extra code') }
93
93
  let!(:guide) { create(:guide) }
94
94
 
95
95
  it { expect(exercise_with_extra.extra).to eq "exercise extra code\n" }
96
96
  end
97
97
 
98
- context 'when exercise has extra code and belong to a guide with extra code' do
98
+ context 'when exercise has extra code with trailing whitespaces
99
+ and belongs to a guide with no extra code' do
100
+ let!(:exercise_with_extra) { create(:exercise, guide: guide, extra: "\nexercise extra code \n") }
101
+ let!(:guide) { create(:guide) }
102
+
103
+ it { expect(exercise_with_extra.extra).to eq "exercise extra code\n" }
104
+ end
105
+
106
+ context 'when exercise has extra code and belongs to a guide with extra code' do
99
107
  let!(:exercise_with_extra) { create(:exercise, guide: guide, extra: 'exercise extra code') }
100
108
  let!(:guide) { create(:guide, extra: 'guide extra code') }
101
109
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Guide do
3
+ describe Guide, organization_workspace: :test do
4
4
  let!(:extra_user) { create(:user, first_name: 'Ignatius', last_name: 'Reilly') }
5
5
  let(:guide) { create(:guide) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Interactive do
3
+ describe Interactive, organization_workspace: :test do
4
4
  let!(:interactive) { create(:interactive) }
5
5
  let!(:user) { create(:user) }
6
6
  let(:assignment) { interactive.find_or_init_assignment_for(user) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Lesson do
3
+ describe Lesson, organization_workspace: :test do
4
4
  let(:user) { create(:user) }
5
5
  describe '#friendly' do
6
6
  let!(:chapter) {
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Message do
3
+ describe Message, organization_workspace: :test do
4
4
  describe '#parse_json' do
5
5
  let(:data) {
6
6
  {'exercise_id' => 1,
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'Navigation' do
3
+ describe 'Navigation', organization_workspace: :test do
4
4
  let(:organization_1) { create(:organization, name: 'org1', book: book_1) }
5
5
  let(:organization_2) { create(:organization, name: 'org2', book: book_2) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Organization do
3
+ describe Organization, organization_workspace: :test do
4
4
  let(:user) { create(:user) }
5
5
  let(:central) { create(:organization, name: 'central') }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Problem do
3
+ describe Problem, organization_workspace: :test do
4
4
 
5
5
  context 'when no manual evaluation and' do
6
6
  before { problem.manual_evaluation = false }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Query do
3
+ describe Query, organization_workspace: :test do
4
4
  let!(:exercise) { create(:problem) }
5
5
  let(:student) { create(:user) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Reading do
3
+ describe Reading, organization_workspace: :test do
4
4
  let!(:reading) { create(:reading) }
5
5
  let!(:user) { create(:user) }
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Solution do
3
+ describe Solution, organization_workspace: :test do
4
4
 
5
5
  describe '#run_tests!' do
6
6
  let(:user) { create(:user) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Usage, clean: true do
3
+ describe Usage do
4
4
 
5
5
  let!(:fundamentals) { create(:topic) }
6
6
  let!(:functional_programming) { create(:topic) }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe User do
3
+ describe User, organization_workspace: :test do
4
4
  let(:user) { User.find_by(uid: 'foo@bar.com') }
5
5
  let(:user_json) { {
6
6
  uid: 'foo@bar.com',
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe User do
3
+ describe User, organization_workspace: :test do
4
4
  describe '#clear_progress!' do
5
5
  let(:student) { create :user }
6
6
  let(:more_clauses) { create(:exercise, name: 'More Clauses') }
@@ -25,7 +25,7 @@ describe User do
25
25
  context 'when final user has less information than original' do
26
26
  let!(:submission) { your_first_program.submit_solution! original, content: 'adasdsadas' }
27
27
 
28
- before { original.reload.transfer_progress_to! final }
28
+ before { original.reload.copy_progress_to! final }
29
29
 
30
30
  let(:original) { create :user,
31
31
  permissions: {student: 'codeorga/*'},
@@ -54,7 +54,7 @@ describe User do
54
54
 
55
55
  context 'when final user has more information than original' do
56
56
  before { more_clauses.submit_solution! final, content: 'adasdsadas' }
57
- before { original.transfer_progress_to! final.reload }
57
+ before { original.copy_progress_to! final.reload }
58
58
 
59
59
  let(:original) { create :user,
60
60
  permissions: Mumukit::Auth::Permissions.new,
@@ -79,7 +79,7 @@ describe User do
79
79
  end
80
80
 
81
81
  context 'when both have information, but final is newer' do
82
- before { original.transfer_progress_to! final }
82
+ before { original.copy_progress_to! final }
83
83
 
84
84
  let(:original) { create :user,
85
85
  permissions: {student: 'codeorga/*'},
@@ -109,7 +109,7 @@ describe User do
109
109
  end
110
110
 
111
111
  context 'when both have information, but original is newer' do
112
- before { original.transfer_progress_to! final }
112
+ before { original.copy_progress_to! final }
113
113
 
114
114
  let(:original) { create :user,
115
115
  permissions: {student: 'codeorga/*'},