diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index b3624b14d..6a0b351ba 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -386,14 +386,16 @@ class IssuesController < ApplicationController end def add_journal - jour = Journal.new - jour.user_id = User.current.id - jour.notes = params[:notes] - jour.journalized = @issue - jour.save - @user_activity_id = params[:user_activity_id] - respond_to do |format| - format.js + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end end end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 965aacab0..f71103973 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -101,27 +101,27 @@ class MessagesController < ApplicationController ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE end - # 与我相关动态的记录add start - if(@board && @board.course) #项目的先不管 - teachers = searchTeacherAndAssistant(@board.course) - for teacher in teachers - if(teacher.user_id != User.current.id) - notify = ActivityNotify.new() - if(@board.course) - notify.activity_container_id = @board.course_id - notify.activity_container_type = 'Course' - else - notify.activity_container_id = @board.project_id - notify.activity_container_type = 'Project' - end - notify.activity_id = @message.id - notify.activity_type = 'Message' - notify.notify_to = teacher.user_id - notify.is_read = 0 - notify.save() - end - end - end + # # 与我相关动态的记录add start + # if(@board && @board.course) #项目的先不管 + # teachers = searchTeacherAndAssistant(@board.course) + # for teacher in teachers + # if(teacher.user_id != User.current.id) + # notify = ActivityNotify.new() + # if(@board.course) + # notify.activity_container_id = @board.course_id + # notify.activity_container_type = 'Course' + # else + # notify.activity_container_id = @board.project_id + # notify.activity_container_type = 'Project' + # end + # notify.activity_id = @message.id + # notify.activity_type = 'Message' + # notify.notify_to = teacher.user_id + # notify.is_read = 0 + # notify.save() + # end + # end + # end # 与我相关动态的记录add end call_hook(:controller_messages_new_after_save, { :params => params, :message => @message}) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index ea4dd404a..9f8d25c7e 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -12,10 +12,37 @@ class StudentWorkController < ApplicationController ### def program_test - resultObj = {status: 0, results: [], error_msg: '', time: Time.now} - student_work = find_or_save_student_work - unless student_work - resultObj[:status] = 100 + is_test = params[:is_test] == 'true' + resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')} + unless is_test + student_work = find_or_save_student_work + + unless student_work + resultObj[:status] = 100 + else + if @homework.homework_type == 2 && @homework.homework_detail_programing + result = test_realtime(student_work, params[:src]) + logger.debug result + resultObj[:status] = result["status"] + resultObj[:results] = result["results"] + resultObj[:error_msg] = result["error_msg"] + results = result["results"] + if result["status"].to_i == -2 #编译错误 + results = [result["error_msg"]] + end + student_work_test = student_work.student_work_tests.build(status: result["status"], results: results, + src: params[:src]) + unless student_work.save + resultObj[:status] = 200 + else + resultObj[:status] = result["status"].to_i + resultObj[:time] = student_work_test.created_at.to_s(:db) + resultObj[:index] = student_work.student_work_tests.count + end + + end + end + else if @homework.homework_type == 2 && @homework.homework_detail_programing result = test_realtime(student_work, params[:src]) @@ -27,18 +54,15 @@ class StudentWorkController < ApplicationController if result["status"].to_i == -2 #编译错误 results = [result["error_msg"]] end - student_work_test = student_work.student_work_tests.build(status: result["status"], results: results, - src: params[:src]) - unless student_work.save - resultObj[:status] = 200 - else - resultObj[:status] = result["status"].to_i - resultObj[:time] = student_work_test.created_at.to_s(:db) - resultObj[:index] = student_work.student_work_tests.count - end - + + resultObj[:status] = result["status"].to_i + resultObj[:time] = Time.now.strftime('%Y-%m-%d %T') + resultObj[:index] = 0 end + end + + render :json => resultObj end @@ -142,10 +166,18 @@ class StudentWorkController < ApplicationController end def new + if @homework.homework_type==2 + redirect_to new_user_commit_homework_users_path(homework_id: @homework.id) + return + end + @user = User.current @student_work = @homework.student_works.where("user_id = ?",User.current.id).first if @student_work.nil? @student_work = StudentWork.new end + respond_to do |format| + format.html{ render :layout => "new_base_user"} + end end def create @@ -186,11 +218,12 @@ class StudentWorkController < ApplicationController end def edit + @user = User.current if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业 render_403 else respond_to do |format| - format.html + format.html{ render :layout => "new_base_user"} end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5bd124fb9..4bbb9848a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -102,9 +102,19 @@ class UsersController < ApplicationController # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) def user_messages unless User.current.logged? - render_403 + redirect_to signin_url return end + # 记录当前点击按钮的时间 + if OnclickTime.where("user_id =?", User.current).first.nil? + message_new_time = OnclickTime.new + message_new_time.user_id = User.current.id + message_new_time.onclick_time = Time.now + message_new_time.save + else + message_new_time = OnclickTime.where("user_id =?", User.current).first + message_new_time.update_attributes(:onclick_time => Time.now) + end # 当前用户查看消息,则设置消息为已读 if params[:viewed] == "all" course_querys = @user.course_messages @@ -296,12 +306,16 @@ class UsersController < ApplicationController #用户作业列表 def user_homeworks - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_course_ids = "(" + @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) - respond_to do |format| - format.js - format.html {render :layout => 'new_base_user'} + if User.current == @user + @page = params[:page] ? params[:page].to_i + 1 : 0 + user_course_ids = "(" + @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) + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 end end @@ -345,71 +359,80 @@ class UsersController < ApplicationController end def new_user_commit_homework - @user = User.current - @homework = HomeworkCommon.find(params[:homework_id]) - @student_work = @homework.student_works.where(user_id: User.current.id).first - if @student_work.nil? - @student_work = StudentWork.new - end - respond_to do |format| - format.js - format.html {render :layout => 'new_base_user'} + if User.current.logged? + @user = User.current + @homework = HomeworkCommon.find(params[:homework_id]) + @is_test = params[:is_test] == 'true' + @student_work = @homework.student_works.where(user_id: User.current.id).first + if @student_work.nil? + @student_work = StudentWork.new + end + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + else + render_403 end end def user_commit_homework flash[:notice] = l(:notice_successful_create) - redirect_to user_homeworks_user_path(User.current) + redirect_to student_work_index_url(:homework => params[:homework]) end def user_new_homework - if params[:homework_common] - homework = HomeworkCommon.new - homework.name = params[:homework_common][:name] - homework.description = params[:homework_common][:description] - homework.end_time = params[:homework_common][:end_time] || Time.now - homework.publish_time = Time.now - homework.homework_type = params[:homework_type].to_i || 1 - homework.late_penalty = 2 - homework.user_id = User.current.id - homework.course_id = params[:course_id] - - homework.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(homework) - - #匿评作业相关属性 - if homework.homework_type == 1 - homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = Time.now - homework_detail_manual.evaluation_end = Time.now - homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 - homework_detail_manual.absence_penalty = 2 - homework.homework_detail_manual = homework_detail_manual - else - homework_detail_programing = HomeworkDetailPrograming.new - homework.homework_detail_programing = homework_detail_programing - homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_programing.language = params[:program][:language].to_i - - inputs = params[:program][:input] - if Array === inputs - inputs.each_with_index do |val, i| - homework.homework_tests << HomeworkTest.new( - input: val, - output: params[:program][:output][i] - ) + if User.current.logged? + if params[:homework_common] + homework = HomeworkCommon.new + homework.name = params[:homework_common][:name] + homework.description = params[:homework_common][:description] + homework.end_time = params[:homework_common][:end_time] || Time.now + homework.publish_time = Time.now + homework.homework_type = params[:homework_type].to_i || 1 + homework.late_penalty = 2 + homework.user_id = User.current.id + homework.course_id = params[:course_id] + + homework.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(homework) + + #匿评作业相关属性 + if homework.homework_type == 1 + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = Time.now + homework_detail_manual.evaluation_end = Time.now + homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 + homework_detail_manual.absence_penalty = 2 + homework.homework_detail_manual = homework_detail_manual + else + homework_detail_programing = HomeworkDetailPrograming.new + homework.homework_detail_programing = homework_detail_programing + homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_programing.language = params[:program][:language].to_i + + inputs = params[:program][:input] + if Array === inputs + inputs.each_with_index do |val, i| + homework.homework_tests << HomeworkTest.new( + input: val, + output: params[:program][:output][i] + ) + end end + end - - end - 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 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) + end end + else + render_403 end end @@ -506,6 +529,7 @@ class UsersController < ApplicationController att_copy = atta.copy att_copy.container_id = nil att_copy.container_type = nil + att_copy.author_id = User.current.id att_copy.copy_from = atta.id att_copy.save @attachments << att_copy @@ -539,6 +563,10 @@ class UsersController < ApplicationController # modified by fq def user_newfeedback + unless User.current.logged? + redirect_to signin_url + return + end # 更新用户留言消息状态 @user.journals_for_messages.each do |jour_message| jour_message.user_feedback_messages.each do |userfeedback_message| @@ -766,7 +794,7 @@ class UsersController < ApplicationController @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - course_types = "('Message','News','HomeworkCommon','poll')" + course_types = "('Message','News','HomeworkCommon','Poll')" project_types = "('Message','Issue')" if params[:type].present? case params[:type] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ad9322cbc..2f210f466 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2347,7 +2347,7 @@ module ApplicationHelper if homework.homework_type == 1 && homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 link_to "修改作品", "", :class => 'c_blue', :title => "开启匿评后不可修改作品" elsif homework.homework_type == 2 #编程作业不能修改作品 - link_to "作品已交", "",:class => 'c_blue',:title => "编程作业不可修改作品" + link_to "作品已交", student_work_index_path(:homework => homework.id),:class => 'c_blue',:title => "编程作业不可修改作品" else link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue' end diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index f24d5078f..bff997ba4 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -1,4 +1,6 @@ # encoding: utf-8 +include UserScoreHelper + module StudentWorkHelper def user_projects_option cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" diff --git a/app/helpers/user_score_helper.rb b/app/helpers/user_score_helper.rb index 41f76a792..c82255d00 100644 --- a/app/helpers/user_score_helper.rb +++ b/app/helpers/user_score_helper.rb @@ -27,7 +27,7 @@ module UserScoreHelper issue_c = issue_c + Journal.where("user_id = ?", user.id).count ############################ memos = Memo.where('author_id = ? AND parent_id IS NOT NULL', user.id) - + memos.each do |m| if Memo.find(m.parent_id).author.id != user.id issue_c = issue_c + 1 @@ -35,18 +35,18 @@ module UserScoreHelper issue_c = issue_c - 1 end end - - + + pmemos = Memo.where('author_id = ? AND parent_id IS NULL', user.id) pmemos.each do |pm| issue_c = issue_c + pm.replies_count end ############################ - + issue_c = issue_c + JournalsForMessage.where('user_id = ? AND reply_id IS NOT NULL AND reply_id <> ?', user.id, user.id).count + JournalsForMessage.where('reply_id = ? AND user_id <> ?', user.id, user.id).count - - - + + + return issue_c end @@ -58,14 +58,14 @@ module UserScoreHelper def calculate_skill_count(user) - + praise_count_l0 = 0 praise_count_l1 = 0 praise_count_l2 = 0 tread_count_l0 = 0 tread_count_l1 = 0 tread_count_l2 = 0 - issues = Issue.where('author_id = ?', user.id) + issues = Issue.where('author_id = ?', user.id) issues.each do |i| pts = PraiseTread.where('praise_tread_object_id = ?', i.id) pts.each do |p| @@ -75,7 +75,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -97,7 +97,7 @@ module UserScoreHelper - + bids = Bid.where('author_id = ?', user.id) bids.each do |b| ptcs = PraiseTread.where('praise_tread_object_id = ?', b.id) @@ -108,7 +108,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -127,7 +127,7 @@ module UserScoreHelper end end end - + contests = Contest.where('author_id = ?', user.id) contests.each do |c| ptcs = PraiseTread.where('praise_tread_object_id = ?', c.id) @@ -138,7 +138,7 @@ module UserScoreHelper if p.praise_or_tread == 1 praise_count_l0 = praise_count_l0 + 1 else - tread_count_l0 = tread_count_l0 + 1 + tread_count_l0 = tread_count_l0 + 1 end end if templevel.to_i == 1 @@ -154,12 +154,12 @@ module UserScoreHelper else tread_count_l2 + tread_count_l2 + 1 end - end - end + end + end end - - - + + + # case level # when 0 skill_score = praise_count - 0.5 * tread_count # when 1 skill_score = 2 * praise_count - 1.5 * tread_count @@ -170,9 +170,9 @@ module UserScoreHelper skill_score = 2 * praise_count_l0.to_f + 3 * praise_count_l1.to_f + 4 * praise_count_l2.to_f - 1 * tread_count_l0.to_f - 1.5 * tread_count_l1.to_f - 2 * tread_count_l2.to_f - + tread_user_count = PraiseTread.where('praise_or_tread = ? AND user_id = ?', 0, user.id).count - + skill_score = skill_score.to_f - tread_user_count.to_f @@ -182,17 +182,17 @@ module UserScoreHelper return skill_score - - - + + + end - + def calculate_level(user) commit_count = user.changesets.count max_praise_num = 0 - - - issues = Issue.where('author_id = ?', user.id) + + + issues = Issue.where('author_id = ?', user.id) issues.each do |i| ptcs = PraiseTreadCache.where('object_id = ?', i.id) ptcs.each do |p| @@ -201,7 +201,7 @@ module UserScoreHelper end end end - + bids = Bid.where('author_id = ?', user.id) bids.each do |b| ptcs = PraiseTreadCache.where('object_id = ?', b.id) @@ -211,7 +211,7 @@ module UserScoreHelper end end end - + contests = Contest.where('author_id = ?', user.id) contests.each do |c| ptcs = PraiseTreadCache.where('object_id = ?', c.id) @@ -219,12 +219,12 @@ module UserScoreHelper if p.praise_num.to_i > max_praise_num.to_i max_praise_num = p.praise_num end - end + end end - - + + best_answer_num = 0 - + isManager = 0 members = Member.where('user_id = ?', user.id) members.each do |m| @@ -238,21 +238,21 @@ module UserScoreHelper end - + level = 0 - + if max_praise_num > 4 level = 1 end if commit_count > 0 and commit_count < 101 level = 1 - end + end if commit_count > 100 or isManager == 1 level = 2 end - + return level - + end def calculate_activity_count(user) @@ -282,23 +282,23 @@ module UserScoreHelper def calculate_issue(user) commit_count = user.changesets.count - + issue_details_count = 0 issues = Issue.where('assigned_to_id = ?', user.id) - + change_count = 0 issues.each do |issue| js = issue.journals js.each do |j| change_count = change_count + j.details.where("prop_key = ?", "done_ratio").count end - - + + issue_details_count = change_count + issue_details_count end - + return (commit_count + issue_details_count) - + end @@ -306,9 +306,9 @@ module UserScoreHelper attachments = Attachment.where("container_type IS NOT NULL AND container_type <> 'Issue' AND author_id = ?", user.id).count return attachments - + end - + def calculate_user_score(user) collaboration = calculate_collaboration_count(user) influence = calculate_influence_count(user) @@ -322,7 +322,7 @@ module UserScoreHelper UserScore.new(:collaboration => collaboration, :influence => influence, :skill => skill, :activity => activity, :file => file, :issue => issue, :level => level) end - + def update_user_score(user) collaboration = calculate_collaboration_count(user) influence = calculate_influence_count(user) @@ -331,7 +331,7 @@ module UserScoreHelper issue = calculate_issue(user) ##activity = calculate_activity_count(user) - + level = calculate_level(user) user.user_score.update_attributes(:collaboration => collaboration, :influence => influence, :skill => skill, :activity => activity, :file => file, :issue => issue, :level => level) @@ -423,7 +423,7 @@ module UserScoreHelper #更新分数 def update_score(option_number) - option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number) + option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + project_active(option_number) if option_number.total_score < 0 option_number.total_score = 0 end @@ -433,7 +433,7 @@ module UserScoreHelper #协同得分 def collaboration(option_number) - option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo + option_number.memo * 2 + option_number.messages_for_issues + option_number.issues_status + option_number.replay_for_message + option_number.replay_for_memo end #影响力得分 def influence(option_number) @@ -444,8 +444,8 @@ module UserScoreHelper option_number.praise_by_one * 4 + option_number.praise_by_two * 6 + option_number.praise_by_three * 8 - option_number.tread * 2 - option_number.tread_by_one * 2 - option_number.tread_by_two * 4 - option_number.tread_by_three * 6 end #项目贡献得分 - def active(option_number) - option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 + option_number.memo * 2 + def project_active(option_number) + option_number.changeset * 4 + option_number.document * 4 + option_number.attachment * 4 + option_number.issue_done_ratio * 2 + option_number.post_issue * 4 end #更新发帖数 diff --git a/app/models/course_message.rb b/app/models/course_message.rb index 4f62d24c2..eae880380 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -15,6 +15,8 @@ class CourseMessage < ActiveRecord::Base after_create :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb index 2d05972ab..0c8b3384f 100644 --- a/app/models/forge_message.rb +++ b/app/models/forge_message.rb @@ -22,6 +22,8 @@ class ForgeMessage < ActiveRecord::Base after_create :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/models/memo_message.rb b/app/models/memo_message.rb index 9be00ce14..ce3896389 100644 --- a/app/models/memo_message.rb +++ b/app/models/memo_message.rb @@ -12,6 +12,8 @@ class MemoMessage < ActiveRecord::Base after_create :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/models/news.rb b/app/models/news.rb index 6e2725d1c..a9e9d1d18 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -121,7 +121,7 @@ class News < ActiveRecord::Base # Description 公用表中也要记录 def act_as_forge_activity # 如果是project为空,那么是课程相关的,不需要保存 - if !self.project.nil? + if self.project self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.project.id) end diff --git a/app/models/onclick_time.rb b/app/models/onclick_time.rb new file mode 100644 index 000000000..c62a9274c --- /dev/null +++ b/app/models/onclick_time.rb @@ -0,0 +1,5 @@ +class OnclickTime < ActiveRecord::Base + attr_accessible :onclick_time, :user_id + + belongs_to :user +end diff --git a/app/models/query.rb b/app/models/query.rb index 19bd1bed5..65c78e71f 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -492,26 +492,29 @@ class Query < ActiveRecord::Base def project_statement project_clauses = [] - if project && !project.descendants.active.empty? - ids = [project.id] - if has_filter?("subproject_id") - case operator_for("subproject_id") - when '=' - # include the selected subprojects - ids += values_for("subproject_id").each(&:to_i) - when '!*' - # main project only - else - # all subprojects - ids += project.descendants.collect(&:id) - end - elsif Setting.display_subprojects_issues? - ids += project.descendants.collect(&:id) - end - project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') - elsif project - project_clauses << "#{Project.table_name}.id = %d" % project.id + # unless project.descendants.blank? + # if project && project.descendants && project.descendants.active && !project.descendants.active.empty? + # ids = [project.id] + # if has_filter?("subproject_id") + # case operator_for("subproject_id") + # when '=' + # # include the selected subprojects + # ids += values_for("subproject_id").each(&:to_i) + # when '!*' + # # main project only + # else + # # all subprojects + # ids += project.descendants.collect(&:id) + # end + # elsif Setting.display_subprojects_issues? + # ids += project.descendants.collect(&:id) + # end + # project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',') + # elsif project + if project + project_clauses << "#{Project.table_name}.id = %d" % project.id end + # end project_clauses.any? ? project_clauses.join(' AND ') : nil end diff --git a/app/models/user.rb b/app/models/user.rb index b08b29981..e7f4a8c50 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -132,6 +132,7 @@ class User < Principal has_many :course_messages has_many :memo_messages has_many :user_feedback_messages + has_one :onclick_time # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" @@ -209,7 +210,7 @@ class User < Principal before_save :update_hashed_password before_destroy :remove_references_before_destroy # added by fq - after_create :act_as_activity + after_create :act_as_activity, :add_onclick_time # end scope :in_group, lambda {|group| @@ -257,10 +258,16 @@ class User < Principal # 新消息统计 def count_new_message - course_count = CourseMessage.where("user_id =? and viewed =?", User.current.id, 0).count - forge_count = ForgeMessage.where("user_id =? and viewed =?", User.current.id, 0).count - user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", User.current.id, 0).count - user_memo_count = MemoMessage.where("user_id =? and viewed =?", User.current.id, 0).count + if OnclickTime.where("user_id =?", User.current).first.nil? + message_new_time = OnclickTime.new + message_new_time.user_id = User.current.id + message_new_time.onclick_time = User.current.last_login_on.nil? ? Time.now : User.current.last_login_on + message_new_time.save + end + course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count + forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count + user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count + user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count messages_count = course_count + forge_count + user_feedback_count + user_memo_count end @@ -994,6 +1001,10 @@ class User < Principal self.acts << Activity.new(:user_id => self.id) end + def add_onclick_time + self.onclick_time << OnclickTime.new(:user_id => self.id, :onclick_time => self.created_on) + end + # Removes references that are not handled by associations # Things that are not deleted are reassociated with the anonymous user def remove_references_before_destroy diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb index 02335b8e2..db7d3a384 100644 --- a/app/models/user_feedback_message.rb +++ b/app/models/user_feedback_message.rb @@ -11,6 +11,8 @@ class UserFeedbackMessage < ActiveRecord::Base after_save :add_user_message def add_user_message - self.message_alls << MessageAll.new(:user_id => self.user_id) + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end end end diff --git a/app/views/attachments/_new_form.html.erb b/app/views/attachments/_new_form.html.erb index 38b471897..47f6fd202 100644 --- a/app/views/attachments/_new_form.html.erb +++ b/app/views/attachments/_new_form.html.erb @@ -23,6 +23,7 @@ <% end %> <% end %> +
<% project = project %> <%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn', :style => ie8? ? 'display:none' : '' %> diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index c90dbf724..5ce51ff7b 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -10,6 +10,7 @@ div.respond-form .reply_btn{margin-left:565px;margin-top:5px;} div.recall_con{width:570px;} div.recall_con .reply_btn{margin-left:525px;margin-top:5px;} + .ke-container{height: 80px !important;} <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> -
-

创建作品

-
-
-
-
- <%= form_for(@student_work, - :html => { :multipart => true }, - :url => {:controller => 'student_work', - :action => 'create', - :homework => @homework.id - }) do |f|%> -
- <% if @homework.homework_type == 1%> -
- 提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息 -
- <% end%> -

- - <%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %> - <% if @homework.homework_type != 2%> - - 项目信息 - - - <% end%> -

-

-

-
-

- - <%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %> -

-
-

- - <% if @homework.homework_type == 2 && @homework.homework_detail_programing%> - <%= f.text_area "description", :class => "w620 hwork_txt h400", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => @homework.homework_detail_programing.language == "1" ? c_stantard_code_student : c_stantard_code_student_%> - <% else %> - <%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%> - <% end%> -

-

-

-
- <% if @homework.homework_type != 2%> -

- - <%= render :partial => 'attachments/new_form' %> -

-
+
+
+
提交作品
+
+
+
+
+ <%= form_for(@student_work, + :html => { :multipart => true }, + :url => {:controller => 'student_work', + :action => 'create', + :homework => @homework.id + }) do |f|%> +
+ <% if @homework.homework_type == 1%> +
+ 提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息 +
+ <% end%> +

+ + <%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %> + <% if @homework.homework_type != 2%> + + 项目信息 + + + <% end%> +

+

+

+
+

+ + <%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %> +

+
+

+ + <% if @homework.homework_type == 2 && @homework.homework_detail_programing%> + <%= f.text_area "description", :class => "w620 hwork_txt h400", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();", :value => @homework.homework_detail_programing.language == "1" ? c_stantard_code_student : c_stantard_code_student_%> + <% else %> + <%= f.text_area "description", :class => "w620 hwork_txt", :placeholder => "作品描述不能为空", :onkeyup => "regexStudentWorkDescription();"%> + <% end%> +

+

+

+
+ <% if @homework.homework_type != 2%> +

+ + <%= render :partial => 'attachments/new_form' %> +

+
+ <% end%> +

+ 提交作品 + <%= link_to "返  回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white mt10 ml10"%> +

+

+
<% end%> -

- 提交作品 - <%= link_to "返  回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%> -

-

-
- <% end%> +
+
+
+
-
-
-
<% else %> @@ -125,8 +127,8 @@ -
-
+ +
提交作品
@@ -201,6 +203,5 @@ <% end %> <% end %>
-
<% end %> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index f29512b0e..07a2dad39 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -22,7 +22,7 @@
截止时间:<%= activity.end_time.to_s %>
- 作业描述:<%= activity.description.html_safe %> + <%= activity.description.html_safe %>
-
帖子描述: +
<% if activity.parent_id.nil? %> <%= activity.content.to_s.html_safe%> <% else %> @@ -85,7 +85,7 @@ <% activity= activity.parent ? activity.parent : activity%> <% replies_all_i = 0 %> <% if count > 0 %> -
+
    <% activity.children.reorder("created_on desc").each do |reply|%> <% replies_all_i=replies_all_i+1 %> diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index a558911c1..d2213c743 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -19,7 +19,6 @@ 发布时间:<%= format_time(activity.created_on) %>
- 通知描述: <%= activity.description.html_safe %>
@@ -57,7 +56,7 @@ <% replies_all_i = 0 %> <% if count > 0 %> -
+
    <% activity.comments.reorder("created_on desc").each do |comment| %> <% replies_all_i = replies_all_i + 1 %> diff --git a/app/views/users/_course_poll.html.erb b/app/views/users/_course_poll.html.erb index 436ae2f46..bde8de90d 100644 --- a/app/views/users/_course_poll.html.erb +++ b/app/views/users/_course_poll.html.erb @@ -1,5 +1,6 @@ <% has_commit = has_commit_poll?(activity.id ,User.current)%> <% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> +<% if has_commit || activity.user_id == User.current %>
    @@ -28,7 +29,7 @@
    发布时间:<%= format_time(activity.published_at) %>
    -
    问卷描述:<%=activity.polls_description.html_safe.to_s%>
    +
    <%=activity.polls_description.html_safe.to_s%>
    -
    \ No newline at end of file +
    +<% end %> \ No newline at end of file diff --git a/app/views/users/_influence_new_score_index.html.erb b/app/views/users/_influence_new_score_index.html.erb index 505785351..f99cdee19 100644 --- a/app/views/users/_influence_new_score_index.html.erb +++ b/app/views/users/_influence_new_score_index.html.erb @@ -5,4 +5,4 @@
        <%= l('userscore.active.update_issues')%> * 2 = <%= option_num.issue_done_ratio %> * 2 = <%= option_num.issue_done_ratio * 2 %>
        <%= l('userscore.active.release_issues')%> * 4 = <%= option_num.post_issue %> * 4 = <%= option_num.post_issue * 4 %>
        <%= l('userscore.active.release_messages')%> * 1 = <%= option_num.memo %> * 2 = <%= option_num.memo * 2 %>
    -
        <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> + <%= option_num.memo * 2 %> = <%= active(option_num) %>
    \ No newline at end of file +
        <%= l(:label_user_score_of_active)%> = <%= option_num.changeset * 4 %> + <%= option_num.document * 4 %> + <%= option_num.attachment * 4 %> + <%= option_num.issue_done_ratio * 2 %> + <%= option_num.post_issue * 4 %> + <%= option_num.memo * 2 %> = <%= project_active(option_num) %>
    \ No newline at end of file diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 1bd0b834a..3a6eac49d 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -33,7 +33,7 @@ <%=format_time(activity.created_on) %>
-
缺陷描述: +
<% if activity.description? %> <%= textAreailizable activity, :description, :attachments => activity.attachments %> <% end %> @@ -94,7 +94,7 @@ <% replies_all_i = 0 %> <% if count > 0 %> -
+
    <% activity.journals.reorder("created_on desc").each do |reply| %> <% replies_all_i=replies_all_i + 1 %> diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index 6c3842f73..5fc10e48c 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -26,7 +26,7 @@
    时间:<%= format_time(activity.created_on) %>
    -
    帖子描述: +
    <% if activity.parent_id.nil? %> <%= activity.content.to_s.html_safe%> <% else %> @@ -71,7 +71,7 @@ <% activity= activity.parent_id.nil? ? activity : activity.parent %> <% replies_all_i = 0 %> <% if count > 0 %> -
    +
      <% activity.children.reorder("created_on desc").each do |reply| %> <% replies_all_i=replies_all_i+1 %> diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index e50b240fd..c1d23d0ed 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -5,8 +5,8 @@ <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
    = <%= format("%.2f" ,collaboration(option_num)).to_i %> + <%= format("%.2f" , influence(option_num) ).to_i %> - + <%= "(" if skill(option_num) < 0 %> <%= format("%.2f" , skill(option_num)).to_i %> <%= ")" if skill(option_num) < 0 %> + <%= format("%.2f" , active(option_num)).to_i %>
    - <% if (format("%.2f" ,collaboration(option_num)).to_i + format("%.2f" , influence(option_num) ).to_i + format("%.2f" , skill(option_num)).to_i + format("%.2f" , active(option_num)).to_i) < 0 %> + + <%= "(" if skill(option_num) < 0 %> <%= format("%.2f" , skill(option_num)).to_i %> <%= ")" if skill(option_num) < 0 %> + <%= format("%.2f" ,project_active(option_num)).to_i %>
    + <% if (format("%.2f" ,collaboration(option_num)).to_i + format("%.2f" , influence(option_num) ).to_i + format("%.2f" , skill(option_num)).to_i + format("%.2f" , project_active(option_num)).to_i) < 0 %>
    <%= l(:label_score_less_than_zero) %>
    <% else %>
    = <%= format("%.2f" ,option_num.total_score).to_i %>
    diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index 2081c38d6..4e89506a6 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -68,7 +68,7 @@
  • <%= link_to l(:label_user_score_of_active), "javascript:void(0)", :onclick => "show_div('influence_new_score_index')" %> : - <%= format("%.2f" , active(option_num)).to_i %> + <%= format("%.2f" , project_active(option_num)).to_i %>
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index f1529ffb8..4ff98b1b7 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -9,7 +9,7 @@ span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;} div.ke-toolbar .ke-outline{border:none;} .ke-inline-block{display: none;} - .ke-container{height: 40px !important;} + .ke-container{height: 30px !important;} <% user_activities.each do |user_activity| if user_activities %> @@ -23,7 +23,7 @@ target.show(); }else{ btn.data('init',0); - btn.html('点击展开更多回复('+btn.data('count')+')'); + btn.html('展开更多('+btn.data('count')+')'); target.hide(); target.eq(0).show(); target.eq(1).show(); diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index 076383607..f0bab160f 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -19,6 +19,11 @@
<%= user_for_homework_common homework_common,is_teacher %>
+ <% if homework_common.homework_type == 2 && is_teacher%> +
+ <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue' %> +
+ <% end %>
<%= l(:label_end_time)%>:<%= homework_common.end_time%>
diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index a150c39ba..8d5a1a48c 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -41,19 +41,17 @@
-
提交作品
+
<%= @is_test ? '模拟答题' : '提交作品' %>
<%= @homework.name %>
截止时间:<%= @homework.end_time %>
<%= @homework.user.show_name %> -

<%= @homework.description %>
-输入 2 1 1 4 4 2 3 6 5
-输出 15
+

<%= @homework.description.html_safe %>

-

注:迟交扣2分,缺评一个作品扣2

+
<%= form_for(@student_work, @@ -64,7 +62,7 @@ :homework => @homework.id }, :method => :post) do |f|%> - +
请使用 <%= @homework.language_name %> 语言编写
@@ -76,13 +74,18 @@
测试代码 + <% unless @is_test %> 提交代码 + <% end %>
<% end %>
+ +
+ <% @student_work.student_work_tests.each_with_index do |test, index| %>

第<%= @student_work.student_work_tests.count - index%>次测试

<%= test.created_at.to_s(:db) %> diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb index 894c1d2fa..d295ce003 100644 --- a/app/views/users/resource_search.js.erb +++ b/app/views/users/resource_search.js.erb @@ -1,3 +1,5 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -$("#res_all_count").html(<%= @atta_count%>); \ No newline at end of file +$("#res_all_count").html(<%= @atta_count%>); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c1cd3723f..92f3f4a1a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -37,4 +37,4 @@
-<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type} %> +<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type} %> diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 29020560d..c3c1a447b 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -31,7 +31,7 @@
<% if params[:type].nil? %> <% end %> <% if @message_alls.count >0 %> @@ -59,7 +59,7 @@ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> -
+
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -100,7 +100,7 @@ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> -
    + <% end %> @@ -182,7 +182,7 @@ :topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> -
    + <% end %> @@ -240,7 +240,7 @@ :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> -
    + <% end %> @@ -264,7 +264,7 @@ :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> -
    +
  • <%= time_tag(ma.journals_for_message.created_on).html_safe %>
  • @@ -290,7 +290,7 @@ function message_titile_show(obj,e) { obj.parent().next("div").show(); - obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","fixed"); + obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","absolute"); } function message_titile_hide(obj) { diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index 60e630959..19cdd845f 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -8,6 +8,7 @@ span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;} span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;} div.ke-toolbar .ke-outline{border:none;} + .ke-container{height: 80px !important;}
    diff --git a/db/migrate/20150829023459_forge_messages.rb b/db/migrate/20150829023459_forge_messages.rb index c468ad68f..96369a323 100644 --- a/db/migrate/20150829023459_forge_messages.rb +++ b/db/migrate/20150829023459_forge_messages.rb @@ -1,78 +1,78 @@ # encoding: UTF-8 class ForgeMessages < ActiveRecord::Migration def up - Project.all.each do |project| - transaction do - project.forge_messages << ForgeMessage.new(:user_id => project.user_id, :project_id => project.id) - - # 新闻 - project.news.each do |new| - new.project.members.each do |m| - if m.user_id != new.author_id - if m.created_on < new.created_on # 在成员加入项目之后 - new.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => new.project_id, :viewed => true) - end - end - end - end - - # 新闻回复 - project.news.each do |new| - if new.comments - new.comments.each do |comment| - if comment.author_id != comment.commented.author_id - comment.forge_messages << ForgeMessage.new(:user_id => comment.commented.author_id, :project_id => comment.commented.project.id, :viewed => true) - end - end - end - end - - # 讨论区 - if project.boards.first - project.boards.first.messages.each do |message| - if message.parent_id.nil? # 主贴 - message.project.members.each do |m| - if m.user_id != message.author_id - if m.created_on < message.created_on - message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) - end - end - end - else # 回帖 - message.project.members.each do |m| - if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 - if m.created_on < message.created_on - message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) - end - end - end - end - end - end - - # 缺陷 - project.issues.each do |issue| - unless issue.author_id == issue.assigned_to_id - issue.forge_messages << ForgeMessage.new(:user_id => issue.assigned_to_id, :project_id => issue.project_id, :viewed => true) - end - end - - # 缺陷更新 - project.issues.each do |issue| - if issue.journals - issue.journals.each do |journal| - if journal.user_id != journal.issue.author_id - journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.author_id, :project_id => journal.issue.project_id, :viewed => true) - end - if journal.user_id != journal.issue.assigned_to_id && journal.issue.assigned_to_id != journal.issue.author_id # 指派人不是自己的话,则给指派人发送 - journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.assigned_to_id, :project_id => journal.issue.project_id, :viewed => true) - end - end - end - end - - end - end + # Project.all.each do |project| + # transaction do + # project.forge_messages << ForgeMessage.new(:user_id => project.user_id, :project_id => project.id) + # + # # 新闻 + # project.news.each do |new| + # new.project.members.each do |m| + # if m.user_id != new.author_id + # if m.created_on < new.created_on # 在成员加入项目之后 + # new.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => new.project_id, :viewed => true) + # end + # end + # end + # end + # + # # 新闻回复 + # project.news.each do |new| + # if new.comments + # new.comments.each do |comment| + # if comment.author_id != comment.commented.author_id + # comment.forge_messages << ForgeMessage.new(:user_id => comment.commented.author_id, :project_id => comment.commented.project.id, :viewed => true) + # end + # end + # end + # end + # + # # 讨论区 + # if project.boards.first + # project.boards.first.messages.each do |message| + # if message.parent_id.nil? # 主贴 + # message.project.members.each do |m| + # if m.user_id != message.author_id + # if m.created_on < message.created_on + # message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) + # end + # end + # end + # else # 回帖 + # message.project.members.each do |m| + # if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 + # if m.created_on < message.created_on + # message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true) + # end + # end + # end + # end + # end + # end + # + # # 缺陷 + # project.issues.each do |issue| + # unless issue.author_id == issue.assigned_to_id + # issue.forge_messages << ForgeMessage.new(:user_id => issue.assigned_to_id, :project_id => issue.project_id, :viewed => true) + # end + # end + # + # # 缺陷更新 + # project.issues.each do |issue| + # if issue.journals + # issue.journals.each do |journal| + # if journal.user_id != journal.issue.author_id + # journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.author_id, :project_id => journal.issue.project_id, :viewed => true) + # end + # if journal.user_id != journal.issue.assigned_to_id && journal.issue.assigned_to_id != journal.issue.author_id # 指派人不是自己的话,则给指派人发送 + # journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.assigned_to_id, :project_id => journal.issue.project_id, :viewed => true) + # end + # end + # end + # end + # + # end + # end end def down diff --git a/db/migrate/20150829024549_course_messages.rb b/db/migrate/20150829024549_course_messages.rb index 34f4e9ef2..9d66bf9cd 100644 --- a/db/migrate/20150829024549_course_messages.rb +++ b/db/migrate/20150829024549_course_messages.rb @@ -1,80 +1,80 @@ # encoding: UTF-8 class CourseMessages < ActiveRecord::Migration def up - Course.all.each do |course| - transaction do - put course.id - course.course_messages << CourseMessage.new(:user_id => course.tea_id,:course_id => course.id) - # 作业 - course.homework_commons.each do |homework_common| - homework_common.course.members.each do |m| - if m.user_id != homework_common.user_id - if m.created_on < homework_common.created_at - homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - end - - # 通知 - course.news.each do |new| - new.course.members.each do |m| - if m.user_id != new.author_id - if m.created_on < new.created_on # 在成员加入课程之后 - new.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - end - - # 通知的回复 - course.news.each do |new| - if new.comments - new.comments.each do |comment| - if comment.author_id != comment.commented.author_id - comment.course_messages << CourseMessage.new(:user_id => comment.commented.author_id, :course_id => course.id, :viewed => true) - end - end - end - end - - # 讨论区 - if course.boards.first - course.boards.first.messages.each do |message| - if message.parent_id.nil? # 主贴 - message.course.members.each do |m| - if message.author.allowed_to?(:as_teacher, message.course) && m.user_id != message.author_id # 老师 自己的帖子不给自己发送消息 - if m.created_on < message.created_on - message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - else # 回帖 - message.course.members.each do |m| - if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 - if m.created_on < message.created_on - message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - end - end - end - - # 问卷 - Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll| - if poll.polls_status == 2 #问卷是发布状态 - Course.find(poll.polls_group_id).members.each do |m| - if m.user_id != poll.user_id - if m.created_on < poll.created_at - poll.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) - end - end - end - elsif poll.polls_status == 1 #问卷是新建状态 - poll.course_messages.destroy_all - end - end + # Course.all.each do |course| + # transaction do + # put course.id + # course.course_messages << CourseMessage.new(:user_id => course.tea_id,:course_id => course.id) + # # 作业 + # course.homework_commons.each do |homework_common| + # homework_common.course.members.each do |m| + # if m.user_id != homework_common.user_id + # if m.created_on < homework_common.created_at + # homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # + # # 通知 + # course.news.each do |new| + # new.course.members.each do |m| + # if m.user_id != new.author_id + # if m.created_on < new.created_on # 在成员加入课程之后 + # new.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # + # # 通知的回复 + # course.news.each do |new| + # if new.comments + # new.comments.each do |comment| + # if comment.author_id != comment.commented.author_id + # comment.course_messages << CourseMessage.new(:user_id => comment.commented.author_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # + # # 讨论区 + # if course.boards.first + # course.boards.first.messages.each do |message| + # if message.parent_id.nil? # 主贴 + # message.course.members.each do |m| + # if message.author.allowed_to?(:as_teacher, message.course) && m.user_id != message.author_id # 老师 自己的帖子不给自己发送消息 + # if m.created_on < message.created_on + # message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # else # 回帖 + # message.course.members.each do |m| + # if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息 + # if m.created_on < message.created_on + # message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # end + # end + # end + # + # # 问卷 + # Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll| + # if poll.polls_status == 2 #问卷是发布状态 + # Course.find(poll.polls_group_id).members.each do |m| + # if m.user_id != poll.user_id + # if m.created_on < poll.created_at + # poll.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true) + # end + # end + # end + # elsif poll.polls_status == 1 #问卷是新建状态 + # poll.course_messages.destroy_all + # end + # end # 作品评阅 # course.homework_commons.each do |homework_common| @@ -107,8 +107,8 @@ class CourseMessages < ActiveRecord::Migration # end # 作品讨论 - end - end + # end + # end end def down diff --git a/db/migrate/20150829081822_update_message_time.rb b/db/migrate/20150829081822_update_message_time.rb index 09e42b6d1..a5b2457ad 100644 --- a/db/migrate/20150829081822_update_message_time.rb +++ b/db/migrate/20150829081822_update_message_time.rb @@ -1,25 +1,25 @@ class UpdateMessageTime < ActiveRecord::Migration def up - course_count = CourseMessage.all.count / 30 + 1 - transaction do - for i in 1 ... course_count do i - CourseMessage.page(i).per(30).each do |cmessage| - if cmessage.course_message - if cmessage.course_message.respond_to?("created_at") - cmessage.created_at = cmessage.course_message.created_at - elsif cmessage.course_message.respond_to?("created_on") - cmessage.created_at = cmessage.course_message.created_on - end - cmessage.save - puts cmessage.id - - course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first - course_all_message.created_at = cmessage.created_at - course_all_message.save - end - end - end - end + # course_count = CourseMessage.all.count / 30 + 1 + # transaction do + # for i in 1 ... course_count do i + # CourseMessage.page(i).per(30).each do |cmessage| + # if cmessage.course_message + # if cmessage.course_message.respond_to?("created_at") + # cmessage.created_at = cmessage.course_message.created_at + # elsif cmessage.course_message.respond_to?("created_on") + # cmessage.created_at = cmessage.course_message.created_on + # end + # cmessage.save + # puts cmessage.id + # + # course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first + # course_all_message.created_at = cmessage.created_at + # course_all_message.save + # end + # end + # end + # end end def down diff --git a/db/migrate/20150829130302_update_forge_message_time.rb b/db/migrate/20150829130302_update_forge_message_time.rb index 295cafea6..3121278ae 100644 --- a/db/migrate/20150829130302_update_forge_message_time.rb +++ b/db/migrate/20150829130302_update_forge_message_time.rb @@ -1,25 +1,25 @@ class UpdateForgeMessageTime < ActiveRecord::Migration def up - forge_count = ForgeMessage.all.count / 30 + 1 - transaction do - for i in 1 ... forge_count do i - ForgeMessage.page(i).per(30).each do |fmessage| - if fmessage.forge_message - if fmessage.forge_message.respond_to?("created_at") - fmessage.created_at = fmessage.forge_message.created_at - elsif fmessage.forge_message.respond_to?("created_on") - fmessage.created_at = fmessage.forge_message.created_on - end - fmessage.save - puts fmessage.id - - forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first - forge_all_message.created_at = fmessage.created_at - forge_all_message.save - end - end - end - end + # forge_count = ForgeMessage.all.count / 30 + 1 + # transaction do + # for i in 1 ... forge_count do i + # ForgeMessage.page(i).per(30).each do |fmessage| + # if fmessage.forge_message + # if fmessage.forge_message.respond_to?("created_at") + # fmessage.created_at = fmessage.forge_message.created_at + # elsif fmessage.forge_message.respond_to?("created_on") + # fmessage.created_at = fmessage.forge_message.created_on + # end + # fmessage.save + # puts fmessage.id + # + # forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first + # forge_all_message.created_at = fmessage.created_at + # forge_all_message.save + # end + # end + # end + # end end def down diff --git a/db/migrate/20150831070611_about_memo_message.rb b/db/migrate/20150831070611_about_memo_message.rb index fde94d2f9..a6e4a34c1 100644 --- a/db/migrate/20150831070611_about_memo_message.rb +++ b/db/migrate/20150831070611_about_memo_message.rb @@ -1,34 +1,34 @@ class AboutMemoMessage < ActiveRecord::Migration def up - Memo.all.each do |memo| - transaction do - # 贴吧帖子 - receivers = [] - u = User.find(6) - receivers << u - # 主贴 - if memo.parent_id.nil? - if memo.author_id != memo.forum.creator_id # 发帖人不是吧主 - receivers << memo.forum.creator - end - else # 回帖 - # 添加吧主 - if memo.author_id != memo.forum.creator_id - receivers << memo.forum.creator - end - # 添加发帖人 - unless memo.parent.nil? - if memo.author_id != memo.parent.author_id - receivers << memo.parent.author - puts memo.id - end - end - end - receivers.each do |r| - memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => true) - end - end - end + # Memo.all.each do |memo| + # transaction do + # # 贴吧帖子 + # receivers = [] + # u = User.find(6) + # receivers << u + # # 主贴 + # if memo.parent_id.nil? + # if memo.author_id != memo.forum.creator_id # 发帖人不是吧主 + # receivers << memo.forum.creator + # end + # else # 回帖 + # # 添加吧主 + # if memo.author_id != memo.forum.creator_id + # receivers << memo.forum.creator + # end + # # 添加发帖人 + # unless memo.parent.nil? + # if memo.author_id != memo.parent.author_id + # receivers << memo.parent.author + # puts memo.id + # end + # end + # end + # receivers.each do |r| + # memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => true) + # end + # end + # end end def down diff --git a/db/migrate/20150831093918_about_user_feedback_message.rb b/db/migrate/20150831093918_about_user_feedback_message.rb index d021bc3ad..a76b7c5e3 100644 --- a/db/migrate/20150831093918_about_user_feedback_message.rb +++ b/db/migrate/20150831093918_about_user_feedback_message.rb @@ -1,34 +1,34 @@ class AboutUserFeedbackMessage < ActiveRecord::Migration def up - JournalsForMessage.all.each do |jour_for_message| - transaction do - # 主留言 - if jour_for_message.jour_type == 'Principal' - receivers = [] - if jour_for_message.reply_id == 0 - if jour_for_message.user_id != jour_for_message.jour_id # 过滤自己给自己的留言消息 - receivers << jour_for_message.jour - end - else # 留言回复 - reply_to = User.find(jour_for_message.reply_id) - if jour_for_message.user_id != jour_for_message.reply_id # 添加我回复的那个人 - receivers << reply_to - end - unless jour_for_message.parent.nil? - if jour_for_message.user_id != jour_for_message.parent.jour_id && jour_for_message.reply_id != jour_for_message.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 - receivers << jour_for_message.parent.jour - end - end - end - unless receivers.blank? - receivers.each do |r| - puts jour_for_message.id - jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => true) - end - end - end - end - end + # JournalsForMessage.all.each do |jour_for_message| + # transaction do + # # 主留言 + # if jour_for_message.jour_type == 'Principal' + # receivers = [] + # if jour_for_message.reply_id == 0 + # if jour_for_message.user_id != jour_for_message.jour_id # 过滤自己给自己的留言消息 + # receivers << jour_for_message.jour + # end + # else # 留言回复 + # reply_to = User.find(jour_for_message.reply_id) + # if jour_for_message.user_id != jour_for_message.reply_id # 添加我回复的那个人 + # receivers << reply_to + # end + # unless jour_for_message.parent.nil? + # if jour_for_message.user_id != jour_for_message.parent.jour_id && jour_for_message.reply_id != jour_for_message.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发 + # receivers << jour_for_message.parent.jour + # end + # end + # end + # unless receivers.blank? + # receivers.each do |r| + # puts jour_for_message.id + # jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => true) + # end + # end + # end + # end + # end end def down diff --git a/db/migrate/20150901004812_update_memo_message_time.rb b/db/migrate/20150901004812_update_memo_message_time.rb index 80ae557fc..8760a50a4 100644 --- a/db/migrate/20150901004812_update_memo_message_time.rb +++ b/db/migrate/20150901004812_update_memo_message_time.rb @@ -1,25 +1,25 @@ class UpdateMemoMessageTime < ActiveRecord::Migration def up - memo_count = Memo.all.count / 30 + 1 - transaction do - for i in 1 ... memo_count do i - MemoMessage.page(i).per(30).each do |memo_message| - if memo_message.memo - if memo_message.memo.respond_to?("created_at") - memo_message.created_at = memo_message.memo.created_at - elsif memo_message.memo.respond_to?("created_on") - memo_message.created_at = memo_message.memo.created_on - end - memo_message.save - puts memo_message.id - - memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first - memo_messages.created_at = memo_message.created_at - memo_messages.save - end - end - end - end + # memo_count = Memo.all.count / 30 + 1 + # transaction do + # for i in 1 ... memo_count do i + # MemoMessage.page(i).per(30).each do |memo_message| + # if memo_message.memo + # if memo_message.memo.respond_to?("created_at") + # memo_message.created_at = memo_message.memo.created_at + # elsif memo_message.memo.respond_to?("created_on") + # memo_message.created_at = memo_message.memo.created_on + # end + # memo_message.save + # puts memo_message.id + # + # memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first + # memo_messages.created_at = memo_message.created_at + # memo_messages.save + # end + # end + # end + # end end def down diff --git a/db/migrate/20150901004910_update_userfeeback_message_time.rb b/db/migrate/20150901004910_update_userfeeback_message_time.rb index 686bc496e..95bfbd2ac 100644 --- a/db/migrate/20150901004910_update_userfeeback_message_time.rb +++ b/db/migrate/20150901004910_update_userfeeback_message_time.rb @@ -1,25 +1,25 @@ class UpdateUserfeebackMessageTime < ActiveRecord::Migration def up - user_feedback_count = UserFeedbackMessage.all.count / 30 + 1 - transaction do - for i in 1 ... user_feedback_count do i - UserFeedbackMessage.page(i).per(30).each do |ufm| - if ufm.journals_for_message - if ufm.journals_for_message.respond_to?("created_at") - ufm.created_at = ufm.journals_for_message.created_at - elsif ufm.journals_for_message.respond_to?("created_on") - ufm.created_at = ufm.journals_for_message.created_on - end - puts ufm.id - ufm.save - - user_feedback_messages = MessageAll.where("message_type = '#{ufm.class.to_s}' and message_id = '#{ufm.id}'").first - user_feedback_messages.created_at = ufm.created_at - user_feedback_messages.save - end - end - end - end + # user_feedback_count = UserFeedbackMessage.all.count / 30 + 1 + # transaction do + # for i in 1 ... user_feedback_count do i + # UserFeedbackMessage.page(i).per(30).each do |ufm| + # if ufm.journals_for_message + # if ufm.journals_for_message.respond_to?("created_at") + # ufm.created_at = ufm.journals_for_message.created_at + # elsif ufm.journals_for_message.respond_to?("created_on") + # ufm.created_at = ufm.journals_for_message.created_on + # end + # puts ufm.id + # ufm.save + # + # user_feedback_messages = MessageAll.where("message_type = '#{ufm.class.to_s}' and message_id = '#{ufm.id}'").first + # user_feedback_messages.created_at = ufm.created_at + # user_feedback_messages.save + # end + # end + # end + # end end def down diff --git a/db/migrate/20150906025009_forge_activitues_date.rb b/db/migrate/20150906025009_forge_activitues_date.rb new file mode 100644 index 000000000..b282d1938 --- /dev/null +++ b/db/migrate/20150906025009_forge_activitues_date.rb @@ -0,0 +1,25 @@ +class ForgeActivituesDate < ActiveRecord::Migration + def up + forge_count = ForgeActivity.all.count / 30 + 2 + transaction do + for i in 1 ... forge_count do i + ForgeActivity.page(i).per(30).each do |activity| + unless activity.forge_act_type == "ProjectCreateInfo" + if activity.forge_act + unless activity.forge_act.project + # puts activity.id + activity.destroy + end + else + # puts activity.id.to_s + "----" + activity.destroy + end + end + end + end + end + end + + def down + end +end diff --git a/db/migrate/20150906065702_create_onclick_times.rb b/db/migrate/20150906065702_create_onclick_times.rb new file mode 100644 index 000000000..3922b775e --- /dev/null +++ b/db/migrate/20150906065702_create_onclick_times.rb @@ -0,0 +1,10 @@ +class CreateOnclickTimes < ActiveRecord::Migration + def change + create_table :onclick_times do |t| + t.integer :user_id + t.datetime :onclick_time + + t.timestamps + end + end +end diff --git a/db/migrate/20150906083453_delete_anonymous_jour.rb b/db/migrate/20150906083453_delete_anonymous_jour.rb new file mode 100644 index 000000000..5361eb5e1 --- /dev/null +++ b/db/migrate/20150906083453_delete_anonymous_jour.rb @@ -0,0 +1,15 @@ +class DeleteAnonymousJour < ActiveRecord::Migration + def up + jour_count = Journal.all.count / 30 + 2 + transaction do + for i in 1 ... jour_count do i + Journal.page(i).per(30).each do |jour| + jour.destroy if jour.user_id == 2 + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 05825bd5d..e44bdd1d9 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 => 20150829070453) do +ActiveRecord::Schema.define(:version => 20150906083453) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -497,23 +497,26 @@ ActiveRecord::Schema.define(:version => 20150829070453) 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| @@ -936,6 +939,13 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.datetime "updated_at", :null => false end + create_table "onclick_times", :force => true do |t| + t.integer "user_id" + t.datetime "onclick_time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "open_id_authentication_associations", :force => true do |t| t.integer "issued" t.integer "lifetime" @@ -1296,11 +1306,11 @@ ActiveRecord::Schema.define(:version => 20150829070453) do create_table "student_work_tests", :force => true do |t| t.integer "student_work_id" - t.integer "homework_test_id" - t.integer "result" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "error_msg" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 9 + t.text "results" + t.text "src" end create_table "student_works", :force => true do |t| @@ -1317,6 +1327,7 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.datetime "updated_at", :null => false t.integer "late_penalty", :default => 0 t.integer "absence_penalty", :default => 0 + t.integer "system_score" end create_table "student_works_evaluation_distributions", :force => true do |t| @@ -1534,7 +1545,6 @@ ActiveRecord::Schema.define(:version => 20150829070453) do t.string "identity_url" t.string "mail_notification", :default => "", :null => false t.string "salt", :limit => 64 - t.integer "gid" end add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index 67bfd59c3..6813f90af 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -26,6 +26,7 @@ $(function(){ var student_work_id = $('#test-program-btn').attr('data-student-work-id'); var src = $('#program-src').val(); var title = $('#program-title').val(); + var is_test = $('input[name=is_test]').val(); if(!valid_form()){ return; @@ -33,10 +34,13 @@ $(function(){ $.post( '/student_work/program_test', - {homework: homework_id, student_work_id: student_work_id, src: src, title: title}, + {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}, function(data,status){ tested = true; console.log(data); + if(data.index <=0){ + data.index = $('.ProResultTop').length+1; + } if (typeof cb == 'function') {cb(); return;} @@ -44,7 +48,7 @@ $(function(){ var html=bt('t:result-list',data); $('.ProResult').prepend(html); - if (data.status==0) { + if (data.status==0 && is_test != 'true') { var r=confirm("答题正确,是否立刻提交?"); if (r) { $(".HomeWorkCon form").submit(); diff --git a/public/javascripts/init_KindEditor.js b/public/javascripts/init_KindEditor.js index 31f0efe81..fc02146bb 100644 --- a/public/javascripts/init_KindEditor.js +++ b/public/javascripts/init_KindEditor.js @@ -1,6 +1,6 @@ function init_editor(params){ var editor = params.kindutil.create(params.textarea, { - resizeType : 0,minWidth:"1px",width:"100%",minHeight:"28px", + resizeType : 1,minWidth:"1px",width:"100%",height:"80px", items:['emoticons'], afterChange:function(){//按键事件 nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index 3607c3f09..fdf739bd0 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -131,4 +131,50 @@ function search_homework_by_name(url){ function (data) { } ); +} + +//提交新建作品 +function new_student_work() +{ + if(regexStudentWorkName()&®exStudentWorkDescription()) + {$("#new_student_work").submit();} +} + +function edit_student_work(id) +{ + if(regexStudentWorkName()&®exStudentWorkDescription()) + {$("#edit_student_work_" + id).submit();} +} + +//验证作品名称 +function regexStudentWorkName() +{ + var name = $.trim($("#student_work_name").val()); + + if(name=="") + { + $("#student_work_name_span").text("作品名称不能为空"); + return false; + } + else + { + $("#student_work_name_span").text(""); + return true; + } +} + +function regexStudentWorkDescription() +{ + var name = $.trim($("#student_work_description").val()); + + if(name=="") + { + $("#student_work_description_textarea").text("作品描述不能为空"); + return false; + } + else + { + $("#student_work_description_textarea").text(""); + return true; + } } \ No newline at end of file diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index e65afbe1e..f8000f674 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -187,7 +187,7 @@ a:hover.grey_n_btn{ background:#717171; color:#fff;} .green_btn{ background:#28be6c; color:#fff; font-weight:normal;padding:2px 10px; text-align:center;} a.green_btn{background:#28be6c;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.green_btn{ background:#14ad5a;} -.blue_btn{ background:#64bdd9; color:#fff; font-weight:normal;padding:2px 10px; text-align:center;} +.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} a.blue_btn{background:#64bdd9;color:#fff; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.blue_btn{ background:#329cbd;} a.orange_btn{ background:#ff5722;color:#fff; font-weight:normal; padding:2px 10px; text-align:center; } @@ -925,6 +925,7 @@ img.ui-datepicker-trigger { text-overflow: ellipsis; margin-bottom: 3px; } +.message_title{border: 1px solid #D4D4D4;padding: 0.6em;margin-left: 1.4em;margin-right: 0.4em;border-radius: 4px;font-family: "Microsoft YaHei";background-size: 100% 100%;margin-bottom: 5px;background-color: #E8E8E8;} .description{display: none !important;} .ispublic-label{display: none !important;} .is_public_checkbox{display: none !important;} @@ -953,3 +954,50 @@ blockquote { background-color: #e8e8e8; } +/* 创建作品 work */ +.Newwork{ width:668px; height:418px;} +.N_top{ float:right; margin-left:390px; } +.N_con{ color:#484747; font-weight:bold; width:660px; margin-top:10px; } +.N_con p{ } +.w430{ width:470px;} +.w557{ width:557px;} +.w350{ width:350px;} +.h400{height: 400px !important;} +.w620{ width:480px; height:160px; border:1px solid #CCC;} +.bo{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:470px; } +.bo02{height:26px; border:1px solid #CCC; padding-left:5px; background:#fff;width:480px; margin-left:2px; color: #999; } +.hwork_txt{ width:560px; padding-left:5px; background:#fff;} +a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:10px;} +a:hover.tijiao{ background:#0f99a9;} +.members_left{ float:left; width:410px; margin-right:20px; text-align:center;} +.members_left{} +.members_left ul li{ height:30px; border-bottom:1px solid #E4E4E4; width:410px; padding-top:10px; } +.members_left ul li a{ float:left; text-align:center;} +.members_left ul li span{ float:left; text-align:center; color:#484747;} +.w150{ text-align:center; width:150px;min-height: 10px;} +.f_b{ font-weight: bold;} +.members_right label{ margin-left:15px;} +.N_search{ height:20px; border:1px solid #999;} +/* 创建作品 homework */ +.hwork_new{ color:#4c4c4c;} +.c_red{ color:#F00;} +.hwork_input{ border:1px solid #64bdd9; height:22px; width:88%; background:#fff; margin-bottom:10px; padding:5px;} +.hwork_input02{ border:1px solid #64bdd9; height:15px; width:140px; background:#fff; margin-bottom:10px; padding:5px;} +.hwork_text{ border:1px solid #64bdd9; height:100px;width:555px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} +.hwork_new ul li{ } +.ml21{ margin-left:21px;} +.ml9{ margin-left:9px;} +.hwork_ttl{height:24px;} +.hwork_ctt{height:auto; padding-left:10px;clear:both;} +.hwork_tb_{ border-bottom:3px solid #e4e4e4; text-align:center;} +.hwork_tb_ ul{height:24px;} +.hwork_tb_ li{float:left;height: 24px;width: auto; padding:0 10px;cursor:pointer;} +.hwork_normaltab { color:#15bccf ; border-bottom:3px solid #e4e4e4; } +.hwork_hovertab { color:#656767; font-weight:bold; border-bottom:3px solid #15bccf; } + +.hwork_dis{display:block; } +.hwork_undis{display:none;} +.project_none{ display:none;} +.about_project{ overflow:hidden;display:none;} +.project_r_h{ width:670px; height:40px; background:#eaeaea; margin-bottom:10px;} +.project_r_h02{ width:920px; height:40px; background:#eaeaea; margin-bottom:10px;} diff --git a/public/stylesheets/nyan.css b/public/stylesheets/nyan.css index 6c046d62c..b64e60831 100644 --- a/public/stylesheets/nyan.css +++ b/public/stylesheets/nyan.css @@ -210,7 +210,7 @@ span[id^=valid_user] { p.jRatingInfos { position: absolute; z-index: 9999; - background: transparent url('bg_jRatingInfos.png') no-repeat; + /*background: transparent url('bg_jRatingInfos.png') no-repeat;*/ color: #CACACA; display: none; width: 91px; diff --git a/spec/factories/onclick_times.rb b/spec/factories/onclick_times.rb new file mode 100644 index 000000000..fcdda983d --- /dev/null +++ b/spec/factories/onclick_times.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :onclick_time do + user_id 1 +onclick_time "2015-09-06 14:57:02" + end + +end diff --git a/spec/models/onclick_time_spec.rb b/spec/models/onclick_time_spec.rb new file mode 100644 index 000000000..bc453f545 --- /dev/null +++ b/spec/models/onclick_time_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OnclickTime, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end