diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index f5e3314bb..7220eec27 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -91,8 +91,12 @@ class BlogCommentsController < ApplicationController def edit @article = BlogComment.find(params[:id]) - respond_to do |format| - format.html {render :layout=>'new_base_user'} + if User.current.admin? || User.current.id == @article.author_id + respond_to do |format| + format.html { render :layout => 'new_base_user' } + end + else + render_403 end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index f06a782bc..24f5fd52c 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -902,10 +902,7 @@ class CoursesController < ApplicationController end def feedback - @course.journals_for_messages.each do |messages| - query = messages.course_messages.where("user_id = ?", User.current.id) - query.update_all(:viewed => true); - end + CourseMessage.where("user_id = ? and course_id = ?", User.current, @course.id).update_all(:viewed => true) if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) page = params[:page] diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 9f754a0fc..3532a9e4c 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -1,378 +1,380 @@ -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 +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 + eval_start = homework_detail_manual.evaluation_start + if eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1 + homework_detail_manual.evaluation_start = @homework.end_time + 7 + homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7 + end + @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/issues_controller.rb b/app/controllers/issues_controller.rb index eb78c4c5b..44f0d15f4 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -118,6 +118,9 @@ class IssuesController < ApplicationController end def show + # 打开编辑内容 + @is_edit = true unless params[:edit].nil? + # 当前用户查看指派给他的缺陷消息,则设置消息为已读 query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first query.update_attribute(:viewed, true) unless query.nil? @@ -387,6 +390,9 @@ class IssuesController < ApplicationController end def destroy + # 增加删除页面类型,如果是个人主页,则返回该主页,项目动态则返回项目动态页眉 + page_classify = params[:page_classify] unless params[:page_classify].nil? + page_id = params[:page_id] unless params[:page_id].nil? @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f if @hours > 0 case params[:todo] @@ -415,7 +421,11 @@ class IssuesController < ApplicationController end end respond_to do |format| - format.html { redirect_back_or_default _project_issues_path(@project) } + if page_classify + format.html { redirect_back_or_default _project_issues_path(@project, page_classify, page_id) } + else + format.html { redirect_back_or_default _project_issues_path(@project) } + end format.api { render_api_ok } end end diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index f250b46de..d1a8b23dd 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -1,6 +1,6 @@ class OrgDocumentCommentsController < ApplicationController before_filter :find_organization, :only => [:new, :create, :show, :index] - helper :attachments + helper :attachments,:organizations layout 'base_org' def new diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 9337c5fd2..ba4c1f18f 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -5,9 +5,8 @@ class OrgSubfieldsController < ApplicationController def create if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0 @res = true - @subfield = OrgSubfield.create(:name => params[:name]) @organization = Organization.find(params[:organization_id]) - @organization.org_subfields << @subfield + @subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id],:priority => @organization.org_subfields.order("priority").last.priority + 1) if !params[:sub_dir].blank? sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" @@ -15,7 +14,7 @@ class OrgSubfieldsController < ApplicationController SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir]) end end - @subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type]) + @subfield.update_attributes(:field_type => params[:field_type]) else @res = false end @@ -125,6 +124,12 @@ class OrgSubfieldsController < ApplicationController end end + def update_priority + @org_subfield = OrgSubfield.find(params[:id]) + @org_subfield.update_attribute(:priority, params[:priority].to_i) + @organization = @org_subfield.organization + end + def show_attachments obj @attachments = [] obj.each do |container| diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 711663c3d..239253d82 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -317,7 +317,7 @@ class OrganizationsController < ApplicationController @organization = Organization.find(params[:id]) admins = User.where("admin=1") admins.each do |admin| - OrgMessage.create(:user_id => admin.id, :organization_id => @organization.id, :message_type => 'ApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:domain]) + OrgMessage.create(:user_id => admin.id, :organization_id => @organization.id, :message_type => 'ApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:domain].downcase) end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 05c80a9fc..2ced977be 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -300,66 +300,27 @@ class ProjectsController < ApplicationController end # 统计访问量 @project.update_attribute(:visits, @project.visits.to_i + 1) -=begin - cond = @project.project_condition(Setting.display_subprojects_issues?) - has = { - "show_issues" => true , - "show_files" => true, - "show_documents" => true, - "show_messages" => true, - "show_news" => true, - "show_bids" => true, - "show_contests" => true, - "show_wiki_edits"=>true, - "show_journals_for_messages" => true - } - # 读取项目默认展示的动态时间天数 - @days = Setting.activity_days_default.to_i - @date_to ||= Date.today + 1 - # 时间跨度不能太大,不然很慢,所以删掉了-1.years - @date_from = @date_to - @days - @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') -=end - @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) - # 决定显示所用用户或单个用户活动 -=begin - @activity = Redmine::Activity::Fetcher.new(User.current, - :project => @project, - :with_subprojects => @with_subprojects, - :author => @author) - @activity.scope_select {|t| !has["show_#{t}"].nil?} -=end - @page = params[:page] ? params[:page].to_i + 1 : 0 # 根据私密性,取出符合条件的所有数据 if User.current.member_of?(@project) || User.current.admin? case params[:type] when nil - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo')",@project).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo', 'Attachment')",@project).order("updated_at desc").limit(10).offset(@page * 10) when 'issue' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10) when 'news' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10) when 'message' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'attachment' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Attachment'",@project).order("updated_at desc").limit(10).offset(@page * 10) end - - #events = @activity.events(@date_from, @date_to) else @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc") .page(params['page'|| 1]).per(10); - # @events = @activity.events(@date_from, @date_to, :is_public => 1) end - -=begin - @events_pages = Paginator.new events.count, 10, params['page'] - # 总的数据中取出某一页 - events = events.slice(@events_pages.offset,10) - # 按天分组 - @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} -=end boards = @project.boards.includes(:last_message => :author).all @topic_count = @project.boards.count # 根据对应的请求,返回对应的数据 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 06b2df862..33b6e8643 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -388,12 +388,12 @@ class UsersController < ApplicationController @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") end @type = params[:type] - @limit = 15 + @limit = 25 @is_remote = true @hw_count = @homeworks.count @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset - @homeworks = paginateHelper @homeworks,15 + @homeworks = paginateHelper @homeworks,25 respond_to do |format| format.js format.html {render :layout => 'static_base'} @@ -547,13 +547,13 @@ class UsersController < ApplicationController end @type = params[:type] @property = params[:property] - @limit = 15 + @is_import = params[:is_import] + @limit = params[:is_import].to_i == 1 ? 15 : 25 @is_remote = true @hw_count = @homeworks.count @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset - @homeworks = paginateHelper @homeworks,15 - @is_import = params[:is_import] + @homeworks = paginateHelper @homeworks,@limit respond_to do |format| format.js end @@ -573,6 +573,7 @@ class UsersController < ApplicationController @r_sort = @b_sort == "desc" ? "asc" : "desc" @user = User.current search = params[:name].to_s.strip.downcase + type_ids = params[:property] ? "(" + params[:property] + ")" : "(1, 2, 3)" 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(",") + ")" @@ -580,24 +581,40 @@ 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("#{@order} #{@b_sort}") + if @order == "course_name" + sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' or homework_commons.user_id in #{user_ids}) order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" + @homeworks = HomeworkCommon.find_by_sql(sql) + elsif @order == "user_name" + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") + else + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}") + end elsif params[:type] == "2" #课程资源 - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("#{@order} #{@b_sort}") + if @order == "course_name" + sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" + @homeworks = HomeworkCommon.find_by_sql(sql) + elsif @order == "user_name" + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") + else + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") + end end +=begin if params[:property] && params[:property] == "1" - @homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}") + @homeworks = @homeworks.where("homework_type = 1") elsif params[:property] && params[:property] == "2" - @homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}") + @homeworks = @homeworks.where("homework_type = 2") elsif params[:property] && params[:property] == "3" - @homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}") + @homeworks = @homeworks.where("homework_type = 3") end +=end @type = params[:type] - @limit = 15 + @limit = params[:is_import].to_i == 1 ? 15 : 25 @is_remote = true @hw_count = @homeworks.count @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset - @homeworks = paginateHelper @homeworks,15 + @homeworks = paginateHelper @homeworks,@limit @is_import = params[:is_import] @property = params[:property] @search = search diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ca8e0fc28..42911cc33 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1044,9 +1044,9 @@ module ApplicationHelper elsif @organization title << @organization.name elsif @user - title << @user.login + title << @user.try(:realname) else - title << User.current.login + title << User.current.try(:realname) end if first_page.nil? || first_page.web_title.nil? title << Setting.app_title unless Setting.app_title == title.last @@ -2069,7 +2069,7 @@ module ApplicationHelper candown = User.current.member_of?(project) || (project.is_public && attachment_history.is_public == 1) elsif attachment_history.container_type == "OrgSubfield" org = OrgSubfield.find(attachment_history.container_id) - candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1) + candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1 && (User.current.logged? || org.organization.allow_guest_download?)) end end @@ -2943,41 +2943,86 @@ int main(int argc, char** argv){ end def user_url_in_org(user_id) - if Rails.env.development? - return "http://localhost:3000/users/" + user_id.to_s - elsif Rails.env.test? - return "https://www.test.forge.trustie.net/users/" + user_id.to_s - else - return "https://www.trustie.net/users/" + user_id.to_s - end + Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s +end + +def project_issues_url_in_org(project_id) + Setting.protocol + "://" + Setting.host_name + "/projects/" + project_id.to_s + "/issues" +end + +def issue_url_in_org(id) + Setting.protocol + "://" + Setting.host_name + "/issues/" + id.to_s +end + +def project_boards_url_in_org(id) + Setting.protocol + "://" + Setting.host_name + "/projects/" + id.to_s + "/boards" +end + +def board_message_url_in_org(board_id, message_id) + Setting.protocol + "://" + Setting.host_name + "/boards/" + board_id.to_s + "/topics/" + message_id.to_s +end + +def project_url_in_org(id) + Setting.protocol + "://" + Setting.host_name + "/projects/" + id.to_s +end + +def homework_common_index_url_in_org(course_id) + Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s +end + +def student_work_index_url_in_org(homework_id) + Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s +end + +def course_url_in_org(course_id) + Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s +end + +def user_watchlist_url_in_org(id) + Setting.protocol + "://" + Setting.host_name + "/users/" + id.to_s + "/user_watchlist" +end + +def user_fanslist_url_in_org(id) + Setting.protocol + "://" + Setting.host_name + "/users/" + id.to_s + "/user_fanslist" +end + +def user_blogs_url_in_org(user_id) + Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s + "/blogs" +end + +def feedback_url_in_org(user_id) + Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s + "/user_newfeedback" +end + +def user_activities_url_in_org(user_id) + Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s + "/user_activities" +end + +def course_news_index_url_in_org(course_id) + Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s + "/news" +end + +def news_url_in_org(news_id) + Setting.protocol + "://" + Setting.host_name + "/news/" + news_id.to_s +end + +def course_boards_url_in_org(course_id) + Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s + "/boards" end def logout_url_without_domain - if Rails.env.development? - return "http://localhost:3000/logout" - elsif Rails.env.test? - return "https://test.forge.trustie.net/logout" - else - return "https://www.trustie.net/logout" - end + Setting.protocol + "://" + Setting.host_name + "/logout" end def signin_url_without_domain - if Rails.env.development? - return "http://localhost:3000/login?login=true" - elsif Rails.env.test? - return "https://test.forge.trustie.net/login?login=true" - else - return "https://www.trustie.net/login?login=true" - end + Setting.protocol + "://" + Setting.host_name + "/login?login=true" end def register_url_without_domain - if Rails.env.development? - return "http://localhost:3000/login?login=false" - elsif Rails.env.test? - return "https://test.forge.trustie.net/login?login=false" - else - return "https://www.trustie.net/login?login=false" - end + Setting.protocol + "://" + Setting.host_name + "/login?login=false" end +#判断是否为默认的组织栏目 +def is_default_field? field + (field.name == 'activity' || field.name == 'course' || field.name == 'project') && field.field_type == 'default' +end + diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb index 15c809964..8d08f22da 100644 --- a/app/helpers/routes_helper.rb +++ b/app/helpers/routes_helper.rb @@ -22,10 +22,18 @@ module RoutesHelper # Returns the path to project issues or to the cross-project # issue list if project is nil def _project_issues_path(project, *args) - if project - project_issues_path(project, *args) + if args[0].to_s.include? '_page' + if args[0].to_s == "user_page" + user_activities_path(args[1].to_i) + else + project_path(project) + end else - issues_path(*args) + if project + project_issues_path(project, *args) + else + issues_path(*args) + end end end diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 9c1431d5d..a02eb750c 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -5,7 +5,7 @@ class CourseActivity < ActiveRecord::Base belongs_to :course belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity, :add_course_activity + after_save :add_user_activity, :add_org_activity after_create :add_course_lead before_destroy :destroy_user_activity, :destroy_org_activity @@ -31,14 +31,16 @@ class CourseActivity < ActiveRecord::Base end end - def add_course_activity + def add_org_activity org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'").first if org_activity + org_activity.updated_at = self.updated_at org_activity.save else if self.course_act_type == 'Message' && !self.course_act.parent_id.nil? org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.course_act.parent.id}").first org_activity.created_at = self.created_at + org_activity.updated_at = self.updated_at org_activity.save else OrgActivity.create(:user_id => self.user_id, @@ -66,12 +68,13 @@ class CourseActivity < ActiveRecord::Base # 导语要放置在课程创建信息之后 # 导语 def add_course_lead - if self.course_act_type == "Course" + if self.course_act_type == "Course" and Message.where("id=12440").any? lead_message = Message.find(12440) name = lead_message.subject content = lead_message.content # message的status状态为0为正常,为1表示创建课程时发送的message - message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => self.course.tea_id , :sticky => true, :status => true ) + # author_id 默认为课程使者创建 + message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => 1 , :sticky => true, :status => true ) # 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直 message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index c98c5475b..c044392a0 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -48,7 +48,7 @@ class ForgeActivity < ActiveRecord::Base def add_org_activity org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first if org_activity - org_activity.created_at = self.created_at + org_activity.updated_at = self.updated_at org_activity.save else if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil? diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index c62cbf4f8..8cec49686 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -9,6 +9,7 @@ class OrgSubfield < ActiveRecord::Base has_many :news, :dependent => :destroy acts_as_attachable after_create :create_board_sync + after_destroy :update_priority # 创建资源栏目讨论区 def create_board_sync @board = self.boards.build @@ -25,4 +26,11 @@ class OrgSubfield < ActiveRecord::Base def project end + + def update_priority + OrgSubfield.where("organization_id=? and priority>?", self.organization_id, self.priority).each do |field| + field.decrement(:priority) + field.save + end + end end \ No newline at end of file diff --git a/app/models/organization.rb b/app/models/organization.rb index fcb777fb6..248783a26 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -16,8 +16,8 @@ class Organization < ActiveRecord::Base end def add_default_subfields - OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default') - OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default') - OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default') + OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default', :priority => 1) + OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default', :priority => 2) + OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default', :priority => 3) end end diff --git a/app/models/user.rb b/app/models/user.rb index a74c20751..78d823ea7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -116,7 +116,7 @@ class User < Principal has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'" has_one :blog, :class_name => 'Blog', :foreign_key => "author_id" - has_many :org_document_comments, :dependent =>:destroy + has_many :org_document_comments, :dependent =>:destroy, :foreign_key => "creator_id" has_one :api_token, :class_name => 'Token', :conditions => "action='api'" belongs_to :auth_source has_many :org_members @@ -822,6 +822,9 @@ class User < Principal end def member_of_org?(org) + if !self.logged? + return false + end OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0 end @@ -1064,6 +1067,16 @@ class User < Principal anonymous_user end + # refactor User model find function, + # return anonymous user when can not find user id = user_id + def self.find (*args, &block) + begin + super + rescue + self.anonymous + end + # super + end # Salts all existing unsalted passwords # It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password)) # This method is used in the SaltPasswords migration and is to be kept as is diff --git a/app/views/blog_comments/edit.html.erb b/app/views/blog_comments/edit.html.erb index 704342fc0..1e29d0a14 100644 --- a/app/views/blog_comments/edit.html.erb +++ b/app/views/blog_comments/edit.html.erb @@ -1,6 +1,5 @@ -<% if User.current.logged? && User.current.id == @user.id %> - <%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id, :is_homepage => params[:is_homepage],:in_act => params[:in_act]},:method=>'PUT', - :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> - <% end %> -<% end %> \ No newline at end of file + +<%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id, :is_homepage => params[:is_homepage],:in_act => params[:in_act]},:method=>'PUT', + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> +<% end %> diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index c80274db4..de7f1647d 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -38,7 +38,7 @@ <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
- <% if @article.author.id == User.current.id%> + <% if @article.author.id == User.current.id || User.current.admin? %>
- <% if activity.author.id == User.current.id%> + <% if activity.author.id == User.current.id || User.current.admin? %>
diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 31cdf41eb..3deb04f6c 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,7 +1,123 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> <% end %> - + <%= error_messages_for 'message' %>
@@ -25,7 +141,7 @@ <%= text_area :quote,:quote,:style => 'display:none' %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :content, :editor_id => 'message_content_editor', + <%#= f.kindeditor :content, :editor_id => 'message_content_editor', :owner_id => topic.nil? ? 0: topic.id, :owner_type => OwnerTypeHelper::MESSAGE, :width => '100%', @@ -37,8 +153,11 @@ :maxlength => 5000 }, at_id: topic.id, at_type: topic.class.to_s %> +

+

+

@@ -49,11 +168,11 @@
<%if !edit_mode %> - 确定 + 确定 取消 <% else %> - 确定 + 确定 <%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%> <% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 16b4fcd3d..d33b75f82 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -25,11 +25,13 @@ 课程问答区
+
<% if User.current.logged? %> <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :course => @board.course} %> <% end %> <% end %> +
<%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %>
diff --git a/app/views/courses/private_or_public.js.erb b/app/views/courses/private_or_public.js.erb index 10b787dd4..4e512a6a0 100644 --- a/app/views/courses/private_or_public.js.erb +++ b/app/views/courses/private_or_public.js.erb @@ -9,10 +9,10 @@ } <% else %> <% if @course.is_public? %> - $("#set_course_public_<%= @course.id %>").text("设为私有"); $("#show_course_<%= @course.id %>").attr("title","公开课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); <% else %> - $("#set_course_public_<%= @course.id %>").text("设为公开"); $("#show_course_<%= @course.id %>").attr("title","私有课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); <% end %> + $("#set_course_public_<%= @course.id %>").replaceWith('<%= escape_javascript(link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => "courses", :action => "private_or_public", :id => @course,:user_page => true}, + :id => "set_course_public_#{@course.id.to_s}",:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗") %>'); <% end %> \ No newline at end of file diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index b839128da..ab547db87 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -11,7 +11,7 @@
<%# 如果有历史版本则提供历史版本下载 %> <% if file.attachment_histories.count == 0 %> - <%= link_to truncate(file.filename,length: 35, omission: '...'), + <%= link_to file.is_public? ? truncate(file.filename, length: 45) : truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> <% else %> diff --git a/app/views/files/_subfield_files.html.erb b/app/views/files/_subfield_files.html.erb index 7fb9e2e0a..9e0dd41d0 100644 --- a/app/views/files/_subfield_files.html.erb +++ b/app/views/files/_subfield_files.html.erb @@ -41,9 +41,10 @@ <%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%> <%= submit_tag "栏目内搜索", :class => "blueBtn mr5 fl",:style => 'width:72px;',:name => "inorg_subfield",:id => "inorg_subfield", :onmouseover => "presscss('inorg_subfield')",:onmouseout =>"buttoncss()" %> <%#= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> - - <%= link_to("导入资源", import_resources_user_path(User.current, :type => 6, :subfield_file_id => @org_subfield.id), :class => "blue-btn fr mr5", :remote => true) %> - <%#= link_to "上传资源",subfield_upload_file_org_subfield_files_path(@org_subfield.id, :in_org => 1),:method => "post",:class=>"blueBtn fr mr5",:remote => true %> + <% if User.current.member_of_org?(org_subfield.organization) %> + + <%= link_to("导入资源", import_resources_user_path(User.current, :type => 6, :subfield_file_id => @org_subfield.id), :class => "blue-btn fr mr5", :remote => true) %> + <% end %> <% end %>
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index b9d463855..4b82f8665 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -9,6 +9,9 @@ $(function(){ $("#RSide").removeAttr("id"); $("#Container").css("width","1000px"); + if(<%= @is_edit %>) { + issueEditShow(); + } });
diff --git a/app/views/layouts/_org_courses.html.erb b/app/views/layouts/_org_courses.html.erb index 648f62ecf..282447f0f 100644 --- a/app/views/layouts/_org_courses.html.erb +++ b/app/views/layouts/_org_courses.html.erb @@ -1,7 +1,7 @@ <% courses.each do |course|%> <%# pro = Project.find course.course_id %>
  • - <%= link_to course.name, course_path(course.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => course.name%> + <%= link_to course.name, course_url_in_org(course.id), :class => "coursesLineGrey hidden", :title => course.name%> diff --git a/app/views/layouts/_org_projects.html.erb b/app/views/layouts/_org_projects.html.erb index 2e5041d20..b4ddccd9b 100644 --- a/app/views/layouts/_org_projects.html.erb +++ b/app/views/layouts/_org_projects.html.erb @@ -1,7 +1,7 @@ <% projects.each do |project|%> <%# pro = Project.find project.project_id %>
  • - <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => project.name%> + <%= link_to project.name, project_url_in_org(project.id), :class => "coursesLineGrey hidden", :title => project.name%> diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index 30a911d09..872d842be 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -1,7 +1,7 @@ <% courses.each do |course|%>
  • <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> - <%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", + <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", :id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+"("+current_time_and_term(course)+")"%> <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
      diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 7b19d2f9b..1df3caab2 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -227,6 +227,7 @@
    <% end %> + <% if @course.description && !@course.description.blank? %>

    <%= l(:label_course_brief_introduction)%>:

    @@ -241,6 +242,7 @@
    + <% end %>

    <%= l(:label_tag)%>:

    diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 4a8e00c96..f2ece1f35 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -44,14 +44,14 @@
  • <% if User.current.logged? %> <% else %> - - + + <% end %> - <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%> + <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_url_in_org(activity.course.id), :class => "newsBlue ml15"%>
    <% if activity.homework_detail_manual%> <% if activity.homework_detail_manual.comment_status == 1%> @@ -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=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! + 系统提示:该作业要求各组长<%=link_to "创建项目", "https://www.trustie.net/projects/new",:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! <% elsif activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 0%> 系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合! <% end %> @@ -73,7 +73,7 @@ <% if activity.homework_type == 2 && is_teacher%>
    - <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> + <%= link_to "模拟答题", "https://www.trustie.net/new_user_commit_homework?homework_id="+activity.id.to_s + "&is_test=true", class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
    <% end %> <% if activity.homework_type == 2%> @@ -129,7 +129,7 @@ <% if activity.student_works.count != 0 %> <% sw = activity.student_works.reorder("created_at desc").first %>
    - # <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 + # <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_url_in_org(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
    <% end %>
    @@ -141,7 +141,7 @@ <% last_score = student_work_scores.first %>

    # <%=time_from_now last_score.created_at %> - <%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行: + <%= link_to last_score.user.show_name, user_activities_url_in_org(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行:

    <% end %> @@ -154,18 +154,8 @@ <% end %> <% student_works.each_with_index do |sw, i| %>
    - - <% 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 => "学生头像" %> - - <% else %> - <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '该作业的作品暂未公开') %> - - <% end %> + <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %> + <% 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) %>分

    @@ -175,7 +165,7 @@ <% end %> <% end %> <% if student_works.count > 5 %> - <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <%= link_to "更多>>", student_work_index_url_in_org(activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> <% end %>
    @@ -187,7 +177,7 @@ <% sort_projects = project_sort_update projects %>
    - # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新: + # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_url_in_org(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
    <% sort_projects.each_with_index do |pro, i| %> @@ -204,7 +194,7 @@
    <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> - <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像" %> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_url_in_org(project.id),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像" %> <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %> <% end %> @@ -237,17 +227,17 @@
    • - <%= link_to l(:button_edit),edit_homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity), :class => "postOptionLink"%> + <%= link_to l(:button_edit),Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/edit?", :class => "postOptionLink"%>
    • - <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> + <%= link_to(l(:label_bid_respond_delete), Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "?is_in_course=-1&course_activity=" + course_activity.to_s,:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
    • - <%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => 0),:class => "postOptionLink", :remote => true) %> + <%= link_to("评分设置", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/score_rule_set?is_in_course=0&user_activity_id=" + user_activity_id.to_s,:class => "postOptionLink", :remote => true) %>
    • <% if activity.anonymous_comment == 0 %>
    • - <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> + <%= link_to("匿评设置", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/start_evaluation_set",:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%>
    • <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %> @@ -255,17 +245,17 @@ <% end %> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
    • - <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", + <%= link_to("禁用匿评", Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_forbidden_anonymous_comment?user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品",:remote => true)%>
    • <% end %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
    • - <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= link_to("公开作品", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%>
    • <% elsif activity.is_open == 1 %>
    • - <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= link_to("取消公开", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%>
    • <% end %>
    @@ -356,7 +346,7 @@ <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
    - +

    <% end%> diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb index 4873fbba9..9a9943e9b 100644 --- a/app/views/organizations/_org_course_message.html.erb +++ b/app/views/organizations/_org_course_message.html.erb @@ -12,13 +12,13 @@ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> + <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_url_in_org(activity.course.id), :class => "newsBlue ml15 mr5"%>
  • <% if activity.sticky == 1%> diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb index 3da0887ed..7f50b3725 100644 --- a/app/views/organizations/_org_course_news.html.erb +++ b/app/views/organizations/_org_course_news.html.erb @@ -1,123 +1,123 @@ -
    -
    -
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> -
    -
    -
    - <% if @ctivity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %> -
    - - <% if activity.sticky == 1%> - 置顶 - <% end%> -
    -
    - 发布时间:<%= format_time(activity.created_on) %> -
    -
    - 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %> -
    -
    - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %> -
    - - -
    -
    - <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> -
    -
    -
    -
    - <% count=activity.comments.count %> -
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <% if activity.author == User.current %> - - <% 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) %> - - <% if comment.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - <% end %> - -
      -
      - <%= comment.comments.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 => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> - -
    - - -
    -

    - <% end%> -
    -
    -
    -
    -
    -
    -
    +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> +
    +
    +
    + <% if @ctivity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_url_in_org(activity.course.id), :class => "newsBlue ml15" %> +
    + + <% if activity.sticky == 1%> + 置顶 + <% end%> +
    +
    + 发布时间:<%= format_time(activity.created_on) %> +
    +
    + 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %> +
    +
    + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %> +
    + + +
    +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> +
    +
    +
    +
    + <% count=activity.comments.count %> +
    +
    +
    回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% 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) %> + + <% if comment.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> + +
      +
      + <%= comment.comments.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 => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + +
    + + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    +
    diff --git a/app/views/organizations/_org_course_poll.html.erb b/app/views/organizations/_org_course_poll.html.erb index c124e829f..cfd2fcb65 100644 --- a/app/views/organizations/_org_course_poll.html.erb +++ b/app/views/organizations/_org_course_poll.html.erb @@ -16,7 +16,7 @@ <%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %> + <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", Setting.protocol + "://" + Setting.host_name + "/poll?polls_type=Course&polls_group_id=" + activity.polls_group_id.to_s, :class => "newsBlue ml15" %>
    diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 449d95f4c..3db6ffb13 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -34,71 +34,76 @@ }) }) -<% org_activity_field = organization.org_subfields.where('field_type="default" and name="activity" and field_type="default"').first %> -<% org_course_field = organization.org_subfields.where('field_type="default" and name="course" and field_type="default"').first %> -<% org_project_field = organization.org_subfields.where('field_type="default" and name="project" and field_type="default"').first %> -
    - <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %> -
    -
    -
    - 项目 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - <% end %> -
    -
    -
      - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
    -
    -
    -
    -
    - 课程 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <% end %> -
    -
    -
      - <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
    -
    -
    -<% organization.org_subfields.where("field_type != 'default'").each do |field| %> -
    - <% if field.field_type == "Post" %> - <% if !field.subfield_subdomain_dir.nil? %> - <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> - <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> +<% organization.org_subfields.order("priority").each do |field| %> + <% if is_default_field?(field) %> + <% case field.name %> + <% when 'activity' %> +
    + <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %> +
    + <% when 'course' %> +
    +
    + 课程 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <% end %> +
    +
    +
      + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
    +
    +
    + <% when 'project' %> +
    +
    + 项目 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + <% end %> +
    +
    +
      + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
    +
    +
    + <% end %> + <% else %> +
    + <% if field.field_type == "Post" %> + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% else %> + <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% end %> <% else %> - <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> + <% end %> + <% if User.current.member_of_org?organization %> + <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> <% end %> <% else %> - <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% else %> + <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% end %> + <% else %> + <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> + <% end %> + <% if User.current.member_of_org?organization %> + <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %> + + <% end %> + <% end %> - <% if User.current.member_of_org?organization %> - <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> - <% end %> - <% else %> - <% if !field.subfield_subdomain_dir.nil? %> - <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> - <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> - <% else %> - <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> - <% end %> - <% else %> - <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> - <% end %> - <% if User.current.member_of_org?organization %> - <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %> - - <% end %> - - <% end %> -
    - +
    + + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/organizations/_org_members.html.erb b/app/views/organizations/_org_members.html.erb index 53618fc92..b846b940f 100644 --- a/app/views/organizations/_org_members.html.erb +++ b/app/views/organizations/_org_members.html.erb @@ -14,7 +14,7 @@ <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %> <%= l(:label_username)%> - <%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %>
    + <%= link_to(member.user.show_name, user_url_in_org(member.user_id),:class => "ml5 c_blue02") %>
    身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %> <% if member.created_at %> <%= format_time(member.created_at) %> diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 782412e43..9b7dbfa8f 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -1,141 +1,141 @@ -
    -
    -
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> -
    -
    -
    - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%> -
    -
    - <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> - - <%#= get_issue_priority(activity.priority_id)[1] %> - -
    -
    -
    指派给   - <% unless activity.assigned_to_id.nil? %> - <% if activity.try(:assigned_to).try(:realname) == ' ' %> - <%= link_to activity.try(:assigned_to), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:assigned_to).try(:realname), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %> - <% end %> - <% end %> -
    -
    - 发布时间: - <%=format_time(activity.created_on) %> -
    -
    - 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %> -
    -
    -
    - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %> -
    - - -
    -
    - <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> -
    -
    -
    -
    - <% count = activity.journals.count %> -
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <% if activity.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - <% end %> - -
    -
    <%#= format_date(activity.updated_on) %>
    - <% if count > 3 %> - - <% end %> -
    - - <% replies_all_i = 0 %> - <% if count > 0 %> -
    -
      - <% activity.journals.reorder("created_on desc").each do |reply| %> - - <% replies_all_i=replies_all_i + 1 %> -
    • -
      - <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_url_in_org(reply.user_id), :alt => "用户头像" %> -
      -
      -
      - <% if reply.try(:user).try(:realname) == ' ' %> - <%= link_to reply.try(:user), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:user).try(:realname), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %> - <% end %> - <%= format_time(reply.created_on) %> - - <% if reply.user == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> - <% end %> - -
      -
      - <% if reply.details.any? %> - <% details_to_strings(reply.details).each do |string| %> -

      <%= string %>

      - <% end %> - <% end %> -

      <%= reply.notes.nil? ? "" : reply.notes.html_safe %>

      -
      -
      -
      -
    • - <% end %> -
    -
    - <% end %> - -
    -
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
    -
    -
    - <%= form_for('new_form',:url => add_journal_in_org_issue_path(activity.id),:method => "post", :remote => true) do |f|%> - -
    - - -
    -

    - <% end%> -
    -
    -
    -
    -
    - -
    -
    +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> +
    +
    +
    + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_url_in_org(activity.project.id), :class => "newsBlue ml15"%> +
    +
    + <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :class => "postGrey" %> + + <%#= get_issue_priority(activity.priority_id)[1] %> + +
    +
    +
    指派给   + <% unless activity.assigned_to_id.nil? %> + <% if activity.try(:assigned_to).try(:realname) == ' ' %> + <%= link_to activity.try(:assigned_to), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:assigned_to).try(:realname), user_url_in_org(activity.assigned_to_id), :class => "newsBlue mr15" %> + <% end %> + <% end %> +
    +
    + 发布时间: + <%=format_time(activity.created_on) %> +
    +
    + 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %> +
    +
    +
    + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %> +
    + + +
    +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> +
    +
    +
    +
    + <% count = activity.journals.count %> +
    +
    +
    回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
    +
    <%#= format_date(activity.updated_on) %>
    + <% if count > 3 %> + + <% end %> +
    + + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.journals.reorder("created_on desc").each do |reply| %> + + <% replies_all_i=replies_all_i + 1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_url_in_org(reply.user_id), :alt => "用户头像" %> +
      +
      +
      + <% if reply.try(:user).try(:realname) == ' ' %> + <%= link_to reply.try(:user), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:user).try(:realname), user_url_in_org(reply.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> + + <% if reply.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> + +
      +
      + <% if reply.details.any? %> + <% details_to_strings(reply.details).each do |string| %> +

      <%= string %>

      + <% end %> + <% end %> +

      <%= reply.notes.nil? ? "" : reply.notes.html_safe %>

      +
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => add_journal_in_org_issue_path(activity.id),:method => "post", :remote => true) do |f|%> + +
    + + +
    +

    + <% end%> +
    +
    +
    +
    +
    + +
    +
    diff --git a/app/views/organizations/_project_create.html.erb b/app/views/organizations/_project_create.html.erb index e13f4128b..5003fd0e2 100644 --- a/app/views/organizations/_project_create.html.erb +++ b/app/views/organizations/_project_create.html.erb @@ -3,21 +3,21 @@
    - <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user.id), :alt => "用户头像" %> <%= render :partial => 'users/show_detail_info', :locals => {:user => user} %>
    <% if user.try(:realname) == ' ' %> - <%= link_to user, user_url_in_org(user), :class => "newsBlue mr15" %> + <%= link_to user, user_url_in_org(user.id), :class => "newsBlue mr15" %> <% else %> - <%= link_to user.try(:realname), user_url_in_org(user), :class => "newsBlue mr15" %> + <%= link_to user.try(:realname), user_url_in_org(user.id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to project.to_s+" | 项目", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> + <%= link_to project.to_s+" | 项目", project_url_in_org(project.id), :class => "newsBlue ml15" %>
    - <%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %> + <%= link_to project.name, project_url_in_org(project.id), :class => "postGrey" %>
    创建时间:<%= format_time(project.created_on) %> diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb index 99a067dfb..a818939d6 100644 --- a/app/views/organizations/_project_message.html.erb +++ b/app/views/organizations/_project_message.html.erb @@ -1,136 +1,135 @@ -
    -
    -
    - <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> -
    -
    -
    - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> - <% end %> - TO - <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> - -
    -
    - <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" - %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" - %> - <% end %> -
    -
    - 发帖时间:<%= format_time(activity.created_on) %> -
    -
    - 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %> -
    -
    - <% if activity.parent_id.nil? %> - <% content = activity.content%> - <% else %> - <% content = activity.parent.content%> - <% end %> - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %> -
    - - -
    -
    - <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> -
    -
    -
    -
    - <% count = 0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> -
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <% if activity.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - <% end %> - -
    -
    <%#=format_date(activity.updated_on)%>
    - <%if count>3 %> - - <% end %> -
    - - <% activity= activity.parent_id.nil? ? activity : activity.parent %> - <% replies_all_i = 0 %> - <% if count > 0 %> -
    -
      - <% activity.children.reorder("created_on desc").each do |reply| %> - - <% replies_all_i=replies_all_i+1 %> -
    • -
      - <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %> -
      -
      -
      - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %> - <% end %> - <%= format_time(reply.created_on) %> - - <% if reply.author == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> - <% end %> - -
      -
      - <%= reply.content.html_safe %>
      -
      -
      -
    • - <% end %> -
    -
    - <% end %> - -
    -
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
    -
    -
    - <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> - - -
    - - -
    -

    - <% end%> -
    -
    -
    -
    -
    - -
    -
    +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> +
    +
    +
    + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_url_in_org(activity.project.id), :class => "newsBlue ml15 mr5"%> + +
    +
    + <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id), :class=> "postGrey" + %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id), :class=> "postGrey" %> + <% end %> +
    +
    + 发帖时间:<%= format_time(activity.created_on) %> +
    +
    + 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %> +
    +
    + <% if activity.parent_id.nil? %> + <% content = activity.content%> + <% else %> + <% content = activity.parent.content%> + <% end %> + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %> +
    + + +
    +
    + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> +
    +
    +
    +
    + <% count = 0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
    +
    +
    回复 + <%= count>0 ? "(#{count})" : "" %> + + <% if activity.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + +
    +
    <%#=format_date(activity.updated_on)%>
    + <%if count>3 %> + + <% end %> +
    + + <% activity= activity.parent_id.nil? ? activity : activity.parent %> + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.children.reorder("created_on desc").each do |reply| %> + + <% replies_all_i=replies_all_i+1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %> +
      +
      +
      + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> + + <% if reply.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> + +
      +
      + <%= reply.content.html_safe %>
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + +
    + + +
    +

    + <% end%> +
    +
    +
    +
    +
    + +
    +
    diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index ed6e1e092..e3ed492a0 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -1,152 +1,152 @@ -
    -
    -
    - <%= link_to image_tag(url_to_avatar(User.find(document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(document.creator_id) %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => User.find(document.creator_id)} %> -
    -
    -
    - <%= link_to User.find(document.creator_id), user_url_in_org(document.creator.id), :class => "newsBlue mr15" %> - TO  <%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %> - | - <%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %> -
    -
    <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
    -
    - 发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %> -
    -
    - 更新时间:<%= format_time(OrgActivity.where("org_act_type='#{document.class}' and org_act_id =#{document.id}").first.updated_at) %> -
    -
    - <% unless document.content.blank? %> - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>document.id, :content=>document.content} %> - <% end %> -
    - - -
    -
    - <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => document} %> -
    - - <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %> -
    -
      -
    • -
        -
      • - <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id, :show_homepage => 1}, :method => "put", :remote => true) do |f| %> - 设为首页 - <% end %> -
      • -
      • - <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag, :org_subfield_id => params[:org_subfield_id] ), :class => "postOptionLink" %> -
      • -
      • - <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete', - :data => {:confirm => l(:text_are_you_sure)}, - :remote => true, :class => 'postOptionLink' %> -
      • -
      -
    • -
    -
    -
    - <% end %> -
    -
    - <% comments_for_doc = document.children.reorder("created_at desc") %> - <% count = document.children.count() %> - -
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <% if document.creator_id.to_i == User.current.id.to_i %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>document, :user_activity_id=>document.id,:type=>"activity"}%> - <% end %> - -
    - <% if count > 3 %> - - <% end %> -
    -
    -
      - <% reply_id = 0 %> - <% comments_for_doc.each do |comment| %> - <% reply_id += 1 %> -
    • -
      <%= link_to image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_id) %>
      -
      -
      - <%= link_to User.find(comment.creator_id), user_url_in_org(comment.creator_id), :class => "newsBlue mr10 f14" %> - <%= format_activity_day(comment.created_at) %> <%= format_time(comment.created_at, false) %> - - <% if comment.creator_id.to_i == User.current.id.to_i %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - <% end %> - -
      - <% unless comment.content.blank? %> -
      <%= comment.content.html_safe %>
      - <% end %> -
      -
      -
    • - <% end %> -
    -
    -
    -
    - <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current) %> -
    -
    -
    - <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id, :flag => flag), :method => "post", :remote => true) do |f| %> - -
    - - - -
    -

    - <% end %> -
    -
    -
    -
    -
    -
    -
    - - \ No newline at end of file diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index eed0dabf6..0d490df77 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -1,4 +1,5 @@
      +
    • 顺序
    • 已有栏目
    • 状态
    • 类型
    • @@ -6,48 +7,64 @@
    -<% default_fields.each do |field| %> - <% name = get_default_name(field) %> - -<% end %> - <% subfields.each do |field| %> -
      -
    • -
      <%= field.name %>
      - -
    • -
    • 新增
    • -
    • <%= field.field_type == "Post" ? "帖子" : "资源" %>
    • -
    + <% end %> <% end %> -->

    +

    +

    @@ -66,7 +73,7 @@ <% end %>
    - 确定 + 确定 <%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
    @@ -96,23 +103,130 @@ } function popupRegex(){ - if(regexStudentWorkName()&®exStudentWorkDescription()) - { - if($("#group_member_ids").length > 0) { - if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { - $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); - $('#ajax-modal').parent().addClass("anonymos"); - } - } else { + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("anonymos"); } + } else { + $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); + $('#ajax-modal').parent().addClass("anonymos"); } } + + function nh_check_field(params){ + var result=true; + if(!regexStudentWorkName()) { + result=false; + return result; + } + if(params.content!=undefined){ + if(params.content.isEmpty()){ + result=false; + } + if(params.content.html()!=params.textarea.html() || params.issubmit==true){ + params.textarea.html(params.content.html()); + params.content.sync(); + + if(params.content.isEmpty()){ + params.contentmsg.html('作品描述不能为空'); + }else{ + params.contentmsg.html(''); + } + } + } + return result; + } + function init_homework_form(params){ + params.form.submit(function(){ + params.textarea.html(params.editor.html()); + params.editor.sync(); + var flag = false; + if(params.form.attr('data-remote') != undefined ){ + flag = true + } + var is_checked = nh_check_field({ + issubmit:true, + content:params.editor, + contentmsg:params.contentmsg, + textarea:params.textarea + }); + + if(is_checked){ + if(flag){ + popupRegex(); + return true; + }else{ + $(this)[0].submit(); + $("#ajax-indicator").hide(); + return false; + } + } + return false; + }); + } + function init_homework_editor(params){ + params.textarea.removeAttr('placeholder'); + var editor = params.kindutil.create(params.textarea, { + resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px", + items : ['code','emoticons','fontname', + 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|', + 'formatblock', 'fontsize', '|','indent', 'outdent', + '|','imagedirectupload','table', 'media', 'preview',"more" + ], + afterChange:function(){//按键事件 + var edit = this.edit; + var body = edit.doc.body; + //paramsHeight = params.kindutil.removeUnit(this.height); + edit.iframe.height(150); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150)); + }, + afterCreate:function(){ + //init + var edit = this.edit; + var body = edit.doc.body; + edit.iframe[0].scroll = 'no'; + body.style.overflowY = 'hidden'; + //reset height + var edit = this.edit; + var body = edit.doc.body; + edit.html(params.textarea.innerHTML); + //paramsHeight = params.kindutil.removeUnit(this.height); + edit.iframe.height(150); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); + elocalStorage(editor2,'student_work_<%=@work.id %>'); + } + }).loadPlugin('paste'); + return editor; + } + KindEditor.ready(function(K){ + $("div[nhname='student_work_form']").each(function(){ + var params = {}; + params.kindutil = K; + params.div_form = $(this); + params.form = $("form",params.div_form); + if(params.form==undefined || params.form.length==0){ + return; + } + params.textarea = $("textarea[nhname='student_work_textarea']",params.div_form); + params.contentmsg = $("#student_work_description_textarea"); + params.submit_btn = $("#new_message_submit_btn"); + if(params.textarea.data('init') == undefined) { + params.editor = init_homework_editor(params); + editor2 = params.editor; + init_homework_form(params); + params.submit_btn.click(function () { + params.form.submit(); + $("#ajax-indicator").hide(); + }); + params.textarea.data('init', 1); + } + }); + }); \ No newline at end of file diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 41ec2b61b..8e7d87302 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -172,7 +172,7 @@
    <% if @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status < 2 %>
    提交截止时间:<%= @homework.end_time %> 23:59
    - <% elsif @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status >= 2 %> + <% elsif @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status >= 2 && @homework.anonymous_comment == 0 %>
    匿评截止时间:<%= @homework.homework_detail_manual.evaluation_end %> 23:59
    <% end %> <% if @homework.homework_detail_manual.comment_status == 0 %> diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 5d2b134a8..c43482299 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -1,4 +1,9 @@ +<% content_for :header_tags do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> + <%= javascript_include_tag 'homework','baiduTemplate' %> +<% end %> +
    @@ -110,7 +225,7 @@
    -
    +
    <%= form_for(@student_work, :html => { :multipart => true }, :url => {:controller => 'student_work', @@ -127,18 +242,21 @@ <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> <% end %>
    - <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请输入作品名称", :onkeyup => "regexStudentWorkName();" %> + <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请输入作品名称",:value=>"#{@homework.name}的作品提交", :onkeyup => "regexStudentWorkName();" %>

    - <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%> - -->

    +

    +

    @@ -167,9 +285,9 @@
    -->
    - 提交 + 提交 - <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%> + <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id),:id => 'new_message_cancel_btn', :class => "fr mr10 mt3"%>
    <% end%> diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb index c89180b16..135da3c0d 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_<%= @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'}); +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_<%= @work.id%>").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_message.html.erb b/app/views/users/_course_message.html.erb index df084357a..7477eaabd 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -1,23 +1,15 @@
    - <% if activity.status == 1 %> - <%= image_tag("/images/trustie_logo1.png", width: "50px", height: "50px") %> - <% else %> - <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> - <% end %> + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
    - <% if activity.status == 1 %> - 确实团队 + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <% else %> - <% 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 %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> <% end %> TO <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> diff --git a/app/views/users/_homework_detail_information.html.erb b/app/views/users/_homework_detail_information.html.erb index 07328e696..1829fa61c 100644 --- a/app/views/users/_homework_detail_information.html.erb +++ b/app/views/users/_homework_detail_information.html.erb @@ -1,7 +1,17 @@
    题目信息
    <% if homework.nil? %> - 请先在左侧选择作业 + 本题库遵循创作共用许可证

    + +教师给学生出题本质上是一种创作行为,题目的作者通常为此付出大量时间和精力。好的题目不仅能加深学生对知识点的理解,还能激发学生兴趣,提升学习效率。为此,本网站的题库许可证基于创作共用许可证( Creative Commons License )建立,其核心条款包括:

    + +1. 署名:必须提到原作者。

    + +2. 非商业用途:不得用于盈利性目的。

    + +3. 相同方式共享:允许修改原作品,但必须使用相同的许可证发布。

    + +对此许可证的支持或反对,请在网站中留言,我们不断完善,谢谢!
    <% else %>
    标题:<%=homework.name %>
    来源:<%=homework.course.name %>
    diff --git a/app/views/users/_homework_repository_detail.html.erb b/app/views/users/_homework_repository_detail.html.erb index 7cf74e11e..efbf24955 100644 --- a/app/views/users/_homework_repository_detail.html.erb +++ b/app/views/users/_homework_repository_detail.html.erb @@ -2,7 +2,18 @@
    题目信息
    <% if homework.nil? %> - 请先在左侧选择作业 + 本题库遵循创作共用许可证
    + +教师给学生出题本质上是一种创作行为,题目的作者通常为此付出大量时间和精力。好的题目不仅能加深学生对知识点的理解,还能激发学生兴趣,提升学习效率。为此,本网站的题库许可证基于创作共用许可证( Creative Commons License )建立,其核心条款包括:

    + +1. 署名:必须提到原作者。

    + +2. 非商业用途:不得用于盈利性目的。

    + +3. 相同方式共享:允许修改原作品,但必须使用相同的许可证发布。

    + +对此许可证的支持或反对,请在网站中留言,我们不断完善,谢谢! +
    <% else %>
    标题:<%=homework.name %>
    来源:<%=homework.course.name %>
    diff --git a/app/views/users/_homework_repository_list.html.erb b/app/views/users/_homework_repository_list.html.erb index 67a8f47b4..99e6d4e27 100644 --- a/app/views/users/_homework_repository_list.html.erb +++ b/app/views/users/_homework_repository_list.html.erb @@ -1,18 +1,33 @@
      -
    • 来源
    • -
    • 类别
    • -
    • 贡献者
    • +
    • + <%= link_to "来源",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "course_name", :sort => @r_sort),:class => "fl ml55",:remote => true%> + <% if @order == "course_name"%> + <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "course_name", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%> + <% end%> +
    • +
    • + <%= link_to "类别",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "homework_type", :sort => @r_sort),:class => "fl ml10",:remote => true%> + <% if @order == "homework_type"%> + <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "homework_type", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%> + <% end%> +
    • +
    • + <%= link_to "贡献者",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "user_name", :sort => @r_sort),:class => "fl ml20",:remote => true%> + <% if @order == "user_name"%> + <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "user_name", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%> + <% end%> +
    • - <%= 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%> + <%= 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 ml5",: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%> + <%= 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 fl" ,: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%> + <%= 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 fl" ,:remote => true%> <% end%>
    diff --git a/app/views/users/_project_attachment.html.erb b/app/views/users/_project_attachment.html.erb index b98356c7b..deb0cb4c6 100644 --- a/app/views/users/_project_attachment.html.erb +++ b/app/views/users/_project_attachment.html.erb @@ -1,18 +1,32 @@ + +
    -
    +
    - 用户头像
    + <%= 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} %> +
    - - -
    - -
    截止时间:2015-08-20
    +
    + <% 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_files_path(activity.course), :class => "newsBlue ml15" %>
    -
    (作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
    - <% end %> <% end %> -
    - - -
    +
    <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
    diff --git a/app/views/users/_show_detail_info.html.erb b/app/views/users/_show_detail_info.html.erb index f2a2faeb3..7d4919149 100644 --- a/app/views/users/_show_detail_info.html.erb +++ b/app/views/users/_show_detail_info.html.erb @@ -1,6 +1,6 @@
    - <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user), :alt => "用户头像", :target => '_blank' %> + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user.id), :alt => "用户头像", :target => '_blank' %> <%#= image_tag(url_to_avatar(user), :width => "50", :height => "50") %>
    @@ -21,18 +21,18 @@
    -
    <%= link_to User.watched_by(user.id).count, {:controller=>"users", :action=>"user_watchlist",:id=>user.id}, :class => 'homepageImageNumber',:target => "_blank" %>
    -
    <%= link_to '关注',{:controller=>"users", :action=>"user_watchlist",:id=>user.id},:target => "_blank" %>
    +
    <%= link_to User.watched_by(user.id).count, user_watchlist_url_in_org(user.id), :class => 'homepageImageNumber',:target => "_blank" %>
    +
    <%= link_to '关注',user_watchlist_url_in_org(user.id),:target => "_blank" %>
    -
    <%= link_to user.watcher_users.count,{:controller=>"users", :action=>"user_fanslist",:id=>user.id}, :class => "homepageImageNumber fans_count_#{user.id}",:target => "_blank" %>
    -
    <%= link_to '粉丝', {:controller=>"users", :action=>"user_fanslist",:id=>user.id},:target => "_blank" %>
    +
    <%= link_to user.watcher_users.count,user_fanslist_url_in_org(user.id), :class => "homepageImageNumber fans_count_#{user.id}",:target => "_blank" %>
    +
    <%= link_to '粉丝', user_fanslist_url_in_org(user.id),:target => "_blank" %>
    -
    <%= link_to user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count, user_blogs_path(user), :class => 'homepageImageNumber',:target => "_blank" %>
    -
    <%= link_to '博客', user_blogs_path(user),:target => "_blank" %>
    +
    <%= link_to user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count, user_blogs_url_in_org(user.id), :class => 'homepageImageNumber',:target => "_blank" %>
    +
    <%= link_to '博客', user_blogs_url_in_org(user.id),:target => "_blank" %>
    <% if User.current != user %> @@ -40,8 +40,8 @@ <%= render :partial => 'users/watch_btn_for_picture', :locals => {:user => user} %>
    - <%= link_to "留言", feedback_path(user), :class => 'greyBtn fr', :target => "_blank" %> - <%= link_to "私信", feedback_path(user), :class => 'greyBtn fr', :style => 'margin-right:20px;', :target => "_blank" %> + <%= link_to "留言", feedback_url_in_org(user.id), :class => 'greyBtn fr', :target => "_blank" %> + <%= link_to "私信", feedback_url_in_org(user.id), :class => 'greyBtn fr', :style => 'margin-right:20px;', :target => "_blank" %> <% end %>
    diff --git a/app/views/users/_show_user_homeworks.html.erb b/app/views/users/_show_user_homeworks.html.erb index b9bbf6934..7e9df7f4d 100644 --- a/app/views/users/_show_user_homeworks.html.erb +++ b/app/views/users/_show_user_homeworks.html.erb @@ -30,7 +30,7 @@ 取消
    -
      +
        <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
    diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 0e55c246c..01711ace3 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -89,7 +89,7 @@ <% if act %> <% case user_activity.act_type.to_s %> <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id, :user_id => user_id} %> <% when 'Message' %> <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> <% when 'ProjectCreateInfo'%> diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb index d8649cabe..089171c3d 100644 --- a/app/views/users/_user_at_message.html.erb +++ b/app/views/users/_user_at_message.html.erb @@ -8,15 +8,15 @@ <% 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))" %> + :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %> + + <% 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))" %> + :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %> + + <% 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 %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 8b72ec781..f23d01d3c 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -16,7 +16,6 @@ $("#GroupPopupBox a.group_save_btn").click(); <% end %> }); - var homework_description_editor; function checked_val() { if ($("#anonymous_comment").is(":checked")) { $("#anonymous_comment").val(1); @@ -106,7 +105,7 @@ //paramsHeight = params.kindutil.removeUnit(this.height); edit.iframe.height(150); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); - + elocalStorage(homework_description_editor,'homework_<%=User.current.id %>'); } }).loadPlugin('paste'); return editor; @@ -150,7 +149,7 @@
    - <%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%> + <%= link_to("从题库选用", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%> <% unless edit_mode %> <% end %> @@ -159,7 +158,7 @@ <% end %>
    - <% if homework.homework_detail_manual.comment_status.to_i < 3 %> + <% if homework.homework_detail_manual.comment_status.to_i < 2 %> <%= calendar_for('homework_end_time')%> <% end %>
    @@ -199,6 +198,8 @@ <%= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w709",:value => "请选择发布作业的课程"} %>

    +

    +

    diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 62568d505..3b035179b 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -1,692 +1,707 @@ -<% if ma.class == CourseMessage %> - <% if ma.course_message_type == "News" %> -
      -
    • <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"),user_path(ma.course_message.author) %>
    • -
    • <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">发布了通知:
    • -
    • - <%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id }, - :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %>
    • - -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - <% if ma.course_message_type == "Comment" %> -
      -
    • <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %>
    • -
    • <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">评论了通知:
    • -
    • - <%= link_to ma.course_message.commented.title, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id }, - :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %>
    • - -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil?%> - - <% end %> - <% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %> -
      -
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • -
    • <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + '老师', - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %> - ">发布的作业:
    • -
    • - <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), - :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover => "message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> -
    • - -
    •    截止时间快到啦
    • -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - - <% if ma.course_message_type == "HomeworkCommon" && ma.status == 2 %> -
      -
    • - <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %> -
    • -
    • - <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> - ">启动了作业匿评: -
    • -
    • - <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover => "message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> -
    • - -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - - <% if ma.course_message_type == "HomeworkCommon" && ma.status == 3 %> -
      -
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • -
    • - <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">关闭了作业匿评:
    • -
    • - <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))"%> -
    • - -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - - <% if ma.course_message_type == "HomeworkCommon" && ma.status == 4 %> -
      -
    • - <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %> -
    • -
    • - <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> - ">启动作业匿评失败 -
    • -
    • - <%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}", - :onmouseover => "message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> -
    • - -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - - <% if ma.course_message_type == "Poll" %> - - <% end %> - <% if ma.course_message_type == "Message" %> - - <% end %> - <% if ma.course_message_type == "StudentWorksScore" %> -
      -
    • - <% if ma.course_message.reviewer_role == 3 %> - <%=link_to image_tag(url_to_avatar(""), :width => "30", :height => "30") %> - <% else %> - <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %> - <% end %> -
    • -
    • - <% if ma.course_message.reviewer_role == 3 %> - 匿名用户 - <% else %> - <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> - <% end %> - "> - <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %> - -
    • -
    • - <% unless ma.content.nil? %> - <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id), - :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %>
    • - - <% end %> -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - <% if ma.course_message_type == "JournalsForMessage" %> - <% if ma.course_message.jour_type == 'Course' %> - <% if params[:type] != 'homework' %> - - <% end %> - <% else %> - - <% end %> - <% end %> - - <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %> - - <% end %> - - <% if ma.course_message_type == "Course" %> - - <% end %> - <% if ma.course_message_type == "JoinCourseRequest" %> - - <% end %> - <% if ma.course_message_type == "CourseRequestDealResult" %> - - <% end %> - - - <% if ma.course_message_type == "JoinCourse" and ma.status == 0 %> - - <% end %> - - - <% if ma.course_message_type == "JoinCourse" and ma.status == 1 %> - - <% end %> - - - <% if ma.course_message_type == "RemoveFromCourse" %> - - <% end %> - - - <% if ma.course_message_type == "Exercise" && ma.status == 2 %> -
      -
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • -
    • - <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布了课程测验 :
    • -
    • - <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))"%> -
    • - - -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> - - - <% if ma.course_message_type == "Exercise" && ma.status == 3 %> -
      -
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • -
    • - <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", - user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布的测验:
    • -
    • - <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))"%> - -
    • - - -
    • 截止时间快到啦
    • -
    • <%= time_tag(ma.created_at).html_safe %>
    • -
    - <% end %> +<% if ma.class == CourseMessage %> + <% if ma.course_message_type == "News" %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"),user_path(ma.course_message.author) %>
    • +
    • <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">发布了通知:
    • +
    • + <%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id }, + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +
    • + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + <% if ma.course_message_type == "Comment" %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %>
    • +
    • <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">评论了通知:
    • +
    • + <%= link_to ma.course_message.commented.title, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id }, + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +
    • + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil?%> + + <% end %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + '老师', + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %> + ">发布的作业:
    • +
    • + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), + :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +
    • + +
    •    截止时间快到啦
    • +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 2 %> +
      +
    • + <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %> +
    • +
    • + <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> + ">启动了作业匿评: +
    • +
    • + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover => "message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %> +
    • + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 3 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • + <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">关闭了作业匿评:
    • +
    • + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +
    • + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 4 %> +
      +
    • + <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %> +
    • +
    • + <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> + ">启动作业匿评失败 +
    • +
    • + <%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}" %> + + +
    • + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + + <% if ma.course_message_type == "Poll" %> + + <% end %> + <% if ma.course_message_type == "Message" %> + + <% end %> + <% if ma.course_message_type == "StudentWorksScore" %> +
      +
    • + <% if ma.course_message.reviewer_role == 3 %> + <%=link_to image_tag(url_to_avatar(""), :width => "30", :height => "30") %> + <% else %> + <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %> + <% end %> +
    • +
    • + <% if ma.course_message.reviewer_role == 3 %> + 匿名用户 + <% else %> + <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> + <% end %> + "> + <%= ma.status == 0 ? "评阅了您的作品:" : "重新评阅了您的作品:" %> + +
    • +
    • + <% unless ma.content.nil? %> + <%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id), + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +
    • + + <% end %> +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + <% if ma.course_message_type == "JournalsForMessage" %> + <% if ma.course_message.jour_type == 'Course' %> + <% if params[:type] != 'homework' %> + + <% end %> + <% else %> + + <% end %> + <% end %> + + <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %> + + <% end %> + + <% if ma.course_message_type == "Course" %> +
      +
    • + +
    • +
    • + 系统提示 + ">您成功创建了课程: +
    • +
    • + <%= link_to "课程名称:" + ma.course_message.name, course_path(ma.course_message), + :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %> + + +
    • + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + <% if ma.course_message_type == "JoinCourseRequest" %> + + <% end %> + <% if ma.course_message_type == "CourseRequestDealResult" %> + + <% end %> + + + <% if ma.course_message_type == "JoinCourse" and ma.status == 0 %> + + <% end %> + + + <% if ma.course_message_type == "JoinCourse" and ma.status == 1 %> + + <% end %> + + + <% if ma.course_message_type == "RemoveFromCourse" %> + + <% end %> + + + <% if ma.course_message_type == "Exercise" && ma.status == 2 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • + <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布了课程测验 :
    • +
    • + <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +
    • + + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + + + <% if ma.course_message_type == "Exercise" && ma.status == 3 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • + <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布的测验:
    • +
    • + <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + + +
    • + + +
    • 截止时间快到啦
    • +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index 967941a88..574411055 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -10,9 +10,10 @@ ">申请加入项目:
  • - <%= link_to ma.project, settings_project_path(:id => ma.project, :tab => "members"), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover => "message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> + <%= link_to ma.project, settings_project_path(:id => ma.project, :tab => "members"), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +