Merge branch 'final_questions' of https://github.com/differentreality/osem into differentreality-final_questions

Conflicts:
	app/models/conference.rb
	config/routes.rb
This commit is contained in:
Henne Vogelsang 2014-03-03 10:43:38 +01:00
commit 243ea41456
28 changed files with 342 additions and 16 deletions

View file

@ -47,4 +47,7 @@
%li.active= link_to "Dietary Choices", "#"
- else
%li= link_to "Dietary Choices", admin_conference_dietary_list_path(@conference.short_title)
- if activated == "Questions"
%li.active= link_to "Questions", "#"
- else
%li= link_to "Questions", admin_conference_questions_path(@conference.short_title)

View file

@ -0,0 +1,4 @@
.nested-fields
= f.inputs do
= f.input :title
= remove_association_link :answer, f

View file

@ -0,0 +1,8 @@
.row-fluid
.span6
%legend Question
= f.input :title, :label => "Your Question"
= f.input :question_type
= f.input :global, :label => "Make Global", :hint => "(Global questions are available for selection to all conferences)"
.span6
= dynamic_association :answers, "Answers", f, :hint => "Insert your answers in the order you want them to appear"

View file

@ -0,0 +1,20 @@
%h2
Questions for #{@conference.short_title}
- if @questions_conference.count
= "(#{@questions_conference.count})"
%i The questions will appear in the registration page of the conference
%table.table
- @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
= label_tag dom_id(q), q.title
= label_tag dom_id(q), "Type: #{q.question_type.title}"
= label_tag dom_id(q), "Answers: #{q.answers.map {|a| a.title}.join(', ')}"
%td= link_to "Edit", edit_admin_conference_question_path(@conference.short_title, q), :class => "btn btn-primary", :disabled => q.global == true && !has_role?(current_user, "Admin")
%td= 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 => q.global == true && !has_role?(current_user, "Admin")

View file

@ -0,0 +1 @@
$('#myquestions').html("<%= escape_javascript(render :partial => 'questions') %>");

View file

@ -0,0 +1,9 @@
%h2
Edit Question
%h3
"#{@question.title}"
= semantic_form_for(@question, :url => admin_conference_question_path(@conference.short_title, @question.id)) do |f|
= render :partial => "form", :locals => {:f => f}
= f.submit "Save", :class => "btn btn-primary", :confirm => "Are you sure you want to make these changes?"

View file

@ -0,0 +1,31 @@
.container-fluid
.row-fluid
.span3
= render 'admin/conference/sidebar', :activated => "Questions"
.span9
.pull-right
%b= link_to "Create New Question","#", "data-toggle" => "modal", "data-target" => "#new-question", :class => "btn btn-success"
%br
%br
- if @questions.count > 0
= semantic_form_for(@conference, :url => admin_conference_questions_update_conference_path(@conference.short_title), :method => 'put') do |f|
.questions{:id => "myquestions"}
= render :partial => "questions"
= f.submit "Update Questions for #{@conference.short_title}", :class => "btn btn-primary", :confirm => "Are you sure you want to make these changes?"
.modal.hide.fade{:id => "new-question", "role" => "dialog", "aria-hidden" => "true"}
.modal-header
%h3{:id => "new-question-header"}
Add new question
.modal-body
= semantic_form_for(@new_question, :url => admin_conference_questions_path(@conference.short_title), :method => :post) do |f|
= render :partial => "form", :locals => {:f => f}
%button{:class => "btn btn-primary"}
Save
.pull-right
%button{:class=> "btn btn-danger", "data-dismiss"=> "modal", "aria-hidden"=>"true"}
Cancel

View file

@ -0,0 +1,9 @@
- @conference.questions.each do |q|
%b Q:
= q.title
%b A:
- registration.qanswers.where(:question_id => q.id).each do |qa|
= qa.answer.title
%br

View file

@ -11,7 +11,7 @@
- if @registrations
= "(#{@registrations.length})"
= " - Attended (#{@attended})"
%table.table.table-striped.table-bordered.table-hover#registrations
%table.table.table-bordered.table-striped.table-hover#registrations
%thead
%th
No
@ -21,6 +21,7 @@
= h.capitalize
%th
%th
%th
- counter = 0
- @registrations.each do |registration|
%tr
@ -45,11 +46,17 @@
- else
= registration.send(field.to_sym)
%td
= link_to "Questions", "#", :class => "questions btn btn-success", :id => counter, :onclick => "toggle('row#{counter}')"
%td
= link_to "Edit", admin_conference_registrations_edit_path(@conference.short_title, :id => registration.id), :method => :get, :class => "btn btn-primary"
%td
= link_to "Delete", admin_conference_registrations_path(@conference.short_title, :id => registration.id), :method => :delete, :class => "btn btn-danger", :confirm => "Really delete registration for #{registration.public_name} #{registration.email}?"
%tr{:id => "row#{counter}", :style=>"display:none;"}
%td{:colspan=>13}
= render :partial => "questions", :locals => {:registration => registration}
:javascript
$(document).ready(function() {
@ -58,3 +65,11 @@
"bLengthChange": false
} );
} );
function toggle(rowid) {
if( document.getElementById(rowid).style.display=='none' ){
document.getElementById(rowid).style.display = '';
}else{
document.getElementById(rowid).style.display = 'none';
}
};

View file

@ -0,0 +1,13 @@
- @conference.questions.each do |q|
%h5
= "Q: #{q.title}"
- if q.question_type.id == 1 || q.question_type.id == 2 # yes/no or single choice
= f.input :qanswers, :collection => q.qanswers, :as => :select, :input_html => { :multiple => false }, :label => false, :include_blank => "Please make your choice",
:member_label => Proc.new {|a| a.answer.title}
- if q.question_type.id == 3 # multiple choice
= f.input :qanswers, :collection => q.qanswers, :as => :check_boxes, :label => false,
:member_label => Proc.new {|a| a.answer.title}

View file

@ -17,15 +17,18 @@
%br
= f.fields_for :person do |p|
= p.text_field :public_name, :for => :person
- if @conference.use_supporter_levels?
- if @conference.questions
= render :partial => "questions", :locals => {:f => f}
%br
- if @conference.use_supporter_levels? && @conference.supporter_levels.count > 0
= f.semantic_fields_for :supporter_registration do |reg|
= reg.input :supporter_level, :as => :select, :collection => @conference.supporter_levels
= reg.input :code, :label => "Confirmation or registration code (if applicable)"
%span#supporter-link.help-block
= f.input :attending_with_partner, :label => false
= f.input :using_affiliated_lodging, :label => false
= f.input :handicapped_access_required, :label => false
= f.input :other_special_needs, :label => "Any other special needs?", :input_html => {:rows => 2}
= f.input :other_special_needs, :label => "Any other needs or comments?", :input_html => {:rows => 2, :class => "span6"}
- if @workshops.count > 0
=f.inputs "Register to workshops" do