Merge remote-tracking branch 'origin/develop' into guange_dev

This commit is contained in:
guange 2016-05-05 14:07:29 +08:00
commit 88fd2cbfb6
58 changed files with 744 additions and 236 deletions

View File

@ -1 +1 @@
{"access_token":"nwsA--Idg9Wk4Kyuybly8XuI8MWx-NrJbPTzZX2ynbGaVHBnXZgJ4DHkwlJK6dGfYOmeMNmRj6PSXEzs1GS6vAy0e_7_6S34-S44wtGK83dv6HCUQ8qh3vAw12QUi39fUMDhCIAFXO","expires_in":7200,"got_token_at":1461723935} {"access_token":"yFUfEXFu0_Pl_jdojoRv6eA8pmGjyRkRIL1VCB2HZ4kVJhEq6crriyCRCI-_u5QbWgtepiIOvqTHtXpKgzMuaB7Eo7MjlMcXeecqhzTjnvpivK5HUzGhZXBG1dk_BxicJAFlCAARIN","expires_in":7200,"got_token_at":1461934858}

View File

@ -27,11 +27,15 @@ class BlogsController < ApplicationController
@topics.each do |topic| @topics.each do |topic|
topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count) topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count)
if topic[:infocount] < 0
topic[:infocount] = 0
end
end end
@b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] } @b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] }
@topics = sort_by_sticky @topics @topics = sort_by_sticky @topics
@topics = sortby_time_countcommon_hassticky @topics,sort_name
else else
@type = 1 @type = 1
end end

View File

@ -77,7 +77,7 @@ class BoardsController < ApplicationController
@b_sort = 2 @b_sort = 2
end end
sort_name = "updated_at" sort_name = "updated_on"
sort_type = @b_sort == 1 ? "asc" : "desc" sort_type = @b_sort == 1 ? "asc" : "desc"
@ -126,9 +126,13 @@ class BoardsController < ApplicationController
@type = 2 @type = 2
@topics.each do |topic| @topics.each do |topic|
topic[:infocount] = get_praise_num(topic) + (topic.parent ? x.parent.children.count : topic.children.count) topic[:infocount] = get_praise_num(topic) + (topic.parent ? x.parent.children.count : topic.children.count)
if topic[:infocount] < 0
topic[:infocount] = 0
end
end end
@b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] } @b_sort == 1 ? @topics = @topics.sort{|x,y| x[:infocount] <=> y[:infocount] } : @topics = @topics.sort{|x,y| y[:infocount] <=> x[:infocount] }
@topics = sort_by_sticky @topics @topics = sort_by_sticky @topics
@topics = sortby_time_countcommon_hassticky @topics,sort_name
else else
@type = 1 @type = 1
end end

View File

@ -89,7 +89,7 @@ class HomeworkCommonController < ApplicationController
homework_detail_manual.comment_status = 1 homework_detail_manual.comment_status = 1
end end
eval_start = homework_detail_manual.evaluation_start eval_start = homework_detail_manual.evaluation_start
if eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1 if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1)
homework_detail_manual.evaluation_start = @homework.end_time + 7 homework_detail_manual.evaluation_start = @homework.end_time + 7
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7 homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
end end

View File

@ -79,21 +79,20 @@ class NewsController < ApplicationController
@b_sort = 2 @b_sort = 2
end end
sort_name = "created_on" sort_name = "updated_at"
sort_type = @b_sort == 1 ? "asc" : "desc" sort_type = @b_sort == 1 ? "asc" : "desc"
scope = @course ? @course.news.course_visible : News.course_visible scope = @course ? @course.news.course_visible : News.course_visible
news_arr = scope.map{|news| news.id} news_arr = scope.map{|news| news.id}
@page = params[:page] ? params[:page].to_i + 1 : 0 @page = params[:page] ? params[:page].to_i + 1 : 0
news_page = 0 #@page *10 news_page = 0 #@page *10
@news_count = scope.count @news_count = scope.count
@is_new = params[:is_new] @is_new = params[:is_new]
@q = params[:subject] @q = params[:subject]
if params[:subject].nil? || params[:subject].blank? if params[:subject].nil? || params[:subject].blank?
scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.#{sort_name} #{sort_type}").offset(news_page).includes(:author,:course).all() scope_order = scope.reorder("#{News.table_name}.sticky DESC, #{News.table_name}.created_on #{sort_type}").offset(news_page).includes(:author,:course).all()
#all(:include => [:author, :course], #all(:include => [:author, :course],
#:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page) #:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page)
else else
@ -101,16 +100,26 @@ class NewsController < ApplicationController
#.all(:include => [:author, :course],:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC") #.all(:include => [:author, :course],:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC")
end end
scope_order.each do |topic|
topic[:updated_at] = CourseActivity.where("course_act_type='#{topic.class}' and course_act_id =#{topic.id}").first.updated_at
end
#根据 赞+回复数排序 #根据 赞+回复数排序
if @order.to_i == 2 if @order.to_i == 2
@type = 2 @type = 2
scope_order.each do |topic| scope_order.each do |topic|
topic[:infocount] = get_praise_num(topic) + topic.comments.count topic[:infocount] = get_praise_num(topic) + topic.comments.count
if topic[:infocount] < 0
topic[:infocount] = 0
end
end end
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:infocount] <=> y[:infocount] } : scope_order = scope_order.sort{|x,y| y[:infocount] <=> x[:infocount] } @b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:infocount] <=> y[:infocount] } : scope_order = scope_order.sort{|x,y| y[:infocount] <=> x[:infocount] }
scope_order = sort_by_sticky scope_order scope_order = sort_by_sticky scope_order
scope_order = sortby_time_countcommon_hassticky scope_order,sort_name
else else
@type = 1 @type = 1
@b_sort == 1 ? scope_order = scope_order.sort{|x,y| x[:updated_at] <=> y[:updated_at] } : scope_order = scope_order.sort{|x,y| y[:updated_at] <=> x[:updated_at] }
scope_order = sort_by_sticky scope_order
end end
@newss = scope_order @newss = scope_order

View File

@ -5,7 +5,7 @@ class StudentWorkController < ApplicationController
include ApplicationHelper include ApplicationHelper
require 'bigdecimal' require 'bigdecimal'
require "base64" require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students,:work_canrepeat]
before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment]
before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :author_of_work, :only => [:edit, :update, :destroy]
@ -17,41 +17,41 @@ class StudentWorkController < ApplicationController
is_test = params[:is_test] == 'true' is_test = params[:is_test] == 'true'
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')} resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')}
student_work = find_or_save_student_work(is_test) student_work = find_or_save_student_work(is_test)
unless student_work unless student_work
resultObj[:status] = 100 resultObj[:status] = 100
else else
if @homework.homework_type == 2 && @homework.homework_detail_programing if @homework.homework_type == 2 && @homework.homework_detail_programing
result = test_realtime(student_work, params[:src]) result = test_realtime(student_work, params[:src])
logger.debug result logger.debug result
resultObj[:status] = result["status"] resultObj[:status] = result["status"]
resultObj[:results] = result["results"] resultObj[:results] = result["results"]
resultObj[:error_msg] = result["error_msg"] resultObj[:error_msg] = result["error_msg"]
results = result["results"] results = result["results"]
if result["status"].to_i == -2 #编译错误 if result["status"].to_i == -2 #编译错误
results = [result["error_msg"]] results = [result["error_msg"]]
end end
student_work_test = student_work.student_work_tests.build(status: result["status"], results: results, student_work_test = student_work.student_work_tests.build(status: result["status"], results: results,
src: params[:src]) src: params[:src])
unless student_work.save unless student_work.save
resultObj[:status] = 200 resultObj[:status] = 200
else
student_work.name = params[:title]
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
else else
student_work.name = params[:title] student_work.late_penalty = 0
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
else
student_work.late_penalty = 0
end
student_work.save
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
student_work.save
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 end
end
render :json => resultObj render :json => resultObj
end end
@ -81,6 +81,8 @@ class StudentWorkController < ApplicationController
#根据传入的tIndex确定是第几次测试 #根据传入的tIndex确定是第几次测试
#之后如果觉得很卡 可以改成将结果传回JS再以参数形式传回来 #之后如果觉得很卡 可以改成将结果传回JS再以参数形式传回来
def program_test_ex def program_test_ex
tStarttime = Time.now
is_test = params[:is_test] == 'true' is_test = params[:is_test] == 'true'
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T'),tseq:1,tcount:1,testid:1} #保存每测试一次返回的结果 resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T'),tseq:1,tcount:1,testid:1} #保存每测试一次返回的结果
@ -92,83 +94,229 @@ class StudentWorkController < ApplicationController
resultObj[:status] = 100 resultObj[:status] = 100
else else
if @homework.homework_type == 2 && @homework.homework_detail_programing if @homework.homework_type == 2 && @homework.homework_detail_programing
#找到第index个测试的输入输出 #找到第index个测试的输入输出
index = params[:tIndex].to_i index = params[:tIndex].to_i
resultObj[:tseq] = index resultObj[:tseq] = index
test = @homework.homework_tests[index - 1] test = @homework.homework_tests[index - 1]
#请求测试 #请求测试
begin
result = test_realtime_ex(test, params[:src]) result = test_realtime_ex(test, params[:src])
rescue Timeout::Error
tEndtime = Time.now
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
logger.debug "program_test_ex user wait time = #{tUsedtime} 毫秒"
if result["status"].to_i != -2 #status 0:答案正确 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时
#result["results"].first['output'] = result["results"].first['output'].gsub(" ","□") CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>-3,:wait_time=>tUsedtime,:student_work_id=>student_work.id)
#result["results"].first['result'] = result["results"].first['result'].gsub(" ","□")
space_replace_1(result["results"].first['output'])
space_replace_1(result["results"].first['result'])
end
logger.debug result end
if result["status"].to_i != -2
#result["results"].first['output'] = result["results"].first['output'].gsub(" ","□")
#result["results"].first['result'] = result["results"].first['result'].gsub(" ","□")
space_replace_1(result["results"].first['output'])
space_replace_1(result["results"].first['result'])
end
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误 logger.debug result
resultObj[:status] = -1
resultObj[:results] = result["results"].first #本次测试结果
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
if result["status"].to_i == -2 #编译错误 #-1 默认值 0全部正确并结束 2 超时 -2 编译错误
resultObj[:results] = result["error_msg"] resultObj[:status] = -1
resultObj[:status] = -2 resultObj[:results] = result["results"].first #本次测试结果
elsif result["results"][0]["status"].to_i == 2 resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
resultObj[:status] = 2
end
unless student_work.save #该状态用于存入CodeTests
resultObj[:status] = 200 tmpstatus = -1
if result["status"].to_i == -2 #编译错误
resultObj[:results] = result["error_msg"]
resultObj[:status] = -2
tmpstatus = -2
elsif result["results"][0]["status"].to_i == 2
resultObj[:status] = 2
tmpstatus = 2
end
if result["status"] == 0
tmpstatus = 0
end
unless student_work.save
resultObj[:status] = 200
else
student_work.name = params[:title]
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
else else
student_work.name = params[:title] student_work.late_penalty = 0
student_work.description = params[:src]
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
else
student_work.late_penalty = 0
end
#每次从数据库取出上次的结果加上本次的结果再存入数据库
status = result["status"]
if index == 1
student_work_test = student_work.student_work_tests.build(status: status,
results: [resultObj[:results]],src: params[:src])
student_work_test.save!
resultObj[:testid] = student_work_test.id
else
#先从数据库取出result
student_work_test = StudentWorkTest.find(params[:testid])
results = student_work_test.results
results << resultObj[:results]
student_work_test.results = results
student_work_test.status = (result["status"] != 0 ? result["status"] : student_work_test.status)
student_work_test.save!
status = student_work_test.status
resultObj[:testid] = student_work_test.id
end
#超时或编译错误则直接返回了并存入数据库
if resultObj[:status] == 2 || resultObj[:status] == -2 || index == @homework.homework_tests.size
if status == 0
resultObj[:status] = 0
end
student_work.save!
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
end
#渲染返回结果
render :json => resultObj
end end
#每次从数据库取出上次的结果加上本次的结果再存入数据库
if result["status"].to_i != -2
result["results"].first['user_wait'] = tUsedtime
if result["results"][0]["status"].to_i == 2
result["status"] = 2
end
end
status = result["status"]
if index == 1
student_work_test = student_work.student_work_tests.build(status: status,
results: [resultObj[:results]],src: params[:src])
student_work_test.save!
resultObj[:testid] = student_work_test.id
else
#先从数据库取出result
student_work_test = StudentWorkTest.find(params[:testid])
results = student_work_test.results
results << resultObj[:results]
student_work_test.results = results
student_work_test.status = (result["status"] != 0 ? result["status"] : student_work_test.status)
student_work_test.save!
status = student_work_test.status
resultObj[:testid] = student_work_test.id
end
#超时或编译错误则直接返回了并存入数据库
if resultObj[:status] == 2 || resultObj[:status] == -2 || index == @homework.homework_tests.size
if status == 0
resultObj[:status] = 0
end
student_work.save!
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
end
#将每次用户等待时间都存起来以便管理界面显示用
tEndtime = Time.now
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000+(tEndtime.usec - tStarttime.usec)/1000
logger.debug "program_test_ex user wait time = #{tUsedtime} 毫秒"
time_used = 0
if result["status"].to_i != -2
#至少一毫秒
time_used = result["results"].first['time_used'] == 0 ? 1:result["results"].first['time_used']
end
#0:答案正确 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时
CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>tmpstatus,:time_used=>time_used,:wait_time=>tUsedtime,:student_work_id=>student_work.id)
#渲染返回结果
render :json => resultObj
end
end end
end end
end end
#找出该作业的所有提交作业
def find_all_student_work_by_homeid()
all_studentwork = StudentWork.where("homework_common_id = #{@homework.id} and is_test = 0 ")
all_studentwork
end
def request_code_repeattest(src)
url = "#{Redmine::Configuration['jplag_server']}api/realtime_test.json"
factor = []
src.each do |test|
factor << {work_id: test.id, des: test.description,created_at:test.created_at.to_i}
end
solutions = {
homeid:@homework.id,
language:@homework.homework_detail_programing.language,
factor: factor
}
uri = URI(url)
body = solutions.to_json
logger.debug "send body"
logger.debug body
res = Net::HTTP.new(uri.host, uri.port).start do |client|
request = Net::HTTP::Post.new(uri.path)
request.body = body
request["Content-Type"] = "application/json"
client.request(request)
end
JSON.parse(res.body)
end
#点击代码查重按钮
def work_canrepeat
@homework_id = params[:homework]
@course_id = params[:course_id]
all_studentwork = find_all_student_work_by_homeid()
@work_count = all_studentwork.count
end
#代码查重 status: 0完成 -2不需要查重 -1查重失败不支持该语言
def code_repeattest
tStarttime = Time.now
logger.debug "code_repeattest start is #{tStarttime}}"
resultObj = {status: -2}
@homework = HomeworkCommon.find params[:homework]
all_studentwork = find_all_student_work_by_homeid()
if all_studentwork == nil
resultObj[:status] = -2
elsif all_studentwork.count <= 1
resultObj[:status] = -2
else
#@homework.homework_detail_programing.language、id、description
logger.debug "time1 is #{Time.now.usec} "
result = request_code_repeattest(all_studentwork)
logger.debug "time2 is #{Time.now.usec} "
resultObj[:status] = result['status'].to_i
# resultObj[:results] = result['results']
#Time.now, simi_id = simiworkid , simi_value = simivalue
if resultObj[:status] == 0
@homework.simi_time = Time.now
resultObj[:comparetime] = @homework.simi_time
@homework.update_column('simi_time', @homework.simi_time)
logger.debug "time3 is #{Time.now.usec} "
result['results'].each do |key,value|
@student_work = StudentWork.where("id =?", key.to_i).first
@student_work.update_column('simi_id', value['simiworkid'].to_i)
@student_work.update_column('simi_value', value['simivalue'].to_i)
# sqlstr = "update student_works set simi_id=#{value['simiworkid']},simi_value=#{value['simivalue']} where id=#{key.to_i} "
# dbh.execute(sqlstr)
end
logger.debug "time4 is #{Time.now.usec} "
end
end
tEndtime = Time.now
logger.debug "code_repeattest end is #{tEndtime}}"
tUsedtime = (tEndtime.to_i-tStarttime.to_i)*1000000+(tEndtime.usec - tStarttime.usec)
logger.debug "code_repeattest userd utime is #{tUsedtime}"
render :json => resultObj
end
#上次代码查重时间
def last_codecomparetime
resultObj = {status: 0}
@homework = HomeworkCommon.find params[:homework]
#转换一下
if @homework.simi_time != nil
resultObj[:comparetime] = Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H:%M:%S")
else
resultObj[:comparetime] = 0
end
render :json => resultObj
end
def index def index
# 作业消息状态更新 # 作业消息状态更新
@ -504,7 +652,7 @@ class StudentWorkController < ApplicationController
if @homework.homework_detail_group.base_on_project == 1 if @homework.homework_detail_group.base_on_project == 1
stu_project.project_id = @student_work_project.project_id stu_project.project_id = @student_work_project.project_id
else @homework.homework_detail_group.base_on_project == 0 else @homework.homework_detail_group.base_on_project == 0
stu_project.project_id = -1 stu_project.project_id = -1
end end
stu_project.user_id = members[i].to_i stu_project.user_id = members[i].to_i
stu_project.is_leader = 0 stu_project.is_leader = 0
@ -791,7 +939,7 @@ class StudentWorkController < ApplicationController
if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s) if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s)
homework_detail_manual.ta_proportion = params[:ta_proportion] homework_detail_manual.ta_proportion = params[:ta_proportion]
homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing
@homework.teacher_priority = teacher_priority @homework.update_column('teacher_priority', teacher_priority)
homework_detail_manual.save if homework_detail_manual homework_detail_manual.save if homework_detail_manual
homework_detail_programing.save if homework_detail_programing homework_detail_programing.save if homework_detail_programing
@ -801,7 +949,7 @@ class StudentWorkController < ApplicationController
student_work.save student_work.save
end end
end end
@homework.save @homework.save
if params[:student_path] if params[:student_path]
redirect_to student_work_index_url(:homework => @homework.id) redirect_to student_work_index_url(:homework => @homework.id)
@ -1095,11 +1243,11 @@ class StudentWorkController < ApplicationController
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
if student_work.nil? if student_work.nil?
@homework.student_works.build( @homework.student_works.build(
name: params[:title], name: params[:title],
description: params[:src], description: params[:src],
user_id: User.current.id, user_id: User.current.id,
is_test: is_test is_test: is_test
) )
unless @homework.save unless @homework.save
logger.debug @homework.errors.full_messages logger.debug @homework.errors.full_messages
else else
@ -1120,7 +1268,7 @@ class StudentWorkController < ApplicationController
src:src, src:src,
language:@homework.homework_detail_programing.language, language:@homework.homework_detail_programing.language,
factor: factor factor: factor
} }
uri = URI(url) uri = URI(url)
body = solutions.to_json body = solutions.to_json
res = Net::HTTP.new(uri.host, uri.port).start do |client| res = Net::HTTP.new(uri.host, uri.port).start do |client|
@ -1174,8 +1322,12 @@ class StudentWorkController < ApplicationController
final_score = final_ta_score + final_s_score final_score = final_ta_score + final_s_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end end
else #不考虑教师评分 else #不考虑教师评分
if student_work.teaching_asistant_score.nil? if student_work.teaching_asistant_score.nil?
@ -1189,8 +1341,12 @@ class StudentWorkController < ApplicationController
final_score = final_ta_score + final_s_score final_score = final_ta_score + final_s_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end end
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空 elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
if homework.teacher_priority == 1 #教师优先 if homework.teacher_priority == 1 #教师优先
@ -1225,8 +1381,12 @@ class StudentWorkController < ApplicationController
final_score = final_sy_score + final_ts_score + final_st_score final_score = final_sy_score + final_ts_score + final_st_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end end
else #不考虑教师评分 else #不考虑教师评分
if student_work.teaching_asistant_score.nil? #教辅未评分 if student_work.teaching_asistant_score.nil? #教辅未评分
@ -1256,8 +1416,12 @@ class StudentWorkController < ApplicationController
final_score = final_sy_score + final_ts_score + final_st_score final_score = final_sy_score + final_ts_score + final_st_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end end
end end
end end

View File

@ -477,8 +477,8 @@ class UsersController < ApplicationController
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i) ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i)
if ah.empty? if ah.empty?
@status = 2 @status = 2
elsif ah.first.status == 1 elsif ah.first.status != 2
@status = 1 @status = ah.first.status
end end
end end
if !params[:search].nil? if !params[:search].nil?
@ -1208,13 +1208,13 @@ class UsersController < ApplicationController
#显示更多用户课程 #显示更多用户课程
def user_courses4show def user_courses4show
@page = params[:page].to_i + 1 @page = params[:page].to_i + 1
@courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5)
end end
#显示更多用户项目 #显示更多用户项目
def user_projects4show def user_projects4show
@page = params[:page].to_i + 1 @page = params[:page].to_i + 1
@projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5) @projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5)
end end
def user_course_activities def user_course_activities
@ -2948,20 +2948,19 @@ class UsersController < ApplicationController
sort_name = "created_at" sort_name = "created_at"
sort_type = @c_sort == 1 ? "asc" : "desc" sort_type = @c_sort == 1 ? "asc" : "desc"
if @user.courses.visible.count > 0 @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a #{sort_type}")
course_order_ids = "(" + CourseActivity.find_by_sql("SELECT c.course_id, updated_at FROM(SELECT ca.course_id, MAX(ca.updated_at) AS updated_at FROM course_activities ca WHERE ca.course_id IN (" + @user.courses.visible.select('courses.id').map{|c| c.id}.join(',') + ") GROUP BY ca.course_id) AS c ").map {|c| c.course_id}.join(",") + ")"
@courses = Course.where("id in #{course_order_ids}").order("#{sort_name} #{sort_type}")
else
@courses = []
end
#根据 作业+资源数排序 #根据 作业+资源数排序
if @order.to_i == 2 if @order.to_i == 2
@type = 2 @type = 2
@courses.each do |course| @courses.each do |course|
course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count) course[:infocount] = (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) ? (course.homework_commons.count + visable_attachemnts_incourse(course).count) : (course.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(course).count)
if course[:infocount] < 0
course[:infocount] = 0
end
end end
@c_sort == 1 ? (@courses = @courses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@courses = @courses.sort{|x,y| y[:infocount] <=> x[:infocount]}) @c_sort == 1 ? (@courses = @courses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@courses = @courses.sort{|x,y| y[:infocount] <=> x[:infocount]})
@courses = sortby_time_countcommon_nosticky @courses,sort_name
else else
@type = 1 @type = 1
end end
@ -2993,21 +2992,19 @@ class UsersController < ApplicationController
sort_name = "created_on" sort_name = "created_on"
sort_type = @c_sort == 1 ? "asc" : "desc" sort_type = @c_sort == 1 ? "asc" : "desc"
if @user.projects.visible.count > 0 @projects = @user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a #{sort_type}")
project_order_ids = "(" +ForgeActivity.find_by_sql("SELECT p.project_id, p.created_at FROM (SELECT fa.project_id, MAX(fa.created_at) AS created_at FROM forge_activities fa WHERE fa.project_id IN (" + @user.projects.visible.select('projects.id').map{|p| p.id}.join(',') + ") GROUP BY fa.project_id) AS p ").map {|p| p.project_id}.join(",") + ")"
@projects = Project.where("projects.id in #{project_order_ids}").order("#{sort_name} #{sort_type}")
else
@projects = []
end
#根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num #根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num
if @order.to_i == 2 if @order.to_i == 2
@type = 2 @type = 2
@projects.each do |project| @projects.each do |project|
project[:infocount] = project.project_score.issue_num+project.project_score.attach_num project[:infocount] = project.project_score.issue_num+project.project_score.attach_num
if project[:infocount] < 0
project[:infocount] = 0
end
end end
@c_sort == 1 ? (@projects = @projects.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@projects = @projects.sort{|x,y| y[:infocount] <=> x[:infocount] }) @c_sort == 1 ? (@projects = @projects.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@projects = @projects.sort{|x,y| y[:infocount] <=> x[:infocount] })
@projects = sortby_time_countcommon_nosticky @projects,sort_name
else else
@type = 1 @type = 1
end end

View File

@ -3065,7 +3065,7 @@ def host_with_protocol
return Setting.protocol + "://" + Setting.host_name return Setting.protocol + "://" + Setting.host_name
end end
#将有置顶属性的提到数组前面 #infocount 相同的按时间降序排列 #将有置顶属性的提到数组前面
def sort_by_sticky topics def sort_by_sticky topics
tmpTopics = [] tmpTopics = []
tmpIndex = 0 tmpIndex = 0
@ -3082,10 +3082,120 @@ def sort_by_sticky topics
tmpIndex = tmpIndex + 1 tmpIndex = tmpIndex + 1
end end
end end
return tmpTopics
end
topics = tmpTopics #按人气排序的时候 相同的人气必须按某种时间顺序排序 有置顶属性
return topics def sortby_time_countcommon_hassticky topics,sortstr
enddef strip_html(text,len=0,endss="...") tmpTopics = []
tmpTopics = topics
tStart = -1
tEnd = -1
tmpTopics_1 = []
tmpIndex = 0
tmpTopics.each_with_index do |topic,index|
if topic.sticky == 0
if tStart == -1
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
tStart = index
end
else
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
tEnd = index
else
if (topic[:infocount] == tmpTopics[index-1][:infocount])
tEnd = index
end
if tEnd > tStart
for i in tStart..tEnd
tmpTopics_1[tmpIndex] = tmpTopics[i]
tmpIndex = tmpIndex + 1
end
if sortstr == "created_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
elsif sortstr == "created_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
elsif sortstr == "updated_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
elsif sortstr == "updated_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
end
tmpIndex = 0
for i in tStart..tEnd
tmpTopics[i] = tmpTopics_1[tmpIndex]
tmpIndex = tmpIndex + 1
end
end
tStart = -1
tEnd = -1
tmpTopics_1 = []
tmpIndex = 0
end
end
end
end
return tmpTopics
end
#按人气排序的时候 相同的人气必须按某种时间顺序排序 无置顶属性
def sortby_time_countcommon_nosticky topics,sortstr
tmpTopics = []
tmpTopics = topics
tStart = -1
tEnd = -1
tmpTopics_1 = []
tmpIndex = 0
tmpTopics.each_with_index do |topic,index|
if tStart == -1
if (index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])
tStart = index
end
else
if ((topic[:infocount] == tmpTopics[index-1][:infocount]) && ((index != tmpTopics.count-1) && (topic[:infocount] == tmpTopics[index+1][:infocount])))
tEnd = index
else
if (topic[:infocount] == tmpTopics[index-1][:infocount])
tEnd = index
end
if tEnd > tStart
for i in tStart..tEnd
tmpTopics_1[tmpIndex] = tmpTopics[i]
tmpIndex = tmpIndex + 1
end
if sortstr == "created_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_at].to_i <=> x[:created_at].to_i }
elsif sortstr == "created_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:created_on].to_i <=> x[:created_on].to_i }
elsif sortstr == "updated_at"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_at].to_i <=> x[:updated_at].to_i }
elsif sortstr == "updated_on"
tmpTopics_1 = tmpTopics_1.sort{|x,y| y[:updated_on].to_i <=> x[:updated_on].to_i }
end
tmpIndex = 0
for i in tStart..tEnd
tmpTopics[i] = tmpTopics_1[tmpIndex]
tmpIndex = tmpIndex + 1
end
end
tStart = -1
tEnd = -1
tmpTopics_1 = []
tmpIndex = 0
end
end
end
return tmpTopics
end
def strip_html(text,len=0,endss="...")
ss = "" ss = ""
if text.length>0 if text.length>0
ss=text.gsub(/<\/?.*?>/, '').strip ss=text.gsub(/<\/?.*?>/, '').strip
@ -3098,4 +3208,4 @@ enddef strip_html(text,len=0,endss="...")
end end
end end
return ss return ss
end end

View File

@ -45,7 +45,8 @@ class Comment < ActiveRecord::Base
if self.commented.course if self.commented.course
if self.author_id != self.commented.author_id if self.author_id != self.commented.author_id
self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false)
if ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count
if count == 0
content = strip_html self.comments.html_safe, 200 content = strip_html self.comments.html_safe, 200
ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
end end

View File

@ -59,7 +59,8 @@ class HomeworkCommon < ActiveRecord::Base
self.course.members.each do |m| self.course.members.each do |m|
# if m.user_id != self.user_id # if m.user_id != self.user_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
if count == 0
ws = WechatService.new ws = WechatService.new
ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
end end
@ -108,7 +109,8 @@ class HomeworkCommon < ActiveRecord::Base
#修改作业后发送微信模板消息 #修改作业后发送微信模板消息
def wechat_message def wechat_message
self.course.members.each do |member| self.course.members.each do |member|
if ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
if count == 0
ws = WechatService.new ws = WechatService.new
ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59")
end end

View File

@ -162,7 +162,7 @@ class Issue < ActiveRecord::Base
end end
self.project.members.each do |m| self.project.members.each do |m|
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count
if m.user_id != self.author_id && count != 0 if m.user_id != self.author_id && count == 0
ws = WechatService.new ws = WechatService.new
content = strip_html self.project.name + " 有新缺陷了:" + self.subject.html_safe, 200 content = strip_html self.project.name + " 有新缺陷了:" + self.subject.html_safe, 200
ws.message_update_template m.user_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) ws.message_update_template m.user_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on)

View File

@ -255,11 +255,14 @@ class JournalsForMessage < ActiveRecord::Base
self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false) self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false)
end end
end end
if self.jour_type == 'HomeworkCommon' && ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count == 0 if self.jour_type == 'HomeworkCommon'
ws = WechatService.new count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count
#content = truncate(strip_tags(self.notes.to_s), length: 200) if count == 0
content = strip_html self.notes.html_safe, 200 ws = WechatService.new
ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content #content = truncate(strip_tags(self.notes.to_s), length: 200)
content = strip_html self.notes.html_safe, 200
ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content
end
end end
end end

View File

@ -83,7 +83,7 @@ class Message < ActiveRecord::Base
# after_create :add_author_as_watcher, :reset_counters!, :add_boards_count # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
after_update :update_messages_board, :update_activity after_update :update_messages_board, :update_activity
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message
#before_save :be_user_score #before_save :be_user_score
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
@ -263,8 +263,9 @@ class Message < ActiveRecord::Base
if self.parent_id.nil? # 主贴 if self.parent_id.nil? # 主贴
self.course.members.includes(:user).each do |m| self.course.members.includes(:user).each do |m|
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count
if count == 0
content = strip_html self.subject, 200 content = strip_html self.subject, 200
ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
end end
@ -273,8 +274,9 @@ class Message < ActiveRecord::Base
else # 回帖 else # 回帖
parent_author_id = Message.find(self.parent_id).author_id parent_author_id = Message.find(self.parent_id).author_id
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false) #self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false)
if ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count
if count == 0
content = strip_html self.content.html_safe, 200 content = strip_html self.content.html_safe, 200
ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
end end
@ -284,8 +286,9 @@ class Message < ActiveRecord::Base
if self.parent_id.nil? # 主贴 if self.parent_id.nil? # 主贴
self.project.members.includes(:user).each do |m| self.project.members.includes(:user).each do |m|
if m.user_id != self.author_id if m.user_id != self.author_id
self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) #self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false)
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count
if count == 0
content = strip_html self.subject, 200 content = strip_html self.subject, 200
ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on)
end end
@ -294,8 +297,9 @@ class Message < ActiveRecord::Base
else # 回帖 else # 回帖
parent_author_id = Message.find(self.parent_id).author_id parent_author_id = Message.find(self.parent_id).author_id
if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息
self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false) #self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false)
if ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count
if count == 0
content = strip_html self.content.html_safe, 200 content = strip_html self.content.html_safe, 200
ws.comment_template parent_author_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content ws.comment_template parent_author_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content
end end

View File

@ -170,7 +170,8 @@ class News < ActiveRecord::Base
self.course.members.each do |m| self.course.members.each do |m|
if m.user_id != self.author_id if m.user_id != self.author_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
if ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count == 0 count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
if count == 0
ws = WechatService.new ws = WechatService.new
content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200 content = strip_html self.author.try(:realname) + " 发布了通知:" + self.title.html_safe, 200
ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on) ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 发布了通知:" + content, format_time(self.created_on)

View File

@ -63,11 +63,17 @@ class StudentWork < ActiveRecord::Base
final_score = final_ta_score + final_s_score final_score = final_ta_score + final_s_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end end
else #不考虑教师评分 else #不考虑教师评分
if student_work.teaching_asistant_score.nil? if student_work.student_score.nil? && student_work.teaching_asistant_score.nil?
student_work.final_score = student_work.teacher_score
elsif student_work.teaching_asistant_score.nil?
student_work.final_score = student_work.student_score student_work.final_score = student_work.student_score
elsif student_work.student_score.nil? elsif student_work.student_score.nil?
student_work.final_score = student_work.teaching_asistant_score student_work.final_score = student_work.teaching_asistant_score
@ -78,8 +84,12 @@ class StudentWork < ActiveRecord::Base
final_score = final_ta_score + final_s_score final_score = final_ta_score + final_s_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end end
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空 elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
if homework.teacher_priority == 1 #教师优先 if homework.teacher_priority == 1 #教师优先
@ -114,9 +124,13 @@ class StudentWork < ActiveRecord::Base
final_score = final_sy_score + final_ts_score + final_st_score final_score = final_sy_score + final_ts_score + final_st_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
end student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end
else #不考虑教师评分 else #不考虑教师评分
if student_work.teaching_asistant_score.nil? #教辅未评分 if student_work.teaching_asistant_score.nil? #教辅未评分
if student_work.student_score.nil? if student_work.student_score.nil?
@ -145,8 +159,12 @@ class StudentWork < ActiveRecord::Base
final_score = final_sy_score + final_ts_score + final_st_score final_score = final_sy_score + final_ts_score + final_st_score
student_work.final_score = format("%.2f",final_score.to_f) student_work.final_score = format("%.2f",final_score.to_f)
end end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
else
student_work.work_score = nil
end
end end
end end
end end

View File

@ -10,23 +10,23 @@ class WechatService
data:{ data:{
first: { first: {
value:first, value:first,
color:"#CCCCCC" color:"#707070"
}, },
keyword1:{ keyword1:{
value:key1, value:key1,
color:"#CCCCCC" color:"#707070"
}, },
keyword2:{ keyword2:{
value:key2, value:key2,
color:"#CCCCCC" color:"#707070"
}, },
keyword3:{ keyword3:{
value:key3, value:key3,
color:"#CCCCCC" color:"#707070"
}, },
remark:{ remark:{
value:remark, value:remark,
color:"#CCCCCC" color:"#707070"
} }
} }
} }
@ -88,19 +88,19 @@ class WechatService
data:{ data:{
first: { first: {
value:first, value:first,
color:"#CCCCCC" color:"#707070"
}, },
keyword1:{ keyword1:{
value:key1, value:key1,
color:"#CCCCCC" color:"#707070"
}, },
keyword2:{ keyword2:{
value:key2, value:key2,
color:"#CCCCCC" color:"#707070"
}, },
remark:{ remark:{
value:remark, value:remark,
color:"#CCCCCC" color:"#707070"
} }
} }
} }

View File

@ -25,7 +25,7 @@
<%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%> <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%>
<% end %> <% end %>
<% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
<span class="c_red ml10 fr">[已设为首页]</span> <span class="font_normal ml10 fr">[已设为首页]</span>
<% end %> <% end %>
<% if activity.sticky == 1 %> <% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span> <span class="fl ml10 red-cir-btn">顶</span>

View File

@ -84,7 +84,7 @@
<% end%> <% end%>
<script type="text/javascript"> <script type="text/javascript">
var coursecount = <%= @user.courses.visible.count%>; var coursecount = <%= @user.courses.visible.where("is_delete =?", 0).select("courses.* FROM `course_activities` WHERE course_activities.course_id = courses.id) ").count %>;
var courseshowcount = document.getElementsByClassName("coursesLineGrey").length; var courseshowcount = document.getElementsByClassName("coursesLineGrey").length;
if((coursecount == courseshowcount)&&(coursecount > 5) ){ if((coursecount == courseshowcount)&&(coursecount > 5) ){

View File

@ -64,7 +64,7 @@
<% end%> <% end%>
<script type="text/javascript"> <script type="text/javascript">
var projectcount = <%= @user.projects.visible.count%>; var projectcount = <%= @user.projects.visible.select("projects.* FROM `forge_activities` WHERE forge_activities.project_id = projects.id) ").count %>;
var projectshowcount = document.getElementsByClassName("projectsLineGrey").length; var projectshowcount = document.getElementsByClassName("projectsLineGrey").length;
if((projectcount == projectshowcount)&&(projectcount > 5)){ if((projectcount == projectshowcount)&&(projectcount > 5)){

View File

@ -226,7 +226,7 @@
end end
%> %>
<% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %>
<div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" > <div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" >
<div class = "leftCoursesList" id="homepageLeftMenuCourses"> <div class = "leftCoursesList" id="homepageLeftMenuCourses">
@ -258,7 +258,7 @@
end end
%> %>
<% projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%> <% projects = @user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%>
<div class="homepageLeftMenuCourses <%= projects.empty? ? 'none' : ''%>" > <div class="homepageLeftMenuCourses <%= projects.empty? ? 'none' : ''%>" >
<div class = "leftProjecsList" id="homepageLeftMenuForge"> <div class = "leftProjecsList" id="homepageLeftMenuForge">
<ul> <ul>

View File

@ -97,11 +97,19 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="homepagePostReply"> <div class="homepagePostReply">
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复
<sapn class="mr15"><%= @comments.count>0 ? "#{@comments.count}" : "" %></sapn><span style="color: #cecece;">▪</span>
<span id="praise_count_<%=@news.id %>">
<% if @news.author == User.current %>
<span class="ml15 likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(@news) > 0 ? "#{get_praise_num(@news)}" : "" %></span></span>
<% else %>
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>@news, :user_activity_id=>@news.id,:type=>"activity"}%>
<% end %>
</span>
</div>
</div>
<% unless @comments.empty? %> <% unless @comments.empty? %>
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复(<%=@comments.count %></div>
<div class="homepagePostReplyBannerTime"></div>
</div>
<div class="" id="reply_div_<%=@news.id %>"> <div class="" id="reply_div_<%=@news.id %>">
<% @comments.each_with_index do |reply,i| %> <% @comments.each_with_index do |reply,i| %>
<script type="text/javascript"> <script type="text/javascript">
@ -127,13 +135,20 @@
<div style="margin-top: -7px; margin-bottom: 5px"> <div style="margin-top: -7px; margin-bottom: 5px">
<%= format_time(reply.created_on) %> <%= format_time(reply.created_on) %>
<div class="fr" id="reply_edit_menu_<%= reply.id%>" style="display: none"> <div class="fr" id="reply_edit_menu_<%= reply.id%>" style="display: none">
<span id="reply_praise_count_<%=reply.id %>">
<% if reply.author == User.current %>
<span class="fr newsGrey" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(reply) > 0 ? "#{get_praise_num(reply)}" : "" %></span></span>
<% else %>
<%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
<% end %>
</span>
<%= link_to_if_authorized_course( <%= link_to_if_authorized_course(
l(:button_delete), l(:button_delete),
{:controller => 'comments', {:controller => 'comments',
:action => 'destroy', :id => @news, :action => 'destroy', :id => @news,
:comment_id => reply}, :comment_id => reply},
:method => :delete, :method => :delete,
:class => 'fr newsGrey', :class => 'fr newsGrey mr10',
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete) :title => l(:button_delete)
) %> ) %>

View File

@ -34,4 +34,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -153,9 +153,9 @@
<div> <div>
<% if activity.homework_type != 2 %> <% if activity.homework_type != 2 %>
<% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %> <% else %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %>
<% end %> <% end %>
<% student_works.each_with_index do |sw, i| %> <% student_works.each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;"> <div class="fl mr10 w100" style="text-align:center;">
@ -211,7 +211,7 @@
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>"> <div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>">
项目名称:<%=project.name %><br /> 项目名称:<%=project.name %><br />
创建者:<%=(User.find project.user_id).show_name %>(组长)<br /> 创建者:<%=(User.find project.user_id).show_name %>(组长)<br />
更新时间:<%=time_from_now time %> 更新时间:<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %>
</div> </div>
</div> </div>
<% if i == 9 && projects.count > 10 %> <% if i == 9 && projects.count > 10 %>
@ -372,4 +372,7 @@
$("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap'); $("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap');
$("#moreProject_<%=user_activity_id %>").show(); $("#moreProject_<%=user_activity_id %>").show();
}); });
$(function(){
user_card_show_hide();
});
</script> </script>

View File

@ -157,3 +157,8 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -121,3 +121,8 @@
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -56,3 +56,8 @@
</div> </div>
</div> </div>
<% end %> <% end %>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -139,3 +139,8 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -159,3 +159,8 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -143,4 +143,7 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(description_show_hide(<%=user_activity_id %>)); $(description_show_hide(<%=user_activity_id %>));
$(function(){
user_card_show_hide();
});
</script> </script>

View File

@ -36,4 +36,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -133,3 +133,8 @@
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -152,4 +152,7 @@
target.eq(2).show(); target.eq(2).show();
} }
} }
$(function(){
user_card_show_hide();
});
</script> </script>

View File

@ -36,4 +36,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -120,4 +120,9 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -38,4 +38,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -34,4 +34,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -158,9 +158,9 @@
<div> <div>
<% if activity.homework_type != 2 %> <% if activity.homework_type != 2 %>
<% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %> <% else %>
<% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %>
<% end %> <% end %>
<% student_works.includes(:user).each_with_index do |sw, i| %> <% student_works.includes(:user).each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;"> <div class="fl mr10 w100" style="text-align:center;">
@ -226,7 +226,7 @@
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>"> <div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>">
项目名称:<%=project.name %><br /> 项目名称:<%=project.name %><br />
创建者:<%=(User.find project.user_id).show_name %>(组长)<br /> 创建者:<%=(User.find project.user_id).show_name %>(组长)<br />
更新时间:<%=time_from_now time %> 更新时间:<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %>
</div> </div>
</div> </div>
<% if i == 9 && projects.count > 10 %> <% if i == 9 && projects.count > 10 %>
@ -388,4 +388,7 @@
$("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap'); $("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap');
$("#moreProject_<%=user_activity_id %>").show(); $("#moreProject_<%=user_activity_id %>").show();
}); });
$(function(){
user_card_show_hide();
});
</script> </script>

View File

@ -107,4 +107,9 @@
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -2,7 +2,7 @@
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
<%#= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTo break_word mt-4"> <div class="homepagePostTo break_word mt-4">
@ -174,4 +174,9 @@
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -146,3 +146,8 @@
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -55,3 +55,8 @@
</div> </div>
</div> </div>
<% end %> <% end %>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -38,4 +38,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -36,4 +36,9 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -96,3 +96,8 @@
<%= render :partial => 'users/project_issue_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %> <%= render :partial => 'users/project_issue_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -167,3 +167,8 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -144,4 +144,7 @@
$("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap'); $("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap');
$("#moreProject_<%=user_activity_id %>").show(); $("#moreProject_<%=user_activity_id %>").show();
}); });
$(function(){
user_card_show_hide();
});
</script> </script>

View File

@ -162,9 +162,9 @@
<div> <div>
<% if homework_common.homework_type != 2 %> <% if homework_common.homework_type != 2 %>
<% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
<% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> <% student_works = homework_common.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %>
<% else %> <% else %>
<% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> <% student_works = homework_common.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %>
<% end %> <% end %>
<% student_works.includes(:user).each_with_index do |sw, i| %> <% student_works.includes(:user).each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;"> <div class="fl mr10 w100" style="text-align:center;">
@ -230,7 +230,7 @@
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=homework_common.id %>"> <div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=homework_common.id %>">
项目名称:<%=project.name %><br /> 项目名称:<%=project.name %><br />
创建者:<%=(User.find project.user_id).show_name %>(组长)<br /> 创建者:<%=(User.find project.user_id).show_name %>(组长)<br />
更新时间:<%=time_from_now time %> 更新时间:<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %>
</div> </div>
</div> </div>
<% if i == 9 && projects.count > 10 %> <% if i == 9 && projects.count > 10 %>
@ -392,4 +392,7 @@
$("#relatePWrap_<%=homework_common.id %>").toggleClass('relatePWrap'); $("#relatePWrap_<%=homework_common.id %>").toggleClass('relatePWrap');
$("#moreProject_<%=homework_common.id %>").show(); $("#moreProject_<%=homework_common.id %>").show();
}); });
$(function(){
user_card_show_hide();
});
</script> </script>

View File

@ -149,4 +149,9 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

@ -2,6 +2,8 @@
alert("您的申请尚未通过审核,暂时不可发送至课程"); alert("您的申请尚未通过审核,暂时不可发送至课程");
<% elsif @status == 2 %> <% elsif @status == 2 %>
alert("该作业是私有的,请先提交申请并通过审核后再发送"); alert("该作业是私有的,请先提交申请并通过审核后再发送");
<% elsif @status == 3 %>
alert("您的申请已被拒绝,不可发送至课程");
<% else %> <% else %>
<% if params[:is_observe].nil? %> <% if params[:is_observe].nil? %>
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/send_homework_to_course', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>'); $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/send_homework_to_course', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>');

View File

@ -2139,7 +2139,7 @@ zh:
label_journals_comment_template: 您的留言有新回复了 label_journals_comment_template: 您的留言有新回复了
label_blog_comment_template: 您的博客有新回复了 label_blog_comment_template: 您的博客有新回复了
label_new_blog_template: 有新博客了 label_new_blog_template: 有新博客了
label_new_issue_template: 有新缺陷了 label_new_issue_template: 有新缺陷了
label_new_notice_template: 您的课程有新通知了 label_new_notice_template: 您的课程有新通知了
#edit yk #edit yk
label_code_work_tests: 代码测试列表 label_code_work_tests: 代码测试列表

View File

@ -1,6 +1,7 @@
<div id="container"> <div id="container">
<!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 --> <!-- 模板1开始可以使用scripttype设置为text/html来存放模板片段并且用id标示 -->
<div loading-spinner></div>
<div ng-repeat="act in activities"> <div ng-repeat="act in activities">
<div ng-if="act.container_type=='Course'"> <div ng-if="act.container_type=='Course'">
<div ng-if="act.act_type=='HomeworkCommon'"> <div ng-if="act.act_type=='HomeworkCommon'">

View File

@ -14,11 +14,6 @@
</head> </head>
<body> <body>
<div ng-view> <div ng-view>
<div class="loading-modal loading-bg" ng-if="loading">
<div class="loading-box">
<img src="/images/wechat/loading.gif" alt=""/><span>加载中...</span>
</div>
</div>
</div> </div>

View File

@ -23,6 +23,32 @@ function description_show_hide(id){
}); });
} }
//名片的显示
function user_card_show_hide() {
$(".homepagePostPortrait").mouseover(function(){
$(".userCard").css("display","none");
onImage = true;
$(this).children(".userCard").css("display","block");
});
$(".homepagePostPortrait").mouseout(function(){
var cur = $(this);
onImage = false;
setTimeout(function(){
if (onUserCard == false && onImage == false){
$(cur).children(".userCard").css("display", "none");
}
}, 500);
});
$(".userCard").mouseover(function(){
onUserCard = true;
$(this).css("display","block");
});
$(".userCard").mouseout(function(){
onUserCard = false;
$(this).css("display","none");
});
}
function cleanArray (actual){ function cleanArray (actual){
var newArray = new Array(); var newArray = new Array();
for (var i = 0; i< actual.length; i++){ for (var i = 0; i< actual.length; i++){

View File

@ -3,6 +3,7 @@ var apiUrl = '/api/v1/';
var debug = false; //调试标志,如果在本地请置为true var debug = false; //调试标志,如果在本地请置为true
if(debug===true){ if(debug===true){
//apiUrl = 'http://localhost:3000/api/v1/';
apiUrl = 'https://www.trustie.net/api/v1/'; apiUrl = 'https://www.trustie.net/api/v1/';
} }
@ -435,6 +436,25 @@ app.directive('textAutoHeight', function($timeout){
} }
}); });
app.directive('loadingSpinner', function ($http) {
return {
restrict: 'A',
replace: true,
template: '<div class="loading-bg"><div class="loading-box"><img src="/images/wechat/loading.gif" alt=""/><span>加载中...</span></div></div>',
link: function (scope, element, attrs) {
scope.$watch('activeCalls', function (newVal, oldVal) {
if (newVal == 0) {
$(element).hide();
}
else {
$(element).show();
}
});
}
};
});
app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProvider) { app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProvider) {
$routeProvider $routeProvider
.when('/activities', { .when('/activities', {
@ -472,22 +492,30 @@ app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProv
.otherwise({ .otherwise({
redirectTo: '/activities' redirectTo: '/activities'
}); });
//$httpProvider.interceptors.push('timestampMarker');
}]);
//loading //监听异步请求
app.factory('timestampMarker', ["$rootScope", function ($rootScope) { $httpProvider.interceptors.push(function ($q, $rootScope) {
var timestampMarker = { if ($rootScope.activeCalls == undefined) {
request: function (config) { $rootScope.activeCalls = 0;
$rootScope.loading = true; }
config.requestTimestamp = new Date().getTime();
return config; return {
}, request: function (config) {
response: function (response) { $rootScope.activeCalls += 1;
// $rootScope.loading = false; return config;
response.config.responseTimestamp = new Date().getTime(); },
return response; requestError: function (rejection) {
} $rootScope.activeCalls -= 1;
}; return rejection;
return timestampMarker; },
response: function (response) {
$rootScope.activeCalls -= 1;
return response;
},
responseError: function (rejection) {
$rootScope.activeCalls -= 1;
return rejection;
}
};
});
}]); }]);

View File

@ -1322,7 +1322,7 @@ a.sortdownbtn{ background: url(../images/liststyle.png) 0 -12px no-repeat; width
.item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;} .item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;}
.list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:550px;} .list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:550px;}
a:hover.list-title{ color:#269ac9;} a:hover.list-title{ color:#269ac9;}
.c_red{ font-weight:normal; font-size:12px;} .font_normal{ font-weight:normal; font-size:12px;}
.list-file{ padding:10px 0; border-bottom:1px dashed #ddd;} .list-file{ padding:10px 0; border-bottom:1px dashed #ddd;}
.list-file li{ line-height:1.9;} .list-file li{ line-height:1.9;}
.list-info span{ margin-left:5px;} .list-info span{ margin-left:5px;}

View File

@ -1519,7 +1519,7 @@ a.sortdownbtn{ background: url(../images/liststyle.png) 0 -12px no-repeat; width
.item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;} .item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;}
.list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:550px;} .list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:550px;}
a:hover.list-title{ color:#269ac9;} a:hover.list-title{ color:#269ac9;}
.c_red{ font-weight:normal; font-size:12px;} .font_normal{ font-weight:normal; font-size:12px;}
.list-file{ padding:10px 0; border-bottom:1px dashed #ddd;} .list-file{ padding:10px 0; border-bottom:1px dashed #ddd;}
.list-file li{ line-height:1.9;} .list-file li{ line-height:1.9;}
.list-info span{ margin-left:5px;} .list-info span{ margin-left:5px;}

View File

@ -1220,7 +1220,7 @@ a.sortdownbtn{ background: url(../images/liststyle.png) 0 -12px no-repeat; width
.item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;} .item_list{ display:block; width:5px; height:5px;-webkit-border-radius: 25px;border-radius:25px; background-color:#adadad; margin:10px 10px 0 0;}
.list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:550px;} .list-file a.list-title{ font-size:14px; font-weight: bold; color:#000;white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:block; max-width:550px;}
a:hover.list-title{ color:#269ac9;} a:hover.list-title{ color:#269ac9;}
.c_red{ font-weight:normal; font-size:12px;} .font_normal{ font-weight:normal; font-size:12px;}
.list-file{ padding:10px 0; border-bottom:1px dashed #ddd;} .list-file{ padding:10px 0; border-bottom:1px dashed #ddd;}
.list-file li{ line-height:1.9;} .list-file li{ line-height:1.9;}
.list-info span{ margin-left:5px;} .list-info span{ margin-left:5px;}
@ -1230,4 +1230,5 @@ a.pages-big{ width:50px;}
.pages .active{ background-color:#269ac9; color:#fff;} .pages .active{ background-color:#269ac9; color:#fff;}
.pages{width:330px; margin:20px auto 10px;} .pages{width:330px; margin:20px auto 10px;}
.red-cir-btn{ background:#e74c3c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;} .red-cir-btn{ background:#e74c3c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;}
.green-cir-btn{ background:#28be6c; padding:1px 5px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#fff; font-weight:normal;font-size:12px;}

View File

@ -76,4 +76,4 @@ a.underline {text-decoration:underline;}
.loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;} .loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;}
.loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;} .loading-box {position:absolute; top:50%; background:white; width:160px; height:72px; left:50%; margin-top:-36px; margin-left:-80px; text-align:center;}
.loading-box img {margin-top: 3px; text-align: center;} .loading-box img {margin-top: 3px; text-align: center;}
.loading-box span {display: block; font-size:13px;} .loading-box span {display: block; font-size:12px;}