1、分离出新建问卷问题页面

2、增加修改问题相关路由及action
This commit is contained in:
sw 2015-01-15 14:40:17 +08:00
parent 4996b9a546
commit a99d7c5145
8 changed files with 140 additions and 34 deletions

View File

@ -89,7 +89,7 @@ class PollController < ApplicationController
def create_poll_question
question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
option = {
:is_necessary => params[:is_necessary] || true,
:is_necessary => params[:is_necessary] || 1,
:question_title => question_title,
:question_type => params[:question_type] || 1,
:question_number => @poll.poll_questions.count + 1
@ -112,6 +112,11 @@ class PollController < ApplicationController
end
end
#修改单选题
def update_poll_question
a = 1
end
private
def find_poll_and_course
@poll = Poll.find params[:id]

View File

@ -1,37 +1,25 @@
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
<%= form_for poll_question,:url =>update_poll_question_poll_path(@poll.id),:remote => true do |f|%>
<div>
<!--编辑单选start-->
<div class="ur_editor radio">
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input type="hidden" name="question_type" value="1"/>
<input class="ur_question_title" type="text" name="poll_questions_title" placeholder="请输入单选题标题"/>
<input type="checkbox" name="is_necessary" value="true" checked/>
<input type="hidden" name="question_type" value="<%= poll_question.question_type%>"/>
<input class="ur_question_title" type="text" name="poll_questions_title" placeholder="请输入单选题标题" value="<%= poll_question.question_title%>"/>
<input type="checkbox" name="is_necessary" value="true" checked = "<%= poll_question.is_necessary == 1%>"/>
<label>必答</label>
</div>
<div class="ur_editor_content">
<ul>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[0]' placeholder='新建选项'/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[1]' placeholder='新建选项'/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[2]' placeholder='新建选项'/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<% poll_question.poll_answers.reorder("answer_position") do |poll_answer| %>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[<%= poll_answer.id %>]' placeholder='新建选项' value="<%= poll_answer.answer_text%>"/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<% end%>
</ul>
</div>
<div class="ur_editor_footer">

View File

@ -0,0 +1,45 @@
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
<div>
<!--编辑单选start-->
<div class="ur_editor radio">
<div class="ur_editor_title">
<label>问题:&nbsp;&nbsp;</label>
<input type="hidden" name="question_type" value="1"/>
<input class="ur_question_title" type="text" name="poll_questions_title" placeholder="请输入单选题标题"/>
<input type="checkbox" name="is_necessary" value="true" checked/>
<label>必答</label>
</div>
<div class="ur_editor_content">
<ul>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[0]' placeholder='新建选项'/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[1]' placeholder='新建选项'/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
<li class='ur_item'>
<label>选项<span class='ur_index'></span></label>
<input type='text' name='question_answer[2]' placeholder='新建选项'/>
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
</li>
<div class='cl'></div>
</ul>
</div>
<div class="ur_editor_footer">
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().parent().submit();">确定</a>
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().parent().remove();">取消</a>
</div>
<div class="cl"></div>
</div>
<!--编辑单选 end-->
</div>
<% end%>

View File

@ -0,0 +1,33 @@
<div><!--编辑多选start-->
<div class="ur_editor checkbox">
<div class="ur_editor_title">
<label >问题:&nbsp;&nbsp;</label>
<input class="ur_question_title" type="text" name="title" placeholder="请输入多选题题标题"/>
<input type="checkbox" name="required" value="true" checked=""/>
<label >必答</label>
</div>
<div class="ur_editor_content">
<ul>
<li class="ur_item">
<label>选项 <span class="ur_index">01</span> </label>
<input type="text" name="option" placeholder="新建选项"/>
<a class="icon_add" title="向下插入选项"></a>
<a class="icon_remove" title="删除"></a>
</li>
<div class="cl"></div>
<li class="ur_item">
<label >选项 <span class="ur_index">01</span> </label>
<input type="text" name="option" placeholder="新建选项"/>
<a class="icon_add" title="向下插入选项"></a>
<a class="icon_remove" title="删除"></a>
</li>
<div class="cl"></div>
</ul>
</div>
<div class="ur_editor_footer">
<a class="btn btn_dark btn_submit" data-button="ok">确定</a>
<a class="btn btn_light btn_cancel" data-button="cancel">取消</a>
</div>
<div class="cl"></div>
</div>
</div><!--编辑多选 end-->

View File

@ -0,0 +1,18 @@
<div class="ur_editor textarea"> <!--编辑多行文字start-->
<div class="ur_editor_title">
<label for="ur_question_title">问题:&nbsp;&nbsp;</label>
<input id="ur_question_title" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入多行文字标题"/>
<input type="checkbox" name="required" value="true" id="ur_question_require" checked=""/>
<label for="ur_question_require">必答</label>
</div>
<div class="ur_editor_toolbar">
<label>尺寸:</label>
<label>宽 <input name="cols" type="number" min="1" value="60"> 字</label>,
<label>高 <input name="rows" type="number" min="1" value="5"> 行</label>
</div>
<div class="ur_editor_footer">
<a class="btn_submit" data-button="ok">确定</a>
<a class="btn_cancel" data-button="cancel">取消</a>
</div>
<div class="cl"></div>
</div><!--编辑多行文字end-->

View File

@ -0,0 +1,13 @@
<div class="ur_editor text "> <!--编辑单行文字start-->
<div class="ur_editor_title">
<label for="ur_question_title">问题:&nbsp;&nbsp;</label>
<input id="ur_question_title_1" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入单行文字标题"/>
<input type="checkbox" name="required" value="true" id="ur_question_require_2" checked=""/>
<label for="ur_question_require">必答</label>
</div>
<div class="ur_editor_footer">
<a class="btn_submit" data-button="ok">确定</a>
<a class="btn_cancel" data-button="cancel">取消</a>
</div>
<div class="cl"></div>
</div><!--编辑单行文字end-->

View File

@ -6,10 +6,10 @@
<%= stylesheet_link_tag 'polls', :media => 'all' %>
<script type="text/javascript">
function add_MC(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MC') %>");}
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");}
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");}
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");}
function add_MC(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_MC') %>");}
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_MCQ') %>");}
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_single') %>");}
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_mulit') %>");}
//问卷头
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
@ -71,11 +71,14 @@
<%= render :partial => 'edit_head', :locals => {:poll => @poll}%>
</div>
<div>
<% @poll.poll_questions.each do |poll_question|%>
<% @poll.poll_questions.each do |poll_question|%>
<div id="show_polls_questions_<%= poll_question.id %>">
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
<% end%>
</div>
</div>
<div id="edit_polls_questions_<%= poll_question.id %>" style="display: none;">
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
</div>
<% end%>
<div id="poll_content">
<%#= render :partial => 'edit_MC'%>
</div>

View File

@ -62,6 +62,7 @@ RedmineApp::Application.routes.draw do
member do
get 'statistics_result'
post 'create_poll_question'
post 'update_poll_question'
end
end