From f262a7cc1300e5c9e3d6ebae096a6ee469c7f2a0 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 22:05:31 +0800 Subject: [PATCH 01/21] cffd --- db/schema.rb | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 95f79b84b..912911185 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 => 20151120134208) do +ActiveRecord::Schema.define(:version => 20151120115137) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -241,6 +241,58 @@ ActiveRecord::Schema.define(:version => 20151120134208) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -539,7 +591,7 @@ ActiveRecord::Schema.define(:version => 20151120134208) do end create_table "exercise_questions", :force => true do |t| - t.text "question_title" + t.string "question_title" t.integer "question_type" t.integer "question_number" t.integer "exercise_id" @@ -568,7 +620,7 @@ ActiveRecord::Schema.define(:version => 20151120134208) do end create_table "exercises", :force => true do |t| - t.text "exercise_name" + t.string "exercise_name" t.text "exercise_description" t.integer "course_id" t.integer "exercise_status" From e89cb99743e1d8fa8984aa68474ac68964b103b3 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 Nov 2015 16:20:29 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E7=BB=93=E6=9E=9C=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- app/views/exercise/student_exercise_list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index d53dc067c..1598030a2 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -328,7 +328,7 @@ class ExerciseController < ApplicationController def student_exercise_list @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @exercise = Exercise.find params[:id] - @all_exercises = @course.exercises.order("created_at desc") + @all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc") @exercise_count = @exercise.exercise_users.where('score is not NULL').count if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S")) @exercise_users_list = @exercise.exercise_users.where('score is not NULL') diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 8653836ca..2e51d61af 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -73,7 +73,7 @@ '+ ''+ ' diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb index 66bbe8a6f..18ae79d1c 100644 --- a/app/views/exercise/_edit_MCQ.html.erb +++ b/app/views/exercise/_edit_MCQ.html.erb @@ -29,14 +29,12 @@
  • 分 - 标准答案:请选择
  • <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
  • - @@ -44,6 +42,11 @@
    <% end %>
  • +
  • + + +
  • +
    <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id, :quest_num => exercise_question.question_number), - - method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de",:title => "删除") %> + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
    @@ -54,11 +53,9 @@ '
  • '+ ''+ '分'+ - '标准答案:请选择'+ '
  • '+ '
  • '+ ''+ - ''+ ''+ ''+ ''+ @@ -66,7 +63,6 @@ '
    '+ '
  • '+ ''+ - ''+ ''+ ''+ ''+ @@ -74,7 +70,6 @@ '
    '+ '
  • '+ ''+ - ''+ ''+ ''+ ''+ @@ -82,12 +77,16 @@ '
    '+ '
  • '+ ''+ - ''+ ''+ ''+ ''+ '
  • '+ '
    '+ + '
  • '+ + ''+ + ''+ + '
  • '+ + '
    '+ ''+ ''+ ''+ ' @@ -16,8 +16,10 @@ <% if exercise.exercise_status == 1 %>
  • <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml5"%>
  • +
  • <%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%>
  • <% else%>
  • 编辑
  • +
  • 已发布
  • <% end%> <%# if exercise.exercise_status == 2 %> @@ -31,11 +33,6 @@ <%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> <%# end%> - - -
  • <%= format_date exercise.created_at.to_date%>
  • - - <% if exercise.exercise_status == 1 %>
  • 发布试卷
  • <% elsif exercise.exercise_status == 2%> @@ -59,5 +56,5 @@ <%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> <%#end%> <% end%> -
  • <%= format_date exercise.created_at.to_date%>
  • +
  • 截止时间:<%= format_time(exercise.end_time.to_s)%>
  • <% end%> \ No newline at end of file diff --git a/app/views/exercise/_exercises_list.html.erb b/app/views/exercise/_exercises_list.html.erb index f277ebdf5..89964f032 100644 --- a/app/views/exercise/_exercises_list.html.erb +++ b/app/views/exercise/_exercises_list.html.erb @@ -10,9 +10,9 @@
    - <% @exercises.each do |exercise|%> + <% @exercises.each_with_index do |exercise,index|%>
      - <%= render :partial => 'exercise', :locals => {:exercise => exercise} %> + <%= render :partial => 'exercise', :locals => {:exercise => exercise,:index => index} %>
    <% end%> From 5bdcdc607f1424a2e1064db32f3ccbbb34a5f214 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 26 Nov 2015 14:45:35 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise.html.erb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index d7a457047..ba82fbf82 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -12,16 +12,6 @@
    - <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> - - <% if exercise.exercise_status == 1 %> -
  • <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml5"%>
  • -
  • <%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%>
  • - <% else%> -
  • 编辑
  • -
  • 已发布
  • - <% end%> - <%# if exercise.exercise_status == 2 %> <%# else %> @@ -47,6 +37,16 @@
  • <%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fr mr10"%>
  • <% end%> + <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> + + <% if exercise.exercise_status == 1 %> +
  • <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml10"%>
  • +
  • <%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%>
  • + <% else%> +
  • 编辑
  • +
  • 已发布
  • + <% end%> + <% else%> <% if exercise.exercise_status == 2%> <%# if has_commit%> From b602e1c85d82af3774e6c4a6adf45d4d56976cae Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 26 Nov 2015 14:47:52 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E8=AF=95=E5=8D=B7=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_student.html.erb | 5 ++++- app/views/exercise/_exercise_student_result.html.erb | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 45d6ccf70..20b8a3d8c 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -42,7 +42,10 @@
    开始时间:<%=format_time(exercise_user.start_at.to_s)%> - 测验时长:<%=exercise.time %>分钟 + 截止时间:<%=format_time(exercise.end_time.to_s)%> + <% unless exercise.time == -1 %> + 测验时长:<%=exercise.time %>分钟 + <% end %> diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index b9306b0d2..8f6ac0e54 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -11,7 +11,10 @@

    <%= exercise.exercise_name%>

    开始时间:<%=format_time(exercise_user.start_at.to_s) %> - 测验时长:<%=exercise.time %>分钟 + 截止时间:<%=format_time(exercise.end_time.to_s)%> + <% unless exercise.time == -1 %> + 测验时长:<%=exercise.time %>分钟 + <% end %> <%# time = exercise_user.end_at - exercise_user.start_at %>
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    From ed9cef486febc212888880a8ec569e72e9298a84 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 26 Nov 2015 15:21:46 +0800 Subject: [PATCH 19/21] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=8C=89=E9=92=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 3 +++ app/views/exercise/_exercise.html.erb | 6 +++--- app/views/exercise/index.html.erb | 8 ++++---- app/views/exercise/publish_exercise.js.erb | 2 +- app/views/exercise/republish_exercise.js.erb | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 0b1a035c1..6066ef3d0 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -302,6 +302,7 @@ class ExerciseController < ApplicationController # 发布试卷 def publish_exercise @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @index = params[:index] @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save @@ -316,11 +317,13 @@ class ExerciseController < ApplicationController # 重新发布的时候会删除所有的答题 def republish_exercise @is_teacher = User.current.allowed_to?(:as_teacher,@course) + @index = params[:index] @exercise.exercise_questions.each do |exercise_question| exercise_question.exercise_answers.destroy_all end @exercise.exercise_users.destroy_all @exercise.exercise_status = 1 + @exercise.publish_time = nil @exercise.save respond_to do |format| format.js diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index ba82fbf82..91af83aee 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -8,7 +8,7 @@ <%# else %> <%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> <%# end %> - <%= link_to (index+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> + <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %>
    @@ -24,9 +24,9 @@ <%# end%> <% if exercise.exercise_status == 1 %> -
  • 发布试卷
  • +
  • 发布试卷
  • <% elsif exercise.exercise_status == 2%> -
  • 取消发布
  • +
  • 取消发布
  • <% else%>
  • 发布试卷
  • <% end%> diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index aacc79950..9b6961e6c 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -5,14 +5,14 @@ $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); }); - function republish_exercise(exercise_id) + function republish_exercise(exercise_id,index) { $('#ajax-modal').html("
    " + "
    " + "
    " + "

    取消发布后学生答题将会被清空
    是否确定取消发布该测验?

    " + "
    " + - "确  定" + + "确  定" + "取  消" + "
    " + "
    " + @@ -31,7 +31,7 @@ function clickCanel(){hideModal("#popbox02");} - function exercise_submit(exercise_id,exercise_name) + function exercise_submit(exercise_id,exercise_name,index) { if(exercise_name == 0) { @@ -44,7 +44,7 @@ "
    " + "

    测验发布后将不能对测验进行修改,
    是否确定发布该测验?

    " + "
    " + - "确  定" + + "确  定" + "取  消" + "
    " + "
    " + diff --git a/app/views/exercise/publish_exercise.js.erb b/app/views/exercise/publish_exercise.js.erb index ac2899402..c1c4a4fd5 100644 --- a/app/views/exercise/publish_exercise.js.erb +++ b/app/views/exercise/publish_exercise.js.erb @@ -1,4 +1,4 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index =>@index}) %>"); $('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); showModal('ajax-modal', '250px'); //$('#ajax-modal').css('height','111px'); diff --git a/app/views/exercise/republish_exercise.js.erb b/app/views/exercise/republish_exercise.js.erb index b7172fe9e..2b4e67606 100644 --- a/app/views/exercise/republish_exercise.js.erb +++ b/app/views/exercise/republish_exercise.js.erb @@ -1,4 +1,4 @@ -$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise,:index => @index}) %>"); $('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); showModal('ajax-modal', '250px'); //$('#ajax-modal').css('height','80px'); From f8621cac76b3e00baeadc30843019d54723373cf Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 26 Nov 2015 16:57:51 +0800 Subject: [PATCH 20/21] =?UTF-8?q?=E6=9C=AA=E8=AE=BE=E7=BD=AE=E8=80=83?= =?UTF-8?q?=E8=AF=95=E6=97=B6=E9=95=BF=E6=97=B6=EF=BC=8C=E5=8F=AA=E8=A6=81?= =?UTF-8?q?=E8=BF=98=E6=9C=AA=E5=88=B0=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=B0=B1=E5=8F=AF=E4=BB=A5=E4=B8=80=E7=9B=B4=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E8=AF=95=E5=8D=B7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 19 ++++++++++----- app/views/exercise/_commit_alert.html.erb | 5 +++- app/views/exercise/_exercise.html.erb | 2 +- app/views/exercise/_exercise_form.html.erb | 6 ++--- app/views/exercise/_exercise_student.html.erb | 23 ++++++++++++------- .../_exercise_student_result.html.erb | 10 ++++---- app/views/exercise/_exercise_teacher.html.erb | 4 ++-- app/views/exercise/_show_head.html.erb | 4 ++-- app/views/exercise/commit_exercise.js.erb | 2 +- public/stylesheets/courses.css | 1 + 10 files changed, 47 insertions(+), 29 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 6066ef3d0..d4050da18 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -34,17 +34,24 @@ class ExerciseController < ApplicationController render_403 return end - @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? + exercise_end = Time.parse(format_time(@exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") + if @exercise.time == -1 + @can_edit_excercise = exercise_end + else + @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin? + end @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first # 学生点击的时候即创建关联,自动保存 #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) # 已提交问卷的用户不能再访问该界面 +=begin if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) respond_to do |format| format.html {render :layout => 'base_courses'} end else +=end if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first @@ -55,7 +62,7 @@ class ExerciseController < ApplicationController respond_to do |format| format.html {render :layout => 'base_courses'} end - end + #end end def new @@ -82,7 +89,7 @@ class ExerciseController < ApplicationController exercise ||= Exercise.new exercise.exercise_name = params[:exercise][:exercise_name] exercise.exercise_description = params[:exercise][:exercise_description] - exercise.end_time = params[:exercise][:end_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.user_id = User.current.id exercise.time = params[:exercise][:time] @@ -107,7 +114,7 @@ class ExerciseController < ApplicationController @exercise.exercise_name = params[:exercise][:exercise_name] @exercise.exercise_description = params[:exercise][:exercise_description] @exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time] - @exercise.end_time = params[:exercise][:end_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] if @exercise.save @@ -351,8 +358,8 @@ class ExerciseController < ApplicationController # 学生提交答卷,选中答案的过程中提交 def commit_answer eq = ExerciseQuestion.find(params[:exercise_question_id]) - # 已提交过的则不允许答题 - if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) + # 已提交过的且是限时的则不允许答题 + if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) && @exercise.time != -1 render :json => {:text => "failure"} return end diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb index d92ca51fb..a21dbd2a7 100644 --- a/app/views/exercise/_commit_alert.html.erb +++ b/app/views/exercise/_commit_alert.html.erb @@ -1,7 +1,10 @@
    - <% if status == 0 %> + <% if status == 0 && exercise.time != -1 %>

    提交成功!您的分数是:<%=@score %>分。

    <%= link_to "确定", exercise_path(),:class => 'commit'%> + <% elsif status == 0 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") %> +

    提交成功!

    + <%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%> <% elsif status == 1 %>

    您还有尚未作答的题目请完成后再提交!

    <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index 91af83aee..db412672c 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -53,7 +53,7 @@ <%#else%> - <%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> + <%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> <%#end%> <% end%>
  • 截止时间:<%= format_time(exercise.end_time.to_s)%>
  • diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 8de4dac38..e283f8b0c 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -136,14 +136,14 @@ alert("测验标题不能为空"); } else if($.trim($("#exercise_end_time").val()) =="") { alert("截止时间不能为空"); - } else if(Date.parse($("#exercise_end_time").val()) < Date.now()) { + } else if((Date.parse($("#exercise_end_time").val())+(24*60*60-1)*1000) < Date.now()) { alert("截止时间不能小于当前时间"); } else if($.trim($("#exercise_time").val()) !="" && !/^[1-9][0-9]*$/.test($.trim($("#exercise_time").val()))) { alert("测验时长必须为非零开头的数字"); } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_publish_time").val()) < Date.now()) { alert("发布时间不能小于当前时间"); - } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) <= Date.parse($("#exercise_publish_time").val())) { - alert("截止时间必须大于发布时间"); + } else if($.trim($("#exercise_publish_time").val()) !="" && Date.parse($("#exercise_end_time").val()) < Date.parse($("#exercise_publish_time").val())) { + alert("截止时间不能小于发布时间"); } else { doc.parent().parent().parent().submit(); } diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 20b8a3d8c..7010407ce 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,6 +3,8 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); + end_time = <%=exercise.end_time.to_i%> + getTime(end_time); /*start_time = new Date(); start_time.setFullYear(<%#=exercise_user.start_at.year%>); start_time.setMonth(<%#=exercise_user.start_at.month%>); @@ -17,11 +19,16 @@ function getTime(end_time) { //alert(end_time); now = new Date(); - var total_seconds = (now.getTime() - end_time)/1000; + var total_seconds = now.getTime()/1000 - end_time; + if (total_seconds < 0) { + $("#exercise_submit_btn").click(); + return; + } + setTimeout("getTime("+end_time+");", 1000); //start = new Date(start_time); //end_time = start_time; //var total_seconds = total_seconds - 1; - var hours = total_seconds / 60 / 60; + /*var hours = total_seconds / 60 / 60; var hoursRound = Math.floor(hours); var minutes = total_seconds /60 - (60 * hoursRound); var minutesRound = Math.floor(minutes); @@ -29,9 +36,9 @@ var secondsRound = Math.round(seconds); $("#rest_hours").html(hoursRound); $("#rest_minutes").html(minutesRound); - $("#rest_seconds").html(secondsRound); + $("#rest_seconds").html(secondsRound);*/ //if(total_seconds >0) { - setTimeout("getTime("+end_time+");", 1000); + //setTimeout("getTime("+end_time+");", 1000); //} } @@ -41,8 +48,8 @@

    <%= exercise.exercise_name%>

    - 开始时间:<%=format_time(exercise_user.start_at.to_s)%> - 截止时间:<%=format_time(exercise.end_time.to_s)%> + 开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S")%> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%> <% unless exercise.time == -1 %> 测验时长:<%=exercise.time %>分钟 <% end %> @@ -194,7 +201,7 @@ } - > + >
    @@ -202,7 +209,7 @@ <% end %>
    - <%= link_to l(:button_submit),commit_exercise_exercise_path(exercise), :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %> + <%= link_to l(:button_submit),commit_exercise_exercise_path(exercise),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
    diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 8f6ac0e54..3445d6986 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -10,8 +10,8 @@

    <%= exercise.exercise_name%>

    - 开始时间:<%=format_time(exercise_user.start_at.to_s) %> - 截止时间:<%=format_time(exercise.end_time.to_s)%> + 开始时间:<%=Time.parse(h(exercise_user.start_at)).strftime("%Y-%m-%d %H:%M:%S") %> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S")%> <% unless exercise.time == -1 %> 测验时长:<%=exercise.time %>分钟 <% end %> @@ -34,7 +34,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %> + <% if !answer.empty? && !standard_answer.empty? && answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %> √ <% else %> × @@ -73,7 +73,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %> + <% if !standard_answer.empty? && get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %> √ <% else %> × @@ -112,7 +112,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if standard_answer.include?(answer.first.answer_text) %> + <% if !answer.empty? && !standard_answer.empty? && standard_answer.include?(answer.first.answer_text) %> √ <% else %> × diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 0a96b782b..6e00fc41d 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -11,9 +11,9 @@

    <%= exercise.exercise_name%>

    <% unless exercise.publish_time.nil? %> - 发布时间:<%=format_time(exercise.publish_time.to_s) %> + 发布时间:<%=Time.parse(h(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") %> <% end %> - 截止时间:<%=format_time(exercise.end_time.to_s) %> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") %> <% if exercise.time != -1 %> 测验时长:<%=exercise.time %>分钟 <% end %> diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index 16a572583..f385e58b8 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -4,9 +4,9 @@

    <%= exercise.exercise_name%>

    <% unless exercise.publish_time.nil? %> - 发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%> + 发布时间:<%=Time.parse(h(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%> <% end %> - 截止时间:<%=Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %> + 截止时间:<%=Time.parse(h(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %> <% if exercise.time != -1 %> 测验时长:<%= exercise.time %>分钟 <% end %> diff --git a/app/views/exercise/commit_exercise.js.erb b/app/views/exercise/commit_exercise.js.erb index 2a40df2a5..5ede8a951 100644 --- a/app/views/exercise/commit_exercise.js.erb +++ b/app/views/exercise/commit_exercise.js.erb @@ -1,4 +1,4 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>'); showModal('ajax-modal', '270px'); $('#ajax-modal').css('height','110px'); $('#ajax-modal').siblings().remove(); diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index b7a742994..17ed37e05 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1166,4 +1166,5 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;} .questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;} .fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;} .mr130 {margin-right:130px;} +.mr100 {margin-right:100px;} .ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; } \ No newline at end of file From dec5980443be5de596bf04892dcc57908afd8593 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 26 Nov 2015 17:20:17 +0800 Subject: [PATCH 21/21] =?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=B8=80=E5=88=B0=E7=AB=8B=E5=8D=B3=E6=8F=90=E4=BA=A4=E8=AF=95?= =?UTF-8?q?=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_commit_alert.html.erb | 7 +++++-- app/views/exercise/_exercise_student.html.erb | 2 +- app/views/exercise/_exercise_student_result.html.erb | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb index a21dbd2a7..23aee5a90 100644 --- a/app/views/exercise/_commit_alert.html.erb +++ b/app/views/exercise/_commit_alert.html.erb @@ -1,5 +1,5 @@
    - <% if status == 0 && exercise.time != -1 %> + <% if status == 0 && exercise.time != -1%>

    提交成功!您的分数是:<%=@score %>分。

    <%= link_to "确定", exercise_path(),:class => 'commit'%> <% elsif status == 0 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") %> @@ -8,8 +8,11 @@ <% elsif status == 1 %>

    您还有尚未作答的题目请完成后再提交!

    <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> - <% else %> + <% elsif status == 2 %>

    发生未知错误,请检查您的网络。

    <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% else %> +

    时间已到!您的分数是:<%=@score %>分。

    + <%= link_to "确定", exercise_path(),:class => 'commit'%> <% end %>
    diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 7010407ce..a5c0f2a46 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -20,7 +20,7 @@ //alert(end_time); now = new Date(); var total_seconds = now.getTime()/1000 - end_time; - if (total_seconds < 0) { + if (total_seconds > 0) { $("#exercise_submit_btn").click(); return; } diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 3445d6986..93e52b0a1 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -39,7 +39,7 @@ <% else %> × <% end %>
    - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
    @@ -117,7 +117,7 @@ <% else %> × <% end %>
    - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>