error
- <%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %>
+ <%= labelled_form_for(@memo, :url => forum_memos_path(@forum),:remote=>true) do |f| %>
<%= submit_tag '',:class=>'searchIconPopup',:onfocus=>"this.blur();",:style=>'border-style:none' %>
<% end %>
diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb
index ed2ed44a6..53fb6673b 100644
--- a/app/views/users/_resource_share_popup.html.erb
+++ b/app/views/users/_resource_share_popup.html.erb
@@ -17,7 +17,10 @@
:remote=>true,:id=>'search_user_course_form',:class=>'resourcesSearchBox' do %>
<%= hidden_field_tag(:send_id, send_id) %>
<%= hidden_field_tag(:send_ids, send_ids) %>
-
+
+
<%= submit_tag '',:class=>'searchIconPopup',:onfocus=>"this.blur();",:style=>'border-style:none' %>
<% end %>
diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb
index 0c0f4af08..a6d8d18c7 100644
--- a/app/views/users/user_resource.html.erb
+++ b/app/views/users/user_resource.html.erb
@@ -327,16 +327,17 @@
alert('暂时不支持多页选择,您当前页没有选择任何资源');
return ;
}
- if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
- $.ajax({
- type: 'get',
- url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
- });
- }else{
+ if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
});
+ }else{
+ $.ajax({
+ type: 'get',
+ url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
+ });
+
}
}
@@ -480,5 +481,36 @@
lastSendType = sendType;
}
+
+ function observeSearchfieldOnInput(fieldId, url,send_id,send_ids) {
+ $('#'+fieldId).each(function() {
+ var $this = $(this);
+ $this.addClass('autocomplete');
+ $this.attr('data-value-was', $this.val());
+ var check = function() {
+ var val = $this.val();
+ if ($this.attr('data-value-was') != val){
+ $this.attr('data-value-was', val);
+ $.ajax({
+ url: url,
+ type: 'get',
+ data: {search: $this.val(),send_id:send_id,send_ids:send_ids},
+ success: function(data){ },
+ beforeSend: function(){ $this.addClass('ajax-loading'); },
+ complete: function(){ $this.removeClass('ajax-loading'); }
+ });
+ }
+ };
+ var reset = function() {
+ if (timer) {
+ clearInterval(timer);
+ timer = setInterval(check, 300);
+ }
+ };
+ var timer = setInterval(check, 300);
+ $this.bind('keyup click mousemove', reset);
+ });
+ }
+
From adb246f9ad0336eb299d593db4b60bd8cdda669a Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Wed, 2 Dec 2015 15:30:07 +0800
Subject: [PATCH 08/21] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=A0=87=E8=AE=B0=20?=
=?UTF-8?q?=E9=94=99=E8=AF=AF=20?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/users/_user_message_course.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 6e8fda92e..9f2c9b9ef 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -579,7 +579,7 @@
<% end %>
-
+
<% if ma.course_message_type == "RemoveFromCourse" %>
-
From 89b8f7783da5be3c75d1594a399403e37cfa50e9 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 4 Dec 2015 08:57:29 +0800
Subject: [PATCH 09/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0forked=5Fform=E7=9A=84i?=
=?UTF-8?q?d?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/repositories/show.html.erb | 2 +-
..._add_forked_from_project_id_to_projects.rb | 5 ++
db/schema.rb | 63 +++++++++----------
3 files changed, 35 insertions(+), 35 deletions(-)
create mode 100644 db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index e06542cba..324dc6202 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -15,7 +15,7 @@
版本库地址:<%= @repos_url %>
<% else %>
版本库地址:<%= h @repository.url %>
- <% end %>
+ <% end %>-
diff --git a/db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb b/db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb
new file mode 100644
index 000000000..f679eaecd
--- /dev/null
+++ b/db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb
@@ -0,0 +1,5 @@
+class AddForkedFromProjectIdToProjects < ActiveRecord::Migration
+ def change
+ add_column :projects, :forked_from_project_id, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index c6ca6a0ce..886f233a8 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 => 20151130033906) do
+ActiveRecord::Schema.define(:version => 20151203072815) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
- create_table "dts", :force => true do |t|
- t.string "IPLineCode"
- t.string "Description"
- t.string "Num"
- t.string "Variable"
- t.string "TraceInfo"
- t.string "Method"
+ create_table "dts", :primary_key => "Num", :force => true do |t|
+ t.string "Defect", :limit => 50
+ t.string "Category", :limit => 50
t.string "File"
- t.string "IPLine"
- t.string "Review"
- t.string "Category"
- t.string "Defect"
- t.string "PreConditions"
- t.string "StartLine"
+ t.string "Method"
+ t.string "Module", :limit => 20
+ t.string "Variable", :limit => 50
+ t.integer "StartLine"
+ t.integer "IPLine"
+ t.string "IPLineCode", :limit => 200
+ t.string "Judge", :limit => 15
+ t.integer "Review", :limit => 1
+ t.string "Description"
+ t.text "PreConditions", :limit => 2147483647
+ t.text "TraceInfo", :limit => 2147483647
+ t.text "Code", :limit => 2147483647
t.integer "project_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "id", :null => false
end
create_table "enabled_modules", :force => true do |t|
@@ -891,16 +894,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
- create_table "journal_details_copy", :force => true do |t|
- t.integer "journal_id", :default => 0, :null => false
- t.string "property", :limit => 30, :default => "", :null => false
- t.string "prop_key", :limit => 30, :default => "", :null => false
- t.text "old_value"
- t.text "value"
- end
-
- add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
-
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"
@@ -970,6 +963,7 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
t.integer "course_group_id", :default => 0
end
+ add_index "members", ["course_id"], :name => "index_members_on_course_id"
add_index "members", ["project_id"], :name => "index_members_on_project_id"
add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true
add_index "members", ["user_id"], :name => "index_members_on_user_id"
@@ -1303,27 +1297,28 @@ ActiveRecord::Schema.define(:version => 20151130033906) do
end
create_table "projects", :force => true do |t|
- t.string "name", :default => "", :null => false
+ t.string "name", :default => "", :null => false
t.text "description"
- t.string "homepage", :default => ""
- t.boolean "is_public", :default => true, :null => false
+ t.string "homepage", :default => ""
+ t.boolean "is_public", :default => true, :null => false
t.integer "parent_id"
t.datetime "created_on"
t.datetime "updated_on"
t.string "identifier"
- t.integer "status", :default => 1, :null => false
+ t.integer "status", :default => 1, :null => false
t.integer "lft"
t.integer "rgt"
- t.boolean "inherit_members", :default => false, :null => false
+ t.boolean "inherit_members", :default => false, :null => false
t.integer "project_type"
- t.boolean "hidden_repo", :default => false, :null => false
- t.integer "attachmenttype", :default => 1
+ t.boolean "hidden_repo", :default => false, :null => false
+ t.integer "attachmenttype", :default => 1
t.integer "user_id"
- t.integer "dts_test", :default => 0
+ t.integer "dts_test", :default => 0
t.string "enterprise_name"
t.integer "organization_id"
t.integer "project_new_type"
t.integer "gpid"
+ t.integer "forked_from_project_id"
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"
From 6553559929f76759cc83849f7bfe772154488058 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 4 Dec 2015 10:56:16 +0800
Subject: [PATCH 10/21] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_controller.rb | 4 ++
app/controllers/users_controller.rb | 4 +-
app/models/exercise.rb | 14 ++++
app/views/users/_user_message_course.html.erb | 70 +++++++++++++++++++
.../exercise_close_to_deadline_warn.rake | 22 ++++++
lib/tasks/exercise_publishtime.rake | 22 ++++++
6 files changed, 134 insertions(+), 2 deletions(-)
create mode 100644 lib/tasks/exercise_close_to_deadline_warn.rake
create mode 100644 lib/tasks/exercise_publishtime.rake
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 6d6d429b6..db09c50a5 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -316,6 +316,9 @@ class ExerciseController < ApplicationController
@exercise.exercise_status = 2
@exercise.publish_time = Time.now
if @exercise.save
+ @exercise.course.members.each do |m|
+ @exercise.course_messages << CourseMessage.create(:user_id =>m.user_id, :course_id => @exercise.course.id, :viewed => false,:status=>2)
+ end
#redirect_to exercise_index_url(:course_id=> @course.id)
respond_to do |format|
format.js
@@ -331,6 +334,7 @@ class ExerciseController < ApplicationController
@exercise.exercise_questions.each do |exercise_question|
exercise_question.exercise_answers.destroy_all
end
+ @exercise.course_messages.destroy_all
@exercise.exercise_users.destroy_all
@exercise.exercise_status = 1
@exercise.publish_time = nil
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 626bb59fc..834009d71 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -92,7 +92,7 @@ class UsersController < ApplicationController
end
# 用户消息
- # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复
+ # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复,exercise:课程测验
# issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment)
def user_messages
if !User.current.logged?
@@ -128,7 +128,7 @@ class UsersController < ApplicationController
#课程相关消息
when 'homework'
- @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork') and user_id =?", @user).order("created_at desc")
+ @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?", @user).order("created_at desc")
when 'course_message'
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc")
when 'course_news'
diff --git a/app/models/exercise.rb b/app/models/exercise.rb
index d23e8f115..c91e59fd9 100644
--- a/app/models/exercise.rb
+++ b/app/models/exercise.rb
@@ -6,4 +6,18 @@ class Exercise < ActiveRecord::Base
has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number"
has_many :exercise_users, :dependent => :destroy
has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过
+ # 课程消息
+ has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
+ after_create :acts_as_course_message
+ def acts_as_course_message
+ if self.course
+ if self.exercise_status == 2 #未发布
+ #self.course.members.each do |m|
+ self.course_messages << CourseMessage.create(:user_id => User.current.id, :course_id => self.course_id, :viewed => false,:status=>2)
+ #end
+ # else
+ # self.course_messages.destroy_all 这里的destory_all值得商榷。因为我这里是通过status来控制不同的status的
+ end
+ end
+ end
end
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 9f2c9b9ef..566677964 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -612,4 +612,74 @@
<%= time_tag(ma.created_at).html_safe %>
<% end %>
+
+
+ <% if ma.course_message_type == "Exercise" && ma.status == 2 %>
+
+ - <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+ -
+ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布了课程测验 :
+ -
+ <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))"%>
+
+
+
+
+ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
+ <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>发布了课程测验 ,测验详情如下:
+
+
+ - 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ - 测验标题:<%= ma.course_message.exercise_name %>
+
+
+
+
+
+ - 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
+ - 答题时间:<%= ma.course_message.time == 0 ? '不限时' : ma.course_message.time.to_s + '分钟' %>
+ <% if !User.current.allowed_to?(:as_teacher,ma.course_message.course)%>
+ 请记得在截止时间前完成测验噢,辛苦啦!
+ <% end %>
+
+
+ - <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+
+ <% if ma.course_message_type == "Exercise" && ma.status == 3 %>
+
+ - <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+ -
+ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布的测验:
+ -
+ <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))"%>
+
+
+
+
+
+ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
+ <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>发布的课程测验截止时间快到了,测验详情如下:
+
+
+
+ - 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ - 测验标题:<%= ma.course_message.exercise_name %>
+ - 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
+ - 答题时间:<%= ma.course_message.time == 0 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
+ 请及时完成课程测验,辛苦啦!
+
+
+ - 截止时间快到啦
+ - <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
<% end %>
\ No newline at end of file
diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake
new file mode 100644
index 000000000..2af513ee8
--- /dev/null
+++ b/lib/tasks/exercise_close_to_deadline_warn.rake
@@ -0,0 +1,22 @@
+#coding=utf-8
+
+namespace :exercise_deadline_warn do
+ desc "exercise deadline warn"
+ task :deadline_warn => :environment do
+ exercises = Exercise.where("date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验
+ exercises.each do |exercise|
+ if exercise.exercise_status == 2 #发布的作业才能告给学生发截止消息
+ course = exercise.course
+ course.members.each do |m|
+ #CourseMessage status 1 未发布 status 2 已发布 status 3 已发布快截止了
+ exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) unless m.user.allowed_to?(:as_teacher,m)
+ end
+ # if homework.course_acts.size == 0
+ # homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id)
+ # end
+ # 邮件通知
+ #Mailer.run.homework_added(homework)
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/tasks/exercise_publishtime.rake b/lib/tasks/exercise_publishtime.rake
new file mode 100644
index 000000000..6cef511e2
--- /dev/null
+++ b/lib/tasks/exercise_publishtime.rake
@@ -0,0 +1,22 @@
+#coding=utf-8
+
+namespace :exercise_publishtime do
+ desc "start publish exercise"
+ task :publish => :environment do
+ exercises = Exercise.where("date_format(publish_time,'%Y-%m-%d')= '#{Date.today}'")
+ exercises.each do |exercise|
+ if exercise.exercise_status == 1 #未发布
+ exercise.update_column('exercise_status', 2) #改为发布
+ course = exercise.course
+ course.members.each do |m|
+ exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
+ end
+ # if homework.course_acts.size == 0
+ # homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id)
+ # end
+ # 邮件通知
+ #Mailer.run.homework_added(homework)
+ end
+ end
+ end
+end
\ No newline at end of file
From 03588ca88ded7a776c16339d4bc6a65ad542ac35 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 4 Dec 2015 11:21:41 +0800
Subject: [PATCH 11/21] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=B5=8B=E9=AA=8C?=
=?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E5=8F=91=E5=B8=83=E6=B6=88=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/tasks/exercise_publish.rake | 4 ++++
lib/tasks/exercise_publishtime.rake | 22 ----------------------
2 files changed, 4 insertions(+), 22 deletions(-)
delete mode 100644 lib/tasks/exercise_publishtime.rake
diff --git a/lib/tasks/exercise_publish.rake b/lib/tasks/exercise_publish.rake
index aacd67c1f..a27c6a6fb 100644
--- a/lib/tasks/exercise_publish.rake
+++ b/lib/tasks/exercise_publish.rake
@@ -6,6 +6,10 @@ namespace :exercise_publish do
exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
+ course = exercise.course
+ course.members.each do |m|
+ exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
+ end
end
end
diff --git a/lib/tasks/exercise_publishtime.rake b/lib/tasks/exercise_publishtime.rake
deleted file mode 100644
index 6cef511e2..000000000
--- a/lib/tasks/exercise_publishtime.rake
+++ /dev/null
@@ -1,22 +0,0 @@
-#coding=utf-8
-
-namespace :exercise_publishtime do
- desc "start publish exercise"
- task :publish => :environment do
- exercises = Exercise.where("date_format(publish_time,'%Y-%m-%d')= '#{Date.today}'")
- exercises.each do |exercise|
- if exercise.exercise_status == 1 #未发布
- exercise.update_column('exercise_status', 2) #改为发布
- course = exercise.course
- course.members.each do |m|
- exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
- end
- # if homework.course_acts.size == 0
- # homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id)
- # end
- # 邮件通知
- #Mailer.run.homework_added(homework)
- end
- end
- end
-end
\ No newline at end of file
From 06122dab1dfad02ea5d9c36a2c36b08655153b72 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 4 Dec 2015 11:24:24 +0800
Subject: [PATCH 12/21] =?UTF-8?q?=E5=BD=93=E5=A4=A9=E6=88=AA=E6=AD=A2?=
=?UTF-8?q?=E7=9A=84=E6=B5=8B=E9=AA=8C=E9=9C=80=E8=A6=81=E5=8F=91=E5=B8=83?=
=?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=B6=88=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/tasks/exercise_close_to_deadline_warn.rake | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake
index 2af513ee8..890191167 100644
--- a/lib/tasks/exercise_close_to_deadline_warn.rake
+++ b/lib/tasks/exercise_close_to_deadline_warn.rake
@@ -3,9 +3,8 @@
namespace :exercise_deadline_warn do
desc "exercise deadline warn"
task :deadline_warn => :environment do
- exercises = Exercise.where("date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验
+ exercises = Exercise.where("exercise_status = 2 and date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验
exercises.each do |exercise|
- if exercise.exercise_status == 2 #发布的作业才能告给学生发截止消息
course = exercise.course
course.members.each do |m|
#CourseMessage status 1 未发布 status 2 已发布 status 3 已发布快截止了
@@ -16,7 +15,6 @@ namespace :exercise_deadline_warn do
# end
# 邮件通知
#Mailer.run.homework_added(homework)
- end
end
end
end
\ No newline at end of file
From e2f5dcc3f977536513ea8e8becf4d705a5226472 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 4 Dec 2015 13:39:17 +0800
Subject: [PATCH 13/21] =?UTF-8?q?=E5=BD=93=E5=A4=A9=E6=88=AA=E6=AD=A2?=
=?UTF-8?q?=E7=9A=84=E6=B5=8B=E9=AA=8C=E9=9C=80=E8=A6=81=E5=8F=91=E5=B8=83?=
=?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=B6=88=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/tasks/exercise_close_to_deadline_warn.rake | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake
index 890191167..2deb7204e 100644
--- a/lib/tasks/exercise_close_to_deadline_warn.rake
+++ b/lib/tasks/exercise_close_to_deadline_warn.rake
@@ -3,6 +3,7 @@
namespace :exercise_deadline_warn do
desc "exercise deadline warn"
task :deadline_warn => :environment do
+ #exercise_status 1 未发布 2 已发布 3已截止
exercises = Exercise.where("exercise_status = 2 and date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验
exercises.each do |exercise|
course = exercise.course
From dbfc4969e071b8dea30c9861414aea22d643ea92 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Fri, 4 Dec 2015 15:36:19 +0800
Subject: [PATCH 14/21] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E6=B6=88=E6=81=AFbug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/exercise_controller.rb | 12 ++++++++++++
app/views/users/_user_message_course.html.erb | 6 +++---
lib/tasks/exercise_close_to_deadline_warn.rake | 2 +-
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 55daf0562..a99ab32ec 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -9,6 +9,10 @@ class ExerciseController < ApplicationController
publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
publish_exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
+ course = exercise.course
+ course.members.each do |m|
+ exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
+ end
end
end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
end_exercises.each do |exercise|
@@ -35,6 +39,10 @@ class ExerciseController < ApplicationController
publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now)
publish_exercises.each do |exercise|
exercise.update_column('exercise_status', 2)
+ course = exercise.course
+ course.members.each do |m|
+ exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
+ end
end
end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now)
end_exercises.each do |exercise|
@@ -504,6 +512,10 @@ class ExerciseController < ApplicationController
@exercise.update_attributes(:show_result => params[:show_result])
@exercise.update_attributes(:exercise_status => 2)
@exercise.update_attributes(:publish_time => Time.now)
+ course = @exercise.course
+ course.members.each do |m|
+ @exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2)
+ end
redirect_to exercise_url(@exercise)
return
elsif @exercise.publish_time > Time.now
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 566677964..640f98b1f 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -640,9 +640,9 @@
截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
-
答题时间:<%= ma.course_message.time == 0 ? '不限时' : ma.course_message.time.to_s + '分钟' %>
+
答题时长:<%= ma.course_message.time == -1 ? '不限时' : ma.course_message.time.to_s + '分钟' %>
<% if !User.current.allowed_to?(:as_teacher,ma.course_message.course)%>
-
请记得在截止时间前完成测验噢,辛苦啦!
+
请记得在截止时间前完成测验噢,辛苦啦!
<% end %>