Merge branch 'adding_surveys' of https://github.com/mdeniz/osem into mdeniz-adding_surveys
This commit is contained in:
commit
1991f53f26
40 changed files with 694 additions and 33 deletions
|
|
@ -0,0 +1,4 @@
|
|||
.nested-fields
|
||||
= f.inputs do
|
||||
= f.input :title
|
||||
= remove_association_link :answer, f
|
||||
92
app/views/admin/survey_questions/_form.html.haml
Normal file
92
app/views/admin/survey_questions/_form.html.haml
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
- if @survey_question.new_record?
|
||||
%h1
|
||||
New Survey Question
|
||||
- else
|
||||
%h1
|
||||
Edit Survey Question
|
||||
.text-muted
|
||||
= @survey_question.title
|
||||
|
||||
.col-md-6
|
||||
= semantic_form_for @survey_question, url: @url do |f|
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
= f.input :title
|
||||
= f.input :mandatory
|
||||
%div.survey-possible-answers{ class: @survey_question.choice? ? '' : 'hidden'}
|
||||
= f.input :possible_answers, hint: 'Comma separated', input_html: { rows: 3 }
|
||||
.row
|
||||
.col-md-6
|
||||
= f.input :min_choices
|
||||
.col-md-6
|
||||
= f.input :max_choices
|
||||
%hr
|
||||
.row
|
||||
.col-md-6
|
||||
%label{ required: 'required' }
|
||||
Type of Question:
|
||||
.form-group
|
||||
%select.selectpicker.form-control{ id: 'survey_question_kind', name: 'survey_question[kind]' }
|
||||
- SurveyQuestion.kinds.each do |kind|
|
||||
%option{ id: "#{kind.second}", 'data-icon' => "fa fa-#{SurveyQuestion::ICONS[kind.first.to_sym]}", selected: @survey_question.kind == kind.first }
|
||||
= kind.first
|
||||
.col-md-6
|
||||
%label
|
||||
Preview:
|
||||
.panel.panel-default
|
||||
.panel-body{id: 'survey_question_preview'}
|
||||
%p{id: 'title', style: 'word-wrap: break-word'}
|
||||
= @survey_question.title.blank? ? 'What is your answer?' : @survey_question.title
|
||||
|
||||
%div.kinds.boolean{ class: @survey_question.boolean? ? '' : 'hidden'}
|
||||
%input{type: 'radio', name: 'radio'} Yes
|
||||
%br
|
||||
%input{type: 'radio', name: 'radio'} No
|
||||
|
||||
%div.kinds.choice{ id: '', class: @survey_question.choice? ? '' : 'hidden'}
|
||||
- if @survey_question.possible_answers.blank?
|
||||
- if @survey_question.single_choice?
|
||||
%input{ type: 'radio', name: 'radio' } Choice 1
|
||||
%br
|
||||
%input{ type: 'radio', name: 'radio' } Choice 2
|
||||
%br
|
||||
%input{ type: 'radio', name: 'radio' } Choice 3
|
||||
- else
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 1
|
||||
%br
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 2
|
||||
%br
|
||||
%input{ type: 'checkbox', name: 'checkbox' } Choice 3
|
||||
- else
|
||||
- @survey_question.possible_answers.split(',').map(&:strip).each do |option|
|
||||
- if @survey_question.single_choice?
|
||||
%input{ type: 'radio', name: 'radio' }
|
||||
= option
|
||||
%br
|
||||
- else
|
||||
%input{ type: 'checkbox', name: 'checkbox' }
|
||||
= option
|
||||
%br
|
||||
|
||||
%div.kinds.string{ class: @survey_question.string? ? '' : 'hidden'}
|
||||
%input.form-control
|
||||
|
||||
%div.kinds.text{ class: @survey_question.text? ? '' : 'hidden'}
|
||||
%textarea.form-control{ rows: 4 }
|
||||
|
||||
|
||||
%div.kinds.datetime{ class: @survey_question.datetime? ? '' : 'hidden'}
|
||||
.form-group{class: 'datetimepicker'}
|
||||
.input-group
|
||||
.input-group-addon
|
||||
%span.fa.fa-calendar
|
||||
%input.form-control{readonly: 'readonly'}
|
||||
|
||||
%div.kinds.numeric{ class: @survey_question.numeric? ? '' : 'hidden'}
|
||||
%input.form-control{ type: 'number' }
|
||||
|
||||
= f.submit 'Save', class: 'btn btn-primary'
|
||||
27
app/views/admin/survey_questions/_questions.html.haml
Normal file
27
app/views/admin/survey_questions/_questions.html.haml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
%table.table.table-hover#questions
|
||||
%th Enabled
|
||||
%th Question
|
||||
%th Type
|
||||
%th Answers
|
||||
%th Actions
|
||||
- @questions.each do |q|
|
||||
%tr
|
||||
%td
|
||||
= hidden_field_tag "conference[question_ids][]", nil
|
||||
= check_box_tag "conference[question_ids][]", q.id,
|
||||
@conference.question_ids.include?(q.id), id: dom_id(q)
|
||||
%td
|
||||
= q.title
|
||||
%td
|
||||
= q.question_type.title
|
||||
%td
|
||||
= q.answers.map {|a| a.title}.join(', ')
|
||||
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Show', admin_conference_question_path(@conference.short_title, q), class: 'btn btn-success'
|
||||
= link_to 'Edit', edit_admin_conference_question_path(@conference.short_title, q),
|
||||
class: 'btn btn-primary', disabled: !(can? :update, q)
|
||||
= link_to 'Delete', admin_conference_question_path(@conference.short_title, q),
|
||||
method: :delete, remote: true, class: 'btn btn-danger',
|
||||
confirm: "Delete question '#{q.title}'?", disabled: !(can? :destroy, q)
|
||||
1
app/views/admin/survey_questions/destroy.js.erb
Normal file
1
app/views/admin/survey_questions/destroy.js.erb
Normal file
|
|
@ -0,0 +1 @@
|
|||
$('#myquestions').html("<%= escape_javascript(render :partial => 'questions') %>");
|
||||
1
app/views/admin/survey_questions/edit.html.haml
Normal file
1
app/views/admin/survey_questions/edit.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render partial: 'form'
|
||||
33
app/views/admin/survey_questions/index.html.haml
Normal file
33
app/views/admin/survey_questions/index.html.haml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
Questions for survey
|
||||
= link_to @survey.title, admin_conference_survey_path(@conference.short_title, @survey)
|
||||
= "(#{@survey_questions.length})"
|
||||
|
||||
- if @survey_questions.any?
|
||||
%table.table
|
||||
%thead
|
||||
%th
|
||||
%th Title
|
||||
%th Kind
|
||||
%th Possible Answers
|
||||
%th Mandatory
|
||||
%th Answers
|
||||
%th Actions
|
||||
%tbody
|
||||
- @survey_questions.each.with_index(1) do |survey_question, index|
|
||||
%tr
|
||||
%td= index
|
||||
%td= survey_question.title
|
||||
%td= survey_question.kind
|
||||
%td= survey_question.possible_answers
|
||||
%td= survey_question.mandatory
|
||||
%td
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question), class: 'btn btn-primary'
|
||||
= link_to 'Delete', 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?' }, class: 'btn btn-danger'
|
||||
|
||||
= link_to 'Add', new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), class: 'btn btn-success pull-right'
|
||||
26
app/views/admin/survey_questions/show.html.haml
Normal file
26
app/views/admin/survey_questions/show.html.haml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
.container
|
||||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1= @question.title
|
||||
- @question.answers.each do |answer|
|
||||
= answer.title
|
||||
(#{answer.qanswers.find_by(question: @question).registrations.where(conference: @conference).count})
|
||||
|
||||
|
||||
.row
|
||||
.col-md-12
|
||||
|
||||
%table.table.table-border.table-hover.datatable#question_users
|
||||
%thead
|
||||
%th Name
|
||||
%th Username
|
||||
%th Email
|
||||
%th Answer
|
||||
%tbody
|
||||
- @registrations.each do |registration|
|
||||
%tr
|
||||
%td= registration.name
|
||||
%td= registration.username
|
||||
%td= registration.email
|
||||
%td= registration.qanswers.find_by(question: @question).answer.title
|
||||
15
app/views/admin/surveys/_form.html.haml
Normal file
15
app/views/admin/surveys/_form.html.haml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1 New Survey
|
||||
|
||||
.col-md-6
|
||||
= semantic_form_for @survey, url: @url do |f|
|
||||
= f.hidden_field :surveyable_type
|
||||
= f.hidden_field :surveyable_id
|
||||
= f.input :title
|
||||
= f.input :description, input_html: { rows: 3 }
|
||||
= f.input :target, as: :select, collection: Survey.targets.keys, label: "When to ask"
|
||||
= f.input :start_date, as: :string, input_html: { class: 'datetimepicker' }
|
||||
= f.input :end_date, as: :string, input_html: { class: 'datetimepicker' }
|
||||
= f.submit 'Save', class: 'btn btn-primary'
|
||||
42
app/views/admin/surveys/_survey_question.html.haml
Normal file
42
app/views/admin/surveys/_survey_question.html.haml
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%span.badge
|
||||
= index
|
||||
= survey_question.title
|
||||
- if survey_question.multiple_choice?
|
||||
( Select
|
||||
- if survey_question.min_choices != survey_question.max_choices
|
||||
a minimum of
|
||||
= survey_question.min_choices
|
||||
- if survey_question.min_choices != survey_question.max_choices
|
||||
and a maximum of
|
||||
= survey_question.max_choices
|
||||
choices )
|
||||
- if survey_question.mandatory
|
||||
%span.fa.fa-asterisk.text-danger
|
||||
- if can? :edit, @survey
|
||||
%p.pull-right
|
||||
= link_to edit_admin_conference_survey_survey_question_path(@conference.short_title, @survey, survey_question) do
|
||||
%span.fa.fa-edit
|
||||
= 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}" }
|
||||
1
app/views/admin/surveys/edit.html.haml
Normal file
1
app/views/admin/surveys/edit.html.haml
Normal file
|
|
@ -0,0 +1 @@
|
|||
= render partial: 'form'
|
||||
38
app/views/admin/surveys/index.html.haml
Normal file
38
app/views/admin/surveys/index.html.haml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
Surveys
|
||||
= link_to 'New', new_admin_conference_survey_path(@conference.short_title, survey: { surveyable_type: 'Conference', surveyable_id: @conference.id }), class: 'btn btn-success pull-right'
|
||||
%p.text-muted
|
||||
Available surveys for this conference
|
||||
|
||||
|
||||
- if @surveys.any?
|
||||
.row
|
||||
.col-md-12
|
||||
%table.table.table-hover#surveys
|
||||
%thead
|
||||
%th Title
|
||||
%th When
|
||||
%th Start Date
|
||||
%th End Date
|
||||
%th Actions
|
||||
%tbody
|
||||
- @surveys.each_with_index do |survey, index|
|
||||
%tr
|
||||
%td
|
||||
= link_to survey.title, admin_conference_survey_path(@conference.short_title, survey)
|
||||
%td
|
||||
= survey.target
|
||||
%td
|
||||
= survey.start_date
|
||||
%td
|
||||
= survey.end_date
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', edit_admin_conference_survey_path(@conference.short_title, survey),
|
||||
class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_survey_path(@conference.short_title, survey),
|
||||
method: :delete, class: 'btn btn-danger',
|
||||
data: { confirm: "Do you really want to delete #{survey.title}?"}
|
||||
14
app/views/admin/surveys/new.html.haml
Normal file
14
app/views/admin/surveys/new.html.haml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1 New Survey
|
||||
|
||||
.col-md-6
|
||||
= semantic_form_for @survey, url: @url do |f|
|
||||
= f.hidden_field :surveyable_type
|
||||
= f.hidden_field :surveyable_id
|
||||
= f.input :title
|
||||
= f.input :description, input_html: { rows: 3 }
|
||||
= f.input :start_date, as: :string, input_html: { class: 'datetimepicker' }
|
||||
= f.input :end_date, as: :string, input_html: { class: 'datetimepicker' }
|
||||
= f.submit 'Save', class: 'btn btn-primary'
|
||||
18
app/views/admin/surveys/show.html.haml
Normal file
18
app/views/admin/surveys/show.html.haml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.page-header
|
||||
%h1
|
||||
Survey #{@survey.title}
|
||||
= link_to 'Edit Survey', edit_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
|
||||
- @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 }
|
||||
= link_to 'Add Question', new_admin_conference_survey_survey_question_path(@conference.short_title, @survey), class: 'btn btn-success pull-right'
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
- if @conference.questions.any?
|
||||
= render partial: 'conference_registrations/questions', locals: { f: f }
|
||||
- if @conference.program.events.with_registration_open.any? || @registration.events.any?
|
||||
= f.inputs 'Pre-registration required for the following:' do
|
||||
|
||||
|
|
|
|||
|
|
@ -36,24 +36,20 @@
|
|||
= @registration.departure.strftime('%A, %B %-d. %Y %H:%M')
|
||||
- else
|
||||
You haven't scheduled your departure
|
||||
- if @conference.questions.any?
|
||||
- if @conference.surveys.for_registration.any?
|
||||
.row
|
||||
.col-md-12
|
||||
%h4
|
||||
%span.fa-stack
|
||||
%i.fa.fa-square-o.fa-stack-2x
|
||||
%i.fa.fa-info.fa-stack-1x
|
||||
Additional Info
|
||||
Surveys
|
||||
|
||||
%ul
|
||||
- @conference.questions.each do |q|
|
||||
- @conference.surveys.for_registration.each do |survey|
|
||||
%li
|
||||
%strong
|
||||
= q.title
|
||||
- if @registration.qanswers.any?
|
||||
- @registration.qanswers.where(:question_id => q.id).each do |qa|
|
||||
= qa.answer.title
|
||||
- else
|
||||
You haven't answered
|
||||
= link_to survey.title, conference_survey_path(@conference.short_title, survey)
|
||||
|
||||
- if @registration.events.any?
|
||||
.row
|
||||
.col-md-12
|
||||
|
|
|
|||
|
|
@ -131,6 +131,10 @@
|
|||
= link_to(admin_conference_emails_path(@conference.short_title)) do
|
||||
%span.fa.fa-envelope
|
||||
E-Mails
|
||||
%li{ class: active_nav_li(admin_conference_surveys_path(@conference.short_title)) }
|
||||
= link_to(admin_conference_surveys_path(@conference.short_title)) do
|
||||
%span.fa.fa-list-alt
|
||||
Surveys
|
||||
- if can? :index, Role.new(resource: @conference)
|
||||
%li{:class=> active_nav_li(admin_conference_roles_path(@conference.short_title))}
|
||||
= link_to(admin_conference_roles_path(@conference.short_title)) do
|
||||
|
|
|
|||
21
app/views/survey/show.html.haml
Normal file
21
app/views/survey/show.html.haml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
.row
|
||||
.col-md-12
|
||||
.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, index|
|
||||
.row
|
||||
.col-md-12
|
||||
= render partial: 'admin/surveys/survey_question', locals: { survey_question: survey_question, index: index, f: f }
|
||||
= f.submit 'Submit', class: 'btn btn-primary pull-right'
|
||||
Loading…
Add table
Add a link
Reference in a new issue