runtimerevolution / survey Goto Github PK
View Code? Open in Web Editor NEWSurvey is a Rails Engine that brings quizzes, surveys and contests into your Rails application.
License: MIT License
Survey is a Rails Engine that brings quizzes, surveys and contests into your Rails application.
License: MIT License
In app/models/survey/attempt at line 14 -- calling
attr_accessible :participant_id, :survey_id,
:answers_attributes, :survey, :winner, :participant
Does this need to be
def attempt_params
params.require(:attempt).permit(:participant_id, :survey_id,
:answers_attributes, :survey, :winner, :participant)
end
Sorry, bit of a noob at rails
It would be great to have an extra parameter to pass in with a question to require the user to select one or more check_box_tags
.
This will require a migration to the Question model in the most basic implementation.
The word successfully is spelled successfull
Currently reads:
surveys_controller:
create: Your Survey has been successfull created
update: Your Survey has been successfull updated
Should be fixed to read:
surveys_controller:
create: Your Survey has been successfully created
update: Your Survey has been successfully updated
Simplify current mechanism to generate form views. Support for simple_form or formtastic might be needed.
Update the active admin file (notice the comments in the code).
here is my example:
ActiveAdmin.register Survey::Survey do
permit_params :name, :attempts_number, :description, :finished, :active #mandatory for rails 4 and newer versions of active admin
menu :label => I18n.t("surveys")
filter :name,
:as => :select,
:collection => proc {
Survey::Survey.select("distinct(name)").collect { |c|
[c.name, c.name]
}
}
filter :active #,
#:as => :select,
#:collection => ["true", "false"]
# no needed activeadmin detects a boolean as yes or not automatically
filter :created_at
index do
column :name
column :description
column :active
column :attempts_number
column :finished
column :created_at
actions #default_actions
end
form do |f|
f.inputs I18n.t("survey_details") do
f.input :name
f.input :description
f.input :active #, :as => :select, :collection => ["true", "false"] no needed activeadmin detects a boolean input as checkbox
f.input :attempts_number
end
f.inputs I18n.t("questions") do
f.has_many :questions do |q|
q.input :text
q.has_many :options do |a|
a.input :text
a.input :correct
end
end
end
f.actions #buttons
end
end
There is another thing, the questions are not saving correctly, you can create a survey but when you save it, the questions were not saved, or when you try to save the survey a validation says " Survey without questions cannot be activated" in the active field and the questions that you've made, disappeared
I'm using active admin 1.0.0 pre 4
Rails 4.2.6
Ruby 2.20
the gsurvey gem "survey", "~> 0.1"
undefined method `link_to_function' for #<#Class:0x007ff02f4b5470:0x007ff02f4ad900>
Rails 4:
Rails generate survey plain is not creating the necessary routes. Rails generate survey routes did not do it either. I had to manually add it to make it work.
do you support mongoid in this gem?
I used "rails generate survey active_admin", but routes are not generated nor controllers.
Ps: Activeadmin gem is already installed
Hey guys,
I was wondering if it's possible to use the survey without binding it to a specific user. For example if I want to ask a visitor a question but he doesn't have an account yet.
Cezar
Hello!
Using this gem, is it possible to create non-multiple choice questions (ie, just a text area for users to write things)? Or do all the questions have to be multiple choice?
Thanks!
Hi would be great add support for show/hide questions depending of previous answer.
getting error when trying to bundle install
on windows env:
Unable to create file rdoc/<.html (Invalid argument) when running bundle install with gem 'survey'
Hi
Migrating to CreateSurvey (20140903155504)
(0.1ms) BEGIN
== 20140903155504 CreateSurvey: migrating =====================================
-- create_table(:survey_surveys)
(19.5ms) CREATE TABLE "survey_surveys" ("id" serial primary key, "name" character varying(255), "description" text, "attempts_number" integer DEFAULT 0, "finished" boolean DEFAULT 'f', "active" boolean DEFAULT 'f', "created_at" timestamp, "updated_at" timestamp)
-> 0.0232s
-- create_table(:survey_questions)
(1.5ms) SELECT f.conname, pg_get_constraintdef(f.oid), t.relname
FROM pg_class t, pg_constraint f
WHERE f.conrelid = t.oid
AND f.contype = 'f'
AND t.relname = 'survey_questions'
AND t.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname = ANY (current_schemas(false)) )
(13.8ms) CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id"))
PG::UndefinedTable: ERROR: relation "surveys" does not exist
: CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id"))
(0.2ms) ROLLBACK
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "surveys" does not exist
: CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id")) /home/empire/rails4-starterkit/db/migrate/20140903155504_create_survey.rb:15:in up' ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "surveys" does not exist : CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id")) /home/empire/rails4-starterkit/db/migrate/20140903155504_create_survey.rb:15:in
up'
PG::UndefinedTable: ERROR: relation "surveys" does not exist
/home/empire/rails4-starterkit/db/migrate/20140903155504_create_survey.rb:15:in `up'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Seems odd, any suggestions?
@Survey should be pluralized according to views
def index
@survey = Survey::Survey.all
end
Using your namespaced scaffold-generation:
rails g survey plain namespace:tools
results in _form-partial:
undefined method `tools_survey_survey_path' for #<#Class:0x8e21ae8:0x66743a0>
I don't know this *_scope-methods used there. Is this rails-stuff oder something defined by you ? <%= form_for survey_scope(@Survey) do |f| %>
In general: Editing surveys does not persist changes if I add new options or questions.
Nothing really dramatically ... they are just scaffolds. I can write them myself.
hi guyz i am new in ror and i creating a quiz app which is cient project i want one question on one page how can i achieve this if anybudy knows plz help me
thanks
Hi ,
Please suggest the solution for Db migration error.
PG::UndefinedTable: ERROR: relation "surveys" does not exist
: CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id")) /home/test/db/migrate/20150515142125_create_survey.rb:15:in up' ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "surveys" does not exist : CREATE TABLE "survey_questions" ("id" serial primary key, "survey_id" integer, "text" character varying(255), "created_at" timestamp, "updated_at" timestamp, CONSTRAINT fk_survey_questions_survey_id FOREIGN KEY ("survey_id") REFERENCES "surveys" ("id")) /home/test/db/migrate/20150515142125_create_survey.rb:15:in
up'
PG::UndefinedTable: ERROR: relation "surveys" does not exist
/home/test/db/migrate/20150515142125_create_survey.rb:15:in `up'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Thank you !
hi guyz i am new in ror and i creating a quiz app which is cient project i want one question on one page how can i achieve this if anybudy knows plz help me
thanks
jass
We are not generating routes for example controllers. It makes sense to add them to the default task in order to the generated controllers be capable to work out of the box.
Hello,
When I try to run the rails generate for RailsAdmin I'm getting this exception. I'm trying to add this to an existing site. Rails 4.2.2.
/.rbenv/versions/2.2.0-dev/lib/ruby/gems/2.3.0/gems/survey-0.2/lib/generators/survey/survey_generator.rb:87:in `get_scope': undefined method `split' for nil:NilClass (NoMethodError)
Thanks
Hi again, maybe I do something wrong but currently I can't get the form-partial running. I have a survey with two questions. The new-action in the AttemptsController prepares answers on attempts n-times for each question. However, this causes that all questions will be shown n-times because <%= f.fields_for :answers do |builder| %> renders the ul-tag n-times ?!
Issue 2: Each question has 5 options for answering, but only the last selected option will be in the params-hash. I have to change the checkbox like this:
<%= builder.check_box :option_id, {multiple: true}, option.id, nil %>
For what kind of use-case did you provided this form-partial? I think for my case I could never get this working or am I wrong ?
Models won't get added. I had read anywhere that using c.model is deprecated, but I'm not sure. However it does not work this way. They are using now whitelists and blacklists for specifying the included models via 'config.included_models'. You should recap a remove of this initializer cause it's confusing. By the way: nice gem !
Using the Contests controller example, I'm going to add a simple correction for the controller, because it throws an undefined method 'base_class'. I've solved it by adding this:
class ContestsController < ApplicationController
helper_method :survey, :participant
# create a new attempt to this survey
def new
@participant = current_user #notice this and the base_class error disappears
@attempt = survey.attempts.new
# build a number of possible answers equal to the number of options
survey.questions.size.times { @attempt.answers.build }
end
# create a new attempt in this survey
# an attempt needs to have a participant assigned
def create
@attempt = survey.attempts.new(params[:attempt])
# ensure that current user is assigned with this attempt
@attempt.participant = participant
if @attempt.valid? and @attempt.save
redirect_to contests_path
else
render :action => :new
end
end
def participant
@participant ||= current_user
end
def survey
@survey ||= Survey::Survey.active.first
end
end
But as I said before the 'base_class' error disappears and throws another error in the form.
<%= form_for [:contests, @attempt] do |f| %> <!-- the error is this line it says 'undefined method for contest_survey_attemps_path' -->
<%= f.fields_for :answers do |builder| %>
<ul>
<% @survey.questions.each do |question| %>
<li>
<p><%= question.text %></p>
<%= builder.hidden_field :question_id, :value => question.id %>
<% question.options.each do |option| %>
<%= builder.check_box :option_id, {}, option.id, nil %>
<%= option.text %> <br/ >
<% end -%>
</li>
<% end -%>
</ul>
<% end -%>
<%= f.submit "Submit" %>
<% end -%>
I'm using Rails 4
Is there a easy way to Add free text answer field?
How you would attach a survey model to another model that acts as its parent?
Eg:
A lesson has a survey
The survey belongs to the lesson (or anything)
What is the reason to not support to Rails 5 in the latest version?https://github.com/runtimerevolution/survey/blob/master/survey.gemspec#L14
If there is no reason, shall we include it in the next release
Hey guys,
I was trying to create a survey at http://localhost:3000/contests/surveys/new and when I create the test I am running into a ActiveModel::ForbiddenAttributesError at /contests/surveys error and it is pointing to the first line in your Survey create. I can test my parms coming in and it looks ok to me so I am not sure what is going on.
FYI the parm incoming is
params[:survey_survey]
=> {"name"=>"test", "attempts_number"=>"100", "active"=>"true", "description"=>"testing", "questions_attributes"=>{"1389644195139"=>{"text"=>"q1", "options_attributes"=>{"1389644204233"=>{"text"=>"right", "correct"=>"1", "_destroy"=>"false"}, "1389644214822"=>{"text"=>"wrong", "correct"=>"0", "_destroy"=>"false"}}, "_destroy"=>"false"}}}
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.