gnarus_exercise 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +7 -7
- data/app/assets/javascripts/gnarus_exercise/attempt.js +27 -0
- data/app/controllers/gnarus_exercise/attempts_controller.rb +6 -14
- data/app/controllers/gnarus_exercise/executions_controller.rb +14 -0
- data/app/models/activity_processor.rb +5 -0
- data/app/models/gnarus_exercise/attempt.rb +7 -4
- data/app/models/gnarus_exercise/execution.rb +6 -0
- data/app/views/gnarus_exercise/exercises/_my_fields.html.erb +0 -0
- data/config/initializers/gnarus_exercise.rb +1 -0
- data/config/routes.rb +3 -1
- data/db/migrate/20120405185533_create_gnarus_exercise_attempts.rb +1 -1
- data/db/migrate/20120408064126_create_gnarus_exercise_executions.rb +12 -0
- data/lib/gnarus_exercise/version.rb +1 -1
- data/test/fixtures/gnarus_exercise/executions.yml +11 -0
- data/test/unit/gnarus_exercise/execution_test.rb +9 -0
- metadata +57 -64
data/README.md
CHANGED
@@ -3,21 +3,21 @@ GnarusExercise
|
|
3
3
|
|
4
4
|
This project rocks and uses MIT-LICENSE.
|
5
5
|
|
6
|
-
Configuring a new project
|
7
|
-
|
6
|
+
Configuring a new project
|
7
|
+
=========================
|
8
8
|
|
9
9
|
```
|
10
10
|
rails new my_exercise -m https://raw.github.com/caelum/gnarus-exercise/master/template.rb
|
11
11
|
```
|
12
12
|
|
13
|
-
You will be prompted about
|
14
|
-
to you accept or not. The template will handle all
|
13
|
+
You will be prompted about adding <code>devise</code> into your application, then it is up
|
14
|
+
to you accept or not (if you want to auth your exercises). The template will handle all configuration required for you.
|
15
15
|
|
16
16
|
|
17
17
|
TODO
|
18
18
|
====
|
19
19
|
|
20
20
|
- update method UPDATE from exercise to be safe
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
21
|
+
- rename to gnarus-exercise
|
22
|
+
- we are using the index file to show an attempt, nasty. a GET to a better named method
|
23
|
+
- automatic reload from ActivityProcessor
|
@@ -0,0 +1,27 @@
|
|
1
|
+
var gnarus = {
|
2
|
+
attemptForm : function(solution, viewer, returnUri) {
|
3
|
+
|
4
|
+
var viewChanged = function(execution) {
|
5
|
+
viewer(execution);
|
6
|
+
if(execution.suceeded) {
|
7
|
+
var form = $('<form action=' + returnUri + '></form>');
|
8
|
+
var input = $('<input name="solution" />');
|
9
|
+
input.val(execution.solution);
|
10
|
+
form.insertAfter(input);
|
11
|
+
form.submit();
|
12
|
+
}
|
13
|
+
};
|
14
|
+
|
15
|
+
return {
|
16
|
+
process : function() {
|
17
|
+
var target = $('#exercise').attr('action');
|
18
|
+
$.post(target, solution(), function(r) {
|
19
|
+
viewChanged(r);
|
20
|
+
});
|
21
|
+
},
|
22
|
+
setup : function() {
|
23
|
+
$('#try').click(this.process);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
}
|
27
|
+
};
|
@@ -1,21 +1,13 @@
|
|
1
1
|
module GnarusExercise
|
2
|
-
class AttemptsController < ApplicationController
|
2
|
+
class AttemptsController < ApplicationController
|
3
3
|
|
4
|
-
|
4
|
+
skip_before_filter :verify_authenticity_token
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@attempt.
|
6
|
+
def index
|
7
|
+
exercise = Exercise.find(params[:exercise_id])
|
8
|
+
@attempt = exercise.attempts.create(params[:attempt])
|
9
|
+
@attempt.save
|
10
10
|
end
|
11
|
-
redirect_to @attempt.full_return_uri
|
12
|
-
end
|
13
11
|
|
14
|
-
def index
|
15
|
-
exercise = Exercise.find(params[:exercise_id])
|
16
|
-
@attempt = exercise.attempts.create(params[:attempt])
|
17
|
-
@attempt.save
|
18
12
|
end
|
19
|
-
|
20
|
-
end
|
21
13
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module GnarusExercise
|
2
|
+
class ExecutionsController < ApplicationController
|
3
|
+
|
4
|
+
skip_before_filter :verify_authenticity_token
|
5
|
+
|
6
|
+
def create
|
7
|
+
@attempt = Attempt.find params[:attempt_id]
|
8
|
+
execution = ::ActivityProcessor.process @attempt, params
|
9
|
+
execution.save
|
10
|
+
render :json => execution.to_json(:includes => :attempt)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
module GnarusExercise
|
2
2
|
class Attempt < ActiveRecord::Base
|
3
3
|
belongs_to :exercise
|
4
|
-
|
4
|
+
has_many :executions
|
5
|
+
attr_accessible :return_uri, :author_id
|
5
6
|
|
6
|
-
def not_finished
|
7
|
-
solution.nil?
|
8
|
-
end
|
9
7
|
def full_return_uri
|
10
8
|
(return_uri || "") + "?answer=" + (solution || "")
|
11
9
|
end
|
10
|
+
|
11
|
+
def process(params)
|
12
|
+
executions.create :solution => params[:solution], :suceeded => params[:suceeded]
|
13
|
+
end
|
14
|
+
|
12
15
|
end
|
13
16
|
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'activity_processor'
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateGnarusExerciseExecutions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :gnarus_exercise_executions do |t|
|
4
|
+
t.references :attempt
|
5
|
+
t.text :solution
|
6
|
+
t.boolean :suceeded
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
add_index :gnarus_exercise_executions, :attempt_id
|
11
|
+
end
|
12
|
+
end
|
metadata
CHANGED
@@ -1,80 +1,79 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnarus_exercise
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Guilherme Silveira
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: rails
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 2
|
33
|
-
- 2
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 3.2.2
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: sqlite3
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
25
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sqlite3
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
49
38
|
type: :development
|
50
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
51
46
|
description: Create external exercises by mounting this plugin.
|
52
|
-
email:
|
47
|
+
email:
|
53
48
|
- guilherme.silveira@caelum.com.br
|
54
49
|
executables: []
|
55
|
-
|
56
50
|
extensions: []
|
57
|
-
|
58
51
|
extra_rdoc_files: []
|
59
|
-
|
60
|
-
files:
|
52
|
+
files:
|
61
53
|
- app/assets/javascripts/gnarus_exercise/application.js
|
54
|
+
- app/assets/javascripts/gnarus_exercise/attempt.js
|
62
55
|
- app/assets/stylesheets/gnarus_exercise/application.css
|
63
56
|
- app/controllers/gnarus_exercise/application_controller.rb
|
64
57
|
- app/controllers/gnarus_exercise/attempts_controller.rb
|
58
|
+
- app/controllers/gnarus_exercise/executions_controller.rb
|
65
59
|
- app/controllers/gnarus_exercise/exercises_controller.rb
|
66
60
|
- app/helpers/gnarus_exercise/application_helper.rb
|
61
|
+
- app/models/activity_processor.rb
|
67
62
|
- app/models/gnarus_exercise/attempt.rb
|
63
|
+
- app/models/gnarus_exercise/execution.rb
|
68
64
|
- app/models/gnarus_exercise/exercise.rb
|
69
65
|
- app/views/gnarus_exercise/exercises/_form.html.erb
|
66
|
+
- app/views/gnarus_exercise/exercises/_my_fields.html.erb
|
70
67
|
- app/views/gnarus_exercise/exercises/edit.html.erb
|
71
68
|
- app/views/gnarus_exercise/exercises/index.html.erb
|
72
69
|
- app/views/gnarus_exercise/exercises/new.html.erb
|
73
70
|
- app/views/gnarus_exercise/exercises/show.html.erb
|
74
71
|
- app/views/layouts/gnarus_exercise/application.html.erb
|
72
|
+
- config/initializers/gnarus_exercise.rb
|
75
73
|
- config/routes.rb
|
76
74
|
- db/migrate/20120405185453_create_gnarus_exercise_exercises.rb
|
77
75
|
- db/migrate/20120405185533_create_gnarus_exercise_attempts.rb
|
76
|
+
- db/migrate/20120408064126_create_gnarus_exercise_executions.rb
|
78
77
|
- lib/gnarus_exercise/engine.rb
|
79
78
|
- lib/gnarus_exercise/version.rb
|
80
79
|
- lib/gnarus_exercise.rb
|
@@ -111,49 +110,41 @@ files:
|
|
111
110
|
- test/dummy/README.rdoc
|
112
111
|
- test/dummy/script/rails
|
113
112
|
- test/fixtures/gnarus_exercise/attempts.yml
|
113
|
+
- test/fixtures/gnarus_exercise/executions.yml
|
114
114
|
- test/fixtures/gnarus_exercise/exercises.yml
|
115
115
|
- test/fixtures/gnarus_exercise/users.yml
|
116
116
|
- test/gnarus_exercise_test.rb
|
117
117
|
- test/integration/navigation_test.rb
|
118
118
|
- test/test_helper.rb
|
119
119
|
- test/unit/gnarus_exercise/attempt_test.rb
|
120
|
+
- test/unit/gnarus_exercise/execution_test.rb
|
120
121
|
- test/unit/gnarus_exercise/exercise_test.rb
|
121
122
|
- test/unit/gnarus_exercise/user_test.rb
|
122
|
-
has_rdoc: true
|
123
123
|
homepage: http://online.caelum.com.br
|
124
124
|
licenses: []
|
125
|
-
|
126
125
|
post_install_message:
|
127
126
|
rdoc_options: []
|
128
|
-
|
129
|
-
require_paths:
|
127
|
+
require_paths:
|
130
128
|
- lib
|
131
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
130
|
none: false
|
133
|
-
requirements:
|
134
|
-
- -
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
|
137
|
-
|
138
|
-
- 0
|
139
|
-
version: "0"
|
140
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
136
|
none: false
|
142
|
-
requirements:
|
143
|
-
- -
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
|
146
|
-
segments:
|
147
|
-
- 0
|
148
|
-
version: "0"
|
137
|
+
requirements:
|
138
|
+
- - ! '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
149
141
|
requirements: []
|
150
|
-
|
151
142
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.
|
143
|
+
rubygems_version: 1.8.19
|
153
144
|
signing_key:
|
154
145
|
specification_version: 3
|
155
146
|
summary: A plugin structure for external exercises.
|
156
|
-
test_files:
|
147
|
+
test_files:
|
157
148
|
- test/dummy/app/assets/javascripts/application.js
|
158
149
|
- test/dummy/app/assets/stylesheets/application.css
|
159
150
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -183,11 +174,13 @@ test_files:
|
|
183
174
|
- test/dummy/README.rdoc
|
184
175
|
- test/dummy/script/rails
|
185
176
|
- test/fixtures/gnarus_exercise/attempts.yml
|
177
|
+
- test/fixtures/gnarus_exercise/executions.yml
|
186
178
|
- test/fixtures/gnarus_exercise/exercises.yml
|
187
179
|
- test/fixtures/gnarus_exercise/users.yml
|
188
180
|
- test/gnarus_exercise_test.rb
|
189
181
|
- test/integration/navigation_test.rb
|
190
182
|
- test/test_helper.rb
|
191
183
|
- test/unit/gnarus_exercise/attempt_test.rb
|
184
|
+
- test/unit/gnarus_exercise/execution_test.rb
|
192
185
|
- test/unit/gnarus_exercise/exercise_test.rb
|
193
186
|
- test/unit/gnarus_exercise/user_test.rb
|