diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 1efbc9c48..8a64918ae 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -50,11 +50,15 @@ class CommentsController < ApplicationController # # ������ض�̬�ļ�¼add end flash[:notice] = l(:label_comment_added) course_activity = CourseActivity.where("course_act_type='News' and course_act_id =#{@news.id}").first - course_activity.updated_at = Time.now - course_activity.save + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end user_activity = UserActivity.where("act_type='News' and act_id =#{@news.id}").first - user_activity.updated_at = Time.now - user_activity.save + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end end if params[:user_activity_id] diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 00d814bd3..9e3a4b836 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -11,11 +11,16 @@ class HomeworkCommonController < ApplicationController before_filter :member_of_course, :only => [:index] def index - homeworks = @course.homework_commons.order("created_at desc") + @new_homework = HomeworkCommon.new + @new_homework.homework_detail_manual = HomeworkDetailManual.new + @new_homework.course = @course + @page = params[:page] ? params[:page].to_i + 1 : 0 + @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10) @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) - @homeworks = paginateHelper homeworks,20 + @is_new = params[:is_new] respond_to do |format| + format.js format.html end end @@ -32,7 +37,7 @@ class HomeworkCommonController < ApplicationController def edit @user = User.current - @is_in_course = params[:is_in_course] + @is_in_course = params[:is_in_course].to_i respond_to do |format| format.html{render :layout => 'new_base_user'} end @@ -148,9 +153,9 @@ class HomeworkCommonController < ApplicationController # 开启/关闭匿评消息通知 def send_message_anonymous_comment(homework, m_status ) # status 标记匿评状态 1为关闭 0为开启 - course = @homework.course - course.student.each do |st| - @homework.course_messages << CourseMessage.new(:user_id => st.student_id, :course_id => course.id, :viewed => false, :status => m_status) + course = homework.course + course.members.each do |m| + @homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => m_status) end end #提示 diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index c6ac8b906..4f3f3ec0d 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -163,11 +163,15 @@ class MessagesController < ApplicationController # @reply.reply_id = params[:id] @topic.children << @reply course_activity = CourseActivity.where("course_act_type='Message' and course_act_id =#{@topic.id}").first - course_activity.updated_at = Time.now - course_activity.save + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first - user_activity.updated_at = Time.now - user_activity.save + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? if params[:asset_id] diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 2d7bf02b1..f2858d097 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -173,6 +173,16 @@ class StudentWorkController < ApplicationController end if student_work.save + course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end + user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework.id}").first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end respond_to do |format| format.html { flash[:notice] = l(:notice_successful_create) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9a6f72e2e..4f3df3bd4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -346,6 +346,7 @@ class UsersController < ApplicationController user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" @homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10) @is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true) + @is_in_course = params[:is_in_course].to_i || 0 respond_to do |format| format.js format.html {render :layout => 'new_base_user'} @@ -508,7 +509,13 @@ class UsersController < ApplicationController if homework.save homework_detail_manual.save if homework_detail_manual homework_detail_programing.save if homework_detail_programing - redirect_to user_homeworks_user_path(User.current.id) + + if params[:is_in_course] == "1" + redirect_to homework_common_index_path(:course => homework.course_id) + else + redirect_to user_homeworks_user_path(User.current.id) + end + end end else diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index a0ce8d18e..a59f507df 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -55,12 +55,16 @@ class WordsController < ApplicationController @jfm = add_reply_adapter options @save_succ = true if @jfm.errors.empty? if @save_succ - course_activity = CourseActivity.where("course_act_type='JournalsForMessage' and course_act_id =#{parent_id}").first - course_activity.updated_at = Time.now - course_activity.save - user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first - user_activity.updated_at = Time.now - user_activity.save + course_activity = CourseActivity.where("course_act_type='JournalsForMessage' and course_act_id =#{parent_id}").first + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end + user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end end respond_to do |format| # format.html { diff --git a/app/models/course_message.rb b/app/models/course_message.rb index eae880380..65e91141c 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -1,4 +1,7 @@ class CourseMessage < ActiveRecord::Base + # status说明: status在课程不同的类型,区分不同的功能 + # HomeworkCommon:status: + # nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败 attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status # 多态 虚拟关联 diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb index 0dce57598..8bf754719 100644 --- a/app/models/forge_message.rb +++ b/app/models/forge_message.rb @@ -1,14 +1,7 @@ class ForgeMessage < ActiveRecord::Base - # 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT - TYPE_OF_ISSUE_ACT = "Issue" - TYPE_OF_MESSAGE_ACT = "Message" - TYPE_OF_ATTACHMENT_ACT = "Attachment" - TYPE_OF_DOCUMENT_ACT = "Document" - TYPE_OF_JOURNAL_ACT = "Journal" - TYPE_OF_WIKI_ACT = "Wiki" - TYPE_OF_NEWS_ACT = "News" - - attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key + # status在不同的类中,作用不同 + # Isseu: satus nil:发布了缺陷;:1:缺陷计划完成日志到了提醒 + attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed, :secret_key, :status belongs_to :forge_message ,:polymorphic => true belongs_to :project diff --git a/app/models/mailer.rb b/app/models/mailer.rb index b820e6d54..52b7242dd 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -51,9 +51,9 @@ class Mailer < ActionMailer::Base def send_mail_anonymous_comment_open(homework_common) course = homework_common.course recipients ||= [] - course.student.each do |student| - user = User.find(student.student_id) - @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}" + course.members.each do |member| + user = User.find(member.user_id) + # @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}" @token = Token.get_token_from_user(user, 'autologin') @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) @anonymous_comment_close_name = homework_common.name @@ -62,16 +62,16 @@ class Mailer < ActionMailer::Base recipients << user.mail end mail :to => recipients, - :subject => @subject + :subject => "[#{l(:mail_homework)}#{homework_common.name}] #{l(:mail_anonymous_comment_open)}" end # 作业匿评关闭 def send_mail_anonymous_comment_close(homework_common) course = homework_common.course recipients ||= [] - course.student.each do |student| - user = User.find(student.student_id) - @subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}" + course.members.each do |member| + user = User.find(member.user_id) + #@subject = "#{l(:mail_homework)}#{homework_common.name} #{l(:mail_anonymous_comment_open)}" @token = Token.get_token_from_user(user, 'autologin') @anonymous_comment_close_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) @anonymous_comment_close_name = homework_common.name @@ -80,7 +80,28 @@ class Mailer < ActionMailer::Base recipients << user.mail end mail :to => recipients, - :subject => @subject + :subject => "[#{l(:mail_homework)}#{homework_common.name}] #{l(:mail_anonymous_comment_open)}" + end + + # 匿评失败给老师发送邮件通知 + def send_mail_anonymous_comment_fail(homework_common) + course = homework_common.course + recipients ||= [] + # 只给该课程的老师发送邮件提醒 + course.members.each do |member| + if m.user.allowed_to?(:as_teacher,course) + user = User.find(member.user_id) + #@subject = "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}" + @token = Token.get_token_from_user(user, 'autologin') + @anonymous_comment_fail_url = url_for(student_work_index_url(:homework => homework_common.id, :token => @token.value)) + @anonymous_comment_fail_name = homework_common.name + @author = homework_common.user + #收件人邮箱 + recipients << user.mail + end + end + mail :to => recipients, + :subject => "[#{l(:mail_homework)} #{homework_common.name}] #{l(:mail_anonymous_comment_failed)}" end # author: alan @@ -247,6 +268,7 @@ class Mailer < ActionMailer::Base has_content = [@issues,@issues_journals,@course_messages,@project_messages,@course_news,@course_news_comments,@project_news,@project_news_comments,@project_attachments, @course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?} + mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 mail :to => user.mail,:subject => subject if has_content @@ -263,7 +285,7 @@ class Mailer < ActionMailer::Base #收件人邮箱 recipient = user.mail mail :to => recipient, - :subject => "#{l(:mail_homework)}#{homework_common.name}#{l(:mail_homework_endtime)} " + :subject => @subject end # 公共讨论区发帖、回帖添加邮件发送信息 diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index bc6dcacfa..bb8bb546a 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -1,7 +1,6 @@ diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 48ac057a0..714d364a4 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag 'new_user' %> +<%= javascript_include_tag 'new_user','/assets/kindeditor/pasteimg','/assets/kindeditor/kindeditor' %> @@ -99,11 +103,7 @@
- <%= l(:label_totle)%> - <%= @obj_count%> - <%= l(:label_homework_count)%> -
- <%#= link_to( l(:label_course_homework_new), new_homework_common_path(:course => @course.id), :class => 'problem_new_btn fl c_dorange') if @is_teacher %> - -- <%= l(:lebel_homework_commit)%> - ( <%= link_to homework.student_works.count, student_work_index_path(:homework => homework.id), :class => 'c_red'%> ) -
- <% if @is_teacher%> - <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework,:is_in_course => 1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr mr10 work_edit") %> - <%= link_to(l(:button_edit),edit_homework_common_path(homework,:is_in_course => 1), :class => "fr mr10 work_edit ml10") %> - <%= homework_anonymous_comment(homework)%> - <% elsif @is_student%> - <%= student_anonymous_comment homework %> - <%= student_new_homework homework %> - <% end %> - - -<%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @anonymous_comment_fail_name, @anonymous_comment_fail_url%> 匿评开启失败!
+ +git 克隆和提交的用户名和密码为登录用户名和密码
-项目代码请设置好正确的编码方式(utf-8),否则中文会出现乱码。
-通过cmd命令提示符进入代码对应文件夹的根目录, - 如果是首次提交代码,执行如下命令:
-git init
- -git add *
- -git commit -m "first commit"
- -git remote add origin - <%= @repos_url %> -
- -git config http.postBuffer 524288000 #设置本地post缓存为500MB
- -git push -u origin master
-已经有本地库,还没有配置远程地址,打开命令行执行如下:
-git remote add origin <%= @repos_url %>
- -git add .
- -git commit -m "first commit"
- -git config http.postBuffer 524288000 #设置本地post缓存为500MB
- -git push -u origin master
-已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:
-git clone <%= @repos_url %>
- -git push
- -git checkout -b branch_name
- -git push origin branch_name
-从网上获取别人的开源版本库,转交到trustie网站上,打开命令行执行如下:
-git remote add trustie - <%= @repos_url %> -
- -git add .
- -git commit -m "first commit"
- -git config http.postBuffer 524288000 #设置本地post缓存为500MB
- -git push -u trustie branch:branch
- -李海提供
-<%= string %>
@@ -133,17 +133,3 @@