From c33bf1b1637096d6a65f8aed3a694280c58f1573 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 1 Dec 2016 15:42:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E5=A4=B4=E9=83=A8=E5=92=8C?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=A2=98=E7=9B=AE=E7=9A=84=E6=94=B9=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 +- app/helpers/exercise_helper.rb | 39 +++++++++ app/views/exercise/_edit_head.html.erb | 14 ++-- app/views/exercise/_exercise_form.html.erb | 61 +++++++++++--- app/views/exercise/_new_MC.html.erb | 80 +++++++++---------- app/views/exercise/_new_MCQ.html.erb | 53 ++++++------ app/views/exercise/_new_question.html.erb | 6 +- app/views/exercise/_new_single.html.erb | 16 ++-- app/views/exercise/_show_head.html.erb | 9 ++- .../20161129084352_add_column_to_exercises.rb | 6 ++ db/schema.rb | 8 +- public/stylesheets/css/courses.css | 7 ++ 12 files changed, 201 insertions(+), 102 deletions(-) create mode 100644 db/migrate/20161129084352_add_column_to_exercises.rb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 02a8400a7..02ee909b7 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -132,7 +132,9 @@ class ExerciseController < ApplicationController @exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time] @exercise.end_time = Time.at(params[:exercise][:end_time].to_time.to_i + 16*60*60 -1) @exercise.publish_time = params[:exercise][:publish_time] - @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result] + @exercise.show_result = params[:show_result].blank? ? 1 : params[:show_result] + @exercise.question_random = params[:question_random] + @exercise.choice_random = params[:choice_random] if @exercise.save respond_to do |format| format.js diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 6dadf92b5..47fccefff 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -175,4 +175,43 @@ module ExerciseHelper standard_answer end + # 问题随机的下拉列表 + def question_random_select + type = [] + option1 = [] + option1 << "题目不随机打乱" + option1 << 0 + type << option1 + option2 = [] + option2 << "题目随机打乱" + option2 << 1 + type << option2 + end + + # 选项随机的下拉列表 + def choice_random_select + type = [] + option1 = [] + option1 << "选项不随机打乱" + option1 << 0 + type << option1 + option2 = [] + option2 << "选项随机打乱" + option2 << 1 + type << option2 + end + + #允许学生查看结果的下拉列表 + def show_result_select + type = [] + option1 = [] + option1 << "允许学生查看测验结果" + option1 << 1 + type << option1 + option2 = [] + option2 << "不允许学生查看测验结果" + option2 << 0 + type << option2 + end + end \ No newline at end of file diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index a071904ce..e23f3134a 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -16,13 +16,13 @@
- diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index cb41cf26b..c2c01ac25 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -168,17 +168,55 @@ $("#edit_poll_questions_"+question_id).show(); $("#poll_questions_title_"+question_id).focus(); } - //单选题 - function add_single_answer(doc) - { - var li = doc.parent().after("
  • " + - ""+ - "
  • "); - var select_items =$("label[name='select_items']",li.parent()); - for(var i=0; i:   "); + // 选项的选择 + function toggle_select(doc, type){ + if(doc.hasClass("question_choice_blue")){ + doc.removeClass("question_choice_blue").addClass("question_choice_white"); + if(type == "1"){ + $("#question_standard_answer").html("请点击选项"); + $("#exercise_choice").val(""); + }else{ + var eles = doc.parent().parent().find("a.question_choice_blue"); + var str = ""; + if(eles.length > 0){ + for(var i=0; i" + + ""+ + "
    "); + var select_items =$("li.new_answer",li.parent()); + li.prev().prev().find("a.question_choice_white").html(String.fromCharCode(64 + select_items.length)); + doc.prev("a.question_choice_dash").html(String.fromCharCode(64 + select_items.length + 1)); + } function add_candidate_answer(doc) { doc.parent().after("
  • " + @@ -214,10 +252,11 @@ { var parent = doc.parent().parent(); doc.parent().remove(); - var select_items =$("label[name='select_items']",parent); + + var select_items =$("li.ur_item",parent); var candiate_items =$("label[name='candiate_items']",parent); for(var i=0; i:   "); + $(select_items[i]).find("a.choice_btn").html(String.fromCharCode(64 + parseInt(i+1))); } for(var i=0; i:   "); diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 054285825..6ebf3bd40 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -3,6 +3,14 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> + + 分 + 请点击选项 + 标准答案: +
    +
    @@ -10,52 +18,44 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> - - 分 -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • -
      -
    • - - - - -
    • + +
    • + A + + +
    • +
      +
    • + B + + +
    • +
      +
    • + C + + +
    • +
      +
    • + D + + +
    • +
      +
    • + E +
      新建选项
      +
    • +
      -
    • - - -
    • -
    diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index d8dbf0adb..965772051 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -3,6 +3,14 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> + + 分 + 请点击选项 + 标准答案: +
    +
    @@ -10,52 +18,43 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - - 分 -
    • -
      -
    • - - - + +
    • + A +
    • -
    • - - - +
    • + B +
    • -
    • - - - +
    • + C +
    • -
    • - - - +
    • + D +
    • - - + E +
      新建选项
    • -
      +
    diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb index faadb08a9..23aae4cb3 100644 --- a/app/views/exercise/_new_question.html.erb +++ b/app/views/exercise/_new_question.html.erb @@ -14,7 +14,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } @@ -26,7 +26,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } @@ -38,7 +38,7 @@ alert("请先保存正在编辑的题目再新建。"); } else{ $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single', :locals => {:exercise=>exercise}) %>"); - $("#poll_questions_title").focus(); + $("#question_score").focus(); } } diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index d0fce87c8..669a1b8db 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -3,6 +3,12 @@ :url=>create_exercise_question_exercise_path(exercise.id), :remote=>true ) do |f| %>
    +
    + <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> + + 分 +
    +
    @@ -10,12 +16,6 @@
      -
    • - <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - - 分 -
    • -
    • @@ -42,8 +42,8 @@
    diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index 4cc5a6cf8..b59eb11c7 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -1,5 +1,5 @@ -
    - +
    +

    <%= exercise.exercise_name%>

    @@ -12,5 +12,10 @@ <% end %>
    <%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>
    +
    \ No newline at end of file diff --git a/db/migrate/20161129084352_add_column_to_exercises.rb b/db/migrate/20161129084352_add_column_to_exercises.rb new file mode 100644 index 000000000..ea3d01667 --- /dev/null +++ b/db/migrate/20161129084352_add_column_to_exercises.rb @@ -0,0 +1,6 @@ +class AddColumnToExercises < ActiveRecord::Migration + def change + add_column :exercises, :question_random, :integer, :default => 0 + add_column :exercises, :choice_random, :integer, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index bd3645e2c..9109f785d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20161128072528) do +ActiveRecord::Schema.define(:version => 20161129084352) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -820,11 +820,13 @@ ActiveRecord::Schema.define(:version => 20161128072528) do t.integer "exercise_status" t.integer "user_id" t.integer "time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "publish_time" t.datetime "end_time" t.integer "show_result" + t.integer "question_random", :default => 0 + t.integer "choice_random", :default => 0 end create_table "first_pages", :force => true do |t| diff --git a/public/stylesheets/css/courses.css b/public/stylesheets/css/courses.css index 91a22a177..7ea9346cc 100644 --- a/public/stylesheets/css/courses.css +++ b/public/stylesheets/css/courses.css @@ -604,3 +604,10 @@ a:hover.ex_icon_edit{ background:url(/images/course/icons.png) -21px -276px no- .archive_course_notice {width:220px; position:absolute; padding:5px 10px; white-space:nowrap; background-color:#fff; right:-265px; top:-15px; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);} .archive_course_notice em {display:block; border-width:10px; position:absolute;top:26px; left:-20px; border-style:dashed solid dashed dashed; border-color:transparent #eaeaea transparent transparent; font-size:0; line-height:0;} .archive_course_notice span {display:block; border-width:10px; position:absolute;top:26px; left:-18px; border-style:dashed solid dashed dashed; border-color:transparent #fff transparent transparent; font-size:0; line-height:0;} + +/* 新版测验 */ +.blue_select{ background: #3b94d6; font-size: 12px; color: #fff; padding: 5px 10px;} +.grey_select{ background: #c3c3c3; font-size: 12px; color: #fff; padding: 5px 10px;} +a.question_choice_white{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a.question_choice_blue{ background: #3b94d6; color: #fff; width: 34px; height: 30px; border: 1px solid #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +.question_choice_dash{ background: #fff; color: #000000; width: 34px; height: 30px; border: 1px dashed #ddd; text-align: center; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} \ No newline at end of file