Skip to content

Commit

Permalink
Merge branch 'rails4' of https://github.com/expertiza/expertiza into …
Browse files Browse the repository at this point in the history
…rails4

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
yangsong8 committed Aug 23, 2015
2 parents 9b67f6e + fcf09c3 commit 0d40041
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 287 deletions.
7 changes: 7 additions & 0 deletions app/controllers/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ def toggle_access
redirect_to :controller => 'tree_display', :action => 'list'
end

#Zhewei: This method is used to add new questions when creating or editing questionnaire.
def add_new_questions
(1..params[:question][:total_num].to_i).each do |i|
Object.const_get(params[:question][:type]).create(id: Question.last.id+1, txt: 'Edit question content here', weight: 1, questionnaire_id: params[:id], seq: 0, type: params[:question][:type], break_before: true)
end
redirect_to edit_questionnaire_path(params[:id].to_sym)
end
#=========================================================================================================
#Separate methods for quiz questionnaire
#=========================================================================================================
Expand Down
279 changes: 0 additions & 279 deletions app/views/questionnaires/_add_and_delete_question_script.html.erb

This file was deleted.

22 changes: 20 additions & 2 deletions app/views/questionnaires/_questionnaire.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,26 @@
<table id="question_actions_table">
<tr>
<td>
<input type="button" value="Add" onclick="addQuestions()">
<input id="numQuestionsToAdd" type="text" value="1" size=1> more question(s)
<!--Zhewei: the reason why we put an empty form_tag here: https://github.com/expertiza/expertiza/blob/53212b6967e9b2d6362d91846bc268ecf1750c6b/app/views/sign_up_sheet/_add_signup_topics_staggered.html.erb-->
<%= form_tag :action => 'add_new_questions' do %>
<% end %>
<%= form_tag :action => 'add_new_questions', :id => params[:id] do %>
<%= submit_tag 'Add' %>
<%= text_field 'question', 'total_num', :size => 1, :value => "1" %> more
<%= select "question", "type",
{"Criterion" =>"Criterion",
"Scale"=>"Scale",
"Dropdown"=>"Dropdown",
"MultipleChoice"=>"MultipleChoice",
"Checkbox"=>"Checkbox",
"TextArea"=>"TextArea",
"TextField"=>"TextField",
"UploadFile"=>"UploadFile",
"SectionHeader"=>"SectionHeader",
"TableHeader"=>"TableHeader",
"ColumnHeader"=>"ColumnHeader",
} %> question(s)
<% end %>
</td>
</tr>
</table>
Expand Down
6 changes: 0 additions & 6 deletions app/views/questionnaires/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<%= render :partial => 'add_and_delete_question_script' %>
<%= form_tag :action => 'create' do %>
<%= render :partial => 'questionnaire' %>
<%= submit_tag "Create #{@questionnaire.display_type.downcase}", :name=>"save" %>

<script>
for (var x = 1; x <= 5; x++) {
addQuestion(",",",",",");}
</script>
<% end %>
<br />
<a href="javascript:window.history.back()">Back</a>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
get :delete
post :create_quiz_questionnaire
post :update_quiz
post :add_new_questions
end
end

Expand Down

0 comments on commit 0d40041

Please sign in to comment.