Latest state
This commit is contained in:
parent
933e14673c
commit
ed087352e2
10 changed files with 119 additions and 45 deletions
|
|
@ -621,6 +621,3 @@ DEPENDENCIES
|
|||
web-console (~> 2.0)
|
||||
webmock
|
||||
whenever
|
||||
|
||||
BUNDLED WITH
|
||||
1.12.5
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
//= require waypoints/jquery.waypoints
|
||||
//= require dataTables/jquery.dataTables
|
||||
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
||||
//= require cocoon
|
||||
//= require bootstrap
|
||||
//= require Chart
|
||||
//= require osem
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
class SurveyController < ApplicationController
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource
|
||||
|
||||
def show
|
||||
@survey_submission = @survey.survey_submissions.new
|
||||
end
|
||||
|
||||
def reply
|
||||
end
|
||||
|
||||
end
|
||||
21
app/controllers/survey_submissions_controller.rb
Normal file
21
app/controllers/survey_submissions_controller.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
class SurveySubmissionsController < ApplicationController
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_resource :survey
|
||||
load_and_authorize_resource
|
||||
# skip_before_filter :verify_authenticity_token
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
end
|
||||
26
app/controllers/surveys_controller.rb
Normal file
26
app/controllers/surveys_controller.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
class SurveysController < ApplicationController
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource
|
||||
# skip_before_filter :verify_authenticity_token
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def show
|
||||
@survey_submission = @survey.survey_submissions.new
|
||||
end
|
||||
|
||||
def reply
|
||||
redirect_to :back
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%span.badge
|
||||
= index
|
||||
= question_index
|
||||
= survey_question.title
|
||||
ID
|
||||
= survey_question.id
|
||||
|
||||
- if survey_question.multiple_choice?
|
||||
( Select
|
||||
- if survey_question.min_choices != survey_question.max_choices
|
||||
|
|
@ -21,22 +24,37 @@
|
|||
= link_to admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question), method: :delete, data: { confirm: 'Are you sure you want to delete this question?' } do
|
||||
%span.fa.fa-times
|
||||
.panel-body
|
||||
= f.semantic_fields_for :survey_reply do |reply, index|
|
||||
= reply.hidden_field :survey_question_id, value: survey_question.id
|
||||
- if survey_question.boolean?
|
||||
= reply.input :text, as: :radio, label: false
|
||||
- elsif survey_question.choice?
|
||||
- choice_type = survey_question.single_choice? ? :radio : :check_boxes
|
||||
= reply.input :text, as: choice_type, label: false, collection: survey_question.possible_answers.split(',').map(&:strip)
|
||||
- elsif survey_question.string?
|
||||
%input.form-control{ name: "survey_question_#{survey_question.id}" }
|
||||
- elsif survey_question.text?
|
||||
%textarea.form-control{ rows: 4, name: "survey_question_#{survey_question.id}" }
|
||||
- elsif survey_question.datetime?
|
||||
.form-group{ class: 'datetimepicker' }
|
||||
.input-group
|
||||
.input-group-addon
|
||||
%span.fa.fa-calendar
|
||||
%input.form-control{ readonly: 'readonly', name: "survey_question_#{survey_question.id}" }
|
||||
- elsif survey_question.numeric?
|
||||
%input.form-control{ type: 'number', name: "survey_question_#{survey_question.id}" }
|
||||
%input{ type: 'hidden', name: "survey_question_#{survey_question.id}", value: survey_question.id }
|
||||
|
||||
- if survey_question.boolean?
|
||||
%input{ type: 'radio', name: "survey_question_#{survey_question.id}_reply", value: 'Yes' }
|
||||
Yes
|
||||
%input{ type: 'radio', name: "survey_question_#{survey_question.id}_reply", value: 'No' }
|
||||
No
|
||||
|
||||
- elsif survey_question.choice?
|
||||
- possible_answers = survey_question.possible_answers.split(',').map(&:strip)
|
||||
|
||||
- possible_answers.each do |answer|
|
||||
- if survey_question.single_choice?
|
||||
%input{ type: 'radio', name: "survey_question_#{survey_question.id}_reply", value: answer }
|
||||
= label_tag answer
|
||||
%br
|
||||
- else
|
||||
= hidden_field_tag "survey_submission[survey_question_#{survey_question.id}][survey_reply_ids][]", nil
|
||||
= check_box_tag "survey_submission[survey_question_#{survey_question.id}][survey_reply_ids][]", possible_answers.index, false
|
||||
= answer
|
||||
%br
|
||||
- elsif survey_question.string?
|
||||
%input.form-control{ name: "survey_question_#{survey_question.id}" }
|
||||
- elsif survey_question.text?
|
||||
%textarea.form-control{ rows: 4, name: "survey_question_#{survey_question.id}" }
|
||||
- elsif survey_question.datetime?
|
||||
.form-group{ class: 'datetimepicker' }
|
||||
.input-group
|
||||
.input-group-addon
|
||||
%span.fa.fa-calendar
|
||||
%input.form-control{ readonly: 'readonly', name: "survey_question_#{survey_question.id}" }
|
||||
- elsif survey_question.numeric?
|
||||
%input.form-control{ type: 'number', name: "survey_question_#{survey_question.id}" }
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@
|
|||
= @survey.end_date
|
||||
.row
|
||||
.col-md-12
|
||||
- @survey.survey_questions.each.with_index(1) do |survey_question, index|
|
||||
.row
|
||||
.col-md-12
|
||||
= render partial: 'survey_question', locals: { survey_question: survey_question, index: index }
|
||||
= semantic_form_for 'survey_submission', url: '#' do |f|
|
||||
- @survey.survey_questions.each.with_index(1) do |survey_question, index|
|
||||
.row
|
||||
.col-md-12
|
||||
= render partial: 'survey_question', locals: { survey_question: survey_question, index: index, f: f }
|
||||
= link_to 'Add Question', new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), class: 'btn btn-success pull-right'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.col-md-10.col-md-offset-1
|
||||
.page-header
|
||||
%h1
|
||||
Survey #{@survey.title}
|
||||
|
|
@ -14,8 +14,9 @@
|
|||
.row
|
||||
.col-md-12
|
||||
= semantic_form_for @survey_submission, url: conference_survey_reply_path(@conference.short_title, @survey) do |f|
|
||||
- @survey.survey_questions.each.with_index(1) do |survey_question, index|
|
||||
- @survey.survey_questions.each.with_index(1) do |survey_question, question_index|
|
||||
.row
|
||||
.col-md-12
|
||||
= render partial: 'admin/surveys/survey_question', locals: { survey_question: survey_question, index: index, f: f }
|
||||
.col-md-10.col-md-offset-1
|
||||
|
||||
= render partial: 'admin/surveys/survey_question', locals: { survey_question: survey_question, question_index: question_index, f: f }
|
||||
= f.submit 'Submit', class: 'btn btn-primary pull-right'
|
||||
22
app/views/surveys/show.html.haml
Normal file
22
app/views/surveys/show.html.haml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
.row
|
||||
.col-md-10.col-md-offset-1
|
||||
.page-header
|
||||
%h1
|
||||
Survey #{@survey.title}
|
||||
- if can? :edit, @survey
|
||||
= link_to 'Edit Survey', admin_conference_survey_path(@conference.short_title, @survey), class: 'btn btn-primary pull-right'
|
||||
%p.text-muted
|
||||
From:
|
||||
= @survey.start_date
|
||||
to
|
||||
= @survey.end_date
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= semantic_form_for @survey_submission, url: conference_survey_reply_path(@conference.short_title, @survey) do |f|
|
||||
- @survey.survey_questions.each.with_index(1) do |survey_question|
|
||||
.row
|
||||
.col-md-10.col-md-offset-1
|
||||
= f.semantic_fields_for :survey_reply do |myreply, index|
|
||||
= render partial: 'admin/surveys/survey_question', locals: { survey_question: survey_question, index: index, myreply: myreply }
|
||||
= f.submit 'Submit', class: 'btn btn-primary pull-right'
|
||||
|
|
@ -96,7 +96,8 @@ Osem::Application.routes.draw do
|
|||
end
|
||||
|
||||
resources :conference, only: [:index, :show] do
|
||||
resources :survey, only: [:show] do
|
||||
resources :surveys, only: [:show] do
|
||||
resource :survey_submission
|
||||
post :reply
|
||||
end
|
||||
resource :program, only: [] do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue