From f262a7cc1300e5c9e3d6ebae096a6ee469c7f2a0 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 22:05:31 +0800 Subject: [PATCH 01/33] 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 9b033c3adfa8513face966c10e19f65b32de7d8a Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 Nov 2015 10:08:51 +0800 Subject: [PATCH 02/33] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/db/schema.rb b/db/schema.rb index 95f79b84b..8b018ecd7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 From e89cb99743e1d8fa8984aa68474ac68964b103b3 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 Nov 2015 16:20:29 +0800 Subject: [PATCH 03/33] =?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 @@
    <% @all_exercises.each_with_index do |exercise,index |%>
  • - <%= link_to "作业#{@all_exercises.count - index}:#{exercise.exercise_name}",''%> + <%= link_to "测验#{@all_exercises.count - index}:#{exercise.exercise_name}",student_exercise_list_exercise_path(exercise.id,:course_id => @course.id)%> <%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
  • <% end%> From 0e7cf4b122c7df17684b1a80b8efd08227453ab2 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 Nov 2015 16:21:25 +0800 Subject: [PATCH 04/33] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=89=B9=E6=AC=A1=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=B7=B2=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9ad46cd69..3c60fcaed 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -76,7 +76,7 @@ class StudentWorkController < ApplicationController end ################################################################################################################## @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] - @homework_commons = @course.homework_commons.order("created_at desc") + @homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc") @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评 @show_all = false From 1ae514ca4857d7e2ad53b338731c1e01f899fb4d Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 25 Nov 2015 09:38:13 +0800 Subject: [PATCH 05/33] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E7=9A=84=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=A5=E6=9C=9F=E5=92=8C=E6=B5=8B=E9=AA=8C=E6=97=B6?= =?UTF-8?q?=E9=95=BF=E5=81=9A=E6=88=90=E5=8F=AF=E9=80=89=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 5 +- app/views/exercise/_edit_head.html.erb | 17 +++--- app/views/exercise/_exercise_form.html.erb | 60 +++++++++---------- app/views/exercise/_exercise_teacher.html.erb | 8 ++- app/views/exercise/_show_head.html.erb | 9 ++- public/stylesheets/courses.css | 2 +- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 1598030a2..6fcbb0c6c 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -65,7 +65,6 @@ class ExerciseController < ApplicationController :end_time => "", :publish_time => "", :exercise_description => "", - :show_result => "", :show_result => 1 } @exercise = Exercise.create option @@ -104,10 +103,10 @@ class ExerciseController < ApplicationController def update @exercise.exercise_name = params[:exercise][:exercise_name] @exercise.exercise_description = params[:exercise][:exercise_description] - @exercise.time = params[:exercise][:time] + @exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time] @exercise.end_time = params[:exercise][:end_time] @exercise.publish_time = params[:exercise][:publish_time] - @exercise.show_result = params[:exercise][:show_result] + @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result] if @exercise.save respond_to do |format| format.js diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index 3090cc2c5..6c357130c 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -6,18 +6,17 @@ <%# if edit_mode %> <%# end %> -
    - " > - <%= calendar_for('exercise_publish_time')%> -
    - <%# if edit_mode %> - - <%# end %> +
    - " > + "/> <%= calendar_for('exercise_end_time')%>
    -
    测验时长:分钟
    +
    测验时长:分钟
    + +
    + "/> + <%= calendar_for('exercise_publish_time')%> +
'+ ''+ ' 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 18/33] =?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 19/33] =?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 20/33] =?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 21/33] =?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 22/33] =?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 %>
    From 1f2675020b88e93ffb09b3126d6604889eb93762 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 27 Nov 2015 10:15:25 +0800 Subject: [PATCH 23/33] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E6=88=90=E6=97=B6=E5=8F=AF=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E8=AF=95=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 44 +++++++++++-------- app/helpers/exercise_helper.rb | 13 ++++++ app/views/exercise/_commit_alert.html.erb | 9 ++-- app/views/exercise/_exercise_student.html.erb | 23 +++++++++- app/views/exercise/_exercise_teacher.html.erb | 2 +- 5 files changed, 66 insertions(+), 25 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index d4050da18..0a95fd025 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -359,7 +359,7 @@ 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?) && @exercise.time != -1 + if (has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) && @exercise.time != -1) || Time.parse(format_time(@exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") < Time.now.strftime("%Y-%m-%d %H:%M:%S") render :json => {:text => "failure"} return end @@ -376,8 +376,14 @@ class ExerciseController < ApplicationController ea.exercise_choice_id = params[:exercise_choice_id] if ea.save # 保存成功返回成功信息及当前以答题百分比 + uncomplete_question = get_uncomplete_question(@exercise, User.current) + if uncomplete_question.count < 1 + complete = 1; + else + complete = 0; + end @percent = get_percent(@exercise,User.current) - render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)} + render :json => {:text => "ok" ,:complete => complete,:percent => format("%.2f" ,@percent)} else #返回失败信息 render :json => {:text => "failure"} @@ -392,8 +398,14 @@ class ExerciseController < ApplicationController ea.exercise_question_id = params[:exercise_question_id] ea.exercise_choice_id = params[:exercise_choice_id] if ea.save + uncomplete_question = get_uncomplete_question(@exercise, User.current) + if uncomplete_question.count < 1 + complete = 1; + else + complete = 0; + end @percent = get_percent(@exercise,User.current) - render :json => {:text => "ok",:percent => format("%.2f" ,@percent)} + render :json => {:text => "ok",:complete => complete,:percent => format("%.2f" ,@percent)} else render :json => {:text => "failure"} end @@ -422,8 +434,14 @@ class ExerciseController < ApplicationController ea.exercise_question_id = params[:exercise_question_id] ea.answer_text = params[:answer_text] if ea.save + uncomplete_question = get_uncomplete_question(@exercise, User.current) + if uncomplete_question.count < 1 + complete = 1; + else + complete = 0; + end @percent = get_percent(@exercise,User.current) - render :json => {:text => ea.answer_text,:percent => format("%.2f",@percent)} + render :json => {:text => ea.answer_text,:complete => complete,:percent => format("%.2f",@percent)} else render :json => {:text => "failure"} end @@ -513,7 +531,7 @@ class ExerciseController < ApplicationController exercise_qustions.each do |question| answer = get_user_answer(question, user) standard_answer = get_user_standard_answer(question, user) - unless answer.nil? + unless answer.empty? # 问答题有多个答案 if question.question_type == 3 if standard_answer.include?(answer.first.answer_text) @@ -555,19 +573,6 @@ class ExerciseController < ApplicationController eu end - #获取未完成的题目 - def get_uncomplete_question exercise,user - all_questions = exercise.exercise_questions - uncomplete_question = [] - all_questions.each do |question| - answers = get_user_answer(question, user) - if answers.nil? - uncomplete_question << question - end - end - uncomplete_question - end - # 获取当前学生回答问题的答案 def get_user_answer(question,user) # user_answer = ExerciseAnswer.where("user_id=? and exercise_question_id=?", user.id, question.id).first @@ -586,7 +591,8 @@ class ExerciseController < ApplicationController standard_answer = question.exercise_standard_answers.first end standard_answer - end # 是否完成了答题 + end + # 是否完成了答题 def get_complete_question(exercise,user) questions = exercise.exercise_questions complete_question = [] diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index bb87f3b82..b0d0118e5 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -107,6 +107,19 @@ module ExerciseHelper end end + #获取未完成的题目 + def get_uncomplete_question exercise,user + all_questions = exercise.exercise_questions + uncomplete_question = [] + all_questions.each do |question| + answers = get_user_answer(question, user) + if answers.empty? + uncomplete_question << question + end + end + uncomplete_question + end + #获取文本题答案 def get_anwser_vote_text(question_id,user_id) pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id) diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb index 23aee5a90..e9c3ebf57 100644 --- a/app/views/exercise/_commit_alert.html.erb +++ b/app/views/exercise/_commit_alert.html.erb @@ -5,9 +5,12 @@ <% 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'%> + <% elsif status == 1 && 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 && 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_path(),:class => 'commit'%> <% elsif status == 2 %>

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

    <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index a5c0f2a46..adaab5021 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,7 +3,11 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); - end_time = <%=exercise.end_time.to_i%> + <%uncomplete_question =get_uncomplete_question(exercise, User.current) %>; + <% if (uncomplete_question.count < 1) %> + $("#exercise_submit_btn").html("提交"); + <% end %> + var end_time = <%=exercise.end_time.to_i%>; getTime(end_time); /*start_time = new Date(); start_time.setFullYear(<%#=exercise_user.start_at.year%>); @@ -100,6 +104,11 @@ { obj.checked = false; } + if(dataObj.complete == 1) { + $("#exercise_submit_btn").html("提交"); + } else { + $("#exercise_submit_btn").html("保存"); + } } }); } @@ -154,6 +163,11 @@ { obj.checked = false; } + if(dataObj.complete == 1) { + $("#exercise_submit_btn").html("提交"); + } else { + $("#exercise_submit_btn").html("保存"); + } } }); } @@ -196,6 +210,11 @@ success: function (data) { var dataObj = eval(data); obj.value = dataObj.text; + if(dataObj.complete == 1) { + $("#exercise_submit_btn").html("提交"); + } else { + $("#exercise_submit_btn").html("保存"); + } } }); @@ -209,7 +228,7 @@ <% end %>
    - <%= 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 %> + <%= link_to "保存",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_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 6e00fc41d..24687d28b 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -96,7 +96,7 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分)
    - 标准答案:<%= 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%>
    From 2d14b66336007ab94e483b81e71dfbb4122f5d16 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 27 Nov 2015 10:56:46 +0800 Subject: [PATCH 24/33] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student_work/_student_work_list.html.erb | 102 +++++++++--------- public/stylesheets/courses.css | 2 +- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index c18ec4c73..e9b056c84 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -1,52 +1,52 @@ -
    - - 作品 - - (<%= @student_work_count%>人已交) - - <% if !@is_teacher && @stundet_works.empty?%> - 您尚未提交作品 - <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> - 您已提交且不可再修改,因为截止日期已过 - <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> - 您已提交,您还可以修改 - <% end %> - - <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> -
    - - -
    - <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> - <% end%> - -
    -
    - -
    - <% if @is_evaluation && !@stundet_works.empty?%> - <%= render :partial => "evaluation_title"%> - <% else%> - <%= render :partial => "evaluation_un_title"%> - <% end%> -
    -
    - -<% @stundet_works.each do |student_work|%> - <% if @is_evaluation%> - <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> - <% else%> - <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> - <% end%> -
    -
    - <% if student_work.user == User.current && !@is_evaluation %> - <% if @homework.homework_type == 2%> - <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> - <% else %> - <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> - <% end %> - <% end %> -
    -
    +
    + + 作品 + + (<%= @student_work_count%>人已交) + + <% if !@is_teacher && @stundet_works.empty?%> + 您尚未提交作品 + <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + 您已提交且不可再修改,因为截止日期已过 + <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + 您已提交,您还可以修改 + <% end %> + + <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> +
    + + +
    + <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> + <% end%> + +
    +
    + +
    + <% if @is_evaluation && !@stundet_works.empty?%> + <%= render :partial => "evaluation_title"%> + <% else%> + <%= render :partial => "evaluation_un_title"%> + <% end%> +
    +
    + +<% @stundet_works.each do |student_work|%> + <% if @is_evaluation%> + <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> + <% else%> + <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> + <% end%> +
    +
    + <% if student_work.user == User.current && !@is_evaluation %> + <% if @homework.homework_type == 2%> + <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% else %> + <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% end %> + <% end %> +
    +
    <% end%> \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 17ed37e05..faffee4d1 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -60,7 +60,7 @@ a:hover.news_foot{ color:#787b7e; border:1px solid #d4d4d4;} .hworkStName {width:60px; max-width:60px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} .hworkStID {width:80px; max-width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} .hworkDate {max-width:150px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:14px; line-height:14px; font-size:12px; color:#888888;} -.hworkMenu {width:100px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-110px; font-size:12px; color:#888888; display:none; line-height:2;} +.hworkMenu {width:100px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-110px; font-size:12px; color:#888888; display:none; line-height:2; z-index:99;} a.hworkExport {background:url(../images/homepage_icon2.png) -10px -401px no-repeat; padding-left:23px;} a.hworkSetting {background:url(../images/homepage_icon2.png) -10px -450px no-repeat; padding-left:23px;} .hworkInfor {font-size:12px; color:#269ac9; width:80px; height:40px; vertical-align:middle; float:left; line-height:40px; text-align:center; font-weight:bold;} From f7ac2b0ef5e67b8bb8aa48b7bc8953455c5a6eb5 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 27 Nov 2015 15:19:13 +0800 Subject: [PATCH 25/33] =?UTF-8?q?=E8=80=81=E5=B8=88=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=9A=84=E7=AD=94=E5=8D=B7=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 29 +++++++++++++++---- app/views/exercise/_edit_head.html.erb | 5 ++-- app/views/exercise/_exercise_form.html.erb | 2 +- .../_exercise_student_result.html.erb | 20 ++++++------- app/views/exercise/_show_head.html.erb | 3 +- app/views/exercise/_student_exercise.html.erb | 8 ++++- app/views/exercise/show.html.erb | 2 +- .../exercise/show_student_result.html.erb | 1 + config/routes.rb | 1 + public/stylesheets/courses.css | 4 +-- 10 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 app/views/exercise/show_student_result.html.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 0a95fd025..6d6d429b6 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise,:show_student_result] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] include ExerciseHelper @@ -34,7 +34,7 @@ class ExerciseController < ApplicationController render_403 return end - 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") + exercise_end = @exercise.end_time > Time.now if @exercise.time == -1 @can_edit_excercise = exercise_end else @@ -59,6 +59,9 @@ class ExerciseController < ApplicationController # @percent = get_percent(@exercise,User.current) exercise_questions = @exercise.exercise_questions @exercise_questions = paginateHelper exercise_questions,5 #分页 + score = calculate_student_score(@exercise, User.current) + eu = get_exercise_user(@exercise.id, User.current.id) + eu.update_attributes(:score => score) respond_to do |format| format.html {render :layout => 'base_courses'} end @@ -342,10 +345,10 @@ class ExerciseController < ApplicationController @exercise = Exercise.find params[:id] @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")) + if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time <= Time.now) @exercise_users_list = @exercise.exercise_users.where('score is not NULL') @show_all = true; - elsif !@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") + elsif !@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time > Time.now @exercise_users_list = @exercise.exercise_users.where("user_id = ? and score is not NULL",User.current.id) else @exercise_users_list = [] @@ -359,7 +362,7 @@ 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?) && @exercise.time != -1) || Time.parse(format_time(@exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") < Time.now.strftime("%Y-%m-%d %H:%M:%S") + if (has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) && @exercise.time != -1) || @exercise.end_time < Time.now render :json => {:text => "failure"} return end @@ -483,7 +486,7 @@ class ExerciseController < ApplicationController @exercise.update_attributes(:publish_time => Time.now) redirect_to exercise_url(@exercise) return - elsif Time.parse(@exercise.publish_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S") + elsif @exercise.publish_time > Time.now @exercise.update_attributes(:show_result => params[:show_result]) redirect_to exercise_url(@exercise) return @@ -521,6 +524,20 @@ class ExerciseController < ApplicationController end end + #查看学生的答卷情况 + def show_student_result + @user = User.find params[:user_id] + @can_edit_excercise = false + @exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first + @exercise_questions = @exercise.exercise_questions + score = calculate_student_score(@exercise, @user) + eu = get_exercise_user(@exercise.id, @user.id) + eu.update_attributes(:score => score) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end + # 计算学生得分 def calculate_student_score(exercise, user) score = 0 diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index c8ba0c4d7..b69f52a56 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -30,10 +30,11 @@ \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index e283f8b0c..f0bef74bf 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -9,7 +9,7 @@ var popWindow ; //弹出框的引用 var importPollPopWindow; //选择导入的弹出框引用 function edit_head(){ - $("#polls_description").val($("#polls_description_div").html()); + $("#exercise_description").val($("#exercise_description_div").html()); } $(function(){ //点击空白处 diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 93e52b0a1..529a73da3 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -32,8 +32,8 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% answer = get_user_answer(exercise_question, User.current)%> - <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% answer = get_user_answer(exercise_question, user)%> + <% standard_answer = get_user_standard_answer(exercise_question, user)%> <% if !answer.empty? && !standard_answer.empty? && answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %> √ <% else %> @@ -49,7 +49,7 @@ @@ -71,9 +71,9 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% answer = get_user_answer(exercise_question, User.current)%> - <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if !standard_answer.empty? && get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %> + <% answer = get_user_answer(exercise_question, user)%> + <% standard_answer = get_user_standard_answer(exercise_question, user)%> + <% if !standard_answer.empty? && get_mulscore(exercise_question, user).to_i == standard_answer.first.exercise_choice_id %> √ <% else %> × @@ -88,7 +88,7 @@ @@ -110,8 +110,8 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% answer = get_user_answer(exercise_question, User.current)%> - <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% answer = get_user_answer(exercise_question, user)%> + <% standard_answer = get_user_standard_answer(exercise_question, user)%> <% if !answer.empty? && !standard_answer.empty? && standard_answer.include?(answer.first.answer_text) %> √ <% else %> @@ -126,7 +126,7 @@ <% end %>
    - > + >
    diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index f385e58b8..cfa814c2e 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -11,7 +11,6 @@ 测验时长:<%= exercise.time %>分钟 <% end %>
    -
    <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
    -
    +
    <%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>
    \ No newline at end of file diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb index 25bf3f7cd..4e27d57cb 100644 --- a/app/views/exercise/_student_exercise.html.erb +++ b/app/views/exercise/_student_exercise.html.erb @@ -44,7 +44,13 @@
    • - <%= exercise.user.show_name%> + <% name = exercise.user.show_name %> + <% if Time.parse(h(@exercise.end_time)).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S") %> + <%= link_to name,show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %> + <% else %> + <%=name%> + <%#= link_to name,'',:title=>"截止日期未到,暂不能查看学生答题结果。" %> + <% end %>
    • <%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%> diff --git a/app/views/exercise/show.html.erb b/app/views/exercise/show.html.erb index f47710d1c..c488ec203 100644 --- a/app/views/exercise/show.html.erb +++ b/app/views/exercise/show.html.erb @@ -5,6 +5,6 @@ <% if @can_edit_excercise %> <%=render :partial => 'exercise_student', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user} %> <% else %> - <%=render :partial => 'exercise_student_result', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user} %> + <%=render :partial => 'exercise_student_result', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user,:user=>User.current} %> <% end %> <% end %> \ No newline at end of file diff --git a/app/views/exercise/show_student_result.html.erb b/app/views/exercise/show_student_result.html.erb new file mode 100644 index 000000000..6b32a0dd0 --- /dev/null +++ b/app/views/exercise/show_student_result.html.erb @@ -0,0 +1 @@ +<%=render :partial => 'exercise_student_result', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user,:user =>@user} %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d137553ad..cbff8558f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -168,6 +168,7 @@ RedmineApp::Application.routes.draw do get 'export_exercise' get 'publish_exercise' get 'republish_exercise' + get 'show_student_result' post 'create_exercise_question' post 'commit_answer' post 'commit_exercise' diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 17ed37e05..25ba6e488 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1166,5 +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 +.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; } +.font_cus {font-family: "微软雅黑","宋体"; font-size: 12px; line-height: 1.5;} \ No newline at end of file From 3abc3f7af0c226137edf7c69893b385275d8e75c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 27 Nov 2015 15:25:49 +0800 Subject: [PATCH 26/33] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E7=BC=96=E8=BE=91=EF=BC=8C=E8=BF=94=E5=9B=9E=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_document_comments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 776bd132d..02527bdfc 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -39,7 +39,7 @@ class OrgDocumentCommentsController < ApplicationController end respond_to do |format| format.html { - if params[:flag] == 0 + if params[:flag].to_i == 0 redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id) else redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) From e3e0f4ab3798cb2f84e6845e5a3b22c5d661cccd Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 27 Nov 2015 16:00:43 +0800 Subject: [PATCH 27/33] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=A7=BB=E5=8A=A8+?= =?UTF-8?q?=E5=8F=B7=E6=98=BE=E7=A4=BA=E7=95=99=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_tool_expand.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb index 9a36b8efb..e032496ea 100644 --- a/app/views/courses/_tool_expand.html.erb +++ b/app/views/courses/_tool_expand.html.erb @@ -30,7 +30,7 @@ <% if show_nav?(course_feedback_count) %> <% end %> <% if show_nav?(course_poll_count) %> From 89d01679a7fe1301632fcecac25bf503c7c28981 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 27 Nov 2015 16:27:23 +0800 Subject: [PATCH 28/33] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=9A=84=E9=A1=B9=E7=9B=AE=E5=92=8C=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 45 +++++++++++--------- app/views/layouts/base_org.html.erb | 4 +- app/views/organizations/join_courses.js.erb | 2 +- app/views/organizations/join_projects.js.erb | 2 +- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index ba4dda939..b326051e6 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -161,7 +161,7 @@ class OrganizationsController < ApplicationController def more_org_projects @organization = Organization.find params[:id] @page = params[:page] - @org_projects = @organization.projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + @org_projects = @organization.projects.reorder('created_at').uniq.page((params[:page].to_i || 1) +1).per(5) respond_to do |format| format.js end @@ -170,7 +170,7 @@ class OrganizationsController < ApplicationController def more_org_courses @organization = Organization.find(params[:id]) @page = params[:page] - @org_courses = @organization.courses.reorder('created_at').page((params[:page].to_i || 1) + 1 ).per(5) + @org_courses = @organization.courses.reorder('created_at').uniq.page((params[:page].to_i || 1) + 1 ).per(5) respond_to do |format| format.js end @@ -189,16 +189,17 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - #sql = "select courses.* from courses inner join members on courses.id = members.course_id inner join org_courses on courses.id = org_courses.course_id where org_courses.organization_id != #{@organization.id} and members.user_id = #{User.current.id} and courses.name like '#{condition}'" - sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'" - user_courses = Course.find_by_sql(sql) - @added_course_ids = @organization.courses.map(&:id) - @courses = [] - user_courses.each do |course| - if !@added_course_ids.include?(course.id) - @courses << course - end - end + sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+ + "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})" + #user_courses = Course.find_by_sql(sql) + @courses = Course.find_by_sql(sql) + # @added_course_ids = @organization.courses.map(&:id) + # @courses = [] + # user_courses.each do |course| + # if !@added_course_ids.include?(course.id) + # @courses << course + # end + # end end def join_courses @@ -225,15 +226,17 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" - user_projects = Course.find_by_sql(sql) - @added_course_ids = @organization.projects.map(&:id) - @projects = [] - user_projects.each do |project| - if !@added_course_ids.include?(project.id) - @projects << project - end - end + sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" + + " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})" + #user_projects = Course.find_by_sql(sql) + @projects = Course.find_by_sql(sql) + # @added_course_ids = @organization.projects.map(&:id) + # @projects = [] + # user_projects.each do |project| + # if !@added_course_ids.include?(project.id) + # @projects << project + # end + # end end def join_projects diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index b89977b09..b071a7c3b 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -104,7 +104,7 @@
    • - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.projects.reorder('created_at').limit(5),:org_id=>@organization.id,:page=>1}%> + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.projects.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%> @@ -131,7 +131,7 @@
      - <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>@organization.courses.reorder('created_at').limit(5),:org_id=>@organization.id,:page=>1}%> + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>@organization.courses.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%>
    diff --git a/app/views/organizations/join_courses.js.erb b/app/views/organizations/join_courses.js.erb index 1c234704e..643af161f 100644 --- a/app/views/organizations/join_courses.js.erb +++ b/app/views/organizations/join_courses.js.erb @@ -1,5 +1,5 @@ $("#homepageLeftMenuCourses").html(""); $("#homepageLeftMenuCourses").append("
      "); $("#homepageLeftMenuCourses").append("<%= escape_javascript(render :partial => 'layouts/org_courses', - :locals=>{:courses=>@organization.courses.reorder('created_at').limit(5),:org_id=>@organization.id,:page=> 1}) %>"); + :locals=>{:courses=>@organization.courses.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=> 1}) %>"); $("#homepageLeftMenuCourses").append("
    "); \ No newline at end of file diff --git a/app/views/organizations/join_projects.js.erb b/app/views/organizations/join_projects.js.erb index 1db8021bf..a39d94819 100644 --- a/app/views/organizations/join_projects.js.erb +++ b/app/views/organizations/join_projects.js.erb @@ -1,5 +1,5 @@ $("#homepageLeftMenuProjects").html(""); $("#homepageLeftMenuProjects").append("
      "); $("#homepageLeftMenuProjects").append("<%= escape_javascript(render :partial => 'layouts/org_projects', - :locals=>{:projects=>@organization.projects.reorder('created_at').limit(5),:org_id=>@organization.id,:page=> 1}) %>"); + :locals=>{:projects=>@organization.projects.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=> 1}) %>"); $("#homepageLeftMenuProjects").append("
    "); \ No newline at end of file From 06ca4c8f4ba6c99209ac321afb5518df64e91069 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 27 Nov 2015 16:52:28 +0800 Subject: [PATCH 29/33] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/courses.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index faffee4d1..00aff2195 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -64,7 +64,7 @@ a:hover.news_foot{ color:#787b7e; border:1px solid #d4d4d4;} a.hworkExport {background:url(../images/homepage_icon2.png) -10px -401px no-repeat; padding-left:23px;} a.hworkSetting {background:url(../images/homepage_icon2.png) -10px -450px no-repeat; padding-left:23px;} .hworkInfor {font-size:12px; color:#269ac9; width:80px; height:40px; vertical-align:middle; float:left; line-height:40px; text-align:center; font-weight:bold;} -.infoNi{ width:100px; padding:5px;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left; line-height:2; position:absolute; margin-top:-24px;margin-left: 40px;} +.infoNi{ width:100px; padding:5px;-moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; box-shadow:0px 0px 5px #194a81; color:#666; background:#fff; text-align:left; line-height:2; position:absolute; margin-top:-24px;margin-left: 40px; z-index:99;} .problemTxt {width:660px; margin-left:10px; color:#777777; position:relative;} .rTxtTit{width:560px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf; float:left; color:#269ac9; font-size:14px;} .hworkSearchBox {border:1px solid #e6e6e6; width:185px; float:left; background-color:#ffffff;} From b130b52a23ada16fd441f5c0d8384211540865a4 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 27 Nov 2015 16:55:45 +0800 Subject: [PATCH 30/33] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20151127011351_add_course_contributor_total_score.rb | 2 +- db/schema.rb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/db/migrate/20151127011351_add_course_contributor_total_score.rb b/db/migrate/20151127011351_add_course_contributor_total_score.rb index 2606864d8..28ce55ef4 100644 --- a/db/migrate/20151127011351_add_course_contributor_total_score.rb +++ b/db/migrate/20151127011351_add_course_contributor_total_score.rb @@ -14,7 +14,7 @@ class AddCourseContributorTotalScore < ActiveRecord::Migration message_reply_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.student_id} and me.parent_id is not null").count * 1 common_reply_count = Comment.find_by_sql("select cm.* from comments cm, news n where cm.author_id = #{s.student_id} and n.course_id = #{course.id} and cm.commented_id = n.id and cm.commented_type ='News'").count * 1 # attachment_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "Attachment").count * 5 - attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.student_id};").count * 5 + attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.student_id} and container_type ='Course'").count * 5 journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.student_id, course.id, "Course").count * 1 # journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1 # journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1 diff --git a/db/schema.rb b/db/schema.rb index 603ca6857..87342bf9c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -605,7 +605,7 @@ ActiveRecord::Schema.define(:version => 20151127011351) do end create_table "exercise_questions", :force => true do |t| - t.string "question_title" + t.text "question_title" t.integer "question_type" t.integer "question_number" t.integer "exercise_id" @@ -634,7 +634,7 @@ ActiveRecord::Schema.define(:version => 20151127011351) do end create_table "exercises", :force => true do |t| - t.string "exercise_name" + t.text "exercise_name" t.text "exercise_description" t.integer "course_id" t.integer "exercise_status" @@ -1151,10 +1151,6 @@ ActiveRecord::Schema.define(:version => 20151127011351) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" -<<<<<<< HEAD - t.string "role" -======= ->>>>>>> 1ae514ca4857d7e2ad53b338731c1e01f899fb4d t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end From cb910b8d4ab85c7df743af3de1b5578d79f0e670 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 17:02:37 +0800 Subject: [PATCH 31/33] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index da649663d..c2b1b509f 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -411,7 +411,9 @@ <% if ma.course_message_type == "Course" %>
      -
    • +
    • + +
    • 系统提示 ">您成功创建了课程: @@ -443,7 +445,7 @@ <% end %> <% if ma.course_message_type == "JoinCourseRequest" %>
        -
      • +
      • 系统提示 ">您有了新的课程成员申请: @@ -482,7 +484,7 @@ <% end %> <% if ma.course_message_type == "CourseRequestDealResult" %>
          -
        • +
        • 系统提示 "> @@ -548,7 +550,7 @@ <% if ma.course_message_type == "JoinCourse" and ma.status == 1 %>
          • - +
          • 系统提示 From 634e11d0ecf6852bdbbf1ddc814b476e52e7a2a1 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 27 Nov 2015 17:15:51 +0800 Subject: [PATCH 32/33] 0 --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 87342bf9c..55a97ee20 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 => 20151127011351) do +ActiveRecord::Schema.define(:version => 20151126160252) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From f91918145dfe9d42d15196d289cdaaa45ec3ac83 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 27 Nov 2015 18:00:26 +0800 Subject: [PATCH 33/33] 0 --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 55a97ee20..87342bf9c 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 => 20151126160252) do +ActiveRecord::Schema.define(:version => 20151127011351) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false