Merge branch 'dev_hjq' of http://repository.trustie.net/xianbo/trustie2 into dev_hjq

This commit is contained in:
ouyangxuhua 2015-09-07 15:24:10 +08:00
commit 8c66adec1b
57 changed files with 942 additions and 650 deletions

View File

@ -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

View File

@ -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})

View File

@ -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

View File

@ -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]
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)
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
#匿评作业相关属性
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]
)
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)
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)
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]

View File

@ -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

View File

@ -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"

View File

@ -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
#更新发帖数

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
class OnclickTime < ActiveRecord::Base
attr_accessible :onclick_time, :user_id
belongs_to :user
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -23,6 +23,7 @@
<% end %>
<% end %>
</span>
<div class="cl"></div>
<% project = project %>
<span class="add_attachment" style="font-weight:normal;">
<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn', :style => ie8? ? 'display:none' : '' %>

View File

@ -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;}
</style>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %>
<script >

View File

@ -28,7 +28,6 @@
<%= homework_anonymous_comment(homework)%>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "fr mr10 work_edit") %>
<%#= link_to(l(:button_edit),edit_homework_common_path(homework), :class => "fr mr10 work_edit") %>
<%= link_to(l(:button_edit),"javascript:void(0)", :class => "fr mr10 un_work_edit",:title => "编辑功能正在维护中") %>
<% elsif @is_student%>
<%= student_anonymous_comment homework %>
<%= student_new_homework homework %>

View File

@ -19,12 +19,23 @@
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<%= stylesheet_link_tag 'base','header', :media => 'all'%>
</head>
<body class="<%=h body_css_classes %>">
<div class="cl"></div>
<div class="navContainer mb10">
<% if User.current.logged? %>
<%= render :partial => 'layouts/logined_header',:locals=>{:name=>@name,:type=>@type} %>
<% else%>
<%= render :partial => 'layouts/unlogin_header',:locals=>{:name=>@name,:type=>@type} %>
<% end%>
</div>
<div class="cl"></div>
<div id="wrapper">
<div id="wrapper2">
<div id="wrapper3">
<%= render :partial => 'layouts/base_header'%>
<div id="main" class="">
<div id="sidebar">
@ -38,7 +49,6 @@
<%= call_hook :view_layouts_base_content %>
<div style="clear:both;"></div>
</div>
<%= render :partial => 'layouts/base_footer'%>
</div>
</div>
@ -47,6 +57,11 @@
</div>
</div>
<div class="cl"></div>
<%= render :partial => 'layouts/footer' %>
<div class="cl"></div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>
</html>

View File

@ -1,52 +1,54 @@
<div class="project_r_h">
<h2 class="project_h2">编辑作品</h2>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= labelled_form_for @work,:html => { :multipart => true } do |f|%>
<div class="N_con">
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="student_work[name]" id="student_work_name" class="bo fl" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>">
<a href="javascript:void(0)" class="fl ml10 mt3" onclick="show_project();" >项目信息
<img class="ml5 " src="/images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</a>
<div class="cl"></div>
<p id="student_work_name_span" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<div class="HomeWork" id="RSide">
<div class="RightBanner">
<div class="NewsBannerName">编辑作品</div>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= labelled_form_for @work,:html => { :multipart => true } do |f|%>
<div class="N_con">
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<input type="text" name="student_work[name]" id="student_work_name" class="bo fl" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>">
<a href="javascript:void(0)" class="fl ml10 mt3" onclick="show_project();" >项目信息
<img class="ml5 " src="/images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</a>
<div class="cl"></div>
<p id="student_work_name_span" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<p id="about_project" class="about_project" style="<%= @work.project.nil? ? '' : 'display:block;'%>">
<label class="fl">&nbsp;&nbsp;&nbsp;关联项目&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.select :project,options_for_select(user_projects_option,@work.project_id), {},{:class => "bo02 mb10"} %>
</p>
<div class="cl"></div>
<p id="about_project" class="about_project" style="<%= @work.project.nil? ? '' : 'display:block;'%>">
<label class="fl">&nbsp;&nbsp;&nbsp;关联项目&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.select :project,options_for_select(user_projects_option,@work.project_id), {},{:class => "bo02 mb10"} %>
</p>
<div class="cl"></div>
<p>
<label class="fl">
<span class="c_red">*</span>
&nbsp;作品描述&nbsp;&nbsp;&nbsp;&nbsp;
</label>
<textarea name="student_work[description]" placeholder="最多3000个汉字(或6000个英文字符)" id="student_work_description" class="w620 hwork_txt" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form',:locals => {:container => @work} %>
</p>
<div class="cl"></div>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="edit_student_work(<%= @work.id%>);">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</p>
</div><!---创建作业内容结束-->
<% end%>
<p>
<label class="fl">
<span class="c_red">*</span>
&nbsp;作品描述&nbsp;&nbsp;&nbsp;&nbsp;
</label>
<textarea name="student_work[description]" placeholder="最多3000个汉字(或6000个英文字符)" id="student_work_description" class="w620 hwork_txt" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form',:locals => {:container => @work} %>
</p>
<div class="cl"></div>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white mt10" onclick="edit_student_work(<%= @work.id%>);">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white mt10 ml10"%>
<div class="cl"></div>
</p>
</div><!---创建作业内容结束-->
<% end%>
</div>
</div>
</div>
</div>
</div><!--新建作业结束-->
<div class="cl"></div>
</div>

View File

@ -124,7 +124,6 @@
</h4>
<% if @is_teacher%>
<%= homework_anonymous_comment(@homework)%>
<%= link_to(l(:button_edit),"javascript:void(0)", :class => "fr mr10 un_work_edit",:title => "编辑功能正在维护中") %>
<% else%>
<%= student_anonymous_comment @homework %>
<%= student_new_homework @homework %>

View File

@ -17,75 +17,77 @@
});
<% end%>
</script>
<div class="project_r_h">
<h2 class="project_h2">创建作品</h2>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
:action => 'create',
:homework => @homework.id
}) do |f|%>
<div class="N_con">
<% if @homework.homework_type == 1%>
<div class=" c_red mb10 ml90">
提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息
</div>
<div class="HomeWork" id="RSide">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
</div>
<div class="Newwork">
<div class="hwork_ctt">
<div class="hwork_dis" id="tbc_01">
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
:action => 'create',
:homework => @homework.id
}) do |f|%>
<div class="N_con">
<% if @homework.homework_type == 1%>
<div class=" c_red mb10 ml90">
提示:匿评作业提交的作品,作品名称和描述中不能出现真实的姓名信息
</div>
<% end%>
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %>
<% if @homework.homework_type != 2%>
<a href="javascript:void(0)" class="fl ml10 mt3" onclick=" $('#about_project').slideToggle();" >
项目信息
<img class="ml5 " src="../images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</a>
<% end%>
<div class="cl"></div>
<p id="student_work_name_span" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<p id="about_project" class="about_project" >
<label class="fl">&nbsp;&nbsp;&nbsp;选择项目&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %>
</p>
<div class="cl"></div>
<p>
<label class="fl">
<span class="c_red">*</span>&nbsp;
<%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
&nbsp;&nbsp;&nbsp;
</label>
<% 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%>
<div class="cl"></div>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<% if @homework.homework_type != 2%>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form' %>
</p>
<div class="cl"></div>
<% end%>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white mt10" onclick="new_student_work();">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white mt10 ml10"%>
<div class="cl"></div>
</p>
</div><!---创建作业内容结束-->
<% end%>
<p>
<label class="fl"><span class="c_red">*</span>&nbsp;&nbsp;作品名称&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.text_field "name", :required => true, :size => 60, :class => "bo fl", :maxlength => 200, :placeholder => "作品名称", :onkeyup => "regexStudentWorkName();" %>
<% if @homework.homework_type != 2%>
<a href="javascript:void(0)" class="fl ml10 mt3" onclick="show_project();" >
项目信息
<img class="ml5 " src="../images/bid/pic_question.png" width="15" height="15" Title="项目是一种由用户创建的基于&#10;网络的协作空间,能够为个人&#10;或小组提供分布式的协同交流&#10;和资料管理等方面的。">
</a>
<% end%>
<div class="cl"></div>
<p id="student_work_name_span" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<p id="about_project" class="about_project" >
<label class="fl">&nbsp;&nbsp;&nbsp;选择项目&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= f.select :project_id,options_for_select(user_projects_option), {},{:class => "bo02 mb10"} %>
</p>
<div class="cl"></div>
<p>
<label class="fl">
<span class="c_red">*</span>&nbsp;
<%= @homework.homework_type == 2 ? "提交代码" : "作品描述"%>
&nbsp;&nbsp;&nbsp;
</label>
<% 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%>
<div class="cl"></div>
<p id="student_work_description_textarea" class="c_red ml90 mb10"></p>
</p>
<div class="cl"></div>
<% if @homework.homework_type != 2%>
<p>
<label class="fl">&nbsp;&nbsp;&nbsp;添加附件&nbsp;&nbsp;&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form' %>
</p>
<div class="cl"></div>
<% end%>
<p class="ml80 ">
<a href="javascript:void(0)" class="blue_btn fl c_white" onclick="new_student_work();">提交作品</a>
<%= link_to "返&nbsp;&nbsp;回".html_safe, student_work_index_path(:homework => @homework), :class => "blue_btn grey_btn fl c_white"%>
<div class="cl"></div>
</p>
</div><!---创建作业内容结束-->
<% end%>
</div>
</div>
</div><!--新建作业结束-->
<div class="cl"></div>
</div>
</div>
</div><!--新建作业结束-->
<div class="cl"></div>
<% else %>
@ -125,8 +127,8 @@
</script>
<!-- 模板1结束 -->
<div class="homepageRight">
<div class="HomeWork">
<div class="HomeWork" id="RSide">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
</div>
@ -201,6 +203,5 @@
<% end %>
<% end %>
</div><!----ProResult end-->
</div><!--homepageRight end-->
<% end %>

View File

@ -22,7 +22,7 @@
<div class="homepagePostDeadline">截止时间:<%= activity.end_time.to_s %></div>
</div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">
作业描述:<%= activity.description.html_safe %>
<%= activity.description.html_safe %>
</div>
<div class="homepagePostSetting" style="visibility: hidden" id="act-<%=user_activity_id %>">
<ul>

View File

@ -25,7 +25,7 @@
</div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">帖子描述:
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">
<% 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 %>
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.children.reorder("created_on desc").each do |reply|%>
<% replies_all_i=replies_all_i+1 %>

View File

@ -19,7 +19,6 @@
发布时间:<%= format_time(activity.created_on) %>
</div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id %>">
通知描述:
<%= activity.description.html_safe %>
</div>
</div>
@ -57,7 +56,7 @@
<% replies_all_i = 0 %>
<% if count > 0 %>
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.comments.reorder("created_on desc").each do |comment| %>
<% replies_all_i = replies_all_i + 1 %>

View File

@ -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 %>
<div class="resources mt10">
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
@ -28,7 +29,7 @@
<div class="homepagePostDate">
发布时间:<%= format_time(activity.published_at) %>
</div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">问卷描述:<%=activity.polls_description.html_safe.to_s%></div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>"><%=activity.polls_description.html_safe.to_s%></div>
<div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden">
<ul>
<li class="homepagePostSettingIcon">
@ -43,4 +44,5 @@
</div>
<div class="cl"></div>
</div>
</div>
</div>
<% end %>

View File

@ -5,4 +5,4 @@
<div>&nbsp;&nbsp;&nbsp; <%= l('userscore.active.update_issues')%> * 2 = <%= option_num.issue_done_ratio %> * 2 = <%= option_num.issue_done_ratio * 2 %></div>
<div>&nbsp;&nbsp;&nbsp; <%= l('userscore.active.release_issues')%> * 4 = <%= option_num.post_issue %> * 4 = <%= option_num.post_issue * 4 %></div>
<div>&nbsp;&nbsp;&nbsp; <%= l('userscore.active.release_messages')%> * 1 = <%= option_num.memo %> * 2 = <%= option_num.memo * 2 %></div>
<div>&nbsp;&nbsp;&nbsp; <%= 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) %> </div>
<div>&nbsp;&nbsp;&nbsp; <%= 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) %> </div>

View File

@ -33,7 +33,7 @@
<%=format_time(activity.created_on) %>
</div>
</div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id %>">缺陷描述:
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id %>">
<% if activity.description? %>
<%= textAreailizable activity, :description, :attachments => activity.attachments %>
<% end %>
@ -94,7 +94,7 @@
<% replies_all_i = 0 %>
<% if count > 0 %>
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.journals.reorder("created_on desc").each do |reply| %>
<% replies_all_i=replies_all_i + 1 %>

View File

@ -26,7 +26,7 @@
<div class="homepagePostDate">
时间:<%= format_time(activity.created_on) %>
</div>
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">帖子描述:
<div class="homepagePostIntro break_word upload_img" id="activity_description_<%= user_activity_id%>">
<% 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 %>
<div class="homepagePostReplyContainer" id="reply_div_<%= user_activity_id %>">
<div class="" id="reply_div_<%= user_activity_id %>">
<ul>
<% activity.children.reorder("created_on desc").each do |reply| %>
<% replies_all_i=replies_all_i+1 %>

View File

@ -5,8 +5,8 @@
<%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %></div>
<!-- <div>&nbsp;&nbsp;&nbsp;+ <%#= l(:label_user_score_of_influence) %></div> -->
<div> = <%= 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 %></div>
<% 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 %></div>
<% 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 %>
<div><%= l(:label_score_less_than_zero) %></div>
<% else %>
<div> = <%= format("%.2f" ,option_num.total_score).to_i %></div>

View File

@ -68,7 +68,7 @@
</li>
<li>
<%= 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 %>
</li>
</ul>

View File

@ -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;}
</style>
<% 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();

View File

@ -19,6 +19,11 @@
<div class="homepagePostSubmit">
<%= user_for_homework_common homework_common,is_teacher %>
</div>
<% if homework_common.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit">
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue' %>
</div>
<% end %>
<div class="homepagePostDeadline">
<%= l(:label_end_time)%><%= homework_common.end_time%>
</div>

View File

@ -41,19 +41,17 @@
<div class="homepageRight">
<div class="HomeWork">
<div class="RightBanner">
<div class="NewsBannerName">提交作品</div>
<div class="NewsBannerName"><%= @is_test ? '模拟答题' : '提交作品' %></div>
</div>
<div class="HomeWorkBox">
<div class="">
<div class="homepagePostTitle fl"><%= @homework.name %></div><span class="fr c_grey">截止时间:<%= @homework.end_time %></span>
<div class="cl"></div>
<a href="javascript:void(0);" class="c_blue"><%= @homework.user.show_name %></a>
<p class="HomeWorkP"><%= @homework.description %> <br />
输入 2 1 1 4 4 2 3 6 5 <br />
输出 15<br />
<p class="HomeWorkP"><%= @homework.description.html_safe %> <br />
</p>
</div>
<p class="c_grey mt15">注:迟交扣<span class="c_red">2</span>分,缺评一个作品扣<span class="c_red">2</span>分</p>
<!--p class="c_grey mt15">注:迟交扣<span class="c_red">2</span>分,缺评一个作品扣<span class="c_red">2</span>分</p-->
</div><!---HomeWorkBox end -->
<div class="HomeWorkCon">
<%= form_for(@student_work,
@ -64,7 +62,7 @@
:homework => @homework.id
},
:method => :post) do |f|%>
<input type="hidden" name="is_test" value="<%=@is_test%>">
<div class="mt15">
<span>请使用 <%= @homework.language_name %> 语言编写</span>
</div>
@ -76,13 +74,18 @@
</div>
<div class="mt10">
<a href="javascript:void(0);" class="BlueCirBtn fl" data-homework-id="<%=@homework.id%>" data-student-work-id="<%=@student_work.id%>" id="test-program-btn">测试代码</a>
<% unless @is_test %>
<a href="javascript:void(0);" class="BlueCirBtn fr" id="commit-program-work-btn">提交代码</a>
<% end %>
<div class="cl"></div>
</div>
<% end %>
</div><!----HomeWorkCon end-->
</div><!----HomeWork end-->
<div class="cl"></div>
<div class="ProResult mt10">
<% @student_work.student_work_tests.each_with_index do |test, index| %>
<div class="ProResultTop">
<p class="c_blue fl">第<%= @student_work.student_work_tests.count - index%>次测试</p><span class="fr c_grey"><%= test.created_at.to_s(:db) %></span>

View File

@ -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%>);
$("#res_all_count").html(<%= @atta_count%>);
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);

View File

@ -37,4 +37,4 @@
</ul>
</div>
<%= 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} %>

View File

@ -31,7 +31,7 @@
<div>
<% if params[:type].nil? %>
<div class="newsReadSetting">
有&nbsp;<span class="c_red"><%= User.current.count_new_message %></span>&nbsp;未读<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
有&nbsp;<span class="c_red"><%= User.current.count_new_message %></span>&nbsp;未读<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
</div>
<% 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))" %></li>
<div style="display: none" >
<div style="display: none" class="message_title">
<%= ma.course_message.comments.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
@ -100,7 +100,7 @@
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a></li>
<div style="display: none" >
<div style="display: none" class="message_title" >
<%= ma.course_message.content.html_safe %>
</div>
<% 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))" %></a></li>
<div style="display: none" >
<div style="display: none" class="message_title">
<%= ma.forge_message.content.html_safe %>
</div>
<% end %>
@ -240,7 +240,7 @@
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>
</li>
<div style="display: none" >
<div style="display: none" class="message_title">
<%= ma.memo.content.html_safe %>
</div>
<% end %>
@ -264,7 +264,7 @@
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>
</li>
<div style="display: none" >
<div style="display: none" class="message_title" >
<%= ma.journals_for_message.notes.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.journals_for_message.created_on).html_safe %> </li>
@ -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)
{

View File

@ -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;}
</style>
<div >
<div class="homepageRightBanner mb10">

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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();

View File

@ -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});

View File

@ -131,4 +131,50 @@ function search_homework_by_name(url){
function (data) {
}
);
}
//提交新建作品
function new_student_work()
{
if(regexStudentWorkName()&&regexStudentWorkDescription())
{$("#new_student_work").submit();}
}
function edit_student_work(id)
{
if(regexStudentWorkName()&&regexStudentWorkDescription())
{$("#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;
}
}

View File

@ -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;}

View File

@ -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;

View File

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :onclick_time do
user_id 1
onclick_time "2015-09-06 14:57:02"
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe OnclickTime, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end