diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index cf4e6a8e9..b878a14ac 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -251,7 +251,7 @@ class AttachmentsController < ApplicationController
@history.version = @old_history.nil? ? 1 : @old_history.version + 1
@history.save #历史记录保存完毕
#将最新保存的记录 数据替换到 需要修改的文件记录
- @old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads")
+ @old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes")
@old_attachment.save
#删除当前记录
@attachment.delete
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index be96124c2..708ac9a14 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -1067,7 +1067,7 @@ class CoursesController < ApplicationController
sql_select = ""
if groupid == 0
sql_select = "SELECT members.*,(
- SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))
+ SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
@@ -1079,7 +1079,7 @@ class CoursesController < ApplicationController
WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}"
else
sql_select = "SELECT members.*,(
- SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))
+ SELECT SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 57cadc10b..b288629c8 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -559,7 +559,8 @@ class FilesController < ApplicationController
end
end
# 更新课程英雄榜得分
- update_contributor_score(@course, attachments[:files].first)
+ course_member_score(@course.id, attachments[:files].first.author_id, "Attachment")
+ # end
# end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'
@@ -632,18 +633,6 @@ class FilesController < ApplicationController
end
end
- def update_contributor_score(course, file )
- course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course.id, file.author.id).first
- if course_contributor_score.nil?
- CourseContributorScore.create(:course_id => course.id, :user_id => file.author.id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 0, :resource_num => 5, :journal_num => 0, :journal_reply_num => 0, :total_score => 5)
- else
- score = course_contributor_score.resource_num + 5
- total_score = course_contributor_score.total_score + 5
- course_contributor_score.update_attributes(:resource_num => score, :total_score => total_score)
- end
- end
-
def get_project_tag_name_by_type_nmuber type
case type
when "1"
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 00b11323b..9f754a0fc 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -1,378 +1,378 @@
-class HomeworkCommonController < ApplicationController
- require 'net/http'
- require 'json'
- require "base64"
- layout "base_courses"
-
- include StudentWorkHelper
- 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,: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,:alert_open_student_works,:open_student_works]
- before_filter :member_of_course, :only => [:index]
-
- def index
- @new_homework = HomeworkCommon.new
- @new_homework.homework_detail_manual = HomeworkDetailManual.new
- @new_homework.course = @course
- @page = params[:page] ? params[:page].to_i + 1 : 0
- @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
- if @is_teacher
- @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
- else
- @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
- end
- @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
- @is_new = params[:is_new]
-
- #设置at已读
- @homeworks.each do |homework|
- homework.journals_for_messages.each do |j|
- User.current.at_messages.unviewed('JournalsForMessage', j.id).each {|x| x.viewed!}
- end
- end
-
- respond_to do |format|
- format.js
- format.html
- end
- end
-
- #新建作业,在个人作业列表创建作业
- def new
- render_404
- end
-
- #新建作业,在个人作业列表创建作业
- def create
- redirect_to user_homeworks_user_path(User.current.id)
- end
-
- def edit
- @user = User.current
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.html{render :layout => 'new_base_user'}
- end
- end
-
- def update
- if params[:homework_common]
- @homework.name = params[:homework_common][:name]
- @homework.description = params[:homework_common][:description]
- if params[:homework_common][:publish_time] == ""
- @homework.publish_time = Date.today
- else
- @homework.publish_time = params[:homework_common][:publish_time]
- end
- @homework.end_time = params[:homework_common][:end_time] || Time.now
- @homework.course_id = params[:course_id]
- @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
-
- homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
- if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
- homework_detail_manual.comment_status = 1
- end
- homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start]
- homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
-
- @homework.save_attachments(params[:attachments])
- render_attachment_warning_if_needed(@homework)
-
- #编程作业相关属性
- if @homework.homework_type == 2
- @homework.homework_detail_programing ||= HomeworkDetailPrograming.new
- @homework_detail_programing = @homework.homework_detail_programing
- @homework_detail_programing.language = params[:language_type].to_i
-
- @homework.homework_tests.delete_all
- inputs = params[:program][:input]
- if Array === inputs
- inputs.each_with_index do |val, i|
- @homework.homework_tests << HomeworkTest.new(
- input: val,
- output: params[:program][:output][i]
- )
- end
- end
- end
-
- #分组作业
- if @homework.homework_type == 3
- @homework.homework_detail_group ||= HomeworkDetailGroup.new
- @homework_detail_group = @homework.homework_detail_group
- @homework_detail_group.min_num = params[:min_num].to_i
- @homework_detail_group.max_num = params[:max_num].to_i
- @homework_detail_group.base_on_project = params[:base_on_project].to_i
- end
-
- if @homework.save
- @homework_detail_manual.save if @homework_detail_manual
- @homework_detail_programing.save if @homework_detail_programing
- @homework_detail_group.save if @homework_detail_group
-
- if params[:is_in_course] == "1"
- redirect_to homework_common_index_path(:course => @course.id)
- elsif params[:is_in_course] == "0"
- redirect_to user_homeworks_user_path(User.current.id)
- elsif params[:is_in_course] == "-1" && params[:course_activity] == "0"
- redirect_to user_path(User.current.id)
- elsif params[:is_in_course] == "-1" && params[:course_activity] == "1"
- redirect_to course_path(@course.id)
- end
- end
- end
- end
-
- def destroy
- if @homework.destroy
- respond_to do |format|
- format.html {
- if params[:is_in_course] == "1"
- redirect_to homework_common_index_path(:course => @course.id)
- elsif params[:is_in_course] == "0"
- redirect_to user_homeworks_user_path(User.current.id)
- elsif params[:is_in_course] == "-1" && params[:course_activity] == "0"
- redirect_to user_path(User.current.id)
- elsif params[:is_in_course] == "-1" && params[:course_activity] == "1"
- redirect_to course_path(@course.id)
- end
- }
- end
- end
- end
-
- #开启匿评
- #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
- def start_anonymous_comment
- @statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
- @statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
- if @homework_detail_manual.comment_status == 1
- student_works = @homework.student_works
- if student_works && student_works.size >= 2
- if @homework.homework_type == 3
- student_work_projects = @homework.student_work_projects.where("student_work_id is not null")
- student_work_projects.each_with_index do |pro_work, pro_index|
- n = @homework_detail_manual.evaluation_num
- n = n < student_works.size ? n : student_works.size - 1
- work_index = -1
- student_works.each_with_index do |stu_work, stu_index|
- if stu_work.id.to_i == pro_work.student_work_id.to_i
- work_index = stu_index
- end
- end
- assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
- assigned_homeworks.each do |h|
- student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
- student_works_evaluation_distributions.save
- end
- end
- else
- student_works.each_with_index do |work, index|
- user = work.user
- n = @homework_detail_manual.evaluation_num
- n = n < student_works.size ? n : student_works.size - 1
- assigned_homeworks = get_assigned_homeworks(student_works, n, index)
- assigned_homeworks.each do |h|
- student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
- student_works_evaluation_distributions.save
- end
- end
- end
- @homework_detail_manual.update_column('comment_status', 2)
- @homework_detail_manual.update_column('evaluation_start', Date.today)
- @statue = 1
- # 匿评开启消息邮件通知
- send_message_anonymous_comment(@homework, m_status = 2)
- Mailer.send_mail_anonymous_comment_open(@homework).deliver
- else
- @statue = 2
-
- end
- else
- @statue = 3
- end
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- end
-
- #关闭匿评
- def stop_anonymous_comment
- @homework_detail_manual.update_column('comment_status', 3)
- @homework_detail_manual.update_column('evaluation_end', Date.today)
- #计算缺评扣分
- work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
- @homework.student_works.each do |student_work|
- absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
- student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
- student_work.save
- end
- # 匿评关闭消息邮件通知
- send_message_anonymous_comment(@homework, m_status = 3)
- Mailer.send_mail_anonymous_comment_close(@homework).deliver
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.js
- end
- end
-
- # 开启/关闭匿评消息通知
- def send_message_anonymous_comment(homework, m_status )
- # status 标记匿评状态 1为关闭 0为开启
- course = homework.course
- course.members.each do |m|
- @homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => m_status)
- end
- end
- #提示
- def alert_anonymous_comment
- @cur_size = 0
- @totle_size = 0
- if @homework_detail_manual.comment_status == 1
- @totle_size = @course.student.count
- @cur_size = @homework.student_works.size
- elsif @homework_detail_manual.comment_status == 2
- @homework.student_works.map { |work| @totle_size += work.student_works_evaluation_distributions.count}
- @cur_size = 0
- @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count}
- end
- @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.js
- end
- end
-
- def alert_forbidden_anonymous_comment
- 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 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
- test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
- @index = params[:index]
- uri = URI('http://192.168.80.21:8080/api/realtime.json')
- body = test.to_json
- 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
- result = JSON.parse(res.body)
- @err_msg = result["compile_error_msg"]
- result["results"].each do |re|
- @result = re["status"]
- end
- end
-
- #启动匿评参数设置
- def start_evaluation_set
- 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]
- @course_activity = params[:course_activity].to_i
- end
-
- #设置匿评参数
- def set_evaluation_attr
- if @homework_detail_manual
- unless params[:evaluation_start].to_s == @homework_detail_manual.evaluation_start.to_s
- @homework_detail_manual.evaluation_start = params[:evaluation_start]
- end
-
- unless @homework_detail_manual.evaluation_end.to_s == params[:evaluation_end].to_s
- @homework_detail_manual.evaluation_end = params[:evaluation_end]
- end
-
- @homework_detail_manual.evaluation_num = params[:evaluation_num]
- @homework_detail_manual.save
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- end
- end
-
- #评分设置
- def score_rule_set
- 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]
- @course_activity = params[:course_activity].to_i
- end
-
- private
- #获取课程
- def find_course
- @course = Course.find params[:course]
- rescue
- render_404
- end
- #获取作业
- def find_homework
- @homework = HomeworkCommon.find params[:id]
- @homework_detail_manual = @homework.homework_detail_manual
- @homework_detail_programing = @homework.homework_detail_programing
- @homework_detail_group = @homework.homework_detail_group
- @course = @homework.course
- rescue
- render_404
- end
- #是不是课程的老师
- def teacher_of_course
- render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
- end
-
- #当前用户是不是课程的成员
- def member_of_course
- render_403 unless @course.is_public==1 || User.current.member_of_course?(@course) || User.current.admin?
- end
-
- def get_assigned_homeworks(student_works, n, index)
- student_works += student_works
- student_works[index + 1 .. index + n]
- end
-end
+class HomeworkCommonController < ApplicationController
+ require 'net/http'
+ require 'json'
+ require "base64"
+ layout "base_courses"
+
+ include StudentWorkHelper
+ 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,: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,:alert_open_student_works,:open_student_works]
+ before_filter :member_of_course, :only => [:index]
+
+ def index
+ @new_homework = HomeworkCommon.new
+ @new_homework.homework_detail_manual = HomeworkDetailManual.new
+ @new_homework.course = @course
+ @page = params[:page] ? params[:page].to_i + 1 : 0
+ @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
+ if @is_teacher
+ @homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10)
+ else
+ @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10)
+ end
+ @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
+ @is_new = params[:is_new]
+
+ #设置at已读
+ @homeworks.each do |homework|
+ homework.journals_for_messages.each do |j|
+ User.current.at_messages.unviewed('JournalsForMessage', j.id).each {|x| x.viewed!}
+ end
+ end
+
+ respond_to do |format|
+ format.js
+ format.html
+ end
+ end
+
+ #新建作业,在个人作业列表创建作业
+ def new
+ render_404
+ end
+
+ #新建作业,在个人作业列表创建作业
+ def create
+ redirect_to user_homeworks_user_path(User.current.id)
+ end
+
+ def edit
+ @user = User.current
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ respond_to do |format|
+ format.html{render :layout => 'new_base_user'}
+ end
+ end
+
+ def update
+ if params[:homework_common]
+ @homework.name = params[:homework_common][:name]
+ @homework.description = params[:homework_common][:description]
+ if params[:homework_common][:publish_time] == ""
+ @homework.publish_time = Date.today
+ else
+ @homework.publish_time = params[:homework_common][:publish_time]
+ end
+ @homework.end_time = params[:homework_common][:end_time] || Time.now
+ @homework.course_id = params[:course_id]
+ @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0
+
+ homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new
+ if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
+ homework_detail_manual.comment_status = 1
+ end
+ homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start]
+ homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
+
+ @homework.save_attachments(params[:attachments])
+ render_attachment_warning_if_needed(@homework)
+
+ #编程作业相关属性
+ if @homework.homework_type == 2
+ @homework.homework_detail_programing ||= HomeworkDetailPrograming.new
+ @homework_detail_programing = @homework.homework_detail_programing
+ @homework_detail_programing.language = params[:language_type].to_i
+
+ @homework.homework_tests.delete_all
+ inputs = params[:program][:input]
+ if Array === inputs
+ inputs.each_with_index do |val, i|
+ @homework.homework_tests << HomeworkTest.new(
+ input: val,
+ output: params[:program][:output][i]
+ )
+ end
+ end
+ end
+
+ #分组作业
+ if @homework.homework_type == 3
+ @homework.homework_detail_group ||= HomeworkDetailGroup.new
+ @homework_detail_group = @homework.homework_detail_group
+ @homework_detail_group.min_num = params[:min_num].to_i
+ @homework_detail_group.max_num = params[:max_num].to_i
+ @homework_detail_group.base_on_project = params[:base_on_project].to_i
+ end
+
+ if @homework.save
+ @homework_detail_manual.save if @homework_detail_manual
+ @homework_detail_programing.save if @homework_detail_programing
+ @homework_detail_group.save if @homework_detail_group
+
+ if params[:is_in_course] == "1"
+ redirect_to homework_common_index_path(:course => @course.id)
+ elsif params[:is_in_course] == "0"
+ redirect_to user_homeworks_user_path(User.current.id)
+ elsif params[:is_in_course] == "-1" && params[:course_activity] == "0"
+ redirect_to user_path(User.current.id)
+ elsif params[:is_in_course] == "-1" && params[:course_activity] == "1"
+ redirect_to course_path(@course.id)
+ end
+ end
+ end
+ end
+
+ def destroy
+ if @homework.destroy
+ respond_to do |format|
+ format.html {
+ if params[:is_in_course] == "1"
+ redirect_to homework_common_index_path(:course => @course.id)
+ elsif params[:is_in_course] == "0"
+ redirect_to user_homeworks_user_path(User.current.id)
+ elsif params[:is_in_course] == "-1" && params[:course_activity] == "0"
+ redirect_to user_path(User.current.id)
+ elsif params[:is_in_course] == "-1" && params[:course_activity] == "1"
+ redirect_to course_path(@course.id)
+ end
+ }
+ end
+ end
+ end
+
+ #开启匿评
+ #statue 1:启动成功,2:启动失败,作业总数大于等于2份时才能启动匿评,3:已开启匿评,请务重复开启,4:没有开启匿评的权限
+ def start_anonymous_comment
+ @statue = 4 and return unless User.current.admin? || User.current.allowed_to?(:as_teacher,@course)
+ @statue = 5 and return if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
+ if @homework_detail_manual.comment_status == 1
+ student_works = @homework.student_works
+ if student_works && student_works.size >= 2
+ if @homework.homework_type == 3
+ student_work_projects = @homework.student_work_projects.where("student_work_id is not null")
+ student_work_projects.each_with_index do |pro_work, pro_index|
+ n = @homework_detail_manual.evaluation_num
+ n = n < student_works.size ? n : student_works.size - 1
+ work_index = -1
+ student_works.each_with_index do |stu_work, stu_index|
+ if stu_work.id.to_i == pro_work.student_work_id.to_i
+ work_index = stu_index
+ end
+ end
+ assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
+ assigned_homeworks.each do |h|
+ student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
+ student_works_evaluation_distributions.save
+ end
+ end
+ else
+ student_works.each_with_index do |work, index|
+ user = work.user
+ n = @homework_detail_manual.evaluation_num
+ n = n < student_works.size ? n : student_works.size - 1
+ assigned_homeworks = get_assigned_homeworks(student_works, n, index)
+ assigned_homeworks.each do |h|
+ student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
+ student_works_evaluation_distributions.save
+ end
+ end
+ end
+ @homework_detail_manual.update_column('comment_status', 2)
+ @homework_detail_manual.update_column('evaluation_start', Date.today)
+ @statue = 1
+ # 匿评开启消息邮件通知
+ send_message_anonymous_comment(@homework, m_status = 2)
+ Mailer.send_mail_anonymous_comment_open(@homework).deliver
+ else
+ @statue = 2
+
+ end
+ else
+ @statue = 3
+ end
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ end
+
+ #关闭匿评
+ def stop_anonymous_comment
+ @homework_detail_manual.update_column('comment_status', 3)
+ @homework_detail_manual.update_column('evaluation_end', Date.today)
+ #计算缺评扣分
+ work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
+ @homework.student_works.each do |student_work|
+ absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
+ student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
+ student_work.save
+ end
+ # 匿评关闭消息邮件通知
+ send_message_anonymous_comment(@homework, m_status = 3)
+ Mailer.send_mail_anonymous_comment_close(@homework).deliver
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ # 开启/关闭匿评消息通知
+ def send_message_anonymous_comment(homework, m_status )
+ # status 标记匿评状态 1为关闭 0为开启
+ course = homework.course
+ course.members.each do |m|
+ @homework.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => m_status)
+ end
+ end
+ #提示
+ def alert_anonymous_comment
+ @cur_size = 0
+ @totle_size = 0
+ if @homework_detail_manual.comment_status == 1
+ @totle_size = @course.student.count
+ @cur_size = @homework.student_works.size
+ elsif @homework_detail_manual.comment_status == 2
+ @homework.student_works.map { |work| @totle_size += work.student_works_evaluation_distributions.count}
+ @cur_size = 0
+ @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count}
+ end
+ @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100)
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def alert_forbidden_anonymous_comment
+ 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 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
+ test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
+ @index = params[:index]
+ uri = URI('http://192.168.80.21:8080/api/realtime.json')
+ body = test.to_json
+ 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
+ result = JSON.parse(res.body)
+ @err_msg = result["compile_error_msg"]
+ result["results"].each do |re|
+ @result = re["status"]
+ end
+ end
+
+ #启动匿评参数设置
+ def start_evaluation_set
+ 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]
+ @course_activity = params[:course_activity].to_i
+ end
+
+ #设置匿评参数
+ def set_evaluation_attr
+ if @homework_detail_manual
+ unless params[:evaluation_start].to_s == @homework_detail_manual.evaluation_start.to_s
+ @homework_detail_manual.evaluation_start = params[:evaluation_start]
+ end
+
+ unless @homework_detail_manual.evaluation_end.to_s == params[:evaluation_end].to_s
+ @homework_detail_manual.evaluation_end = params[:evaluation_end]
+ end
+
+ @homework_detail_manual.evaluation_num = params[:evaluation_num]
+ @homework_detail_manual.save
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ end
+ end
+
+ #评分设置
+ def score_rule_set
+ 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]
+ @course_activity = params[:course_activity].to_i
+ end
+
+ private
+ #获取课程
+ def find_course
+ @course = Course.find params[:course]
+ rescue
+ render_404
+ end
+ #获取作业
+ def find_homework
+ @homework = HomeworkCommon.find params[:id]
+ @homework_detail_manual = @homework.homework_detail_manual
+ @homework_detail_programing = @homework.homework_detail_programing
+ @homework_detail_group = @homework.homework_detail_group
+ @course = @homework.course
+ rescue
+ render_404
+ end
+ #是不是课程的老师
+ def teacher_of_course
+ render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
+ end
+
+ #当前用户是不是课程的成员
+ def member_of_course
+ render_403 unless @course.is_public==1 || User.current.member_of_course?(@course) || User.current.admin?
+ end
+
+ def get_assigned_homeworks(student_works, n, index)
+ student_works += student_works
+ student_works[index + 1 .. index + n]
+ end
+end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index b650afe1b..3d5030c29 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -406,6 +406,7 @@ class ProjectsController < ApplicationController
end
flash.now[:error] = html if !html.to_s.blank?
end
+ # for:设置默认分支
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index f7845d6f1..9bb6055ee 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -140,7 +140,7 @@ class RepositoriesController < ApplicationController
attrs = {:parent_id => project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_url(attrs, :course => '0')
else
- redirect_to settings_project_url(project)
+ redirect_to project_path(project)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => project.id) }
@@ -431,7 +431,10 @@ update
def entry
entry_and_raw(false)
- render :layout => 'base_projects'
+ @content = @repository.cat(@path, @rev)
+ if is_entry_text_data?(@content, @path)
+ render :layout => 'base_projects'
+ end
end
def entry_and_raw(is_raw)
@@ -443,9 +446,7 @@ update
@content = @repository.cat(@path, @rev)
(show_error_not_found; return) unless @content
- if is_raw ||
- (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
- ! is_entry_text_data?(@content, @path)
+ if is_raw || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || !is_entry_text_data?(@content, @path)
# Force the download
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
send_type = Redmine::MimeType.of(@path)
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index a38d83851..f9208b39f 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -1,1081 +1,1094 @@
-class StudentWorkController < ApplicationController
- layout "base_courses"
- include StudentWorkHelper
- 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,: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 :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
- 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 :is_logged, :only => [:index]
-
- ###
- def program_test
- 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)
-
- unless student_work
- resultObj[:status] = 100
- else
- if @homework.homework_type == 2 && @homework.homework_detail_programing
- result = test_realtime(student_work, params[:src])
- logger.debug result
- resultObj[:status] = result["status"]
- resultObj[:results] = result["results"]
- resultObj[:error_msg] = result["error_msg"]
- results = result["results"]
- if result["status"].to_i == -2 #编译错误
- results = [result["error_msg"]]
- end
- student_work_test = student_work.student_work_tests.build(status: result["status"], results: results,
- src: params[:src])
- unless student_work.save
- resultObj[:status] = 200
- else
- resultObj[:status] = result["status"].to_i
- resultObj[:time] = student_work_test.created_at.to_s(:db)
- resultObj[:index] = student_work.student_work_tests.count
- end
-
- end
- end
-
- render :json => resultObj
- end
-
- def index
- # 作业消息状态更新
- @homework.course_messages.each do |homework_message|
- if User.current.id == homework_message.user_id && homework_message.viewed == 0
- homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0
- end
- end
- # 作品打分消息状态更新
- studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0)
- studentworks_scores.each do |studentworks_score|
- studentworks_score.update_attributes(:viewed => true) if studentworks_score.viewed == 0
- end
- # 作品评论消息状态更新
- journals_for_teacher = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "JournalsForMessage", 0)
- journals_for_teacher.each do |journal_for_teacher|
- journal_for_teacher.update_attributes(:viewed => true)
- end
- #不能参与作业匿评消息状态更新
- no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =? and status =?", User.current.id, @homework.course, "StudentWork", 0, 0)
- no_evaluation.update_all(:viewed => true)
- # 作品留言
- # 消息end
- #设置作业对应的forge_messages表的viewed字段
- query_student_work = @homework.course_messages
- query_student_work.each do |query|
- if User.current.id == query.user_id
- query.update_attributes(:viewed => true)
- end
- end
- ##################################################################################################################
- @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
- @homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
- @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
- @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
- @show_all = false
-
- course_group = CourseGroup.find_by_id(@group) if @group
- if course_group
- group_students = course_group.users
- if group_students.empty?
- student_in_group = '(0)'
- else
- student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
- end
- #老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
- 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").joins(:user).where("users.id in #{student_in_group}").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").joins(:user).where("users.id in #{student_in_group}").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").joins(:user).where("users.id in #{student_in_group}").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").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
- end
-
- @score = @b_sort == "desc" ? "asc" : "desc"
-
- respond_to do |format|
- format.js
- format.html
- format.xls {
- filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls"
- send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
- :filename => filename_for_content_disposition(filename))
- }
- end
- end
-
- def new
- #更新消息
- noEvaluation = @homework.course_messages.where("user_id =? and viewed =?", User.current.id, 0)
- noEvaluation.update_all(:viewed => true)
-
- if @homework.homework_type==2
- redirect_to new_user_commit_homework_users_path(homework_id: @homework.id)
- return
- end
- @user = User.current
- @student_work = @homework.student_works.where("user_id = ?",User.current.id).first
- if @student_work.nil?
- @student_work = StudentWork.new
- end
- respond_to do |format|
- format.html{ render :layout => "new_base_user"}
- end
- end
-
- def create
- # 提交作品前先判断是否已经提交
- @has_commit = false;
- if hsd_committed_work?(User.current.id, @homework.id)
- @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
- @has_commit = true;
- #flash[:notice] = l(:notice_successful_create)
- #redirect_to edit_student_work_url(params[:student_work])
- respond_to do |format|
- format.js
- end
- return
- end
- if params[:student_work]
- @submit_result = true
- student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
- student_work ||= StudentWork.new
- student_work.name = params[:student_work][:name]
- student_work.description = params[:student_work][:description]
- student_work.homework_common_id = @homework.id
- student_work.user_id = User.current.id
- student_work.save_attachments(params[:attachments])
- render_attachment_warning_if_needed(student_work)
- if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
- @student_work_project = @homework.student_work_projects.where("user_id = #{User.current.id}").first
- student_work.project_id = @student_work_project.project_id
- end
- #提交作品时,计算是否迟交
- 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
- if student_work.save
- if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
- @student_work_project.student_work_id = student_work.id
- @student_work_project.save
- members = params[:group_member_ids].split(',')
- for i in 1 .. members.count-1
- stu_project = StudentWorkProject.new
- stu_project.homework_common_id = @homework.id
- stu_project.student_work_id = student_work.id
- stu_project.project_id = @student_work_project.project_id
- stu_project.user_id = members[i].to_i
- stu_project.is_leader = 0
- stu_project.save
- end
- elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
- members = params[:group_member_ids].split(',')
- for i in 0 .. members.count-1
- stu_project = StudentWorkProject.new
- stu_project.homework_common_id = @homework.id
- stu_project.student_work_id = student_work.id
- stu_project.project_id = -1
- stu_project.user_id = members[i].to_i
- if i == 0
- stu_project.is_leader = 1
- else
- stu_project.is_leader = 0
- end
- stu_project.save
- end
- end
- update_course_activity(@homework.class,@homework.id)
- update_user_activity(@homework.class,@homework.id)
- update_org_activity(@homework.class,@homework.id)
-
- course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"new",:course_message_id=>student_work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录
- course_message.save
-
- @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
- respond_to do |format|
- format.js
- end
- return
- end
- end
- @submit_result = false
- respond_to do |format|
- format.js
- end
- end
-
- def edit
- @user = User.current
- if (!User.current.admin? && @homework.homework_type == 2) || Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业
- render_403
- else
- respond_to do |format|
- format.html{ render :layout => "new_base_user"}
- end
- end
- end
-
- def update
- if params[:student_work]
- @submit_result = true
- @work.name = params[:student_work][:name]
- @work.description = params[:student_work][:description]
- @work.save_attachments(params[:attachments])
- render_attachment_warning_if_needed(@work)
- if @work.save
- if @homework.homework_type == 3
- @student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first
- student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0)
- student_work_projects.delete_all
- members = params[:group_member_ids].split(',')
- for i in 1 .. members.count-1
- stu_project = StudentWorkProject.new
- stu_project.homework_common_id = @homework.id
- stu_project.student_work_id = @work.id
- 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
- end
- stu_project.user_id = members[i].to_i
- stu_project.is_leader = 0
- stu_project.save
- end
- end
-
- course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"edit",:course_message_id=>@work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录
- course_message.save
- @student_work = @work
- respond_to do |format|
- format.js
- end
- return
- end
- end
-=begin
- respond_to do |format|
- format.html{redirect_to edit_student_work_url(@work)}
- end
-=end
- @submit_result = false
- respond_to do |format|
- format.js
- end
- end
-
- def show
- @score = student_work_score @work,User.current
- @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
- @student_work_scores = @work.student_works_scores.order("updated_at desc")
- respond_to do |format|
- format.js
- end
- end
-
- def destroy
- if @work.destroy
- if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
- pros = @work.student_work_projects.where("is_leader = 0")
- pros.each do |pro|
- pro.destroy
- end
- project = @work.student_work_projects.where("is_leader = 1").first
- project.update_attributes(:student_work_id => nil)
- elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
- @work.student_work_projects.each do |pro2|
- pro2.destroy
- end
- end
- respond_to do |format|
- format.html {
- redirect_to student_work_index_url(:homework => @homework.id)
- }
- end
- end
- end
-
- def delete_work
- @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
- if @work
- @work.destroy
- if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
- pros = @work.student_work_projects.where("is_leader = 0")
- pros.each do |pro|
- pro.destroy
- end
- project = @work.student_work_projects.where("is_leader = 1").first
- project.update_attributes(:student_work_id => nil)
- elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
- @work.student_work_projects.each do |pro2|
- pro2.destroy
- end
- end
- end
- redirect_to user_homeworks_user_path(User.current.id)
- end
-
- def retry_work
- if @work.destroy
- if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
- pros = @work.student_work_projects.where("is_leader = 0")
- pros.each do |pro|
- pro.destroy
- end
- project = @work.student_work_projects.where("is_leader = 1").first
- project.update_attributes(:student_work_id => nil)
- elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
- @work.student_work_projects.each do |pro2|
- pro2.destroy
- end
- end
- @student_work = StudentWork.new
- respond_to do |format|
- format.js
- end
- end
- end
-
- #添加评分,已评分则为修改评分
- def add_score
- @is_last = params[:is_last] == "true"
- render_403 and return if User.current == @work.user #不可以匿评自己的作品
- @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
- #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
- render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
- @score = student_work_score @work,User.current
- if @score
- @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
- @score.score = params[:score] if params[:score]
- if User.current.admin?
- @score.reviewer_role = 1
- else
- role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
- @score.reviewer_role = get_role_by_name(role)
- end
- @is_new = false
- else
- @is_last_a = @work.student_works_scores.empty?
- @score = StudentWorksScore.new
- @score.score = params[:score] if params[:score]
- @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
- @score.user_id = User.current.id
- @score.student_work_id = @work.id
- if User.current.admin?
- @score.reviewer_role = 1
- else
- role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
- @score.reviewer_role = get_role_by_name(role)
- end
- @is_new = true
- end
-
- @score.save_attachments(params[:attachments])
- render_attachment_warning_if_needed(@score)
-
- if @score.save
- case @score.reviewer_role
- when 1 #教师评分:最后一个教师评分为最终评分
- @work.teacher_score = @score.score
- when 2 #教辅评分 教辅评分显示平均分
- @work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
- when 3 #学生评分 学生评分显示平均分
- @work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
- end
- if @work.save
- respond_to do |format|
- format.js
- end
- end
- end
- end
-
- #添加评分的回复
- def add_score_reply
- @score = StudentWorksScore.find params[:score_id]
- @is_last = params[:is_last] == "true"
- @jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0)
- if @jour.save
- @status = 1
- else
- @status = 2
- end
- respond_to do |format|
- format.js
- end
- end
-
- #删除评分的回复
- def destroy_score_reply
- @jour = JournalsForMessage.find params[:jour_id]
- if @jour.destroy
- respond_to do |format|
- format.js
- end
- end
- end
-
- #为作品点赞
- def praise_student_work
- pt = PraiseTread.new
- pt.user_id = User.current.id
- pt.praise_tread_object_id = @work.id
- pt.praise_tread_object_type = "StudentWork"
- pt.praise_or_tread = 1
- if pt.save
- respond_to do |format|
- format.js
- end
- else
- render_404
- end
- end
-
- #缺评列表显示
- def student_work_absence_penalty
- order = params[:order] || "desc"
- if @homework.student_works.empty?
- @stundet_works = []
- else
- work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
- @stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM(
- SELECT * ,
- (SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count,
- (SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
- FROM `student_works`
- WHERE homework_common_id = #{@homework.id}
- ) AS table_1
- ORDER BY absence #{order}")
- end
- @order = order == "desc" ? "asc" : "desc"
- respond_to do |format|
- format.html
- end
- end
-
- #导出缺评列表
- def absence_penalty_list
- if @homework.student_works.empty?
- @stundet_works = []
- else
- work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
- @stundet_works = StudentWork.find_by_sql("SELECT * FROM (SELECT *,(all_count - has_count) AS absence FROM(
- SELECT * ,
- (SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count,
- (SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
- FROM `student_works`
- WHERE homework_common_id = #{@homework.id}
- ) AS table_1) AS table_2
- where absence > 0 order by absence")
- end
- respond_to do |format|
- format.xls {
- filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_absence_list)}.xls"
- send_data(absence_penalty_list_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
- :filename => filename_for_content_disposition(filename))
- }
- end
- end
-
- #导出匿评列表
- def evaluation_list
- respond_to do |format|
- format.xls {
- filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_evaluation_list)}.xls"
- send_data(evaluation_list_xls(@homework.student_works), :type => "text/excel;charset=utf-8; header=present",
- :filename => filename_for_content_disposition(filename))
- }
- end
- end
-
- #设置评分规则
- def set_score_rule
- homework_detail_manual = @homework.homework_detail_manual
- homework_detail_programing = @homework.homework_detail_programing
-
- unless @homework.late_penalty.to_s == params[:late_penalty].to_s
- @homework.late_penalty = params[:late_penalty]
- @homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work|
- student_work.late_penalty = @homework.late_penalty
- student_work.save
- end
-
- @homework.save
- end
-
- unless homework_detail_manual.absence_penalty.to_s == params[:absence_penalty].to_s
- homework_detail_manual.absence_penalty = params[:absence_penalty]
- if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值
- work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
- @homework.student_works.each do |student_work|
- absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
- student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
- student_work.save
- end
- end
-
- homework_detail_manual.save if homework_detail_manual
- end
-
- teacher_priority = params[:teacher_priority] ? 1 : 0
- 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.save
- homework_detail_manual.save if homework_detail_manual
- homework_detail_programing.save if homework_detail_programing
-
- @homework.student_works.each do |student_work|
- set_final_score @homework,student_work
- student_work.save
- end
- end
- if params[:student_path]
- redirect_to student_work_index_url(:homework => @homework.id)
- else
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.js
- end
- end
- end
-
- def forbidden_anonymous_comment
- @homework.update_column('anonymous_comment', 1)
- homework_detail_manual = @homework.homework_detail_manual
- homework_detail_programing = @homework.homework_detail_programing
- if homework_detail_programing
- homework_detail_manual.update_column('ta_proportion', 0.4)
- homework_detail_programing.update_column('ta_proportion', 0.6)
- else
- homework_detail_manual.update_column('ta_proportion', 1.0)
- end
- @homework.student_works.each do |student_work|
- set_final_score @homework,student_work
- student_work.save
- end
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- end
-
- def revise_attachment
- Attachment.attach_filesex(@work, params[:attachments], params[:attachment_type])
- revise_attachments = @work.attachments.where("attachtype = 7").reorder("created_on desc")
- if revise_attachments.count == 2
- revise_attachments.last.destroy
- end
- attachment = @work.attachments.where("attachtype = 7").first
- attachment.update_attributes(:description => params[:description])
- respond_to do |format|
- format.js
- end
- end
-
- def new_student_work_project
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.js
- end
- end
-
- #创建作业的关联项目
- def student_work_project
- @project = StudentWorkProject.new
- @project.homework_common_id = @homework.id
- @project.project_id = (Project.find params[:projectName].to_i).id
- @project.user_id = User.current.id
- @project.is_leader = 1
- if @project.save
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.js
- end
- end
-
- end
-
- #查找学生创建的项目列表
- def search_user_projects
- condition = '%%'
- if !params[:name].nil?
- condition = "%#{params[:name].strip}%".gsub(" ","")
- end
- @project_ids = Project.visible.where("user_id = #{User.current.id} and name like '#{condition}'")
- @first = params[:first].to_i
- respond_to do |format|
- format.js
- end
- end
-
- #查找课程的学生
- def search_course_students
- name = ""
- unless params[:name].nil?
- name = params[:name]
- end
- if @homework.homework_detail_group.base_on_project == 0
- all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")"
- else
- pro = Project.find @homework.student_work_projects.where("user_id=?",User.current.id).first.project_id
- all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")"
- end
- all_students = User.where("id in #{all_student_ids}")
- @commit_student_ids = @homework.student_work_projects.map{|student| student.user_id}
- @users = searchstudent_by_name all_students,name
- respond_to do |format|
- format.js
- end
- end
-
- def cancel_relate_project
- relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first
- if relate_pro.destroy
- @user_activity_id = params[:user_activity_id].to_i
- @is_in_course = params[:is_in_course].to_i
- @course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.js
- end
- end
- end
-
- private
- def searchstudent_by_name users, name
- mems = []
- if name != ""
- name = name.to_s.downcase
- users.each do |m|
- username = m.lastname.to_s.downcase + m.firstname.to_s.downcase
- if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
- mems << m
- end
- end
- else
- mems = users
- end
- mems
- end
-
- def hsd_committed_work?(user, homework)
- sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first
- sw.nil? ? result = false : result = true
- result
- end
-
- #获取作业
- def find_homework
- @homework = HomeworkCommon.find params[:homework]
- @course = @homework.course
- rescue
- render_404
- end
- #获取作品
- def find_work
- @work = StudentWork.find params[:id]
- @homework = @work.homework_common
- @course = @homework.course
- rescue
- render_404
- end
-
- #是不是当前课程的成员
- #当前课程成员才可以看到作品列表
- def member_of_course
- render_403 unless User.current.member_of_course?(@course) || User.current.admin?
- end
-
- #判断是不是当前作品的提交者
- #提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
- def author_of_work
- render_403 unless User.current.admin? || (User.current.id == @work.user_id && @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
- end
-
- def teacher_of_course
- render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
- end
-
- def is_logged
- redirect_to signin_path unless User.current.logged?
- end
-
- #根据条件过滤作业结果
- def search_homework_member homeworks,name
- if name == ""
- select_homework = homeworks
- else
- name = name.downcase
- select_homework = homeworks.select{ |homework|
- homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name)
- }
- end
- select_homework
- end
-
- #作品列表转换为excel
- def homework_to_xls items
- xls_report = StringIO.new
- book = Spreadsheet::Workbook.new
- sheet1 = book.create_worksheet :name => "homework"
- blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
- sheet1.row(0).default_format = blue
- if @homework.homework_type == 1 #匿评作业
- sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
- l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
- count_row = 1
- items.each do |homework|
- sheet1[count_row,0]=homework.user.id
- sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
- sheet1[count_row,2] = homework.user.login
- sheet1[count_row,3] = homework.user.user_extensions.student_id
- sheet1[count_row,4] = homework.user.mail
- sheet1[count_row,5] = homework.name
- sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
- sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
- sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
- sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
- sheet1[count_row,10] = format_time(homework.created_at)
- count_row += 1
- end
- elsif @homework.homework_type == 2 #编程作业
- sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
- l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
- count_row = 1
- items.each do |homework|
- sheet1[count_row,0]=homework.user.id
- sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
- sheet1[count_row,2] = homework.user.login
- sheet1[count_row,3] = homework.user.user_extensions.student_id
- sheet1[count_row,4] = homework.user.mail
- sheet1[count_row,5] = homework.name
- sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
- sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
- sheet1[count_row,8] = homework.system_score.nil? ? l(:label_without_score) : format("%.2f",homework.system_score)
- sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
- sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
- sheet1[count_row,11] = format_time(homework.created_at)
- count_row += 1
- end
- end
- book.write xls_report
- xls_report.string
- end
-
- #缺评列表转换为excel
- def absence_penalty_list_xls items
- xls_report = StringIO.new
- book = Spreadsheet::Workbook.new
- sheet1 = book.create_worksheet :name => "homework"
- blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
- sheet1.row(0).default_format = blue
-
- sheet1.row(0).concat([l(:excel_student_id),l(:excel_nickname),l(:excel_user_name),l(:lable_all_penalty),l(:lable_has_penalty),l(:lable_absence_penalty)])
- count_row = 1
- items.each do |homework|
- sheet1[count_row,0] = homework.user.user_extensions.student_id
- sheet1[count_row,1] = homework.user.login
- sheet1[count_row,2] = homework.user.lastname.to_s + homework.user.firstname.to_s
- sheet1[count_row,3] = homework.all_count
- sheet1[count_row,4] = homework.has_count
- sheet1[count_row,5] = homework.absence
- count_row += 1
- end
- book.write xls_report
- xls_report.string
- end
-
- #匿评列表转换为excel
- def evaluation_list_xls items
- xls_report = StringIO.new
- book = Spreadsheet::Workbook.new
- sheet1 = book.create_worksheet :name => "homework"
- blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
- sheet1.row(0).default_format = blue
-
- sheet1.row(0).concat([l(:label_work_name),l(:label_work_id),l(:label_work_autor),l(:label_evaluation_id),l(:label_evaluation_name),
- l(:label_evaluation_score),l(:label_evaluation_common),l(:label_evaluation_time)])
- count_row = 1
- items.each do |homework|
- homework.student_works_scores.where(:reviewer_role => 3).each do |score|
- sheet1[count_row,0] = homework.name
- sheet1[count_row,1] = homework.user.user_extensions.student_id
- sheet1[count_row,2] = homework.user.show_name
- sheet1[count_row,3] = score.user.user_extensions.student_id
- sheet1[count_row,4] = score.user.show_name
- sheet1[count_row,5] = score.score
- sheet1[count_row,6] = score.comment
- sheet1[count_row,7] = format_time(score.created_at)
- count_row += 1
- end
- end
- book.write xls_report
- xls_report.string
- end
-
- def find_or_save_student_work(is_test)
- 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
- )
- unless @homework.save
- logger.debug @homework.errors.full_messages
- else
- student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
- end
- end
- student_work
- end
-
-
- def test_realtime(student_work, src)
- url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
-
- factor = []
- @homework.homework_tests.each do |test|
- factor << {input: test.input, output: test.output}
- end
- solutions = {
- 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|
- 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 set_final_score homework,student_work
- if homework && homework.homework_detail_manual
- if homework.homework_type != 2 #匿评作业
- if homework.teacher_priority == 1 #教师优先
- if student_work.teacher_score
- student_work.final_score = student_work.teacher_score
- else
- if 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
- else
- ta_proportion = homework.homework_detail_manual.ta_proportion
- final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
- final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
- final_score = final_ta_score + final_s_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- end
- else #不考虑教师评分
- if 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
- else
- ta_proportion = homework.homework_detail_manual.ta_proportion
- final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
- final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
- final_score = final_ta_score + final_s_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- end
- elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
- if homework.teacher_priority == 1 #教师优先
- if student_work.teacher_score
- student_work.final_score = student_work.teacher_score
- else
- if student_work.teaching_asistant_score.nil? #教辅未评分
- if student_work.student_score.nil?
- student_work.final_score = student_work.system_score
- else
- ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
- final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
- final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
- final_score = final_sy_score + final_st_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- elsif student_work.student_score.nil? #学生未评分
- if student_work.teaching_asistant_score.nil?
- student_work.final_score = student_work.system_score
- else
- ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
- final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
- final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
- final_score = final_sy_score + final_ts_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- else
- final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
- final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
- final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
- final_score = final_sy_score + final_ts_score + final_st_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- end
- else #不考虑教师评分
- if student_work.teaching_asistant_score.nil? #教辅未评分
- if student_work.student_score.nil?
- student_work.final_score = student_work.system_score
- else
- ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
- final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
- final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
- final_score = final_sy_score + final_st_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- elsif student_work.student_score.nil? #学生未评分
- if student_work.teaching_asistant_score.nil?
- student_work.final_score = student_work.system_score
- else
- ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
- final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
- final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
- final_score = final_sy_score + final_ts_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- else
- final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
- final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
- final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
- final_score = final_sy_score + final_ts_score + final_st_score
- student_work.final_score = format("%.2f",final_score.to_f)
- end
- end
- end
- end
- end
-end
+class StudentWorkController < ApplicationController
+ layout "base_courses"
+ include StudentWorkHelper
+ 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,: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 :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work]
+ 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 :is_logged, :only => [:index]
+
+ ###
+ def program_test
+ 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)
+
+ 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.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
+
+ def index
+ # 作业消息状态更新
+ @homework.course_messages.each do |homework_message|
+ if User.current.id == homework_message.user_id && homework_message.viewed == 0
+ homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0
+ end
+ end
+ # 作品打分消息状态更新
+ studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0)
+ studentworks_scores.each do |studentworks_score|
+ studentworks_score.update_attributes(:viewed => true) if studentworks_score.viewed == 0
+ end
+ # 作品评论消息状态更新
+ journals_for_teacher = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "JournalsForMessage", 0)
+ journals_for_teacher.each do |journal_for_teacher|
+ journal_for_teacher.update_attributes(:viewed => true)
+ end
+ #不能参与作业匿评消息状态更新
+ no_evaluation = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =? and status =?", User.current.id, @homework.course, "StudentWork", 0, 0)
+ no_evaluation.update_all(:viewed => true)
+ # 作品留言
+ # 消息end
+ #设置作业对应的forge_messages表的viewed字段
+ query_student_work = @homework.course_messages
+ query_student_work.each do |query|
+ if User.current.id == query.user_id
+ query.update_attributes(:viewed => true)
+ end
+ end
+ ##################################################################################################################
+ @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group]
+ @homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
+ @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评
+ @show_all = false
+
+ course_group = CourseGroup.find_by_id(@group) if @group
+ if course_group
+ group_students = course_group.users
+ if group_students.empty?
+ student_in_group = '(0)'
+ else
+ student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
+ end
+ #老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
+ if @homework.is_open == 1
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, 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
+ 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,IF(final_score = 0, 0, 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
+ 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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
+ 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, 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,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count
+ end
+
+ @score = @b_sort == "desc" ? "asc" : "desc"
+
+ respond_to do |format|
+ format.js
+ format.html
+ format.xls {
+ filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls"
+ send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
+ :filename => filename_for_content_disposition(filename))
+ }
+ end
+ end
+
+ def new
+ #更新消息
+ noEvaluation = @homework.course_messages.where("user_id =? and viewed =?", User.current.id, 0)
+ noEvaluation.update_all(:viewed => true)
+
+ if @homework.homework_type==2
+ redirect_to new_user_commit_homework_users_path(homework_id: @homework.id)
+ return
+ end
+ @user = User.current
+ @student_work = @homework.student_works.where("user_id = ?",User.current.id).first
+ if @student_work.nil?
+ @student_work = StudentWork.new
+ end
+ respond_to do |format|
+ format.html{ render :layout => "new_base_user"}
+ end
+ end
+
+ def create
+ # 提交作品前先判断是否已经提交
+ @has_commit = false;
+ if hsd_committed_work?(User.current.id, @homework.id)
+ @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
+ @has_commit = true;
+ #flash[:notice] = l(:notice_successful_create)
+ #redirect_to edit_student_work_url(params[:student_work])
+ respond_to do |format|
+ format.js
+ end
+ return
+ end
+ if params[:student_work]
+ @submit_result = true
+ student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
+ student_work ||= StudentWork.new
+ student_work.name = params[:student_work][:name]
+ student_work.description = params[:student_work][:description]
+ student_work.homework_common_id = @homework.id
+ student_work.user_id = User.current.id
+ student_work.save_attachments(params[:attachments])
+ render_attachment_warning_if_needed(student_work)
+ if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
+ @student_work_project = @homework.student_work_projects.where("user_id = #{User.current.id}").first
+ student_work.project_id = @student_work_project.project_id
+ end
+ #提交作品时,计算是否迟交
+ 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
+ if student_work.save
+ if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
+ @student_work_project.student_work_id = student_work.id
+ @student_work_project.save
+ members = params[:group_member_ids].split(',')
+ for i in 1 .. members.count-1
+ stu_project = StudentWorkProject.new
+ stu_project.homework_common_id = @homework.id
+ stu_project.student_work_id = student_work.id
+ stu_project.project_id = @student_work_project.project_id
+ stu_project.user_id = members[i].to_i
+ stu_project.is_leader = 0
+ stu_project.save
+ end
+ elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
+ members = params[:group_member_ids].split(',')
+ for i in 0 .. members.count-1
+ stu_project = StudentWorkProject.new
+ stu_project.homework_common_id = @homework.id
+ stu_project.student_work_id = student_work.id
+ stu_project.project_id = -1
+ stu_project.user_id = members[i].to_i
+ if i == 0
+ stu_project.is_leader = 1
+ else
+ stu_project.is_leader = 0
+ end
+ stu_project.save
+ end
+ end
+ @homework.update_attributes(:updated_at => Time.now)
+ update_course_activity(@homework.class,@homework.id)
+ update_user_activity(@homework.class,@homework.id)
+ update_org_activity(@homework.class,@homework.id)
+
+ course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"new",:course_message_id=>student_work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录
+ course_message.save
+
+ @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
+ respond_to do |format|
+ format.js
+ end
+ return
+ end
+ end
+ @submit_result = false
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def edit
+ @user = User.current
+ if (!User.current.admin? && @homework.homework_type == 2) || Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业
+ render_403
+ else
+ respond_to do |format|
+ format.html{ render :layout => "new_base_user"}
+ end
+ end
+ end
+
+ def update
+ if params[:student_work]
+ @submit_result = true
+ @work.name = params[:student_work][:name]
+ @work.description = params[:student_work][:description]
+ @work.save_attachments(params[:attachments])
+ render_attachment_warning_if_needed(@work)
+ if @work.save
+ if @homework.homework_type == 3
+ @student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first
+ student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0)
+ student_work_projects.delete_all
+ members = params[:group_member_ids].split(',')
+ for i in 1 .. members.count-1
+ stu_project = StudentWorkProject.new
+ stu_project.homework_common_id = @homework.id
+ stu_project.student_work_id = @work.id
+ 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
+ end
+ stu_project.user_id = members[i].to_i
+ stu_project.is_leader = 0
+ stu_project.save
+ end
+ end
+
+ course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"edit",:course_message_id=>@work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录
+ course_message.save
+ @student_work = @work
+ respond_to do |format|
+ format.js
+ end
+ return
+ end
+ end
+=begin
+ respond_to do |format|
+ format.html{redirect_to edit_student_work_url(@work)}
+ end
+=end
+ @submit_result = false
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def show
+ @score = student_work_score @work,User.current
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
+ @student_work_scores = @work.student_works_scores.order("updated_at desc")
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def destroy
+ if @work.destroy
+ if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
+ pros = @work.student_work_projects.where("is_leader = 0")
+ pros.each do |pro|
+ pro.destroy
+ end
+ project = @work.student_work_projects.where("is_leader = 1").first
+ project.update_attributes(:student_work_id => nil)
+ elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
+ @work.student_work_projects.each do |pro2|
+ pro2.destroy
+ end
+ end
+ respond_to do |format|
+ format.html {
+ redirect_to student_work_index_url(:homework => @homework.id)
+ }
+ end
+ end
+ end
+
+ def delete_work
+ @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
+ if @work
+ @work.destroy
+ if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
+ pros = @work.student_work_projects.where("is_leader = 0")
+ pros.each do |pro|
+ pro.destroy
+ end
+ project = @work.student_work_projects.where("is_leader = 1").first
+ project.update_attributes(:student_work_id => nil)
+ elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
+ @work.student_work_projects.each do |pro2|
+ pro2.destroy
+ end
+ end
+ end
+ redirect_to user_homeworks_user_path(User.current.id)
+ end
+
+ def retry_work
+ if @work.destroy
+ if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
+ pros = @work.student_work_projects.where("is_leader = 0")
+ pros.each do |pro|
+ pro.destroy
+ end
+ project = @work.student_work_projects.where("is_leader = 1").first
+ project.update_attributes(:student_work_id => nil)
+ elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
+ @work.student_work_projects.each do |pro2|
+ pro2.destroy
+ end
+ end
+ @student_work = StudentWork.new
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
+ #添加评分,已评分则为修改评分
+ def add_score
+ @is_last = params[:is_last] == "true"
+ render_403 and return if User.current == @work.user #不可以匿评自己的作品
+ @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
+ #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分
+ render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2
+ @score = student_work_score @work,User.current
+ if @score
+ @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
+ @score.score = params[:score] if params[:score]
+ if User.current.admin?
+ @score.reviewer_role = 1
+ else
+ role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
+ @score.reviewer_role = get_role_by_name(role)
+ end
+ @is_new = false
+ else
+ @is_last_a = @work.student_works_scores.empty?
+ @score = StudentWorksScore.new
+ @score.score = params[:score] if params[:score]
+ @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""
+ @score.user_id = User.current.id
+ @score.student_work_id = @work.id
+ if User.current.admin?
+ @score.reviewer_role = 1
+ else
+ role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name
+ @score.reviewer_role = get_role_by_name(role)
+ end
+ @is_new = true
+ end
+
+ @score.save_attachments(params[:attachments])
+ render_attachment_warning_if_needed(@score)
+
+ if @score.save
+ case @score.reviewer_role
+ when 1 #教师评分:最后一个教师评分为最终评分
+ @work.teacher_score = @score.score
+ when 2 #教辅评分 教辅评分显示平均分
+ @work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f
+ when 3 #学生评分 学生评分显示平均分
+ @work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
+ end
+ @homework.update_attributes(:updated_at => Time.now)
+ update_course_activity(@homework.class,@homework.id)
+ update_user_activity(@homework.class,@homework.id)
+ update_org_activity(@homework.class,@homework.id)
+ if @work.save
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+ end
+
+ #添加评分的回复
+ def add_score_reply
+ @score = StudentWorksScore.find params[:score_id]
+ @is_last = params[:is_last] == "true"
+ @jour = @score.journals_for_messages.new(:user_id => User.current.id,:notes =>params[:message], :reply_id => 0)
+ if @jour.save
+ @status = 1
+ else
+ @status = 2
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ #删除评分的回复
+ def destroy_score_reply
+ @jour = JournalsForMessage.find params[:jour_id]
+ if @jour.destroy
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
+ #为作品点赞
+ def praise_student_work
+ pt = PraiseTread.new
+ pt.user_id = User.current.id
+ pt.praise_tread_object_id = @work.id
+ pt.praise_tread_object_type = "StudentWork"
+ pt.praise_or_tread = 1
+ if pt.save
+ respond_to do |format|
+ format.js
+ end
+ else
+ render_404
+ end
+ end
+
+ #缺评列表显示
+ def student_work_absence_penalty
+ order = params[:order] || "desc"
+ if @homework.student_works.empty?
+ @stundet_works = []
+ else
+ work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
+ @stundet_works = StudentWork.find_by_sql("SELECT *,(all_count - has_count) AS absence FROM(
+ SELECT * ,
+ (SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count,
+ (SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
+ FROM `student_works`
+ WHERE homework_common_id = #{@homework.id}
+ ) AS table_1
+ ORDER BY absence #{order}")
+ end
+ @order = order == "desc" ? "asc" : "desc"
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #导出缺评列表
+ def absence_penalty_list
+ if @homework.student_works.empty?
+ @stundet_works = []
+ else
+ work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
+ @stundet_works = StudentWork.find_by_sql("SELECT * FROM (SELECT *,(all_count - has_count) AS absence FROM(
+ SELECT * ,
+ (SELECT COUNT(*) FROM `student_works_evaluation_distributions` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS all_count,
+ (SELECT COUNT(*) FROM `student_works_scores` WHERE user_id = student_works.user_id AND student_work_id IN #{work_ids}) AS has_count
+ FROM `student_works`
+ WHERE homework_common_id = #{@homework.id}
+ ) AS table_1) AS table_2
+ where absence > 0 order by absence")
+ end
+ respond_to do |format|
+ format.xls {
+ filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_absence_list)}.xls"
+ send_data(absence_penalty_list_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
+ :filename => filename_for_content_disposition(filename))
+ }
+ end
+ end
+
+ #导出匿评列表
+ def evaluation_list
+ respond_to do |format|
+ format.xls {
+ filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_evaluation_list)}.xls"
+ send_data(evaluation_list_xls(@homework.student_works), :type => "text/excel;charset=utf-8; header=present",
+ :filename => filename_for_content_disposition(filename))
+ }
+ end
+ end
+
+ #设置评分规则
+ def set_score_rule
+ homework_detail_manual = @homework.homework_detail_manual
+ homework_detail_programing = @homework.homework_detail_programing
+
+ unless @homework.late_penalty.to_s == params[:late_penalty].to_s
+ @homework.late_penalty = params[:late_penalty]
+ @homework.student_works.where("created_at > '#{@homework.end_time} 23:59:59'").each do |student_work|
+ student_work.late_penalty = @homework.late_penalty
+ student_work.save
+ end
+
+ @homework.save
+ end
+
+ unless homework_detail_manual.absence_penalty.to_s == params[:absence_penalty].to_s
+ homework_detail_manual.absence_penalty = params[:absence_penalty]
+ if homework_detail_manual.comment_status == 3 #当前作业处于匿评结束状态,修改缺评扣分才会修改每个作品应扣分的值
+ work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
+ @homework.student_works.each do |student_work|
+ absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
+ student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
+ student_work.save
+ end
+ end
+
+ homework_detail_manual.save if homework_detail_manual
+ end
+
+ teacher_priority = params[:teacher_priority] ? 1 : 0
+ 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.save
+ homework_detail_manual.save if homework_detail_manual
+ homework_detail_programing.save if homework_detail_programing
+
+ @homework.student_works.each do |student_work|
+ set_final_score @homework,student_work
+ student_work.save
+ end
+ end
+ if params[:student_path]
+ redirect_to student_work_index_url(:homework => @homework.id)
+ else
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
+ def forbidden_anonymous_comment
+ @homework.update_column('anonymous_comment', 1)
+ homework_detail_manual = @homework.homework_detail_manual
+ homework_detail_programing = @homework.homework_detail_programing
+ if homework_detail_programing
+ homework_detail_manual.update_column('ta_proportion', 0.4)
+ homework_detail_programing.update_column('ta_proportion', 0.6)
+ else
+ homework_detail_manual.update_column('ta_proportion', 1.0)
+ end
+ @homework.student_works.each do |student_work|
+ set_final_score @homework,student_work
+ student_work.save
+ end
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ end
+
+ def revise_attachment
+ Attachment.attach_filesex(@work, params[:attachments], params[:attachment_type])
+ revise_attachments = @work.attachments.where("attachtype = 7").reorder("created_on desc")
+ if revise_attachments.count == 2
+ revise_attachments.last.destroy
+ end
+ attachment = @work.attachments.where("attachtype = 7").first
+ attachment.update_attributes(:description => params[:description])
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def new_student_work_project
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ #创建作业的关联项目
+ def student_work_project
+ @project = StudentWorkProject.new
+ @project.homework_common_id = @homework.id
+ @project.project_id = (Project.find params[:projectName].to_i).id
+ @project.user_id = User.current.id
+ @project.is_leader = 1
+ if @project.save
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ end
+
+ #查找学生创建的项目列表
+ def search_user_projects
+ condition = '%%'
+ if !params[:name].nil?
+ condition = "%#{params[:name].strip}%".gsub(" ","")
+ end
+ @project_ids = Project.visible.where("user_id = #{User.current.id} and name like '#{condition}'")
+ @first = params[:first].to_i
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ #查找课程的学生
+ def search_course_students
+ name = ""
+ unless params[:name].nil?
+ name = params[:name]
+ end
+ if @homework.homework_detail_group.base_on_project == 0
+ all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")"
+ else
+ pro = Project.find @homework.student_work_projects.where("user_id=?",User.current.id).first.project_id
+ all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")"
+ end
+ all_students = User.where("id in #{all_student_ids}")
+ @commit_student_ids = @homework.student_work_projects.map{|student| student.user_id}
+ @users = searchstudent_by_name all_students,name
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def cancel_relate_project
+ relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first
+ if relate_pro.destroy
+ @user_activity_id = params[:user_activity_id].to_i
+ @is_in_course = params[:is_in_course].to_i
+ @course_activity = params[:course_activity].to_i
+ respond_to do |format|
+ format.js
+ end
+ end
+ end
+
+ private
+ def searchstudent_by_name users, name
+ mems = []
+ if name != ""
+ name = name.to_s.downcase
+ users.each do |m|
+ username = m.lastname.to_s.downcase + m.firstname.to_s.downcase
+ if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
+ mems << m
+ end
+ end
+ else
+ mems = users
+ end
+ mems
+ end
+
+ def hsd_committed_work?(user, homework)
+ sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first
+ sw.nil? ? result = false : result = true
+ result
+ end
+
+ #获取作业
+ def find_homework
+ @homework = HomeworkCommon.find params[:homework]
+ @course = @homework.course
+ rescue
+ render_404
+ end
+ #获取作品
+ def find_work
+ @work = StudentWork.find params[:id]
+ @homework = @work.homework_common
+ @course = @homework.course
+ rescue
+ render_404
+ end
+
+ #是不是当前课程的成员
+ #当前课程成员才可以看到作品列表
+ def member_of_course
+ render_403 unless User.current.member_of_course?(@course) || User.current.admin?
+ end
+
+ #判断是不是当前作品的提交者
+ #提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品
+ def author_of_work
+ render_403 unless User.current.admin? || (User.current.id == @work.user_id && @homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 )
+ end
+
+ def teacher_of_course
+ render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
+ end
+
+ def is_logged
+ redirect_to signin_path unless User.current.logged?
+ end
+
+ #根据条件过滤作业结果
+ def search_homework_member homeworks,name
+ if name == ""
+ select_homework = homeworks
+ else
+ name = name.downcase
+ select_homework = homeworks.select{ |homework|
+ homework.user[:login].to_s.downcase.include?(name) || homework.user.user_extensions[:student_id].to_s.downcase.include?(name) || (homework.user[:lastname].to_s.downcase + homework.user[:firstname].to_s.downcase).include?(name)
+ }
+ end
+ select_homework
+ end
+
+ #作品列表转换为excel
+ def homework_to_xls items
+ xls_report = StringIO.new
+ book = Spreadsheet::Workbook.new
+ sheet1 = book.create_worksheet :name => "homework"
+ blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
+ sheet1.row(0).default_format = blue
+ if @homework.homework_type == 1 #匿评作业
+ sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
+ l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
+ count_row = 1
+ items.each do |homework|
+ sheet1[count_row,0]=homework.user.id
+ sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
+ sheet1[count_row,2] = homework.user.login
+ sheet1[count_row,3] = homework.user.user_extensions.student_id
+ sheet1[count_row,4] = homework.user.mail
+ sheet1[count_row,5] = homework.name
+ sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
+ sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
+ sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
+ sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
+ sheet1[count_row,10] = format_time(homework.created_at)
+ count_row += 1
+ end
+ elsif @homework.homework_type == 2 #编程作业
+ sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),
+ l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)])
+ count_row = 1
+ items.each do |homework|
+ sheet1[count_row,0]=homework.user.id
+ sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s
+ sheet1[count_row,2] = homework.user.login
+ sheet1[count_row,3] = homework.user.user_extensions.student_id
+ sheet1[count_row,4] = homework.user.mail
+ sheet1[count_row,5] = homework.name
+ sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score)
+ sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score)
+ sheet1[count_row,8] = homework.system_score.nil? ? l(:label_without_score) : format("%.2f",homework.system_score)
+ sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score)
+ sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score)
+ sheet1[count_row,11] = format_time(homework.created_at)
+ count_row += 1
+ end
+ end
+ book.write xls_report
+ xls_report.string
+ end
+
+ #缺评列表转换为excel
+ def absence_penalty_list_xls items
+ xls_report = StringIO.new
+ book = Spreadsheet::Workbook.new
+ sheet1 = book.create_worksheet :name => "homework"
+ blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
+ sheet1.row(0).default_format = blue
+
+ sheet1.row(0).concat([l(:excel_student_id),l(:excel_nickname),l(:excel_user_name),l(:lable_all_penalty),l(:lable_has_penalty),l(:lable_absence_penalty)])
+ count_row = 1
+ items.each do |homework|
+ sheet1[count_row,0] = homework.user.user_extensions.student_id
+ sheet1[count_row,1] = homework.user.login
+ sheet1[count_row,2] = homework.user.lastname.to_s + homework.user.firstname.to_s
+ sheet1[count_row,3] = homework.all_count
+ sheet1[count_row,4] = homework.has_count
+ sheet1[count_row,5] = homework.absence
+ count_row += 1
+ end
+ book.write xls_report
+ xls_report.string
+ end
+
+ #匿评列表转换为excel
+ def evaluation_list_xls items
+ xls_report = StringIO.new
+ book = Spreadsheet::Workbook.new
+ sheet1 = book.create_worksheet :name => "homework"
+ blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
+ sheet1.row(0).default_format = blue
+
+ sheet1.row(0).concat([l(:label_work_name),l(:label_work_id),l(:label_work_autor),l(:label_evaluation_id),l(:label_evaluation_name),
+ l(:label_evaluation_score),l(:label_evaluation_common),l(:label_evaluation_time)])
+ count_row = 1
+ items.each do |homework|
+ homework.student_works_scores.where(:reviewer_role => 3).each do |score|
+ sheet1[count_row,0] = homework.name
+ sheet1[count_row,1] = homework.user.user_extensions.student_id
+ sheet1[count_row,2] = homework.user.show_name
+ sheet1[count_row,3] = score.user.user_extensions.student_id
+ sheet1[count_row,4] = score.user.show_name
+ sheet1[count_row,5] = score.score
+ sheet1[count_row,6] = score.comment
+ sheet1[count_row,7] = format_time(score.created_at)
+ count_row += 1
+ end
+ end
+ book.write xls_report
+ xls_report.string
+ end
+
+ def find_or_save_student_work(is_test)
+ 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
+ )
+ unless @homework.save
+ logger.debug @homework.errors.full_messages
+ else
+ student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
+ end
+ end
+ student_work
+ end
+
+
+ def test_realtime(student_work, src)
+ url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json"
+
+ factor = []
+ @homework.homework_tests.each do |test|
+ factor << {input: test.input, output: test.output}
+ end
+ solutions = {
+ 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|
+ 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 set_final_score homework,student_work
+ if homework && homework.homework_detail_manual
+ if homework.homework_type != 2 #匿评作业
+ if homework.teacher_priority == 1 #教师优先
+ if student_work.teacher_score
+ student_work.final_score = student_work.teacher_score
+ else
+ if 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
+ else
+ ta_proportion = homework.homework_detail_manual.ta_proportion
+ final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
+ final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
+ final_score = final_ta_score + final_s_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ end
+ else #不考虑教师评分
+ if 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
+ else
+ ta_proportion = homework.homework_detail_manual.ta_proportion
+ final_ta_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{ta_proportion}")
+ final_s_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
+ final_score = final_ta_score + final_s_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ end
+ elsif homework.homework_type == 2 && homework.homework_detail_programing #编程作业-----设定:系统评分必定不为空
+ if homework.teacher_priority == 1 #教师优先
+ if student_work.teacher_score
+ student_work.final_score = student_work.teacher_score
+ else
+ if student_work.teaching_asistant_score.nil? #教辅未评分
+ if student_work.student_score.nil?
+ student_work.final_score = student_work.system_score
+ else
+ ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
+ final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
+ final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
+ final_score = final_sy_score + final_st_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ elsif student_work.student_score.nil? #学生未评分
+ if student_work.teaching_asistant_score.nil?
+ student_work.final_score = student_work.system_score
+ else
+ ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
+ final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
+ final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
+ final_score = final_sy_score + final_ts_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ else
+ final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
+ final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
+ final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
+ final_score = final_sy_score + final_ts_score + final_st_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ end
+ else #不考虑教师评分
+ if student_work.teaching_asistant_score.nil? #教辅未评分
+ if student_work.student_score.nil?
+ student_work.final_score = student_work.system_score
+ else
+ ta_proportion = homework.homework_detail_programing.ta_proportion + homework.homework_detail_manual.ta_proportion / 2
+ final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
+ final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
+ final_score = final_sy_score + final_st_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ elsif student_work.student_score.nil? #学生未评分
+ if student_work.teaching_asistant_score.nil?
+ student_work.final_score = student_work.system_score
+ else
+ ta_proportion = homework.homework_detail_programing.ta_proportion + (1.0 - homework.homework_detail_manual.ta_proportion - homework.homework_detail_programing.ta_proportion) / 2
+ final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{ta_proportion}")
+ final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{ta_proportion}"))
+ final_score = final_sy_score + final_ts_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ else
+ final_sy_score = BigDecimal.new("#{student_work.system_score || 0}") * BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}")
+ final_ts_score = BigDecimal.new("#{student_work.teaching_asistant_score}") * BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}")
+ final_st_score = BigDecimal.new("#{student_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework.homework_detail_programing.ta_proportion}") - BigDecimal.new("#{homework.homework_detail_manual.ta_proportion}"))
+ final_score = final_sy_score + final_ts_score + final_st_score
+ student_work.final_score = format("%.2f",final_score.to_f)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 921262106..ea984aa80 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -58,6 +58,7 @@ class UsersController < ApplicationController
helper :sort
helper :attachments
include SortHelper
+ include ApplicationHelper
helper :custom_fields
include CustomFieldsHelper
include AvatarHelper
@@ -690,6 +691,11 @@ class UsersController < ApplicationController
end
student_work.save
+ homework.update_attributes(:updated_at => Time.now)
+ update_course_activity(homework.class,homework.id)
+ update_user_activity(homework.class,homework.id)
+ update_org_activity(homework.class,homework.id)
+
flash[:notice] = l(:notice_successful_create)
redirect_to student_work_index_url(:homework => params[:homework])
else
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index d1aa67483..e6d1d9117 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -276,7 +276,7 @@ class WordsController < ApplicationController
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
end
-
+ @homework_common.update_attributes(:updated_at => Time.now)
update_course_activity(@homework_common.class,@homework_common.id)
update_user_activity(@homework_common.class,@homework_common.id)
update_org_activity(@homework_common.class,@homework_common.id)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c19c44935..477e18f41 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -117,56 +117,102 @@ module ApplicationHelper
when "HomeworkCommon"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :homework_journal_num => 1 , :total_score => 1)
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :homework_journal_num => 1)
else
score = course_contributor_score.homework_journal_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:homework_journal_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:homework_journal_num => score)
end
- when "JournalForMessage"
+ # 课程留言
+ when "Course"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0, :total_score => 1)
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0)
else
score = course_contributor_score.journal_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:journal_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:journal_num => score)
end
when "Message"
if course_contributor_score.nil?
- CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 2, :message_reply_num => 0,
- :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 2)
+ CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1, :message_reply_num => 0,
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
else
- score = course_contributor_score.message_num + 2
- total_score = course_contributor_score.total_score + 2
- course_contributor_score.update_attributes(:message_num => score, :total_score => total_score)
+ score = course_contributor_score.message_num + 1
+ course_contributor_score.update_attributes(:message_num => score)
end
when "MessageReply"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 1,
- :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
else
score = course_contributor_score.message_reply_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:message_reply_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:message_reply_num => score)
end
when "NewReply"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
+ :news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
else
score = course_contributor_score.news_reply_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:news_reply_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:news_reply_num => score)
end
when "News"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 0, :news_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
+ :news_reply_num => 0, :news_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
else
score = course_contributor_score.news_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:news_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:news_num => score)
+ end
+ when "Attachment"
+ if course_contributor_score.nil?
+ CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
+ :news_reply_num => 0, :news_num => 0, :resource_num => 1, :journal_num => 0, :journal_reply_num => 0)
+ else
+ score = course_contributor_score.resource_num + 1
+ course_contributor_score.update_attributes(:resource_num => score)
+ end
+ end
+ end
+
+ # 删除某条记录相应减少课程统计数
+ def down_course_score_num (course_id,user_id,type)
+ course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course_id, user_id).first
+ case type
+ when "HomeworkCommon"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.homework_journal_num - 1
+ course_contributor_score.update_attribute(:homework_journal_num, score < 0 ? 0 : score)
+ end
+ # 课程留言
+ when "Course"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.journal_num - 1
+ course_contributor_score.update_attribute(:journal_num, score < 0 ? 0 : score)
+ end
+ when "Message"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.message_num - 1
+ course_contributor_score.update_attribute(:message_num, score < 0 ? 0 : score)
+ end
+ when "MessageReply"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.message_reply_num - 1
+ course_contributor_score.update_attribute(:message_reply_num, score < 0 ? 0 : score)
+ end
+ when "NewReply"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.news_reply_num - 1
+ course_contributor_score.update_attribute(:news_reply_num, score < 0 ? 0 : score)
+ end
+ when "News"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.news_num - 1
+ course_contributor_score.update_attribute(:news_num, score < 0 ? 0 : score)
+ end
+ when "Attachment"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.resource_num - 1
+ course_contributor_score.update_attribute(:resource_num, score < 0 ? 0 : score)
end
end
end
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 82f648ad9..9f0c2c559 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -43,6 +43,7 @@ class Attachment < ActiveRecord::Base
#elasticsearch
include Elasticsearch::Model
+ include ApplicationHelper
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
@@ -92,7 +93,7 @@ class Attachment < ActiveRecord::Base
after_save :act_as_course_activity
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_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, :down_course_score
# add by nwb
# 获取所有可公开的资源文件列表
@@ -655,6 +656,12 @@ class Attachment < ActiveRecord::Base
self.container.project_score.update_attribute(:attach_num, attach_count < 0 ? 0 : attach_count)
end
end
+
+ def down_course_score
+ if self.container_type == "Course"
+ down_course_score_num(self.container_id, self.author_id, "Attachment")
+ end
+ end
end
# Delete the previous articles index in Elasticsearch
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 4d7af1d73..b87203a50 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -36,6 +36,7 @@ class Comment < ActiveRecord::Base
validates_presence_of :commented, :author, :comments
safe_attributes 'comments'
after_create :send_mail, :act_as_system_message, :act_as_student_score
+ after_destroy :down_course_score
def act_as_system_message
if self.commented.course
@@ -86,4 +87,11 @@ class Comment < ActiveRecord::Base
end
end
+ # 课程新闻数减少
+ def down_course_score
+ if self.commented.course
+ down_course_score_num(self.commented.course.id, self.author_id, "NewReply")
+ end
+ end
+
end
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index 7990979e4..dae779b65 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -73,7 +73,7 @@ class JournalsForMessage < ActiveRecord::Base
#after_update :update_activity
after_destroy :reset_counters!
after_save :be_user_score
- after_destroy :down_user_score
+ after_destroy :down_user_score, :down_course_score
# default_scope { where('m_parent_id IS NULL') }
@@ -184,6 +184,7 @@ class JournalsForMessage < ActiveRecord::Base
end
end
end
+
# 更新用户分数 -by zjc
def down_user_score
#删除了留言回复
@@ -286,10 +287,19 @@ class JournalsForMessage < ActiveRecord::Base
# 课程成员得分(活跃度)
def act_as_student_score
if self.jour_type == "Course"
- course_member_score(self.jour_id, self.user_id, "JournalForMessage")
+ course_member_score(self.jour_id, self.user_id, "Course")
elsif self.jour_type == "HomeworkCommon"
course_member_score(self.jour.course_id, self.user_id, "HomeworkCommon")
end
end
+ # 删除操作的时候相应扣掉回复数
+ def down_course_score
+ if self.jour_type == "Course"
+ down_course_score_num(self.jour_id, self.user_id, "Course")
+ elsif self.jour_type == "HomeworkCommon"
+ down_course_score_num(self.jour.course_id, self.user_id, "HomeworkCommon")
+ end
+ end
+
end
diff --git a/app/models/member.rb b/app/models/member.rb
index 413fedc07..9eac21fa7 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -1,185 +1,185 @@
-# Redmine - project management software
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-class Member < ActiveRecord::Base
- belongs_to :user
- belongs_to :principal, :foreign_key => 'user_id'
- has_many :member_roles, :dependent => :destroy
- has_many :roles, :through => :member_roles
-
- belongs_to :project
- belongs_to :course
-
- belongs_to :course_group
- validates_presence_of :principal
- validates_uniqueness_of :user_id, :scope => [:project_id,:course_id]
- validate :validate_role
-
- before_destroy :set_issue_category_nil
- # 删除项目成员一并删除该成员的邀请记录
- after_destroy :delete_ivite_list
-
-
-
- def role
- end
-
- def role=
- end
-
- def name
- self.user.name
- end
-
- alias :base_role_ids= :role_ids=
- def role_ids=(arg)
- ids = (arg || []).collect(&:to_i) - [0]
- # Keep inherited roles
- ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
-
- new_role_ids = ids - role_ids
- # Add new roles
- new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
- # Remove roles (Rails' #role_ids= will not trigger MemberRole#on_destroy)
- member_roles_to_destroy = member_roles.select {|mr| !ids.include?(mr.role_id)}
- if member_roles_to_destroy.any?
- member_roles_to_destroy.each(&:destroy)
- end
- end
-
- def <=>(member)
- a, b = roles.sort.first, member.roles.sort.first
- if a == b
- if principal
- principal <=> member.principal
- else
- 1
- end
- elsif a
- a <=> b
- else
- 1
- end
- end
-
- def deletable?
- member_roles.detect {|mr| mr.inherited_from}.nil?
- end
-
- def include?(user)
- if principal.is_a?(Group)
- !user.nil? && user.groups.include?(principal)
- else
- self.user == user
- end
- end
-
- def set_issue_category_nil
- if user
- # remove category based auto assignments for this member
- #modify by nwb
- if project
- IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
- elsif course
- #IssueCategory.update_all "assigned_to_id = NULL", ["course_id = ? AND assigned_to_id = ?", course.id, user.id]
- end
-
- end
- end
-
- # 删除成员一并删除该成员的邀请信息
- def delete_ivite_list
- member_invite_lists = InviteList.where("user_id =? and project_id =?", self.user_id, self.project_id)
- unless member_invite_lists.nil?
- member_invite_lists.each do |member_invite_list|
- member_invite_list.destroy
- end
- end
- end
-
- # Find or initilize a Member with an id, attributes, and for a Principal
- def self.edit_membership(id, new_attributes, principal=nil)
- @membership = id.present? ? Member.find(id) : Member.new(:principal => principal)
- @membership.attributes = new_attributes
- @membership
- end
-
- # Finds or initilizes a Member for the given project and principal
- def self.find_or_new(project, principal)
- project_id = project.is_a?(Project) ? project.id : project
- principal_id = principal.is_a?(Principal) ? principal.id : principal
-
- member = Member.find_by_project_id_and_user_id(project_id, principal_id)
- member ||= Member.new(:project_id => project_id, :user_id => principal_id)
- member
- end
-
- # 查找每个学生每个作业的评分
- def student_homework_score
- homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score
- FROM student_works,homework_commons
- WHERE student_works.homework_common_id = homework_commons.id
- AND homework_commons.course_id = #{self.course_id}
- AND student_works.user_id = #{self.user_id}")
- score_count = StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
- [homework_score, format("%0.2f", score_count)]
- end
-
- def student_work_score
- StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}")
- end
-
- #当前课程的作业列表
- def homework_common_list
- HomeworkCommon.where(:course_id => self.course_id)
- end
-
- #当前学生在指定作业内的得分
- def homework_common_score homework_common
- StudentWork.select("IF(final_score is null,null,final_score - absence_penalty - late_penalty) as final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
- end
-
- def student_work_score_avg
- StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
- end
-
- def student_work_score_sum
- sql_select = "SELECT (SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))) as score
- FROM student_works,homework_commons
- WHERE student_works.homework_common_id = homework_commons.id
- AND homework_commons.course_id = #{self.course_id}
- AND student_works.user_id = #{self.user_id}"
- score = StudentWork.find_by_sql(sql_select)
- end
-
- protected
-
- def validate_role
- errors.add_on_empty :role if member_roles.empty? && roles.empty?
- end
-
-
-
- def searchTeacherAndAssistant project
- #searchPeopleByRoles(project, TeacherRoles)
- members = []
- project.members.each do |m|
- members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
- end
- members
- end
-end
+# Redmine - project management software
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Member < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :principal, :foreign_key => 'user_id'
+ has_many :member_roles, :dependent => :destroy
+ has_many :roles, :through => :member_roles
+
+ belongs_to :project
+ belongs_to :course
+
+ belongs_to :course_group
+ validates_presence_of :principal
+ validates_uniqueness_of :user_id, :scope => [:project_id,:course_id]
+ validate :validate_role
+
+ before_destroy :set_issue_category_nil
+ # 删除项目成员一并删除该成员的邀请记录
+ after_destroy :delete_ivite_list
+
+
+
+ def role
+ end
+
+ def role=
+ end
+
+ def name
+ self.user.name
+ end
+
+ alias :base_role_ids= :role_ids=
+ def role_ids=(arg)
+ ids = (arg || []).collect(&:to_i) - [0]
+ # Keep inherited roles
+ ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
+
+ new_role_ids = ids - role_ids
+ # Add new roles
+ new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
+ # Remove roles (Rails' #role_ids= will not trigger MemberRole#on_destroy)
+ member_roles_to_destroy = member_roles.select {|mr| !ids.include?(mr.role_id)}
+ if member_roles_to_destroy.any?
+ member_roles_to_destroy.each(&:destroy)
+ end
+ end
+
+ def <=>(member)
+ a, b = roles.sort.first, member.roles.sort.first
+ if a == b
+ if principal
+ principal <=> member.principal
+ else
+ 1
+ end
+ elsif a
+ a <=> b
+ else
+ 1
+ end
+ end
+
+ def deletable?
+ member_roles.detect {|mr| mr.inherited_from}.nil?
+ end
+
+ def include?(user)
+ if principal.is_a?(Group)
+ !user.nil? && user.groups.include?(principal)
+ else
+ self.user == user
+ end
+ end
+
+ def set_issue_category_nil
+ if user
+ # remove category based auto assignments for this member
+ #modify by nwb
+ if project
+ IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
+ elsif course
+ #IssueCategory.update_all "assigned_to_id = NULL", ["course_id = ? AND assigned_to_id = ?", course.id, user.id]
+ end
+
+ end
+ end
+
+ # 删除成员一并删除该成员的邀请信息
+ def delete_ivite_list
+ member_invite_lists = InviteList.where("user_id =? and project_id =?", self.user_id, self.project_id)
+ unless member_invite_lists.nil?
+ member_invite_lists.each do |member_invite_list|
+ member_invite_list.destroy
+ end
+ end
+ end
+
+ # Find or initilize a Member with an id, attributes, and for a Principal
+ def self.edit_membership(id, new_attributes, principal=nil)
+ @membership = id.present? ? Member.find(id) : Member.new(:principal => principal)
+ @membership.attributes = new_attributes
+ @membership
+ end
+
+ # Finds or initilizes a Member for the given project and principal
+ def self.find_or_new(project, principal)
+ project_id = project.is_a?(Project) ? project.id : project
+ principal_id = principal.is_a?(Principal) ? principal.id : principal
+
+ member = Member.find_by_project_id_and_user_id(project_id, principal_id)
+ member ||= Member.new(:project_id => project_id, :user_id => principal_id)
+ member
+ end
+
+ # 查找每个学生每个作业的评分
+ def student_homework_score
+ homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score
+ FROM student_works,homework_commons
+ WHERE student_works.homework_common_id = homework_commons.id
+ AND homework_commons.course_id = #{self.course_id}
+ AND student_works.user_id = #{self.user_id}")
+ score_count = StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
+ [homework_score, format("%0.2f", score_count)]
+ end
+
+ def student_work_score
+ StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}")
+ end
+
+ #当前课程的作业列表
+ def homework_common_list
+ HomeworkCommon.where(:course_id => self.course_id)
+ end
+
+ #当前学生在指定作业内的得分
+ def homework_common_score homework_common
+ StudentWork.select("IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
+ end
+
+ def student_work_score_avg
+ StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
+ end
+
+ def student_work_score_sum
+ sql_select = "SELECT (SUM(IF(student_works.final_score IS NULL,NULL,IF(student_works.final_score =0,0,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))) as score
+ FROM student_works,homework_commons
+ WHERE student_works.homework_common_id = homework_commons.id
+ AND homework_commons.course_id = #{self.course_id}
+ AND student_works.user_id = #{self.user_id}"
+ score = StudentWork.find_by_sql(sql_select)
+ end
+
+ protected
+
+ def validate_role
+ errors.add_on_empty :role if member_roles.empty? && roles.empty?
+ end
+
+
+
+ def searchTeacherAndAssistant project
+ #searchPeopleByRoles(project, TeacherRoles)
+ members = []
+ project.members.each do |m|
+ members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
+ end
+ members
+ end
+end
diff --git a/app/models/message.rb b/app/models/message.rb
index 44f2d2c80..0ddc6f8e0 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -79,7 +79,7 @@ class Message < ActiveRecord::Base
after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
after_update :update_messages_board, :update_activity
- after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count
+ after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message
#before_save :be_user_score
@@ -354,6 +354,18 @@ class Message < ActiveRecord::Base
end
end
+ # 删除帖子的时候更新课程帖子总数, 删除回复的时候减少总数
+ def down_course_score
+ if self.course
+ if self.parent_id.nil? # 发帖
+ down_course_score_num(self.course.id, self.author_id, "Message")
+ else
+ # 回帖
+ down_course_score_num(self.course.id, self.author_id, "MessageReply")
+ end
+ end
+ end
+
def delete_org_activities
OrgActivity.where("org_act_type='Message' and org_act_id =#{self.id} and container_type='OrgSubfield'").destroy_all
end
diff --git a/app/models/news.rb b/app/models/news.rb
index 028b6d737..6746d90cd 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -61,7 +61,7 @@ class News < ActiveRecord::Base
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score
after_update :update_activity
- after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities
+ after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
@@ -195,10 +195,18 @@ class News < ActiveRecord::Base
OrgActivity.where("container_type='OrgSubfield' and org_act_type='News' and org_act_id=?", self.id).destroy_all
end
+ # 新增新闻统计数增加
def act_as_student_score
if self.course
course_member_score(self.course.id, self.author_id, "News")
end
end
+ # 删除新闻统计数减少
+ def down_course_score
+ if self.course
+ down_course_score_num(self.course.id, self.author_id, "News")
+ end
+ end
+
end
\ No newline at end of file
diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb
index e222d8e56..ac953b254 100644
--- a/app/views/blog_comments/_simple_ke_reply_form.html.erb
+++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb
@@ -1,21 +1,21 @@
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
-
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
\ No newline at end of file
diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb
index 05f69055f..a5aa8b780 100644
--- a/app/views/blogs/_article.html.erb
+++ b/app/views/blogs/_article.html.erb
@@ -1,226 +1,226 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
-
-
- <% if activity.author.id == User.current.id%>
-
-
-
-
-
- <%= link_to(
- l(:button_edit),
- {:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.author.id %>
-
-
- <%= link_to(
- l(:button_delete),
- {:controller => 'blog_comments',:action => 'destroy',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
- :method => :delete,
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.author.id %>
-
-
- <% if activity.id == activity.blog.homepage_id %>
- <%= link_to(
- l(:button_cancel_homepage),
- {:controller => 'blogs',:action => 'cancel_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
- :method => :post,
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.blog.author_id %>
- <% else %>
- <%= link_to(
- l(:button_set_homepage),
- {:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
- :method => :post,
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.blog.author_id %>
- <% end %>
-
-
-
-
-
- <%end%>
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% end %>
- TO
- <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
- <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
- 已设为首页
- <% end %>
-
-
-
- <% if activity.parent_id.nil? %>
- <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey" %>
- <% else %>
- <%= 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=> "postGrey"%>
- <% end %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
- <% if activity.locked%>
-
- <% end%>
-
-
- 发帖时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(activity.updated_on) %>
-
-
- <% if activity.parent_id.nil? %>
- <% content= activity.content%>
- <% else %>
- <% content= activity.parent.content%>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
-
-
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
-
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#=format_date(activity.updated_on)%>
- <%if count > 3 %>
-
- <% end %>
-
-
- <% activity= activity.parent ? activity.parent : activity%>
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |reply|%>
-
- <% replies_all_i=replies_all_i+1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.author == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <%= reply.content.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if !activity.locked? %>
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%>
-
-
-
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
- <% end %>
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+
+
+ <% if activity.author.id == User.current.id%>
+
+
+
+
+
+ <%= link_to(
+ l(:button_edit),
+ {:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == activity.author.id %>
+
+
+ <%= link_to(
+ l(:button_delete),
+ {:controller => 'blog_comments',:action => 'destroy',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
+ :method => :delete,
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == activity.author.id %>
+
+
+ <% if activity.id == activity.blog.homepage_id %>
+ <%= link_to(
+ l(:button_cancel_homepage),
+ {:controller => 'blogs',:action => 'cancel_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
+ :method => :post,
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == activity.blog.author_id %>
+ <% else %>
+ <%= link_to(
+ l(:button_set_homepage),
+ {:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
+ :method => :post,
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == activity.blog.author_id %>
+ <% end %>
+
+
+
+
+
+ <%end%>
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
+ <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
+ 已设为首页
+ <% end %>
+
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey" %>
+ <% else %>
+ <%= 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=> "postGrey"%>
+ <% end %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+ <% if activity.locked%>
+
+ <% end%>
+
+
+ 发帖时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(activity.updated_on) %>
+
+
+ <% if activity.parent_id.nil? %>
+ <% content= activity.content%>
+ <% else %>
+ <% content= activity.parent.content%>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+
+
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+
+ <% count=0 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#=format_date(activity.updated_on)%>
+ <%if count > 3 %>
+
+ <% end %>
+
+
+ <% activity= activity.parent ? activity.parent : activity%>
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply|%>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.author == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <%= reply.content.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !activity.locked? %>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%>
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+ <% end %>
+
+
+
diff --git a/app/views/courses/_new_member_list.html.erb b/app/views/courses/_new_member_list.html.erb
index 35d9fe399..fd33d5a19 100644
--- a/app/views/courses/_new_member_list.html.erb
+++ b/app/views/courses/_new_member_list.html.erb
@@ -1,81 +1,81 @@
-
-
- <% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
- <%= join_in_course_group(@course.course_groups,@group, User.current) unless @canShowCode %>
-
- <%= l(:label_current_group)%>:
- <%= @group.name %>
-
- <% end %>
-
-
-
-<% if members.any? %>
- <% if @result_count %>
-
- <%= l(:label_search_member_count) %>
- <%= @result_count %>
- <%= l(:label_member_people) %>
-
-
- <% end %>
-
-
-
- 姓名
- 学号
-
- <%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
- <% if @score_sort_by == 'desc' %>
-
- <% else %>
-
- <% end %>
-
- 加入时间
-
-
-
- <% members.each do |member| %>
-
-
- <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %>
-
-
- <% if @canShowCode %>
-
- <% if member.user.show_name == ''%>
- <%= link_to("#{l(:label_bidding_user_studentname)}:#{member.user.name} ".html_safe,user_path(member.user)) %>
- <% else%>
- <%= link_to("#{l(:label_bidding_user_studentname)}:#{member.user.show_name} ".html_safe,user_path(member.user)) %>
- <%end%>
-
- <% else %>
- <%= link_to("#{l(:label_bidding_user_studentname)}:#{member.user.name} ".html_safe, user_path(member.user)) %>
- <% end %>
-
- <% unless member.user.user_extensions.student_id == ''%>
- <%= link_to("#{l(:label_bidding_user_studentcode)}:#{member.user.user_extensions.student_id} ".html_safe,user_path(member.user)) %>
- <% end%>
-
- <%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
- :action => 'show_member_score',
- :member_id => member.id,
- :remote => true},
- :class => 'ml258 c_red' %>
-
<%= format_date(member.created_on)%>
- <%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
-
-
- <% end; reset_cycle %>
-
-
-
-<% else%>
-
- <%= l(:label_no_data) %>
-
-<% end%>
-
+
+
+ <% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
+ <%= join_in_course_group(@course.course_groups,@group, User.current) unless @canShowCode %>
+
+ <%= l(:label_current_group)%>:
+ <%= @group.name %>
+
+ <% end %>
+
+
+
+<% if members.any? %>
+ <% if @result_count %>
+
+ <%= l(:label_search_member_count) %>
+ <%= @result_count %>
+ <%= l(:label_member_people) %>
+
+
+ <% end %>
+
+
+
+ 姓名
+ 学号
+
+ <%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
+ <% if @score_sort_by == 'desc' %>
+
+ <% else %>
+
+ <% end %>
+
+ 加入时间
+
+
+
+ <% members.each do |member| %>
+
+
+ <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %>
+
+
+ <% if @canShowCode %>
+
+ <% if member.user.show_name == ''%>
+ <%= link_to("#{l(:label_bidding_user_studentname)}:#{member.user.name} ".html_safe,user_path(member.user)) %>
+ <% else%>
+ <%= link_to("#{l(:label_bidding_user_studentname)}:#{member.user.show_name} ".html_safe,user_path(member.user)) %>
+ <%end%>
+
+ <% else %>
+ <%= link_to("#{l(:label_bidding_user_studentname)}:#{member.user.name} ".html_safe, user_path(member.user)) %>
+ <% end %>
+
+ <% unless member.user.user_extensions.student_id == ''%>
+ <%= link_to("#{l(:label_bidding_user_studentcode)}:#{member.user.user_extensions.student_id} ".html_safe,user_path(member.user)) %>
+ <% end%>
+
+ <%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
+ :action => 'show_member_score',
+ :member_id => member.id,
+ :remote => true},
+ :class => 'ml258 c_red' %>
+
<%= format_date(member.created_on)%>
+ <%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
+
+
+ <% end; reset_cycle %>
+
+
+
+<% else%>
+
+ <%= l(:label_no_data) %>
+
+<% end%>
+
diff --git a/app/views/courses/_recommendation.html.erb b/app/views/courses/_recommendation.html.erb
index f26c5fd41..f697383ca 100644
--- a/app/views/courses/_recommendation.html.erb
+++ b/app/views/courses/_recommendation.html.erb
@@ -6,7 +6,7 @@
<%= image_tag(url_to_avatar(e_course), :width => "40", :height => "40", :class => "fl mr10 rankPortrait", :alt => "logo") %>
-
<%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %>
+
<%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %>
<% if e_course.attachments.count > 0 %>
<%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)
@@ -14,6 +14,7 @@
<% if e_course.homework_commons.count > 0 %>
<%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)
<% end %>
+
diff --git a/app/views/courses/syllabus.html.erb b/app/views/courses/syllabus.html.erb
index e12876ce9..8be245958 100644
--- a/app/views/courses/syllabus.html.erb
+++ b/app/views/courses/syllabus.html.erb
@@ -1,218 +1,218 @@
-
-<%= content_for(:header_tags) do %>
- <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
- <%= javascript_include_tag 'blog' %>
-<% end %>
-
-
-
-
-
-
- <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
-
-
- <% if User.current && @article.author.id == User.current.id%>
-
-
-
-
-
- 重设大纲
-
-
- <%= link_to(
- '取消大纲',
- {:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id},
- :method => :delete,
- :data => {:confirm => '您确定要取消么?'},
- :class => 'postOptionLink'
- ) if User.current && User.current.id == @article.author.id %>
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%end%>
-
-
-
-
- <% if @article.try(:author).try(:realname) == ' ' %>
- <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
- <% else %>
- <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
- <% end %>
-
-
<%= format_time( @article.created_on)%>
-
-
- <%= @article.content.html_safe%>
-
-
-
- <%#= link_to_attachments_course @topic, :author => false %>
- <% if @article.attachments.any?%>
- <% options = {:author => true, :deletable => false} %>
- <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %>
- <% end %>
-
-
-
-
-
- <% count=0 %>
- <% if @article.parent %>
- <% count=@article.parent.children.count%>
- <% else %>
- <% count=@article.children.count%>
- <% end %>
-
- <% unless count == 0 %>
-
-
- <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %>
-
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
-
-
- <%= reply.content.html_safe%>
-
-
- <%= format_time(reply.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if !@article.locked? && User.current.logged?%>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@article.author_id), :alt => "用户头像" %>
-
-
- <%= form_for 'blog_comment',:url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id},:method => "post",:html => {:multipart => true, :id => 'message_form'} do |f|%>
-
-
-
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
- <% end %>
-
-
-
+
+
+
+
+ <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
+
+
+ <% if User.current && @article.author.id == User.current.id%>
+
+
+
+
+
+ 重设大纲
+
+
+ <%= link_to(
+ '取消大纲',
+ {:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id},
+ :method => :delete,
+ :data => {:confirm => '您确定要取消么?'},
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == @article.author.id %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%end%>
+
+
+
+
+ <% if @article.try(:author).try(:realname) == ' ' %>
+ <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% else %>
+ <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% end %>
+
+
<%= format_time( @article.created_on)%>
+
+
+ <%= @article.content.html_safe%>
+
+
+
+ <%#= link_to_attachments_course @topic, :author => false %>
+ <% if @article.attachments.any?%>
+ <% options = {:author => true, :deletable => false} %>
+ <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %>
+ <% end %>
+
+
+
+
+
+ <% count=0 %>
+ <% if @article.parent %>
+ <% count=@article.parent.children.count%>
+ <% else %>
+ <% count=@article.children.count%>
+ <% end %>
+
+ <% unless count == 0 %>
+
+
+ <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% end %>
+
+
+ <%= reply.content.html_safe%>
+
+
+ <%= format_time(reply.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !@article.locked? && User.current.logged?%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@article.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for 'blog_comment',:url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id},:method => "post",:html => {:multipart => true, :id => 'message_form'} do |f|%>
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb
index 4c5c922f0..4c8dfa1d9 100644
--- a/app/views/issues/_issue_replies.html.erb
+++ b/app/views/issues/_issue_replies.html.erb
@@ -1,86 +1,86 @@
-
- <% issue.journals.reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:user).try(:realname) == ' ' %>
- <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%#= format_time(reply.created_on) %>
-
-
- <% if reply.details.any? %>
- <% details_to_strings(reply.details).each do |string| %>
-
<%= string %>
- <% end %>
- <% end %>
-
<%= reply.notes.html_safe %>
-
-
- <%= format_time(reply.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
-
-
- <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@issue.author_id), :alt => "用户头像" %>
-
-
-
-
- <%= form_for('new_form',:url => add_journal_issue_path(@issue.id),:method => "post", :remote => true) do |f| %>
- <%#= kindeditor_tag :notes,"",:height=>"33",:minHeight=>"33",:editor_id=>"issues_reply_editor"%>
-
-
-
-
-
-
-
- <%= render :partial => 'attachments/issue_reply', :locals => {:container => @issue} %>
-
-
-
发送
-
- <% end %>
-
-
-
-
-
-
+
+ <% issue.journals.reorder("created_on desc").each do |reply| %>
+
+ <% replies_all_i=replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:user).try(:realname) == ' ' %>
+ <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%#= format_time(reply.created_on) %>
+
+
+ <% if reply.details.any? %>
+ <% details_to_strings(reply.details).each do |string| %>
+
<%= string %>
+ <% end %>
+ <% end %>
+
<%= reply.notes.html_safe %>
+
+
+ <%= format_time(reply.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+
+
+ <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@issue.author_id), :alt => "用户头像" %>
+
+
+
+
+ <%= form_for('new_form',:url => add_journal_issue_path(@issue.id),:method => "post", :remote => true) do |f| %>
+ <%#= kindeditor_tag :notes,"",:height=>"33",:minHeight=>"33",:editor_id=>"issues_reply_editor"%>
+
+
+
+
+
+
+
+ <%= render :partial => 'attachments/issue_reply', :locals => {:container => @issue} %>
+
+
+
发送
+
+ <% end %>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/issues/_issue_reply_ke_form.html.erb b/app/views/issues/_issue_reply_ke_form.html.erb
index e84d5905c..a2975237b 100644
--- a/app/views/issues/_issue_reply_ke_form.html.erb
+++ b/app/views/issues/_issue_reply_ke_form.html.erb
@@ -1,27 +1,27 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@issue.author_id), :alt => "用户头像" %>
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@issue.author_id), :alt => "用户头像" %>
+
+
+
\ No newline at end of file
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 2a44f2980..8f6628b62 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -143,18 +143,19 @@
<% unless contributor_course_scor(@course.id).count == 0 %>
-
-
积分规则
- 资源发布:资源数 x 5
- 问答发布:发帖数 x 2
- 通知发布:通知数 x 1
- 问答回复:回复数 x 1
- 作业留言:留言数 x 1
- 通知留言:留言数 x 1
- 课程留言:留言数 x 1
- 总得分为以上得分之和
+
+
+ 积分规则
+ 资源发布:资源数 x 5
+ 问答发布:发帖数 x 2
+ 通知发布:通知数 x 1
+ 问答回复:回复数 x 1
+ 作业留言:留言数 x 1
+ 通知留言:留言数 x 1
+ 课程留言:留言数 x 1
+ 总得分为以上得分之和
<% contributor_course_scor(@course.id).each do |contributor_score| %>
@@ -163,13 +164,13 @@
+ contributor_score.homework_journal_num.to_i * 1 + contributor_score.news_reply_num.to_i * 1 +
contributor_score.news_num.to_i * 1 %>
<% unless total_score ==0 %>
-
<%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %>
- <%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %>
+ <%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %>
+ <%=link_to contributor_score.user.show_name, user_path(contributor_score.user.id), :title => contributor_score.user.show_name %>
<%=total_score %>
-
-
积分计算
+
+
积分计算
<%# unless contributor_score.resource_num.to_i == 0 %>
资源发布数 x 5 = <%= contributor_score.resource_num.to_i %> x 5 = <%= contributor_score.resource_num.to_i * 5 %>
@@ -208,10 +209,11 @@
<% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %>
-
-
积分规则
+
积分规则
+
+
积分规则
英雄榜的得分是每个同学作业的得分总和
+
<% hero_homework_scores.each do |student_score| %>
<% if student_score.score.to_i != 0 %>
diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb
index 16bc5c742..4feb998cf 100644
--- a/app/views/memos/show.html.erb
+++ b/app/views/memos/show.html.erb
@@ -113,7 +113,7 @@
<%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %>
-
发送
+
发送
<% end%>
diff --git a/app/views/messages/_reply_message.html.erb b/app/views/messages/_reply_message.html.erb
index 2d957dbda..faa0bd0ce 100644
--- a/app/views/messages/_reply_message.html.erb
+++ b/app/views/messages/_reply_message.html.erb
@@ -1,19 +1,19 @@
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
-
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
\ No newline at end of file
diff --git a/app/views/org_document_comments/_simple_ke_reply_form.html.erb b/app/views/org_document_comments/_simple_ke_reply_form.html.erb
index 44eb71500..1813f5b5f 100644
--- a/app/views/org_document_comments/_simple_ke_reply_form.html.erb
+++ b/app/views/org_document_comments/_simple_ke_reply_form.html.erb
@@ -1,18 +1,18 @@
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
-
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
\ No newline at end of file
diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb
index 0dd9fb725..a437acc7e 100644
--- a/app/views/organizations/_org_course_homework.html.erb
+++ b/app/views/organizations/_org_course_homework.html.erb
@@ -154,8 +154,18 @@
<% end %>
<% student_works.each_with_index do |sw, i| %>
-
<%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %>
- <%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%>
+
+ <% if User.current.member_of_course?(activity.course) || User.current.admin? || activity.is_open == 1 %>
+ <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %>
+
+ <%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%>
+
+ <% else %>
+ <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '该作业的作品暂未公开') %>
+
+ <%=sw.user.show_name %>
+
+ <% end %>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
分数:<%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分
@@ -346,7 +356,7 @@
<%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
-
发送
+
发送
<% end%>
diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb
index 99229634e..4873fbba9 100644
--- a/app/views/organizations/_org_course_message.html.erb
+++ b/app/views/organizations/_org_course_message.html.erb
@@ -144,7 +144,7 @@
-
发送
+
发送
<% end%>
diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb
index ecdf728f8..3da0887ed 100644
--- a/app/views/organizations/_org_course_news.html.erb
+++ b/app/views/organizations/_org_course_news.html.erb
@@ -1,123 +1,123 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if @ctivity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
-
-
- <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% count=activity.comments.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_url_in_org(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if @ctivity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
+
+
+ <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% count=activity.comments.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.comments.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_url_in_org(comment.author_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:author).try(:realname) == ' ' %>
+ <%= link_to comment.try(:author), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:author).try(:realname), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb
index 855a8053c..782412e43 100644
--- a/app/views/organizations/_org_project_issue.html.erb
+++ b/app/views/organizations/_org_project_issue.html.erb
@@ -1,141 +1,141 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%>
-
-
- <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %>
-
- <%#= get_issue_priority(activity.priority_id)[1] %>
-
-
-
-
指派给
- <% unless activity.assigned_to_id.nil? %>
- <% if activity.try(:assigned_to).try(:realname) == ' ' %>
- <%= link_to activity.try(:assigned_to), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:assigned_to).try(:realname), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %>
- <% end %>
- <% end %>
-
-
- 发布时间:
- <%=format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
-
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% count = activity.journals.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <% if count > 3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.journals.reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_url_in_org(reply.user_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:user).try(:realname) == ' ' %>
- <%= link_to reply.try(:user), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:user).try(:realname), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.user == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <% if reply.details.any? %>
- <% details_to_strings(reply.details).each do |string| %>
-
<%= string %>
- <% end %>
- <% end %>
-
<%= reply.notes.nil? ? "" : reply.notes.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => add_journal_in_org_issue_path(activity.id),:method => "post", :remote => true) do |f|%>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%>
+
+
+ <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %>
+
+ <%#= get_issue_priority(activity.priority_id)[1] %>
+
+
+
+
指派给
+ <% unless activity.assigned_to_id.nil? %>
+ <% if activity.try(:assigned_to).try(:realname) == ' ' %>
+ <%= link_to activity.try(:assigned_to), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:assigned_to).try(:realname), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %>
+ <% end %>
+ <% end %>
+
+
+ 发布时间:
+ <%=format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
+
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% count = activity.journals.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <% if count > 3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.journals.reorder("created_on desc").each do |reply| %>
+
+ <% replies_all_i=replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_url_in_org(reply.user_id), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:user).try(:realname) == ' ' %>
+ <%= link_to reply.try(:user), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:user).try(:realname), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.user == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <% if reply.details.any? %>
+ <% details_to_strings(reply.details).each do |string| %>
+
<%= string %>
+ <% end %>
+ <% end %>
+
<%= reply.notes.nil? ? "" : reply.notes.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => add_journal_in_org_issue_path(activity.id),:method => "post", :remote => true) do |f|%>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
diff --git a/app/views/organizations/_org_subfield_message.html.erb b/app/views/organizations/_org_subfield_message.html.erb
index aa2493c5f..bf0cc8734 100644
--- a/app/views/organizations/_org_subfield_message.html.erb
+++ b/app/views/organizations/_org_subfield_message.html.erb
@@ -1,161 +1,161 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% end %>
- TO
- <%= link_to activity.board.org_subfield.name.to_s+" | 帖子栏目讨论区",organization_path(activity.board.org_subfield.organization, :org_subfield_id => activity.board.org_subfield.id), :class => "newsBlue ml15 mr5"%>
-
-
- <% if activity.parent_id.nil? %>
- <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
- %>
- <% else %>
- <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
- %>
- <% end %>
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(OrgActivity.where("org_act_type='#{activity.class}' and org_act_id =#{activity.id}").first.updated_at) %>
-
-
- <% if activity.parent_id.nil? %>
- <% content = activity.content%>
- <% else %>
- <% content = activity.parent.content%>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% if User.current.logged? %>
-
- <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'message')") %>
-
- <%= link_to(
- l(:button_edit),
- {:controller => 'messages', :action => 'edit', :id => activity, :board_id => activity.board_id},
- :class => 'postOptionLink'
- ) if activity.org_subfield_editable_by?(User.current) %>
-
-
- <%= link_to(
- l(:button_delete),
- {:controller => 'messages', :action => 'destroy', :id => activity, :board_id => activity.board_id},
- :method => 'post',
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'postOptionLink'
- ) if activity.org_subfield_editable_by?(User.current) %>
-
-
- <% end %>
-
-
-
-
-
-
- <% count = 0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
- <%if count>3 %>
-
- <% end %>
-
-
- <% activity= activity.parent_id.nil? ? activity : activity.parent %>
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i+1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.author == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <%= reply.content.html_safe %>
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.board.org_subfield.name.to_s+" | 帖子栏目讨论区",organization_path(activity.board.org_subfield.organization, :org_subfield_id => activity.board.org_subfield.id), :class => "newsBlue ml15 mr5"%>
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
+ %>
+ <% else %>
+ <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
+ %>
+ <% end %>
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(OrgActivity.where("org_act_type='#{activity.class}' and org_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <% if activity.parent_id.nil? %>
+ <% content = activity.content%>
+ <% else %>
+ <% content = activity.parent.content%>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% if User.current.logged? %>
+
+ <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'message')") %>
+
+ <%= link_to(
+ l(:button_edit),
+ {:controller => 'messages', :action => 'edit', :id => activity, :board_id => activity.board_id},
+ :class => 'postOptionLink'
+ ) if activity.org_subfield_editable_by?(User.current) %>
+
+
+ <%= link_to(
+ l(:button_delete),
+ {:controller => 'messages', :action => 'destroy', :id => activity, :board_id => activity.board_id},
+ :method => 'post',
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if activity.org_subfield_editable_by?(User.current) %>
+
+
+ <% end %>
+
+
+
+
+
+
+ <% count = 0 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% activity= activity.parent_id.nil? ? activity : activity.parent %>
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply| %>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.author == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <%= reply.content.html_safe %>
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
diff --git a/app/views/organizations/_org_subfield_news.html.erb b/app/views/organizations/_org_subfield_news.html.erb
index edbdfa16b..3d2a316cf 100644
--- a/app/views/organizations/_org_subfield_news.html.erb
+++ b/app/views/organizations/_org_subfield_news.html.erb
@@ -1,146 +1,146 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.org_subfield.name.to_s+" | 帖子栏目通知", organization_path(activity.org_subfield.organization, :org_subfield_id => activity.org_subfield.id), :class => "newsBlue ml15" %>
-
-
- <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
-
-
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% if User.current.logged? %>
-
- <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
-
- <%= link_to(
- l(:button_edit),
- {:controller => 'news', :action => 'edit', :id => activity},
- :class => 'postOptionLink'
- ) if activity.author == User.current %>
-
-
- <%= delete_link(
- news_path(activity),
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'postOptionLink'
- ) if activity.author == User.current %>
-
-
- <% end %>
-
-
-
-
-
-
- <% count=activity.comments.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_url_in_org(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.org_subfield.name.to_s+" | 帖子栏目通知", organization_path(activity.org_subfield.organization, :org_subfield_id => activity.org_subfield.id), :class => "newsBlue ml15" %>
+
+
+ <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
+
+
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% if User.current.logged? %>
+
+ <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
+
+ <%= link_to(
+ l(:button_edit),
+ {:controller => 'news', :action => 'edit', :id => activity},
+ :class => 'postOptionLink'
+ ) if activity.author == User.current %>
+
+
+ <%= delete_link(
+ news_path(activity),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if activity.author == User.current %>
+
+
+ <% end %>
+
+
+
+
+
+
+ <% count=activity.comments.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.comments.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_url_in_org(comment.author_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:author).try(:realname) == ' ' %>
+ <%= link_to comment.try(:author), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:author).try(:realname), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb
index 3b459f366..99a067dfb 100644
--- a/app/views/organizations/_project_message.html.erb
+++ b/app/views/organizations/_project_message.html.erb
@@ -1,136 +1,136 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
- <% end %>
- TO
- <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%>
-
-
-
- <% if activity.parent_id.nil? %>
- <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
- %>
- <% else %>
- <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
- %>
- <% end %>
-
-
- 发帖时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
-
-
- <% if activity.parent_id.nil? %>
- <% content = activity.content%>
- <% else %>
- <% content = activity.parent.content%>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% count = 0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#=format_date(activity.updated_on)%>
- <%if count>3 %>
-
- <% end %>
-
-
- <% activity= activity.parent_id.nil? ? activity : activity.parent %>
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i+1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.author == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <%= reply.content.html_safe %>
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%>
+
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
+ %>
+ <% else %>
+ <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey"
+ %>
+ <% end %>
+
+
+ 发帖时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <% if activity.parent_id.nil? %>
+ <% content = activity.content%>
+ <% else %>
+ <% content = activity.parent.content%>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% count = 0 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#=format_date(activity.updated_on)%>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% activity= activity.parent_id.nil? ? activity : activity.parent %>
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply| %>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.author == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <%= reply.content.html_safe %>
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb
index 2584e4209..ed6e1e092 100644
--- a/app/views/organizations/_show_org_document.html.erb
+++ b/app/views/organizations/_show_org_document.html.erb
@@ -1,152 +1,152 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(User.find(document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(document.creator_id) %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => User.find(document.creator_id)} %>
-
-
-
- <%= link_to User.find(document.creator_id), user_url_in_org(document.creator.id), :class => "newsBlue mr15" %>
- TO <%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %>
- |
- <%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %>
-
-
<%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
-
- 发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
-
-
- 更新时间:<%= format_time(OrgActivity.where("org_act_type='#{document.class}' and org_act_id =#{document.id}").first.updated_at) %>
-
-
- <% unless document.content.blank? %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>document.id, :content=>document.content} %>
- <% end %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => document} %>
-
-
- <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %>
-
-
-
-
-
- <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id, :show_homepage => 1}, :method => "put", :remote => true) do |f| %>
- 设为首页
- <% end %>
-
-
- <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag, :org_subfield_id => params[:org_subfield_id] ), :class => "postOptionLink" %>
-
-
- <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete',
- :data => {:confirm => l(:text_are_you_sure)},
- :remote => true, :class => 'postOptionLink' %>
-
-
-
-
-
-
- <% end %>
-
-
- <% comments_for_doc = document.children.reorder("created_at desc") %>
- <% count = document.children.count() %>
-
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if document.creator_id.to_i == User.current.id.to_i %>
- 赞 <%= get_praise_num(document) > 0 ? "(#{get_praise_num(document)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>document, :user_activity_id=>document.id,:type=>"activity"}%>
- <% end %>
-
-
- <% if count > 3 %>
-
- <% end %>
-
-
-
- <% reply_id = 0 %>
- <% comments_for_doc.each do |comment| %>
- <% reply_id += 1 %>
-
- <%= link_to image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_id) %>
-
-
- <%= link_to User.find(comment.creator_id), user_url_in_org(comment.creator_id), :class => "newsBlue mr10 f14" %>
- <%= format_activity_day(comment.created_at) %> <%= format_time(comment.created_at, false) %>
-
-
- <% unless comment.content.blank? %>
-
<%= comment.content.html_safe %>
- <% end %>
-
-
-
- <% end %>
-
-
-
-
- <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current) %>
-
-
-
- <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id, :flag => flag), :method => "post", :remote => true) do |f| %>
-
-
-
-
发送
-
-
-
- <% end %>
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/views/projects/_project_news.html.erb b/app/views/projects/_project_news.html.erb
index 518ee3a2b..4ea0e9f17 100644
--- a/app/views/projects/_project_news.html.erb
+++ b/app/views/projects/_project_news.html.erb
@@ -1,123 +1,123 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.project.name.to_s+" | 项目新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %>
-
-
- <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% count=activity.comments.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.project.name.to_s+" | 项目新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %>
+
+
+ <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% count=activity.comments.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.comments.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:author).try(:realname) == ' ' %>
+ <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 76d5745df..750a3c6ec 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -1,81 +1,81 @@
-<%= call_hook(:view_repositories_show_contextual, {:repository => @repository, :project => @project}) %>
-
-
<%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
-
-
- <% if @entries.nil? %>
- <%# 未提交代码提示 %>
-
- <% if @entries.nil? && authorize_for('repositories', 'browse') %>
-
- 该版本库还没有上传代码!
-
- <% end %>
- <% if @repository.type.to_s=="Repository::Gitlab" %>
- 版本库地址:<%= @repos_url %>
- <% else %>
- 版本库地址:<%= h @repository.url %>
- <% end %>
-
-
-
- <% else %>
- <%= render :partial => 'navigation' %>
-
克隆网址:
-
-
-
- <%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %>
- <% if User.current.id != @project.user_id %>
-
<%= link_to " ".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn", :confirm=>"平台将为您创建一个新的同名项目和版本库,请问是否继续?" %>
- <%= @project.forked_count.to_i %>
-
- <% end %>
-
-
- <% if @changesets && !@changesets.empty? %>
- <% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %>
- <%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
-
<%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %>
- 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
- <%= @changesets_latest_coimmit.message %>
-
- <% else %>
-
<%=@changesets_latest_coimmit.author_email %>
- 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
- <%= @changesets_latest_coimmit.message %>
-
- <%end%>
- <% end %>
-
- <%= @repository.branches.count %> 个分支
-
-
-
- <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> 提交
-
-
-
- <% end %>
-
-
-
-<% if !@entries.nil? && authorize_for('repositories', 'browse') %>
- <%# 数据统计 %>
- <%#= render :partial => 'summary' %>
- <%# end %>
- <%= render :partial => 'dir_list' %>
-<% end %>
-<%#= render_properties(@properties) %>
-
-
-<%#= render_properties(@properties) %>
-
-
-
如何提交代码
-
-<% content_for :header_tags do %>
- <%= stylesheet_link_tag "scm" %>
-<% end %>
-
-<% html_title(l(:label_repository)) -%>
+<%= call_hook(:view_repositories_show_contextual, {:repository => @repository, :project => @project}) %>
+
+
<%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
+
+
+ <% if @entries.nil? %>
+ <%# 未提交代码提示 %>
+
+ <% if @entries.nil? && authorize_for('repositories', 'browse') %>
+
+ 该版本库还没有上传代码!
+
+ <% end %>
+ <% if @repository.type.to_s=="Repository::Gitlab" %>
+ 版本库地址:<%= @repos_url %>
+ <% else %>
+ 版本库地址:<%= h @repository.url %>
+ <% end %>
+
+
+
+ <% else %>
+ <%= render :partial => 'navigation' %>
+
克隆网址:
+
+
+
+ <%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %>
+ <% if User.current.id != @project.user_id %>
+
<%= link_to " ".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn", :target => "_blank", :confirm=>"平台将为您创建一个新的同名项目和版本库,请问是否继续?" %>
+ <%= @project.forked_count.to_i %>
+
+ <% end %>
+
+
+ <% if @changesets && !@changesets.empty? %>
+ <% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %>
+ <%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
+
<%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %>
+ 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
+ <%= @changesets_latest_coimmit.message %>
+
+ <% else %>
+
<%=@changesets_latest_coimmit.author_email %>
+ 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
+ <%= @changesets_latest_coimmit.message %>
+
+ <%end%>
+ <% end %>
+
+ <%= @repository.branches.count %> 个分支
+
+
+
+ <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> 提交
+
+
+
+ <% end %>
+
+
+
+<% if !@entries.nil? && authorize_for('repositories', 'browse') %>
+ <%# 数据统计 %>
+ <%#= render :partial => 'summary' %>
+ <%# end %>
+ <%= render :partial => 'dir_list' %>
+<% end %>
+<%#= render_properties(@properties) %>
+
+
+<%#= render_properties(@properties) %>
+
+
+
如何提交代码
+
+<% content_for :header_tags do %>
+ <%= stylesheet_link_tag "scm" %>
+<% end %>
+
+<% html_title(l(:label_repository)) -%>
diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb
index bf022f64c..884bb8eb1 100644
--- a/app/views/student_work/_evaluation_un_work.html.erb
+++ b/app/views/student_work/_evaluation_un_work.html.erb
@@ -1,102 +1,102 @@
-
-
-
-
-
- <%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40"),user_activities_path(student_work.user)) %>
-
-
-
- <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
-
- <%= link_to student_work_name,"javascript:void(0)" ,:title => student_work_name, :class => "linkGrey f14 StudentName break_word #{@homework.homework_type == 2 ? '' : 'width165'}"%>
-
-
-
- <% if @homework.homework_type != 3 %>
-
-
- <%= student_work.user.show_name%>
-
-
- <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
-
-
- <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
-
-
- <%= student_work.project.name %>
-
-
- <% end %>
-
-
-
-
-
- <% if student_work.created_at && @homework.end_time%>
- <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
- <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
- [迟交]
- <% end %>
- <% end %>
-
-
- <%= student_work.teacher_score.nil? ? "--" : format("%.1f",student_work.teacher_score)%>
-
-
- <%= student_work.teaching_asistant_score.nil? ? "--" : format("%.1f",student_work.teaching_asistant_score)%>
-
-
- <% if @homework.homework_type == 2%>
-
-
- <%= student_work.system_score.nil? ? "--" : format("%.1f",student_work.system_score)%>
-
- <% end%>
-
- <% if @homework.anonymous_comment == 0%>
-
- <%= student_work.student_score.nil? ? "未参与" : format("%.1f",student_work.student_score)%>
- <% unless student_work.student_score.nil?%>
-
- (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>)
-
-
- 现共有
- <%= student_work.student_works_scores.where(:reviewer_role => 3).count%>
- 名学生进行了匿评,平均分为
- <%= format("%.1f",student_work.student_score)%> 分。
-
- <% end%>
-
- <% end %>
-
- <% score = student_work.respond_to?("score") ? student_work.score : (student_work.final_score || 0) - student_work.absence_penalty - student_work.late_penalty%>
-
- <%= score.nil? ? "--" : format("%.1f",score<0 ? 0 : score)%>
- <% unless score.nil?%>
-
- 作品最终评分为
- <%= student_work.final_score%> 分。
- 迟交扣分
- <%= student_work.late_penalty%> 分,
- 缺评扣分
- <%= student_work.absence_penalty%> 分,
- 最终成绩为
- <%= format("%.1f",score<0 ? 0 : score)%> 分。
-
- <% end%>
-
- 点击查看详情
-
-
-
+
+
+
+
+
+ <%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40"),user_activities_path(student_work.user)) %>
+
+
+
+ <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
+
+ <%= link_to student_work_name,"javascript:void(0)" ,:title => student_work_name, :class => "linkGrey f14 StudentName break_word #{@homework.homework_type == 2 ? '' : 'width165'}"%>
+
+
+
+ <% if @homework.homework_type != 3 %>
+
+
+ <%= student_work.user.show_name%>
+
+ ">
+ <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
+
+
+ <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
+
+
+ <%= student_work.project.name %>
+
+
+ <% end %>
+
+
+
+
+
+ <% if student_work.created_at && @homework.end_time%>
+ <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
+ <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
+ [迟交]
+ <% end %>
+ <% end %>
+
+
+ <%= student_work.teacher_score.nil? ? "--" : format("%.1f",student_work.teacher_score)%>
+
+
+ <%= student_work.teaching_asistant_score.nil? ? "--" : format("%.1f",student_work.teaching_asistant_score)%>
+
+
+ <% if @homework.homework_type == 2%>
+
+
+ <%= student_work.system_score.nil? ? "--" : format("%.1f",student_work.system_score)%>
+
+ <% end%>
+
+ <% if @homework.anonymous_comment == 0%>
+
+ <%= student_work.student_score.nil? ? "未参与" : format("%.1f",student_work.student_score)%>
+ <% unless student_work.student_score.nil?%>
+
+ (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>)
+
+
+ 现共有
+ <%= student_work.student_works_scores.where(:reviewer_role => 3).count%>
+ 名学生进行了匿评,平均分为
+ <%= format("%.1f",student_work.student_score)%> 分。
+
+ <% end%>
+
+ <% end %>
+
+ <% score = student_work.respond_to?("score") ? student_work.score : (student_work.final_score || 0) - student_work.absence_penalty - student_work.late_penalty%>
+
+ <%= score.nil? ? "--" : format("%.1f",score<0 ? 0 : score)%>
+ <% unless score.nil?%>
+
+ 作品最终评分为
+ <%= student_work.final_score%> 分。
+ 迟交扣分
+ <%= student_work.late_penalty%> 分,
+ 缺评扣分
+ <%= student_work.absence_penalty%> 分,
+ 最终成绩为
+ <%= format("%.1f",score<0 ? 0 : score)%> 分。
+
+ <% end%>
+
+ 点击查看详情
+
+
+
diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb
index cc346361e..f97a8dd2d 100644
--- a/app/views/student_work/_evaluation_work.html.erb
+++ b/app/views/student_work/_evaluation_work.html.erb
@@ -21,10 +21,10 @@
<% if @homework.homework_type != 3 %>
-
+
<%= student_work.user.show_name%>
-
+ ">
<%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb
index d6977325c..8e7c58dc3 100644
--- a/app/views/student_work/_programing_work_show.html.erb
+++ b/app/views/student_work/_programing_work_show.html.erb
@@ -25,7 +25,7 @@
编程代码:
- <%= work.description if work.description%>
+
<%= work.description if work.description%>
diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb
index 1eea8f1c2..53e57fd9c 100644
--- a/app/views/student_work/_student_work_list.html.erb
+++ b/app/views/student_work/_student_work_list.html.erb
@@ -63,7 +63,7 @@
} else if(language==4){
program_name = 'text/x-java';
}
- var editor = CodeMirror(document.getElementById("work-code"), {
+ var editor = CodeMirror(document.getElementById("work-code_<%= work.id%>"), {
mode: {name: program_name,
version: 2,
singleLineStringErrors: false},
diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb
index 477f06e0f..c89180b16 100644
--- a/app/views/student_work/show.js.erb
+++ b/app/views/student_work/show.js.erb
@@ -1,36 +1,36 @@
-if($("#about_hwork_<%= @work.id%>").children().length > 0){
- $("#about_hwork_<%= @work.id%>").html("");
-}
-else{
- <% if @homework.homework_type == 2%>
- $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>");
-
- var program_name = "text/x-csrc";
- var language = <%= @homework.language %>;
- if (language == 1) {
- program_name = 'text/x-csrc';
- } else if(language==2){
- program_name = 'text/x-c++src';
- }else if(language==3){
- program_name = 'text/x-cython';
- } else if(language==4){
- program_name = 'text/x-java';
- }
-
- var editor = CodeMirror(document.getElementById("work-code"), {
- mode: {name: program_name,
- version: 2,
- singleLineStringErrors: false},
- lineNumbers: true,
- indentUnit: 2,
- matchBrackets: true,
- readOnly: true,
- value: $("#work-src").text()
- }
- );
-
- <% else%>
- $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>");
- <% end%>
- $('#score_<%= @work.id%>').peSlider({range: 'min'});
+if($("#about_hwork_<%= @work.id%>").children().length > 0){
+ $("#about_hwork_<%= @work.id%>").html("");
+}
+else{
+ <% if @homework.homework_type == 2%>
+ $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>");
+
+ var program_name = "text/x-csrc";
+ var language = <%= @homework.language %>;
+ if (language == 1) {
+ program_name = 'text/x-csrc';
+ } else if(language==2){
+ program_name = 'text/x-c++src';
+ }else if(language==3){
+ program_name = 'text/x-cython';
+ } else if(language==4){
+ program_name = 'text/x-java';
+ }
+
+ var editor = CodeMirror(document.getElementById("work-code_<%= @work.id%>"), {
+ mode: {name: program_name,
+ version: 2,
+ singleLineStringErrors: false},
+ lineNumbers: true,
+ indentUnit: 2,
+ matchBrackets: true,
+ readOnly: true,
+ value: $("#work-src").text()
+ }
+ );
+
+ <% else%>
+ $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>");
+ <% end%>
+ $('#score_<%= @work.id%>').peSlider({range: 'min'});
}
\ No newline at end of file
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb
index d42dc152d..5529998a7 100644
--- a/app/views/users/_course_homework.html.erb
+++ b/app/views/users/_course_homework.html.erb
@@ -153,8 +153,18 @@
<% end %>
<% student_works.each_with_index do |sw, i| %>
-
<%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %>
- <%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%>
+
+ <% if User.current.member_of_course?(activity.course) || User.current.admin? || activity.is_open == 1 %>
+ <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %>
+
+ <%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%>
+
+ <% else %>
+ <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '该作业的作品暂未公开') %>
+
+ <%=sw.user.show_name %>
+
+ <% end %>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
分数:<%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分
@@ -346,7 +356,7 @@
<%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb
index 6b28fb568..f9a59f024 100644
--- a/app/views/users/_course_journalsformessage.html.erb
+++ b/app/views/users/_course_journalsformessage.html.erb
@@ -1,110 +1,110 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
-
-
-
- <% if activity.try(:user).try(:realname) == ' ' %>
- <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <% course=Course.find(activity.jour_id) %>
- <%= link_to course.name.to_s+" | 课程留言", course_feedback_path(course), :class => "newsBlue ml15" %>
-
-
- <% if activity.parent %>
- <%= link_to activity.parent.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
- <% else %>
- <%= link_to activity.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
- <% end %>
-
-
- 留言时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
-
-
-
-
-
- <% count = fetch_user_leaveWord_reply(activity).count %>
-
-
-
-
- 回复(<%= count %>)
-
-
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% fetch_user_leaveWord_reply(activity).each do |comment| unless fetch_user_leaveWord_reply(activity).nil? %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
- <% end %>
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id}, :method => "post", :remote => true) do |f|%>
- <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
- <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
- <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
- <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
- <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
+
+
+
+ <% if activity.try(:user).try(:realname) == ' ' %>
+ <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <% course=Course.find(activity.jour_id) %>
+ <%= link_to course.name.to_s+" | 课程留言", course_feedback_path(course), :class => "newsBlue ml15" %>
+
+
+ <% if activity.parent %>
+ <%= link_to activity.parent.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
+ <% else %>
+ <%= link_to activity.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
+ <% end %>
+
+
+ 留言时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+
+
+
+
+
+ <% count = fetch_user_leaveWord_reply(activity).count %>
+
+
+
+
+ 回复(<%= count %>)
+
+
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% fetch_user_leaveWord_reply(activity).each do |comment| unless fetch_user_leaveWord_reply(activity).nil? %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:user).try(:realname) == ' ' %>
+ <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+ <% end %>
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id}, :method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
+ <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
+ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
+ <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb
index bb2a31dcc..df084357a 100644
--- a/app/views/users/_course_message.html.erb
+++ b/app/views/users/_course_message.html.erb
@@ -178,7 +178,7 @@
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb
index 15dd486ec..efaa72beb 100644
--- a/app/views/users/_course_news.html.erb
+++ b/app/views/users/_course_news.html.erb
@@ -1,148 +1,148 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if @ctivity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
-
-
- <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% if User.current.logged? %>
-
- <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
-
- <%= link_to(
- l(:button_edit),
- {controller:'news', :action => 'edit', :id => activity.id},
- :class => 'postOptionLink'
- ) if User.current.allowed_to?(:manage_news, activity.course) %>
-
-
- <%= delete_link(
- news_path(activity),
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'postOptionLink'
- ) if User.current.allowed_to?(:manage_news, activity.course) %>
-
-
- <% end %>
-
-
-
-
-
-
- <% count=activity.comments.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if @ctivity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
+
+
+ <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% if User.current.logged? %>
+
+ <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
+
+ <%= link_to(
+ l(:button_edit),
+ {controller:'news', :action => 'edit', :id => activity.id},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, activity.course) %>
+
+
+ <%= delete_link(
+ news_path(activity),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, activity.course) %>
+
+
+ <% end %>
+
+
+
+
+
+
+ <% count=activity.comments.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.comments.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:author).try(:realname) == ' ' %>
+ <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
diff --git a/app/views/users/_project_issue_reply.html.erb b/app/views/users/_project_issue_reply.html.erb
index adebd74ad..16d681dc9 100644
--- a/app/views/users/_project_issue_reply.html.erb
+++ b/app/views/users/_project_issue_reply.html.erb
@@ -1,89 +1,89 @@
-<% count = activity.journals.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <% if count > 3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.journals.reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:user).try(:realname) == ' ' %>
- <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.user == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <% if reply.details.any? %>
- <% details_to_strings(reply.details).each do |string| %>
-
<%= string %>
- <% end %>
- <% end %>
-
<%= reply.notes.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => add_journal_issue_path(activity.id, :user_activity_id => user_activity_id),:method => "post", :remote => true) do |f| %>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
+<% count = activity.journals.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <% if count > 3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.journals.reorder("created_on desc").each do |reply| %>
+
+ <% replies_all_i=replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:user).try(:realname) == ' ' %>
+ <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.user == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <% if reply.details.any? %>
+ <% details_to_strings(reply.details).each do |string| %>
+
<%= string %>
+ <% end %>
+ <% end %>
+
<%= reply.notes.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => add_journal_issue_path(activity.id, :user_activity_id => user_activity_id),:method => "post", :remote => true) do |f| %>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb
index 30183c4d1..dd2c832cf 100644
--- a/app/views/users/_project_message.html.erb
+++ b/app/views/users/_project_message.html.erb
@@ -154,7 +154,7 @@
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb
index 9e02c4cf4..7f5d185e5 100644
--- a/app/views/users/_project_news.html.erb
+++ b/app/views/users/_project_news.html.erb
@@ -132,7 +132,7 @@
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_upload_resource.html.erb b/app/views/users/_upload_resource.html.erb
index b72ec880b..1e691c3b7 100644
--- a/app/views/users/_upload_resource.html.erb
+++ b/app/views/users/_upload_resource.html.erb
@@ -37,8 +37,8 @@
-
(未选择文件)
-
+
(未选择文件)
+
您可以上传小于50MB 的文件
diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb
index f174e8513..d8649cabe 100644
--- a/app/views/users/_user_at_message.html.erb
+++ b/app/views/users/_user_at_message.html.erb
@@ -1,21 +1,33 @@
-<% if AtMessage === ma && ma.at_valid? %>
-
- <%=link_to image_tag(url_to_avatar(ma.author), :width => "30", :height => "30"),user_path(ma.author) %>
-
- <%= ma.author.login %> 提到了你:
-
-
- <%= link_to ma.subject.html_safe, ma.url,
- :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
标题: <%= ma.subject %>
- <% unless ma.description.nil? %>
-
内容:
-
<%= ma.description.html_safe %>
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
+<% if AtMessage === ma && ma.at_valid? %>
+
+ <%=link_to image_tag(url_to_avatar(ma.author), :width => "30", :height => "30"),user_path(ma.author) %>
+
+ <%= ma.author.login %> 提到了你:
+
+
+ <% if ma.at_message_type == "Message" && !ma.at_message.course.nil? %>
+ <%= link_to ma.subject.html_safe, course_boards_path(ma.at_message.course,
+ :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id),
+ :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+ <% elsif ma.at_message_type == "Message" && !ma.at_message.project.nil? %>
+ <%= link_to ma.subject.html_safe, project_boards_path(ma.at_message.project,
+ :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id),
+ :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+ <% else %>
+ <%= link_to ma.subject.html_safe, ma.url, :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
+ <% end %>
+
+
+
标题: <%= ma.subject %>
+ <% unless ma.description.nil? %>
+
内容:
+
<%= ma.description.html_safe %>
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
<% end %>
\ No newline at end of file
diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb
index 244951dfa..841fd9377 100644
--- a/app/views/users/_user_blog.html.erb
+++ b/app/views/users/_user_blog.html.erb
@@ -1,147 +1,147 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if @ctivity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.author.name.to_s+" | 博客", user_blogs_path(:user_id=>activity.author_id), :class => "newsBlue ml15" %>
-
-
-
- <%= link_to activity.title.to_s, user_blog_blog_comment_path(:user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id,:in_act => true), :class => "postGrey" %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
- <% if activity.locked%>
-
- <% end%>
-
-
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(UserActivity.where("act_type='#{activity.class}' and act_id =#{activity.id}").first.updated_at) %>
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.content} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% count=activity.children.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if activity.locked == false && User.current.logged?%>
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id},:method => "post", :remote => true) do |f|%>
-
-
-
-
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
- <% end %>
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if @ctivity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.author.name.to_s+" | 博客", user_blogs_path(:user_id=>activity.author_id), :class => "newsBlue ml15" %>
+
+
+
+ <%= link_to activity.title.to_s, user_blog_blog_comment_path(:user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id,:in_act => true), :class => "postGrey" %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+ <% if activity.locked%>
+
+ <% end%>
+
+
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(UserActivity.where("act_type='#{activity.class}' and act_id =#{activity.id}").first.updated_at) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.content} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% count=activity.children.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:author).try(:realname) == ' ' %>
+ <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if activity.locked == false && User.current.logged?%>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id},:method => "post", :remote => true) do |f|%>
+
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+ <% end %>
+
+
+
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb
index 0c2856c89..0c34993b7 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -157,8 +157,18 @@
<% end %>
<% student_works.each_with_index do |sw, i| %>
-
<%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id), :alt => "学生头像" %>
- <%= link_to sw.user.show_name, student_work_index_path(:homework => homework_common.id)%>
+
+ <% if User.current.member_of_course?(homework_common.course) || User.current.admin? || homework_common.is_open == 1 %>
+ <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id), :alt => "学生头像" %>
+
+ <%= link_to sw.user.show_name, student_work_index_path(:homework => homework_common.id)%>
+
+ <% else %>
+ <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '该作业的作品暂未公开') %>
+
+ <%=sw.user.show_name %>
+
+ <% end %>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
分数:<%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分
@@ -350,7 +360,7 @@
<%= hidden_field_tag 'is_in_course',params[:is_in_course],:value =>is_in_course %>
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb
index f49a65262..dde4f34ce 100644
--- a/app/views/users/_user_journalsformessage.html.erb
+++ b/app/views/users/_user_journalsformessage.html.erb
@@ -1,152 +1,152 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
-
-
-
- <%= link_to activity.user.show_name, user_path(activity.user_id), :class => "newsBlue mr15" %>
- TO
- <% if activity.jour %>
- <%= link_to activity.jour.show_name+"("+(activity.jour.login ? activity.jour.login : activity.jour.show_name ).to_s+")的"+ (activity.private == 1? "私信":"留言"),
- feedback_path(activity.jour, :host=> Setting.host_user), :class => "newsBlue ml15" %>
- <% if activity.private == 1 %>
- 私信
- <% end %>
- <% end %>
-
- <% if is_activity.to_i == 1 %>
-
- <% if activity.parent %>
- <%= link_to activity.parent.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
- <% else %>
- <%= link_to activity.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
- <% end %>
-
- <% else %>
- <% if activity.parent %>
- <% content = activity.parent.notes %>
- <% else %>
- <% content = activity.notes %>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
- <% end %>
-
- 留言时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(PrincipalActivity.where("principal_act_type='#{activity.class}' and principal_act_id =#{activity.id}").first.updated_at) %>
-
-
- <% if activity.user == User.current || User.current.admin?%>
-
-
-
-
-
- <%= link_to(l(:label_bid_respond_delete),
- {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id,:is_activity=>is_activity},
- :confirm => l(:text_are_you_sure), :method => 'delete',
- :class => "postOptionLink", :title => l(:button_delete)) %>
-
-
-
-
-
- <% end%>
-
-
-
- <% count=fetch_user_leaveWord_reply(activity).count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.user == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %>
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
- <%= comment.notes.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id},:method => "post", :remote => true) do |f|%>
- <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
- <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
- <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
- <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
- <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
- <%= hidden_field_tag 'is_activity',params[:is_activity],:value =>is_activity %>
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
+
+
+
+ <%= link_to activity.user.show_name, user_path(activity.user_id), :class => "newsBlue mr15" %>
+ TO
+ <% if activity.jour %>
+ <%= link_to activity.jour.show_name+"("+(activity.jour.login ? activity.jour.login : activity.jour.show_name ).to_s+")的"+ (activity.private == 1? "私信":"留言"),
+ feedback_path(activity.jour, :host=> Setting.host_user), :class => "newsBlue ml15" %>
+ <% if activity.private == 1 %>
+ 私信
+ <% end %>
+ <% end %>
+
+ <% if is_activity.to_i == 1 %>
+
+ <% if activity.parent %>
+ <%= link_to activity.parent.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
+ <% else %>
+ <%= link_to activity.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
+ <% end %>
+
+ <% else %>
+ <% if activity.parent %>
+ <% content = activity.parent.notes %>
+ <% else %>
+ <% content = activity.notes %>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+ <% end %>
+
+ 留言时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(PrincipalActivity.where("principal_act_type='#{activity.class}' and principal_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <% if activity.user == User.current || User.current.admin?%>
+
+
+
+
+
+ <%= link_to(l(:label_bid_respond_delete),
+ {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id,:is_activity=>is_activity},
+ :confirm => l(:text_are_you_sure), :method => 'delete',
+ :class => "postOptionLink", :title => l(:button_delete)) %>
+
+
+
+
+
+ <% end%>
+
+
+
+ <% count=fetch_user_leaveWord_reply(activity).count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.user == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %>
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:user).try(:realname) == ' ' %>
+ <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+ <%= comment.notes.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id},:method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
+ <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
+ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
+ <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
+ <%= hidden_field_tag 'is_activity',params[:is_activity],:value =>is_activity %>
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 9f7b90ee4..62568d505 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -1,690 +1,692 @@
-<% if ma.class == CourseMessage %>
- <% if ma.course_message_type == "News" %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"),user_path(ma.course_message.author) %>
- <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">发布了通知:
-
- <%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id },
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
标题: <%= ma.course_message.title %>
- <% unless ma.course_message.description.nil? %>
-
内容:
-
<%= ma.course_message.description.html_safe %>
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% if ma.course_message_type == "Comment" %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %>
- <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">评论了通知:
-
- <%= link_to ma.course_message.commented.title, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id },
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
评论对象: <%= ma.course_message.commented.title %>
- <% unless ma.course_message.comments.nil? %>
-
评论内容:
-
<%= ma.course_message.comments.html_safe %>
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil?%>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
- <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
- ">发布了课程作业:
-
-
- <% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %>
- <%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id),
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
- <% else %>
- <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
- :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
- <% end %>
-
-
- <% if User.current.allowed_to?(:as_teacher,ma.course_message.course) %>
-
- <%= User.current.lastname + User.current.firstname %>老师您好!
- <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.show_name + "老师")%>刚刚发布了一个作业:
-
-
- 课程名称:<%= ma.course_message.course.name %>
- (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
- 作业标题:<%= ma.course_message.name %>
- 发布时间:<%= DateTime.parse(ma.course_message.created_at.to_s).strftime('%Y-%m-%d %H:%M').to_s %>
- 提交截止:<%= ma.course_message.end_time %> 23:59
- 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %> 23:59
- 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
- 迟交扣分:<%= ma.course_message.late_penalty %>分
- 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
-
-
- 您可以修改作业内容、评分规则、匿评过程等,谢谢!
-
- <% else %>
-
<%= User.current.lastname + User.current.firstname %>同学您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师刚刚发布了一个作业:
-
- 课程名称:<%= ma.course_message.course.name %>
- (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
- 作业标题:<%= ma.course_message.name %>
- 提交截止:<%= ma.course_message.end_time %> 23:59
- 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %> 23:59
- 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
- 迟交扣分:<%= ma.course_message.late_penalty %>分
- 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
-
-
- 请抓紧时间提交您的作品,谢谢!
-
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
- <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + '老师',
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %>
- ">发布的作业:
-
- <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
- :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <% if !User.current.allowed_to?(:as_teacher,ma.course_message.course) %>
-
- <%= User.current.lastname + User.current.firstname %>同学您好!
- <%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师发布的作业截止日期快到了:
-
-
- 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
- 作业标题:<%= ma.course_message.name %>
- 提交截止:<%= ma.course_message.end_time %> 23:59
- 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %> 23:59
- 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
- 迟交扣分:<%= ma.course_message.late_penalty %>分
- 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
- 请抓紧时间提交您的作品,谢谢!
-
- <% end %>
-
- 截止时间快到啦
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
- <% if ma.course_message_type == "HomeworkCommon" && ma.status == 2 %>
-
-
- <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
-
-
- <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
- ">启动了作业匿评:
-
-
- <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
-
- <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师' : '同学' %>您好!
- <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>开启了匿评,作业详情如下:
-
-
- 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
- 作业标题:<%= ma.course_message.name %>
- 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
- 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
-
- <% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%>
-
请您尽早完成匿评,如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。
-
例如,您缺评了两份作品,则您的最终成绩将被扣除 <%= ma.course_message.homework_detail_manual.absence_penalty %> * 2 = <%= ma.course_message.homework_detail_manual.absence_penalty * 2 %>分
- <% end%>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
- <% if ma.course_message_type == "HomeworkCommon" && ma.status == 3 %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
-
- <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">关闭了作业匿评:
-
- <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))"%>
-
-
-
- <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
- 该作业已经关闭了匿评。作业信息如下:
-
-
- 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
- 作业标题:<%= ma.course_message.name %>
-
-
-
注:缺省情况下,系统将在作业提交截止日期后14天自动关闭匿评。
-
- <% if User.current.allowed_to?(:as_teacher,ma.course_message.course)%>
-
祝您的教学活动高效、顺利、愉快!
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
- <% if ma.course_message_type == "HomeworkCommon" && ma.status == 4 %>
-
-
- <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
-
-
- <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
- ">启动作业匿评失败
-
-
- <%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
-
- <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher, ma.course_message.course) ? '老师':'同学'%>您好!
- <%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败啦
-
-
-
- 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年' + ma.course_message.course.term %>)
- 作业标题:<%= ma.course_message.name %>
- 提交截止:<%= ma.course_message.end_time%> 23:59
-
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
- <% if ma.course_message_type == "Poll" %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
- <%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布了问卷:
-
- <%= link_to format_activity_title(" #{ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name}"), poll_path(ma.course_message.id),
- :class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
- <%= ma.course_message.polls_name %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% if ma.course_message_type == "Message" %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %>
- <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>"><%= ma.course_message.parent_id.nil? ? "发布了课程帖子:" : "评论了课程帖子:" %>
- <% if ma.course_message.parent_id.nil? %>
-
- <%= link_to ma.course_message.subject, course_boards_path(ma.course_message.course, :parent_id => ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id, :topic_id => ma.course_message.id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
主题: <%= ma.course_message.subject %>
- <% unless ma.course_message.content.nil? %>
-
内容:
-
<%= ma.course_message.content.html_safe %>
- <% end %>
-
- <% else %>
-
- <%= link_to ma.course_message.content.html_safe, course_boards_path(ma.course_message.course, :parent_id => ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id, :topic_id => ma.course_message.id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
主题: <%= ma.course_message.subject %>
- <% unless ma.course_message.content.nil? %>
-
内容:
-
<%= ma.course_message.content.html_safe %>
- <% end %>
-
- <% end %>
- <%= time_tag(ma.created_at).html_safe %>
-
-
- <% end %>
- <% if ma.course_message_type == "StudentWorksScore" %>
-
-
- <% if ma.course_message.reviewer_role == 3 %>
- <%=link_to image_tag(url_to_avatar(""), :width => "30", :height => "30") %>
- <% else %>
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
- <% end %>
-
-
- <% if ma.course_message.reviewer_role == 3 %>
- 匿名用户
- <% else %>
- <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
- <% end %>
- ">
- <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %>
-
-
-
- <% unless ma.content.nil? %>
- <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <%= User.current.show_name %>同学您好!
- <%= ma.course_message.reviewer_role == 3? "匿名用户" : (ma.course_message.user.show_name + "老师")%><%= ma.status == 0? "评阅了您的作品":"重新评阅了您的作品"%>。详情如下:
-
-
- 课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)
- 作业标题:<%=ma.course_message.student_work.homework_common.name %>
- <% content = ma.content.gsub("作业评分:","").split(" 评语:")%>
- 作品评分:<%= content[0] %>分
- <% if content.size > 1 %>
-
作品评语:
- <%= content[1] %>
- <% end %>
-
-
- 本次作业将在<%= ma.course_message.student_work.homework_common.homework_detail_manual.evaluation_end %> 23:59结束匿评,到时您将可以看到所有其他同学的作品啦!大家可以进一步互相学习。 期待您取得更大的进步!
-
-
- <% end %>
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% if ma.course_message_type == "JournalsForMessage" %>
- <% if ma.course_message.jour_type == 'Course' %>
- <% if params[:type] != 'homework' %>
-
-
- <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
-
- <%= link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
- ">在课程中留言了:
-
-
- <%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id),
- :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <%= ma.course_message.notes.html_safe %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% else %>
-
-
- <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
-
-
- <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname +
- "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"}",
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
- ">回复了作品评论:
-
-
- <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
-
- <%= User.current.show_name %>老师您好!
- <%= ma.course_message.user.show_name%><%= ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"%>回复了您的作品评论。详情如下:
-
-
- 回复内容:<%= ma.course_message.notes %>
- 您的评论:<%= ma.course_message.jour.comment %>
- 课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)
- 作业标题:<%=ma.course_message.jour.student_work.homework_common.name %>
-
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% end %>
-
- <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %>
-
- <%= link_to image_tag(url_to_avatar(ma.course_message.homework_common.user), :width => "30", :height => "30"), user_path(ma.course_message.homework_common.user) %>
-
- <%=link_to ma.course_message.homework_common.user.show_name+"老师", user_path(ma.course_message.homework_common.user), :class => "newsBlue homepageNewsPublisher" %>
- ">发布的作业:
-
-
- <%= link_to "作业标题:" + ma.course_message.homework_common.name, student_work_index_path(:homework => ma.course_message.homework_common_id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
-
- <%= User.current.lastname + User.current.firstname %>
- <%= User.current.allowed_to?(:as_teacher,ma.course_message.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:
-
-
- 课程名称:<%= ma.course_message.homework_common.course.name %>(<%= ma.course_message.homework_common.course.time.to_s + '年' + ma.course_message.homework_common.course.term %>)
- 作业标题:<%= ma.course_message.homework_common.name %>
- 提交截止:<%= ma.course_message.homework_common.end_time %> 23:59
- 提交时间:<%= format_time(ma.course_message.created_at) %>
- 迟交扣分:<%= ma.course_message.homework_common.late_penalty %>分
-
-
如需获得最终成绩,请您联系主讲老师对您的作品进行单独评分!
-
- 您成功提交了作品(但被标记为迟交啦)
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
- <% if ma.course_message_type == "Course" %>
-
-
- <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
-
-
- 系统提示
- ">您成功创建了课程:
-
-
- <%= link_to "课程名称:" + ma.course_message.name, course_path(ma.course_message),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <%= User.current.lastname + User.current.firstname %>老师您好!您成功创建了一个课程,详情如下:
-
-
课程名称:<%= ma.course_message.name %>
-
开课学期:<%= ma.course_message.time.to_s + '年' + ma.course_message.term %>
-
课程ID:<%= ma.course_message.id %>
-
课程密码:<%= ma.course_message.password %>
-
学时总数:<%= ma.course_message.class_period %>
-
创建时间:<%= format_time(ma.course_message.created_at) %>
-
您可以点击左上角的“配置”按钮,修改课程基本信息,添加及删除课程成员。您也可以把课程ID及密码告诉学生和其他成员,让他们输入ID及密码加入课程。
- <% if ma.course_message.is_public %>
-
您的课程是公开的,所有人都能访问您的课程。若不想设置为公开,您可以在配置中设置。
- <% else %>
-
您的课程是私有的,非课程成员不能访问您的课程。如果想设置为公开,您可以在配置中设置。
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% if ma.course_message_type == "JoinCourseRequest" %>
-
- <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
-
- 系统提示
- ">您有了新的课程成员申请:
-
-
- <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
-
- <%= User.current.lastname + User.current.firstname %>老师您好!您有了新的课程成员申请,信息如下:
-
-
真实姓名:<%= User.find(ma.course_message_id).realname %>
-
申请课程:<%= Course.find(ma.course_id).name%>
-
课程描述:
-
<%= Course.find(ma.course_id).description.html_safe %>
-
申请职位:<%= ma.content == '9' ? "教师" : "教辅"%>
-
-
-
- <% if ma.status == 0 || ma.status.nil?%>
- <%= link_to '同意',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true'%>
- |
- <%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%>
- <% elsif ma.status == 1%>
- 您已经同意了该申请
- <% elsif ma.status == 2%>
- 您已经拒绝了该申请
- <%end %>
-
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
- <% if ma.course_message_type == "CourseRequestDealResult" %>
-
- <% end %>
-
-
- <% if ma.course_message_type == "JoinCourse" and ma.status == 0 %>
-
-
- <%=link_to image_tag(url_to_avatar(User.find(ma.course_message_id)), :width => "30", :height => "30"), user_path(ma.course_message_id) %>
-
-
- <%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher" %>
- ">将您加入了课程:
-
-
- <%= link_to ma.course.name, course_member_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <% if ma.course.is_public? || User.current.member_of_course?(ma.course) || User.current.admin? %>
- <% teacher = User.find(ma.course_message_id) %>
-
<%= teacher.show_name %>(<%= teacher %>)老师把您加入了课程,详情如下:
-
课程名称:<%= ma.course.name %>
-
开课学期:<%= ma.course.time.to_s + '年'+ ma.course.term %>
-
课程ID:<%= ma.course.id %>
-
课时总数:<%= ma.course.class_period %>
- <% else %>
-
- 您已经被移出该私有课程,非课程成员没有权限访问私有课程
-
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
-
- <% if ma.course_message_type == "JoinCourse" and ma.status == 1 %>
-
-
- <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
-
-
- 系统提示
- ">您增加了新的课程成员:
-
-
- <%= link_to User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")", user_path(ma.course_message_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <% if ma.course.is_public? || User.current.member_of_course?(ma.course) || User.current.admin? %>
-
您增加了新的课程成员,详情如下:
-
成员:<%= User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")" %>
-
课程名称:<%= ma.course.name %>
-
开课学期:<%= ma.course.time.to_s + '年'+ ma.course.term %>
-
课程ID:<%= ma.course.id %>
-
课时总数:<%= ma.course.class_period %>
- <% else %>
-
- 您已经被移出该私有课程,非课程成员没有权限访问私有课程
-
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
-
- <% if ma.course_message_type == "RemoveFromCourse" %>
-
-
- <%=link_to image_tag(url_to_avatar(User.find(ma.course_message_id)), :width => "30", :height => "30"), user_path(ma.course_message_id) %>
-
-
- <%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher" %>
- ">将您移出了课程:
-
-
- <%= link_to ma.course.name, member_course_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <% if ma.course.is_public? || User.current.member_of?(ma.course) || User.current.admin? %>
-
您已被<%= User.find(ma.course_message_id).show_name %>老师移出了课程,详情如下:
-
课程名称:<%= ma.course.name %>
-
开课学期:<%= ma.course.time.to_s + '年'+ ma.course.term %>
- <% if !ma.content.nil? %>
-
担任角色:<%= ma.content %>
- <% end %>
-
学时总数:<%= ma.course.class_period %>
- <% else %>
-
- 您已经被移出该私有课程,非课程成员没有权限访问私有课程
-
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
-
- <% if ma.course_message_type == "Exercise" && ma.status == 2 %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
-
- <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">发布了课程测验 :
-
- <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))"%>
-
-
-
-
- <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
- <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>发布了课程测验 ,测验详情如下:
-
-
- 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
- 测验标题:<%= ma.course_message.exercise_name %>
-
-
-
-
-
- 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
- 答题时长:<%= ma.course_message.time == -1 ? '不限时' : ma.course_message.time.to_s + '分钟' %>
- <% if !User.current.allowed_to?(:as_teacher,ma.course_message.course)%>
- 请记得在截止时间前完成测验噢,辛苦啦!
- <% end %>
-
-
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
-
-
- <% if ma.course_message_type == "Exercise" && ma.status == 3 %>
-
- <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
-
- <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
- user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">发布的测验:
-
- <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))"%>
-
-
-
-
-
- <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
- <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>发布的课程测验截止时间快到了,测验详情如下:
-
-
-
- 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
- 测验标题:<%= ma.course_message.exercise_name %>
- 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
- 答题时长:<%= ma.course_message.time == -1 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
- 请及时完成课程测验,辛苦啦!
-
-
- 截止时间快到啦
- <%= time_tag(ma.created_at).html_safe %>
-
- <% end %>
+<% if ma.class == CourseMessage %>
+ <% if ma.course_message_type == "News" %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"),user_path(ma.course_message.author) %>
+ <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">发布了通知:
+
+ <%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id },
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
标题: <%= ma.course_message.title %>
+ <% unless ma.course_message.description.nil? %>
+
内容:
+
<%= ma.course_message.description.html_safe %>
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% if ma.course_message_type == "Comment" %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %>
+ <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">评论了通知:
+
+ <%= link_to ma.course_message.commented.title, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id },
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
评论对象: <%= ma.course_message.commented.title %>
+ <% unless ma.course_message.comments.nil? %>
+
评论内容:
+
<%= ma.course_message.comments.html_safe %>
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil?%>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
+ ">发布了课程作业:
+
+
+ <% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %>
+ <%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id),
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+ <% else %>
+ <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
+ :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+ <% end %>
+
+
+ <% if User.current.allowed_to?(:as_teacher,ma.course_message.course) %>
+
+ <%= User.current.lastname + User.current.firstname %>老师您好!
+ <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.show_name + "老师")%>刚刚发布了一个作业:
+
+
+ 课程名称:<%= ma.course_message.course.name %>
+ (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ 作业标题:<%= ma.course_message.name %>
+ 发布时间:<%= DateTime.parse(ma.course_message.created_at.to_s).strftime('%Y-%m-%d %H:%M').to_s %>
+ 提交截止:<%= ma.course_message.end_time %> 23:59
+ 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %> 23:59
+ 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
+ 迟交扣分:<%= ma.course_message.late_penalty %>分
+ 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
+
+
+ 您可以修改作业内容、评分规则、匿评过程等,谢谢!
+
+ <% else %>
+
<%= User.current.lastname + User.current.firstname %>同学您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师刚刚发布了一个作业:
+
+ 课程名称:<%= ma.course_message.course.name %>
+ (<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ 作业标题:<%= ma.course_message.name %>
+ 提交截止:<%= ma.course_message.end_time %> 23:59
+ 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %> 23:59
+ 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
+ 迟交扣分:<%= ma.course_message.late_penalty %>分
+ 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
+
+
+ 请抓紧时间提交您的作品,谢谢!
+
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + '老师',
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %>
+ ">发布的作业:
+
+ <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
+ :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <% if !User.current.allowed_to?(:as_teacher,ma.course_message.course) %>
+
+ <%= User.current.lastname + User.current.firstname %>同学您好!
+ <%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师发布的作业截止日期快到了:
+
+
+ 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ 作业标题:<%= ma.course_message.name %>
+ 提交截止:<%= ma.course_message.end_time %> 23:59
+ 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %> 23:59
+ 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
+ 迟交扣分:<%= ma.course_message.late_penalty %>分
+ 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
+ 请抓紧时间提交您的作品,谢谢!
+
+ <% end %>
+
+ 截止时间快到啦
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+ <% if ma.course_message_type == "HomeworkCommon" && ma.status == 2 %>
+
+
+ <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+
+
+ <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
+ ">启动了作业匿评:
+
+
+ <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+
+ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师' : '同学' %>您好!
+ <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>开启了匿评,作业详情如下:
+
+
+ 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ 作业标题:<%= ma.course_message.name %>
+ 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
+ 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %> 23:59
+
+ <% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%>
+
请您尽早完成匿评,如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。
+
例如,您缺评了两份作品,则您的最终成绩将被扣除 <%= ma.course_message.homework_detail_manual.absence_penalty %> * 2 = <%= ma.course_message.homework_detail_manual.absence_penalty * 2 %>分
+ <% end%>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+ <% if ma.course_message_type == "HomeworkCommon" && ma.status == 3 %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+
+ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">关闭了作业匿评:
+
+ <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))"%>
+
+
+
+ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
+ 该作业已经关闭了匿评。作业信息如下:
+
+
+ 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ 作业标题:<%= ma.course_message.name %>
+
+
+
注:缺省情况下,系统将在作业提交截止日期后14天自动关闭匿评。
+
+ <% if User.current.allowed_to?(:as_teacher,ma.course_message.course)%>
+
祝您的教学活动高效、顺利、愉快!
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+ <% if ma.course_message_type == "HomeworkCommon" && ma.status == 4 %>
+
+
+ <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+
+
+ <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
+ ">启动作业匿评失败
+
+
+ <%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+
+ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher, ma.course_message.course) ? '老师':'同学'%>您好!
+ <%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败啦
+
+
+
+ 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年' + ma.course_message.course.term %>)
+ 作业标题:<%= ma.course_message.name %>
+ 提交截止:<%= ma.course_message.end_time%> 23:59
+
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+ <% if ma.course_message_type == "Poll" %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+ <%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布了问卷:
+
+ <%= link_to format_activity_title(" #{ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name}"), poll_path(ma.course_message.id),
+ :class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+ <%= ma.course_message.polls_name %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% if ma.course_message_type == "Message" %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %>
+
+ <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">
+ <%= ma.course_message.parent_id.nil? ? "发布了课程帖子:" : "评论了课程帖子:" %>
+ <% if ma.course_message.parent_id.nil? %>
+
+ <%= link_to ma.course_message.subject, course_boards_path(ma.course_message.course, :parent_id => ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id, :topic_id => ma.course_message.id),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
主题: <%= ma.course_message.subject %>
+ <% unless ma.course_message.content.nil? %>
+
内容:
+
<%= ma.course_message.content.html_safe %>
+ <% end %>
+
+ <% else %>
+
+ <%= link_to ma.course_message.content.html_safe, course_boards_path(ma.course_message.course, :parent_id => ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id, :topic_id => ma.course_message.id),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
主题: <%= ma.course_message.subject %>
+ <% unless ma.course_message.content.nil? %>
+
内容:
+
<%= ma.course_message.content.html_safe %>
+ <% end %>
+
+ <% end %>
+ <%= time_tag(ma.created_at).html_safe %>
+
+
+ <% end %>
+ <% if ma.course_message_type == "StudentWorksScore" %>
+
+
+ <% if ma.course_message.reviewer_role == 3 %>
+ <%=link_to image_tag(url_to_avatar(""), :width => "30", :height => "30") %>
+ <% else %>
+ <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+ <% end %>
+
+
+ <% if ma.course_message.reviewer_role == 3 %>
+ 匿名用户
+ <% else %>
+ <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
+ <% end %>
+ ">
+ <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %>
+
+
+
+ <% unless ma.content.nil? %>
+ <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <%= User.current.show_name %>同学您好!
+ <%= ma.course_message.reviewer_role == 3? "匿名用户" : (ma.course_message.user.show_name + "老师")%><%= ma.status == 0? "评阅了您的作品":"重新评阅了您的作品"%>。详情如下:
+
+
+ 课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)
+ 作业标题:<%=ma.course_message.student_work.homework_common.name %>
+ <% content = ma.content.gsub("作业评分:","").split(" 评语:")%>
+ 作品评分:<%= content[0] %>分
+ <% if content.size > 1 %>
+
作品评语:
+ <%= content[1] %>
+ <% end %>
+
+
+ 本次作业将在<%= ma.course_message.student_work.homework_common.homework_detail_manual.evaluation_end %> 23:59结束匿评,到时您将可以看到所有其他同学的作品啦!大家可以进一步互相学习。 期待您取得更大的进步!
+
+
+ <% end %>
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% if ma.course_message_type == "JournalsForMessage" %>
+ <% if ma.course_message.jour_type == 'Course' %>
+ <% if params[:type] != 'homework' %>
+
+
+ <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+
+ <%= link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
+ ">在课程中留言了:
+
+
+ <%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id),
+ :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <%= ma.course_message.notes.html_safe %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% else %>
+
+
+ <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+
+
+ <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname +
+ "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"}",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
+ ">回复了作品评论:
+
+
+ <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+
+ <%= User.current.show_name %>老师您好!
+ <%= ma.course_message.user.show_name%><%= ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"%>回复了您的作品评论。详情如下:
+
+
+ 回复内容:<%= ma.course_message.notes %>
+ 您的评论:<%= ma.course_message.jour.comment %>
+ 课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)
+ 作业标题:<%=ma.course_message.jour.student_work.homework_common.name %>
+
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% end %>
+
+ <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %>
+
+ <%= link_to image_tag(url_to_avatar(ma.course_message.homework_common.user), :width => "30", :height => "30"), user_path(ma.course_message.homework_common.user) %>
+
+ <%=link_to ma.course_message.homework_common.user.show_name+"老师", user_path(ma.course_message.homework_common.user), :class => "newsBlue homepageNewsPublisher" %>
+ ">发布的作业:
+
+
+ <%= link_to "作业标题:" + ma.course_message.homework_common.name, student_work_index_path(:homework => ma.course_message.homework_common_id),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+
+ <%= User.current.lastname + User.current.firstname %>
+ <%= User.current.allowed_to?(:as_teacher,ma.course_message.homework_common.course) ? '老师':'同学'%>您好!由于迟交作业,您及您的作品都不能参与以下作业的匿评。作业详情如下:
+
+
+ 课程名称:<%= ma.course_message.homework_common.course.name %>(<%= ma.course_message.homework_common.course.time.to_s + '年' + ma.course_message.homework_common.course.term %>)
+ 作业标题:<%= ma.course_message.homework_common.name %>
+ 提交截止:<%= ma.course_message.homework_common.end_time %> 23:59
+ 提交时间:<%= format_time(ma.course_message.created_at) %>
+ 迟交扣分:<%= ma.course_message.homework_common.late_penalty %>分
+
+
如需获得最终成绩,请您联系主讲老师对您的作品进行单独评分!
+
+ 您成功提交了作品(但被标记为迟交啦)
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+ <% if ma.course_message_type == "Course" %>
+
+
+ <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
+
+
+ 系统提示
+ ">您成功创建了课程:
+
+
+ <%= link_to "课程名称:" + ma.course_message.name, course_path(ma.course_message),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <%= User.current.lastname + User.current.firstname %>老师您好!您成功创建了一个课程,详情如下:
+
+
课程名称:<%= ma.course_message.name %>
+
开课学期:<%= ma.course_message.time.to_s + '年' + ma.course_message.term %>
+
课程ID:<%= ma.course_message.id %>
+
课程密码:<%= ma.course_message.password %>
+
学时总数:<%= ma.course_message.class_period %>
+
创建时间:<%= format_time(ma.course_message.created_at) %>
+
您可以点击左上角的“配置”按钮,修改课程基本信息,添加及删除课程成员。您也可以把课程ID及密码告诉学生和其他成员,让他们输入ID及密码加入课程。
+ <% if ma.course_message.is_public %>
+
您的课程是公开的,所有人都能访问您的课程。若不想设置为公开,您可以在配置中设置。
+ <% else %>
+
您的课程是私有的,非课程成员不能访问您的课程。如果想设置为公开,您可以在配置中设置。
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% if ma.course_message_type == "JoinCourseRequest" %>
+
+ <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
+
+ 系统提示
+ ">您有了新的课程成员申请:
+
+
+ <%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id),
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+
+ <%= User.current.lastname + User.current.firstname %>老师您好!您有了新的课程成员申请,信息如下:
+
+
真实姓名:<%= User.find(ma.course_message_id).realname %>
+
申请课程:<%= Course.find(ma.course_id).name%>
+
课程描述:
+
<%= Course.find(ma.course_id).description.html_safe %>
+
申请职位:<%= ma.content == '9' ? "教师" : "教辅"%>
+
+
+
+ <% if ma.status == 0 || ma.status.nil?%>
+ <%= link_to '同意',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true'%>
+ |
+ <%= link_to '拒绝',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%>
+ <% elsif ma.status == 1%>
+ 您已经同意了该申请
+ <% elsif ma.status == 2%>
+ 您已经拒绝了该申请
+ <%end %>
+
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+ <% if ma.course_message_type == "CourseRequestDealResult" %>
+
+ <% end %>
+
+
+ <% if ma.course_message_type == "JoinCourse" and ma.status == 0 %>
+
+
+ <%=link_to image_tag(url_to_avatar(User.find(ma.course_message_id)), :width => "30", :height => "30"), user_path(ma.course_message_id) %>
+
+
+ <%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher" %>
+ ">将您加入了课程:
+
+
+ <%= link_to ma.course.name, course_member_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <% if ma.course.is_public? || User.current.member_of_course?(ma.course) || User.current.admin? %>
+ <% teacher = User.find(ma.course_message_id) %>
+
<%= teacher.show_name %>(<%= teacher %>)老师把您加入了课程,详情如下:
+
课程名称:<%= ma.course.name %>
+
开课学期:<%= ma.course.time.to_s + '年'+ ma.course.term %>
+
课程ID:<%= ma.course.id %>
+
课时总数:<%= ma.course.class_period %>
+ <% else %>
+
+ 您已经被移出该私有课程,非课程成员没有权限访问私有课程
+
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+
+ <% if ma.course_message_type == "JoinCourse" and ma.status == 1 %>
+
+
+ <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
+
+
+ 系统提示
+ ">您增加了新的课程成员:
+
+
+ <%= link_to User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")", user_path(ma.course_message_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <% if ma.course.is_public? || User.current.member_of_course?(ma.course) || User.current.admin? %>
+
您增加了新的课程成员,详情如下:
+
成员:<%= User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")" %>
+
课程名称:<%= ma.course.name %>
+
开课学期:<%= ma.course.time.to_s + '年'+ ma.course.term %>
+
课程ID:<%= ma.course.id %>
+
课时总数:<%= ma.course.class_period %>
+ <% else %>
+
+ 您已经被移出该私有课程,非课程成员没有权限访问私有课程
+
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+
+ <% if ma.course_message_type == "RemoveFromCourse" %>
+
+
+ <%=link_to image_tag(url_to_avatar(User.find(ma.course_message_id)), :width => "30", :height => "30"), user_path(ma.course_message_id) %>
+
+
+ <%=link_to User.find(ma.course_message_id), user_path(User.find(ma.course_message_id)), :class => "newsBlue homepageNewsPublisher" %>
+ ">将您移出了课程:
+
+
+ <%= link_to ma.course.name, member_course_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover => "message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <% if ma.course.is_public? || User.current.member_of?(ma.course) || User.current.admin? %>
+
您已被<%= User.find(ma.course_message_id).show_name %>老师移出了课程,详情如下:
+
课程名称:<%= ma.course.name %>
+
开课学期:<%= ma.course.time.to_s + '年'+ ma.course.term %>
+ <% if !ma.content.nil? %>
+
担任角色:<%= ma.content %>
+ <% end %>
+
学时总数:<%= ma.course.class_period %>
+ <% else %>
+
+ 您已经被移出该私有课程,非课程成员没有权限访问私有课程
+
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+
+ <% if ma.course_message_type == "Exercise" && ma.status == 2 %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+
+ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">发布了课程测验 :
+
+ <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))"%>
+
+
+
+
+ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
+ <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>发布了课程测验 ,测验详情如下:
+
+
+ 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ 测验标题:<%= ma.course_message.exercise_name %>
+
+
+
+
+
+ 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
+ 答题时长:<%= ma.course_message.time == -1 ? '不限时' : ma.course_message.time.to_s + '分钟' %>
+ <% if !User.current.allowed_to?(:as_teacher,ma.course_message.course)%>
+ 请记得在截止时间前完成测验噢,辛苦啦!
+ <% end %>
+
+
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
+
+
+ <% if ma.course_message_type == "Exercise" && ma.status == 3 %>
+
+ <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
+
+ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
+ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">发布的测验:
+
+ <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))"%>
+
+
+
+
+
+ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好!
+ <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>发布的课程测验截止时间快到了,测验详情如下:
+
+
+
+ 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
+ 测验标题:<%= ma.course_message.exercise_name %>
+ 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
+ 答题时长:<%= ma.course_message.time == -1 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
+ 请及时完成课程测验,辛苦啦!
+
+
+ 截止时间快到啦
+ <%= time_tag(ma.created_at).html_safe %>
+
+ <% end %>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/_user_resource_info.html.erb b/app/views/users/_user_resource_info.html.erb
index cafbf457f..6eddf1e05 100644
--- a/app/views/users/_user_resource_info.html.erb
+++ b/app/views/users/_user_resource_info.html.erb
@@ -3,7 +3,6 @@
<%= render :partial => 'users/resource_search_form',:locals => {:user => @user, :type => @type} %>
-
为您找到<%= @atta_count %> 个资源
diff --git a/db/migrate/20160309024051_update_homework_common_updated_at.rb b/db/migrate/20160309024051_update_homework_common_updated_at.rb
new file mode 100644
index 000000000..37accdc6e
--- /dev/null
+++ b/db/migrate/20160309024051_update_homework_common_updated_at.rb
@@ -0,0 +1,18 @@
+class UpdateHomeworkCommonUpdatedAt < ActiveRecord::Migration
+ def up
+ count = HomeworkCommon.all.count / 30 + 2
+ transaction do
+ for i in 1 ... count do i
+ HomeworkCommon.page(i).per(30).each do |hw|
+ ca = CourseActivity.where("course_act_type = 'HomeworkCommon' and course_act_id = #{hw.id}").first
+ unless ca.nil?
+ hw.update_attributes(:updated_at => ca.updated_at)
+ end
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20160309072649_update_contributor_after_delete.rb b/db/migrate/20160309072649_update_contributor_after_delete.rb
new file mode 100644
index 000000000..01f91105a
--- /dev/null
+++ b/db/migrate/20160309072649_update_contributor_after_delete.rb
@@ -0,0 +1,50 @@
+class UpdateContributorAfterDelete < ActiveRecord::Migration
+ def up
+ Course.all.each do |course|
+ if course.course_activities.count > 1
+ course.members.each do |s|
+ puts course.id
+ puts course.name
+ puts s.user_id
+ # board_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?",s.student_id, course.id, "Message").count * 2
+ # 发帖数
+ board_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.user_id} and me.parent_id is null;").count
+ # 回帖数
+ message_reply_count = Message.find_by_sql("select DISTINCT me.* from messages me, boards b where b.id = me.board_id and b.course_id = #{course.id} and b.project_id = '-1' and me.author_id = #{s.user_id} and me.parent_id is not null").count * 1
+ # 新闻回复
+ common_reply_count = Comment.find_by_sql("select cm.* from comments cm, news n where cm.author_id = #{s.user_id} and n.course_id = #{course.id} and cm.commented_id = n.id and cm.commented_type ='News'").count * 1
+ # 通知
+ common_count = News.find_by_sql("select n.* from news n where n.author_id = #{s.user_id} and n.course_id = #{course.id} ").count * 1
+ # attachment_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "Attachment").count * 5
+ # 附件数
+ attachment_count = Attachment.find_by_sql("SELECT * FROM `attachments` where container_id = #{course.id} and author_id = #{s.user_id} and container_type ='Course'").count
+ # 课程留言数
+ journal_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? ", s.user_id, course.id, "Course").count * 1
+ # 作业留言
+ journal_homework_count = JournalsForMessage.find_by_sql("SELECT jfm.* FROM `journals_for_messages` jfm, homework_commons hc where hc.id = jfm.jour_id and hc.course_id =#{course.id} and jfm.user_id =#{s.user_id} and jfm.jour_type ='HomeworkCommon';").count * 1
+ # journal_count = CourseActivity.where("user_id =? and course_id =? and course_act_type =?", s.student_id, course.id, "JournalsForMessage").count * 1
+ # journal_reply_count = JournalsForMessage.where("user_id =? and jour_id =? and jour_type =? and status =?", s.student_id, course.id, "Course",1).count * 1
+ total = board_count + message_reply_count + common_reply_count + attachment_count + journal_count
+ course_contributor = CourseContributorScore.where("course_id =? and user_id =?", course.id, s.user_id).first
+ if course_contributor.nil?
+ CourseContributorScore.create(:course_id => course.id, :user_id => s.user_id, :message_num => board_count, :message_reply_num => message_reply_count,
+ :news_reply_num => common_reply_count, :news_num => common_count, :resource_num => attachment_count, :journal_num => journal_count,
+ :homework_journal_num => journal_homework_count, :journal_reply_num => 0, :total_score => total)
+ else
+ course_contributor.message_num = board_count
+ course_contributor.message_reply_num = message_reply_count
+ course_contributor.news_reply_num = common_reply_count
+ course_contributor.news_num = common_count
+ course_contributor.resource_num = attachment_count
+ course_contributor.journal_num = journal_count
+ course_contributor.homework_journal_num = journal_homework_count
+ course_contributor.save
+ end
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20160310033019_delete_student_work_data.rb b/db/migrate/20160310033019_delete_student_work_data.rb
new file mode 100644
index 000000000..9cb952064
--- /dev/null
+++ b/db/migrate/20160310033019_delete_student_work_data.rb
@@ -0,0 +1,8 @@
+class DeleteStudentWorkData < ActiveRecord::Migration
+ def up
+ StudentWork.where("homework_common_id = 2604 AND user_id = 10763 AND final_score = 0").destroy_all
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a7ffc23b1..abaafdf80 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20160304234903) do
+ActiveRecord::Schema.define(:version => 20160310033019) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
diff --git a/lib/trustie/gitlab/helper.rb b/lib/trustie/gitlab/helper.rb
index 9fb1f5735..c9cbcee26 100644
--- a/lib/trustie/gitlab/helper.rb
+++ b/lib/trustie/gitlab/helper.rb
@@ -1,73 +1,78 @@
-#coding=utf-8
-
-module Trustie
- module Gitlab
- module Helper
- GUEST = 10
- REPORTER = 20
- DEVELOPER = 30
- MASTER = 40
- OWNER = 50
- # 项目公开和私有
- PUBLIC = 20
- PRIVATE = 0
-
- def change_password(uid, en_pwd, salt)
- return unless uid
- options = {:encrypted_password=>en_pwd, :password_salt=>salt}
- self.g.put("/users/ext/#{uid}", :body => options)
- # g.edit_user(uid, :encrypted_password=>en_pwd, :password_salt=>salt)
- end
-
- def find_user(user)
- us = self.g.get("/users?search=#{user.mail}")
- if Array === us
- us.each do |u|
- return u if u.email == user.mail
- end
- end
- return nil
- end
-
- def add_user(user)
- u = nil
- begin
- u = find_user(user)
- unless u
- u = self.g.create_user(user.mail,
- user.hashed_password,
- name: user.show_name,
- username: user.login,
- confirm: "true")
- user.gid = u.id
- end
- change_password(u.id, user.hashed_password, user.salt)
- rescue => e
- puts e
- end
- return u
- end
-
- def del_user(user)
- return unless user.gid
- self.g.delete_user(user.gid)
- end
-
- def get_gitlab_role m
- case m.roles.first.position
- when 1,2
- GUEST
- when 5
- REPORTER
- when 4
- DEVELOPER
- when 3
- MASTER
- else
- GUEST
- end
- end
-
- end
- end
+#coding=utf-8
+
+module Trustie
+ module Gitlab
+ module Helper
+ GUEST = 10
+ REPORTER = 20
+ DEVELOPER = 30
+ MASTER = 40
+ OWNER = 50
+ # 项目公开和私有
+ PUBLIC = 20
+ PRIVATE = 0
+
+ def change_password(uid, en_pwd, salt)
+ return unless uid
+ options = {:encrypted_password=>en_pwd, :password_salt=>salt}
+ self.g.put("/users/ext/#{uid}", :body => options)
+ # g.edit_user(uid, :encrypted_password=>en_pwd, :password_salt=>salt)
+ end
+
+ def find_user(user)
+ us = self.g.get("/users?search=#{user.mail}")
+ if Array === us
+ us.each do |u|
+ return u if u.email == user.mail
+ end
+ end
+ return nil
+ end
+
+ def add_user(user)
+ u = nil
+ begin
+ u = find_user(user)
+ unless u
+ u = self.g.create_user(user.mail,
+ user.hashed_password,
+ name: user.show_name,
+ username: user.login,
+ confirm: "true")
+ user.gid = u.id
+ user.save
+ end
+ if user.gid.nil?
+ user.gid = u.id
+ user.save
+ end
+ change_password(u.id, user.hashed_password, user.salt)
+ rescue => e
+ puts e
+ end
+ return u
+ end
+
+ def del_user(user)
+ return unless user.gid
+ self.g.delete_user(user.gid)
+ end
+
+ def get_gitlab_role m
+ case m.roles.first.position
+ when 1,2
+ GUEST
+ when 5
+ REPORTER
+ when 4
+ DEVELOPER
+ when 3
+ MASTER
+ else
+ GUEST
+ end
+ end
+
+ end
+ end
end
\ No newline at end of file
diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js
index 8b1c68c70..060898b88 100644
--- a/public/assets/kindeditor/kindeditor.js
+++ b/public/assets/kindeditor/kindeditor.js
@@ -5667,8 +5667,29 @@ _plugin('core', function(K) {
}else{
//TODO 暂时什么也不做
}
+ var _bod = $(self.cmd.doc.body);
+ var body = self.cmd.doc.body;
+ var _bw = _bod.width(),_bh = Math.max((K.IE ? body.scrollHeight : (K.GECKO ? body.offsetHeight+26:body.offsetHeight)));
+ var _bsh = 0;
+ _bod.children().each(function(){
+ _bsh += $(this).height();
+ });
+ var _imgbase = _bod.find("img");
+ _imgbase[0].onload = function(){
+ var _iw=_imgbase.width(),_ih = _imgbase.height();
+ var _alh = _bsh + _ih;
+ var _rhig = _alh > _bh ? _alh : _bh;
+ switch(self.resizeType){
+ case 1:
+ var _defh = self.toolbar.div.height() + self.statusbar.height();
+ _defh = _defh > 0 ? _defh + 6 : _defh;
+ self.resize(null,_rhig + _defh);
+ break;
+ }
+ }
} else {
- alert(data.message);
+ //alert(data.message);
+ alert("仅支持如下图片格式:bmp,jpeg,jpg,png,gif,BMP,JPEG,JPG,PNG,GIF");
}
},
afterError : function(str) {
diff --git a/public/assets/kindeditor/plugins/table/table.js b/public/assets/kindeditor/plugins/table/table.js
index ba72a0ff8..08a1fbcc5 100644
--- a/public/assets/kindeditor/plugins/table/table.js
+++ b/public/assets/kindeditor/plugins/table/table.js
@@ -1,719 +1,724 @@
-/*******************************************************************************
-* KindEditor - WYSIWYG HTML Editor for Internet
-* Copyright (C) 2006-2011 kindsoft.net
-*
-* @author Roddy
-* @site http://www.kindsoft.net/
-* @licence http://www.kindsoft.net/license.php
-*******************************************************************************/
-
-KindEditor.plugin('table', function(K) {
- var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
- // 设置颜色
- function _setColor(box, color) {
- color = color.toUpperCase();
- box.css('background-color', color);
- box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
- box.html(color);
- }
- // 初始化取色器
- var pickerList = [];
- function _initColorPicker(dialogDiv, colorBox) {
- colorBox.bind('click,mousedown', function(e){
- e.stopPropagation();
- });
- function removePicker() {
- K.each(pickerList, function() {
- this.remove();
- });
- pickerList = [];
- K(document).unbind('click,mousedown', removePicker);
- dialogDiv.unbind('click,mousedown', removePicker);
- }
- colorBox.click(function(e) {
- removePicker();
- var box = K(this),
- pos = box.pos();
- var picker = K.colorpicker({
- x : pos.x,
- y : pos.y + box.height(),
- z : 811214,
- selectedColor : K(this).html(),
- colors : self.colorTable,
- noColor : self.lang('noColor'),
- shadowMode : self.shadowMode,
- click : function(color) {
- _setColor(box, color);
- removePicker();
- }
- });
- pickerList.push(picker);
- K(document).bind('click,mousedown', removePicker);
- dialogDiv.bind('click,mousedown', removePicker);
- });
- }
- // 取得下一行cell的index
- function _getCellIndex(table, row, cell) {
- var rowSpanCount = 0;
- for (var i = 0, len = row.cells.length; i < len; i++) {
- if (row.cells[i] == cell) {
- break;
- }
- rowSpanCount += row.cells[i].rowSpan - 1;
- }
- return cell.cellIndex - rowSpanCount;
- }
- self.plugin.table = {
- //insert or modify table
- prop : function(isInsert) {
- var html = [
- '',
- //rows, cols
- '
',
- '' + lang.cells + ' ',
- lang.rows + ' ',
- lang.cols + ' ',
- '
',
- //width, height
- '
',
- '' + lang.size + ' ',
- lang.width + ' ',
- '',
- '' + lang.percent + ' ',
- '' + lang.px + ' ',
- ' ',
- lang.height + ' ',
- '',
- '' + lang.percent + ' ',
- '' + lang.px + ' ',
- ' ',
- '
',
- //space, padding
- '
',
- '' + lang.space + ' ',
- lang.padding + ' ',
- lang.spacing + ' ',
- '
',
- //align
- '
',
- '' + lang.align + ' ',
- '',
- '' + lang.alignDefault + ' ',
- '' + lang.alignLeft + ' ',
- '' + lang.alignCenter + ' ',
- '' + lang.alignRight + ' ',
- ' ',
- '
',
- //border
- '
',
- '' + lang.border + ' ',
- lang.borderWidth + ' ',
- lang.borderColor + ' ',
- '
',
- //background color
- '
',
- '' + lang.backgroundColor + ' ',
- ' ',
- '
',
- '
'
- ].join('');
- var bookmark = self.cmd.range.createBookmark();
- var dialog = self.createDialog({
- name : name,
- width : 500,
- title : self.lang(name),
- body : html,
- beforeRemove : function() {
- colorBox.unbind();
- },
- yesBtn : {
- name : self.lang('yes'),
- click : function(e) {
- if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(self.edit.html())){
- self.edit.html('');
- }
- var rows = rowsBox.val(),
- cols = colsBox.val(),
- width = widthBox.val(),
- height = heightBox.val(),
- widthType = widthTypeBox.val(),
- heightType = heightTypeBox.val(),
- padding = paddingBox.val(),
- spacing = spacingBox.val(),
- align = alignBox.val(),
- border = borderBox.val(),
- borderColor = K(colorBox[0]).html() || '',
- bgColor = K(colorBox[1]).html() || '';
- if (rows == 0 || !/^\d+$/.test(rows)) {
- alert(self.lang('invalidRows'));
- rowsBox[0].focus();
- return;
- }
- if (cols == 0 || !/^\d+$/.test(cols)) {
- alert(self.lang('invalidRows'));
- colsBox[0].focus();
- return;
- }
- if (!/^\d*$/.test(width)) {
- alert(self.lang('invalidWidth'));
- widthBox[0].focus();
- return;
- }
- if (!/^\d*$/.test(height)) {
- alert(self.lang('invalidHeight'));
- heightBox[0].focus();
- return;
- }
- if (!/^\d*$/.test(padding)) {
- alert(self.lang('invalidPadding'));
- paddingBox[0].focus();
- return;
- }
- if (!/^\d*$/.test(spacing)) {
- alert(self.lang('invalidSpacing'));
- spacingBox[0].focus();
- return;
- }
- if (!/^\d*$/.test(border)) {
- alert(self.lang('invalidBorder'));
- borderBox[0].focus();
- return;
- }
- //modify table
- if (table) {
- if (width !== '') {
- table.width(width + widthType);
- } else {
- table.css('width', '');
- }
- if (table[0].width !== undefined) {
- table.removeAttr('width');
- }
- if (height !== '') {
- table.height(height + heightType);
- } else {
- table.css('height', '');
- }
- if (table[0].height !== undefined) {
- table.removeAttr('height');
- }
- table.css('background-color', bgColor);
- if (table[0].bgColor !== undefined) {
- table.removeAttr('bgColor');
- }
- if (padding !== '') {
- table[0].cellPadding = padding;
- } else {
- table.removeAttr('cellPadding');
- }
- if (spacing !== '') {
- table[0].cellSpacing = spacing;
- } else {
- table.removeAttr('cellSpacing');
- }
- if (align !== '') {
- table[0].align = align;
- } else {
- table.removeAttr('align');
- }
- if (border !== '') {
- table.attr('border', border);
- } else {
- table.removeAttr('border');
- }
- if (border === '' || border === '0') {
- table.addClass(zeroborder);
- } else {
- table.removeClass(zeroborder);
- }
- if (borderColor !== '') {
- table.attr('borderColor', borderColor);
- } else {
- table.removeAttr('borderColor');
- }
- self.hideDialog().focus();
- self.cmd.range.moveToBookmark(bookmark);
- self.cmd.select();
- self.addBookmark();
- return;
- }
- //insert new table
- var style = '';
- if (width !== '') {
- style += 'width:' + width + widthType + ';';
- }
- if (height !== '') {
- style += 'height:' + height + heightType + ';';
- }
- if (bgColor !== '') {
- style += 'background-color:' + bgColor + ';';
- }
- if (border !== ''){
- style += 'border:'+border+'px solid;';
- }
-
- var html = '';
- for (var i = 0; i < rows; i++) {
- html += '';
- for (var j = 0; j < cols; j++) {
- html += '' + (K.IE ? ' ' : ' ') + ' ';
- }
- html += ' ';
- }
- html += '
';
- if (!K.IE) {
- html += ' ';
- }
- self.insertHtml(html);
- self.select().hideDialog().focus();
- self.addBookmark();
- }
- }
- }),
- div = dialog.div,
- rowsBox = K('[name="rows"]', div).val(3),
- colsBox = K('[name="cols"]', div).val(2),
- widthBox = K('[name="width"]', div).val(100),
- heightBox = K('[name="height"]', div),
- widthTypeBox = K('[name="widthType"]', div),
- heightTypeBox = K('[name="heightType"]', div),
- paddingBox = K('[name="padding"]', div).val(2),
- spacingBox = K('[name="spacing"]', div).val(0),
- alignBox = K('[name="align"]', div),
- borderBox = K('[name="border"]', div).val(1),
- colorBox = K('.ke-input-color', div);
- _initColorPicker(div, colorBox.eq(0));
- _initColorPicker(div, colorBox.eq(1));
- _setColor(colorBox.eq(0), '#000000');
- _setColor(colorBox.eq(1), '');
- // foucs and select
- rowsBox[0].focus();
- rowsBox[0].select();
- var table;
- if (isInsert) {
- return;
- }
- //get selected table node
- table = self.plugin.getSelectedTable();
- if (table) {
- rowsBox.val(table[0].rows.length);
- colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
- rowsBox.attr('disabled', true);
- colsBox.attr('disabled', true);
- var match,
- tableWidth = table[0].style.width || table[0].width,
- tableHeight = table[0].style.height || table[0].height;
- if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
- widthBox.val(match[1]);
- widthTypeBox.val(match[2]);
- } else {
- widthBox.val('');
- }
- if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
- heightBox.val(match[1]);
- heightTypeBox.val(match[2]);
- }
- paddingBox.val(table[0].cellPadding || '');
- spacingBox.val(table[0].cellSpacing || '');
- alignBox.val(table[0].align || '');
- borderBox.val(table[0].border === undefined ? '' : table[0].border);
- _setColor(colorBox.eq(0), K.toHex(table.attr('borderColor') || ''));
- _setColor(colorBox.eq(1), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
- widthBox[0].focus();
- widthBox[0].select();
- }
- },
- //modify cell
- cellprop : function() {
- var html = [
- '',
- //width, height
- '
',
- '' + lang.size + ' ',
- lang.width + ' ',
- '',
- '' + lang.percent + ' ',
- '' + lang.px + ' ',
- ' ',
- lang.height + ' ',
- '',
- '' + lang.percent + ' ',
- '' + lang.px + ' ',
- ' ',
- '
',
- //align
- '
',
- '' + lang.align + ' ',
- lang.textAlign + ' ',
- '' + lang.alignDefault + ' ',
- '' + lang.alignLeft + ' ',
- '' + lang.alignCenter + ' ',
- '' + lang.alignRight + ' ',
- ' ',
- lang.verticalAlign + ' ',
- '' + lang.alignDefault + ' ',
- '' + lang.alignTop + ' ',
- '' + lang.alignMiddle + ' ',
- '' + lang.alignBottom + ' ',
- '' + lang.alignBaseline + ' ',
- ' ',
- '
',
- //border
- '
',
- '' + lang.border + ' ',
- lang.borderWidth + ' ',
- lang.borderColor + ' ',
- '
',
- //background color
- '
',
- '' + lang.backgroundColor + ' ',
- ' ',
- '
',
- '
'
- ].join('');
- var bookmark = self.cmd.range.createBookmark();
- var dialog = self.createDialog({
- name : name,
- width : 500,
- title : self.lang('tablecell'),
- body : html,
- beforeRemove : function() {
- colorBox.unbind();
- },
- yesBtn : {
- name : self.lang('yes'),
- click : function(e) {
- var width = widthBox.val(),
- height = heightBox.val(),
- widthType = widthTypeBox.val(),
- heightType = heightTypeBox.val(),
- padding = paddingBox.val(),
- spacing = spacingBox.val(),
- textAlign = textAlignBox.val(),
- verticalAlign = verticalAlignBox.val(),
- border = borderBox.val(),
- borderColor = K(colorBox[0]).html() || '',
- bgColor = K(colorBox[1]).html() || '';
- if (!/^\d*$/.test(width)) {
- alert(self.lang('invalidWidth'));
- widthBox[0].focus();
- return;
- }
- if (!/^\d*$/.test(height)) {
- alert(self.lang('invalidHeight'));
- heightBox[0].focus();
- return;
- }
- if (!/^\d*$/.test(border)) {
- alert(self.lang('invalidBorder'));
- borderBox[0].focus();
- return;
- }
- cell.css({
- width : width !== '' ? (width + widthType) : '',
- height : height !== '' ? (height + heightType) : '',
- 'background-color' : bgColor,
- 'text-align' : textAlign,
- 'vertical-align' : verticalAlign,
- 'border-width' : border,
- 'border-style' : border !== '' ? 'solid' : '',
- 'border-color' : borderColor
- });
- self.hideDialog().focus();
- self.cmd.range.moveToBookmark(bookmark);
- self.cmd.select();
- self.addBookmark();
- }
- }
- }),
- div = dialog.div,
- widthBox = K('[name="width"]', div).val(100),
- heightBox = K('[name="height"]', div),
- widthTypeBox = K('[name="widthType"]', div),
- heightTypeBox = K('[name="heightType"]', div),
- paddingBox = K('[name="padding"]', div).val(2),
- spacingBox = K('[name="spacing"]', div).val(0),
- textAlignBox = K('[name="textAlign"]', div),
- verticalAlignBox = K('[name="verticalAlign"]', div),
- borderBox = K('[name="border"]', div).val(1),
- colorBox = K('.ke-input-color', div);
- _initColorPicker(div, colorBox.eq(0));
- _initColorPicker(div, colorBox.eq(1));
- _setColor(colorBox.eq(0), '#000000');
- _setColor(colorBox.eq(1), '');
- // foucs and select
- widthBox[0].focus();
- widthBox[0].select();
- // get selected cell
- var cell = self.plugin.getSelectedCell();
- var match,
- cellWidth = cell[0].style.width || cell[0].width || '',
- cellHeight = cell[0].style.height || cell[0].height || '';
- if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
- widthBox.val(match[1]);
- widthTypeBox.val(match[2]);
- } else {
- widthBox.val('');
- }
- if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
- heightBox.val(match[1]);
- heightTypeBox.val(match[2]);
- }
- textAlignBox.val(cell[0].style.textAlign || '');
- verticalAlignBox.val(cell[0].style.verticalAlign || '');
- var border = cell[0].style.borderWidth || '';
- if (border) {
- border = parseInt(border);
- }
- borderBox.val(border);
- _setColor(colorBox.eq(0), K.toHex(cell[0].style.borderColor || ''));
- _setColor(colorBox.eq(1), K.toHex(cell[0].style.backgroundColor || ''));
- widthBox[0].focus();
- widthBox[0].select();
- },
- insert : function() {
- this.prop(true);
- },
- 'delete' : function() {
- var table = self.plugin.getSelectedTable();
- self.cmd.range.setStartBefore(table[0]).collapse(true);
- self.cmd.select();
- table.remove();
- self.addBookmark();
- },
- colinsert : function(offset) {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0],
- index = cell.cellIndex + offset;
- // 取得第一行的index
- index += table.rows[0].cells.length - row.cells.length;
-
- for (var i = 0, len = table.rows.length; i < len; i++) {
- var newRow = table.rows[i],
- newCell = newRow.insertCell(index);
- newCell.innerHTML = K.IE ? '' : ' ';
- // 调整下一行的单元格index
- index = _getCellIndex(table, newRow, newCell);
- }
- self.cmd.range.selectNodeContents(cell).collapse(true);
- self.cmd.select();
- self.addBookmark();
- },
- colinsertleft : function() {
- this.colinsert(0);
- },
- colinsertright : function() {
- this.colinsert(1);
- },
- rowinsert : function(offset) {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0];
- var rowIndex = row.rowIndex;
- if (offset === 1) {
- rowIndex = row.rowIndex + (cell.rowSpan - 1) + offset;
- }
- var newRow = table.insertRow(rowIndex);
-
- for (var i = 0, len = row.cells.length; i < len; i++) {
- // 调整cell个数
- if (row.cells[i].rowSpan > 1) {
- len -= row.cells[i].rowSpan - 1;
- }
- var newCell = newRow.insertCell(i);
- // copy colspan
- if (offset === 1 && row.cells[i].colSpan > 1) {
- newCell.colSpan = row.cells[i].colSpan;
- }
- newCell.innerHTML = K.IE ? '' : ' ';
- }
- // 调整rowspan
- for (var j = rowIndex; j >= 0; j--) {
- var cells = table.rows[j].cells;
- if (cells.length > i) {
- for (var k = cell.cellIndex; k >= 0; k--) {
- if (cells[k].rowSpan > 1) {
- cells[k].rowSpan += 1;
- }
- }
- break;
- }
- }
- self.cmd.range.selectNodeContents(cell).collapse(true);
- self.cmd.select();
- self.addBookmark();
- },
- rowinsertabove : function() {
- this.rowinsert(0);
- },
- rowinsertbelow : function() {
- this.rowinsert(1);
- },
- rowmerge : function() {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0],
- rowIndex = row.rowIndex, // 当前行的index
- nextRowIndex = rowIndex + cell.rowSpan, // 下一行的index
- nextRow = table.rows[nextRowIndex]; // 下一行
- // 最后一行不能合并
- if (table.rows.length <= nextRowIndex) {
- return;
- }
- var cellIndex = cell.cellIndex; // 下一行单元格的index
- if (nextRow.cells.length <= cellIndex) {
- return;
- }
- var nextCell = nextRow.cells[cellIndex]; // 下一行单元格
- // 上下行的colspan不一致时不能合并
- if (cell.colSpan !== nextCell.colSpan) {
- return;
- }
- cell.rowSpan += nextCell.rowSpan;
- nextRow.deleteCell(cellIndex);
- self.cmd.range.selectNodeContents(cell).collapse(true);
- self.cmd.select();
- self.addBookmark();
- },
- colmerge : function() {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0],
- rowIndex = row.rowIndex, // 当前行的index
- cellIndex = cell.cellIndex,
- nextCellIndex = cellIndex + 1;
- // 最后一列不能合并
- if (row.cells.length <= nextCellIndex) {
- return;
- }
- var nextCell = row.cells[nextCellIndex];
- // 左右列的rowspan不一致时不能合并
- if (cell.rowSpan !== nextCell.rowSpan) {
- return;
- }
- cell.colSpan += nextCell.colSpan;
- row.deleteCell(nextCellIndex);
- self.cmd.range.selectNodeContents(cell).collapse(true);
- self.cmd.select();
- self.addBookmark();
- },
- rowsplit : function() {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0],
- rowIndex = row.rowIndex;
- // 不是可分割单元格
- if (cell.rowSpan === 1) {
- return;
- }
- var cellIndex = _getCellIndex(table, row, cell);
- for (var i = 1, len = cell.rowSpan; i < len; i++) {
- var newRow = table.rows[rowIndex + i],
- newCell = newRow.insertCell(cellIndex);
- if (cell.colSpan > 1) {
- newCell.colSpan = cell.colSpan;
- }
- newCell.innerHTML = K.IE ? '' : ' ';
- // 调整下一行的单元格index
- cellIndex = _getCellIndex(table, newRow, newCell);
- }
- K(cell).removeAttr('rowSpan');
- self.cmd.range.selectNodeContents(cell).collapse(true);
- self.cmd.select();
- self.addBookmark();
- },
- colsplit : function() {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0],
- cellIndex = cell.cellIndex;
- // 不是可分割单元格
- if (cell.colSpan === 1) {
- return;
- }
- for (var i = 1, len = cell.colSpan; i < len; i++) {
- var newCell = row.insertCell(cellIndex + i);
- if (cell.rowSpan > 1) {
- newCell.rowSpan = cell.rowSpan;
- }
- newCell.innerHTML = K.IE ? '' : ' ';
- }
- K(cell).removeAttr('colSpan');
- self.cmd.range.selectNodeContents(cell).collapse(true);
- self.cmd.select();
- self.addBookmark();
- },
- coldelete : function() {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0],
- index = cell.cellIndex;
- for (var i = 0, len = table.rows.length; i < len; i++) {
- var newRow = table.rows[i],
- newCell = newRow.cells[index];
- if (newCell.colSpan > 1) {
- newCell.colSpan -= 1;
- if (newCell.colSpan === 1) {
- K(newCell).removeAttr('colSpan');
- }
- } else {
- newRow.deleteCell(index);
- }
- // 跳过不需要删除的行
- if (newCell.rowSpan > 1) {
- i += newCell.rowSpan - 1;
- }
- }
- if (row.cells.length === 0) {
- self.cmd.range.setStartBefore(table).collapse(true);
- self.cmd.select();
- K(table).remove();
- } else {
- self.cmd.selection(true);
- }
- self.addBookmark();
- },
- rowdelete : function() {
- var table = self.plugin.getSelectedTable()[0],
- row = self.plugin.getSelectedRow()[0],
- cell = self.plugin.getSelectedCell()[0],
- rowIndex = row.rowIndex;
- // 从下到上删除
- for (var i = cell.rowSpan - 1; i >= 0; i--) {
- table.deleteRow(rowIndex + i);
- }
- if (table.rows.length === 0) {
- self.cmd.range.setStartBefore(table).collapse(true);
- self.cmd.select();
- K(table).remove();
- } else {
- self.cmd.selection(true);
- }
- self.addBookmark();
- }
- };
- self.clickToolbar(name, self.plugin.table.prop);
-});
+/*******************************************************************************
+* KindEditor - WYSIWYG HTML Editor for Internet
+* Copyright (C) 2006-2011 kindsoft.net
+*
+* @author Roddy
+* @site http://www.kindsoft.net/
+* @licence http://www.kindsoft.net/license.php
+*******************************************************************************/
+
+KindEditor.plugin('table', function(K) {
+ var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
+ // 设置颜色
+ function _setColor(box, color) {
+ color = color.toUpperCase();
+ box.css('background-color', color);
+ box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
+ box.html(color);
+ }
+ // 初始化取色器
+ var pickerList = [];
+ function _initColorPicker(dialogDiv, colorBox) {
+ colorBox.bind('click,mousedown', function(e){
+ e.stopPropagation();
+ });
+ function removePicker() {
+ K.each(pickerList, function() {
+ this.remove();
+ });
+ pickerList = [];
+ K(document).unbind('click,mousedown', removePicker);
+ dialogDiv.unbind('click,mousedown', removePicker);
+ }
+ colorBox.click(function(e) {
+ removePicker();
+ var box = K(this),
+ pos = box.pos();
+ var picker = K.colorpicker({
+ x : pos.x,
+ y : pos.y + box.height(),
+ z : 811214,
+ selectedColor : K(this).html(),
+ colors : self.colorTable,
+ noColor : self.lang('noColor'),
+ shadowMode : self.shadowMode,
+ click : function(color) {
+ _setColor(box, color);
+ removePicker();
+ }
+ });
+ pickerList.push(picker);
+ K(document).bind('click,mousedown', removePicker);
+ dialogDiv.bind('click,mousedown', removePicker);
+ });
+ }
+ // 取得下一行cell的index
+ function _getCellIndex(table, row, cell) {
+ var rowSpanCount = 0;
+ for (var i = 0, len = row.cells.length; i < len; i++) {
+ if (row.cells[i] == cell) {
+ break;
+ }
+ rowSpanCount += row.cells[i].rowSpan - 1;
+ }
+ return cell.cellIndex - rowSpanCount;
+ }
+ self.plugin.table = {
+ //insert or modify table
+ prop : function(isInsert) {
+ var html = [
+ '',
+ //rows, cols
+ '
',
+ '' + lang.cells + ' ',
+ lang.rows + ' ',
+ lang.cols + ' ',
+ '
',
+ //width, height
+ '
',
+ '' + lang.size + ' ',
+ lang.width + ' ',
+ '',
+ '' + lang.percent + ' ',
+ '' + lang.px + ' ',
+ ' ',
+ lang.height + ' ',
+ '',
+ '' + lang.percent + ' ',
+ '' + lang.px + ' ',
+ ' ',
+ '
',
+ //space, padding
+ '
',
+ '' + lang.space + ' ',
+ lang.padding + ' ',
+ lang.spacing + ' ',
+ '
',
+ //align
+ '
',
+ '' + lang.align + ' ',
+ '',
+ '' + lang.alignDefault + ' ',
+ '' + lang.alignLeft + ' ',
+ '' + lang.alignCenter + ' ',
+ '' + lang.alignRight + ' ',
+ ' ',
+ '
',
+ //border
+ '
',
+ '' + lang.border + ' ',
+ lang.borderWidth + ' ',
+ lang.borderColor + ' ',
+ '
',
+ //background color
+ '
',
+ '' + lang.backgroundColor + ' ',
+ ' ',
+ '
',
+ '
'
+ ].join('');
+ var bookmark = self.cmd.range.createBookmark();
+ var dialog = self.createDialog({
+ name : name,
+ width : 500,
+ title : self.lang(name),
+ body : html,
+ beforeRemove : function() {
+ colorBox.unbind();
+ },
+ yesBtn : {
+ name : self.lang('yes'),
+ click : function(e) {
+ if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(self.edit.html())){
+ self.edit.html('');
+ }
+ var rows = rowsBox.val(),
+ cols = colsBox.val(),
+ width = widthBox.val(),
+ height = heightBox.val(),
+ widthType = widthTypeBox.val(),
+ heightType = heightTypeBox.val(),
+ padding = paddingBox.val(),
+ spacing = spacingBox.val(),
+ align = alignBox.val(),
+ border = borderBox.val(),
+ borderColor = K(colorBox[0]).html() || '',
+ bgColor = K(colorBox[1]).html() || '';
+ if (rows == 0 || !/^\d+$/.test(rows)) {
+ alert(self.lang('invalidRows'));
+ rowsBox[0].focus();
+ return;
+ }
+ if (cols == 0 || !/^\d+$/.test(cols)) {
+ alert(self.lang('invalidRows'));
+ colsBox[0].focus();
+ return;
+ }
+ if (!/^\d*$/.test(width)) {
+ alert(self.lang('invalidWidth'));
+ widthBox[0].focus();
+ return;
+ }
+ if (!/^\d*$/.test(height)) {
+ alert(self.lang('invalidHeight'));
+ heightBox[0].focus();
+ return;
+ }
+ if (!/^\d*$/.test(padding)) {
+ alert(self.lang('invalidPadding'));
+ paddingBox[0].focus();
+ return;
+ }
+ if (!/^\d*$/.test(spacing)) {
+ alert(self.lang('invalidSpacing'));
+ spacingBox[0].focus();
+ return;
+ }
+ if (!/^\d*$/.test(border)) {
+ alert(self.lang('invalidBorder'));
+ borderBox[0].focus();
+ return;
+ }
+ //modify table
+ if (table) {
+ if (width !== '') {
+ table.width(width + widthType);
+ } else {
+ table.css('width', '');
+ }
+ if (table[0].width !== undefined) {
+ table.removeAttr('width');
+ }
+ if (height !== '') {
+ table.height(height + heightType);
+ } else {
+ table.css('height', '');
+ }
+ if (table[0].height !== undefined) {
+ table.removeAttr('height');
+ }
+ table.css('background-color', bgColor);
+ if (table[0].bgColor !== undefined) {
+ table.removeAttr('bgColor');
+ }
+ if (padding !== '') {
+ table[0].cellPadding = padding;
+ } else {
+ table.removeAttr('cellPadding');
+ }
+ if (spacing !== '') {
+ table[0].cellSpacing = spacing;
+ } else {
+ table.removeAttr('cellSpacing');
+ }
+ if (align !== '') {
+ table[0].align = align;
+ } else {
+ table.removeAttr('align');
+ }
+ if (border !== '') {
+ table.attr('border', border);
+ } else {
+ table.removeAttr('border');
+ }
+ if (border === '' || border === '0') {
+ table.addClass(zeroborder);
+ } else {
+ table.removeClass(zeroborder);
+ }
+ if (borderColor !== '') {
+ table.attr('borderColor', borderColor);
+ table.css("border-color",borderColor);
+ } else {
+ table.removeAttr('borderColor');
+ table.css("border-color","none");
+ }
+ self.hideDialog().focus();
+ self.cmd.range.moveToBookmark(bookmark);
+ self.cmd.select();
+ self.addBookmark();
+ return;
+ }
+ //insert new table
+ var style = '';
+ if (width !== '') {
+ style += 'width:' + width + widthType + ';';
+ }
+ if (height !== '') {
+ style += 'height:' + height + heightType + ';';
+ }
+ if (bgColor !== '') {
+ style += 'background-color:' + bgColor + ';';
+ }
+ if (border !== ''){
+ style += 'border:'+border+'px solid;';
+ }
+ if (borderColor !== ''){
+ style += 'border-color:'+borderColor+';';
+ }
+ style += 'table-layout: '+'fixed;';
+ var html = '';
+ for (var i = 0; i < rows; i++) {
+ html += '';
+ for (var j = 0; j < cols; j++) {
+ html += '' + (K.IE ? ' ' : ' ') + ' ';
+ }
+ html += ' ';
+ }
+ html += '
';
+ if (!K.IE) {
+ html += ' ';
+ }
+ self.insertHtml(html);
+ self.select().hideDialog().focus();
+ self.addBookmark();
+ }
+ }
+ }),
+ div = dialog.div,
+ rowsBox = K('[name="rows"]', div).val(3),
+ colsBox = K('[name="cols"]', div).val(2),
+ widthBox = K('[name="width"]', div).val(100),
+ heightBox = K('[name="height"]', div),
+ widthTypeBox = K('[name="widthType"]', div),
+ heightTypeBox = K('[name="heightType"]', div),
+ paddingBox = K('[name="padding"]', div).val(2),
+ spacingBox = K('[name="spacing"]', div).val(0),
+ alignBox = K('[name="align"]', div),
+ borderBox = K('[name="border"]', div).val(1),
+ colorBox = K('.ke-input-color', div);
+ _initColorPicker(div, colorBox.eq(0));
+ _initColorPicker(div, colorBox.eq(1));
+ _setColor(colorBox.eq(0), '#000000');
+ _setColor(colorBox.eq(1), '');
+ // foucs and select
+ rowsBox[0].focus();
+ rowsBox[0].select();
+ var table;
+ if (isInsert) {
+ return;
+ }
+ //get selected table node
+ table = self.plugin.getSelectedTable();
+ if (table) {
+ rowsBox.val(table[0].rows.length);
+ colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
+ rowsBox.attr('disabled', true);
+ colsBox.attr('disabled', true);
+ var match,
+ tableWidth = table[0].style.width || table[0].width,
+ tableHeight = table[0].style.height || table[0].height;
+ if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
+ widthBox.val(match[1]);
+ widthTypeBox.val(match[2]);
+ } else {
+ widthBox.val('');
+ }
+ if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
+ heightBox.val(match[1]);
+ heightTypeBox.val(match[2]);
+ }
+ paddingBox.val(table[0].cellPadding || '');
+ spacingBox.val(table[0].cellSpacing || '');
+ alignBox.val(table[0].align || '');
+ borderBox.val(table[0].border === undefined ? '' : table[0].border);
+ _setColor(colorBox.eq(0), K.toHex(table.attr('borderColor') || ''));
+ _setColor(colorBox.eq(1), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
+ widthBox[0].focus();
+ widthBox[0].select();
+ }
+ },
+ //modify cell
+ cellprop : function() {
+ var html = [
+ '',
+ //width, height
+ '
',
+ '' + lang.size + ' ',
+ lang.width + ' ',
+ '',
+ '' + lang.percent + ' ',
+ '' + lang.px + ' ',
+ ' ',
+ lang.height + ' ',
+ '',
+ '' + lang.percent + ' ',
+ '' + lang.px + ' ',
+ ' ',
+ '
',
+ //align
+ '
',
+ '' + lang.align + ' ',
+ lang.textAlign + ' ',
+ '' + lang.alignDefault + ' ',
+ '' + lang.alignLeft + ' ',
+ '' + lang.alignCenter + ' ',
+ '' + lang.alignRight + ' ',
+ ' ',
+ lang.verticalAlign + ' ',
+ '' + lang.alignDefault + ' ',
+ '' + lang.alignTop + ' ',
+ '' + lang.alignMiddle + ' ',
+ '' + lang.alignBottom + ' ',
+ '' + lang.alignBaseline + ' ',
+ ' ',
+ '
',
+ //border
+ '
',
+ '' + lang.border + ' ',
+ lang.borderWidth + ' ',
+ lang.borderColor + ' ',
+ '
',
+ //background color
+ '
',
+ '' + lang.backgroundColor + ' ',
+ ' ',
+ '
',
+ '
'
+ ].join('');
+ var bookmark = self.cmd.range.createBookmark();
+ var dialog = self.createDialog({
+ name : name,
+ width : 500,
+ title : self.lang('tablecell'),
+ body : html,
+ beforeRemove : function() {
+ colorBox.unbind();
+ },
+ yesBtn : {
+ name : self.lang('yes'),
+ click : function(e) {
+ var width = widthBox.val(),
+ height = heightBox.val(),
+ widthType = widthTypeBox.val(),
+ heightType = heightTypeBox.val(),
+ padding = paddingBox.val(),
+ spacing = spacingBox.val(),
+ textAlign = textAlignBox.val(),
+ verticalAlign = verticalAlignBox.val(),
+ border = borderBox.val(),
+ borderColor = K(colorBox[0]).html() || '',
+ bgColor = K(colorBox[1]).html() || '';
+ if (!/^\d*$/.test(width)) {
+ alert(self.lang('invalidWidth'));
+ widthBox[0].focus();
+ return;
+ }
+ if (!/^\d*$/.test(height)) {
+ alert(self.lang('invalidHeight'));
+ heightBox[0].focus();
+ return;
+ }
+ if (!/^\d*$/.test(border)) {
+ alert(self.lang('invalidBorder'));
+ borderBox[0].focus();
+ return;
+ }
+ cell.css({
+ width : width !== '' ? (width + widthType) : '',
+ height : height !== '' ? (height + heightType) : '',
+ 'background-color' : bgColor,
+ 'text-align' : textAlign,
+ 'vertical-align' : verticalAlign,
+ 'border-width' : border,
+ 'border-style' : border !== '' ? 'solid' : '',
+ 'border-color' : borderColor
+ });
+ self.hideDialog().focus();
+ self.cmd.range.moveToBookmark(bookmark);
+ self.cmd.select();
+ self.addBookmark();
+ }
+ }
+ }),
+ div = dialog.div,
+ widthBox = K('[name="width"]', div).val(100),
+ heightBox = K('[name="height"]', div),
+ widthTypeBox = K('[name="widthType"]', div),
+ heightTypeBox = K('[name="heightType"]', div),
+ paddingBox = K('[name="padding"]', div).val(2),
+ spacingBox = K('[name="spacing"]', div).val(0),
+ textAlignBox = K('[name="textAlign"]', div),
+ verticalAlignBox = K('[name="verticalAlign"]', div),
+ borderBox = K('[name="border"]', div).val(1),
+ colorBox = K('.ke-input-color', div);
+ _initColorPicker(div, colorBox.eq(0));
+ _initColorPicker(div, colorBox.eq(1));
+ _setColor(colorBox.eq(0), '#000000');
+ _setColor(colorBox.eq(1), '');
+ // foucs and select
+ widthBox[0].focus();
+ widthBox[0].select();
+ // get selected cell
+ var cell = self.plugin.getSelectedCell();
+ var match,
+ cellWidth = cell[0].style.width || cell[0].width || '',
+ cellHeight = cell[0].style.height || cell[0].height || '';
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
+ widthBox.val(match[1]);
+ widthTypeBox.val(match[2]);
+ } else {
+ widthBox.val('');
+ }
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
+ heightBox.val(match[1]);
+ heightTypeBox.val(match[2]);
+ }
+ textAlignBox.val(cell[0].style.textAlign || '');
+ verticalAlignBox.val(cell[0].style.verticalAlign || '');
+ var border = cell[0].style.borderWidth || '';
+ if (border) {
+ border = parseInt(border);
+ }
+ borderBox.val(border);
+ _setColor(colorBox.eq(0), K.toHex(cell[0].style.borderColor || ''));
+ _setColor(colorBox.eq(1), K.toHex(cell[0].style.backgroundColor || ''));
+ widthBox[0].focus();
+ widthBox[0].select();
+ },
+ insert : function() {
+ this.prop(true);
+ },
+ 'delete' : function() {
+ var table = self.plugin.getSelectedTable();
+ self.cmd.range.setStartBefore(table[0]).collapse(true);
+ self.cmd.select();
+ table.remove();
+ self.addBookmark();
+ },
+ colinsert : function(offset) {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0],
+ index = cell.cellIndex + offset;
+ // 取得第一行的index
+ index += table.rows[0].cells.length - row.cells.length;
+
+ for (var i = 0, len = table.rows.length; i < len; i++) {
+ var newRow = table.rows[i],
+ newCell = newRow.insertCell(index);
+ newCell.innerHTML = K.IE ? '' : ' ';
+ // 调整下一行的单元格index
+ index = _getCellIndex(table, newRow, newCell);
+ }
+ self.cmd.range.selectNodeContents(cell).collapse(true);
+ self.cmd.select();
+ self.addBookmark();
+ },
+ colinsertleft : function() {
+ this.colinsert(0);
+ },
+ colinsertright : function() {
+ this.colinsert(1);
+ },
+ rowinsert : function(offset) {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0];
+ var rowIndex = row.rowIndex;
+ if (offset === 1) {
+ rowIndex = row.rowIndex + (cell.rowSpan - 1) + offset;
+ }
+ var newRow = table.insertRow(rowIndex);
+
+ for (var i = 0, len = row.cells.length; i < len; i++) {
+ // 调整cell个数
+ if (row.cells[i].rowSpan > 1) {
+ len -= row.cells[i].rowSpan - 1;
+ }
+ var newCell = newRow.insertCell(i);
+ // copy colspan
+ if (offset === 1 && row.cells[i].colSpan > 1) {
+ newCell.colSpan = row.cells[i].colSpan;
+ }
+ newCell.innerHTML = K.IE ? '' : ' ';
+ }
+ // 调整rowspan
+ for (var j = rowIndex; j >= 0; j--) {
+ var cells = table.rows[j].cells;
+ if (cells.length > i) {
+ for (var k = cell.cellIndex; k >= 0; k--) {
+ if (cells[k].rowSpan > 1) {
+ cells[k].rowSpan += 1;
+ }
+ }
+ break;
+ }
+ }
+ self.cmd.range.selectNodeContents(cell).collapse(true);
+ self.cmd.select();
+ self.addBookmark();
+ },
+ rowinsertabove : function() {
+ this.rowinsert(0);
+ },
+ rowinsertbelow : function() {
+ this.rowinsert(1);
+ },
+ rowmerge : function() {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0],
+ rowIndex = row.rowIndex, // 当前行的index
+ nextRowIndex = rowIndex + cell.rowSpan, // 下一行的index
+ nextRow = table.rows[nextRowIndex]; // 下一行
+ // 最后一行不能合并
+ if (table.rows.length <= nextRowIndex) {
+ return;
+ }
+ var cellIndex = cell.cellIndex; // 下一行单元格的index
+ if (nextRow.cells.length <= cellIndex) {
+ return;
+ }
+ var nextCell = nextRow.cells[cellIndex]; // 下一行单元格
+ // 上下行的colspan不一致时不能合并
+ if (cell.colSpan !== nextCell.colSpan) {
+ return;
+ }
+ cell.rowSpan += nextCell.rowSpan;
+ nextRow.deleteCell(cellIndex);
+ self.cmd.range.selectNodeContents(cell).collapse(true);
+ self.cmd.select();
+ self.addBookmark();
+ },
+ colmerge : function() {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0],
+ rowIndex = row.rowIndex, // 当前行的index
+ cellIndex = cell.cellIndex,
+ nextCellIndex = cellIndex + 1;
+ // 最后一列不能合并
+ if (row.cells.length <= nextCellIndex) {
+ return;
+ }
+ var nextCell = row.cells[nextCellIndex];
+ // 左右列的rowspan不一致时不能合并
+ if (cell.rowSpan !== nextCell.rowSpan) {
+ return;
+ }
+ cell.colSpan += nextCell.colSpan;
+ row.deleteCell(nextCellIndex);
+ self.cmd.range.selectNodeContents(cell).collapse(true);
+ self.cmd.select();
+ self.addBookmark();
+ },
+ rowsplit : function() {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0],
+ rowIndex = row.rowIndex;
+ // 不是可分割单元格
+ if (cell.rowSpan === 1) {
+ return;
+ }
+ var cellIndex = _getCellIndex(table, row, cell);
+ for (var i = 1, len = cell.rowSpan; i < len; i++) {
+ var newRow = table.rows[rowIndex + i],
+ newCell = newRow.insertCell(cellIndex);
+ if (cell.colSpan > 1) {
+ newCell.colSpan = cell.colSpan;
+ }
+ newCell.innerHTML = K.IE ? '' : ' ';
+ // 调整下一行的单元格index
+ cellIndex = _getCellIndex(table, newRow, newCell);
+ }
+ K(cell).removeAttr('rowSpan');
+ self.cmd.range.selectNodeContents(cell).collapse(true);
+ self.cmd.select();
+ self.addBookmark();
+ },
+ colsplit : function() {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0],
+ cellIndex = cell.cellIndex;
+ // 不是可分割单元格
+ if (cell.colSpan === 1) {
+ return;
+ }
+ for (var i = 1, len = cell.colSpan; i < len; i++) {
+ var newCell = row.insertCell(cellIndex + i);
+ if (cell.rowSpan > 1) {
+ newCell.rowSpan = cell.rowSpan;
+ }
+ newCell.innerHTML = K.IE ? '' : ' ';
+ }
+ K(cell).removeAttr('colSpan');
+ self.cmd.range.selectNodeContents(cell).collapse(true);
+ self.cmd.select();
+ self.addBookmark();
+ },
+ coldelete : function() {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0],
+ index = cell.cellIndex;
+ for (var i = 0, len = table.rows.length; i < len; i++) {
+ var newRow = table.rows[i],
+ newCell = newRow.cells[index];
+ if (newCell.colSpan > 1) {
+ newCell.colSpan -= 1;
+ if (newCell.colSpan === 1) {
+ K(newCell).removeAttr('colSpan');
+ }
+ } else {
+ newRow.deleteCell(index);
+ }
+ // 跳过不需要删除的行
+ if (newCell.rowSpan > 1) {
+ i += newCell.rowSpan - 1;
+ }
+ }
+ if (row.cells.length === 0) {
+ self.cmd.range.setStartBefore(table).collapse(true);
+ self.cmd.select();
+ K(table).remove();
+ } else {
+ self.cmd.selection(true);
+ }
+ self.addBookmark();
+ },
+ rowdelete : function() {
+ var table = self.plugin.getSelectedTable()[0],
+ row = self.plugin.getSelectedRow()[0],
+ cell = self.plugin.getSelectedCell()[0],
+ rowIndex = row.rowIndex;
+ // 从下到上删除
+ for (var i = cell.rowSpan - 1; i >= 0; i--) {
+ table.deleteRow(rowIndex + i);
+ }
+ if (table.rows.length === 0) {
+ self.cmd.range.setStartBefore(table).collapse(true);
+ self.cmd.select();
+ K(table).remove();
+ } else {
+ self.cmd.selection(true);
+ }
+ self.addBookmark();
+ }
+ };
+ self.clickToolbar(name, self.plugin.table.prop);
+});
diff --git a/public/javascripts/create_kindeditor.js b/public/javascripts/create_kindeditor.js
index fc2ac8938..8989f8716 100644
--- a/public/javascripts/create_kindeditor.js
+++ b/public/javascripts/create_kindeditor.js
@@ -1,177 +1,183 @@
-//需求:表情栏可以隐藏显示,高度只要一点高
-function sd_create_editor(params){
- // var minHeight; //最小高度
- var paramsHeight = params.height; //设定的高度
- var id = arguments[1] ? arguments[1] : undefined;
- var type = arguments[2] ? arguments[2] : '';
- var paramsWidth = params.width == undefined ? "100%" : params.width;
-
- var editor = params.kindutil.create(params.textarea, {
- resizeType : 1,minWidth:"1px",width:"94%",
- height:"33px",// == undefined ? "30px":paramsHeight+"px",
- minHeight:"33px",// == undefined ? "30px":paramsHeight+"px",
- width:params.width,
- items:['emoticons','fontname',
- 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
- 'formatblock', 'fontsize', '|','indent', 'outdent',
- '|','imagedirectupload','more'],
- afterChange:function(){//按键事件
- var edit = this.edit;
- var body = edit.doc.body;
- edit.iframe.height(paramsHeight);
- this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : (params.kindutil.GECKO ? body.offsetHeight+26:body.offsetHeight)) , paramsHeight));
- },
- afterBlur:function(){
- //params.toolbar_container.hide();
- sd_check_editor_form_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
- if(this.isEmpty()) {
- this.edit.html("我要回复 ");
- }
- //params.toolbar_container.hide();
- $('#reply_image_' + id).addClass('imageFuzzy');
- if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())){
- params.submit_btn.hide();
- params.toolbar_container.hide();
- this.resize("100%", null);
- }else if(this.edit.html().trim() != ""){
- params.submit_btn.show();
- params.toolbar_container.show();
- }
-
- //params.submit_btn.css("display","none");
- },
- afterFocus: function(){
- var edit = this.edit;
- var body = edit.doc.body;
- if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
- edit.html('');
- }
- params.submit_btn.show();
- params.contentmsg.hide();
- params.toolbar_container.show();
- // params.toolbar_container.show();
- $('#reply_image_' + id).removeClass('imageFuzzy');
- //edit.iframe.width(paramsWidth);
- this.resize(paramsWidth, null);
- //params.submit_btn.show();
- },
-
- afterCreate:function(){
- //params.submit_btn.hide();
- var toolbar = $("div[class='ke-toolbar']",params.div_form);
- toolbar.css('display','inline');
- toolbar.css('padding',0);
- $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
- params.toolbar_container.append(toolbar);
- params.toolbar_container.hide();
- //init
- var edit = this.edit;
- var body = edit.doc.body;
- edit.iframe[0].scroll = 'no';
- body.style.overflowY = 'hidden';
- //reset height
- paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
- edit.iframe.height(paramsHeight);
- edit.html("我要回复 ");
- this.resize(null,paramsHeight);// Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ paramsHeight , paramsHeight)
- // params.toolbar_container.hide();
- if(typeof enableAt === 'function'){
- enableAt(this, id, type);
- }
- }
- }).loadPlugin('paste');
- return editor;
-}
-
-function sd_check_editor_form_field(params){
- var result=true;
- if(params.content!=undefined){
- if(params.content.isEmpty()){
- result=false;
- }
- if(params.content.html()!=params.textarea.html() || params.issubmit==true){
- params.textarea.html(params.content.html());
- params.content.sync();
- if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.textarea.html())){
- params.contentmsg.html('内容不能为空');
- params.contentmsg.css({color:'#ff0000'});
- }else{
- params.contentmsg.html('填写正确');
- params.contentmsg.css({color:'#008000'});
- }
- params.contentmsg.show();
- }
- }
- return result;
-}
-function sd_create_form(params){
- params.form.submit(function(){
- var flag = false;
- if(params.form.attr('data-remote') != undefined ){
- flag = true
- }
- var is_checked = sd_check_editor_form_field({
- issubmit:true,
- content:params.editor,
- contentmsg:params.contentmsg,
- textarea:params.textarea
- });
- if(is_checked){
- if(flag){
- return true;
- }else{
- $(this)[0].submit();
- return false;
- }
- }
- return false;
- });
-}
-function sd_reset_editor_form(params){
- params.form[0].reset();
- params.textarea.empty();
- if(params.editor != undefined){
- params.editor.html(params.textarea.html());
- }
- params.contentmsg.hide();
-}
-//第二个参数是高度,可以传,可以不传
-function sd_create_editor_from_data(id){
- var height = arguments[1] ? arguments[1] : undefined;
- var width = arguments[2] ? arguments[2] : undefined;
- var type = arguments[3] ? arguments[3] : undefined;
- KindEditor.ready(function (K) {
- $("div[nhname='new_message_" + id + "']").each(function () {
- var params = {};
- params.kindutil = K;
- params.div_form = $(this);
- params.form = $("form", params.div_form);
- if (params.form == undefined || params.form.length == 0) {
- return;
- }
- params.textarea = $("textarea[nhname='new_message_textarea_" + id + "']", params.div_form);
- params.contentmsg = $("span[nhname='contentmsg_" + id + "']", params.div_form);
- params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form);
- params.cancel_btn = $("#new_message_cancel_btn_" + id);
- params.submit_btn = $("#new_message_submit_btn_" + id);
- params.height = height;
- params.width = width;
- if (params.textarea.data('init') == undefined) {
- params.editor = sd_create_editor(params,id, type);
- sd_create_form(params);
- params.cancel_btn.click(function () {
- sd_reset_editor_form(params);
- });
- params.submit_btn.click(function () {
- params.form.submit();
- });
- params.textarea.data('init', 1);
- $(this).show();
- }
- });
- });
-
- div_form = $("div[nhname='new_message_" + id + "']");
- $(".ke-edit", div_form).css("height","33px");
- $(".ke-edit-iframe",div_form).css("height","33px");
+//需求:表情栏可以隐藏显示,高度只要一点高
+function sd_create_editor(params){
+ // var minHeight; //最小高度
+ var paramsHeight = params.height; //设定的高度
+ var id = arguments[1] ? arguments[1] : undefined;
+ var type = arguments[2] ? arguments[2] : '';
+ var paramsWidth = params.width == undefined ? "100%" : params.width;
+
+ var editor = params.kindutil.create(params.textarea, {
+ resizeType : 1,minWidth:"1px",width:"94%",
+ height:"33px",// == undefined ? "30px":paramsHeight+"px",
+ minHeight:"33px",// == undefined ? "30px":paramsHeight+"px",
+ width:params.width,
+ /*
+ items:['emoticons','fontname',
+ 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
+ 'formatblock', 'fontsize', '|','indent', 'outdent',
+ '|','imagedirectupload','more'],*/
+ items : ['code','emoticons','fontname',
+ 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
+ 'formatblock', 'fontsize', '|','indent', 'outdent',
+ '|','imagedirectupload','table', 'media', 'preview',"more"
+ ],
+ afterChange:function(){//按键事件
+ var edit = this.edit;
+ var body = edit.doc.body;
+ edit.iframe.height(paramsHeight);
+ this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : (params.kindutil.GECKO ? body.offsetHeight+26:body.offsetHeight)) , paramsHeight));
+ },
+ afterBlur:function(){
+ //params.toolbar_container.hide();
+ sd_check_editor_form_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
+ if(this.isEmpty()) {
+ this.edit.html("我要回复 ");
+ }
+ //params.toolbar_container.hide();
+ $('#reply_image_' + id).addClass('imageFuzzy');
+ if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())){
+ params.submit_btn.hide();
+ params.toolbar_container.hide();
+ this.resize("100%", null);
+ }else if(this.edit.html().trim() != ""){
+ params.submit_btn.show();
+ params.toolbar_container.show();
+ }
+
+ //params.submit_btn.css("display","none");
+ },
+ afterFocus: function(){
+ var edit = this.edit;
+ var body = edit.doc.body;
+ if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
+ edit.html('');
+ }
+ params.submit_btn.show();
+ params.contentmsg.hide();
+ params.toolbar_container.show();
+ // params.toolbar_container.show();
+ $('#reply_image_' + id).removeClass('imageFuzzy');
+ //edit.iframe.width(paramsWidth);
+ this.resize(paramsWidth, null);
+ //params.submit_btn.show();
+ },
+
+ afterCreate:function(){
+ //params.submit_btn.hide();
+ var toolbar = $("div[class='ke-toolbar']",params.div_form);
+ toolbar.css('display','inline');
+ toolbar.css('padding',0);
+ $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
+ params.toolbar_container.append(toolbar);
+ params.toolbar_container.hide();
+ //init
+ var edit = this.edit;
+ var body = edit.doc.body;
+ edit.iframe[0].scroll = 'no';
+ body.style.overflowY = 'hidden';
+ //reset height
+ paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
+ edit.iframe.height(paramsHeight);
+ edit.html("我要回复 ");
+ this.resize(null,paramsHeight);// Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ paramsHeight , paramsHeight)
+ // params.toolbar_container.hide();
+ if(typeof enableAt === 'function'){
+ enableAt(this, id, type);
+ }
+ }
+ }).loadPlugin('paste');
+ return editor;
+}
+
+function sd_check_editor_form_field(params){
+ var result=true;
+ if(params.content!=undefined){
+ if(params.content.isEmpty()){
+ result=false;
+ }
+ if(params.content.html()!=params.textarea.html() || params.issubmit==true){
+ params.textarea.html(params.content.html());
+ params.content.sync();
+ if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.textarea.html())){
+ params.contentmsg.html('内容不能为空');
+ params.contentmsg.css({color:'#ff0000'});
+ }else{
+ params.contentmsg.html('填写正确');
+ params.contentmsg.css({color:'#008000'});
+ }
+ params.contentmsg.show();
+ }
+ }
+ return result;
+}
+function sd_create_form(params){
+ params.form.submit(function(){
+ var flag = false;
+ if(params.form.attr('data-remote') != undefined ){
+ flag = true
+ }
+ var is_checked = sd_check_editor_form_field({
+ issubmit:true,
+ content:params.editor,
+ contentmsg:params.contentmsg,
+ textarea:params.textarea
+ });
+ if(is_checked){
+ if(flag){
+ return true;
+ }else{
+ $(this)[0].submit();
+ return false;
+ }
+ }
+ return false;
+ });
+}
+function sd_reset_editor_form(params){
+ params.form[0].reset();
+ params.textarea.empty();
+ if(params.editor != undefined){
+ params.editor.html(params.textarea.html());
+ }
+ params.contentmsg.hide();
+}
+//第二个参数是高度,可以传,可以不传
+function sd_create_editor_from_data(id){
+ var height = arguments[1] ? arguments[1] : undefined;
+ var width = arguments[2] ? arguments[2] : undefined;
+ var type = arguments[3] ? arguments[3] : undefined;
+ KindEditor.ready(function (K) {
+ $("div[nhname='new_message_" + id + "']").each(function () {
+ var params = {};
+ params.kindutil = K;
+ params.div_form = $(this);
+ params.form = $("form", params.div_form);
+ if (params.form == undefined || params.form.length == 0) {
+ return;
+ }
+ params.textarea = $("textarea[nhname='new_message_textarea_" + id + "']", params.div_form);
+ params.contentmsg = $("span[nhname='contentmsg_" + id + "']", params.div_form);
+ params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form);
+ params.cancel_btn = $("#new_message_cancel_btn_" + id);
+ params.submit_btn = $("#new_message_submit_btn_" + id);
+ params.height = height;
+ params.width = width;
+ if (params.textarea.data('init') == undefined) {
+ params.editor = sd_create_editor(params,id, type);
+ sd_create_form(params);
+ params.cancel_btn.click(function () {
+ sd_reset_editor_form(params);
+ });
+ params.submit_btn.click(function () {
+ params.form.submit();
+ });
+ params.textarea.data('init', 1);
+ $(this).show();
+ }
+ });
+ });
+
+ div_form = $("div[nhname='new_message_" + id + "']");
+ $(".ke-edit", div_form).css("height","33px");
+ $(".ke-edit-iframe",div_form).css("height","33px");
}
\ No newline at end of file
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 8e83f2e18..108f1cd2e 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -1286,7 +1286,9 @@ a.chooseActive {background-color:#269ac9; color:#ffffff;}
.subjectType {width:70px; text-align:center;}
.subjectCount {width:65px; text-align:center;}
a.contributor_course{float: right; color: #888; font-size: 12px; font-weight: normal;}
-.contributor_course_innor{font-size: 12px;color: #888;padding-left: 36px;}
-.hero_course_innor{font-size: 12px;color: #888;padding-left:77px;}
-.contributor_course_calculate{padding-left: 54px; font-size: 12px;color: #888}
-.color_888{color: #888}
+.active-degree-rule{font-size: 12px;color: #888; text-align: center; cursor: pointer;}
+.hero-degree-rule{font-size: 12px;color: #888;text-align: center;}
+.contributor-course-calculate{padding-left: 54px; font-size: 12px;color: #888}
+
+/*20160310分班样式*/
+.select-class-option {width:125px;}
diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css
index f321d6eab..2b1caefce 100644
--- a/public/stylesheets/new_user.css
+++ b/public/stylesheets/new_user.css
@@ -692,7 +692,7 @@ a.postReplyCancel:hover {color:#ffffff;}
.homepagePostSetting {position:absolute; width:20px; height:20px; right:0px; top:0px;}
.homepagePostSetting ul li:hover ul {display:block;}
.homepagePostSettingIcon {background:url(../images/homepage_icon.png) -93px -5px no-repeat; width:20px; height:20px;}
-.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;}
+.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;z-index:999;}
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
.whiteSettingIcon {background:url(../images/hwork_icon.png) -5px -302px no-repeat; width:20px; height:20px;}
.whiteSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
@@ -1481,4 +1481,4 @@ a.choose-active {background-color:#269ac9; color:#ffffff;}
.subject-list-from {width:105px; text-align:center;}
/*视频播放默认图标*/
-.mediaIco{margin: 30px 0 30px 20px;}
\ No newline at end of file
+.mediaIco{margin: 30px 0 30px 20px;}
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index 4842f0542..9ea718295 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -66,6 +66,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.ml15{ margin-left:15px;}
.ml16{ margin-left: 16px;}
.ml20{ margin-left:20px;}
+.ml25 {margin-left:25px;}
.ml30{margin-left:30px !important;}
.ml35{margin-left: 35px;}
.ml40{ margin-left:40px;}
@@ -144,6 +145,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.w80{ width:80px;}
.w90{ width:90px;}
.w100{width: 100px;}
+.w125{width:125px;}
.w210{ width:210px;}
.w150{ width:150px;}
.w170{width:170px;}
@@ -615,7 +617,7 @@ a.postReplyCancel:hover {color:#ffffff;}
.homepagePostReplyContainer {border-bottom:1px solid #e3e3e3; width:690px; margin:0px auto; margin-top:15px; min-height:60px;}
.homepagePostSetting {position:absolute; width:20px; height:20px; right:0px; top:0px;}
.homepagePostSettingIcon {background:url(../images/homepage_icon.png) -93px -5px no-repeat; width:20px; height:20px;}
-.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;}
+.homepagePostSettiongText {width:85px; line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:-68px; top:20px; padding:5px 0px; display:none;z-index:999;}
.homepagePostSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
.whiteSettingIcon {background:url(../images/hwork_icon.png) -5px -302px no-repeat; width:20px; height:20px;}
.whiteSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;}
@@ -1130,4 +1132,4 @@ a.group-btn{ background: url(../images/course/hwork_icon.png) -2px -58px no-rep
a.program-btn{background: url(../images/homepage_icon.png) -86px -393px no-repeat; width:30px; height:20px; display:block; padding-left:23px; color:#888888;}
/*视频播放默认图标*/
-.mediaIco{margin: 30px 0 30px 20px;}
\ No newline at end of file
+.mediaIco{margin: 30px 0 30px 20px;}