Merge branch 'cxt_course' of https://git.trustie.net/jacknudt/trustieforge into cxt_course
This commit is contained in:
commit
2138b1cd56
|
@ -143,7 +143,7 @@ class PollController < ApplicationController
|
||||||
if @before_que && @poll_question.update_attribute('question_number', @poll_question.question_number - 1)
|
if @before_que && @poll_question.update_attribute('question_number', @poll_question.question_number - 1)
|
||||||
@before_que.update_attribute('question_number', @before_que.question_number + 1)
|
@before_que.update_attribute('question_number', @before_que.question_number + 1)
|
||||||
end
|
end
|
||||||
elsif params[:opr] == 'down' && @poll_question.question_number < members.count
|
elsif params[:opr] == 'down' && @poll_question.question_number < poll_questions.count
|
||||||
@after_que = poll_questions.where("question_number = #{@poll_question.question_number + 1}").first
|
@after_que = poll_questions.where("question_number = #{@poll_question.question_number + 1}").first
|
||||||
if @after_que && @poll_question.update_attribute('question_number', @poll_question.question_number + 1)
|
if @after_que && @poll_question.update_attribute('question_number', @poll_question.question_number + 1)
|
||||||
@after_que.update_attribute('question_number', @after_que.question_number - 1)
|
@after_que.update_attribute('question_number', @after_que.question_number - 1)
|
||||||
|
@ -157,12 +157,15 @@ class PollController < ApplicationController
|
||||||
|
|
||||||
#添加题目
|
#添加题目
|
||||||
def create_poll_question
|
def create_poll_question
|
||||||
|
@last_question = @poll.poll_questions.last
|
||||||
question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
|
question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title]
|
||||||
option = {
|
option = {
|
||||||
:is_necessary => (params[:is_necessary]=="true" ? 1 : 0),
|
:is_necessary => (params[:is_necessary]=="true" ? 1 : 0),
|
||||||
:question_title => question_title,
|
:question_title => question_title,
|
||||||
:question_type => params[:question_type] || 1,
|
:question_type => params[:question_type] || 1,
|
||||||
:question_number => @poll.poll_questions.count + 1
|
:question_number => @poll.poll_questions.count + 1,
|
||||||
|
:max_choices => params[:max_choices].to_i || 0,
|
||||||
|
:min_choices => params[:min_choices].to_i || 0,
|
||||||
}
|
}
|
||||||
@poll_questions = @poll.poll_questions.new option
|
@poll_questions = @poll.poll_questions.new option
|
||||||
if params[:question_answer]
|
if params[:question_answer]
|
||||||
|
@ -193,11 +196,11 @@ class PollController < ApplicationController
|
||||||
@poll_questions.question_number = ques_num + 1
|
@poll_questions.question_number = ques_num + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @poll_questions.save
|
if @poll_questions.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#修改题目
|
#修改题目
|
||||||
|
|
|
@ -9,18 +9,6 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="ur_editor_content">
|
<div class="ur_editor_content">
|
||||||
<ul>
|
<ul>
|
||||||
<li class='ur_item'>
|
|
||||||
<div class="fl mr30">
|
|
||||||
<label>下限<span class='ur_index'></span>: </label>
|
|
||||||
<select class="poll-multiple-limit"></select>
|
|
||||||
<span>(可选)答题时最少选几项</span>
|
|
||||||
</div>
|
|
||||||
<div class="fl">
|
|
||||||
<label>上限<span class='ur_index'></span>: </label>
|
|
||||||
<select class="poll-multiple-limit"></select>
|
|
||||||
<span>(可选)答题时最多选几项</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class='ur_item new_answer'>
|
<li class='ur_item new_answer'>
|
||||||
<label>选项<span class='ur_index'></span>: </label>
|
<label>选项<span class='ur_index'></span>: </label>
|
||||||
<input maxlength="200" type='text' name='question_answer[0]' placeholder='新建选项'/>
|
<input maxlength="200" type='text' name='question_answer[0]' placeholder='新建选项'/>
|
||||||
|
@ -41,6 +29,22 @@
|
||||||
<div class='cl'></div>
|
<div class='cl'></div>
|
||||||
</ul>
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li class='ur_item'>
|
||||||
|
<div class="fl mr30">
|
||||||
|
<label>下限<span class='ur_index'></span>: </label>
|
||||||
|
<select name="min_choices" class="poll-multiple-limit"></select>
|
||||||
|
<span class="fontGrey2">(可选)答题时最少选几项</span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<li class='ur_item'>
|
||||||
|
<div class="fl mr30">
|
||||||
|
<label>上限<span class='ur_index'></span>: </label>
|
||||||
|
<select name="max_choices" class="poll-multiple-limit"></select>
|
||||||
|
<span class="fontGrey2">(可选)答题时最多选几项</span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<div class="cl"></div>
|
||||||
<li class="ur_item">
|
<li class="ur_item">
|
||||||
<div class="dash-block new-question" onclick='add_single_answer($(this));'>新建选项</div>
|
<div class="dash-block new-question" onclick='add_single_answer($(this));'>新建选项</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -24,16 +24,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<script>
|
|
||||||
$(".poll-add").mouseover(function(){
|
|
||||||
$(this).next().show();
|
|
||||||
}).mouseout(function(){
|
|
||||||
$(this).next().hide();
|
|
||||||
});
|
|
||||||
$(".poll-add-menu").mouseover(function(){
|
|
||||||
$(this).show();
|
|
||||||
}).mouseout(function(){
|
|
||||||
$(this).hide();
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -492,9 +492,9 @@ function insert_MCQ(quest_type,quest_id){
|
||||||
//多选题答题限制数实时更新
|
//多选题答题限制数实时更新
|
||||||
function multiLimit(){
|
function multiLimit(){
|
||||||
var upperLimit = $(".questionContainer .new_answer").size();
|
var upperLimit = $(".questionContainer .new_answer").size();
|
||||||
$(".poll-multiple-limit").append("<option></option>");
|
$(".poll-multiple-limit").append("<option value='0'></option>");
|
||||||
for(var i = 1; i <= upperLimit; i++){
|
for(var i = 1; i <= upperLimit; i++){
|
||||||
$(".poll-multiple-limit").append("<option>" + i + "</option>");
|
$(".poll-multiple-limit").append("<option value='"+ i +"'>" + i + "</option>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,14 @@
|
||||||
<span class="c_red questionLabel ml5" title="必答">*</span>
|
<span class="c_red questionLabel ml5" title="必答">*</span>
|
||||||
<%end%>
|
<%end%>
|
||||||
</p>
|
</p>
|
||||||
<a class="poll-up mb8" title="上移"></a>
|
<% poll = poll_question.poll %>
|
||||||
<a class="poll-down mb8" title="下移"></a>
|
<% count = poll.poll_questions.count %>
|
||||||
|
<% unless poll_question.question_number == 1 %>
|
||||||
|
<%= link_to('', {:controller => 'poll', :action => 'update_question_num', :id => poll.id, :ques_id => poll_question.id, :opr => 'up'},:remote => true, :method => 'post', :class => "poll-up mb8", :title => '上移') %>
|
||||||
|
<% end %>
|
||||||
|
<% if poll_question.question_number < count %>
|
||||||
|
<%= link_to('', {:controller => 'poll', :action => 'update_question_num', :id => poll.id, :ques_id => poll_question.id, :opr => 'down'},:remote => true, :method => 'post', :class => "poll-down mb8", :title => '下移') %>
|
||||||
|
<% end %>
|
||||||
<a href="javascript:void(0);" class="poll-add mb8"></a>
|
<a href="javascript:void(0);" class="poll-add mb8"></a>
|
||||||
<ul class="poll-add-menu fontGrey3">
|
<ul class="poll-add-menu fontGrey3">
|
||||||
<li><a href="javascript:void(0);" onclick=" dismiss('<%=type %>',<%=poll_question.id%>);insert_MC('<%=type %>',<%=poll_question.id%>);">单选题</a></li>
|
<li><a href="javascript:void(0);" onclick=" dismiss('<%=type %>',<%=poll_question.id%>);insert_MC('<%=type %>',<%=poll_question.id%>);">单选题</a></li>
|
||||||
|
|
|
@ -38,3 +38,15 @@
|
||||||
<!-- 新增问题 -->
|
<!-- 新增问题 -->
|
||||||
<div id="insert_new_poll_question_mc_<%=poll_question.id%>">
|
<div id="insert_new_poll_question_mc_<%=poll_question.id%>">
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
$(".poll-add").mouseover(function(){
|
||||||
|
$(this).next().show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).next().hide();
|
||||||
|
});
|
||||||
|
$(".poll-add-menu").mouseover(function(){
|
||||||
|
$(this).show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).hide();
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -6,6 +6,17 @@
|
||||||
<div class="testEditTitle" style="padding-top:0;">
|
<div class="testEditTitle" style="padding-top:0;">
|
||||||
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
|
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
|
||||||
<span class="fontBlue">[多选题]</span>
|
<span class="fontBlue">[多选题]</span>
|
||||||
|
<% if poll_question.min_choices != 0 || poll_question.max_choices != 0 %>
|
||||||
|
<p class="fontGrey2">
|
||||||
|
<% if poll_question.min_choices != 0 && poll_question.max_choices != 0 %>
|
||||||
|
答题时最少选<%=poll_question.min_choices %>项、最多选<%=poll_question.max_choices %>项
|
||||||
|
<% elsif poll_question.min_choices != 0 %>
|
||||||
|
答题时最少选<%=poll_question.min_choices %>项
|
||||||
|
<% elsif poll_question.max_choices != 0 %>
|
||||||
|
答题时最多选<%=poll_question.max_choices %>项
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<a class="poll-edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
|
<a class="poll-edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
@ -36,4 +47,16 @@
|
||||||
</div><!--多选题显示 end-->
|
</div><!--多选题显示 end-->
|
||||||
<!-- 新增问题 -->
|
<!-- 新增问题 -->
|
||||||
<div id="insert_new_poll_question_mcq_<%=poll_question.id%>">
|
<div id="insert_new_poll_question_mcq_<%=poll_question.id%>">
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
$(".poll-add").mouseover(function(){
|
||||||
|
$(this).next().show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).next().hide();
|
||||||
|
});
|
||||||
|
$(".poll-add-menu").mouseover(function(){
|
||||||
|
$(this).show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).hide();
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -20,4 +20,16 @@
|
||||||
</div><!--多行展示 end-->
|
</div><!--多行展示 end-->
|
||||||
<!-- 新增问题 -->
|
<!-- 新增问题 -->
|
||||||
<div id="insert_new_poll_question_mulit_<%=poll_question.id%>">
|
<div id="insert_new_poll_question_mulit_<%=poll_question.id%>">
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
$(".poll-add").mouseover(function(){
|
||||||
|
$(this).next().show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).next().hide();
|
||||||
|
});
|
||||||
|
$(".poll-add-menu").mouseover(function(){
|
||||||
|
$(this).show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).hide();
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -17,4 +17,16 @@
|
||||||
</div><!--单行文字展示 end-->
|
</div><!--单行文字展示 end-->
|
||||||
<!-- 新增问题 -->
|
<!-- 新增问题 -->
|
||||||
<div id="insert_new_poll_question_single_<%=poll_question.id%>">
|
<div id="insert_new_poll_question_single_<%=poll_question.id%>">
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
$(".poll-add").mouseover(function(){
|
||||||
|
$(this).next().show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).next().hide();
|
||||||
|
});
|
||||||
|
$(".poll-add-menu").mouseover(function(){
|
||||||
|
$(this).show();
|
||||||
|
}).mouseout(function(){
|
||||||
|
$(this).hide();
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -2,6 +2,17 @@
|
||||||
$("#poll_content").html('<%= escape_javascript(render :partial => 'poll_content', :locals => {:poll => @poll})%>');
|
$("#poll_content").html('<%= escape_javascript(render :partial => 'poll_content', :locals => {:poll => @poll})%>');
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#new_poll_question_new").html("");
|
$("#new_poll_question_new").html("");
|
||||||
|
<% if @last_question %>
|
||||||
|
<% if @last_question.question_type == 1%>
|
||||||
|
$("#show_poll_questions_<%= @last_question.id %>").html("<%= escape_javascript(render :partial => 'show_MC', :locals => {:poll_question => @last_question}) %>");
|
||||||
|
<% elsif @last_question.question_type == 2%>
|
||||||
|
$("#show_poll_questions_<%= @last_question.id %>").html("<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:poll_question => @last_question}) %>");
|
||||||
|
<% elsif @last_question.question_type == 3%>
|
||||||
|
$("#show_poll_questions_<%= @last_question.id %>").html("<%= escape_javascript(render :partial => 'show_single', :locals => {:poll_question => @last_question}) %>");
|
||||||
|
<% elsif @last_question.question_type == 4%>
|
||||||
|
$("#show_poll_questions_<%= @last_question.id %>").html("<%= escape_javascript(render :partial => 'show_mulit', :locals => {:poll_question => @last_question}) %>");
|
||||||
|
<% end%>
|
||||||
|
<% end %>
|
||||||
$("#poll_content").append("<div id='poll_questions_<%= @poll_questions.id%>'>" +
|
$("#poll_content").append("<div id='poll_questions_<%= @poll_questions.id%>'>" +
|
||||||
"<div id='show_poll_questions_<%= @poll_questions.id %>'>" +
|
"<div id='show_poll_questions_<%= @poll_questions.id %>'>" +
|
||||||
"<% if @poll_questions.question_type == 1%>" +
|
"<% if @poll_questions.question_type == 1%>" +
|
||||||
|
|
|
@ -109,6 +109,17 @@
|
||||||
<% if pq.is_necessary == 1 %>
|
<% if pq.is_necessary == 1 %>
|
||||||
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
|
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% if pq.min_choices != 0 || pq.max_choices != 0 %>
|
||||||
|
<p class="fontGrey2">
|
||||||
|
<% if pq.min_choices != 0 && pq.max_choices != 0 %>
|
||||||
|
答题时最少选<%=pq.min_choices %>项、最多选<%=pq.max_choices %>项
|
||||||
|
<% elsif pq.min_choices != 0 %>
|
||||||
|
答题时最少选<%=pq.min_choices %>项
|
||||||
|
<% elsif pq.max_choices != 0 %>
|
||||||
|
答题时最多选<%=pq.max_choices %>项
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="ur_inputs">
|
<div class="ur_inputs">
|
||||||
|
|
|
@ -269,7 +269,7 @@ RedmineApp::Application.routes.draw do
|
||||||
get 'close_poll'
|
get 'close_poll'
|
||||||
get 'export_poll'
|
get 'export_poll'
|
||||||
get 'import_poll'
|
get 'import_poll'
|
||||||
|
post 'update_question_num'
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
delete 'delete_poll_question'
|
delete 'delete_poll_question'
|
||||||
|
|
Loading…
Reference in New Issue