question builder

This commit is contained in:
Stella 2014-02-09 18:05:57 +02:00
parent 4356616566
commit 3105c8da5d
28 changed files with 338 additions and 15 deletions

View file

@ -0,0 +1 @@
= f.input :title

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