diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index cec419eba..90981b52a 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -51,6 +51,37 @@ class AdminController < ApplicationController
end
end
+ #管理员界面精品课程列表
+ def excellent_courses
+ @courses = Course.where("is_excellent =? or excellent_option =?", 1, 1 )
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #管理员界面课程资源列表
+ def course_resource_list
+ @resource = Attachment.where(:container_type => 'Course')
+ @resource = paginateHelper @resource,30
+ @page = (params['page'] || 1).to_i - 1
+
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #管理员界面項目资源列表
+ def project_resource_list
+ @pro_resource = Attachment.where(:container_type => 'Project')
+ @pro_resource = paginateHelper @pro_resource,30
+ @page = (params['page'] || 1).to_i - 1
+
+ respond_to do |format|
+ format.html
+ end
+ end
+
+
def users
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
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..f06a782bc 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -240,6 +240,18 @@ class CoursesController < ApplicationController
# req[:message] = l(:modal_valid_passing) if req[:message].blank?
render :json => req
end
+
+ def teacher_assign_group
+ member = Member.where(:course_id => @course.id, :user_id => params[:user_id]).first
+ member.course_group_id = params[:course_group_id].to_i
+ member.save
+ @course_groups = @course.course_groups
+ @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
+ respond_to do |format|
+ format.js
+ end
+ end
+
def join_group
@subPage_title = l :label_student_list
group = CourseGroup.find(params[:object_id])
@@ -838,6 +850,8 @@ class CoursesController < ApplicationController
# render_403
# return
# end
+ # 统计访问量
+ @course.update_attribute(:visits, @course.visits.to_i + 1)
#更新创建课程消息状态
create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
create_course_messages.update_all(:viewed => true)
@@ -1067,7 +1081,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 +1093,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..b6ac99f11 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"
@@ -865,9 +854,7 @@ class FilesController < ApplicationController
@result = visable_attachemnts @result
if params[:other]
@result = @result.select{|attachment|
- attachment.tag_list.exclude?('软件') &&
- attachment.tag_list.exclude?('媒体') &&
- attachment.tag_list.exclude?('代码')
+ attachment.tag_list.index{|tag|tag != '软件' and tag != '媒体' and tag != '代码'}.present?
}
else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
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/news_controller.rb b/app/controllers/news_controller.rb
index 0962deb10..f45e1dbd7 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -107,32 +107,18 @@ class NewsController < ApplicationController
def show
# 更新news对应的forge_messages的消息viewed字段
+ ids = @news.comments.map { |comment| comment.id }.join(",") unless @news.comments.nil?
if @project
- query_message_news = @news.forge_messages
+ # 更新新闻
+ query_message_news = ForgeMessage.where("forge_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first
+ # 更新新闻的时候一并更新回复
+ ForgeMessage.where("forge_message_id in (#{ids}) and forge_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank?
else
- query_message_news = @news.course_messages
+ query_message_news = CourseMessage.where("course_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first
+ CourseMessage.where("course_message_id in (#{ids}) and course_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank?
end
- query_message_news.each do |query|
- if User.current.id == query.user_id
- query.update_attributes(:viewed => true)
- end
- end
- # 更新项目新闻的评阅的消息viewed字段
- current_message_comments = @news.comments
- current_message_comments.each do |current_message_comment|
- if @project
- query_message_comment = current_message_comment.forge_messages
- else
- query_message_comment = current_message_comment.course_messages
- end
- query_message_comment.each do |query|
- if User.current.id == query.user_id
- query.update_attributes(:viewed => true)
- end
- end
- end
- # end
-
+ query_message_news.update_attribute(:viewed, true) unless query_message_news.nil?
+ # over
cs = CoursesService.new
result = cs.show_course_news params,User.current
@news = result[:news]
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index 9fd5e51ee..239253d82 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -69,6 +69,8 @@ class OrganizationsController < ApplicationController
def show
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
+ # 统计访问量
+ @organization.update_attribute(:visits, @organization.visits.to_i + 1)
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index b650afe1b..05c80a9fc 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -298,6 +298,8 @@ class ProjectsController < ApplicationController
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
end
+ # 统计访问量
+ @project.update_attribute(:visits, @project.visits.to_i + 1)
=begin
cond = @project.project_condition(Setting.display_subprojects_issues?)
has = {
@@ -406,6 +408,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..aa77e2d51 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -36,6 +36,14 @@ class StudentWorkController < ApplicationController
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
@@ -91,25 +99,27 @@ class StudentWorkController < ApplicationController
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
+ #开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
+ if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
+ if @order == 'lastname'
+ @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("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @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}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ 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
+ end
@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 #学生 && 未开启匿评 只看到自己的
+ elsif User.current.member_of_course?(@course)
+ if @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)
+ @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,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ @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
@@ -129,15 +139,21 @@ class StudentWorkController < ApplicationController
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)
+ 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,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ 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,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ if @order == 'lastname'
+ @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("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @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}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ 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
+ end
@show_all = true
end
else
@@ -148,25 +164,28 @@ class StudentWorkController < ApplicationController
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
+ @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,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
+ if @order == 'lastname'
+ @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).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @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("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ 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
+ end
@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 #学生 && 未开启匿评 只看到自己的
+ elsif User.current.member_of_course?(@course)
+ if @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)
+ @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,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ @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
@@ -186,15 +205,21 @@ class StudentWorkController < ApplicationController
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)
+ 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,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ 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,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ if @order == 'lastname'
+ @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).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @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("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ 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
+ end
@show_all = true
end
else
@@ -205,7 +230,7 @@ class StudentWorkController < ApplicationController
return
end
- @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name).count
+ @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,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"
@@ -303,6 +328,7 @@ class StudentWorkController < ApplicationController
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)
@@ -500,6 +526,10 @@ class StudentWorkController < ApplicationController
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
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 921262106..1c9a00fa4 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
@@ -375,13 +376,15 @@ class UsersController < ApplicationController
#用户作业列表
def user_homeworks
+ @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
@user = User.current
+ @r_sort = @b_sort == "desc" ? "asc" : "desc"
if(params[:type].blank? || params[:type] == "1") #公共题库
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
- @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc")
+ @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #我的题库
- @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc")
+ @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
end
@type = params[:type]
@limit = 15
@@ -422,7 +425,7 @@ class UsersController < ApplicationController
end
def choose_user_course
- homework = HomeworkCommon.find params[:homework].to_i
+ homework = HomeworkCommon.find params[:send_id].to_i
if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)}
@@ -524,20 +527,22 @@ class UsersController < ApplicationController
end
def user_homework_type
+ @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
+ @r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
if(params[:type].blank? || params[:type] == "1") #公共题库
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
- @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc")
+ @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #我的题库
- @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc")
+ @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
end
if params[:property] && params[:property] == "1"
- @homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc")
+ @homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
elsif params[:property] && params[:property] == "2"
- @homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc")
+ @homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
elsif params[:property] && params[:property] == "3"
- @homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
+ @homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
end
@type = params[:type]
@property = params[:property]
@@ -563,6 +568,8 @@ class UsersController < ApplicationController
#用户主页过滤作业
def user_search_homeworks
+ @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
+ @r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
search = params[:name].to_s.strip.downcase
if(params[:type].blank? || params[:type] == "1") #全部
@@ -572,16 +579,16 @@ class UsersController < ApplicationController
all_user_ids = all_homeworks.map{|hw| hw.user_id}
user_str_ids = search_user_by_name all_user_ids, search
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
- @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("created_at desc")
+ @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #课程资源
- @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
+ @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("#{@order} #{@b_sort}")
end
if params[:property] && params[:property] == "1"
- @homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc")
+ @homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
elsif params[:property] && params[:property] == "2"
- @homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc")
+ @homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
elsif params[:property] && params[:property] == "3"
- @homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
+ @homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
end
@type = params[:type]
@limit = 15
@@ -591,6 +598,8 @@ class UsersController < ApplicationController
@offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,15
@is_import = params[:is_import]
+ @property = params[:property]
+ @search = search
respond_to do |format|
format.js
end
@@ -690,6 +699,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
@@ -1168,6 +1182,10 @@ class UsersController < ApplicationController
end
def show
+ # 统计访问量
+ unless User.current == @user
+ @user.update_attribute(:visits, @user.visits.to_i + 1)
+ end
#更新用户申请成为课程老师或教辅消息的状态
if params[:course_id] != nil
join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?",
@@ -1537,7 +1555,7 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
#@user.save_attachments(params[:attachments],User.current)
# Container_type为Principal
- Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
+ attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true)
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2
@@ -2322,9 +2340,7 @@ class UsersController < ApplicationController
# 获取公共资源
def get_public_resources user_course_ids, user_project_ids
- attachments = Attachment.where("(is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
- "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("created_on desc")
+ attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("created_on desc")
end
# 获取我的资源
@@ -2341,7 +2357,7 @@ class UsersController < ApplicationController
# 获取公共资源课程
def get_course_resources_public user_course_ids
- attchments = Attachment.where("(container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
+ attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("created_on desc")
end
# 获取我的项目资源
@@ -2351,7 +2367,7 @@ class UsersController < ApplicationController
# 获取公共资源的项目资源
def get_project_resources_public user_project_ids
- attchments = Attachment.where("(container_type = 'Project') or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1) ").order("created_on desc")
+ attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("created_on desc")
end
# 获取我上传的附件
@@ -2361,7 +2377,7 @@ class UsersController < ApplicationController
# 获取公共资源中我上传的附件
def get_attch_resources_public
- attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc")
+ attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') and container_id is not null and is_public =1").order("created_on desc")
end
# 获取我的用户类型资源
@@ -2371,7 +2387,7 @@ class UsersController < ApplicationController
# 获取我的用户类型资源
def get_principal_resources_public
- attchments = Attachment.where("container_type = 'Principal'").order("created_on desc")
+ attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("created_on desc")
end
# 资源库 分为全部 课程资源 项目资源 附件
@@ -2603,9 +2619,7 @@ class UsersController < ApplicationController
end
elsif params[:type] == "6" #全部资源
# 公共资源库:所有公开资源或者我上传的私有资源
- @attachments = Attachment.where("((is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+
- "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
- "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("created_on desc")
+ @attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("created_on desc")
end
@type = params[:type]
@limit = 25
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 e35d0cebe..83fb8c4e1 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/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index cbc514df6..d98de27f6 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -71,6 +71,11 @@ module CoursesHelper
project.members.count
end
+ # 统计课程中作品的数量
+ def student_works_num course
+ StudentWork.find_by_sql("SELECT * FROM student_works WHERE homework_common_id IN (SELECT id FROM homework_commons WHERE course_id = '#{course.id}')").count
+ end
+
# 返回教师数量,即roles表中定义的Manager
def teacherCount project
project ? project.members.count - studentCount(project).to_i : 0
@@ -601,6 +606,24 @@ module CoursesHelper
Course.tagged_with(tag_name).order('updated_at desc')
end
+ #分班下拉框
+ def course_group_option course
+ type = []
+ option1 = []
+ option1 << "暂无"
+ option1 << 0
+ type << option1
+ unless course.course_groups.nil?
+ course.course_groups.each do |cg|
+ option = []
+ option << cg.name
+ option << cg.id
+ type << option
+ end
+ end
+ type
+ end
+
#课程实践年份下拉框
def course_time_option year
type = []
@@ -762,7 +785,7 @@ module CoursesHelper
return[] unless course
result = []
course.attachments.each do |attachment|
- if attachment.is_public? ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id))|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
+ if (attachment.is_public? && attachment.is_publish == 1) ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,course)|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
result << attachment
end
end
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index 238999a71..913c49310 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -121,7 +121,8 @@ module FilesHelper
def visable_attachemnts attachments
result = []
attachments.each do |attachment|
- if attachment.is_public? ||
+ if (attachment.is_public? && attachment.container_type != "Course") ||
+ (attachment.is_public? && attachment.container_type == "Course" && attachment.is_publish == 1)||
(attachment.container_type == "Project" && User.current.member_of?(attachment.project)) ||
(attachment.container_type == "Course" && User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id)))||
(attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)) && attachment.is_publish == 1)||
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 82f648ad9..1cc0d3b7a 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
# 获取所有可公开的资源文件列表
@@ -498,6 +499,12 @@ class Attachment < ActiveRecord::Base
result
end
+ def self.attach_filesex_public(obj, attachments,attachment_type, is_public)
+ result = obj.save_attachmentsex_public(attachments, User.current,attachment_type, is_public)
+ obj.attach_saved_attachments
+ result
+ end
+
def self.latest_attach(attachments, filename)
attachments.sort_by(&:created_on).reverse.detect {
|att| att.filename.downcase == filename.downcase
@@ -655,6 +662,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/models/praise_tread.rb b/app/models/praise_tread.rb
index 3df5c72d9..b1b7e0908 100644
--- a/app/models/praise_tread.rb
+++ b/app/models/praise_tread.rb
@@ -2,8 +2,8 @@ class PraiseTread < ActiveRecord::Base
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
belongs_to :user
belongs_to :praise_tread_object, polymorphic: true
- after_create :be_user_score
- after_destroy :down_user_score
+ #after_create :be_user_score
+ #after_destroy :down_user_score
include UserScoreHelper
def self.find_object_by_type_and_id(type,id)
@obj = nil
diff --git a/app/views/admin/course_resource_list.html.erb b/app/views/admin/course_resource_list.html.erb
new file mode 100644
index 000000000..4316555f7
--- /dev/null
+++ b/app/views/admin/course_resource_list.html.erb
@@ -0,0 +1,64 @@
+
<%=l(:label_course_resource_list)%>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb
new file mode 100644
index 000000000..e21ba32aa
--- /dev/null
+++ b/app/views/admin/excellent_courses.html.erb
@@ -0,0 +1,75 @@
+
+ <%=l(:label_excellent_courses_list)%>
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/project_resource_list.html.erb b/app/views/admin/project_resource_list.html.erb
new file mode 100644
index 000000000..c245f73b8
--- /dev/null
+++ b/app/views/admin/project_resource_list.html.erb
@@ -0,0 +1,64 @@
+<%=l(:label_project_resource_list)%>
+
+
+
+
+
\ 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..bf69c3a61 100644
--- a/app/views/courses/_new_member_list.html.erb
+++ b/app/views/courses/_new_member_list.html.erb
@@ -1,81 +1,139 @@
-
-
- <% 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%>
+
+ <% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? %>
+ <% if @course.course_groups.nil? || @group %>
+
+ <%=member.course_group_id == 0 ? "暂无" : member.course_group.name %>
+
+ <% else %>
+ <%= form_tag({:controller => 'courses', :action => 'teacher_assign_group', :id => @course.id,:user_id => member.user_id},:remote=>'true', :method => 'post', :id=>"join_group_form_#{member.id}", :class => 'query_form') do %>
+
<%=member.course_group_id == 0 ? "暂无" : member.course_group.name %>
+
+
+ <%= select( :name,:group_id, course_group_option(@course),
+ { :include_blank => false,:selected => member.course_group_id},
+ {:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w125 undis class-edit fl", :style => "margin-left: 105px;"}) %>
+ <% end %>
+ <% end %>
+ <% else %>
+
+ <%=member.course_group_id == 0 ? "暂无" : member.course_group.name %>
+
+ <% 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 => 'ml25 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/courses/teacher_assign_group.js.erb b/app/views/courses/teacher_assign_group.js.erb
new file mode 100644
index 000000000..1429bb753
--- /dev/null
+++ b/app/views/courses/teacher_assign_group.js.erb
@@ -0,0 +1 @@
+$("#st_groups").html("<%=escape_javascript(render :partial => 'new_groups_name', :locals => {:course_groups => @course_groups}) %>");
\ No newline at end of file
diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb
index 133b8b4d6..0a35c783c 100644
--- a/app/views/files/_upload_course_files.erb
+++ b/app/views/files/_upload_course_files.erb
@@ -25,7 +25,7 @@
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/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb
index 2f0d2732b..0675c8a4a 100644
--- a/app/views/layouts/_unlogin_header.html.erb
+++ b/app/views/layouts/_unlogin_header.html.erb
@@ -77,10 +77,10 @@
diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb
index 7aa591aae..30a911d09 100644
--- a/app/views/layouts/_user_courses.html.erb
+++ b/app/views/layouts/_user_courses.html.erb
@@ -2,7 +2,7 @@
+ 访问计数 <%= @user.visits.to_i %>
<%= format_date( @memo.created_at)%>
-
+
<%= @memo.content.html_safe%>
@@ -95,8 +95,21 @@
<%= reply.author.name%> <%= format_date(reply.created_at) %>
-
<%= reply.content.html_safe%>
+
<%= reply.content.html_safe%>
+
<% end %>
@@ -113,7 +126,7 @@
<%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %>
- 发送
+ 发送
<% end%>
@@ -126,7 +139,7 @@
\ No newline at end of file
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_message.html.erb b/app/views/organizations/_org_course_message.html.erb
index e86159dab..9a9943e9b 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_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/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_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb
index 66b96431e..aee833b70 100644
--- a/app/views/student_work/_evaluation_un_title.html.erb
+++ b/app/views/student_work/_evaluation_un_title.html.erb
@@ -2,8 +2,16 @@
作品名称
<% if @homework.homework_type != 3 %>
- 姓名
- 学号
+
+ <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "lastname", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl" ,:remote => true%>
+ <% if @show_all && @order == "lastname"%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "lastname", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10" ,:remote => true%>
+ <% end%>
+
+ <%= link_to "学号",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_id", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl ml50" ,:remote => true%>
+ <% if @show_all && @order == "student_id"%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_id", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10" ,:remote => true%>
+ <% end%>
<% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
关联项目
<% end %>
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..ee49e3cfc 100644
--- a/app/views/users/_course_homework.html.erb
+++ b/app/views/users/_course_homework.html.erb
@@ -47,7 +47,7 @@
<% end%>
<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1%>
-
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
+
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
<% elsif activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 0%>
系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!
<% end %>
@@ -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/_homework_repository_list.html.erb b/app/views/users/_homework_repository_list.html.erb
new file mode 100644
index 000000000..67a8f47b4
--- /dev/null
+++ b/app/views/users/_homework_repository_list.html.erb
@@ -0,0 +1,21 @@
+
+ 作业名称
+ 来源
+ 类别
+ 贡献者
+
+ <%= link_to "引用数",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort),:class => "fl",:remote => true%>
+ <% if @order == "quotes"%>
+ <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12" ,:remote => true%>
+ <% end%>
+
+
+ <%= link_to "发布时间",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort),:class => "fl",:remote => true%>
+ <% if @order == "created_at"%>
+ <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12" ,:remote => true%>
+ <% end%>
+
+
+
+ <%=render :partial => 'homework_repository', :locals => {:homeworks => homeworks} %>
+
\ No newline at end of file
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..a196ee6c0 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -48,7 +48,7 @@
<% end%>
<% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1%>
-
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
+
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
<% elsif homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 0%>
系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!
<% end %>
@@ -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 bd449de7d..bb9fc1174 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -246,7 +246,9 @@
<% 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? ? "发布了课程帖子:" : "评论了课程帖子:" %>
+
+ <%=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),
@@ -382,7 +384,7 @@
<% end %>
<% end %>
- <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? && ma.course_message.homework_common.user_id != User.current.id %>
+ <% 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) %>
diff --git a/app/views/users/_user_message_userfeedaback.html.erb b/app/views/users/_user_message_userfeedaback.html.erb
index 23a0774c3..6bc169f21 100644
--- a/app/views/users/_user_message_userfeedaback.html.erb
+++ b/app/views/users/_user_message_userfeedaback.html.erb
@@ -1,30 +1,30 @@
-<% if ma.class == UserFeedbackMessage %>
- <% if ma.journals_for_message_type == "JournalsForMessage" %>
-
-
- <%=link_to image_tag(url_to_avatar(ma.journals_for_message.user), :width => "30", :height => "30"), user_path(ma.journals_for_message.user) %>
-
-
- <%=link_to ma.journals_for_message.user, user_path(ma.journals_for_message.user), :class => "newsBlue homepageNewsPublisher" %>
- "><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %>
-
-
- <%= link_to ma.journals_for_message.notes.gsub("","").gsub("
","").gsub(" ","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
- <% if ma.journals_for_message.reply_id == 0 %>
- <%= ma.journals_for_message.notes.html_safe %>
- <% else %>
-
您的留言:
-
<%= JournalsForMessage.find(ma.journals_for_message.m_reply_id).notes.html_safe %>
-
回复内容:
-
<%= ma.journals_for_message.notes.html_safe %>
- <% end %>
-
- <%= time_tag(ma.journals_for_message.created_on).html_safe %>
-
-
- <% end %>
+<% if ma.class == UserFeedbackMessage %>
+ <% if ma.journals_for_message_type == "JournalsForMessage" %>
+
+
+ <%=link_to image_tag(url_to_avatar(ma.journals_for_message.user), :width => "30", :height => "30"), user_path(ma.journals_for_message.user) %>
+
+
+ <%=link_to ma.journals_for_message.user, user_path(ma.journals_for_message.user), :class => "newsBlue homepageNewsPublisher" %>
+ "><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %>
+
+
+ <%= link_to ma.journals_for_message.notes.gsub("","").gsub("
","").gsub(" ","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
+ :onmouseover =>"message_titile_show($(this),event)",
+ :onmouseout => "message_titile_hide($(this))" %>
+
+
+ <% if ma.journals_for_message.reply_id == 0 %>
+ <%= ma.journals_for_message.notes.html_safe %>
+ <% else %>
+
您的留言:
+
<%= JournalsForMessage.find(ma.journals_for_message.m_reply_id).notes.html_safe %>
+
回复内容:
+
<%= ma.journals_for_message.notes.html_safe %>
+ <% end %>
+
+ <%= time_tag(ma.journals_for_message.created_on).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/app/views/users/user_homework_type.js.erb b/app/views/users/user_homework_type.js.erb
index 701cf45fa..8cfb4dc04 100644
--- a/app/views/users/user_homework_type.js.erb
+++ b/app/views/users/user_homework_type.js.erb
@@ -4,7 +4,7 @@ $("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>");
<% else %>
-$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
+$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => @is_import,:property => @property,:search=>''})%>');
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_repository_search', :locals=>{:type=>@type,:is_import=>@is_import,:property=>@property}) %>");
diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb
index 4e928ca78..279f36b5c 100644
--- a/app/views/users/user_homeworks.html.erb
+++ b/app/views/users/user_homeworks.html.erb
@@ -58,40 +58,26 @@
- <%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %>
+ <%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %>
-
-
-
- 作业名称
- 来源
- 类别
- 贡献者
- 引用数
- 发布时间
-
-
- <%=render :partial => 'homework_repository', :locals => {:homeworks => @homeworks} %>
+
+ <%=render :partial => 'homework_repository_list', :locals => {:homeworks => @homeworks,:type=>@type,:is_import => 0,:property => @property,:search=>''} %>
+
+
+ <%=render :partial => 'homework_repository_detail', :locals => {:homework => nil} %>
+
+
+
+
+ <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
+
+
+
+
+
-
-
- <%=render :partial => 'homework_repository_detail', :locals => {:homework => nil} %>
-
-
-
-
- <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/views/users/user_homeworks.js.erb b/app/views/users/user_homeworks.js.erb
index a24b3d018..ce1bb65e2 100644
--- a/app/views/users/user_homeworks.js.erb
+++ b/app/views/users/user_homeworks.js.erb
@@ -1,3 +1,4 @@
-$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
+/*$("#homework_repository").html('<%#= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');*/
+$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => 0,:property => @property,:search=>''})%>');
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
diff --git a/app/views/users/user_search_homeworks.js.erb b/app/views/users/user_search_homeworks.js.erb
index 34d73b823..29d490960 100644
--- a/app/views/users/user_search_homeworks.js.erb
+++ b/app/views/users/user_search_homeworks.js.erb
@@ -3,7 +3,7 @@ $("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'us
$("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
<% else %>
-$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
+$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => @is_import,:property => @property,:search=>@search})%>');
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
<% end %>
\ No newline at end of file
diff --git a/app/views/welcome/_search_attachment_results.html.erb b/app/views/welcome/_search_attachment_results.html.erb
index 21ba68336..e51706085 100644
--- a/app/views/welcome/_search_attachment_results.html.erb
+++ b/app/views/welcome/_search_attachment_results.html.erb
@@ -21,6 +21,6 @@
<% end %>
<% end %>
\ No newline at end of file
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2bed45103..3da533eb7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1520,6 +1520,9 @@ en:
label_submit_comments: Submit_comments
label_course_empty_select: You have not selected course!
label_enterprise_page_made: enterprise_page
+ label_excellent_courses_list: excellent_courses
+ label_course_resource_list: course_resource_list
+ label_project_resource_list: project_resource_list
#api
label_recently_updated_notification: Recently updated notification
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 114e67370..37d26dbd8 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -483,6 +483,9 @@ zh:
label_requirement: 需求
label_new_course: 课程列表
label_course_all: 课程列表
+ label_excellent_courses_list: 精品课程列表
+ label_course_resource_list: 课程资源列表
+ label_project_resource_list: 項目资源列表
label_teacher_all: 所有教师
label_requirement_enterprise_list: 众包列表
label_new_homework: 作业
diff --git a/config/routes.rb b/config/routes.rb
index 29afad2d6..97c1881ed 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -940,6 +940,9 @@ RedmineApp::Application.routes.draw do
match 'admin', :to => 'admin#index', :via => :get
match 'admin/projects', :via => :get
get 'admin/courses'
+ get 'admin/excellent_courses'
+ get 'admin/course_resource_list'
+ get 'admin/project_resource_list'
match 'admin/users', :via => :get
match 'admin/messages', :via => :get
match 'admin/first_page_made', as: :first_page_made
@@ -1006,6 +1009,7 @@ RedmineApp::Application.routes.draw do
get 'course_outline'
post 'search_course_outline'
post 'set_course_outline'
+ post 'teacher_assign_group'
get 'syllabus'
get 'search_public_orgs_not_in_course'
get "homework_search"
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/migrate/20160311072540_add_visits_to_user.rb b/db/migrate/20160311072540_add_visits_to_user.rb
new file mode 100644
index 000000000..2169a4b0b
--- /dev/null
+++ b/db/migrate/20160311072540_add_visits_to_user.rb
@@ -0,0 +1,5 @@
+class AddVisitsToUser < ActiveRecord::Migration
+ def change
+ add_column :users, :visits, :integer, :default => 0
+ end
+end
diff --git a/db/migrate/20160311072622_add_visits_to_project.rb b/db/migrate/20160311072622_add_visits_to_project.rb
new file mode 100644
index 000000000..1e67d9409
--- /dev/null
+++ b/db/migrate/20160311072622_add_visits_to_project.rb
@@ -0,0 +1,5 @@
+class AddVisitsToProject < ActiveRecord::Migration
+ def change
+ add_column :projects, :visits, :integer, :default => 0
+ end
+end
diff --git a/db/migrate/20160311072718_add_visits_to_course.rb b/db/migrate/20160311072718_add_visits_to_course.rb
new file mode 100644
index 000000000..4d4b682cf
--- /dev/null
+++ b/db/migrate/20160311072718_add_visits_to_course.rb
@@ -0,0 +1,5 @@
+class AddVisitsToCourse < ActiveRecord::Migration
+ def change
+ add_column :courses, :visits, :integer, :default => 0
+ end
+end
diff --git a/db/migrate/20160311072819_add_visits_to_organization.rb b/db/migrate/20160311072819_add_visits_to_organization.rb
new file mode 100644
index 000000000..74bbcb5c9
--- /dev/null
+++ b/db/migrate/20160311072819_add_visits_to_organization.rb
@@ -0,0 +1,5 @@
+class AddVisitsToOrganization < ActiveRecord::Migration
+ def change
+ add_column :organizations, :visits, :integer, :default => 0
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 76dd8e19c..2dad292f4 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 => 20160225031230) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -432,11 +432,9 @@ ActiveRecord::Schema.define(:version => 20160304234903) do
t.integer "resource_num"
t.integer "journal_num"
t.integer "journal_reply_num"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.integer "total_score"
- t.integer "homework_journal_num", :default => 0
- t.integer "news_num", :default => 0
end
create_table "course_groups", :force => true do |t|
@@ -1387,7 +1385,6 @@ ActiveRecord::Schema.define(:version => 20160304234903) do
t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0
t.integer "board_num", :default => 0
- t.integer "act_num", :default => 0
t.integer "attach_num", :default => 0
t.datetime "commit_time"
end
@@ -2016,6 +2013,11 @@ ActiveRecord::Schema.define(:version => 20160304234903) do
add_index "wikis", ["project_id"], :name => "wikis_project_id"
+ create_table "wlcs", :force => true do |t|
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "workflows", :force => true do |t|
t.integer "tracker_id", :default => 0, :null => false
t.integer "old_status_id", :default => 0, :null => false
diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
index 682714b9b..6b22496b6 100644
--- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
+++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb
@@ -99,6 +99,13 @@ module Redmine
result
end
+ def save_attachmentsex_public(attachments, author=User.current,attachment_type, is_public)
+ @curattachment_type = attachment_type
+ @is_public = true
+ result = save_attachments(attachments,author)
+ result
+ end
+
def save_attachments(attachments, author=User.current)
# 清除临时文件
if attachments
@@ -142,7 +149,11 @@ module Redmine
end
if a && !attachment['is_public_checkbox']
- a.is_public = false
+ if @is_public
+ a.is_public = true
+ else
+ a.is_public = false
+ end
elsif a && attachment['is_public_checkbox']
a.is_public = true
end
diff --git a/lib/redmine.rb b/lib/redmine.rb
index 8ebdacfa6..47ee3d38f 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -391,6 +391,9 @@ Redmine::MenuManager.map :admin_menu do |menu|
menu.push :messages_list, {:controller => 'admin', :action => 'messages_list'}, :caption => :label_message_plural
menu.push :notices, {:controller => 'admin', :action => 'notices'}, :caption => :label_notification_list
menu.push :latest_login_users, {:controller => 'admin', :action => 'latest_login_users'}, :caption => :label_latest_login_user_list
+ menu.push :excellent_courses, {:controller => 'admin', :action => 'excellent_courses'}, :caption => :label_excellent_courses_list
+ menu.push :course_resource_list, {:controller => 'admin', :action => 'course_resource_list'}, :caption => :label_course_resource_list
+ menu.push :project_resource_list, {:controller => 'admin', :action => 'project_resource_list'}, :caption => :label_project_resource_list
menu.push :homework, {:controller => 'admin', :action => 'homework'}, :caption => :label_user_homework
end
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 6065a563f..060898b88 100644
--- a/public/assets/kindeditor/kindeditor.js
+++ b/public/assets/kindeditor/kindeditor.js
@@ -1,6094 +1,6136 @@
-//function dump_obj(myObject) {
-// var s = "";
-// for (var property in myObject) {
-// s = s + "\n "+property +": " + myObject[property] ;
-// }
-// alert(s);
-//}
-/*******************************************************************************
-* KindEditor - WYSIWYG HTML Editor for Internet
-* Copyright (C) 2006-2013 kindsoft.net
-*
-* @author Roddy
-* @website http://www.kindsoft.net/
-* @licence http://www.kindsoft.net/license.php
-* @version 4.1.10 (2013-11-23)
-*******************************************************************************/
-(function (window, undefined) {
- if (window.KindEditor) {
- return;
- }
-if (!window.console) {
- window.console = {};
-}
-if (!console.log) {
- console.log = function () {};
-}
-var _VERSION = '4.1.10 (2013-11-23)',
- _ua = navigator.userAgent.toLowerCase(),
- _IE = _ua.indexOf('msie') > -1 && _ua.indexOf('opera') == -1,
- _NEWIE = _ua.indexOf('msie') == -1 && _ua.indexOf('trident') > -1,
- _GECKO = _ua.indexOf('gecko') > -1 && _ua.indexOf('khtml') == -1,
- _WEBKIT = _ua.indexOf('applewebkit') > -1,
- _OPERA = _ua.indexOf('opera') > -1,
- _MOBILE = _ua.indexOf('mobile') > -1,
- _IOS = /ipad|iphone|ipod/.test(_ua),
- _QUIRKS = document.compatMode != 'CSS1Compat',
- _IERANGE = !window.getSelection,
- _matches = /(?:msie|firefox|webkit|opera)[\/:\s](\d+)/.exec(_ua),
- _V = _matches ? _matches[1] : '0',
- _TIME = new Date().getTime();
-function _isArray(val) {
- if (!val) {
- return false;
- }
- return Object.prototype.toString.call(val) === '[object Array]';
-}
-function _isFunction(val) {
- if (!val) {
- return false;
- }
- return Object.prototype.toString.call(val) === '[object Function]';
-}
-function _inArray(val, arr) {
- for (var i = 0, len = arr.length; i < len; i++) {
- if (val === arr[i]) {
- return i;
- }
- }
- return -1;
-}
-function _each(obj, fn) {
- if (_isArray(obj)) {
- for (var i = 0, len = obj.length; i < len; i++) {
- if (fn.call(obj[i], i, obj[i]) === false) {
- break;
- }
- }
- } else {
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- if (fn.call(obj[key], key, obj[key]) === false) {
- break;
- }
- }
- }
- }
-}
-function _trim(str) {
- return str.replace(/(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g, '');
-}
-function _inString(val, str, delimiter) {
- delimiter = delimiter === undefined ? ',' : delimiter;
- return (delimiter + str + delimiter).indexOf(delimiter + val + delimiter) >= 0;
-}
-function _addUnit(val, unit) {
- unit = unit || 'px';
- return val && /^\d+$/.test(val) ? val + unit : val;
-}
-function _removeUnit(val) {
- var match;
- return val && (match = /(\d+)/.exec(val)) ? parseInt(match[1], 10) : 0;
-}
-function _escape(val) {
- return val.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
-}
-function _unescape(val) {
- return val.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/&/g, '&');
-}
-function _toCamel(str) {
- var arr = str.split('-');
- str = '';
- _each(arr, function(key, val) {
- str += (key > 0) ? val.charAt(0).toUpperCase() + val.substr(1) : val;
- });
- return str;
-}
-function _toHex(val) {
- function hex(d) {
- var s = parseInt(d, 10).toString(16).toUpperCase();
- return s.length > 1 ? s : '0' + s;
- }
- return val.replace(/rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/ig,
- function($0, $1, $2, $3) {
- return '#' + hex($1) + hex($2) + hex($3);
- }
- );
-}
-function _toMap(val, delimiter) {
- delimiter = delimiter === undefined ? ',' : delimiter;
- var map = {}, arr = _isArray(val) ? val : val.split(delimiter), match;
- _each(arr, function(key, val) {
- if ((match = /^(\d+)\.\.(\d+)$/.exec(val))) {
- for (var i = parseInt(match[1], 10); i <= parseInt(match[2], 10); i++) {
- map[i.toString()] = true;
- }
- } else {
- map[val] = true;
- }
- });
- return map;
-}
-function _toArray(obj, offset) {
- return Array.prototype.slice.call(obj, offset || 0);
-}
-function _undef(val, defaultVal) {
- return val === undefined ? defaultVal : val;
-}
-function _invalidUrl(url) {
- return !url || /[<>"]/.test(url);
-}
-function _addParam(url, param) {
- return url.indexOf('?') >= 0 ? url + '&' + param : url + '?' + param;
-}
-function _extend(child, parent, proto) {
- if (!proto) {
- proto = parent;
- parent = null;
- }
- var childProto;
- if (parent) {
- var fn = function () {};
- fn.prototype = parent.prototype;
- childProto = new fn();
- _each(proto, function(key, val) {
- childProto[key] = val;
- });
- } else {
- childProto = proto;
- }
- childProto.constructor = child;
- child.prototype = childProto;
- child.parent = parent ? parent.prototype : null;
-}
-function _json(text) {
- var match;
- if ((match = /\{[\s\S]*\}|\[[\s\S]*\]/.exec(text))) {
- text = match[0];
- }
- var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
- cx.lastIndex = 0;
- if (cx.test(text)) {
- text = text.replace(cx, function (a) {
- return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
- });
- }
- if (/^[\],:{}\s]*$/.
- test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
- replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
- replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
- return eval('(' + text + ')');
- }
- throw 'JSON parse error';
-}
-var _round = Math.round;
-var K = {
- DEBUG : false,
- VERSION : _VERSION,
- IE : _IE,
- GECKO : _GECKO,
- WEBKIT : _WEBKIT,
- OPERA : _OPERA,
- V : _V,
- TIME : _TIME,
- each : _each,
- isArray : _isArray,
- isFunction : _isFunction,
- inArray : _inArray,
- inString : _inString,
- trim : _trim,
- addUnit : _addUnit,
- removeUnit : _removeUnit,
- escape : _escape,
- unescape : _unescape,
- toCamel : _toCamel,
- toHex : _toHex,
- toMap : _toMap,
- toArray : _toArray,
- undef : _undef,
- invalidUrl : _invalidUrl,
- addParam : _addParam,
- extend : _extend,
- json : _json
-};
-var _INLINE_TAG_MAP = _toMap('a,abbr,acronym,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,img,input,ins,kbd,label,map,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'),
- _BLOCK_TAG_MAP = _toMap('address,applet,blockquote,body,center,dd,dir,div,dl,dt,fieldset,form,frameset,h1,h2,h3,h4,h5,h6,head,hr,html,iframe,ins,isindex,li,map,menu,meta,noframes,noscript,object,ol,p,pre,script,style,table,tbody,td,tfoot,th,thead,title,tr,ul'),
- _SINGLE_TAG_MAP = _toMap('area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed'),
- _STYLE_TAG_MAP = _toMap('b,basefont,big,del,em,font,i,s,small,span,strike,strong,sub,sup,u'),
- _CONTROL_TAG_MAP = _toMap('img,table,input,textarea,button'),
- _PRE_TAG_MAP = _toMap('pre,style,script'),
- _NOSPLIT_TAG_MAP = _toMap('html,head,body,td,tr,table,ol,ul,li'),
- _AUTOCLOSE_TAG_MAP = _toMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'),
- _FILL_ATTR_MAP = _toMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'),
- _VALUE_TAG_MAP = _toMap('input,button,textarea,select');
-// Begining of modification by Macrow
-function _getBasePath() {
- var refPath = '/assets/kindeditor/';
- var els = document.getElementsByTagName('script'), src;
- for (var i = 0, len = els.length; i < len; i++) {
- src = els[i].src || '';
- if (/(kindeditor|application)[\w\-\.]*\.js/.test(src)) {
- return src.substring(0, src.indexOf('assets')) + refPath;
- }
- }
- return refPath;
-}
-// End of modification by Macrow
-K.basePath = _getBasePath();
-K.options = {
- designMode : true,
- fullscreenMode : false,
- filterMode : true,
- wellFormatMode : true,
- shadowMode : true,
- loadStyleMode : true,
- basePath : K.basePath,
- emotionsBasePath: 'http://forge.trustie.net', //TODO
- themesPath : K.basePath + 'themes/',
- langPath : K.basePath + 'lang/',
- pluginsPath : K.basePath + 'plugins/',
- themeType : 'default',
- langType : 'zh_CN',
- urlType : '',
- newlineTag : 'p',
- resizeType : 2,
- syncType : 'form',
- pasteType : 2,
- dialogAlignType : 'page',
- useContextmenu : true,
- fullscreenShortcut : false,
- bodyClass : 'ke-content',
- indentChar : '\t',
- cssPath : K.basePath +'plugins/code/previewcode.css',
- cssData : 'font{color:black;}',
- minWidth : 650,
- minHeight : 100,
- minChangeSize : 1,
- zIndex : 811213,
- items : ['code','emoticons','fontname',
- 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
- 'formatblock', 'fontsize', '|','indent', 'outdent',
- '|','imagedirectupload','table', 'media', 'preview',"more"
- ],
- noDisableItems : ['source', 'fullscreen'],
- colorTable : [
- ['#E53333', '#E56600', '#FF9900', '#64451D', '#DFC5A4', '#FFE500'],
- ['#009900', '#006600', '#99BB00', '#B8D100', '#60D978', '#00D5FF'],
- ['#337FE5', '#003399', '#4C33E5', '#9933E5', '#CC33E5', '#EE33EE'],
- ['#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000']
- ],
- fontSizeTable : ['选中的字体大小:','9px', '10px', '12px', '14px', '16px', '18px', '24px', '32px'],
- htmlTags : {
- font : ['id', 'class', 'color', 'size', 'face', '.background-color'],
- span : [
- 'id', 'class', '.color', '.background-color', '.font-size', '.font-family', '.background',
- '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height', 'data-user-id'
- ],
- div : [
- 'id', 'class', 'align', '.border', '.margin', '.padding', '.text-align', '.color',
- '.background-color', '.font-size', '.font-family', '.font-weight', '.background',
- '.font-style', '.text-decoration', '.vertical-align', '.margin-left'
- ],
- table: [
- 'id', 'class', 'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
- '.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
- '.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.background',
- '.width', '.height', '.border-collapse'
- ],
- 'td,th': [
- 'id', 'class', 'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
- '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
- '.font-style', '.text-decoration', '.vertical-align', '.background', '.border'
- ],
- a : ['id', 'class', 'href', 'target', 'name'],
- embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
- img : ['id', 'class', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'],
- 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
- 'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background',
- '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
- ],
- pre : ['id', 'class'],
- hr : ['id', 'class', '.page-break-after'],
- 'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : ['id', 'class'],
- iframe : ['id', 'class', 'src', 'frameborder', 'width', 'height', '.width', '.height']
- },
- layout : ''
-};
-var _useCapture = false;
-var _INPUT_KEY_MAP = _toMap('8,9,13,32,46,48..57,59,61,65..90,106,109..111,188,190..192,219..222');
-var _CURSORMOVE_KEY_MAP = _toMap('33..40');
-var _CHANGE_KEY_MAP = {};
-_each(_INPUT_KEY_MAP, function(key, val) {
- _CHANGE_KEY_MAP[key] = val;
-});
-_each(_CURSORMOVE_KEY_MAP, function(key, val) {
- _CHANGE_KEY_MAP[key] = val;
-});
-function _bindEvent(el, type, fn) {
- if (el.addEventListener){
- el.addEventListener(type, fn, _useCapture);
- } else if (el.attachEvent){
- el.attachEvent('on' + type, fn);
- }
-}
-function _unbindEvent(el, type, fn) {
- if (el.removeEventListener){
- el.removeEventListener(type, fn, _useCapture);
- } else if (el.detachEvent){
- el.detachEvent('on' + type, fn);
- }
-}
-var _EVENT_PROPS = ('altKey,attrChange,attrName,bubbles,button,cancelable,charCode,clientX,clientY,ctrlKey,currentTarget,' +
- 'data,detail,eventPhase,fromElement,handler,keyCode,metaKey,newValue,offsetX,offsetY,originalTarget,pageX,' +
- 'pageY,prevValue,relatedNode,relatedTarget,screenX,screenY,shiftKey,srcElement,target,toElement,view,wheelDelta,which').split(',');
-function KEvent(el, event) {
- this.init(el, event);
-}
-_extend(KEvent, {
- init : function(el, event) {
- var self = this, doc = el.ownerDocument || el.document || el;
- self.event = event;
- _each(_EVENT_PROPS, function(key, val) {
- self[val] = event[val];
- });
- if (!self.target) {
- self.target = self.srcElement || doc;
- }
- if (self.target.nodeType === 3) {
- self.target = self.target.parentNode;
- }
- if (!self.relatedTarget && self.fromElement) {
- self.relatedTarget = self.fromElement === self.target ? self.toElement : self.fromElement;
- }
- if (self.pageX == null && self.clientX != null) {
- var d = doc.documentElement, body = doc.body;
- self.pageX = self.clientX + (d && d.scrollLeft || body && body.scrollLeft || 0) - (d && d.clientLeft || body && body.clientLeft || 0);
- self.pageY = self.clientY + (d && d.scrollTop || body && body.scrollTop || 0) - (d && d.clientTop || body && body.clientTop || 0);
- }
- if (!self.which && ((self.charCode || self.charCode === 0) ? self.charCode : self.keyCode)) {
- self.which = self.charCode || self.keyCode;
- }
- if (!self.metaKey && self.ctrlKey) {
- self.metaKey = self.ctrlKey;
- }
- if (!self.which && self.button !== undefined) {
- self.which = (self.button & 1 ? 1 : (self.button & 2 ? 3 : (self.button & 4 ? 2 : 0)));
- }
- switch (self.which) {
- case 186 :
- self.which = 59;
- break;
- case 187 :
- case 107 :
- case 43 :
- self.which = 61;
- break;
- case 189 :
- case 45 :
- self.which = 109;
- break;
- case 42 :
- self.which = 106;
- break;
- case 47 :
- self.which = 111;
- break;
- case 78 :
- self.which = 110;
- break;
- }
- if (self.which >= 96 && self.which <= 105) {
- self.which -= 48;
- }
- },
- preventDefault : function() {
- var ev = this.event;
- if (ev.preventDefault) {
- ev.preventDefault();
- } else {
- ev.returnValue = false;
- }
- },
- stopPropagation : function() {
- var ev = this.event;
- if (ev.stopPropagation) {
- ev.stopPropagation();
- } else {
- ev.cancelBubble = true;
- }
- },
- stop : function() {
- this.preventDefault();
- this.stopPropagation();
- }
-});
-var _eventExpendo = 'kindeditor_' + _TIME, _eventId = 0, _eventData = {};
-function _getId(el) {
- return el[_eventExpendo] || null;
-}
-function _setId(el) {
- el[_eventExpendo] = ++_eventId;
- return _eventId;
-}
-function _removeId(el) {
- try {
- delete el[_eventExpendo];
- } catch(e) {
- if (el.removeAttribute) {
- el.removeAttribute(_eventExpendo);
- }
- }
-}
-function _bind(el, type, fn) {
- if (type.indexOf(',') >= 0) {
- _each(type.split(','), function() {
- _bind(el, this, fn);
- });
- return;
- }
- var id = _getId(el);
- if (!id) {
- id = _setId(el);
- }
- if (_eventData[id] === undefined) {
- _eventData[id] = {};
- }
- var events = _eventData[id][type];
- if (events && events.length > 0) {
- _unbindEvent(el, type, events[0]);
- } else {
- _eventData[id][type] = [];
- _eventData[id].el = el;
- }
- events = _eventData[id][type];
- if (events.length === 0) {
- events[0] = function(e) {
- var kevent = e ? new KEvent(el, e) : undefined;
- _each(events, function(i, event) {
- if (i > 0 && event) {
- event.call(el, kevent);
- }
- });
- };
- }
- if (_inArray(fn, events) < 0) {
- events.push(fn);
- }
- _bindEvent(el, type, events[0]);
-}
-function _unbind(el, type, fn) {
- if (type && type.indexOf(',') >= 0) {
- _each(type.split(','), function() {
- _unbind(el, this, fn);
- });
- return;
- }
- var id = _getId(el);
- if (!id) {
- return;
- }
- if (type === undefined) {
- if (id in _eventData) {
- _each(_eventData[id], function(key, events) {
- if (key != 'el' && events.length > 0) {
- _unbindEvent(el, key, events[0]);
- }
- });
- delete _eventData[id];
- _removeId(el);
- }
- return;
- }
- if (!_eventData[id]) {
- return;
- }
- var events = _eventData[id][type];
- if (events && events.length > 0) {
- if (fn === undefined) {
- _unbindEvent(el, type, events[0]);
- delete _eventData[id][type];
- } else {
- _each(events, function(i, event) {
- if (i > 0 && event === fn) {
- events.splice(i, 1);
- }
- });
- if (events.length == 1) {
- _unbindEvent(el, type, events[0]);
- delete _eventData[id][type];
- }
- }
- var count = 0;
- _each(_eventData[id], function() {
- count++;
- });
- if (count < 2) {
- delete _eventData[id];
- _removeId(el);
- }
- }
-}
-function _fire(el, type) {
- if (type.indexOf(',') >= 0) {
- _each(type.split(','), function() {
- _fire(el, this);
- });
- return;
- }
- var id = _getId(el);
- if (!id) {
- return;
- }
- var events = _eventData[id][type];
- if (_eventData[id] && events && events.length > 0) {
- events[0]();
- }
-}
-function _ctrl(el, key, fn) {
- var self = this;
- key = /^\d{2,}$/.test(key) ? key : key.toUpperCase().charCodeAt(0);
- _bind(el, 'keydown', function(e) {
- if (e.ctrlKey && e.which == key && !e.shiftKey && !e.altKey) {
- fn.call(el);
- e.stop();
- }
- });
-}
-var _readyFinished = false;
-function _ready(fn) {
- if (_readyFinished) {
- fn(KindEditor);
- return;
- }
- var loaded = false;
- function readyFunc() {
- if (!loaded) {
- loaded = true;
- fn(KindEditor);
- _readyFinished = true;
- }
- }
- function ieReadyFunc() {
- if (!loaded) {
- try {
- document.documentElement.doScroll('left');
- } catch(e) {
- setTimeout(ieReadyFunc, 100);
- return;
- }
- readyFunc();
- }
- }
- function ieReadyStateFunc() {
- if (document.readyState === 'complete') {
- readyFunc();
- }
- }
- if (document.addEventListener) {
- _bind(document, 'DOMContentLoaded', readyFunc);
- } else if (document.attachEvent) {
- _bind(document, 'readystatechange', ieReadyStateFunc);
- var toplevel = false;
- try {
- toplevel = window.frameElement == null;
- } catch(e) {}
- if (document.documentElement.doScroll && toplevel) {
- ieReadyFunc();
- }
- }
- _bind(window, 'load', readyFunc);
-}
-if (_IE) {
- window.attachEvent('onunload', function() {
- _each(_eventData, function(key, events) {
- if (events.el) {
- _unbind(events.el);
- }
- });
- });
-}
-K.ctrl = _ctrl;
-K.ready = _ready;
-function _getCssList(css) {
- var list = {},
- reg = /\s*([\w\-]+)\s*:([^;]*)(;|$)/g,
- match;
- while ((match = reg.exec(css))) {
- var key = _trim(match[1].toLowerCase()),
- val = _trim(_toHex(match[2]));
- list[key] = val;
- }
- return list;
-}
-function _getAttrList(tag) {
- var list = {},
- reg = /\s+(?:([\w\-:]+)|(?:([\w\-:]+)=([^\s"'<>]+))|(?:([\w\-:"]+)="([^"]*)")|(?:([\w\-:"]+)='([^']*)'))(?=(?:\s|\/|>)+)/g,
- match;
- while ((match = reg.exec(tag))) {
- var key = (match[1] || match[2] || match[4] || match[6]).toLowerCase(),
- val = (match[2] ? match[3] : (match[4] ? match[5] : match[7])) || '';
- list[key] = val;
- }
- return list;
-}
-function _addClassToTag(tag, className) {
- if (/\s+class\s*=/.test(tag)) {
- tag = tag.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/, function($0, $1, $2, $3) {
- if ((' ' + $2 + ' ').indexOf(' ' + className + ' ') < 0) {
- return $2 === '' ? $1 + className + $3 : $1 + $2 + ' ' + className + $3;
- } else {
- return $0;
- }
- });
- } else {
- tag = tag.substr(0, tag.length - 1) + ' class="' + className + '">';
- }
- return tag;
-}
-function _formatCss(css) {
- var str = '';
- _each(_getCssList(css), function(key, val) {
- str += key + ':' + val + ';';
- });
- return str;
-}
-function _formatUrl(url, mode, host, pathname) {
- mode = _undef(mode, '').toLowerCase();
- if (url.substr(0, 5) != 'data:') {
- url = url.replace(/([^:])\/\//g, '$1/');
- }
- if (_inArray(mode, ['absolute', 'relative', 'domain']) < 0) {
- return url;
- }
- host = host || location.protocol + '//' + location.host;
- if (pathname === undefined) {
- var m = location.pathname.match(/^(\/.*)\//);
- pathname = m ? m[1] : '';
- }
- var match;
- if ((match = /^(\w+:\/\/[^\/]*)/.exec(url))) {
- if (match[1] !== host) {
- return url;
- }
- } else if (/^\w+:/.test(url)) {
- return url;
- }
- function getRealPath(path) {
- var parts = path.split('/'), paths = [];
- for (var i = 0, len = parts.length; i < len; i++) {
- var part = parts[i];
- if (part == '..') {
- if (paths.length > 0) {
- paths.pop();
- }
- } else if (part !== '' && part != '.') {
- paths.push(part);
- }
- }
- return '/' + paths.join('/');
- }
- if (/^\//.test(url)) {
- url = host + getRealPath(url.substr(1));
- } else if (!/^\w+:\/\//.test(url)) {
- url = host + getRealPath(pathname + '/' + url);
- }
- function getRelativePath(path, depth) {
- if (url.substr(0, path.length) === path) {
- var arr = [];
- for (var i = 0; i < depth; i++) {
- arr.push('..');
- }
- var prefix = '.';
- if (arr.length > 0) {
- prefix += '/' + arr.join('/');
- }
- if (pathname == '/') {
- prefix += '/';
- }
- return prefix + url.substr(path.length);
- } else {
- if ((match = /^(.*)\//.exec(path))) {
- return getRelativePath(match[1], ++depth);
- }
- }
- }
- if (mode === 'relative') {
- url = getRelativePath(host + pathname, 0).substr(2);
- } else if (mode === 'absolute') {
- if (url.substr(0, host.length) === host) {
- url = url.substr(host.length);
- }
- }
- return url;
-}
-function _formatHtml(html, htmlTags, urlType, wellFormatted, indentChar) {
- if (html == null) {
- html = '';
- }
- urlType = urlType || '';
- wellFormatted = _undef(wellFormatted, false);
- indentChar = _undef(indentChar, '\t');
- var fontSizeList = 'xx-small,x-small,small,medium,large,x-large,xx-large'.split(',');
- html = html.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig, function($0, $1, $2, $3) {
- return $1 + $2.replace(/<(?:br|br\s[^>]*)>/ig, '\n') + $3;
- });
- html = html.replace(/<(?:br|br\s[^>]*)\s*\/?>\s*<\/p>/ig, '');
- html = html.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/ig, '$1 $2');
- html = html.replace(/\u200B/g, '');
- html = html.replace(/\u00A9/g, '©');
- html = html.replace(/\u00AE/g, '®');
- html = html.replace(/<[^>]+/g, function($0) {
- return $0.replace(/\s+/g, ' ');
- });
- var htmlTagMap = {};
- if (htmlTags) {
- _each(htmlTags, function(key, val) {
- var arr = key.split(',');
- for (var i = 0, len = arr.length; i < len; i++) {
- htmlTagMap[arr[i]] = _toMap(val);
- }
- });
- if (!htmlTagMap.script) {
- html = html.replace(/(<(?:script|script\s[^>]*)>)([\s\S]*?)(<\/script>)/ig, '');
- }
- if (!htmlTagMap.style) {
- html = html.replace(/(<(?:style|style\s[^>]*)>)([\s\S]*?)(<\/style>)/ig, '');
- }
- }
- var re = /(\s*)<(\/)?([\w\-:]+)((?:\s+|(?:\s+[\w\-:]+)|(?:\s+[\w\-:]+=[^\s"'<>]+)|(?:\s+[\w\-:"]+="[^"]*")|(?:\s+[\w\-:"]+='[^']*'))*)(\/)?>(\s*)/g;
- var tagStack = [];
- html = html.replace(re, function($0, $1, $2, $3, $4, $5, $6) {
- var full = $0,
- startNewline = $1 || '',
- startSlash = $2 || '',
- tagName = $3.toLowerCase(),
- attr = $4 || '',
- endSlash = $5 ? ' ' + $5 : '',
- endNewline = $6 || '';
- if (htmlTags && !htmlTagMap[tagName]) {
- return '';
- }
- if (endSlash === '' && _SINGLE_TAG_MAP[tagName]) {
- endSlash = ' /';
- }
- if (_INLINE_TAG_MAP[tagName]) {
- if (startNewline) {
- startNewline = ' ';
- }
- if (endNewline) {
- endNewline = ' ';
- }
- }
- if (_PRE_TAG_MAP[tagName]) {
- if (startSlash) {
- endNewline = '\n';
- } else {
- startNewline = '\n';
- }
- }
- if (wellFormatted && tagName == 'br') {
- endNewline = '\n';
- }
- if (_BLOCK_TAG_MAP[tagName] && !_PRE_TAG_MAP[tagName]) {
- if (wellFormatted) {
- if (startSlash && tagStack.length > 0 && tagStack[tagStack.length - 1] === tagName) {
- tagStack.pop();
- } else {
- tagStack.push(tagName);
- }
- startNewline = '\n';
- endNewline = '\n';
- for (var i = 0, len = startSlash ? tagStack.length : tagStack.length - 1; i < len; i++) {
- startNewline += indentChar;
- if (!startSlash) {
- endNewline += indentChar;
- }
- }
- if (endSlash) {
- tagStack.pop();
- } else if (!startSlash) {
- endNewline += indentChar;
- }
- } else {
- startNewline = endNewline = '';
- }
- }
- if (attr !== '') {
- var attrMap = _getAttrList(full);
- if (tagName === 'font') {
- var fontStyleMap = {}, fontStyle = '';
- _each(attrMap, function(key, val) {
- if (key === 'color') {
- fontStyleMap.color = val;
- delete attrMap[key];
- }
- if (key === 'size') {
- fontStyleMap['font-size'] = fontSizeList[parseInt(val, 10) - 1] || '';
- delete attrMap[key];
- }
- if (key === 'face') {
- fontStyleMap['font-family'] = val;
- delete attrMap[key];
- }
- if (key === 'style') {
- fontStyle = val;
- }
- });
- if (fontStyle && !/;$/.test(fontStyle)) {
- fontStyle += ';';
- }
- _each(fontStyleMap, function(key, val) {
- if (val === '') {
- return;
- }
- if (/\s/.test(val)) {
- val = "'" + val + "'";
- }
- fontStyle += key + ':' + val + ';';
- });
- attrMap.style = fontStyle;
- }
- _each(attrMap, function(key, val) {
- if (_FILL_ATTR_MAP[key]) {
- attrMap[key] = key;
- }
- if (_inArray(key, ['src', 'href']) >= 0) {
- attrMap[key] = _formatUrl(val, urlType);
- }
- if (htmlTags && key !== 'style' && !htmlTagMap[tagName]['*'] && !htmlTagMap[tagName][key] ||
- tagName === 'body' && key === 'contenteditable' ||
- /^kindeditor_\d+$/.test(key)) {
- delete attrMap[key];
- }
- if (key === 'style' && val !== '') {
- var styleMap = _getCssList(val);
- _each(styleMap, function(k, v) {
- if (htmlTags && !htmlTagMap[tagName].style && !htmlTagMap[tagName]['.' + k]) {
- delete styleMap[k];
- }
- });
- var style = '';
- _each(styleMap, function(k, v) {
- style += k + ':' + v + ';';
- });
- attrMap.style = style;
- }
- });
- attr = '';
- _each(attrMap, function(key, val) {
- if (key === 'style' && val === '') {
- return;
- }
- val = val.replace(/"/g, '"');
- attr += ' ' + key + '="' + val + '"';
- });
- }
- if (tagName === 'font') {
- tagName = 'span';
- }
- return startNewline + '<' + startSlash + tagName + attr + endSlash + '>' + endNewline;
- });
- html = html.replace(/(<(?:pre|pre\s[^>]*)>)([\s\S]*?)(<\/pre>)/ig, function($0, $1, $2, $3) {
- return $1 + $2.replace(/\n/g, '\n') + $3;
- });
- html = html.replace(/\n\s*\n/g, '\n');
- html = html.replace(/\n/g, '\n');
- return _trim(html);
-}
-function _clearMsWord(html, htmlTags) {
- html = html.replace(/ /ig, '')
- .replace(//ig, '')
- .replace(/'
- ];
- if (!_isArray(cssPath)) {
- cssPath = [cssPath];
- }
- _each(cssPath, function(i, path) {
- if (path) {
- arr.push(' ');
- }
- });
- if (cssData) {
- arr.push('');
- }
- arr.push('