Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Created April 25, 2011 06:23
Show Gist options
  • Save kracekumar/940230 to your computer and use it in GitHub Desktop.
Save kracekumar/940230 to your computer and use it in GitHub Desktop.
#_new_multiple_choice_create_form.rb
<label class="head_label">Create New Multiple Choice Question<span></span></label>
<div id="grading-levels-form">
<% form_remote_for @question, :url=>{:action=>'new_multiple_choice'} do |f| %>
<div id="form-errors"></div>
<div class="label-field-pair">
<div class="label-container"><label>Question name</label></div>
<div class="input-container"><%= f.text_field :question %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label> Answer 1</label></div>
<div class="input-container"><%= f.text_field :ans1 %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label>Answer 2 </label></div>
<div class="input-container"><%= f.text_field :ans2 %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label> Answer 3 </label></div>
<div class="input-container"><%= f.text_field :ans3 %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label> Answer 4</label></div>
<div class="input-container"><%= f.text_field :ans4 %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label>Correct Answer :</label></div>
<div class="input-container"><%= f.select "correct_ans" ,"<option value=1>Option 1</option>,<option value=2>Option 2</option><option value=3>Option 3</option><option value=4>Option 4</option>",{:prompt => 'Select View For Public'} %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label>Difficulty Level :</label></div>
<div class="input-container"><%= f.select "difficulty_level_id" ,"<option value=1>Normal</option>,<option value=2>Medium</option><option value=3>High</option><option value=4>Option 4</option>",{:prompt => 'Select Difficulty Level'} %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label>Select a Subject :</label></div>
<div class="input-container"><%= f.select "subject" , Hash[@subject_final.collect{|p| [p['name'],p['id']]}],{:prompt => 'Select Subject'}, {:onChange => "#{remote_function(:url => {:action => "update_chapters"}, :with => "'subject_id='+value")}"} %></div>
</div>
<div class="label-field-pair">
<div class="label-container"><%= f.label :Chapter %></div>
<div class="input-container"><div id=chapter><%= render :partial => 'chapter',:object=>@chapter%></div></div>
</div>
<div class="label-field-pair">
<div class="label-container"><label>Add to Public repositry :</label></div>
<div class="input-container"><%= f.select "is_public" ,"<option value=1>Yes</option>,<option value=2>No</option>",{:prompt => 'Select View For Public'} %></div>
</div>
<%= submit_tag "► Save",:class=>'submit_button' %>
<% end %>
</div>
#controller
def update_chapters
@chapter = Chapter.find_all_by_subject_id(params[:subject_id])
render :update do |page|
page.replace_html 'chapter', :partial => 'chapter', :object=>@chapter
end
end
#_chapter.rhtml
<%= select :chapter , @chapter.map{|p| [p.name,p.id]},{:prompt => 'Select Chapter'}%>
#error in the terminal (server log)
ActionView::TemplateError (interning empty string) on line #2 of app/views/online_exam/_chapter.rhtml:
1:
2: <%= select :chapter , @chapter.map{|p| [p.name,p.id]},{:prompt => 'Select Chapter'}%>
app/views/online_exam/_chapter.rhtml:2:in `_run_rhtml_app47views47online_exam47_chapter46rhtml_locals_chapter_object'
app/views/online_exam/_new_multiple_choice_create_form.html.erb:47
searchlogic (2.5.5) lib/searchlogic/rails_helpers.rb:79:in `fields_for'
app/views/online_exam/_new_multiple_choice_create_form.html.erb:6
app/views/online_exam/new_multiple_choice.rjs:1:in `_run_rjs_app47views47online_exam47new_multiple_choice46rjs'
app/views/online_exam/new_multiple_choice.rjs:1:in `_run_rjs_app47views47online_exam47new_multiple_choice46rjs'
app/controllers/online_exam_controller.rb:130:in `add_new_multiple_choice'
app/controllers/online_exam_controller.rb:129:in `add_new_multiple_choice'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment