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

This commit is contained in:
huang 2016-02-26 19:25:36 +08:00
commit 81f54e44b4
28 changed files with 515 additions and 125 deletions

View File

@ -469,6 +469,23 @@ class AdminController < ApplicationController
end end
end end
#最近登录老师列表
def latest_login_teachers
scope = User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 ORDER BY last_login_on DESC")
if params[:startdate].present?
scope = User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 and last_login_on>= '#{params[:startdate]} 00:00:00' ORDER BY last_login_on DESC")
end
if params[:enddate].present?
scope = User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 and last_login_on <= '#{params[:enddate]} 23:59:59' ORDER BY last_login_on DESC")
end
@teachers = scope
@teachers = paginateHelper @teachers,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end
end
#作业 #作业
def homework def homework
@homework = HomeworkCommon.order('end_time desc') @homework = HomeworkCommon.order('end_time desc')

View File

@ -29,7 +29,7 @@ class BlogsController < ApplicationController
def set_homepage def set_homepage
@blog = Blog.find(params[:id]) @blog = Blog.find(params[:id])
@blog.update_attribute(:homepage_id, params[:article_id]) @blog.update_attribute(:homepage_id, params[:article_id])
redirect_to user_blogs_path(params[:user_id]) redirect_to user_path(params[:user_id])
end end
def cancel_homepage def cancel_homepage

View File

@ -450,6 +450,93 @@ class CoursesController < ApplicationController
#copy avatar #copy avatar
copy_avatar(@course, copy_course) copy_avatar(@course, copy_course)
if params[:course_content_type]
params[:course_content_type].each do |type|
case type
when "0"
homeworks = copy_course.homework_commons
homeworks.each do |homework|
new_homework = HomeworkCommon.new
new_homework.name = homework.name
new_homework.user_id = User.current.id
new_homework.description = homework.description
new_homework.publish_time = Date.today + 30
new_homework.end_time = Date.today + 60
new_homework.homework_type = homework.homework_type
new_homework.late_penalty = homework.late_penalty
new_homework.course_id = @course.id
new_homework.teacher_priority = homework.teacher_priority
new_homework.anonymous_comment = homework.anonymous_comment
new_homework.quotes = 0
new_homework.is_open = homework.is_open
homework.attachments.each do |attachment|
att = attachment.copy
att.container_id = nil
att.container_type = nil
att.copy_from = attachment.id
att.save
new_homework.attachments << att
end
homework_detail_manual = homework.homework_detail_manual
homework_detail_programing = homework.homework_detail_programing
homework_detail_group = homework.homework_detail_group
if homework_detail_manual
new_homework.homework_detail_manual = HomeworkDetailManual.new
new_homework_detail_manual = new_homework.homework_detail_manual
new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion
new_homework_detail_manual.comment_status = 0
new_homework_detail_manual.evaluation_start = Date.today + 67
new_homework_detail_manual.evaluation_end = Date.today + 74
new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num
new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty
end
if homework_detail_programing
new_homework.homework_detail_programing = HomeworkDetailPrograming.new
new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
new_homework.homework_detail_programing.language = homework_detail_programing.language
homework.homework_tests.each_with_index do |homework_test|
new_homework.homework_tests << HomeworkTest.new(
input: homework_test.input,
output: homework_test.output
)
end
end
if homework_detail_group
new_homework.homework_detail_group = HomeworkDetailGroup.new
new_homework.homework_detail_group.min_num = homework_detail_group.min_num
new_homework.homework_detail_group.max_num = homework_detail_group.max_num
new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project
end
if new_homework.save
new_homework_detail_manual.save if new_homework_detail_manual
new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
new_homework.homework_detail_group.save if new_homework.homework_detail_group
end
homework.update_attribute(:quotes, homework.quotes+1)
end
when "1"
attachments = copy_course.attachments
attachments.each do |attachment|
attach_copied_obj = attachment.copy
attach_copied_obj.tag_list.add(attachment.tag_list) # tag关联
attach_copied_obj.container = @course
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.copy_from = attachment.copy_from.nil? ? attachment.id : attachment.copy_from
attach_copied_obj.is_publish = 0
attach_copied_obj.publish_time = Date.today + 30
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
attach_copied_obj.save
update_quotes attach_copied_obj
end
end
end
end
=begin
if params[:checkAll] if params[:checkAll]
attachments = copy_course.attachments attachments = copy_course.attachments
attachments.each do |attachment| attachments.each do |attachment|
@ -513,6 +600,7 @@ class CoursesController < ApplicationController
end end
end end
end end
=end
end end
if @course if @course
respond_to do |format| respond_to do |format|

View File

@ -6,8 +6,8 @@ class HomeworkCommonController < ApplicationController
include StudentWorkHelper include StudentWorkHelper
before_filter :find_course, :only => [:index,:new,:create] before_filter :find_course, :only => [:index,:new,:create]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works]
before_filter :member_of_course, :only => [:index] before_filter :member_of_course, :only => [:index]
def index def index
@ -261,6 +261,30 @@ class HomeworkCommonController < ApplicationController
end end
end end
def open_student_works
if @homework.is_open == 0
@homework.update_attribute(:is_open, 1)
else
@homework.update_attribute(:is_open, 0)
end
@user_activity_id = params[:user_activity_id]
@is_in_course = params[:is_in_course] if params[:is_in_course]
@course_activity = params[:course_activity] if params[:course_Activity]
end
def alert_open_student_works
if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
else
@user_activity_id = -1
end
@is_in_course = params[:is_in_course] if params[:is_in_course]
@course_activity = params[:course_activity] if params[:course_Activity]
respond_to do |format|
format.js
end
end
def programing_test def programing_test
test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]} test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
@index = params[:index] @index = params[:index]

View File

@ -6,9 +6,10 @@ class StudentWorkController < ApplicationController
require "base64" require "base64"
before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,: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,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students]
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 => [:index, :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]
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment]
before_filter :is_logged, :only => [:index]
### ###
def program_test def program_test
@ -91,101 +92,119 @@ class StudentWorkController < ApplicationController
student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
end end
#老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表 #老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
if @is_teacher || @homework.homework_detail_manual.nil? || if @homework.is_open == 1
(@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@show_all = true @show_all = true
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin?
if @homework.homework_type == 3 if @is_teacher || @homework.homework_detail_manual.nil? ||
pro = @homework.student_work_projects.where(:user_id => User.current.id).first (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
if pro.nil?
@stundet_works = []
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
end
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
end
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.where(:user_id => User.current.id)
end
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = []
else
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@show_all = true @show_all = true
end elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
else if @homework.homework_type == 3
@stundet_works = [] pro = @homework.student_work_projects.where(:user_id => User.current.id).first
end if pro.nil?
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count @stundet_works = []
else else
if @is_teacher || @homework.homework_detail_manual.nil? || (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) #老师 || 超级管理员 显示所有列表 @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name end
@show_all = true else
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
if @homework.homework_type == 3 end
pro = @homework.student_work_projects.where(:user_id => User.current.id).first elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if pro.nil? if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.where(:user_id => User.current.id)
end
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = [] @stundet_works = []
else else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
@show_all = true
end end
else else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
end
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.where(:user_id => User.current.id)
end
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = [] @stundet_works = []
else
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
@show_all = true
end end
else else
@stundet_works = [] render_403
return
end end
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
else
if @homework.is_open == 1
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
@show_all = true
elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin?
if @is_teacher || @homework.homework_detail_manual.nil? || (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) #老师 || 超级管理员 显示所有列表
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
@show_all = true
elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
@stundet_works = []
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
end
else
@stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
end
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.where(:user_id => User.current.id)
end
@stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id}
elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
my_work = []
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
end
else
my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = []
else
@stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
@show_all = true
end
else
@stundet_works = []
end
else
render_403
return
end
@student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name).count @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name).count
end end
@ -802,6 +821,10 @@ class StudentWorkController < ApplicationController
render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
end end
def is_logged
redirect_to signin_path unless User.current.logged?
end
#根据条件过滤作业结果 #根据条件过滤作业结果
def search_homework_member homeworks,name def search_homework_member homeworks,name
if name == "" if name == ""

View File

@ -1592,7 +1592,9 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4 attach_copied_obj.attachtype = 4
end end
attach_copied_obj.save if attach_copied_obj.save
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
@save_message = attach_copied_obj.errors.full_messages @save_message = attach_copied_obj.errors.full_messages
end end
end end
@ -1628,7 +1630,9 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4 attach_copied_obj.attachtype = 4
end end
attach_copied_obj.save if attach_copied_obj.save
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
@save_message = attach_copied_obj.errors.full_messages @save_message = attach_copied_obj.errors.full_messages
end end
end end
@ -1686,7 +1690,9 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1 attach_copied_obj.attachtype = 1
end end
attach_copied_obj.save if attach_copied_obj.save
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
unless Project.find(project_id).project_score.nil? unless Project.find(project_id).project_score.nil?
Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.update_attribute(:attach_num,
Project.find(project_id).project_score.attach_num + 1) Project.find(project_id).project_score.attach_num + 1)
@ -1725,7 +1731,9 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1 attach_copied_obj.attachtype = 1
end end
attach_copied_obj.save if attach_copied_obj.save
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
unless Project.find(project_id).project_score.nil? unless Project.find(project_id).project_score.nil?
Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1) Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1)
end end
@ -1782,7 +1790,9 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1 attach_copied_obj.attachtype = 1
end end
attach_copied_obj.save if attach_copied_obj.save
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
end end
end end
elsif params[:send_ids].present? elsif params[:send_ids].present?
@ -1816,7 +1826,9 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1 attach_copied_obj.attachtype = 1
end end
attach_copied_obj.save if attach_copied_obj.save
ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
end end
end end
else else
@ -1845,6 +1857,10 @@ class UsersController < ApplicationController
course_ids.each do |course_id| course_ids.each do |course_id|
if Course.find(course_id).news.map(&:id).exclude?(news.id) if Course.find(course_id).news.map(&:id).exclude?(news.id)
course_news = News.create(:course_id => course_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) course_news = News.create(:course_id => course_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1)
#record forward to table forwards if new record is valid
if course_news.valid?
news.forwards << Forward.new(:to_type => course_news.class.name, :to_id => course_news.id)
end
news.attachments.each do |attach| news.attachments.each do |attach|
course_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, course_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@ -1861,6 +1877,10 @@ class UsersController < ApplicationController
project = Project.find(project_id) project = Project.find(project_id)
if project.news.map(&:id).exclude?(news.id) if project.news.map(&:id).exclude?(news.id)
message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id)
# record forward to table forwards if new record is valid
if message.valid?
news.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id)
end
news.attachments.each do |attach| news.attachments.each do |attach|
message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@ -1874,6 +1894,10 @@ class UsersController < ApplicationController
news = News.find(params[:send_id]) news = News.find(params[:send_id])
field_id = params[:subfield] field_id = params[:subfield]
org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1)
# record forward to table forwards if new record is valid
if org_news.valid?
news.forwards << Forward.new(:to_type => org_news.class.name, :to_id => org_news.id)
end
news.attachments.each do |attach| news.attachments.each do |attach|
org_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, org_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@ -1889,6 +1913,10 @@ class UsersController < ApplicationController
course = Course.find(course_id) course = Course.find(course_id)
if course.news.map(&:id).exclude?(@message.id) if course.news.map(&:id).exclude?(@message.id)
message = Message.create(:board_id => course.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) message = Message.create(:board_id => course.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
# record forward to table forwards if new record is valid
if message.valid?
@message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id)
end
@message.attachments.each do |attach| @message.attachments.each do |attach|
message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@ -1905,6 +1933,10 @@ class UsersController < ApplicationController
project = Project.find(project_id) project = Project.find(project_id)
if project.news.map(&:id).exclude?(@message.id) if project.news.map(&:id).exclude?(@message.id)
message = Message.create(:board_id => project.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) message = Message.create(:board_id => project.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
# record forward to table forwards if new record is valid
if message.valid?
@message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id)
end
@message.attachments.each do |attach| @message.attachments.each do |attach|
message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@ -1921,6 +1953,10 @@ class UsersController < ApplicationController
@message.save @message.save
board = OrgSubfield.find(field_id).boards.first board = OrgSubfield.find(field_id).boards.first
mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
# record forward to table forwards if new record is valid
if mes.valid?
@message.forwards << Forward.new(:to_type => mes.class.name, :to_id => mes.id)
end
@message.attachments.each do |attach| @message.attachments.each do |attach|
mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,

View File

@ -28,7 +28,7 @@ class Attachment < ActiveRecord::Base
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
# 被ForgeActivity虚拟关联 # 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
has_many :forwards, :as => :from has_many :forwards, :as => :from, :dependent => :destroy
# 课程动态 # 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end # end
@ -88,7 +88,8 @@ class Attachment < ActiveRecord::Base
cattr_accessor :thumbnails_storage_path cattr_accessor :thumbnails_storage_path
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location,:act_as_course_activity before_save :files_to_final_location
after_save :act_as_course_activity
after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index
after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count
@ -606,8 +607,14 @@ class Attachment < ActiveRecord::Base
#课程动态公共表记录 #课程动态公共表记录
def act_as_course_activity def act_as_course_activity
if self.container_type == "Course" && self.course_acts.empty? if self.container_type == "Course"
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id) if self.is_publish == 0
self.course_acts.destroy_all
else
if self.is_publish == 1 && self.course_acts.empty?
self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id)
end
end
end end
end end

View File

@ -45,6 +45,8 @@ class Message < ActiveRecord::Base
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
#转发表
has_many :forwards, :as => :from, :dependent => :destroy
after_destroy :delete_org_activities after_destroy :delete_org_activities
acts_as_searchable :columns => ['subject', 'content'], acts_as_searchable :columns => ['subject', 'content'],

View File

@ -37,6 +37,9 @@ class News < ActiveRecord::Base
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
#end #end
#转发表
has_many :forwards, :as => :from, :dependent => :destroy
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
validates_presence_of :title, :description validates_presence_of :title, :description

View File

@ -0,0 +1,7 @@
<div class="tabs">
<ul>
<li><%= link_to '用户', {:action => 'latest_login_users'}, class: "#{current_page?(latest_login_users_path)? 'selected' : nil }" %></li>
<li><%= link_to '老师', {:action => 'latest_login_teachers'}, class: "#{current_page?(latest_login_teachers_path)? 'selected' : nil }" %></li>
</ul>
</div>

View File

@ -0,0 +1,84 @@
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
<h3>
<%=l(:label_latest_login_user_list)%>
</h3>
<%= render 'tab_users' %>
<h3>
最近登录老师列表
</h3>
<%= form_tag({}, :method => :get) do %>
<fieldset>
<legend>
<%= l(:label_filter_plural) %>
</legend>
<label style="float:left">开始日期:</label>
<%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange=>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
<%= calendar_for('startdate')%><span style="float: left ">&nbsp;&nbsp;&nbsp;</span>
<label style="float:left">结束日期:</label>
<%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
<%= calendar_for('enddate')%> &nbsp;
<%= submit_tag l(:button_apply), :class => "small", :name => nil %>
<%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_teachers'}, :class => 'icon icon-reload' %>
</fieldset>
<% end %>
&nbsp;
<div class="autoscroll">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
序号
</th>
<th style="width: 70px;">
登录时间
</th>
<th style="width: 30px;">
用户id
</th>
<th style="width: 50px;">
用户姓名
</th>
<th style="width: 50px;">
用户登录名
</th>
<th style="width: 50px;">
用户身份
</th>
</tr>
</thead>
<tbody>
<% @count=@page * 30 %>
<% for teacher in @teachers do %>
<tr>
<% @count +=1 %>
<td align="center">
<%=@count %>
</td>
<td align="center">
<%=format_time(teacher.last_login_on) %>
</td>
<td align="center">
<%=teacher.id %>
</td>
<td align="center" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<% if teacher.try(:realname) == ' '%><%= teacher.login%><% else %><%=teacher.try(:realname) %><% end %>'>
<% if teacher.try(:realname) == ' '%>
<%= link_to(teacher.login, user_path(teacher)) %>
<% else %>
<%= link_to(teacher.try(:realname), user_path(teacher)) %>
<% end %>
</td>
<td align="center">
<%=link_to(teacher.login, user_path(teacher)) %>
</td>
<td align="center">
老师
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>

View File

@ -2,7 +2,10 @@
<h3> <h3>
<%=l(:label_latest_login_user_list)%> <%=l(:label_latest_login_user_list)%>
</h3> </h3>
<%= render 'tab_users' %>
<h3>
<%=l(:label_latest_login_user_list)%>
</h3>
<%= form_tag({}, :method => :get) do %> <%= form_tag({}, :method => :get) do %>
<fieldset> <fieldset>
<legend> <legend>

View File

@ -92,16 +92,23 @@
<span class="c_grey">(选中后课外用户可见该课程,否则仅对课内成员可见)</span> <span class="c_grey">(选中后课外用户可见该课程,否则仅对课内成员可见)</span>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<li class="ml58"> <li class="ml85">
<label class="fl">复制资源&nbsp;&nbsp;</label> <label class="fl">复制&nbsp;&nbsp;</label>
<ul class="fl" id="copyResource"> <ul class="fl" id="copyResource" style="width:544px;">
<li class="sendCourseName fl mr15 ml5"> <li class="sendCourseName fl ml5">
<label> <label class="fl">
<input name="checkAll" type="checkbox" id="allResource" value="0" class="resourceCopy"/> <input name="course_content_type[]" type="checkbox" value="0" class="resourceCopy"/>
全部</label> 作业</label>
<span class="c_red ml5 fl mb10 w490">复制到新课中的作业将在1个月后发布、2个月后提交截止请您调整作业的发布时间、截止时间等时间节点。</span>
</li>
<li class="sendCourseName fl ml5">
<label class="fl">
<input name="course_content_type[]" type="checkbox" value="1" class="resourceCopy"/>
资源</label>
<span class="c_red ml5 fl mb10">复制到新课的资源将在1个月后发布请您调整资源的发布时间否则学生可能看不到资源。</span>
</li> </li>
</ul> </ul>
<ul class="fl" id="copyResource2"> <!--<ul class="fl" id="copyResource2">
<li class="sendCourseName fl mr15"> <li class="sendCourseName fl mr15">
<label> <label>
<input name="course_attachment_type[]" type="checkbox" value="1" class="resourceCopy"/> <input name="course_attachment_type[]" type="checkbox" value="1" class="resourceCopy"/>
@ -134,7 +141,7 @@
</li> </li>
<div class="cl"></div> <div class="cl"></div>
</ul> </ul>
<span class="c_red ml5 fl mb10">您可以通过选择资源类型,将对应资源复制到新课程中。</span> <span class="c_red ml5 fl mb10">您可以通过选择类型,将对应类型复制到新课程中。</span>-->
<div class="cl"></div> <div class="cl"></div>
</li> </li>
<% end %> <% end %>

View File

@ -3,7 +3,7 @@ if(document.getElementById("popbox02")) {
} }
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'copy_course') %>'); $('#ajax-modal').html('<%= escape_javascript(render :partial => 'copy_course') %>');
showModal('ajax-modal', '730px'); showModal('ajax-modal', '730px');
$('#ajax-modal').css('height','530px').css('width','730px'); $('#ajax-modal').css('height','auto').css('width','730px');
$('#ajax-modal').siblings().remove(); $('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<div class='resourcePopupClose mt5 mr-5'>" + $('#ajax-modal').before("<div class='resourcePopupClose mt5 mr-5'>" +
"<a href='javascript:void(0)' class='resourceClose' onclick='hideResource();'></a></div>"); "<a href='javascript:void(0)' class='resourceClose' onclick='hideResource();'></a></div>");

View File

@ -0,0 +1,23 @@
<div id="popbox02">
<div class="ni_con">
<% if @homework.is_open == 0 %>
<h2>公开作品</h2>
<p>
本次作业的所有作品将对Trustie平台所有注册用户开放请问是否确定公开作品
</p>
<% else %>
<h2>取消公开作品</h2>
<p>
您将取消“公开作品”的功能本次作业的作品将不对Trustie平台其他未加入本课程的用户开放请问是否确定
</p>
<% end %>
<div class="ni_btn">
<a href="javascript:" class="tijiao" onclick="clickOK('<%= open_student_works_homework_common_path(@homework, :user_activity_id => @user_activity_id,:is_in_course=>@is_in_course, :course_activity => @course_activity)%>');" style="margin-bottom: 20px;" >
确&nbsp;&nbsp;定
</a>
<a href="javascript:" class="tijiao" onclick="clickCanel();" style="margin-bottom: 20px;">
取&nbsp;&nbsp;消
</a>
</div>
</div>
</div>

View File

@ -0,0 +1,6 @@
$("#ajax-modal").html("<%=escape_javascript(render :partial => 'alert_open_student_works') %>");
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed").css("border","3px solid #269ac9");

View File

@ -0,0 +1,7 @@
<% if @user_activity_id.to_i == -1 %>
$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>");
sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>");
<% else %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>");
sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity");
<% end %>

View File

@ -1,6 +1,6 @@
<%= content_for(:header_tags) do %> <%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<%= javascript_include_tag "des_KindEditor" %> <%= javascript_include_tag "des_kindEditor" %>
<% end %> <% end %>
<script> <script>

View File

@ -42,7 +42,7 @@
}); });
</script> </script>
<% if act.container_type == 'Organization' %> <% if act.container_type == 'Organization' %>
<% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> <% if act.org_act_type == 'OrgDocumentComment' %>
<%= render :partial => 'organizations/show_org_document', :locals => {:document => act.org_act, :act => act, :flag => 2, :org_subfield_id => params[:org_subfield_id]} %> <%= render :partial => 'organizations/show_org_document', :locals => {:document => act.org_act, :act => act, :flag => 2, :org_subfield_id => params[:org_subfield_id]} %>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -114,9 +114,11 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div> <div>
<div class="homepagePostDeadline"> <% if activity.anonymous_comment == 0%>
缺评扣分:<%= activity.homework_detail_manual.absence_penalty%>分/作品 <div class="homepagePostDeadline">
</div> 缺评扣分:<%= activity.homework_detail_manual.absence_penalty%>分/作品
</div>
<% end %>
<% if activity.anonymous_comment == 0%> <% if activity.anonymous_comment == 0%>
<div class="homepagePostDeadline" style="float: right; margin-right: 220px;" id="evaluation_end_time_<%=user_activity_id %>"> <div class="homepagePostDeadline" style="float: right; margin-right: 220px;" id="evaluation_end_time_<%=user_activity_id %>">
匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end%>&nbsp;23:59 匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end%>&nbsp;23:59
@ -240,6 +242,15 @@
<%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
</li> </li>
<% end %> <% end %>
<% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
<li>
<%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
</li>
<% elsif activity.is_open == 1 %>
<li>
<%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
</li>
<% end %>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -4,15 +4,16 @@
<font class="f12 c_red"> <font class="f12 c_red">
(<%= @student_work_count%>人已交) (<%= @student_work_count%>人已交)
</font> </font>
<% if !@is_teacher && @stundet_works.empty?%> <% my_work = @homework.student_works.where("user_id = #{User.current.id}").first %>
<% if !@is_teacher && my_work.nil? && User.current.member_of_course?(@course) %>
<span class="f12 c_red">您尚未提交作品</span> <span class="f12 c_red">您尚未提交作品</span>
<% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<span class="f12 c_red">您已提交且不可再修改,因为截止日期已过</span> <span class="f12 c_red">您已提交且不可再修改,因为截止日期已过</span>
<% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%>
<span class="f12 c_red">您已提交,您还可以修改</span> <span class="f12 c_red">您已提交,您还可以修改</span>
<% end %> <% end %>
</span> </span>
<%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3 || @homework.is_open == 1%>
<div class="hworkSearchBox"> <div class="hworkSearchBox">
<input type="text" id="course_student_name" value="<%= @name%>" placeholder="姓名、学号、邮箱" class="hworkSearchInput" onkeypress="SearchByName('<%= student_work_index_path(:homework => @homework.id)%>',event);"/> <input type="text" id="course_student_name" value="<%= @name%>" placeholder="姓名、学号、邮箱" class="hworkSearchInput" onkeypress="SearchByName('<%= student_work_index_path(:homework => @homework.id)%>',event);"/>
<a class="hworkSearchIcon" id="search_in_student_work" onclick="SearchByName_1('<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a> <a class="hworkSearchIcon" id="search_in_student_work" onclick="SearchByName_1('<%= student_work_index_path(:homework => @homework.id)%>');" href="javascript:void(0)"></a>

View File

@ -114,9 +114,11 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div> <div>
<div class="homepagePostDeadline"> <% if activity.anonymous_comment == 0%>
缺评扣分:<%= activity.homework_detail_manual.absence_penalty%>分/作品 <div class="homepagePostDeadline">
</div> 缺评扣分:<%= activity.homework_detail_manual.absence_penalty%>分/作品
</div>
<% end %>
<% if activity.anonymous_comment == 0%> <% if activity.anonymous_comment == 0%>
<div class="homepagePostDeadline" style="float: right; margin-right: 220px;" id="evaluation_end_time_<%=user_activity_id %>"> <div class="homepagePostDeadline" style="float: right; margin-right: 220px;" id="evaluation_end_time_<%=user_activity_id %>">
匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end%>&nbsp;23:59 匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end%>&nbsp;23:59
@ -239,6 +241,15 @@
<%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
</li> </li>
<% end %> <% end %>
<% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
<li>
<%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
</li>
<% elsif activity.is_open == 1 %>
<li>
<%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
</li>
<% end %>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -115,9 +115,11 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div> <div>
<div class="homepagePostDeadline"> <% if homework_common.anonymous_comment == 0 %>
缺评扣分:<%= homework_common.homework_detail_manual.absence_penalty%>分/作品 <div class="homepagePostDeadline">
</div> 缺评扣分:<%= homework_common.homework_detail_manual.absence_penalty%>分/作品
</div>
<% end %>
<% if homework_common.anonymous_comment == 0%> <% if homework_common.anonymous_comment == 0%>
<div class="homepagePostDeadline" style="float: right; margin-right: 220px;" id="evaluation_end_time_<%=homework_common.id %>"> <div class="homepagePostDeadline" style="float: right; margin-right: 220px;" id="evaluation_end_time_<%=homework_common.id %>">
匿评关闭时间:<%= homework_common.homework_detail_manual.evaluation_end%>&nbsp;23:59 匿评关闭时间:<%= homework_common.homework_detail_manual.evaluation_end%>&nbsp;23:59
@ -243,6 +245,15 @@
<%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%> <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%>
</li> </li>
<% end %> <% end %>
<% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %>
<li>
<%= link_to("公开作品", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
</li>
<% elsif homework_common.is_open == 1 %>
<li>
<%= link_to("取消公开", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
</li>
<% end %>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -238,6 +238,8 @@ RedmineApp::Application.routes.draw do
get 'stop_anonymous_comment' get 'stop_anonymous_comment'
get 'alert_anonymous_comment' get 'alert_anonymous_comment'
get 'alert_forbidden_anonymous_comment' get 'alert_forbidden_anonymous_comment'
get 'alert_open_student_works'
get 'open_student_works'
get 'start_evaluation_set' get 'start_evaluation_set'
get 'score_rule_set' get 'score_rule_set'
post 'set_evaluation_attr' post 'set_evaluation_attr'
@ -952,7 +954,8 @@ RedmineApp::Application.routes.draw do
match 'admin/project_messages', as: :project_messages match 'admin/project_messages', as: :project_messages
match'admin/course_messages', as: :course_messages match'admin/course_messages', as: :course_messages
get 'admin/notices' get 'admin/notices'
get 'admin/latest_login_users' match 'admin/latest_login_users', as: :latest_login_users
match 'admin/latest_login_teachers', as: :latest_login_teachers
get 'admin/homework' get 'admin/homework'
resources :auth_sources do resources :auth_sources do

View File

@ -0,0 +1,5 @@
class AddIsOpenToHomewrokCommon < ActiveRecord::Migration
def change
add_column :homework_commons, :is_open, :integer, :default => 0
end
end

View File

@ -751,6 +751,14 @@ ActiveRecord::Schema.define(:version => 20160224074034) do
t.integer "locked" t.integer "locked"
end end
create_table "forwards", :force => true do |t|
t.integer "from_id"
t.string "from_type"
t.integer "to_id"
t.string "to_type"
t.datetime "created_at"
end
create_table "groups_users", :id => false, :force => true do |t| create_table "groups_users", :id => false, :force => true do |t|
t.integer "group_id", :null => false t.integer "group_id", :null => false
t.integer "user_id", :null => false t.integer "user_id", :null => false
@ -788,6 +796,7 @@ ActiveRecord::Schema.define(:version => 20160224074034) do
t.integer "teacher_priority", :default => 1 t.integer "teacher_priority", :default => 1
t.integer "anonymous_comment", :default => 0 t.integer "anonymous_comment", :default => 0
t.integer "quotes", :default => 0 t.integer "quotes", :default => 0
t.integer "is_open", :default => 0
end end
add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id"

View File

@ -1013,8 +1013,9 @@ function showNormalImage(id) {
var image=$(description_images[i]); var image=$(description_images[i]);
var element=$("<a></a>").attr("href",image.attr('src')); var element=$("<a></a>").attr("href",image.attr('src'));
image.wrap(element); image.wrap(element);
$(image).parent().colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
} }
$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框 //$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框
} }
} }

View File

@ -157,6 +157,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.w430{ width:470px;} .w430{ width:470px;}
.w455{width:455px !important;} .w455{width:455px !important;}
.w465{width:465px !important;} .w465{width:465px !important;}
.w490{width:490px;}
.w520{ width:520px;} .w520{ width:520px;}
.w543{ width:543px;} .w543{ width:543px;}
.w557{ width:557px;} .w557{ width:557px;}