Merge branch 'dev_local' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into dev_local

dev_local
caishi 6 years ago
commit 24e2137f74

@ -9,11 +9,11 @@ class ExerciseController < ApplicationController
:send_to_course, :get_student_uncomplete_question, :edit_question_score, :setting, :set_public,
:ex_setting, :add_to_exercise_bank, :choose_shixuns, :shixun_question, :back_to_answer, :export_blank_exercise, :export_student_result,
:choose_student, :redo_exercise, :cancel_commit_confirm, :cancel_commit,
:update_shixun_block]
:update_shixun_block, :delete_shixun_question]
before_filter :find_course, :only => [:index,:new,:create]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :create_exercise_question, :publish_exercise, :publish_notice, :end_exercise, :cancel_publish,
:update_question_num, :send_to_course, :edit_question_score, :set_public, :ex_setting, :export_blank_exercise, :export_student_result,
:choose_shixuns, :shixun_question, :update_shixun_block]
:choose_shixuns, :shixun_question, :update_shixun_block, :delete_shixun_question]
before_filter :require_login, :only => [:student_exercise_list, :show]
include ExerciseHelper
include ApplicationHelper
@ -217,6 +217,10 @@ class ExerciseController < ApplicationController
redirect_to edit_exercise_path(@exercise)
end
def delete_shixun_question
@exercise.exercise_level_settings.destroy_all
end
def create
if params[:exercise]
exercise = Exercise.new

@ -55,4 +55,24 @@ class Exercise < ActiveRecord::Base
def level_setting level
self.exercise_level_settings.where(level: level).first
end
def shixun_question_count
self.exercise_level_settings.sum(:num)
end
def shixun_question_score
score = 0
self.exercise_level_settings.each do |setting|
score += setting.num * setting.score.to_i
end
score
end
def has_shixun_questions?
self.exercise_questions.where("question_type = 5 and exercise_level_setting_id != 0").count > 0
end
def exercise_question_size
self.exercise_questions.where("question_type != 5").count + self.shixun_question_count
end
end

@ -1,5 +1,5 @@
class ExerciseLevelSetting < ActiveRecord::Base
belongs_to :exercise
has_many :exercise_questions
has_many :exercise_questions, :dependent => :destroy
# attr_accessible :level, :num, :score
end

@ -28,7 +28,7 @@
<!-- <p class="fr">-->
<!-- <span class="font-12 color-grey mb10" style="display: block;">温馨提示:[实训题]属于客观题将由系统自动评分</span>-->
<!-- <a href="javascript:void(0)" class="fr task-btn task-btn-orange" onclick="edit_poll_question($(this),<%#= exercise_question.id %>,5);">保存</a>-->
<!-- <a href="javascript:void(0)" class="fr task-btn mr10" onclick="$('#edit_poll_questions_<%=exercise_question.id %>').hide();$('#show_poll_questions_<%=exercise_question.id %>').show();">取消</a>-->
<!-- <a href="javascript:void(0)" class="fr task-btn mr10" onclick="$('#edit_poll_questions_<%#=exercise_question.id %>').hide();$('#show_poll_questions_<%#=exercise_question.id %>').show();">取消</a>-->
<!-- </p>-->
<!-- </li>-->
<!-- </div>-->

@ -29,13 +29,13 @@
<div id='edit_poll_questions_<%= eq.id %>' style='display: none;'>
<%= render :partial => 'edit_multi', :locals => {:exercise_question => eq} %>
</div>
<% when 5 %>
<div id='show_poll_questions_<%= eq.id %>'>
<%= render :partial => 'show_shixun', :locals => {:exercise_question => eq} %>
</div>
<div id='edit_poll_questions_<%= eq.id %>' style='display: none;'>
<%= render :partial => 'edit_shixun', :locals => {:exercise_question => eq} %>
</div>
<% end %>
</div>
<% end %>
<% end %>
<div id='show_shixun_questions'>
<%= render :partial => 'show_shixun' %>
</div>
<div id='edit_shixun_questions' style='display: none;'>
<%= render :partial => 'new_shixun' %>
</div>

@ -6,7 +6,7 @@
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_MCQ();">+&nbsp;多选题</a>
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_single();">+&nbsp;填空题</a>
<a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_multi();">+&nbsp;简答题</a>
<% if @exercise.try(:id).nil? || @exercise.exercise_questions.where("question_type = 5 and exercise_level_setting_id != 0").count == 0 %>
<% if @exercise.try(:id).nil? || !@exercise.has_shixun_questions? %>
<a href="javascript:void(0);" class="fl add_item_part" onclick="add_shixun();">+&nbsp;实训题</a>
<% end %>

@ -1,8 +1,8 @@
<% if exercise.id %>
<% if @exercise.id %>
<div nhname="new_exercise_mc_q">
<%= form_for('',
:html => { :multipart => true, :id => "new_shixun_question"},
:url=>update_shixun_block_exercise_path(exercise.id)) do |f| %>
:url=>update_shixun_block_exercise_path(@exercise.id)) do |f| %>
<!-- <div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 answer_Temp" id="answer_Temp">-->
<!-- <p class="fl mt15 font-16 mb10">实训题</p>-->
<!-- <input name="question_type" value="5" type="hidden">-->
@ -44,7 +44,7 @@
<ul class="fl" id="ul">
<% for i in 1..4 %>
<% questions_list = exercise.exercise_questions.where(question_type: 5, level: i) %>
<% questions_list = @exercise.exercise_questions.where(question_type: 5, level: i) %>
<li id="edit_shixun_ques_<%= i %>" class="<%= questions_list.try(:count).to_i > 0 ? '' : 'none' %>">
<div class="fl font-16 mb10 practicalTitle">
@ -53,7 +53,7 @@
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:
<input id="minute<%= i %>" value="<%= exercise.level_setting(i).try(:score) %>" name="ques_scores[]" class="borderFF8121"/> 分/题
<input id="minute<%= i %>" value="<%= @exercise.level_setting(i).try(:score) %>" name="ques_scores[]" class="borderFF8121"/> 分/题
<div class="colorFF8121sum none" id="scoregreater<%= i %>">*大于等于0且不能大于100</div>
<div class="colorFF8121sum none" id="scorenull<%= i %>">*不能为空</div>
<div class="colorFF8121sum none" id="scorezero<%= i %>">*必须大于等于0</div>
@ -62,7 +62,7 @@
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>
随机出题量:<input id="topic<%= i %>" value="<%= exercise.level_setting(i).try(:num) || questions_list.try(:count) %>" name="ques_nums[]" class="borderFF8121"/> 题
随机出题量:<input id="topic<%= i %>" value="<%= @exercise.level_setting(i).try(:num) || questions_list.try(:count) %>" name="ques_nums[]" class="borderFF8121"/> 题
<div class="colorFF8121 none" id="topicnull<%= i %>">*不能为空</div>
<div class="colorFF8121 none" id="topicinteger<%= i %>">*必须为正整数</div>
<div class="colorFF8121 none" id="topicreater<%= i %>">*不能大于可用题数</div>
@ -99,19 +99,16 @@
<li class="fl clearfix mb20 shixunsboxs">
<p class="mr40">
<a href="javascript:void(0)" class="fr task-btn task-btn-orange" id="add_new_question">保存</a>
<a href="javascript:void(0)" class="fr task-btn mr30">取消</a>
<a href="javascript:void(0)" class="fr task-btn mr30" onclick="$('#show_shixun_questions').show(); $('#edit_shixun_questions').hide();">取消</a>
<span class=" fr font-12 color-grey mt5 mr25" style="display: block;">
<span class="color-orange-tip ">温馨提示:</span>[实训题]属于客观题将由系统自动评分
</span>
</p>
</li>
</div>
<% end %>
</div>
<% end %>
<script type="text/javascript">

@ -3,7 +3,7 @@
<p class="fl font-15">第<%= exercise_question.question_number%>题:<span class="color-orange03 ml10">[单选题]</span><span class="ml10"><%= exercise_question.question_score %></span>分</p>
<% if @exercise.exercise_status == 1 %>
<p class="fr exam_operator font-18">
<% if exercise_question.question_number < @exercise.exercise_questions.count %>
<% if exercise_question.question_number < @exercise.exercise_questions.where("question_type != 5").count %>
<a href="<%= update_question_num_exercise_path(@exercise, :ques_id => exercise_question.id, :opr => 'down') %>" data-remote="true" class="down_question"><i data-tip-down="下移" class="fa fa-arrow-circle-down mr10 color-orange05"></i></a>
<% end %>
<% unless exercise_question.question_number == 1 %>

@ -3,7 +3,7 @@
<p class="fl font-15">第<%= exercise_question.question_number%>题:<span class="color-orange03 ml10">[多选题]</span><span class="ml10"><%= exercise_question.question_score %></span>分</p>
<% if @exercise.exercise_status == 1 %>
<p class="fr exam_operator font-18">
<% if exercise_question.question_number < @exercise.exercise_questions.count %>
<% if exercise_question.question_number < @exercise.exercise_questions.where("question_type != 5").count %>
<a href="<%= update_question_num_exercise_path(@exercise, :ques_id => exercise_question.id, :opr => 'down') %>" data-remote="true" class="down_question"><i data-tip-down="下移" class="fa fa-arrow-circle-down mr10 color-orange05"></i></a>
<% end %>
<% unless exercise_question.question_number == 1 %>

@ -3,7 +3,7 @@
<p class="fl font-15">第<%= exercise_question.question_number%>题:<span class="color-orange03 ml10">[简答题]</span><span class="ml10"><%= exercise_question.question_score %></span>分</p>
<% if @exercise.exercise_status == 1 %>
<p class="fr exam_operator font-18">
<% if exercise_question.question_number < @exercise.exercise_questions.count %>
<% if exercise_question.question_number < @exercise.exercise_questions.where("question_type != 5").count %>
<a href="<%= update_question_num_exercise_path(@exercise, :ques_id => exercise_question.id, :opr => 'down') %>" data-remote="true" class="down_question"><i data-tip-down="下移" class="fa fa-arrow-circle-down mr10 color-orange05"></i></a>
<% end %>
<% unless exercise_question.question_number == 1 %>

@ -11,7 +11,7 @@
<!-- <a href="<%#= update_question_num_exercise_path(@exercise, :ques_id => exercise_question.id, :opr => 'up') %>" data-remote="true" class="up_question"><i data-tip-down="上移" class="fa fa-arrow-circle-up mr10 color-orange05"></i></a>-->
<%# end %>
<!-- <a href="javascript:void(0)" class="add_question" onclick="insert_SHIXUN(<%#=exercise_question.id%>,this);"><i data-tip-down="向下插入简答题" class="fa fa-plus-circle mr10 color-orange05"></i></a>-->
<!-- <a href="javascript:void(0)" onclick="delete_confirm_box('<%= delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number) %>', '确定要删除该题目吗?')"><i data-tip-down="删除" class="fa fa-times-circle mr10 color-orange05"></i></a>-->
<!-- <a href="javascript:void(0)" onclick="delete_confirm_box('<%#= delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number) %>', '确定要删除该题目吗?')"><i data-tip-down="删除" class="fa fa-times-circle mr10 color-orange05"></i></a>-->
<!-- <a href="javascript:void(0)" onclick="exQuestionEdit(<%#= exercise_question.id%>, <%#= exercise_question.question_type %>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a>-->
<!-- </p>-->
<%# end %>
@ -27,87 +27,60 @@
<!-- </li>-->
<%# end %>
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp" id="answer_Temp">
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp <%= @exercise.has_shixun_questions? ? '' : 'none' %>">
<div class="fl mt15 font-16 mb10 padding10 practicalTitlefont">
<span class="colorFF8121s">[实训题]</span>100分)
<span class="colorFF8121s">[实训题]</span><%= @exercise.shixun_question_score %>分)
<!-- 试卷列表不展示三个按钮-->
<i data-tip-down="编辑" class="fa fa-pencil color-orange05 fr mr10"></i>
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-orange05 fr"></i>
<i data-tip-down="向下插入实训题" class="fa fa-plus-circle mr10 color-orange05 fr"></i>
<% if @exercise.exercise_status == 1 %>
<a href="javascript:void(0)" onclick="shixunQuestionEdit();"><i data-tip-down="编辑" class="fa fa-pencil color-orange05 fr mr10"></i></a>
<a href="javascript:void(0)" onclick="delete_confirm_box('<%= delete_shixun_question_exercise_path(@exercise) %>', '确定要删除该题目吗?')">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-orange05 fr"></i>
</a>
<% end %>
</div>
<ul class="fl">
<% for i in 1..4 %>
<% questions_list = @exercise.exercise_questions.where(question_type: 5, level: i) %>
<ul class="fl" id="ul">
<li id="0">
<div class="fl font-16 mb10 practicalTitle">
<li class="<%= questions_list.try(:count).to_i > 0 ? '' : 'none' %>">
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">初级题</span>
<span class="Titlefont"><%= shixun_question_level i %></span>
<div class="fr mr40 shixun-title-font">
分值10 分/题
</div>
<div class="fr mr40 shixun-title-font width200">
随机出题量2
</div>
</div>
<div class="fl mb10 shixunsbox" id="shixunsbox0">
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<a class="white-btn orange-btn fr mr20 mt3" onclick="">+&nbsp;实训详情</a>
</span>
</div>
<div class="fr mr40 shixun-title-font">
分值:<%= @exercise.level_setting(i).try(:score) %> 分/题
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<a class="white-btn orange-btn fr mr20 mt3" onclick="">+&nbsp;实训详情</a>
</span>
<div class="fr mr40 shixun-title-font width200">
随机出题量:<%= @exercise.level_setting(i).try(:num) || questions_list.try(:count) %>
</div>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<a class="white-btn orange-btn fr mr20 mt3" onclick="">+&nbsp;实训详情</a>
</span>
<div class="fl mb10 shixunsbox">
<% questions_list.each_with_index do |question| %>
<div>
<span class="shixunsboxfont"><%= question.question_title %></span>
<span class="shixundelect">
<a href="<%= shixun_path(question.shixun) %>" class="white-btn orange-btn fr mr20 mt3" target="_blank">+&nbsp;实训详情</a>
</span>
</div>
<% end %>
</div>
</div>
</li>
</li>
<% end %>
</ul>
</div>
</div>
</div>
<!-- 新增问题 -->
<div id="insert_new_poll_question_<%=exercise_question.id%>">
</div>
<script type="text/javascript">
function insert_SHIXUN(quest_id,item){
var forms = $("form.new_exercise_question");
if($.trim($("#insert_new_poll_question_"+quest_id).html()) == "") {
if(forms.length > 0){
notice_box("请先保存正在编辑的题目再新建。");
} else {
$.get("/exercise/<%= @exercise.id %>/choose_shixuns?quest_id="+quest_id);
}
set_position(item);
} else {
$("#insert_new_poll_question_"+quest_id).html("");
}
}
<script>
function shixunQuestionEdit(){
$("#show_shixun_questions").hide();
$("#edit_shixun_questions").show();
}
</script>

@ -3,7 +3,7 @@
<p class="fl font-15">第<%= exercise_question.question_number%>题:<span class="color-orange03 ml10">[填空题]</span><span class="ml10"><%= exercise_question.question_score %></span>分</p>
<% if @exercise.exercise_status == 1 %>
<p class="fr exam_operator font-18">
<% if exercise_question.question_number < @exercise.exercise_questions.count %>
<% if exercise_question.question_number < @exercise.exercise_questions.where("question_type != 5").count %>
<a href="<%= update_question_num_exercise_path(@exercise, :ques_id => exercise_question.id, :opr => 'down') %>" data-remote="true" class="down_question"><i data-tip-down="下移" class="fa fa-arrow-circle-down mr10 color-orange05"></i></a>
<% end %>
<% unless exercise_question.question_number == 1 %>

@ -2,23 +2,30 @@
<div class="edu-con-top user_bg_shadow bor-grey-e color-grey clearfix mb20 font-12" style="display: <%= current_score[0] == 0 ? "none" : "" %>">
<p class="ml15 fl">
<% exercise_questions = @exercise.exercise_questions %>
<% if exercise_questions.select{|e| e.question_type==1}.count > 0 %>
<span class="mr20">单选题<span>&nbsp;<%= exercise_questions.select{|e| e.question_type==1}.count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[1] %>&nbsp;</span>分</span>
<% mc_count = exercise_questions.select{|e| e.question_type==1}.count %>
<% mcq_count = exercise_questions.select{|e| e.question_type==2}.count %>
<% single_count = exercise_questions.select{|e| e.question_type==3}.count %>
<% multi_count = exercise_questions.select{|e| e.question_type==4}.count %>
<% if mc_count > 0 %>
<span class="mr20">单选题<span>&nbsp;<%= mc_count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[1] %>&nbsp;</span>分</span>
<% end %>
<% if exercise_questions.select{|e| e.question_type==2}.count > 0 %>
<span class="mr20">多选题<span>&nbsp;<%= exercise_questions.select{|e| e.question_type==2}.count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[2] %>&nbsp;</span>分</span>
<% if mcq_count > 0 %>
<span class="mr20">多选题<span>&nbsp;<%= mcq_count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[2] %>&nbsp;</span>分</span>
<% end %>
<% if exercise_questions.select{|e| e.question_type==3}.count > 0 %>
<span class="mr20">填空题<span>&nbsp;<%= exercise_questions.select{|e| e.question_type==3}.count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[3] %>&nbsp;</span>分</span>
<% if single_count > 0 %>
<span class="mr20">填空题<span>&nbsp;<%= single_count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[3] %>&nbsp;</span>分</span>
<% end %>
<% if exercise_questions.select{|e| e.question_type==4}.count > 0 %>
<span class="mr20">简答题<span>&nbsp;<%= exercise_questions.select{|e| e.question_type==4}.count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[4] %>&nbsp;</span>分</span>
<% if multi_count > 0 %>
<span class="mr20">简答题<span>&nbsp;<%= multi_count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[4] %>&nbsp;</span>分</span>
<% end %>
<% if exercise_questions.select{|e| e.question_type==5}.count > 0 %>
<span>实训题<span>&nbsp;<%= exercise_questions.select{|e| e.question_type==5}.count %>&nbsp;</span>题,共<span>&nbsp;<%= current_score[5] %>&nbsp;</span>分</span>
<% if @exercise.shixun_question_count > 0 %>
<span>实训题<span>&nbsp;<%= @exercise.shixun_question_count %>&nbsp;</span>题,共<span>&nbsp;<%= @exercise.shixun_question_score %>&nbsp;</span>分</span>
<% end %>
</p>
<a class="fr mr15">
<span>合计<span class="color-orange03">&nbsp;<%= @exercise.exercise_questions.size %>&nbsp;</span>题,共<span class="color-orange03">&nbsp;<%= current_score[0] %>&nbsp;</span>分</span>
<% count = mc_count + mcq_count + single_count + multi_count + @exercise.shixun_question_count %>
<% score = current_score[1] + current_score[2] + current_score[3] + current_score[4] + @exercise.shixun_question_score %>
<span>合计<span class="color-orange03">&nbsp;<%= count %>&nbsp;</span>题,共<span class="color-orange03">&nbsp;<%= score %>&nbsp;</span>分</span>
</a>
</div>

@ -0,0 +1,2 @@
$("#exercise_question_list").html("<%= escape_javascript(render :partial => 'exercise/exercise_content') %>");
$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score') %>");

@ -1,6 +1,6 @@
<% if @exercise.exercise_questions.where("question_type = 5 and exercise_level_setting_id != 0").count > 0 %>
<% if @exercise.has_shixun_questions? %>
$("#insert_new_poll_question_<%= params[:quest_id] %>").html("<%= escape_javascript(render :partial => 'new_shixun', :locals => {:exercise=>@exercise}) %>");
$("#quest_id").val(<%= params[:quest_id] %>);
<% else %>
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_shixun', :locals => {:exercise=>@exercise}) %>");
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_shixun') %>");
<% end %>

@ -1049,6 +1049,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'cancel_commit_confirm'
get 'adjust_question_score'
post 'update_shixun_block'
get 'delete_shixun_question'
end
collection do #生成路径为 /exercise/方法名

Loading…
Cancel
Save