diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 4dff2c56..c5ea5ba4 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -179,9 +179,11 @@ class ExerciseController < ApplicationController ex_question = @exercise.exercise_questions.where(shixun_id: shixun.id).first if ex_question.present? ex_question.update_attributes(question_score: params[:ques_scores][index]) + ex_question.exercise_shixun_challenges.update_all(question_score: params[:ques_scores][index]) else ex_question = ExerciseQuestion.create(exercise_id: @exercise.id, question_score: arams[:ques_scores][index], - shixun_id: shixun.id, question_title: shixun.name, question_type: 5, question_number: 0) + shixun_id: shixun.id, question_title: shixun.name, question_type: 5, + question_number: 0, exercise_level_setting_id: level_setting.id) shixun.challenges.each_with_index do |challenge, index| ex_shixun_challenge = ExerciseShixunChallenge.new(challenge_id: challenge.id, shixun_id: shixun.id, exercise_question_id: ex_question.id, question_score: params[:ques_scores][index], position: index + 1) @@ -206,9 +208,7 @@ class ExerciseController < ApplicationController if exercise.save create_exercises_list exercise @exercise = exercise - respond_to do |format| - format.js - end + redirect_to edit_exercise_path(@exercise) end end end diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index b0ebedcf..ea5eae8f 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -1,5 +1,18 @@ # encoding: utf-8 module ExerciseHelper + def shixun_question_level level + case level + when 1 + "初级题" + when 2 + "中级题" + when 3 + "高级题" + when 4 + "顶级题" + end + end + def exercise_shixun_json_data shixuns shixuns.map do |shixun| shixun_owner = shixun.owner.try(:show_name) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index a8452df0..c5992382 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -51,4 +51,8 @@ class Exercise < ActiveRecord::Base pluck(:exercise_question_id)) end end + + def level_setting level + self.exercise_level_settings.where(level: level).first + end end diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb index 7ef70650..e9915c5b 100644 --- a/app/views/exercise/_exercise_content.html.erb +++ b/app/views/exercise/_exercise_content.html.erb @@ -1,4 +1,4 @@ -<% @exercise.exercise_questions.each do |eq| %> +<% @exercise.exercise_questions.where("question_type != 5").each do |eq| %> <div id='poll_questions_<%= eq.id %>' class="exercise_question"> <% case eq.question_type %> <% when 1 %> diff --git a/app/views/exercise/_new_head.html.erb b/app/views/exercise/_new_head.html.erb index 3f80bf40..377ee8a1 100644 --- a/app/views/exercise/_new_head.html.erb +++ b/app/views/exercise/_new_head.html.erb @@ -4,7 +4,7 @@ :action => 'create', :course_id => @course.id }, - :method => :post, :remote => true) do |f| %> + :method => :post) do |f| %> <div class="ml15 mr15 mb15"> <input class="panel-box-sizing panel-form-width-100" name="exercise[exercise_name]" maxlength="100" id="exercise_name" value="<%= @exercise.try(:exercise_name) %>" placeholder="试卷标题" style="text-align: center;"/> </div> diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb index e14a94f6..2543b893 100644 --- a/app/views/exercise/_new_question.html.erb +++ b/app/views/exercise/_new_question.html.erb @@ -6,7 +6,9 @@ <a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_MCQ();">+ 多选题</a> <a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_single();">+ 填空题</a> <a href="javascript:void(0);" class="fl mr20 add_item_part" onclick="add_multi();">+ 简答题</a> -<a href="javascript:void(0);" class="fl add_item_part" onclick="add_shixun();">+ 实训题</a> +<% if @exercise.try(:id).nil? || @exercise.exercise_questions.where(question_type: 5).count == 0 %> + <a href="javascript:void(0);" class="fl add_item_part" onclick="add_shixun();">+ 实训题</a> +<% end %> <div id="hidden_div_block" class="undis"> <textarea style="display: none" id="hidden_textarea"></textarea> diff --git a/app/views/exercise/_new_shixun.html.erb b/app/views/exercise/_new_shixun.html.erb index 36a7789b..1f0de51c 100644 --- a/app/views/exercise/_new_shixun.html.erb +++ b/app/views/exercise/_new_shixun.html.erb @@ -2,7 +2,7 @@ <div nhname="new_exercise_mc_q"> <%= form_for(ExerciseQuestion.new, :html => { :multipart => true, :id => "new_exercise_question"}, - :url=>create_exercise_question_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">--> @@ -39,63 +39,69 @@ <% 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" id="shixun_question_block"> <div class="fl mt15 font-16 mb10 padding10 practicalTitlefont">实训题</div> + <% second_questions = @exercise.level_setting(2).try(:exercise_questions) %> + <% third_questions = @exercise.level_setting(3).try(:exercise_questions) %> + <% fourth_questions = @exercise.level_setting(4).try(:exercise_questions) %> + + <% for i in 1..5 %> + <% questions_list = @exercise.level_setting(i).try(:exercise_questions) %> + <div class="<%= questions_list.try(:count).to_i > 0 ? '' : 'none' %>" id="edit_first_block"> + <div class="fl font-16 mb10 practicalTitle"> + + <span class="Titlefont"><%= shixun_question_level i %></span> + + <div class="fr mr40 shixun-title-font"> + <span class="color-red mr5 shixun-title-font">*</span>分值:<input class="borderFF8121" value=""/> 分/题 + <div class="colorFF8121sum">*大于等于0,且不能大于100</div> + <div class="colorFF8121sum">*不能为空</div> + <div class="colorFF8121sum">*必须大于等于0</div> + <div class="colorFF8121sum">*不能大于100</div> + </div> + + <div class="fr mr40 shixun-title-font"> + <span class="color-red mr5 shixun-title-font">*</span> + 随机出题量:<input class="borderFF8121"/> 题 + <div class="colorFF8121">*不能为空</div> + <div class="colorFF8121">*必须为正整数</div> + <div class="colorFF8121">*不能大于可用题数</div> + </div> + + <div class="fr mr40 shixun-title-font"> + <span class="color-orange mr5 shixun-title-font">3</span> + 题可用 + </div> + </div> + <div class="fl mb10 shixunsbox"> - <div class="fl font-16 mb10 practicalTitle"> - - <span class="Titlefont">初级题</span> - - <div class="fr mr40 shixun-title-font"> - <span class="color-red mr5 shixun-title-font">*</span>分值:<input class="borderFF8121"/> 分/题 - <div class="colorFF8121sum">*大于等于0,且不能大于100</div> - <div class="colorFF8121sum">*不能为空</div> - <div class="colorFF8121sum">*必须大于等于0</div> - <div class="colorFF8121sum">*不能大于100</div> - </div> - - <div class="fr mr40 shixun-title-font"> - <span class="color-red mr5 shixun-title-font">*</span> - 随机出题量:<input class="borderFF8121"/> 题 - <div class="colorFF8121">*不能为空</div> - <div class="colorFF8121">*必须为正整数</div> - <div class="colorFF8121">*不能大于可用题数</div> - </div> - - <div class="fr mr40 shixun-title-font"> - <span class="color-orange mr5 shixun-title-font">3</span> - 题可用 - </div> - - </div> - - <div class="fl mb10 shixunsbox"> - - <div> - <a class="shixunsboxfont">命令加密ZPI压缩文件解压</a> - <span class="shixundelect"> + <div> + <a class="shixunsboxfont">命令加密ZPI压缩文件解压</a> + <span class="shixundelect"> <i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i> </span> - </div> + </div> - <div> - <a class="shixunsboxfont">命令加密ZPI压缩文件解压</a> - <span class="shixundelect"> + <div> + <a class="shixunsboxfont">命令加密ZPI压缩文件解压</a> + <span class="shixundelect"> <i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i> </span> - </div> + </div> - <div> - <a class="shixunsboxfont">命令加密ZPI压缩文件解压</a> - <span class="shixundelect"> + <div> + <a class="shixunsboxfont">命令加密ZPI压缩文件解压</a> + <span class="shixundelect"> <i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i> </span> - </div> + </div> - </div> + </div> + </div> + <% end %> <div class="fl mb10 shixunsboxs"> <div class="newshixunbox"> diff --git a/app/views/exercise/_new_shixun_exercise_list.html.erb b/app/views/exercise/_new_shixun_exercise_list.html.erb index 6ae106b8..8d841bdb 100644 --- a/app/views/exercise/_new_shixun_exercise_list.html.erb +++ b/app/views/exercise/_new_shixun_exercise_list.html.erb @@ -61,7 +61,7 @@ if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) { msg_list_loading = true; - $.getJSON("<%= choose_shixuns_exercise_path(@exercise) %>&page="+page, function(json) { + $.getJSON("<%= choose_shixuns_exercise_path(@exercise) %>?page="+page, function(json) { if (json) { msg_list_loading = false; var str = "";