1.增加新增单选题、新增选项、删除选项等js
2.修改问卷layout增加 3.增加新增单选题确定按钮的路由以及相关action
This commit is contained in:
parent
e4edc5d1db
commit
eb2498c62c
|
@ -54,7 +54,9 @@ class PollController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{render :layout => 'base_courses'}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -82,8 +84,8 @@ class PollController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
#添加单选题
|
#添加单选题
|
||||||
def add_mc
|
def create_poll_question
|
||||||
|
a = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,33 +1,26 @@
|
||||||
<div><!--编辑单选start-->
|
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||||
<div class="ur_editor radio">
|
<div>
|
||||||
<div class="ur_editor_title">
|
<!--编辑单选start-->
|
||||||
<label >问题: </label>
|
<div class="ur_editor radio">
|
||||||
<input class="ur_question_title" type="text" name="title" placeholder="请输入单选题标题"/>
|
<div class="ur_editor_title">
|
||||||
<input type="checkbox" name="required" value="true" checked=""/>
|
<label>问题: </label>
|
||||||
<label >必答</label>
|
<input class="ur_question_title" type="text" name="poll_questions_title" placeholder="请输入单选题标题"/>
|
||||||
</div>
|
<input type="checkbox" name="is_necessary" value="true" checked/>
|
||||||
<div class="ur_editor_content">
|
<label>必答</label>
|
||||||
<ul>
|
</div>
|
||||||
<li class="ur_item">
|
<div class="ur_editor_content">
|
||||||
<label >选项 <span class="ur_index">01</span>: </label>
|
<ul>
|
||||||
<input type="text" name="option" placeholder="新建选项"/>
|
<%= render :partial => 'question_answer'%>
|
||||||
<a class="icon_add" title="向下插入选项"></a>
|
<%= render :partial => 'question_answer'%>
|
||||||
<a class="icon_remove" title="删除"></a>
|
<%= render :partial => 'question_answer'%>
|
||||||
</li>
|
</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 class="cl"></div>
|
||||||
<li class="ur_item">
|
</div>
|
||||||
<label >选项 <span class="ur_index">01</span>: </label>
|
<!--编辑单选 end-->
|
||||||
<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>
|
||||||
<div class="ur_editor_footer">
|
<% end%>
|
||||||
<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-->
|
|
|
@ -10,6 +10,22 @@
|
||||||
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_MCQ') %>");}
|
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_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_single') %>");}
|
||||||
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");}
|
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'edit_mulit') %>");}
|
||||||
|
//单选题
|
||||||
|
function add_single_answer(doc)
|
||||||
|
{
|
||||||
|
doc.parent().after("<%= escape_javascript(render :partial => 'question_answer') %>");
|
||||||
|
}
|
||||||
|
function remove_single_answer(doc)
|
||||||
|
{
|
||||||
|
if(doc.parent().siblings("li").length == 0)
|
||||||
|
{
|
||||||
|
doc.parent().parent().parent().parent().parent().parent().remove();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
doc.parent().remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -45,6 +61,7 @@
|
||||||
<%= render :partial => 'edit_head'%>
|
<%= render :partial => 'edit_head'%>
|
||||||
|
|
||||||
<div id="poll_content">
|
<div id="poll_content">
|
||||||
|
<%#= render :partial => 'edit_MC'%>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ur_buttons">
|
<div class="ur_buttons">
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<li class="ur_item">
|
||||||
|
<label>
|
||||||
|
选项
|
||||||
|
<span class="ur_index">
|
||||||
|
</span>:
|
||||||
|
</label>
|
||||||
|
<input type="text" name="option" 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>
|
|
@ -61,7 +61,7 @@ RedmineApp::Application.routes.draw do
|
||||||
resources :poll do
|
resources :poll do
|
||||||
member do
|
member do
|
||||||
get 'statistics_result'
|
get 'statistics_result'
|
||||||
get 'add_mc'
|
post 'create_poll_question'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue