diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 0c794fe33..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|
@@ -332,6 +340,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
@@ -347,6 +358,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
@@ -500,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/controllers/memos_controller.rb b/app/controllers/memos_controller.rb
index 4181090a5..2d2c058d4 100644
--- a/app/controllers/memos_controller.rb
+++ b/app/controllers/memos_controller.rb
@@ -73,6 +73,7 @@ class MemosController < ApplicationController
end
end
#end
+ format.js
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else
@@ -152,6 +153,7 @@ class MemosController < ApplicationController
end
def update
+ @flag = false
respond_to do |format|
if( #@memo.update_column(:subject, params[:memo][:subject]) &&
@memo.update_column(:content, params[:memo][:content]) &&
@@ -159,10 +161,12 @@ class MemosController < ApplicationController
@memo.update_column(:lock, params[:memo][:lock]) &&
@memo.update_column(:subject,params[:memo][:subject]))
@memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads]))
- @memo.save
+ @flag = @memo.save
# @memo.root.update_attribute(:updated_at, @memo.updated_at)
+ format.js
format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"}
else
+ format.js
format.html { render action: "edit" }
format.json { render json: @person.errors, status: :unprocessable_entity }
end
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index dd2a5b5fc..5e71b0114 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -4,7 +4,7 @@ class StudentWorkController < ApplicationController
require 'bigdecimal'
require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work]
- before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work]
+ before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment]
@@ -527,6 +527,18 @@ class StudentWorkController < ApplicationController
@course_activity = params[:course_activity].to_i
end
+ def revise_attachment
+ Attachment.attach_filesex(@work, params[:attachments], params[:attachment_type])
+ revise_attachments = @work.attachments.where("attachtype = 7").reorder("created_on desc")
+ if revise_attachments.count == 2
+ revise_attachments.last.destroy
+ end
+ #@attachment = @work.attachments.where("attachtype = 7").order("created_on desc").first
+ respond_to do |format|
+ format.js
+ end
+ end
+
private
def hsd_committed_work?(user, homework)
sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9ff833f48..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'
@@ -1429,6 +1429,7 @@ class UsersController < ApplicationController
@course = @user.courses
.select { |course| @user.allowed_to?(:as_teacher,course)}
end
+ @search = params[:search]
#这里仅仅是传递需要发送的资源id
@send_id = params[:send_id]
@send_ids = params[:checkbox1] || params[:send_ids]
@@ -1445,6 +1446,7 @@ class UsersController < ApplicationController
else
@projects = @user.projects
end
+ @search = params[:search]
#这里仅仅是传递需要发送的资源id
@send_id = params[:send_id]
@send_ids = params[:checkbox1] || params[:send_ids] #搜索的时候 和 直接 用表格提交的时候的send_ids
diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb
index e1cf3464e..df5c872f8 100644
--- a/app/helpers/student_work_helper.rb
+++ b/app/helpers/student_work_helper.rb
@@ -126,4 +126,15 @@ module StudentWorkHelper
end
type
end
+
+ def revise_attachment_status homework, attach
+ date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d")
+ status = ""
+ if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < date))
+ status = "此时其他同学作品已公开"
+ else
+ status = "此时其他同学作品尚未公开"
+ end
+ return status
+ end
end
\ No newline at end of file
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/models/student_work.rb b/app/models/student_work.rb
index 010ede635..884f4a089 100644
--- a/app/models/student_work.rb
+++ b/app/models/student_work.rb
@@ -10,6 +10,7 @@ class StudentWork < ActiveRecord::Base
has_many :student_work_tests, order: 'id desc'
# course's message
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
+ has_many :attachments, :dependent => :destroy
before_destroy :delete_praise
before_save :set_program_score, :set_src
diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb
index d23422e24..cfbe68085 100644
--- a/app/views/attachments/destroy.js.erb
+++ b/app/views/attachments/destroy.js.erb
@@ -1,5 +1,9 @@
<% if @is_destroy%>
$("#attachment_<%= @attachment.id%>").remove();
+ if(document.getElementById("uploadReviseBox")) {
+ $("#uploadReviseBox").removeClass('disable_link');
+ $("#choose_revise_attach").attr("onclick","_file.click();");
+ }
<%else%>
var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
@@ -26,5 +30,10 @@
$('#upload_file_count'+containerid).html(""+count+" "+"个文件"+"已上传");
}
}
+
+ if(document.getElementById("uploadReviseBox")) {
+ $("#uploadReviseBox").removeClass('disable_link');
+ $("#choose_revise_attach").attr("onclick","_file.click();");
+ }
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
<% end%>
\ No newline at end of file
diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb
index bb8a91b69..dc3a20482 100644
--- a/app/views/forums/_show_topics.html.erb
+++ b/app/views/forums/_show_topics.html.erb
@@ -16,7 +16,7 @@
<%= format_date(topic.last_reply.created_at)%>
<% end%>
-
+ 更新时间:<%= format_date(topic.updated_at)%>
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb
index 05c086ed4..ad9195804 100644
--- a/app/views/forums/show.html.erb
+++ b/app/views/forums/show.html.erb
@@ -3,7 +3,7 @@
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| %>
diff --git a/app/views/student_work/_revise_attachment.html.erb b/app/views/student_work/_revise_attachment.html.erb
new file mode 100644
index 000000000..968a4853b
--- /dev/null
+++ b/app/views/student_work/_revise_attachment.html.erb
@@ -0,0 +1,28 @@
+<% revise_attachment = work.attachments.where("attachtype = 7").first %>
+<% if @homework.end_time < Date.today %>
+ <% if revise_attachment && @is_teacher %>
+
+ 追加修订附件
+
+
+ 追加附件:
+ <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 2} %>
+ 追加时间: <%=format_time revise_attachment.created_on.to_s %> (<%=revise_attachment_status @homework,revise_attachment %>)
+
+ <% end %>
+ <% if work.user == User.current %>
+
+ 追加修订附件
+
+ <% if revise_attachment %>
+
+ 追加附件:
+ <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 1} %>
+ 追加时间: <%=format_time revise_attachment.created_on.to_s %>
+
+ <% end %>
+
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/student_work/_revise_attachments.html.erb b/app/views/student_work/_revise_attachments.html.erb
deleted file mode 100644
index 1321da368..000000000
--- a/app/views/student_work/_revise_attachments.html.erb
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- 上传附件
- <%#= button_tag "上传附件", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'blueCir ml5' %>
- <%= file_field_tag 'attachments[dummy][file]',
- :id => "_file#{work.id}",
- :class => 'file_selector',
- :multiple => true,
- :onchange => "addReviseFiles(this, '#{work.id}');",
- :style => 'display:none',
- :data => {
- :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
- :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
- :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
- :upload_path => uploads_path(:format => 'js'),
- :description_placeholder => l(:label_optional_description),
- :field_is_public => l(:field_is_public),
- :are_you_sure => l(:text_are_you_sure),
- :file_count => l(:label_file_count),
- :lebel_file_uploding => l(:lebel_file_uploding),
- :delete_all_files => l(:text_are_you_sure_all),
- :containerid => "#{work.id}"
- } %>
-
- <% content_for :header_tags do %>
- <%= javascript_include_tag 'attachments' %>
- <% end %>
-
-
diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb
index 894f9fb39..993b0f2aa 100644
--- a/app/views/student_work/_show.html.erb
+++ b/app/views/student_work/_show.html.erb
@@ -41,17 +41,18 @@
附件:
- <% if work.attachments.empty?%>
+ <% com_attachments = work.attachments.where("attachtype IS NULL OR attachtype <> 7") %>
+ <% if com_attachments.empty?%>
尚未提交附件
<% else%>
- <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments, :status => @homework.homework_detail_manual.comment_status} %>
+ <%= render :partial => 'work_attachments_status', :locals => {:attachments => com_attachments, :status => @homework.homework_detail_manual.comment_status} %>
<% end%>
- <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current )%>
+ <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current)%>
<%= render :partial => 'add_score',:locals => {:work => work,:score => score}%>
@@ -61,30 +62,10 @@
-
- <%#= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%>
- <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
-
- <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%>
- <%#= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
- <%#= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
-
+
<%student_work_scores.each do |student_score|%>
@@ -96,4 +77,26 @@
收起
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/app/views/student_work/_upload_attachment.html.erb b/app/views/student_work/_upload_attachment.html.erb
new file mode 100644
index 000000000..d9c69fc17
--- /dev/null
+++ b/app/views/student_work/_upload_attachment.html.erb
@@ -0,0 +1,50 @@
+
+上传附件
+
+
+ <%= form_tag(revise_attachment_student_work_path(work.id), :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
+
+
+
+
+
+
+
+ 选择文件
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => '_file',
+ :class => ie8? ? '':'file_selector',
+ :multiple => true,
+ :onchange => 'addReviseInputFiles(this,"'+'upload_files_submit_btn'+'");',
+ :style => ie8? ? '': 'display:none',
+ :data => {
+ :max_file_size => Setting.attachment_max_size.to_i.kilobytes,
+ :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
+ :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js'),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :lebel_file_uploding => l(:lebel_file_uploding),
+ :delete_all_files => l(:text_are_you_sure_all)
+ } %>
+
+
+
+
+
+
+
+
+ <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %>
+
+
+
+ <% end %>
+
+
diff --git a/app/views/student_work/revise_attachment.js.erb b/app/views/student_work/revise_attachment.js.erb
new file mode 100644
index 000000000..74813d27b
--- /dev/null
+++ b/app/views/student_work/revise_attachment.js.erb
@@ -0,0 +1,2 @@
+closeModal();
+$("#revise_attachment").html('<%= escape_javascript( render :partial => 'revise_attachment' ,:locals=>{ :work => @work})%>');
\ No newline at end of file
diff --git a/app/views/users/_resource_share_for_project_popup.html.erb b/app/views/users/_resource_share_for_project_popup.html.erb
index 40bbd5e7c..ba136899c 100644
--- a/app/views/users/_resource_share_for_project_popup.html.erb
+++ b/app/views/users/_resource_share_for_project_popup.html.erb
@@ -17,7 +17,10 @@
:remote=>true,:id=>'search_user_project_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/_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_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 6e8fda92e..640f98b1f 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" %>
@@ -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 == -1 ? '不限时' : 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 == -1 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
+ 请及时完成课程测验,辛苦啦!
+
+
+ 截止时间快到啦
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb
index c61790c40..95f7784f7 100644
--- a/app/views/users/add_exist_file_to_course.js.erb
+++ b/app/views/users/add_exist_file_to_course.js.erb
@@ -5,5 +5,6 @@ $("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp();
+alert("发送成功")
<% else%>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/add_exist_file_to_project.js.erb b/app/views/users/add_exist_file_to_project.js.erb
index c61790c40..95f7784f7 100644
--- a/app/views/users/add_exist_file_to_project.js.erb
+++ b/app/views/users/add_exist_file_to_project.js.erb
@@ -5,5 +5,6 @@ $("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
closePopUp();
+alert("发送成功")
<% else%>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb
index 3af9c29fd..a6d8d18c7 100644
--- a/app/views/users/user_resource.html.erb
+++ b/app/views/users/user_resource.html.erb
@@ -143,7 +143,7 @@
//资源名称的链接
var res_link;
var id; //资源id
- var sendType; //发送到课程 1 发送到项目 2
+ var sendType = '1'; //发送到课程 1 发送到项目 2
var lastSendType; //保存上次发送的发送类型
$("#resources_list").mousedown(function(e) {
//如果是右键的话
@@ -309,15 +309,15 @@
document.oncontextmenu = function() {return true;}
line.children().css("background-color",'white');
id = line.children().last().html();
- if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
+ if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
- url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
+ url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
});
}else{
$.ajax({
type: 'get',
- url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id
+ url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id
});
}
}
@@ -327,16 +327,17 @@
alert('暂时不支持多页选择,您当前页没有选择任何资源');
return ;
}
- if (lastSendType === '1'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
+ if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。
$.ajax({
type: 'get',
- url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize()
+ url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
});
}else{
$.ajax({
type: 'get',
- url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize()
+ 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);
+ });
+ }
+
diff --git a/config/routes.rb b/config/routes.rb
index f6fe95a33..59eb29d70 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -206,6 +206,7 @@ RedmineApp::Application.routes.draw do
resources :student_work do
member do
post 'add_score'
+ post 'revise_attachment'
get 'retry_work'
get 'praise_student_work'
get 'forbidden_anonymous_comment'
diff --git a/db/schema.rb b/db/schema.rb
index a1e14c3bd..6cc6b90c4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -543,26 +543,23 @@ ActiveRecord::Schema.define(:version => 20151204062220) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
- 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 "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
+ create_table "dts", :force => true do |t|
+ t.string "IPLineCode"
t.string "Description"
- t.text "PreConditions", :limit => 2147483647
- t.text "TraceInfo", :limit => 2147483647
- t.text "Code", :limit => 2147483647
+ t.string "Num"
+ t.string "Variable"
+ t.string "TraceInfo"
+ t.string "Method"
+ t.string "File"
+ t.string "IPLine"
+ t.string "Review"
+ t.string "Category"
+ t.string "Defect"
+ t.string "PreConditions"
+ t.string "StartLine"
t.integer "project_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "id", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
end
create_table "enabled_modules", :force => true do |t|
@@ -894,6 +891,16 @@ ActiveRecord::Schema.define(:version => 20151204062220) 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"
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..e2808818f
--- /dev/null
+++ b/lib/tasks/exercise_close_to_deadline_warn.rake
@@ -0,0 +1,21 @@
+#coding=utf-8
+#需要在0点以后执行
+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
+ 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
\ No newline at end of file
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/public/javascripts/attachments.js b/public/javascripts/attachments.js
index d7b49c8be..b60b6ad28 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -154,6 +154,73 @@ function addFile(inputEl, file, eagerUpload,btnId) {
}
addFile.nextAttachmentId = 1;
+function addReviseFile(inputEl, file, eagerUpload,btnId) {
+
+ var attachments_frame = '#attachments_fields';
+ if ($(attachments_frame).children().length < 30) {
+ deleteallfiles = $(inputEl).data('deleteAllFiles');
+ var attachmentId = addFile.nextAttachmentId++;
+
+ var fileSpan = $('', {
+ 'id': 'attachments_' + attachmentId,
+ 'class': 'attachment'
+ });
+
+ fileSpan.append(
+ $(' ', {
+ 'type': 'text',
+ 'class': 'upload_filename readonly',
+ 'name': 'attachments[' + attachmentId + '][filename]',
+ 'readonly': 'readonly'
+ }).val(file.name),
+// $(' ', {
+// 'type': 'text',
+// 'class': 'description',
+// 'name': 'attachments[' + attachmentId + '][description]',
+// 'maxlength': 254,
+// 'placeholder': $(inputEl).data('descriptionPlaceholder')
+// }).toggle(!eagerUpload),
+// $('' + $(inputEl).data('fieldIsPublic') + ': ').attr({
+// 'class': 'ispublic-label'
+// }),
+// $(' ', {
+// 'type': 'checkbox',
+// 'class': 'is_public_checkbox',
+// 'value': 1,
+// 'name': 'attachments[' + attachmentId + '][is_public_checkbox]',
+// checked: 'checked'
+// }).toggle(!eagerUpload),
+ $('  ').attr({
+ 'href': "#",
+ 'class': 'remove-upload'
+ }).click(function() {
+ if (confirm($(inputEl).data('areYouSure'))) {
+ removeReviseFile();
+ if (!eagerUpload) {
+ (function(e) {
+ reload(e);
+ })(fileSpan);
+ }
+ }
+
+ }).toggle(!eagerUpload),
+ $('', {
+ 'class': 'div_attachments',
+ 'name': 'div_' + 'attachments_' + attachmentId
+ })
+ ).appendTo('#attachments_fields');
+
+ $("#uploadReviseBox").addClass('disable_link');
+ $("#choose_revise_attach").attr("onclick","return false;");
+
+ if (eagerUpload) {
+ ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
+ }
+ return attachmentId;
+ }
+ return null;
+}
+
function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
//上传开始调用函数
function onLoadstart(e) {
@@ -293,6 +360,13 @@ function removeFile() {
return false;
}
+function removeReviseFile() {
+ $(this).parent('span').remove();
+ $("#uploadReviseBox").removeClass('disable_link');
+ $("#choose_revise_attach").attr("onclick","_file.click();");
+ return false;
+}
+
//gcm delete all file
//modify by yutao 2015-5-14 ��1��ҳ����ڶ���ϴ��ؼ�ʱ�˿�������bug �ʸ�֮ start
function removeAll(containerid) {
@@ -346,6 +420,30 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
});
}
+function addReviseInputFiles(inputEl,btnId) {
+ // var clearedFileInput = $(inputEl).clone().val('');
+ if (inputEl.files) {
+ uploadAndAttachReviseFiles(inputEl.files, inputEl,btnId);
+ // $(inputEl).remove();
+ } else {
+ // browser not supporting the file API, upload on form submission
+ var attachmentId;
+ var aFilename = inputEl.value.split(/\/|\\/);
+ var count = $('#attachments_fields>span').length;
+ attachmentId = addReviseFile(inputEl, {
+ name: aFilename[aFilename.length - 1]
+ }, false);
+ if (attachmentId) {
+ $(inputEl).attr({
+ name: 'attachments[' + attachmentId + '][file]'
+ }).hide();
+ if (count <= 0) count = 1;
+ }
+ }
+
+ //clearedFileInput.insertAfter('#attachments_fields');
+}
+
function addInputFiles(inputEl,btnId) {
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
@@ -405,6 +503,26 @@ function addInputFiles_board(inputEl, id,btnId) {
//clearedFileInput.insertAfter('#attachments_fields');
}
+function uploadAndAttachReviseFiles(files, inputEl,btnId) {
+
+ var maxFileSize = $(inputEl).data('max-file-size');
+ var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
+
+ var sizeExceeded = false;
+ $.each(files, function() {
+ if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {
+ sizeExceeded = true;
+ }
+ });
+ if (sizeExceeded) {
+ window.alert(maxFileSizeExceeded);
+ } else {
+ $.each(files, function() {
+ addReviseFile(inputEl, this, true,btnId);
+ });
+ }
+}
+
function uploadAndAttachFiles(files, inputEl,btnId) {
var maxFileSize = $(inputEl).data('max-file-size');
diff --git a/public/javascripts/blog.js b/public/javascripts/blog.js
index feaab0100..65dbfecba 100644
--- a/public/javascripts/blog.js
+++ b/public/javascripts/blog.js
@@ -34,7 +34,7 @@ function submit_article()
function regexTopicDescription()
{
var name = message_content_editor.html();
- if(name.length ==0)
+ if(message_content_editor.isEmpty())
{
$("#message_content_span").text("描述不能为空");
$("#message_content_span").css('color','#ff0000');
@@ -55,7 +55,7 @@ function regexTopicDescription()
function MessageReplayVevify() {
var content = message_content_editor.html();//$.trim($("#message_content").val());
- if (content.length == 0) {
+ if (message_content_editor.isEmpty()) {
$("#message_content_span").text("回复不能为空");
$("#message_content_span").css('color', '#ff0000');
return false;
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 584a49a4f..c2132c3fa 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -1197,3 +1197,21 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-
.resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;}
a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.blueCir{ background:#3598db; color:#fff;}
+
+/*上传资源弹窗*/
+.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;}
+.uploadDialogText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; width:140px; display:inline-block; font-weight: bold;}
+.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative}
+.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#269ac9; border-radius:3px; float:left; margin-right:12px;}
+a.uploadBoxIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:81px; height:30px; padding-left:22px; font-size:14px; color:#ffffff;}
+a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;}
+.chooseFile {color:#ffffff; display:block; margin-left:32px;}
+.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;}
+.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;}
+.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;}
+.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;}
+.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;}
+.mb10 {margin-bottom: 10px}
+.mb15 {margin-bottom: 15px}
+div.disable_link {background-color: #c1c1c1 !important;}
+div.disable_link :hover {background-color: #c1c1c1}
\ No newline at end of file
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index a1dfe3f4d..70aad2cbe 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -410,7 +410,7 @@ a:hover.search_btn{ background: #0fa9bb;}
.resourcesSendTo {float:left; height:20px; margin-top:15px;}
.resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;}
.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;}
-.resourceClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;}
+.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;}
.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}
.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;}
.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;}
diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css
index db2d021d9..c60adf460 100644
--- a/public/stylesheets/public_new.css
+++ b/public/stylesheets/public_new.css
@@ -566,7 +566,7 @@ a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat;
.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}
.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:100px; display:inline-block;}
.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;}
-.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;}
+.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;}
.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}
.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;}
.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;}