From e13bb9316f858024cacda4b35be9bb1c2416163b Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 29 Sep 2017 15:55:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E3=80=81=E4=B8=8A=E4=B8=8B=E7=A7=BB=E5=8A=A8=E3=80=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=AD=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 61 ++++---- app/views/exercise/_edit_head.html.erb | 4 +- app/views/exercise/_edu_edit_form.html.erb | 65 +++----- app/views/exercise/_exercise_content.html.erb | 90 ++++------- app/views/exercise/_exercises_list.html.erb | 2 +- app/views/exercise/_new_MC.html.erb | 9 +- app/views/exercise/_new_MCQ.html.erb | 11 +- app/views/exercise/_new_head.html.erb | 2 +- app/views/exercise/_new_multi.html.erb | 5 +- app/views/exercise/_new_single.html.erb | 9 +- app/views/exercise/_show_MC.html.erb | 146 +++--------------- app/views/exercise/_show_MCQ.html.erb | 145 +++-------------- app/views/exercise/_show_head.html.erb | 2 +- app/views/exercise/_show_multi.html.erb | 98 ++---------- app/views/exercise/_show_single.html.erb | 117 ++------------ .../exercise/_total_questions_score.html.erb | 18 ++- .../exercise/create_exercise_question.js.erb | 10 +- .../exercise/delete_exercise_question.js.erb | 6 +- app/views/exercise/edit.html.erb | 1 + app/views/exercise/update_question_num.js.erb | 6 +- config/routes.rb | 2 +- public/javascripts/edu/course.js | 25 ++- public/stylesheets/css/edu-class.css | 2 + 23 files changed, 227 insertions(+), 609 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 6a52fa961..534a2fdc2 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -188,17 +188,14 @@ class ExerciseController < ApplicationController option = { :question_title => question_title, :question_type => params[:question_type] || 1, - :question_number => params[:question_type] == "1"? @exercise.exercise_questions.where("question_type = 1").count + 1 : - (params[:question_type] == "2" ? (@exercise.exercise_questions.where("question_type = 2").count + 1) : - (params[:question_type] == "3" ? (@exercise.exercise_questions.where("question_type = 3").count + 1) : - @exercise.exercise_questions.where("question_type = 4").count + 1)), + :question_number => @exercise.exercise_questions.count + 1, :question_score => params[:question_score] } @exercise_questions = @exercise.exercise_questions.new option # params[:question_answer] 题目选项 if params[:question_answer] for i in 1..params[:question_answer].count - answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + answer = params[:question_answer][i-1] question_option = { :choice_position => i, :choice_text => answer @@ -207,20 +204,23 @@ class ExerciseController < ApplicationController end end # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 - if params[:quest_id] + if params[:quest_id] != "0" @is_insert = true - if @exercise_questions.question_type == 1 - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number + 1") - #@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1") - elsif @exercise_questions.question_type == 2 - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number + 1") - elsif @exercise_questions.question_type == 3 - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number + 1") - else - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 4).update_all(" question_number = question_number + 1") + insert_que = ExerciseQuestion.find params[:quest_id] + if insert_que + @exercise.exercise_questions.where("question_number>?",insert_que.question_number).update_all("question_number = question_number + 1") + # if @exercise_questions.question_type == 1 + # ExerciseQuestion.where("question_number>?",params[:quest_num].to_i).update_all(" question_number = question_number + 1") + # elsif @exercise_questions.question_type == 2 + # ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number + 1") + # elsif @exercise_questions.question_type == 3 + # ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number + 1") + # else + # ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 4).update_all(" question_number = question_number + 1") + # end + # @exercise_question_num = params[:quest_num].to_i + @exercise_questions.question_number = insert_que.question_number + 1 end - # @exercise_question_num = params[:quest_num].to_i - @exercise_questions.question_number = params[:quest_num].to_i + 1 end if @exercise_questions.save # params[:exercise_choice] 标准答案参数 @@ -229,7 +229,7 @@ class ExerciseController < ApplicationController for i in 1..params[:exercise_choice].count standart_answer = ExerciseStandardAnswer.new standart_answer.exercise_question_id = @exercise_questions.id - standart_answer.answer_text = params[:exercise_choice].values[i-1] + standart_answer.answer_text = params[:exercise_choice][i-1] standart_answer.save end elsif @exercise_questions.question_type == 4 @@ -337,16 +337,17 @@ class ExerciseController < ApplicationController @exercise_question = ExerciseQuestion.find params[:exercise_question] @exercise = @exercise_question.exercise - if @exercise_question.question_type == 1 - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number - 1") - #@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1") - elsif @exercise_question.question_type == 2 - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number - 1") - elsif @exercise_question.question_type == 3 - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1") - else - ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 4).update_all(" question_number = question_number - 1") - end + ExerciseQuestion.where("question_number>?",params[:quest_num].to_i).update_all("question_number = question_number - 1") + # if @exercise_question.question_type == 1 + # ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number - 1") + # #@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1") + # elsif @exercise_question.question_type == 2 + # ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number - 1") + # elsif @exercise_question.question_type == 3 + # ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1") + # else + # ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 4).update_all(" question_number = question_number - 1") + # end # @exercise_question_num = params[:quest_num].to_i # @exercise_questions.question_number = params[:quest_num].to_i - 1 # @@ -368,12 +369,12 @@ class ExerciseController < ApplicationController exercise_questions = @exercise.exercise_questions if @exercise_question if params[:opr] == 'up' && @exercise_question.question_number > 1 - @before_que = exercise_questions.where("question_type = #{@exercise_question.question_type} and question_number = #{@exercise_question.question_number - 1}").first + @before_que = exercise_questions.where("question_number = #{@exercise_question.question_number - 1}").first if @before_que && @exercise_question.update_attribute('question_number', @exercise_question.question_number - 1) @before_que.update_attribute('question_number', @before_que.question_number + 1) end elsif params[:opr] == 'down' && @exercise_question.question_number < exercise_questions.count - @after_que = exercise_questions.where("question_type = #{@exercise_question.question_type} and question_number = #{@exercise_question.question_number + 1}").first + @after_que = exercise_questions.where("question_number = #{@exercise_question.question_number + 1}").first if @after_que && @exercise_question.update_attribute('question_number', @exercise_question.question_number + 1) @after_que.update_attribute('question_number', @after_que.question_number - 1) end diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index 487900208..1aa23f3d8 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -6,7 +6,7 @@

- 保存 - 取消 + 保存 + 取消

<% end %> \ No newline at end of file diff --git a/app/views/exercise/_edu_edit_form.html.erb b/app/views/exercise/_edu_edit_form.html.erb index 83c684cec..1a26bafeb 100644 --- a/app/views/exercise/_edu_edit_form.html.erb +++ b/app/views/exercise/_edu_edit_form.html.erb @@ -14,22 +14,14 @@ +
+ <%= render :partial => "exercise/total_questions_score" %> +
+
- - - - - - - - - - - - - - - + <% if is_edit %> + <%= render :partial => "exercise/exercise_content" %> + <% end %>
@@ -44,7 +36,7 @@
  • - +
  • @@ -52,7 +44,7 @@ @@ -60,23 +52,11 @@ -
    -

    - 单选题 3 题,共 15  - 多选题 5 题,共 25  - 填空题 10 题,共 25  - 简答题 10 题,共 25  -

    - - 合计 10 题,共 100  - -
    - \ No newline at end of file diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 4e54ec274..70bebd42a 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -7,6 +7,7 @@

    多选题

    +
    @@ -18,21 +19,21 @@ - +
  • - +
  • - +
  • @@ -44,7 +45,7 @@
  • <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - +

    温馨提示:[多选题]属于客观题将由系统自动评分,请设置标准答案 @@ -58,7 +59,7 @@ \ No newline at end of file diff --git a/app/views/exercise/_new_head.html.erb b/app/views/exercise/_new_head.html.erb index b7387d6ea..d651b3d0d 100644 --- a/app/views/exercise/_new_head.html.erb +++ b/app/views/exercise/_new_head.html.erb @@ -12,6 +12,6 @@

  • - 保存 + 保存

    <% end %> \ No newline at end of file diff --git a/app/views/exercise/_new_multi.html.erb b/app/views/exercise/_new_multi.html.erb index 688ed9da6..2ed014967 100644 --- a/app/views/exercise/_new_multi.html.erb +++ b/app/views/exercise/_new_multi.html.erb @@ -6,6 +6,7 @@

    简答题

    +
  • @@ -17,7 +18,7 @@
  • <% score = exercise.exercise_questions.where("question_type=4").last.nil? ? "": exercise.exercise_questions.where("question_type=4").last.question_score %> - +

    温馨提示:[简答题]属于主观题需要人工评分,未作答的情况下系统将自动评分 @@ -32,7 +33,7 @@ \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 7f781cba8..a92b7a7ae 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -7,17 +7,18 @@

    填空题

  • +
  • - +
  • - +
  • @@ -27,7 +28,7 @@
  • <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - +

    温馨提示:[填空题]属于客观题将由系统自动评分,请设置标准答案 @@ -41,7 +42,7 @@ \ No newline at end of file diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index ec260c45d..dde727bca 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -2,159 +2,55 @@

    第<%= exercise_question.question_number%>题:[单选题]<%= exercise_question.question_score %>

    - - - - - + <% if exercise_question.question_number < @exercise.exercise_questions.count %> + + <% end %> + <% unless exercise_question.question_number == 1 %> + + <% end %> + + +

    -

    <%= exercise_question.question_title %>

    +
    <%= exercise_question.question_title %>
    <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> -
  • +
  • + + +
  • <% end %>
    标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
    -<% if false%> -
    -
    -
    - 第<%= exercise_question.question_number%>题.  <%= exercise_question.question_score %>分   - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> - -
    -
    -

    <%= exercise_question.question_title %>

    -
    -
    - - - <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> - - - - <% end %> - -
    - -
    -
    -
    - <% end %> -
    +
    \ No newline at end of file diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index 26d8f5e94..d02c0b9ba 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -2,17 +2,24 @@

    第<%= exercise_question.question_number%>题:[多选题]<%= exercise_question.question_score %>

    - - - - - + <% if exercise_question.question_number < @exercise.exercise_questions.count %> + + <% end %> + <% unless exercise_question.question_number == 1 %> + + <% end %> + + +

    -

    <%= exercise_question.question_title %>

    +
    <%= exercise_question.question_title %>
    <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> -
  • +
  • + + +
  • <% end %>
    @@ -20,132 +27,20 @@
    -<% if false %> -
    -
    -
    - 第<%= exercise_question.question_number%>题.  <%= exercise_question.question_score %>分   - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> - -
    -
    -

    <%= exercise_question.question_title %>

    -
    - -
    - - - <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> - - - - <% end %> - -
    - -
    -
    -
    - -<% end %> - -
    +
    \ No newline at end of file diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index e411bce95..a392bce81 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -4,7 +4,7 @@
    -
    <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description).html_safe%>
    +
    <%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description).html_safe%>
    \ No newline at end of file diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 229123398..39520d7de 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -2,124 +2,39 @@

    第<%= exercise_question.question_number%>题:[填空题]<%= exercise_question.question_score %>

    - - - - - + <% if exercise_question.question_number < @exercise.exercise_questions.count %> + + <% end %> + <% unless exercise_question.question_number == 1 %> + + <% end %> + + +

    -

    <%= exercise_question.question_title %>

    +
    <%= exercise_question.question_title %>
    <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>

    候选答案<%= convert_to_chi_num(index+1) %>:<%= exercise_choice.answer_text%>

    <% end %>
    -<% if false %> -
    -
    -
    - 第<%= exercise_question.question_number%>题.  <%= exercise_question.question_score %>分 - -
    -
    -

    <%= exercise_question.question_title %>

    -
    -
    - <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> - 参考答案<%= convert_to_chi_num(index+1) %>:<%= exercise_choice.answer_text%>
    - <% end %> -
    -
    -<% end %> -
    +
    \ No newline at end of file diff --git a/app/views/exercise/_total_questions_score.html.erb b/app/views/exercise/_total_questions_score.html.erb index bd6bc291a..6119a820a 100644 --- a/app/views/exercise/_total_questions_score.html.erb +++ b/app/views/exercise/_total_questions_score.html.erb @@ -1,8 +1,12 @@ -
    " id="current_score_div"> - 单选题 <%= exercise.exercise_questions.where("question_type=1").count %> 题,共<%= current_score[1] %>分 - 多选题 <%= exercise.exercise_questions.where("question_type=2").count %> 题,共<%= current_score[2] %>分 - 填空题 <%= exercise.exercise_questions.where("question_type=3").count %> 题,共<%= current_score[3] %>分 - 问答题 <%= exercise.exercise_questions.where("question_type=4").count %> 题,共<%= current_score[4] %>分 - 合计 <%= exercise.exercise_questions.count %> 题,共<%= current_score[0] %> -
    +<% current_score = get_current_score @exercise %> +
    "> +

    + 单选题 <%= @exercise.exercise_questions.where("question_type=1").count %> 题,共 <%= current_score[1] %>  + 多选题 <%= @exercise.exercise_questions.where("question_type=2").count %> 题,共 <%= current_score[2] %>  + 填空题 <%= @exercise.exercise_questions.where("question_type=3").count %> 题,共 <%= current_score[3] %>  + 简答题 <%= @exercise.exercise_questions.where("question_type=4").count %> 题,共 <%= current_score[4] %>  +

    + + 合计 <%= @exercise.exercise_questions.count %> 题,共 <%= current_score[0] %>  +
    \ No newline at end of file diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index af1b1af56..41510a199 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,8 +1,6 @@ <% if @is_insert %> - $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); - $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); - <% current_score = get_current_score @exercise %> - $("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score}) %>"); + $("#exercise_question_list").html("<%= escape_javascript(render :partial => 'exercise/exercise_content') %>"); + $("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score') %>"); <% else %> $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); $("#new_poll_question").html(""); @@ -48,7 +46,5 @@ "
    " + "
    "); <% end %> -$("#total_questions_score").show(); -<% current_score = get_current_score @exercise %> -$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score}) %>"); +$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score') %>"); <% end %> diff --git a/app/views/exercise/delete_exercise_question.js.erb b/app/views/exercise/delete_exercise_question.js.erb index 0d20f1ccb..88e8297d2 100644 --- a/app/views/exercise/delete_exercise_question.js.erb +++ b/app/views/exercise/delete_exercise_question.js.erb @@ -1,5 +1,3 @@ hideModal(); -$("#poll_content").html("<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise}) %>"); -<% current_score = get_current_score @exercise %> -$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score', :locals => {:exercise => @exercise, :current_score => current_score}) %>"); -$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file +$("#exercise_question_list").html("<%= escape_javascript(render :partial => 'exercise/exercise_content') %>"); +$("#total_questions_score").html("<%= escape_javascript(render :partial => 'exercise/total_questions_score') %>"); \ No newline at end of file diff --git a/app/views/exercise/edit.html.erb b/app/views/exercise/edit.html.erb index db0cef611..18b73f51d 100644 --- a/app/views/exercise/edit.html.erb +++ b/app/views/exercise/edit.html.erb @@ -7,6 +7,7 @@

    编辑试卷

    <%= link_to "返回", student_exercise_list_exercise_path(@exercise), :class => "fr font-12 color-grey mr15 mt5" %> + <%= link_to "设置", setting_exercise_path(@exercise), :class => "fr font-12 mr15 mt5 color-grey" %>
    <%= render :partial => "exercise/edu_edit_form", :locals => {:is_edit => true} %> diff --git a/app/views/exercise/update_question_num.js.erb b/app/views/exercise/update_question_num.js.erb index 4a3bef3f9..d1284e659 100644 --- a/app/views/exercise/update_question_num.js.erb +++ b/app/views/exercise/update_question_num.js.erb @@ -7,7 +7,7 @@ <% elsif @before_que.question_type == 3%> $("#show_poll_questions_<%= @before_que.id %>").html("<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @before_que}) %>"); <% elsif @before_que.question_type == 4%> - $("#show_poll_questions_<%= @before_que.id %>").html("<%= escape_javascript(render :partial => 'show_mulit', :locals => {:exercise_question => @before_que}) %>"); + $("#show_poll_questions_<%= @before_que.id %>").html("<%= escape_javascript(render :partial => 'show_multi', :locals => {:exercise_question => @before_que}) %>"); <% end%> <% elsif @after_que %> $("#poll_questions_<%= @exercise_question.id%>").insertAfter($("#poll_questions_<%= @after_que.id%>")); @@ -18,7 +18,7 @@ <% elsif @after_que.question_type == 3%> $("#show_poll_questions_<%= @after_que.id %>").html("<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @after_que}) %>"); <% elsif @after_que.question_type == 4%> - $("#show_poll_questions_<%= @after_que.id %>").html("<%= escape_javascript(render :partial => 'show_mulit', :locals => {:exercise_question => @after_que}) %>"); + $("#show_poll_questions_<%= @after_que.id %>").html("<%= escape_javascript(render :partial => 'show_multi', :locals => {:exercise_question => @after_que}) %>"); <% end%> <% end %> <% if @exercise_question.question_type == 1%> @@ -28,5 +28,5 @@ <% elsif @exercise_question.question_type == 3%> $("#show_poll_questions_<%= @exercise_question.id %>").html("<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_question}) %>"); <% elsif @exercise_question.question_type == 4%> - $("#show_poll_questions_<%= @exercise_question.id %>").html("<%= escape_javascript(render :partial => 'show_mulit', :locals => {:exercise_question => @exercise_question}) %>"); + $("#show_poll_questions_<%= @exercise_question.id %>").html("<%= escape_javascript(render :partial => 'show_multi', :locals => {:exercise_question => @exercise_question}) %>"); <% end%> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ea06c7764..e659931c4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -527,7 +527,7 @@ RedmineApp::Application.routes.draw do post 'create_exercise_question' post 'commit_answer' get 'commit_exercise' - post 'update_question_num' + get 'update_question_num' post 'send_to_course' get 'get_student_uncomplete_question' post 'edit_question_score' diff --git a/public/javascripts/edu/course.js b/public/javascripts/edu/course.js index aa271bbdf..67072ab97 100644 --- a/public/javascripts/edu/course.js +++ b/public/javascripts/edu/course.js @@ -652,7 +652,7 @@ function ex_setting_form_submit(){ } //添加标题时确定按钮 -function add_poll_question(doc,quest_type) +function add_ex_question(doc,quest_type) { var title = $.trim($("#poll_questions_title").val()); var score = $.trim($("#question_score").val()); @@ -660,24 +660,24 @@ function add_poll_question(doc,quest_type) if(title.length == 0 || score.length == 0){ notice_box("题目标题/分数不能为空"); doc.one('click', function(){ - add_poll_question($(this),quest_type); + add_ex_question($(this),quest_type); }); }else if(!/^[1-9][0-9]*$/.test(score)) { notice_box("分数必须是非零开头的数字"); doc.one('click', function(){ - add_poll_question($(this),quest_type); + add_ex_question($(this),quest_type); }); }else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) { notice_box("标准答案不能为空"); doc.one('click', function(){ - add_poll_question($(this),quest_type); + add_ex_question($(this),quest_type); }); }else{ doc.parent().parent().parent().parent().submit(); } } -function pollsSubmit(doc){ +function ex_head_submit(doc){ var title = $.trim($("#exercise_name").val()); if(title.length == 0){ notice_box("试卷标题不能为空"); @@ -686,7 +686,20 @@ function pollsSubmit(doc){ } } -function pollsCancel(){ +function ex_head_cancel(){ $("#exercise_head_edit").hide(); $("#exercise_head_show").show(); +} + +function exQuestionEdit(question_id){ + var forms = $("form.new_exercise_question"); + if($.trim($("#insert_new_poll_question_"+question_id).html()) == "") { + if(forms.length > 0){ + notice_box("请先保存正在编辑的题目再新建。"); + } else{ + $("#show_poll_questions_"+question_id).hide(); + $("#edit_poll_questions_"+question_id).show(); + $("#poll_questions_title_"+question_id).focus(); + } + } } \ No newline at end of file diff --git a/public/stylesheets/css/edu-class.css b/public/stylesheets/css/edu-class.css index b4ab73fce..43d2c6c32 100644 --- a/public/stylesheets/css/edu-class.css +++ b/public/stylesheets/css/edu-class.css @@ -404,3 +404,5 @@ a.uploadIcon {width:100px; height:33px;color:#ffffff;} /*课堂改版*/ .sy_member_div:hover{background:#EFF2F7;} .real-name:hover,.operation:hover{color: #FF9e6a!important;} +/*试卷*/ +pre.exercise_que_title{font-family: '微软雅黑','宋体';white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:pre-wrap;white-space:-o-pre-wrap;word-break:normal;word-wrap: break-word;}