questionable_surveys 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -2,36 +2,7 @@ require_dependency "questionable/application_controller"
|
|
2
2
|
|
3
3
|
module Questionable
|
4
4
|
class AnswersController < ApplicationController
|
5
|
-
respond_to :html, :js
|
6
|
-
|
7
5
|
def create
|
8
|
-
assignment = Assignment.find(params[:assignment_id])
|
9
|
-
|
10
|
-
a = Answer.new
|
11
|
-
a.assign_attributes({
|
12
|
-
assignment: assignment,
|
13
|
-
user: current_user,
|
14
|
-
option_id: params[:answer][:option_id],
|
15
|
-
message: (params[:answer][:message] || '')[0..255]
|
16
|
-
}, without_protection: true)
|
17
|
-
|
18
|
-
if a.save
|
19
|
-
respond_to do |format|
|
20
|
-
format.html { redirect_to :back }
|
21
|
-
format.js { render :text => 'Ok' }
|
22
|
-
end
|
23
|
-
else
|
24
|
-
respond_to do |format|
|
25
|
-
format.html do
|
26
|
-
flash[:info] = 'Error saving Answer'
|
27
|
-
redirect_to :back
|
28
|
-
end
|
29
|
-
format.js { render :text => 'Error' }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def create_multiple
|
35
6
|
answers = params[:answers]
|
36
7
|
|
37
8
|
if answers.is_a?(Hash)
|
@@ -49,7 +20,12 @@ module Questionable
|
|
49
20
|
date = answers.first
|
50
21
|
if date[:year].present? or date[:month].present? or date[:day].present?
|
51
22
|
if date[:year].present? and date[:month].present? and date[:day].present?
|
52
|
-
assignment.answers.
|
23
|
+
answer = assignment.answers.build(user_id: current_user.id, message: "#{date[:year]}-#{date[:month]}-#{date[:day]}")
|
24
|
+
if answer.date_answer.nil?
|
25
|
+
flash[:warn] = 'Could not save date. Invalid date.'
|
26
|
+
else
|
27
|
+
answer.save
|
28
|
+
end
|
53
29
|
else
|
54
30
|
flash[:warn] = 'Could not save date. You did not select all three fields.'
|
55
31
|
end
|
@@ -7,20 +7,12 @@ module Questionable
|
|
7
7
|
belongs_to :option
|
8
8
|
has_one :question, :through => :assignment
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
if subject.kind_of?(Symbol) or subject.kind_of?(String)
|
13
|
-
assignments = Questionable::Assignment.where(:subject_type => subject)
|
14
|
-
else
|
15
|
-
assignments = Questionable::Assignment.where(:subject_type => subject.class.to_s, :subject_id => subject.id)
|
16
|
-
end
|
10
|
+
def date_answer
|
11
|
+
return nil if message.nil?
|
17
12
|
|
18
|
-
|
19
|
-
|
13
|
+
self.message.to_date
|
14
|
+
rescue ArgumentError
|
15
|
+
nil
|
20
16
|
end
|
21
|
-
=end
|
22
|
-
|
23
|
-
# Questionable::Question.joins('INNER JOIN questionable_assignments ON questionable_assignments.question_id = questionable_questions.id').where(:questionable_assignments => { :subject_type => type }).order('questionable_assignments.position')
|
24
|
-
|
25
17
|
end
|
26
18
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
= form_tag questionable.
|
2
|
+
= form_tag questionable.answers_path, method: :post, class: 'questions-form' do
|
3
3
|
- assignments.each do |a|
|
4
4
|
.question-block{:id => "qa_#{a.id}", class: "question-#{a.question.id}"}
|
5
5
|
- q = a.question
|
@@ -43,7 +43,7 @@
|
|
43
43
|
=# select_date nil, field, order: [:month, :day, :year]
|
44
44
|
=# date_select (Date.today - 20.years), field, order: [:month, :day, :year]
|
45
45
|
|
46
|
-
- date = selected_answers.first.try(:
|
46
|
+
- date = selected_answers.first.try(:date_answer)
|
47
47
|
|
48
48
|
.date-fields
|
49
49
|
= select_month date, {prompt: date.blank?}, name: "#{field}[month]", class: 'select-month'
|
data/config/routes.rb
CHANGED
data/lib/questionable/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: questionable_surveys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
|
-
rubygems_version: 1.8.
|
189
|
+
rubygems_version: 1.8.25
|
190
190
|
signing_key:
|
191
191
|
specification_version: 3
|
192
192
|
summary: Rails engine that programatically generates surveys.
|