Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-05-05 09:13:36 +08:00
commit bd22364f0a
51 changed files with 707 additions and 212 deletions

View File

@ -27,11 +27,15 @@ class BlogsController < ApplicationController
@topics.each do |topic|
topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count)
if topic[:infocount] < 0
topic[:infocount] = 0
end
end
@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 = sortby_time_countcommon_hassticky @topics,sort_name
else
@type = 1
end

View File

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

View File

@ -89,7 +89,7 @@ class HomeworkCommonController < ApplicationController
homework_detail_manual.comment_status = 1
end
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_end = homework_detail_manual.evaluation_start + 7
end

View File

@ -79,21 +79,20 @@ class NewsController < ApplicationController
@b_sort = 2
end
sort_name = "created_on"
sort_name = "updated_at"
sort_type = @b_sort == 1 ? "asc" : "desc"
scope = @course ? @course.news.course_visible : News.course_visible
news_arr = scope.map{|news| news.id}
@page = params[:page] ? params[:page].to_i + 1 : 0
news_page = 0 #@page *10
@news_count = scope.count
@is_new = params[:is_new]
@q = params[:subject]
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],
#:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC").limit(10).offset(news_page)
else
@ -101,16 +100,26 @@ class NewsController < ApplicationController
#.all(:include => [:author, :course],:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC")
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
@type = 2
scope_order.each do |topic|
topic[:infocount] = get_praise_num(topic) + topic.comments.count
if topic[:infocount] < 0
topic[:infocount] = 0
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] }
scope_order = sort_by_sticky scope_order
scope_order = sortby_time_countcommon_hassticky scope_order,sort_name
else
@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
@newss = scope_order

View File

@ -5,7 +5,7 @@ class StudentWorkController < ApplicationController
include ApplicationHelper
require 'bigdecimal'
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 :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
before_filter :author_of_work, :only => [:edit, :update, :destroy]
@ -17,41 +17,41 @@ class StudentWorkController < ApplicationController
is_test = params[:is_test] == 'true'
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
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
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
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
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
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
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
end
render :json => resultObj
end
@ -81,6 +81,8 @@ class StudentWorkController < ApplicationController
#根据传入的tIndex确定是第几次测试
#之后如果觉得很卡 可以改成将结果传回JS再以参数形式传回来
def program_test_ex
tStarttime = Time.now
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} #保存每测试一次返回的结果
@ -92,83 +94,229 @@ class StudentWorkController < ApplicationController
resultObj[:status] = 100
else
if @homework.homework_type == 2 && @homework.homework_detail_programing
#找到第index个测试的输入输出
index = params[:tIndex].to_i
resultObj[:tseq] = index
test = @homework.homework_tests[index - 1]
#找到第index个测试的输入输出
index = params[:tIndex].to_i
resultObj[:tseq] = index
test = @homework.homework_tests[index - 1]
#请求测试
#请求测试
begin
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
#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
#status 0:答案正确 -3http超时 -2:编译错误 -1:答案错误 2:程序运行超时
CodeTests.create(:homework_id=>@homework.id,:language=>@homework.homework_detail_programing.language,:status=>-3,:wait_time=>tUsedtime,:student_work_id=>student_work.id)
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 编译错误
resultObj[:status] = -1
resultObj[:results] = result["results"].first #本次测试结果
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
logger.debug result
if result["status"].to_i == -2 #编译错误
resultObj[:results] = result["error_msg"]
resultObj[:status] = -2
elsif result["results"][0]["status"].to_i == 2
resultObj[:status] = 2
end
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误
resultObj[:status] = -1
resultObj[:results] = result["results"].first #本次测试结果
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
unless student_work.save
resultObj[:status] = 200
#该状态用于存入CodeTests
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
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
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
student_work.late_penalty = 0
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
#找出该作业的所有提交作业
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
# 作业消息状态更新
@ -504,7 +652,7 @@ class StudentWorkController < ApplicationController
if @homework.homework_detail_group.base_on_project == 1
stu_project.project_id = @student_work_project.project_id
else @homework.homework_detail_group.base_on_project == 0
stu_project.project_id = -1
stu_project.project_id = -1
end
stu_project.user_id = members[i].to_i
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)
homework_detail_manual.ta_proportion = params[:ta_proportion]
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_programing.save if homework_detail_programing
@ -801,7 +949,7 @@ class StudentWorkController < ApplicationController
student_work.save
end
end
@homework.save
if params[:student_path]
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
if student_work.nil?
@homework.student_works.build(
name: params[:title],
description: params[:src],
user_id: User.current.id,
is_test: is_test
)
name: params[:title],
description: params[:src],
user_id: User.current.id,
is_test: is_test
)
unless @homework.save
logger.debug @homework.errors.full_messages
else
@ -1120,7 +1268,7 @@ class StudentWorkController < ApplicationController
src:src,
language:@homework.homework_detail_programing.language,
factor: factor
}
}
uri = URI(url)
body = solutions.to_json
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
student_work.final_score = format("%.2f",final_score.to_f)
end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
if student_work.final_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
else #不考虑教师评分
if student_work.teaching_asistant_score.nil?
@ -1189,8 +1341,12 @@ class StudentWorkController < ApplicationController
final_score = final_ta_score + final_s_score
student_work.final_score = format("%.2f",final_score.to_f)
end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
if student_work.final_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
elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
if homework.teacher_priority == 1 #教师优先
@ -1225,8 +1381,12 @@ class StudentWorkController < ApplicationController
final_score = final_sy_score + final_ts_score + final_st_score
student_work.final_score = format("%.2f",final_score.to_f)
end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
if student_work.final_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
else #不考虑教师评分
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
student_work.final_score = format("%.2f",final_score.to_f)
end
score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score
student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score
if student_work.final_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

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)
if ah.empty?
@status = 2
elsif ah.first.status == 1
@status = 1
elsif ah.first.status != 2
@status = ah.first.status
end
end
if !params[:search].nil?
@ -2948,20 +2948,19 @@ class UsersController < ApplicationController
sort_name = "created_at"
sort_type = @c_sort == 1 ? "asc" : "desc"
if @user.courses.visible.count > 0
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
@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}")
#根据 作业+资源数排序
if @order.to_i == 2
@type = 2
@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)
if course[:infocount] < 0
course[:infocount] = 0
end
end
@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
@type = 1
end
@ -2993,21 +2992,19 @@ class UsersController < ApplicationController
sort_name = "created_on"
sort_type = @c_sort == 1 ? "asc" : "desc"
if @user.projects.visible.count > 0
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
@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.project_score.issue_num @project.project_score.attach_num
if @order.to_i == 2
@type = 2
@projects.each do |project|
project[:infocount] = project.project_score.issue_num+project.project_score.attach_num
if project[:infocount] < 0
project[:infocount] = 0
end
end
@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
@type = 1
end

View File

@ -3065,7 +3065,7 @@ def host_with_protocol
return Setting.protocol + "://" + Setting.host_name
end
#将有置顶属性的提到数组前面 #infocount 相同的按时间降序排列
#将有置顶属性的提到数组前面
def sort_by_sticky topics
tmpTopics = []
tmpIndex = 0
@ -3082,9 +3082,117 @@ def sort_by_sticky topics
tmpIndex = tmpIndex + 1
end
end
return tmpTopics
end
topics = tmpTopics
return topics
#按人气排序的时候 相同的人气必须按某种时间顺序排序 有置顶属性
def sortby_time_countcommon_hassticky topics,sortstr
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="...")
@ -3100,4 +3208,4 @@ def strip_html(text,len=0,endss="...")
end
end
return ss
end
end

View File

@ -162,7 +162,7 @@ class Issue < ActiveRecord::Base
end
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
if m.user_id != self.author_id && count != 0
if m.user_id != self.author_id && count == 0
ws = WechatService.new
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)

View File

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

View File

@ -10,23 +10,23 @@ class WechatService
data:{
first: {
value:first,
color:"#CCCCCC"
color:"#707070"
},
keyword1:{
value:key1,
color:"#CCCCCC"
color:"#707070"
},
keyword2:{
value:key2,
color:"#CCCCCC"
color:"#707070"
},
keyword3:{
value:key3,
color:"#CCCCCC"
color:"#707070"
},
remark:{
value:remark,
color:"#CCCCCC"
color:"#707070"
}
}
}
@ -88,19 +88,19 @@ class WechatService
data:{
first: {
value:first,
color:"#CCCCCC"
color:"#707070"
},
keyword1:{
value:key1,
color:"#CCCCCC"
color:"#707070"
},
keyword2:{
value:key2,
color:"#CCCCCC"
color:"#707070"
},
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"%>
<% end %>
<% 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 %>
<% if activity.sticky == 1 %>
<span class="fl ml10 red-cir-btn">顶</span>

View File

@ -84,7 +84,7 @@
<% end%>
<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;
if((coursecount == courseshowcount)&&(coursecount > 5) ){

View File

@ -64,7 +64,7 @@
<% end%>
<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;
if((projectcount == projectshowcount)&&(projectcount > 5)){

View File

@ -97,11 +97,19 @@
</div>
<div class="cl"></div>
<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? %>
<div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复(<%=@comments.count %></div>
<div class="homepagePostReplyBannerTime"></div>
</div>
<div class="" id="reply_div_<%=@news.id %>">
<% @comments.each_with_index do |reply,i| %>
<script type="text/javascript">
@ -127,13 +135,20 @@
<div style="margin-top: -7px; margin-bottom: 5px">
<%= format_time(reply.created_on) %>
<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(
l(:button_delete),
{:controller => 'comments',
:action => 'destroy', :id => @news,
:comment_id => reply},
:method => :delete,
:class => 'fr newsGrey',
:class => 'fr newsGrey mr10',
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) %>

View File

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

View File

@ -153,9 +153,9 @@
<div>
<% if activity.homework_type != 2 %>
<% 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 %>
<% 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 %>
<% student_works.each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;">
@ -211,7 +211,7 @@
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>">
项目名称:<%=project.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>
<% if i == 9 && projects.count > 10 %>
@ -372,4 +372,7 @@
$("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap');
$("#moreProject_<%=user_activity_id %>").show();
});
$(function(){
user_card_show_hide();
});
</script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -158,9 +158,9 @@
<div>
<% if activity.homework_type != 2 %>
<% 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 %>
<% 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 %>
<% student_works.includes(:user).each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;">
@ -226,7 +226,7 @@
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=activity.id %>">
项目名称:<%=project.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>
<% if i == 9 && projects.count > 10 %>
@ -388,4 +388,7 @@
$("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap');
$("#moreProject_<%=user_activity_id %>").show();
});
$(function(){
user_card_show_hide();
});
</script>

View File

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

View File

@ -2,7 +2,7 @@
<div class="homepagePostBrief">
<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 => "用户头像" %>
<%#= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
<%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
</div>
<div class="homepagePostDes">
<div class="homepagePostTo break_word mt-4">
@ -174,4 +174,9 @@
</div>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
user_card_show_hide();
});
</script>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -162,9 +162,9 @@
<div>
<% if homework_common.homework_type != 2 %>
<% 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 %>
<% 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 %>
<% student_works.includes(:user).each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;">
@ -230,7 +230,7 @@
<div class="relatePInfo" id="relatePInfo_<%=project.id %>_<%=homework_common.id %>">
项目名称:<%=project.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>
<% if i == 9 && projects.count > 10 %>
@ -392,4 +392,7 @@
$("#relatePWrap_<%=homework_common.id %>").toggleClass('relatePWrap');
$("#moreProject_<%=homework_common.id %>").show();
});
$(function(){
user_card_show_hide();
});
</script>

View File

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

View File

@ -2,6 +2,8 @@
alert("您的申请尚未通过审核,暂时不可发送至课程");
<% elsif @status == 2 %>
alert("该作业是私有的,请先提交申请并通过审核后再发送");
<% elsif @status == 3 %>
alert("您的申请已被拒绝,不可发送至课程");
<% else %>
<% 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}) %>');

View File

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

View File

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

View File

@ -14,11 +14,6 @@
</head>
<body>
<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>

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){
var newArray = new Array();
for (var i = 0; i< actual.length; i++){

View File

@ -3,6 +3,7 @@ var apiUrl = '/api/v1/';
var debug = false; //调试标志,如果在本地请置为true
if(debug===true){
//apiUrl = 'http://localhost:3000/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) {
$routeProvider
.when('/activities', {
@ -472,22 +492,30 @@ app.config(['$routeProvider',"$httpProvider",function ($routeProvider, $httpProv
.otherwise({
redirectTo: '/activities'
});
//$httpProvider.interceptors.push('timestampMarker');
}]);
//loading
app.factory('timestampMarker', ["$rootScope", function ($rootScope) {
var timestampMarker = {
request: function (config) {
$rootScope.loading = true;
config.requestTimestamp = new Date().getTime();
return config;
},
response: function (response) {
// $rootScope.loading = false;
response.config.responseTimestamp = new Date().getTime();
return response;
}
};
return timestampMarker;
//监听异步请求
$httpProvider.interceptors.push(function ($q, $rootScope) {
if ($rootScope.activeCalls == undefined) {
$rootScope.activeCalls = 0;
}
return {
request: function (config) {
$rootScope.activeCalls += 1;
return config;
},
requestError: function (rejection) {
$rootScope.activeCalls -= 1;
return rejection;
},
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;}
.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;}
.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 li{ line-height:1.9;}
.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;}
.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;}
.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 li{ line-height:1.9;}
.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;}
.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;}
.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 li{ line-height:1.9;}
.list-info span{ margin-left:5px;}
@ -1230,4 +1230,5 @@ a.pages-big{ width:50px;}
.pages .active{ background-color:#269ac9; color:#fff;}
.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-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 span {display: block; font-size:13px;}
.loading-box span {display: block; font-size:12px;}