diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 01703f679..cec419eba 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -32,18 +32,20 @@ class AdminController < ApplicationController end def projects +=begin @status = params[:status] || 1 - scope = Project.status(@status).order('id asc') + scope = Project.status(@status) scope = scope.like(params[:name]) if params[:name].present? - @projects = scope.where(project_type: Project::ProjectType_project).all - + @projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all +=end + @projects = Project.like(@name).order('created_on desc') render :action => "projects", :layout => false if request.xhr? end def courses @name = params[:name] - @courses = Course.like(@name) + @courses = Course.like(@name).order('created_at desc') respond_to do |format| format.html end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 722522a76..1d328c1e9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -422,11 +422,12 @@ class UsersController < ApplicationController end def choose_user_course + homework = HomeworkCommon.find params[:homework].to_i if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" - @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} + @course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} else - @course = @user.courses.select { |course| @user.allowed_to?(:as_teacher,course)} + @course = @user.courses.where("#{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)} end @search = params[:search] #这里仅仅是传递需要发送的资源id @@ -531,7 +532,15 @@ class UsersController < ApplicationController elsif params[:type] == "2" #我的题库 @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc") end + if params[:property] && params[:property] == "1" + @homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc") + elsif params[:property] && params[:property] == "2" + @homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc") + elsif params[:property] && params[:property] == "3" + @homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc") + end @type = params[:type] + @property = params[:property] @limit = 15 @is_remote = true @hw_count = @homeworks.count @@ -559,10 +568,21 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") #全部 visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc") + all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'") + all_user_ids = all_homeworks.map{|hw| hw.user_id} + user_str_ids = search_user_by_name all_user_ids, search + user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")" + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("created_at desc") elsif params[:type] == "2" #课程资源 @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc") end + if params[:property] && params[:property] == "1" + @homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc") + elsif params[:property] && params[:property] == "2" + @homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc") + elsif params[:property] && params[:property] == "3" + @homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc") + end @type = params[:type] @limit = 15 @is_remote = true @@ -1518,9 +1538,20 @@ class UsersController < ApplicationController #@user.save_attachments(params[:attachments],User.current) # Container_type为Principal Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) - if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 + if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + if params[:status] == 2 + @attachments = get_course_resources(params[:id], user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources params[:id] + elsif params[:status] == "5" + @attachments = get_principal_resources params[:id] + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + end elsif params[:type] == "2" # 课程资源 @attachments = get_course_resources(params[:id], user_course_ids) elsif params[:type] == "3" # 项目资源 @@ -1530,10 +1561,21 @@ class UsersController < ApplicationController elsif params[:type] == "5" #用户资源 @attachments = get_principal_resources params[:id] elsif params[:type] == "6" # 公共资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources_public + elsif params[:status] == "5" + @attachments = get_principal_resources_public + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids) + end end - @type = params[:type] || 1 + @status = params[:status] + @type = params[:type] @limit = 25 @is_remote = true @atta_count = @attachments.count @@ -1558,9 +1600,20 @@ class UsersController < ApplicationController user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} - if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 + if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + if params[:status] == 2 + @attachments = get_course_resources(params[:id], user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources params[:id] + elsif params[:status] == "5" + @attachments = get_principal_resources params[:id] + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + end elsif params[:type] == "2" # 课程资源 @attachments = get_course_resources(params[:id], user_course_ids) elsif params[:type] == "3" # 项目资源 @@ -1570,9 +1623,20 @@ class UsersController < ApplicationController elsif params[:type] == "5" #用户资源 @attachments = get_principal_resources params[:id] elsif params[:type] == "6" # 公共资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids) + elsif params[:status] == "4" + @attachments = get_attch_resources_public + elsif params[:status] == "5" + @attachments = get_principal_resources_public + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids) + end end + @status = params[:status] @type = params[:type] @limit = 25 @is_remote = true @@ -2320,7 +2384,7 @@ class UsersController < ApplicationController # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - if params[:status] == 2 + if params[:status] == "2" @attachments = get_course_resources(params[:id], user_course_ids) elsif params[:status] == "3" @attachments = get_project_resources(params[:id], user_project_ids) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index b77dfe3bd..44b919121 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,664 +1,676 @@ -# encoding: utf-8 -# -# Redmine - project management software -# Copyright (C) 2006-2013 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - - -include AvatarHelper -module UsersHelper - def users_status_options_for_select(selected) - user_count_by_status = User.count(:group => 'status').to_hash - options_for_select([[l(:label_all), ''], - ["#{l(:status_active)} (#{user_count_by_status[1].to_i})", '1'], - ["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", '2'], - ["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s) - end - - def get_resource_type type - case type - when 'Course' - '课程资源' - when 'Project' - '项目资源' - when 'Issue' - '缺陷附件' - when 'Message' - '讨论区附件' - when 'Document' - '文档附件' - when 'News' - '通知附件' - when 'HomewCommon' - '作业附件' - when 'StudentWorkScore' - '批改附件' - when 'Principal' - '用户资源' - when 'OrgSubfield' - '组织资源' - end - end - - def get_resource_origin attach - type = attach.container_type - content = attach.container - unless content.nil? - case type - when 'Course' - result = current_time_and_term_resource content - when 'Project' - result = content.name - when 'Issue' - result = content.subject - when 'Message' - result = content.subject - when 'News' - result = content.title - when 'HomewCommon' - result = content.name - when 'StudentWorkScore' - result = content.name - when 'Principal' - result = content.name - when 'OrgSubfield' - result = content.name - end - end - end - - def current_time_and_term_resource course - str = "" - term = cur_course_term_resource - name = course.name - if (course.time == course.end_time && course.term == course.end_term) || (course.end_term.nil? && course.end_time.nil?) || course.time > Time.now.year - str = name + "(" + course.time.to_s + course.term.to_s + ")" - elsif course.time == Time.now.year && set_term_value(cur_course_term) <= set_term_value(course.term) - str = name + "(" + course.time.to_s + course.term.to_s + ")" - elsif course.end_time < Time.now.year || (course.end_time == Time.now.year && set_term_value(cur_course_term) >= set_term_value(course.term)) - str = name + "(" + course.end_time.to_s + course.end_term.to_s + ")" - else - str = name + "(" + Time.now.year.to_s + cur_course_term_resource.to_s + ")" - end - str - end - - def cur_course_term_resource - month = Time.now.month - if month >= 9 || month < 2 - term = "秋" - elsif (month >= 7 && Time.now.day >= 15) || month == 8 - term = "夏" - else - term = "春" - end - term - end - - def title_for_message type - case type - when nil - '消息' - when 'unviewed' - '未读消息' - when 'apply' - '用户申请' - when 'system_messages' - '系统消息' - when 'homework' - '作业消息' - when 'course_message' - '课程讨论' - when 'course_news' - '课程通知' - when 'poll' - '课程问卷' - when 'issue' - '项目任务' - when 'forge_message' - '项目讨论' - when 'forge_news' - '项目新闻' - when 'forum' - '贴吧帖子' - when 'user_feedback' - '用户留言' - end - end - - def link_to_user_version(version, options = {}) - return '' unless version && version.is_a?(Version) - link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, :class => "linkBlue" - end - - # 统计未读消息数 - def unviewed_message(user) - course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count - forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count - org_count = OrgMessage.where("user_id =? and viewed =?", user, 0).count - user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count - user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count - at_count = user.at_messages.where(viewed: false).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count - end - - def user_mail_notification_options(user) - user.valid_notification_options.collect {|o| [l(o.last), o.first]} - end - - def change_status_link(user) - url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil} - - if user.locked? - link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' - elsif user.registered? - link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' - elsif user != User.current - link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock' - end - end - - def user_settings_tabs - tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general}, - {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural} - ] - if Group.all.any? - tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural} - end - tabs - end - - # this method is used to get all projects that tagged one tag - # added by william - def get_users_by_tag(tag_name) - User.tagged_with(tag_name).order('updated_on desc') - end - - # added by fq - # - - # TODO: 待删 - # def show_activity(state) - # content = ''.html_safe - # case state - # when 0 - # s = content_tag('span', l(:label_user_all_activity), :class => "current-page") - # content << content_tag('li', s) - # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1})) - # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2})) - # when 1 - # s = content_tag('span', l(:label_user_activity_myself), :class => "current-page") - # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'})) - # content << content_tag('li', s, :class => "current-page") - # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2})) - # when 2 - # s = content_tag('span', l(:label_user_all_respond), :class => "current-page") - # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'})) - # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1})) - # content << content_tag('li', s, :class => "current-page") - # end - # content_tag('div', content, :class => "pagination") - # end - - #TODO: 待删 - def watch_projects(state) - content = ''.html_safe - case state - when 0 - s = content_tag('span', l(:label_project_take), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) - when 1 - s = content_tag('span', l(:label_has_watched_project), :class => "current-page") - content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) - content << content_tag('li', s, :class => "current-page") - end - content_tag('div', content, :class => "pagination") - end - - def user_course(state) - content = ''.html_safe - if @user != User.current - if @user.user_extensions.identity == 0 - case state - when 0 - s = content_tag('span', '他执教的课程', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '他发布的作业', :class => "current-page") - content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") - end - else - case state - when 0 - s = content_tag('span', '他的课程', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '他的作业', :class => "current-page") - content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") - end - end - else - if @user.user_extensions.identity == 0 - case state - when 0 - s = content_tag('span', l(:label_teaching_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', l(:label_release_homework), :class => "current-page") - content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") - end - else - case state - when 0 - s = content_tag('span', l(:label_my_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '我的作业', :class => "current-page") - content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") - end - end - end - end - - # added by huang - def sort_user(state, project_type) - content = ''.html_safe - case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs") - end - - def sort_user_enterprise(state, project_type) - content = ''.html_safe - case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) - end - content = content_tag('ul', content) - content_tag('div', content, :class => "tabs_enterprise") - end - - def gender_avatar_uri user - img_uri = '/images/sidebar/female.png' - return img_uri if user.user_extensions.blank? - person_gender = user.user_extensions.gender - img_uri = (person_gender == 1) ? '/images/sidebar/female.png' : '/images/sidebar/male.png' - end - - include CoursesHelper - def is_watching?(user) - login_user = User.current# 登录者 - - courses = user.projects.where('project_type=1') - return true if ((login_user == user) or login_user.admin?) - courses.each do |course| - return true if login_user.member_of?(course) - end - ## 下面的代码只判断是否是老师或者助教,上面是成员都可以看到 - # people_ids = [] - # user.projects.where('project_type=1').each do |project| - # tmp = searchTeacherAndAssistant(project) - # people_ids += (members_to_user_ids(tmp)) unless tmp.nil? - # end - # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin? - - false - end - - # base user上面的navbar显示内容 - def show_item_on_navbar params - displayed_item = %w|index| - displayed_item.include?(params['action']) - end - # base user上面searchBar显示 - def show_search_bar params - displayed_flag = %w|index| - !displayed_flag.include?(params['action']) - end - - #获取指定用户的未过期的课程列表 - def user_courses_list user - result = [] - user.coursememberships.map(&:course).each do |course| - if !course_endTime_timeout?(course) - result << course - end - end - return result - end - - #获取用户参与的公开的课程列表 - def user_public_course_list user - membership = user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current)) - membership.sort! {|older, newer| newer.created_on <=> older.created_on } - memberships = [] - membership.collect { |e| - memberships.push(e) - } - ## 判断课程是否过期 [需封装] - memberships_doing = [] - memberships_done = [] - memberships.map { |e| - if course_endTime_timeout?(e.course) - memberships_done.push e - else - memberships_doing.push e - end - } - end - - #获取用户留言相关的连接 - def user_jour_feed_back_url active - if active.act_type == "JournalsForMessage" - jour = JournalsForMessage.find active.act_id - if jour - case jour.jour_type - when "Principal" - link_to(l(:label_goto), user_newfeedback_user_path(jour.jour_id)) - when "Project" - link_to(l(:label_goto), project_feedback_path(jour.jour_id)) - when "Bid" - link_to(l(:label_goto), course_for_bid_path(jour.jour_id)) - when "Course" - link_to(l(:label_goto), course_feedback_path(jour.jour_id)) - when "Contest" - link_to(l(:label_goto), show_contest_contest_path(jour.jour_id)) - when "Softapplication" - link_to(l(:label_goto), softapplication_path(jour.jour_id)) - when "HomeworkAttach" - link_to(l(:label_goto), course_for_bid_path(jour.jour_id)) - end - end - end - end - - def get_watcher_users(obj) - count = User.watched_by(obj.id).count - if count == 0 - return [0,[]] - end - list = User.watched_by(obj.id).order("#{Watcher.table_name}.id desc").limit(10).all - return [count,list]; - end - - def get_fans_users(obj) - count = obj.watcher_users.count - if count == 0 - return [0,[]] - end - list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all - return [count,list]; - end - - def get_visitor_users(obj) - query = Visitor.where("master_id=?",obj.id) - count = query.count - if count == 0 - return [0,[]] - end - list = query.order("updated_on desc").limit(10).all - return [count,list] - end - - def get_create_course_count(user) - user.courses.visible.where("tea_id = ?",user.id).count - end - - #获取加入课程数 - def get_join_course_count(user) - user.courses.visible.count - get_create_course_count(user) - end - - #发布作业数 - def get_homework_commons_count(user) - HomeworkCommon.where("user_id = ?",user.id).count - end - - #资源数 - def get_projectandcourse_attachment_count(user) - Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count - end - - #创建项目数 - def get_create_project_count(user) - user.projects.visible.where("projects.user_id=#{user.id}").count - end - - #加入项目数 - def get_join_project_count(user) - user.projects.visible.count - get_create_project_count(user) - end - - #创建缺陷数 - def get_create_issue_count(user) - Issue.where("author_id = ?",user.id).count - end - - #解决缺陷数 - def get_resolve_issue_count(user) - Issue.where("assigned_to_id = ? and status_id=3",user.id).count - end - - #参与匿评数 - def get_anonymous_evaluation_count(user) - StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count - end - - def query_activities(query) - list = query.limit(13).all - result = [] - for item in list - container = get_activity_container(item) - result << { :item=>item,:e=>container } - end - result - end - - def get_activity_container activity - return activity.activity_container - end - - def get_activity_act_showname_htmlclear(activity) - str = get_activity_act_showname(activity) - str = str.gsub(/<.*>/,'') - str = str.gsub(/\r/,'') - str = str.gsub(/\n/,'') - str = str.lstrip.rstrip - if str == '' - str = 'RE:' - end - return str.html_safe - end - - # journal.details 记录每个动作的新旧值 - def get_issue_des_update(journal) - no_html = "message" - arr = details_to_strings(journal.details, no_html) - unless journal.notes.blank? - arr << journal.notes - end - str = '' - arr.each { |item| str = str+item } - return str - end - - def get_activity_act_showname(activity) - case activity.act_type - when "HomeworkCommon" - return activity.act.name - when "Issue" - return activity.act.subject - when "Journal" - arr = details_to_strings(activity.act.details,true) - arr << activity.act.notes - str = '' - arr.each { |item| str = str+item } - return str - when "JournalsForMessage" - return activity.act.notes - when "Message" - return activity.act.subject - when "News" - return activity.act.title - when "Poll" - return activity.act.polls_name - when "Contest" - return '' - when "Contestnotification" - return '' - when "Principal" - return '' - else - return activity.act_type - end - end - - def get_activity_act_createtime(activity) - case activity.act_type - when "HomeworkCommon" - return activity.act.created_at - when "Poll" - return activity.act.created_at - else - return activity.act.created_on - end - end - - def get_activity_container_url e - if !e.visible? - return "javascript:;" - end - - if e.class.to_s == 'Course' - return url_for(:controller => 'courses', :action=>"show", :id=>e.id, :host=>Setting.host_course) - end - return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name) - end - - def get_activity_url(activity,e) - if !e.visible? - return "javascript:;" - end - - case activity.act_type - # when "Contest" - # when "Contestnotification" - # when "Principal" - when "HomeworkCommon" - return homework_common_index_path( :course=>e.id ) - when "Issue" - return issue_path(activity.act.id) - when "Journal" - return issue_path( activity.act.journalized_id ) - when "JournalsForMessage" - return e.class.to_s == 'Course' ? course_feedback_path(e) : project_feedback_path(e) - when "Message" - return e.class.to_s == 'Course' ? course_boards_path(e) : project_boards_path(e) - when "News" - return news_path(activity.act) - #return e.class.to_s == 'Course' ? course_news_index_path(e) : project_news_index_path(e) - when "Poll" - return poll_index_path( :polls_group_id=>activity.act.polls_group_id, :polls_type=>e.class.to_s ) - else - return 'javascript:;' - end - end - - def get_activity_opt(activity,e) - case activity.act_type - when "HomeworkCommon" - return '创建了作业' - when "News" - return e.class.to_s == 'Course' ? '发布了通知' : '添加了新闻' - when "Issue" - return '发表了问题' - when "Journal" - return '更新了问题' - when "JournalsForMessage" - return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈' - #return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : '' - when "Message" - return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子' - when "Poll" - return '创建了问卷' - else - return '有了新动态' - end - end - - #获取指定用户作为老师的课程 - def get_as_teacher_courses user - type = [] - option = [] - option << "请选择发布作业的课程" - option << -1 - type << option - user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| - option = [] - option << course.name+"("+course.time.to_s+course.term+")" - option << course.id - type << option - end - type - end - -end +# encoding: utf-8 +# +# Redmine - project management software +# Copyright (C) 2006-2013 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + + +include AvatarHelper +module UsersHelper + def users_status_options_for_select(selected) + user_count_by_status = User.count(:group => 'status').to_hash + options_for_select([[l(:label_all), ''], + ["#{l(:status_active)} (#{user_count_by_status[1].to_i})", '1'], + ["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", '2'], + ["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s) + end + + def get_resource_type type + case type + when 'Course' + '课程资源' + when 'Project' + '项目资源' + when 'Issue' + '缺陷附件' + when 'Message' + '讨论区附件' + when 'Document' + '文档附件' + when 'News' + '通知附件' + when 'HomewCommon' + '作业附件' + when 'StudentWorkScore' + '批改附件' + when 'Principal' + '用户资源' + when 'OrgSubfield' + '组织资源' + end + end + + def get_resource_origin attach + type = attach.container_type + content = attach.container + unless content.nil? + case type + when 'Course' + result = current_time_and_term_resource content + when 'Project' + result = content.name + when 'Issue' + result = content.subject + when 'Message' + result = content.subject + when 'News' + result = content.title + when 'HomewCommon' + result = content.name + when 'StudentWorkScore' + result = content.name + when 'Principal' + result = content.name + when 'OrgSubfield' + result = content.name + end + end + end + + def current_time_and_term_resource course + str = "" + term = cur_course_term_resource + name = course.name + if (course.time == course.end_time && course.term == course.end_term) || (course.end_term.nil? && course.end_time.nil?) || course.time > Time.now.year + str = name + "(" + course.time.to_s + course.term.to_s + ")" + elsif course.time == Time.now.year && set_term_value(cur_course_term) <= set_term_value(course.term) + str = name + "(" + course.time.to_s + course.term.to_s + ")" + elsif course.end_time < Time.now.year || (course.end_time == Time.now.year && set_term_value(cur_course_term) >= set_term_value(course.term)) + str = name + "(" + course.end_time.to_s + course.end_term.to_s + ")" + else + str = name + "(" + Time.now.year.to_s + cur_course_term_resource.to_s + ")" + end + str + end + + def cur_course_term_resource + month = Time.now.month + if month >= 9 || month < 2 + term = "秋" + elsif (month >= 7 && Time.now.day >= 15) || month == 8 + term = "夏" + else + term = "春" + end + term + end + + def title_for_message type + case type + when nil + '消息' + when 'unviewed' + '未读消息' + when 'apply' + '用户申请' + when 'system_messages' + '系统消息' + when 'homework' + '作业消息' + when 'course_message' + '课程讨论' + when 'course_news' + '课程通知' + when 'poll' + '课程问卷' + when 'issue' + '项目任务' + when 'forge_message' + '项目讨论' + when 'forge_news' + '项目新闻' + when 'forum' + '贴吧帖子' + when 'user_feedback' + '用户留言' + end + end + + def link_to_user_version(version, options = {}) + return '' unless version && version.is_a?(Version) + link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, :class => "linkBlue" + end + + # 统计未读消息数 + def unviewed_message(user) + course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count + forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count + org_count = OrgMessage.where("user_id =? and viewed =?", user, 0).count + user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count + user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count + at_count = user.at_messages.where(viewed: false).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count + end + + def user_mail_notification_options(user) + user.valid_notification_options.collect {|o| [l(o.last), o.first]} + end + + def change_status_link(user) + url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil} + + if user.locked? + link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' + elsif user.registered? + link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock' + elsif user != User.current + link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock' + end + end + + def user_settings_tabs + tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general}, + {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural} + ] + if Group.all.any? + tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural} + end + tabs + end + + # this method is used to get all projects that tagged one tag + # added by william + def get_users_by_tag(tag_name) + User.tagged_with(tag_name).order('updated_on desc') + end + + # added by fq + # + + # TODO: 待删 + # def show_activity(state) + # content = ''.html_safe + # case state + # when 0 + # s = content_tag('span', l(:label_user_all_activity), :class => "current-page") + # content << content_tag('li', s) + # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1})) + # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2})) + # when 1 + # s = content_tag('span', l(:label_user_activity_myself), :class => "current-page") + # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'})) + # content << content_tag('li', s, :class => "current-page") + # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2})) + # when 2 + # s = content_tag('span', l(:label_user_all_respond), :class => "current-page") + # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'})) + # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1})) + # content << content_tag('li', s, :class => "current-page") + # end + # content_tag('div', content, :class => "pagination") + # end + + #TODO: 待删 + def watch_projects(state) + content = ''.html_safe + case state + when 0 + s = content_tag('span', l(:label_project_take), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) + when 1 + s = content_tag('span', l(:label_has_watched_project), :class => "current-page") + content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) + content << content_tag('li', s, :class => "current-page") + end + content_tag('div', content, :class => "pagination") + end + + def user_course(state) + content = ''.html_safe + if @user != User.current + if @user.user_extensions.identity == 0 + case state + when 0 + s = content_tag('span', '他执教的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '他发布的作业', :class => "current-page") + content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") + end + else + case state + when 0 + s = content_tag('span', '他的课程', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '他的作业', :class => "current-page") + content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") + end + end + else + if @user.user_extensions.identity == 0 + case state + when 0 + s = content_tag('span', l(:label_teaching_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', l(:label_release_homework), :class => "current-page") + content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") + end + else + case state + when 0 + s = content_tag('span', l(:label_my_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '我的作业', :class => "current-page") + content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") + end + end + end + end + + # added by huang + def sort_user(state, project_type) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + + def sort_user_enterprise(state, project_type) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs_enterprise") + end + + def gender_avatar_uri user + img_uri = '/images/sidebar/female.png' + return img_uri if user.user_extensions.blank? + person_gender = user.user_extensions.gender + img_uri = (person_gender == 1) ? '/images/sidebar/female.png' : '/images/sidebar/male.png' + end + + include CoursesHelper + def is_watching?(user) + login_user = User.current# 登录者 + + courses = user.projects.where('project_type=1') + return true if ((login_user == user) or login_user.admin?) + courses.each do |course| + return true if login_user.member_of?(course) + end + ## 下面的代码只判断是否是老师或者助教,上面是成员都可以看到 + # people_ids = [] + # user.projects.where('project_type=1').each do |project| + # tmp = searchTeacherAndAssistant(project) + # people_ids += (members_to_user_ids(tmp)) unless tmp.nil? + # end + # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin? + + false + end + + # base user上面的navbar显示内容 + def show_item_on_navbar params + displayed_item = %w|index| + displayed_item.include?(params['action']) + end + # base user上面searchBar显示 + def show_search_bar params + displayed_flag = %w|index| + !displayed_flag.include?(params['action']) + end + + #获取指定用户的未过期的课程列表 + def user_courses_list user + result = [] + user.coursememberships.map(&:course).each do |course| + if !course_endTime_timeout?(course) + result << course + end + end + return result + end + + #获取用户参与的公开的课程列表 + def user_public_course_list user + membership = user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current)) + membership.sort! {|older, newer| newer.created_on <=> older.created_on } + memberships = [] + membership.collect { |e| + memberships.push(e) + } + ## 判断课程是否过期 [需封装] + memberships_doing = [] + memberships_done = [] + memberships.map { |e| + if course_endTime_timeout?(e.course) + memberships_done.push e + else + memberships_doing.push e + end + } + end + + #获取用户留言相关的连接 + def user_jour_feed_back_url active + if active.act_type == "JournalsForMessage" + jour = JournalsForMessage.find active.act_id + if jour + case jour.jour_type + when "Principal" + link_to(l(:label_goto), user_newfeedback_user_path(jour.jour_id)) + when "Project" + link_to(l(:label_goto), project_feedback_path(jour.jour_id)) + when "Bid" + link_to(l(:label_goto), course_for_bid_path(jour.jour_id)) + when "Course" + link_to(l(:label_goto), course_feedback_path(jour.jour_id)) + when "Contest" + link_to(l(:label_goto), show_contest_contest_path(jour.jour_id)) + when "Softapplication" + link_to(l(:label_goto), softapplication_path(jour.jour_id)) + when "HomeworkAttach" + link_to(l(:label_goto), course_for_bid_path(jour.jour_id)) + end + end + end + end + + def get_watcher_users(obj) + count = User.watched_by(obj.id).count + if count == 0 + return [0,[]] + end + list = User.watched_by(obj.id).order("#{Watcher.table_name}.id desc").limit(10).all + return [count,list]; + end + + def get_fans_users(obj) + count = obj.watcher_users.count + if count == 0 + return [0,[]] + end + list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all + return [count,list]; + end + + def get_visitor_users(obj) + query = Visitor.where("master_id=?",obj.id) + count = query.count + if count == 0 + return [0,[]] + end + list = query.order("updated_on desc").limit(10).all + return [count,list] + end + + def get_create_course_count(user) + user.courses.visible.where("tea_id = ?",user.id).count + end + + #获取加入课程数 + def get_join_course_count(user) + user.courses.visible.count - get_create_course_count(user) + end + + #发布作业数 + def get_homework_commons_count(user) + HomeworkCommon.where("user_id = ?",user.id).count + end + + #资源数 + def get_projectandcourse_attachment_count(user) + Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count + end + + #创建项目数 + def get_create_project_count(user) + user.projects.visible.where("projects.user_id=#{user.id}").count + end + + #加入项目数 + def get_join_project_count(user) + user.projects.visible.count - get_create_project_count(user) + end + + #创建缺陷数 + def get_create_issue_count(user) + Issue.where("author_id = ?",user.id).count + end + + #解决缺陷数 + def get_resolve_issue_count(user) + Issue.where("assigned_to_id = ? and status_id=3",user.id).count + end + + #参与匿评数 + def get_anonymous_evaluation_count(user) + StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count + end + + def query_activities(query) + list = query.limit(13).all + result = [] + for item in list + container = get_activity_container(item) + result << { :item=>item,:e=>container } + end + result + end + + def get_activity_container activity + return activity.activity_container + end + + def get_activity_act_showname_htmlclear(activity) + str = get_activity_act_showname(activity) + str = str.gsub(/<.*>/,'') + str = str.gsub(/\r/,'') + str = str.gsub(/\n/,'') + str = str.lstrip.rstrip + if str == '' + str = 'RE:' + end + return str.html_safe + end + + # journal.details 记录每个动作的新旧值 + def get_issue_des_update(journal) + no_html = "message" + arr = details_to_strings(journal.details, no_html) + unless journal.notes.blank? + arr << journal.notes + end + str = '' + arr.each { |item| str = str+item } + return str + end + + def get_activity_act_showname(activity) + case activity.act_type + when "HomeworkCommon" + return activity.act.name + when "Issue" + return activity.act.subject + when "Journal" + arr = details_to_strings(activity.act.details,true) + arr << activity.act.notes + str = '' + arr.each { |item| str = str+item } + return str + when "JournalsForMessage" + return activity.act.notes + when "Message" + return activity.act.subject + when "News" + return activity.act.title + when "Poll" + return activity.act.polls_name + when "Contest" + return '' + when "Contestnotification" + return '' + when "Principal" + return '' + else + return activity.act_type + end + end + + def get_activity_act_createtime(activity) + case activity.act_type + when "HomeworkCommon" + return activity.act.created_at + when "Poll" + return activity.act.created_at + else + return activity.act.created_on + end + end + + def get_activity_container_url e + if !e.visible? + return "javascript:;" + end + + if e.class.to_s == 'Course' + return url_for(:controller => 'courses', :action=>"show", :id=>e.id, :host=>Setting.host_course) + end + return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name) + end + + def get_activity_url(activity,e) + if !e.visible? + return "javascript:;" + end + + case activity.act_type + # when "Contest" + # when "Contestnotification" + # when "Principal" + when "HomeworkCommon" + return homework_common_index_path( :course=>e.id ) + when "Issue" + return issue_path(activity.act.id) + when "Journal" + return issue_path( activity.act.journalized_id ) + when "JournalsForMessage" + return e.class.to_s == 'Course' ? course_feedback_path(e) : project_feedback_path(e) + when "Message" + return e.class.to_s == 'Course' ? course_boards_path(e) : project_boards_path(e) + when "News" + return news_path(activity.act) + #return e.class.to_s == 'Course' ? course_news_index_path(e) : project_news_index_path(e) + when "Poll" + return poll_index_path( :polls_group_id=>activity.act.polls_group_id, :polls_type=>e.class.to_s ) + else + return 'javascript:;' + end + end + + def get_activity_opt(activity,e) + case activity.act_type + when "HomeworkCommon" + return '创建了作业' + when "News" + return e.class.to_s == 'Course' ? '发布了通知' : '添加了新闻' + when "Issue" + return '发表了问题' + when "Journal" + return '更新了问题' + when "JournalsForMessage" + return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈' + #return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : '' + when "Message" + return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子' + when "Poll" + return '创建了问卷' + else + return '有了新动态' + end + end + + #获取指定用户作为老师的课程 + def get_as_teacher_courses user + type = [] + option = [] + option << "请选择发布作业的课程" + option << -1 + type << option + user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| + option = [] + option << course.name+"("+course.time.to_s+course.term+")" + option << course.id + type << option + end + type + end + + #根据姓名搜索用户 + def search_user_by_name user_ids, name + result_ids = [] + user_ids.each do |user_id| + user = User.find user_id + username = user.lastname.to_s.downcase + user.firstname.to_s.downcase + if username.include?(name) + result_ids << user_id + end + end + result_ids + end +end diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb index 3f6ee36f0..d12e85856 100644 --- a/app/views/admin/projects.html.erb +++ b/app/views/admin/projects.html.erb @@ -45,8 +45,8 @@ - <% project_tree(@projects) do |project, level| %> - <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>"> + <% @projects.each do |project| %> + "> <%= project.id %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index de3b038e6..16b4fcd3d 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -22,7 +22,7 @@
- 课程讨论区 + 课程问答区
<% if User.current.logged? %> diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb index 3ded0cb1d..aedeec5ef 100644 --- a/app/views/courses/_tool_expand.html.erb +++ b/app/views/courses/_tool_expand.html.erb @@ -24,7 +24,7 @@ <% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %> <% end %> <% if show_nav?(course_feedback_count) %> diff --git a/app/views/files/_import_files.html.erb b/app/views/files/_import_files.html.erb index 168cea962..36fa96a0b 100644 --- a/app/views/files/_import_files.html.erb +++ b/app/views/files/_import_files.html.erb @@ -1,138 +1,138 @@ -<%#= render :partial => 'users/user_resource_info' %> -
选用资源库中的资源
-
公共资源 我的资源 - -
-
-
    - -
  • 类别
  • -
  • 大小
  • -
  • 上传者
  • -
  • 上传时间
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 项目资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 附件
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
    - -
  • 课程资源
  • -
  • 123.0KB
  • -
  • 尹刚
  • -
  • 2016-01-21
  • -
-
- - -
- - - - - - - -
-
-
-
+<%#= render :partial => 'users/user_resource_info' %> +
选用资源库中的资源
+
公共资源 我的资源 + +
+
+
    + +
  • 类别
  • +
  • 大小
  • +
  • 上传者
  • +
  • 上传时间
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 项目资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 附件
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
    + +
  • 课程资源
  • +
  • 123.0KB
  • +
  • 尹刚
  • +
  • 2016-01-21
  • +
+
+ + +
+ + + + + + + +
+
+
+
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index fa59fbed9..4940b60d6 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -7,7 +7,7 @@ <% homework_num = @course.homework_commons.where("publish_time <= '#{Date.today}'").count %> <% end %> - + @@ -104,7 +104,7 @@ <div class="subNav"> <%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %> <%= link_to "(#{@course.boards.first ? (@course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @course.boards.first.id, nil).count) : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %> - <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %> + <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") %> </div> <% end %> <% unless show_nav?(course_feedback_count) %> @@ -142,32 +142,55 @@ <div class="cl"></div> <% unless contributor_course_scor(@course.id).count == 0 %> <ul class="rankList"> - <h4>课程活跃度</h4> + <h4>课程活跃度<a style="float: right; color: #7f7f7f; font-size: 12px;" onmouseover ="message_titile_show2($(this),event)" onmouseout ="message_titile_hide2($(this))">积分规则</a></h4> + <div style="display: none" class="numIntro"> + <div style="padding-left: 35px; font-size: 14px;color: #3b3b3b">积分规则</div> + 资源得分:资源数 x 5 </br> + 发帖得分:发帖数 x 2 </br> + 回帖得分:回复数 x 1 </br> + 课程留言得分:留言数 x 1 </br> + 作业留言得分:留言数 x 1 </br> + 通知得分:通知数 x 1 </br> + 总得分为以上得分之和 + </div> + <% contributor_course_scor(@course.id).each do |contributor_score| %> <% unless contributor_score.total_score ==0 %> <li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %></a> <p><a href="javascript:void:(0);"><%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %></a></p> <p><span class="c_green" style="cursor:pointer"> - <a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"><%= contributor_score.total_score.to_i %></a></span></p> + <a onmouseover ="message_titile_show($(this),event)" onmouseout ="message_titile_hide($(this))" class="c_green"> + <%=total_score = contributor_score.resource_num.to_i * 5 + contributor_score.message_num.to_i * 2 + + contributor_score.message_reply_num.to_i * 1 + contributor_score.journal_num.to_i * 1 + + + contributor_score.homework_journal_num * 1 + contributor_score.news_reply_num.to_i * 1 %></a></span></p> <div style="display: none" class="numIntro"> - <% unless contributor_score.resource_num == 0 %> - 课程资源:<%= contributor_score.resource_num %><br /> - <% end %> - <% unless contributor_score.message_num == 0 %> - 课程讨论:<%= contributor_score.message_num %><br /> - <% end %> - <% unless contributor_score.message_reply_num == 0 %> - 评论回复:<%= contributor_score.message_reply_num %><br /> - <% end %> - <% unless contributor_score.journal_num == 0 %> - 课程留言:<%= contributor_score.journal_num %><br /> - <% end %> - <% unless contributor_score.homework_journal_num == 0 %> - 作业留言:<%= contributor_score.homework_journal_num %><br /> - <% end %> - <% unless contributor_score.news_reply_num == 0 %> - 课程通知:<%= contributor_score.news_reply_num %><br /> - <% end %> + <!--<div style="display: none" class="message_title_red system_message_style">--> + <!--<p><strong>评论对象:</strong><%#= ma.course_message.commented.title %></p>--> + <!--<%# unless ma.course_message.comments.nil? %>--> + <!--<div class="fl"><strong>评论内容:</strong></div>--> + <!--<div class="ml60"><%#= ma.course_message.comments.html_safe %></div>--> + <!--<%# end %>--> + <!--</div>--> + <div style="padding-left: 65px; font-size: 14px;color: #3b3b3b">积分计算</div> + <%# unless contributor_score.resource_num.to_i == 0 %> + 课程资源:资源数 x 5 = <%= contributor_score.resource_num.to_i %> x 5 = <%= contributor_score.resource_num.to_i * 5 %></br> + <%# end %> + <%# unless contributor_score.message_num.to_i == 0 %> + 课程讨论:发帖数 x 2 = <%= contributor_score.message_num.to_i %> x 2 = <%= contributor_score.message_num.to_i * 2 %></br> + <%# end %> + <%# unless contributor_score.message_reply_num.to_i == 0 %> + 评论回复:回复数 x 1 = <%= contributor_score.message_reply_num.to_i %> x 1 = <%= contributor_score.message_reply_num.to_i %></br> + <%# end %> + <%# unless contributor_score.journal_num.to_i == 0 %> + 课程留言:留言数 x 1 = <%= contributor_score.journal_num.to_i %> x 1 = <%= contributor_score.journal_num.to_i %></br> + <%# end %> + <%# unless contributor_score.homework_journal_num.to_i == 0 %> + 作业留言:留言数 x 1 = <%= contributor_score.homework_journal_num.to_i %> x 1 = <%= contributor_score.homework_journal_num.to_i %></br> + <%# end %> + <%# unless contributor_score.news_reply_num.to_i == 0 %> + 课程通知:通知数 x 1 = <%= contributor_score.news_reply_num.to_i %> x 1 = <%= contributor_score.news_reply_num.to_i %></br> + <%# end %> + 总得分:<%=total_score %> </div> </li> <% end %> @@ -179,12 +202,12 @@ <% hero_homework_scores = hero_homework_score(@course, "desc") %> <% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %> <ul class="rankList"> - <h4>课程英雄榜</h4> + <h4><span>课程英雄榜</span><a style="float: right; color: #7f7f7f; font-size: 12px;" title="英雄榜的得分是每个同学作业的得分总和">积分规则</a></h4> <% hero_homework_scores.each do |student_score| %> <% if student_score.score.to_i != 0 %> <li> <a href="javascript:void:(0);"><%=link_to image_tag(url_to_avatar(student_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(student_score.user) %></a> <p><a href="javascript:void:(0);"><%=link_to student_score.user.show_name, user_path(student_score.user), :title => student_score.user.show_name %></a></p> - <p><span class="c_red" style="cursor:pointer" title="作业总分:<%= format("%.1f",student_score.score<0 ? 0 : student_score.score) %>"><%= student_score.score<0 ? 0 : student_score.score.to_i %></span></p> + <p><span class="c_red" style="cursor:pointer" title="英雄榜的得分是每个同学作业的得分总和"><%= student_score.score<0 ? 0 : student_score.score.to_i %></span></p> </li> <% end %> <% end %> @@ -303,6 +326,16 @@ obj.parent().parent().next("div").hide(); } + function message_titile_show2(obj,e) + { + obj.parent().next("div").show(); + obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","absolute"); + } + function message_titile_hide2(obj) + { + obj.parent().next("div").hide(); + } + $("#expand_tools_expand").click(function(){ $("#navContentCourse").toggle(); }); diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 33a1801a0..51cede682 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -128,7 +128,7 @@ <div class="cl"></div> <% if activity.student_works.count != 0 %> <% sw = activity.student_works.reorder("created_at desc").first %> - <div class="mt10 homepagePostDeadline"> + <div class="mt10 homepagePostDeadline mb10"> # <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 </div> <% end %> @@ -139,30 +139,36 @@ <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %> - <div class="mt10"> + <div> <p class="mb10 fontGrey2"># <%=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"%>评阅了作品,优秀排行: </p> - <% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> - <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> - <% student_works.each_with_index do |sw, i| %> - <div class="fl mr10 w100" style="text-align:center;"> - <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %> - <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p> - </a> - <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> - <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> - </div> - <% if i == 4 %> - <% break %> - <% end %> - <% end %> - <% if student_works.count > 5 %> - <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> - <% end %> - <div class="cl"></div> </div> <% end %> + <div> + <% if activity.homework_type != 2 %> + <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> + <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> + <% else %> + <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> + <% end %> + <% student_works.each_with_index do |sw, i| %> + <div class="fl mr10 w100" style="text-align:center;"> + <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %> + <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p> + </a> + <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> + <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> + </div> + <% if i == 4 %> + <% break %> + <% end %> + <% end %> + <% if student_works.count > 5 %> + <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% end %> + <div class="cl"></div> + </div> <% end %> <div class="cl"></div> <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %> @@ -239,7 +245,8 @@ <% end %> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> <li> - <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", + :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品",:remote => true)%> </li> <% end %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb index 4f13e1b4f..7eee53d02 100644 --- a/app/views/organizations/_org_course_message.html.erb +++ b/app/views/organizations/_org_course_message.html.erb @@ -1,159 +1,159 @@ -<div class="resources mt10" id="user_activity_<%= user_activity_id%>"> - <div class="homepagePostBrief"> - <div class="homepagePostPortrait"> - <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> - <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> - </div> - <div class="homepagePostDes"> - <div class="homepagePostTo break_word mt-4"> - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> - <% end %> - TO - <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> - </div> - <div class="homepagePostTitle hidden m_w530 fl"> - <% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> - <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%> - <% end %> - </div> - <% if activity.sticky == 1%> - <span class="sticky_btn_cir ml10">置顶</span> - <% end%> - <% if activity.locked%> - <span class="locked_btn_cir ml10 fl" title="已锁定">      </span> - <% end%> - <div class="cl"></div> - <div class="homepagePostDate fl"> - 发帖时间:<%= format_time(activity.created_on) %> - </div> - <div class="homepagePostDate fl ml15"> - 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %> - </div> - <div class="cl"></div> - <% 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} %> - - <div class="cl"></div> - <div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div> - <div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div> - <div class="cl"></div> - <div class="mt10" style="font-weight:normal;"> - <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> - </div> - <div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden"> - <ul> - <li class="homepagePostSettingIcon"> - <ul class="homepagePostSettiongText"> - <li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li> - <li><a href="javascript:void(0);" class="postOptionLink">复制</a></li> - <li><a href="javascript:void(0);" class="postOptionLink">删除</a></li> - </ul> - </li> - </ul> - </div> - </div> - <div class="cl"></div> - </div> - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> - <div class="homepagePostReply"> - <div class="homepagePostReplyBanner"> - <div class="homepagePostReplyBannerCount">回复 - <sapn class="mr15"><%= count>0 ? "(#{count})" : "" %></sapn><span style="color: #cecece;">▪</span> - <span id="praise_count_<%=user_activity_id %>"> - <% if activity.author == User.current %> - <span class="ml15 likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %></span></span> - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - <% end %> - </span> - </div> - <div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div> - <%if count > 3 %> - <div class="homepagePostReplyBannerMore"> - <a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" > - 展开更多 - </a> - </div> - <% end %> - </div> - - <% activity= activity.parent ? activity.parent : activity%> - <% replies_all_i = 0 %> - <% if count > 0 %> - <div class="" id="reply_div_<%= user_activity_id %>"> - <ul> - <% activity.children.reorder("created_on desc").each do |reply|%> - <script type="text/javascript"> - $(function(){ - showNormalImage('reply_content_<%= reply.id %>'); - }); - </script> - <% replies_all_i=replies_all_i+1 %> - <li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>3 ? 'none' : '' %>"> - <div class="homepagePostReplyPortrait"> - <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> - </div> - <div class="homepagePostReplyDes"> - <div class="homepagePostReplyPublisher mt-4"> - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> - <%= format_time(reply.created_on) %> - <span id="reply_praise_count_<%=reply.id %>"> - <% if reply.author == User.current %> - <span class="fr likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %></span></span> - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> - <% end %> - </span> - </div> - <div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= reply.id %>"> - <%= reply.content.html_safe %> - </div> - </div> - <div class="cl"></div> - </li> - <% end %> - </ul> - </div> - <% end %> - - <% if !activity.locked? && authorize_for_course('messages', 'reply') %> - <div class="homepagePostReplyContainer borderBottomNone minHeight48"> - <div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div> - <div class="homepagePostReplyInputContainer mb10"> - <div nhname='new_message_<%= user_activity_id%>' style="display:none;"> - <%= 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|%> - <input type="hidden" name="quote[quote]" value=""> - <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>"> - <div nhname='toolbar_container_<%= user_activity_id%>'></div> - <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea> - <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> - <div class="cl"></div> - <p nhname='contentmsg_<%= user_activity_id%>'></p> - <% end%> - <div class="cl"></div> - </div> - <div class="cl"></div> - </div> - <div class="cl"></div> - </div> - <% end %> - </div> -</div> +<div class="resources mt10" id="user_activity_<%= user_activity_id%>"> + <div class="homepagePostBrief"> + <div class="homepagePostPortrait"> + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> + </div> + <div class="homepagePostDes"> + <div class="homepagePostTo break_word mt-4"> + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> + </div> + <div class="homepagePostTitle hidden m_w530 fl"> + <% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> + <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%> + <% end %> + </div> + <% if activity.sticky == 1%> + <span class="sticky_btn_cir ml10">置顶</span> + <% end%> + <% if activity.locked%> + <span class="locked_btn_cir ml10 fl" title="已锁定">      </span> + <% end%> + <div class="cl"></div> + <div class="homepagePostDate fl"> + 发帖时间:<%= format_time(activity.created_on) %> + </div> + <div class="homepagePostDate fl ml15"> + 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %> + </div> + <div class="cl"></div> + <% 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} %> + + <div class="cl"></div> + <div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div> + <div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div> + <div class="cl"></div> + <div class="mt10" style="font-weight:normal;"> + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> + </div> + <div class="homepagePostSetting" id="act-<%= user_activity_id %>" style="visibility: hidden"> + <ul> + <li class="homepagePostSettingIcon"> + <ul class="homepagePostSettiongText"> + <li><a href="javascript:void(0);" class="postOptionLink">编辑</a></li> + <li><a href="javascript:void(0);" class="postOptionLink">复制</a></li> + <li><a href="javascript:void(0);" class="postOptionLink">删除</a></li> + </ul> + </li> + </ul> + </div> + </div> + <div class="cl"></div> + </div> + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> + <div class="homepagePostReply"> + <div class="homepagePostReplyBanner"> + <div class="homepagePostReplyBannerCount">回复 + <sapn class="mr15"><%= count>0 ? "(#{count})" : "" %></sapn><span style="color: #cecece;">▪</span> + <span id="praise_count_<%=user_activity_id %>"> + <% if activity.author == User.current %> + <span class="ml15 likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %></span></span> + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + </span> + </div> + <div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div> + <%if count > 3 %> + <div class="homepagePostReplyBannerMore"> + <a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" > + 展开更多 + </a> + </div> + <% end %> + </div> + + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> + <div class="" id="reply_div_<%= user_activity_id %>"> + <ul> + <% activity.children.reorder("created_on desc").each do |reply|%> + <script type="text/javascript"> + $(function(){ + showNormalImage('reply_content_<%= reply.id %>'); + }); + </script> + <% replies_all_i=replies_all_i+1 %> + <li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>3 ? 'none' : '' %>"> + <div class="homepagePostReplyPortrait"> + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> + </div> + <div class="homepagePostReplyDes"> + <div class="homepagePostReplyPublisher mt-4"> + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> + <span id="reply_praise_count_<%=reply.id %>"> + <% if reply.author == User.current %> + <span class="fr likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %></span></span> + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> + </span> + </div> + <div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= reply.id %>"> + <%= reply.content.html_safe %> + </div> + </div> + <div class="cl"></div> + </li> + <% end %> + </ul> + </div> + <% end %> + + <% if !activity.locked? && authorize_for_course('messages', 'reply') %> + <div class="homepagePostReplyContainer borderBottomNone minHeight48"> + <div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div> + <div class="homepagePostReplyInputContainer mb10"> + <div nhname='new_message_<%= user_activity_id%>' style="display:none;"> + <%= 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|%> + <input type="hidden" name="quote[quote]" value=""> + <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>"> + <div nhname='toolbar_container_<%= user_activity_id%>'></div> + <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea> + <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> + <div class="cl"></div> + <p nhname='contentmsg_<%= user_activity_id%>'></p> + <% end%> + <div class="cl"></div> + </div> + <div class="cl"></div> + </div> + <div class="cl"></div> + </div> + <% end %> + </div> +</div> diff --git a/app/views/projects/member.html.erb b/app/views/projects/member.html.erb index 21ce71b47..eb2dcacbc 100644 --- a/app/views/projects/member.html.erb +++ b/app/views/projects/member.html.erb @@ -1,13 +1,13 @@ -<div class="project_r_h"> - <h2 class="project_h2 fl"><%= @subPage_title%></h2> - <% if is_project_manager?(User.current, @project) %> - <span class="fr f14 fontGrey2" style="height: 40px; line-height: 40px; margin-right: 15px;"> - <%=link_to "成员管理", :controller => 'projects', :action => 'settings', :id => @project.id, :tab => 'members' %> - </span> - <% end %> -</div> -<div class="member_content"> - <%= error_messages_for 'member' %> - <%= render :partial => @render_file, :locals => {:members => @members} %> -</div> - +<div class="project_r_h"> + <h2 class="project_h2 fl"><%= @subPage_title%></h2> + <% if is_project_manager?(User.current, @project) %> + <span class="fr f14 fontGrey2" style="height: 40px; line-height: 40px; margin-right: 15px;"> + <%=link_to "成员管理", :controller => 'projects', :action => 'settings', :id => @project.id, :tab => 'members' %> + </span> + <% end %> +</div> +<div class="member_content"> + <%= error_messages_for 'member' %> + <%= render :partial => @render_file, :locals => {:members => @members} %> +</div> + diff --git a/app/views/projects/settings.html.erb b/app/views/projects/settings.html.erb index 9eae5d65b..fc9beae35 100644 --- a/app/views/projects/settings.html.erb +++ b/app/views/projects/settings.html.erb @@ -1,126 +1,126 @@ -<script type="text/javascript"> - $(function(){ - <%if @select_tab %> - <% if @select_tab == "modules" %> - project_setting(2); - <% elsif @select_tab == "members" %> - project_setting(3); - <% elsif @select_tab == "versions" %> - project_setting(4); - $("#pro_st_edit_ban").toggle(); - <% elsif @select_tab == "repositories" %> - project_setting(6); - $("#pro_st_edit_ku").toggle(); - <% else %> - project_setting(5); - <% end%> - <% end%> - $("div[nhname='pro_setting']").show(); - }); -</script> - -<div class="project_r_h"> - <h2 class="project_h2">配置</h2> -</div> - -<!--通过admin界面配置,不同角色显示不同的模块--> -<div class=" pro_setting" nhname="pro_setting" style="display:none;"> - <div id="pro_st_tb_" class="pro_st_tb_"> - <ul> - <% show_memu = show_project_memu User.current%> - <% if User.current.allowed_to?(:edit_project, @project) %> - <li id="pro_st_tb_1" class="<%= show_memu == 'edit_project' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(1);">信息</li> - <% end %> - <% if User.current.allowed_to?(:select_project_modules, @project) %> - <li id="pro_st_tb_2" class="<%= show_memu == 'select_project_modules' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(2);">模块</li> - <% end %> - <% if User.current.allowed_to?(:manage_members, @project) %> - <li id="pro_st_tb_3" class="<%= show_memu == 'manage_members' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(3);">成员</li> - <% end %> - <li id="pro_st_tb_5" class="<%= show_memu == 'join_org' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(5);">组织</li> - <% if User.current.allowed_to?(:manage_versions, @project) %> - <li id="pro_st_tb_4" class="<%= show_memu == 'manage_versions' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(4);">版本</li> - <% end %> - <!--<li id="pro_st_tb_5" class="pro_st_normaltab" onclick="project_setting(5);">问题类别</li>--> - <% if User.current.allowed_to?(:manage_repository, @project) %> - <li id="pro_st_tb_6" class="<%= show_memu == 'manage_repository' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(6);">版本库</li> - <% end %> - <!--<li id="pro_st_tb_7" class="pro_st_normaltab" onclick="project_setting(7);">活动(时间跟踪)</li>--> - <!--<li id="pro_st_tb_8" class="pro_st_normaltab" onclick="project_setting(8);">代码评审</li>--> - - </ul> - </div><!--tb_ end--> - <div class="cl"></div> - - <div class="pro_st_ctt"> - <div class="<%= show_memu == 'edit_project' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_01"> - <%= render :partial=>"projects/settings/new_edit" if User.current.allowed_to?(:edit_project, @project)%> - </div><!--tbc_01 end--> - - <div class="<%= show_memu == 'select_project_modules' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_02"> - <%= render :partial=>"projects/settings/new_modules" if User.current.allowed_to?(:select_project_modules, @project)%> - </div><!--tbc_02 end--> - - <div class="<%= show_memu == 'manage_members' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_03"> - <%= render :partial=>"projects/settings/new_members" if User.current.allowed_to?(:manage_members, @project)%> - </div><!--tbc_03 end--> - - - <div class="<%= show_memu == 'manage_versions' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_04"> - <%= render :partial=>"projects/settings/new_versions" if User.current.allowed_to?(:manage_versions, @project)%> - </div><!--tbc_04 end--> - - <!--<div class="pro_st_undis" id="pro_st_tbc_05">--> - <!--<%#= render :partial=>"projects/settings/new_issue_categories" %>--> - <!--</div><!–tbc_05 end–>--> - <div class="<%= show_memu == 'join_org' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_05"> - <%= render :partial=>"projects/settings/join_org" %> - </div> - - <div class="<%= show_memu == 'manage_repository' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_06"> - <%= render :partial=>"projects/settings/new_repositories" if User.current.allowed_to?(:manage_repository, @project)%> - </div><!--tbc_06 end--> - - <!--<div class="pro_st_undis" id="pro_st_tbc_07">--> - <!--<%#= render :partial=>"projects/settings/new_activities" %>--> - <!--</div><!–tbc_07 end–>--> - - <!--代码评审先不做--> - <!--<div class="pro_st_undis" id="pro_st_tbc_08">--> - <!--<div class="box f14">--> - <!--<ul>--> - <!--<li><label for="setting_tracker_in_review_dialog">允许创建代码审查时选择跟踪者?<span class="required">  </span></label></li>--> - <!--<li><b>设置代码评审的默认跟踪标签:</b></li>--> - <!--<li><label for="setting_tracker_id">跟踪<span class="c_red"> *</span></label>--> - <!--<select id="setting_tracker_id" name="setting[tracker_id]">--> - <!--<option value="1" selected="selected">缺陷</option>--> - <!--<option value="2">功能</option>--> - <!--<option value="3">支持</option>--> - <!--<option value="4">任务</option>--> - <!--</select></li>--> - <!--<li>--> - <!--<label for="setting_hide_code_review_tab">隐藏代码评审页<span class="required">  </span></label>--> - <!--<input name="setting[hide_code_review_tab]" type="hidden" value="0"><input id="setting_hide_code_review_tab" name="setting[hide_code_review_tab]" type="checkbox" value="1">--> - <!--</li>--> - <!--<li>--> - <!--<label>若修订存在问题:</label>--> - <!--<input checked="checked" id="setting_auto_relation_1" name="setting[auto_relation]" type="radio" value="1">--> - <!--与之相关的评审问题--> - - <!--<input id="setting_auto_relation_2" name="setting[auto_relation]" type="radio" value="2">--> - <!--与之无关的评审问题--> - - <!--<input id="setting_auto_relation_0" name="setting[auto_relation]" type="radio" value="0">--> - <!--什么也不做--> - <!--</li>--> - <!--<li>--> - <!--<label>自动分派</label>--> - <!--<input id="auto_assign_enabled" name="auto_assign[enabled]" onchange="setAutoAssignSettingFormEnable();" type="checkbox" value="true">激活--> - <!--</li>--> - <!--</ul>--> - <!--<a href="javascript:viod(0)" class="blue_btn">保存</a>--> - <!--</div>--> - <!--</div><!–tbc_08 end–>--> - - </div><!--ctt end--> -</div><!--pro_setting end--> +<script type="text/javascript"> + $(function(){ + <%if @select_tab %> + <% if @select_tab == "modules" %> + project_setting(2); + <% elsif @select_tab == "members" %> + project_setting(3); + <% elsif @select_tab == "versions" %> + project_setting(4); + $("#pro_st_edit_ban").toggle(); + <% elsif @select_tab == "repositories" %> + project_setting(6); + $("#pro_st_edit_ku").toggle(); + <% else %> + project_setting(5); + <% end%> + <% end%> + $("div[nhname='pro_setting']").show(); + }); +</script> + +<div class="project_r_h"> + <h2 class="project_h2">配置</h2> +</div> + +<!--通过admin界面配置,不同角色显示不同的模块--> +<div class=" pro_setting" nhname="pro_setting" style="display:none;"> + <div id="pro_st_tb_" class="pro_st_tb_"> + <ul> + <% show_memu = show_project_memu User.current%> + <% if User.current.allowed_to?(:edit_project, @project) %> + <li id="pro_st_tb_1" class="<%= show_memu == 'edit_project' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(1);">信息</li> + <% end %> + <% if User.current.allowed_to?(:select_project_modules, @project) %> + <li id="pro_st_tb_2" class="<%= show_memu == 'select_project_modules' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(2);">模块</li> + <% end %> + <% if User.current.allowed_to?(:manage_members, @project) %> + <li id="pro_st_tb_3" class="<%= show_memu == 'manage_members' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(3);">成员</li> + <% end %> + <li id="pro_st_tb_5" class="<%= show_memu == 'join_org' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(5);">组织</li> + <% if User.current.allowed_to?(:manage_versions, @project) %> + <li id="pro_st_tb_4" class="<%= show_memu == 'manage_versions' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(4);">版本</li> + <% end %> + <!--<li id="pro_st_tb_5" class="pro_st_normaltab" onclick="project_setting(5);">问题类别</li>--> + <% if User.current.allowed_to?(:manage_repository, @project) %> + <li id="pro_st_tb_6" class="<%= show_memu == 'manage_repository' ? 'pro_st_hovertab' : 'pro_st_normaltab'%>" onclick="project_setting(6);">版本库</li> + <% end %> + <!--<li id="pro_st_tb_7" class="pro_st_normaltab" onclick="project_setting(7);">活动(时间跟踪)</li>--> + <!--<li id="pro_st_tb_8" class="pro_st_normaltab" onclick="project_setting(8);">代码评审</li>--> + + </ul> + </div><!--tb_ end--> + <div class="cl"></div> + + <div class="pro_st_ctt"> + <div class="<%= show_memu == 'edit_project' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_01"> + <%= render :partial=>"projects/settings/new_edit" if User.current.allowed_to?(:edit_project, @project)%> + </div><!--tbc_01 end--> + + <div class="<%= show_memu == 'select_project_modules' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_02"> + <%= render :partial=>"projects/settings/new_modules" if User.current.allowed_to?(:select_project_modules, @project)%> + </div><!--tbc_02 end--> + + <div class="<%= show_memu == 'manage_members' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_03"> + <%= render :partial=>"projects/settings/new_members" if User.current.allowed_to?(:manage_members, @project)%> + </div><!--tbc_03 end--> + + + <div class="<%= show_memu == 'manage_versions' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_04"> + <%= render :partial=>"projects/settings/new_versions" if User.current.allowed_to?(:manage_versions, @project)%> + </div><!--tbc_04 end--> + + <!--<div class="pro_st_undis" id="pro_st_tbc_05">--> + <!--<%#= render :partial=>"projects/settings/new_issue_categories" %>--> + <!--</div><!–tbc_05 end–>--> + <div class="<%= show_memu == 'join_org' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_05"> + <%= render :partial=>"projects/settings/join_org" %> + </div> + + <div class="<%= show_memu == 'manage_repository' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_06"> + <%= render :partial=>"projects/settings/new_repositories" if User.current.allowed_to?(:manage_repository, @project)%> + </div><!--tbc_06 end--> + + <!--<div class="pro_st_undis" id="pro_st_tbc_07">--> + <!--<%#= render :partial=>"projects/settings/new_activities" %>--> + <!--</div><!–tbc_07 end–>--> + + <!--代码评审先不做--> + <!--<div class="pro_st_undis" id="pro_st_tbc_08">--> + <!--<div class="box f14">--> + <!--<ul>--> + <!--<li><label for="setting_tracker_in_review_dialog">允许创建代码审查时选择跟踪者?<span class="required">  </span></label></li>--> + <!--<li><b>设置代码评审的默认跟踪标签:</b></li>--> + <!--<li><label for="setting_tracker_id">跟踪<span class="c_red"> *</span></label>--> + <!--<select id="setting_tracker_id" name="setting[tracker_id]">--> + <!--<option value="1" selected="selected">缺陷</option>--> + <!--<option value="2">功能</option>--> + <!--<option value="3">支持</option>--> + <!--<option value="4">任务</option>--> + <!--</select></li>--> + <!--<li>--> + <!--<label for="setting_hide_code_review_tab">隐藏代码评审页<span class="required">  </span></label>--> + <!--<input name="setting[hide_code_review_tab]" type="hidden" value="0"><input id="setting_hide_code_review_tab" name="setting[hide_code_review_tab]" type="checkbox" value="1">--> + <!--</li>--> + <!--<li>--> + <!--<label>若修订存在问题:</label>--> + <!--<input checked="checked" id="setting_auto_relation_1" name="setting[auto_relation]" type="radio" value="1">--> + <!--与之相关的评审问题--> + + <!--<input id="setting_auto_relation_2" name="setting[auto_relation]" type="radio" value="2">--> + <!--与之无关的评审问题--> + + <!--<input id="setting_auto_relation_0" name="setting[auto_relation]" type="radio" value="0">--> + <!--什么也不做--> + <!--</li>--> + <!--<li>--> + <!--<label>自动分派</label>--> + <!--<input id="auto_assign_enabled" name="auto_assign[enabled]" onchange="setAutoAssignSettingFormEnable();" type="checkbox" value="true">激活--> + <!--</li>--> + <!--</ul>--> + <!--<a href="javascript:viod(0)" class="blue_btn">保存</a>--> + <!--</div>--> + <!--</div><!–tbc_08 end–>--> + + </div><!--ctt end--> +</div><!--pro_setting end--> diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index f72faaac2..56636a48e 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -41,12 +41,12 @@ <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>str %> <% end %> <div> - <input type="text" name="student_work[name]" id="student_work_name" placeholder="请简洁的概括作品的功能或特性" class="InputBox W700" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>"> + <input type="text" name="student_work[name]" id="student_work_name" placeholder="请输入作品名称" class="InputBox W700" maxlength="200" onkeyup="regexStudentWorkName();" value="<%= @work.name%>"> <div class="cl"></div> <p id="student_work_name_span" class="c_red mb10"></p> </div> <div class="mt10"> - <textarea name="student_work[description]" id="student_work_description" placeholder="请介绍你的作品" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea> + <textarea name="student_work[description]" id="student_work_description" placeholder="请输入作品描述" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea> <script> var text = document.getElementById("student_work_description"); autoTextarea(text);// 调用 diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 99c317314..5d2b134a8 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -127,12 +127,12 @@ <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> <% end %> <div> - <%= 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 => "请输入作品名称", :onkeyup => "regexStudentWorkName();" %> <div class="cl"></div> <p id="student_work_name_span" class="c_red mb10"></p> </div> <div class="mt10"> - <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请介绍你的作品", :onkeyup => "regexStudentWorkDescription();"%> + <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%> <script> var text = document.getElementById("student_work_description"); autoTextarea(text);// 调用 diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 5e684ab15..7c5aa5e4f 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -128,7 +128,7 @@ <div class="cl"></div> <% if activity.student_works.count != 0 %> <% sw = activity.student_works.reorder("created_at desc").first %> - <div class="mt10 homepagePostDeadline"> + <div class="mt10 homepagePostDeadline mb10"> # <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 </div> <% end %> @@ -138,30 +138,36 @@ <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %> - <div class="mt10"> + <div> <p class="mb10 fontGrey2"># <%=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"%>评阅了作品,优秀排行: </p> - <% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> - <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> - <% student_works.each_with_index do |sw, i| %> - <div class="fl mr10 w100" style="text-align:center;"> - <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %> - <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p> - </a> - <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> - <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> - </div> - <% if i == 4 %> - <% break %> - <% end %> - <% end %> - <% if student_works.count > 5 %> - <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> - <% end %> - <div class="cl"></div> </div> <% end %> + <div> + <% if activity.homework_type != 2 %> + <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> + <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> + <% else %> + <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> + <% end %> + <% student_works.each_with_index do |sw, i| %> + <div class="fl mr10 w100" style="text-align:center;"> + <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %> + <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%></p> + </a> + <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> + <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> + </div> + <% if i == 4 %> + <% break %> + <% end %> + <% end %> + <% if student_works.count > 5 %> + <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% end %> + <div class="cl"></div> + </div> <% end %> <div class="cl"></div> <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %> @@ -238,7 +244,8 @@ <% end %> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> <li> - <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", + :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%> </li> <% end %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 7e8a24bb2..bb2a31dcc 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -1,194 +1,194 @@ -<div class="resources mt10" id="user_activity_<%= user_activity_id%>" onmouseover="$('#message_setting_<%= user_activity_id%>').show();" onmouseout="$('#message_setting_<%= user_activity_id%>').hide();"> - <div class="homepagePostBrief"> - <div class="homepagePostPortrait"> - <% 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 %> - </div> - <div class="homepagePostDes"> - <div class="homepagePostTo break_word mt-4"> - <% if activity.status == 1 %> - <span class="fontBlue2">确实团队</span> - <% 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 %> - <% end %> - TO - <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> - </div> - <div class="homepagePostTitle hidden m_w530 fl"> - <% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> - <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%> - <% end %> - </div> - <% if activity.sticky == 1%> - <span class="sticky_btn_cir ml10">置顶</span> - <% end%> - <% if activity.locked%> - <span class="locked_btn_cir ml10 fl" title="已锁定">      </span> - <% end%> - <div class="cl"></div> - <div class="homepagePostDate fl"> - 发帖时间:<%= format_time(activity.created_on) %> - </div> - <div class="homepagePostDate fl ml15"> - 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %> - </div> - <div class="cl"></div> - <% 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} %> - <% if activity.status == 1 %> - <span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.year %></span> - <span style="font-size:10.5000pt;">年</span> - <span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.month %></span> - <span style="font-size:10.5000pt;">月</span> - <span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.day %></span> - <span style="font-size:10.5000pt;">日</span> - <% end %> - <div class="cl"></div> - <div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div> - <div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div> - <div class="cl"></div> - <div class="mt10" style="font-weight:normal;"> - <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> - </div> - - <div class="homepagePostSetting" id="message_setting_<%= user_activity_id%>" style="display: none"> - <ul> - <li class="homepagePostSettingIcon"> - <ul class="homepagePostSettiongText"> - <% if activity.author.id == User.current.id%> - <li> - <%= link_to( - l(:button_edit), - edit_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board), - :class => 'postOptionLink' - ) if activity.course_editable_by?(User.current) %> - </li> - <li> - <%= link_to( - l(:button_delete), - delete_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board), - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'postOptionLink' - ) if activity.course_destroyable_by?(User.current) %> - </li> - <% end %> - <li><%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %></li> - </ul> - </li> - </ul> - </div> - - </div> - <div class="cl"></div> - </div> - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> - <div class="homepagePostReply"> - <div class="homepagePostReplyBanner"> - <div class="homepagePostReplyBannerCount">回复 - <sapn class="mr15"><%= count>0 ? "(#{count})" : "" %></sapn><span style="color: #cecece;">▪</span> - <span id="praise_count_<%=user_activity_id %>"> - <% if activity.author == User.current %> - <span class="ml15 likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %></span></span> - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - <% end %> - </span> - </div> - <div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div> - <%if count > 3 %> - <div class="homepagePostReplyBannerMore"> - <a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" > - 展开更多 - </a> - </div> - <% end %> - </div> - - <% activity= activity.parent ? activity.parent : activity%> - <% replies_all_i = 0 %> - <% if count > 0 %> - <div class="" id="reply_div_<%= user_activity_id %>"> - <ul> - <% activity.children.reorder("created_on desc").each do |reply|%> - <script type="text/javascript"> - $(function(){ - showNormalImage('reply_content_<%= reply.id %>'); - }); - </script> - <% replies_all_i=replies_all_i+1 %> - <li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>3 ? 'none' : '' %>"> - <div class="homepagePostReplyPortrait"> - <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> - </div> - <div class="homepagePostReplyDes"> - <div class="homepagePostReplyPublisher mt-4"> - <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> - <%= format_time(reply.created_on) %> - <span id="reply_praise_count_<%=reply.id %>"> - <% if reply.author == User.current %> - <span class="fr likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %></span></span> - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> - <% end %> - </span> - - </div> - <div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= reply.id %>"> - <%= reply.content.html_safe %> - </div> - </div> - <div class="cl"></div> - </li> - <% end %> - </ul> - </div> - <% end %> - - <% if !activity.locked? && authorize_for_course('messages', 'reply') %> - <div class="homepagePostReplyContainer borderBottomNone minHeight48"> - <div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div> - <div class="homepagePostReplyInputContainer mb10"> - <div nhname='new_message_<%= user_activity_id%>' style="display:none;"> - <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%> - <input type="hidden" name="quote[quote]" value=""> - <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>"> - <div nhname='toolbar_container_<%= user_activity_id%>'></div> - <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea> - <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> - <div class="cl"></div> - <p nhname='contentmsg_<%= user_activity_id%>'></p> - <% end%> - <div class="cl"></div> - </div> - <div class="cl"></div> - </div> - <div class="cl"></div> - </div> - <% end %> - </div> -</div> - +<div class="resources mt10" id="user_activity_<%= user_activity_id%>" onmouseover="$('#message_setting_<%= user_activity_id%>').show();" onmouseout="$('#message_setting_<%= user_activity_id%>').hide();"> + <div class="homepagePostBrief"> + <div class="homepagePostPortrait"> + <% 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 %> + </div> + <div class="homepagePostDes"> + <div class="homepagePostTo break_word mt-4"> + <% if activity.status == 1 %> + <span class="fontBlue2">确实团队</span> + <% 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 %> + <% end %> + TO + <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> + </div> + <div class="homepagePostTitle hidden m_w530 fl"> + <% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> + <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%> + <% end %> + </div> + <% if activity.sticky == 1%> + <span class="sticky_btn_cir ml10">置顶</span> + <% end%> + <% if activity.locked%> + <span class="locked_btn_cir ml10 fl" title="已锁定">      </span> + <% end%> + <div class="cl"></div> + <div class="homepagePostDate fl"> + 发帖时间:<%= format_time(activity.created_on) %> + </div> + <div class="homepagePostDate fl ml15"> + 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %> + </div> + <div class="cl"></div> + <% 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} %> + <% if activity.status == 1 %> + <span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.year %></span> + <span style="font-size:10.5000pt;">年</span> + <span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.month %></span> + <span style="font-size:10.5000pt;">月</span> + <span style="font-family:Calibri;font-size:10.5000pt;"><%= activity.created_on.day %></span> + <span style="font-size:10.5000pt;">日</span> + <% end %> + <div class="cl"></div> + <div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div> + <div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div> + <div class="cl"></div> + <div class="mt10" style="font-weight:normal;"> + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> + </div> + + <div class="homepagePostSetting" id="message_setting_<%= user_activity_id%>" style="display: none"> + <ul> + <li class="homepagePostSettingIcon"> + <ul class="homepagePostSettiongText"> + <% if activity.author.id == User.current.id%> + <li> + <%= link_to( + l(:button_edit), + edit_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board), + :class => 'postOptionLink' + ) if activity.course_editable_by?(User.current) %> + </li> + <li> + <%= link_to( + l(:button_delete), + delete_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board), + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'postOptionLink' + ) if activity.course_destroyable_by?(User.current) %> + </li> + <% end %> + <li><%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %></li> + </ul> + </li> + </ul> + </div> + + </div> + <div class="cl"></div> + </div> + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> + <div class="homepagePostReply"> + <div class="homepagePostReplyBanner"> + <div class="homepagePostReplyBannerCount">回复 + <sapn class="mr15"><%= count>0 ? "(#{count})" : "" %></sapn><span style="color: #cecece;">▪</span> + <span id="praise_count_<%=user_activity_id %>"> + <% if activity.author == User.current %> + <span class="ml15 likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %></span></span> + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + <% end %> + </span> + </div> + <div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div> + <%if count > 3 %> + <div class="homepagePostReplyBannerMore"> + <a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" > + 展开更多 + </a> + </div> + <% end %> + </div> + + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> + <div class="" id="reply_div_<%= user_activity_id %>"> + <ul> + <% activity.children.reorder("created_on desc").each do |reply|%> + <script type="text/javascript"> + $(function(){ + showNormalImage('reply_content_<%= reply.id %>'); + }); + </script> + <% replies_all_i=replies_all_i+1 %> + <li class="homepagePostReplyContainer" nhname="reply_rec" style="display:<%= replies_all_i>3 ? 'none' : '' %>"> + <div class="homepagePostReplyPortrait"> + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> + </div> + <div class="homepagePostReplyDes"> + <div class="homepagePostReplyPublisher mt-4"> + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> + <span id="reply_praise_count_<%=reply.id %>"> + <% if reply.author == User.current %> + <span class="fr likeButton" title="不能自己赞自己哦!"> <span class="likeText">赞</span><span class="likeNum"><%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %></span></span> + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%> + <% end %> + </span> + + </div> + <div class="homepagePostReplyContent break_word list_style upload_img table_maxWidth" id="reply_content_<%= reply.id %>"> + <%= reply.content.html_safe %> + </div> + </div> + <div class="cl"></div> + </li> + <% end %> + </ul> + </div> + <% end %> + + <% if !activity.locked? && authorize_for_course('messages', 'reply') %> + <div class="homepagePostReplyContainer borderBottomNone minHeight48"> + <div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %></div> + <div class="homepagePostReplyInputContainer mb10"> + <div nhname='new_message_<%= user_activity_id%>' style="display:none;"> + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%> + <input type="hidden" name="quote[quote]" value=""> + <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>"> + <div nhname='toolbar_container_<%= user_activity_id%>'></div> + <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea> + <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> + <div class="cl"></div> + <p nhname='contentmsg_<%= user_activity_id%>'></p> + <% end%> + <div class="cl"></div> + </div> + <div class="cl"></div> + </div> + <div class="cl"></div> + </div> + <% end %> + </div> +</div> + diff --git a/app/views/users/_homework_post_notice.html.erb b/app/views/users/_homework_post_notice.html.erb new file mode 100644 index 000000000..d67fa44ae --- /dev/null +++ b/app/views/users/_homework_post_notice.html.erb @@ -0,0 +1,12 @@ +<div id="popbox02"> + <div class="ni_con"> + <p style="display: block;font-size: 14px;margin-left: 30px;margin-top: 20px;"> + 题目已发送到目标课程的作业列表,但需要您设置发布和截止时间,以激活相应作业,谢谢! + </p> + <div class="ni_btn"> + <a href="javascript:void(0)" class="tijiao c_white ml45" onclick="hideModal();"> + 确  定 + </a> + </div> + </div> +</div> \ No newline at end of file diff --git a/app/views/users/_homework_repository_search.html.erb b/app/views/users/_homework_repository_search.html.erb new file mode 100644 index 000000000..dfbaacd05 --- /dev/null +++ b/app/views/users/_homework_repository_search.html.erb @@ -0,0 +1,29 @@ +<input type="text" name="search" placeholder="输入作业、老师姓名的关键词进行搜索" class="subject-pop-search fr" /> +<script type="text/javascript"> + var lastSearchCondition = ''; + var count = 0; + function search_hws(e){ + if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '') + { + return; + } + lastSearchCondition = $(e.target).val().trim(); + $.ajax({ + url: '<%= url_for(:controller => 'users', :action => 'user_search_homeworks') %>'+'?name='+ e.target.value+'&type=<%=type %>&is_import=<%=is_import %>&property=<%=property %>', + type:'get' + }); + } + + function throttle(method,context,e){ + clearTimeout(method.tId); + method.tId=setTimeout(function(){ + method.call(context,e); + },500); + } + + //查询项目 + $("input[name='search']").on('input', function (e) { + throttle(search_hws,window,e); + }); + +</script> \ No newline at end of file diff --git a/app/views/users/_homework_search_input.html.erb b/app/views/users/_homework_search_input.html.erb index d3dabccd4..31d7602d4 100644 --- a/app/views/users/_homework_search_input.html.erb +++ b/app/views/users/_homework_search_input.html.erb @@ -1,4 +1,4 @@ -<input type="text" name="search" placeholder="输入关键词进行搜索" class="subject-pop-search fr" /> +<input type="text" name="search" placeholder="输入作业、老师姓名的关键词进行搜索" class="subject-pop-search fr" /> <script type="text/javascript"> var lastSearchCondition = ''; var count = 0; diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb index f52fbe4df..9e42f9c96 100644 --- a/app/views/users/_resource_search_form.html.erb +++ b/app/views/users/_resource_search_form.html.erb @@ -1,7 +1,7 @@ -<%= form_tag( url_for(:controller => 'users', :action => 'resource_search', :id => user.id), - :remote => true , :method => 'get', :class => 'resourcesSearchloadBox mt10', :id => 'resource_search_form') do %> - <input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchResource" /> - <%= hidden_field_tag(:type,type.nil? ? 1 : type) %> - <%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none' %> - <!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>--> +<%= form_tag( url_for(:controller => 'users', :action => 'resource_search', :id => user.id), + :remote => true , :method => 'get', :class => 'resourcesSearchloadBox mt10', :id => 'resource_search_form') do %> + <input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchResource" /> + <%= hidden_field_tag(:type,type.nil? ? 1 : type) %> + <%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none' %> + <!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>--> <% end %> \ No newline at end of file diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 4e429a640..f679f9c8c 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -1,27 +1,374 @@ -<% if attachments.nil? || attachments.empty? %> - <!--<p class="nodata">--> - <!--<%#= l(:label_no_data) %>--> - <!--</p>--> -<% else %> - <% attachments.each do |attach| %> - <ul class="resource-list" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')"> - <li class="resource-list-checkbox fl"> - <input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" /> - <!--<input name="checkbox2" type="checkbox" value="" class="resourcesCheckbox" />--> - </li> - <li class="resource-list-name fl hidden"> - <%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack' %> - </li> - <li class="resource-list-time fr"><%= format_date(attach.created_on) %></li> - <li class="resource-list-quote fr"><%= attach.quotes.nil? ? 0 : attach.quotes %></li> - <li class="resource-list-download fr"><%= attach.downloads %></li> - <li style="display: none"><%= attach.author_id %></li> - <li class="resource-list-size fr"><%= number_to_human_size(attach.filesize) %></li> - <li class="resource-list-uploader fr hidden"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li> - <li class="resource-list-type fr"><%= get_resource_type(attach.container_type)%></li> - <li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li> - <li style="display: none"><%= attach.id %></li> - </ul> - <div class="cl"></div> - <% end %> -<% end %> +<% if attachments.nil? || attachments.empty? %> + <!--<p class="nodata">--> + <!--<%#= l(:label_no_data) %>--> + <!--</p>--> +<% else %> + <% attachments.each do |attach| %> + <ul class="resource-list" onmouseover="if($('#contextMenu').css('display') != 'block')$(this).children().css('background-color', '#e1e1e1')" onmouseout=" if($('#contextMenu').css('display') == 'none')$(this).children().css('background-color', 'white')"> + <li class="resource-list-checkbox fl"> + <input name="checkbox1[]" type="checkbox" data-has-history="<%= attach.attachment_histories.count == 0 ? 'N' : 'Y' %>" data-deleteble="<%= User.current.id ==attach.author_id ? 'Y' : 'N' %>" onclick="checkAllBox($(this));" value="<%= attach.id%>" class="resourcesCheckbox" /> + <!--<input name="checkbox2" type="checkbox" value="" class="resourcesCheckbox" />--> + </li> + <li class="resource-list-name fl hidden"> + <%= link_to truncate(attach.filename, :length => 30), download_named_attachment_path(attach.id, attach.filename), :title => attach.filename, :class => 'resourcesBlack' %> + </li> + <li class="resource-list-time fr"><%= format_date(attach.created_on) %></li> + <li class="resource-list-quote fr"><%= attach.quotes.nil? ? 0 : attach.quotes %></li> + <li class="resource-list-download fr"><%= attach.downloads %></li> + <li style="display: none"><%= attach.author_id %></li> + <li class="resource-list-size fr"><%= number_to_human_size(attach.filesize) %></li> + <li class="resource-list-uploader fr hidden"><%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %></li> + <li class="resource-list-type fr"><%= get_resource_type(attach.container_type)%></li> + <li class="resource-list-from fr hidden" title="<%= get_resource_origin(attach) %>"><%= get_resource_origin(attach) %></li> + <li style="display: none"><%= attach.id %></li> + </ul> + <div class="cl"></div> + <% end %> +<% end %> + +<script> + var pageX = 0; + var pageY = 0; + //当前选中的行 + var line; + //已经选中的行,和当前选中的行的区别是:右键选中为line,换一行右键后,line变为last_line,line变为换行后的line + var last_line; + //资源名称 + var res_name; + //资源名称的链接 + var res_link; + var id; //资源id + var sendType = '1'; //发送到课程 1 发送到项目 2 + var lastSendType; //保存上次发送的发送类型 + $("#resources_list").mousedown(function(e) { + //如果是右键的话 + if (3 == e.which) { + if( $("#res_name").length != 0 || $("#ajax-indicator").is(":hidden") == false){ //其他ajax在执行的时候阻止操作 + e.preventDefault(); + return ; + } + document.oncontextmenu = function() {return false;} + pageX = e.clientX; + pageY = e.clientY; + $("#contextMenu").hide(); + $("#contextMenu").attr("style","display: block; position: fixed; top:" + + pageY + + "px; left:" + + pageX + + "px; width: 80px;"); + $("#contextMenu").show(); + //当前光标所在的对象 + + var ele = document.elementFromPoint(pageX,pageY); + //转换为jquery对象 + line = $(ele).parent(); + //如果上一条存在被选中,那么将上一条的背景色改为白色 + if(last_line != null){ + last_line.children().css("background-color", 'white'); + restore(); + last_line == null; + } + //如果当前的tag是li,那么还要li的父级元素 + if(line.get(0).tagName === 'LI'){ + line = line.parent(); + } + //将当前的元素的所有子元素的背景色改为蓝色 + line.children().css("background-color", '#e1e1e1'); + //将当前元素赋给 上一个对象 保存起来。 + last_line = line; + } + }); + //元素包含关系计算 + var contains = function(root, el) { + if (root.compareDocumentPosition) + return root === el || !!(root.compareDocumentPosition(el) & 16); + if (root.contains && el.nodeType === 1){ + return root.contains(el) && root !== el; + } + while ((el = el.parentNode)) + if (el === root) return true; + return false; + } + $(document.body).click(function(e) { + //在列表上的任何单击事件都要恢复原来的样子 + //隐藏右键菜单 + //e.preventDefault(); + $("#contextMenu").hide(); + if( $("#ajax-indicator").is(":hidden") == false && $("#res_name").length != 0 ){ //其他ajax在执行的时候或者res_name仍然存在阻止操作 + return ; + } + document.oncontextmenu = function() {return true;} + //如果当前行为空,那么要将当前行的拿到 + var ele; + if(line == null){ + ele = document.elementFromPoint(e.clientX, e.clientY); + line = $(ele).parent(); + //如果是在li上点击事件,那么要获得父组件 + if(line.get(0).tagName === 'LI'){ + line = line.parent(); + } + + } + //如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了 + if( contains($("#resources_list").get(0),line.get(0))){ + line.children().css("background-color", 'white'); + } + + //当前行恢复编辑状态到链接状态 + if(ele && ele.nodeName != 'INPUT') { + restore(); + } + line = null; + }); + //只要有一个选中了就是true + function checkboxSelected(){ + selected = false; + $("#resources_list").find("input[name='checkbox1[]']").each(function(){ + if($(this).attr('checked') == true){ + selected = true; + } + }); + return selected; + } + //只有全选才是true + function checkboxAllSelected(){ + allSelected = true; + $("#resources_list").find("input[name='checkbox1[]']").each(function(){ + if($(this).attr('checked') == undefined){ + allSelected = false; + } + }); + return allSelected; + } + //只有全部不选才是true + function checkboxAllDeselected(){ + allDeselected = true; + $("#resources_list").find("input[name='checkbox1[]']").each(function(){ + if($(this).attr('checked') == 'checked'){ + allDeselected = false; + } + }); + return allDeselected; + } + //查看所有的checkbox状态,并且按情况更改$("#checkboxAll")的状态 + function checkAllBox(checkbox){ + //只有选中当前checkbox且这个时候所有的checkbox都被选中了,$("#checkboxAll")才是被选中状态,其余都是非选中状态 + if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){ + $("#checkboxAll").attr('checked',true); + }else{ + $("#checkboxAll").attr('checked',false); + } + $("#res_count").html(getCheckBoxSeletedCount()); + + } + //获取当前checkbox选中的数目 + function getCheckBoxSeletedCount(){ + var i = 0; + $("#resources_list").find("input[name='checkbox1[]']").each(function(){ + if($(this).attr('checked') == 'checked'){ + i ++; + } + }); + return i; + } + //全选反选 + function all_select(){ + + if($("#checkboxAll").attr('checked')){ + $("#resources_list").find("input[name='checkbox1[]']").each(function(){ + $(this).attr('checked',true); + }); + $("#res_count").html(getCheckBoxSeletedCount()); + }else{ + $("#resources_list").find("input[name='checkbox1[]']").each(function(){ + $(this).attr('checked',false); + }); + $("#res_count").html(0); + } + } + + function show_upload(){ + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'upload_resource' ,:locals => {:user=>User.current.id,:type=>@type,:status=>@status})%>'); + showModal('ajax-modal', '452px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 435px;' class='resourceClose'></a>"); + $('#ajax-modal').parent().css("top","50%").css("left","50%").css("position","absolute"); + $('#ajax-modal').parent().addClass("resourceUploadPopup"); + $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); + } + //批量删除 + function batch_delete(){ + var data = $("#resources_list_form").serialize(); + if($("input[type=checkbox][data-has-history=Y]:checked").length != 0){ + alert("您只能删除没有历史记录的资源,请重新选择后再删除。"); + return; + } + if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){ + alert("您只能删除自己上传的资源,请重新选择后再删除。"); + return; + } + + if(data != "" && confirm('确认要删除这些资源吗?')) { + $.post( + '<%= user_resource_delete_user_path(User.current.id,:type=>@type,:status=>@status)%>', + $("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交 + function (data) { + + } + ); + } + } + + + + function show_send_(){ + $("#contextMenu").hide(); + document.oncontextmenu = function() {return true;} + line.children().css("background-color",'white'); + id = line.children().last().html(); + if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 + $.ajax({ + type: 'get', + url: '<%= search_user_project_user_path(User.current.id)%>' + '?send_id=' + id, + data:{send_type:'file'} + }); + }else{ + $.ajax({ + type: 'get', + url: '<%= search_user_course_user_path(User.current.id)%>' + '?send_id=' + id, + data:{send_type:'file'} + }); + } + } + + function batch_send(){ + if($("#resources_list_form").serialize() == ""){ + alert('暂时不支持多页选择,您当前页没有选择任何资源'); + return ; + } + if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 + $.ajax({ + type: 'get', + url: '<%= search_user_project_user_path(User.current.id)%>' + '?' + $("#resources_list_form").serialize(), + data:{send_type:'file'} + }); + }else{ + $.ajax({ + type: 'get', + url: '<%= search_user_course_user_path(User.current.id)%>' + '?'+ $("#resources_list_form").serialize(), + data:{send_type:'file'} + }); + + } + } + + function preview(){ + $("#contextMenu").hide(); + document.oncontextmenu = function() {return true;} + line.children().css("background-color",'white'); + id = line.children().last().html(); + $.ajax({ + type:'get', + url:'<%= resource_preview_user_path(User.current.id)%>'+"?resource_id="+id + }); + } + + function rename(){ + $("#contextMenu").hide(); + document.oncontextmenu = function() {return true;} + line.children().css("background-color",'white'); + id = line.children().last().html(); + user_id = line.children().eq(5).html(); + if(user_id === '<%= User.current.id %>') { + res_name = line.children().eq(1).children().attr('title'); + res_link = line.children().eq(1).html(); + line.children().eq(1).html( + '<input name="res_name" id="res_name" ' + + 'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' + + ' onkeypress="if(event.keyCode==13){event.preventDefault();this.blur();}" ' + + 'value="'+res_name+ + '"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'); + $("#res_name").focus(); + $("html,body").animate({scrollTop:$("#res_name").offset().top},1000) + }else{ + alert('您无法修改此资源!') + } + } + String.prototype.trim = function() { + var str = this, + str = str.replace(/^\s\s*/, ''), + ws = /\s/, + i = str.length; + while (ws.test(str.charAt(--i))); + return str.slice(0, i + 1); + } + + + + //恢复编辑状态到链接状态 + //如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态 + //如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示 + function restore(){ + //上一行不为空 且链接不为空 + if( last_line != null && res_link != null && res_link != '') { + name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ; + if (name == undefined || name === 'undefined' ){ //只要res_name没有值,那么就不是编辑状态 + return; + } + if( name && name != res_name.trim()){ + + if(confirm('确定修改为 '+name)){ + $.ajax({ + url: '<%=rename_resource_user_path(User.current.id) %>'+ "?res_name="+$('#res_name').val() + "&res_id=" + $("#res_id").val(), + type:'get', + success:function (data) + { + if (data != 'fail' && name != undefined && name != 'undefined') {//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 + last_line.children().eq(1).html(res_link); + last_line.children().eq(1).children().attr('title', name); + last_line.children().eq(1).children().attr('href', data); + last_line.children().eq(1).children().html(name.length > 17 ? name.substring(0, 17) + '...' : name); + } else { + last_line.children().eq(1).html(res_link); + res_link = null; //如果修改失败,恢复之后将res_link置空 + } + } + } ); + }else{ + last_line.children().eq(1).html(res_link); + res_link = null; //如果没有做修改,恢复之后将res_link置空 + } + }else { + last_line.children().eq(1).html(res_link); + res_link = null;//如果没有做修改,恢复之后将res_link置空 + } + + + } + } + + function delete_file() { + $("#contextMenu").hide(); + document.oncontextmenu = function () { + return true; + } + line.children().css("background-color", 'white'); + id = line.children().last().html(); + user_id = line.children().eq(5).html(); + if(line.children().first().children().data('hasHistory') == 'Y'){ + alert('该资源存在历史版本,不能删除'); + return; + } + if(user_id === '<%= User.current.id%>') { + if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) { + $.ajax({ + type: 'post', + url: '<%= user_resource_delete_user_path(User.current.id)%>' + '?resource_id=' + id + '&type=<%=@type %>&status=<%=@status %>' + }); + } + }else{ + alert('您无法删除此资源!') + } + } + +</script> diff --git a/app/views/users/_show_user_homework_form.html.erb b/app/views/users/_show_user_homework_form.html.erb index fff44316b..be9a5bf13 100644 --- a/app/views/users/_show_user_homework_form.html.erb +++ b/app/views/users/_show_user_homework_form.html.erb @@ -6,7 +6,7 @@ <span title="<%= homework.name%>"><%= homework.name%></span> </label> </li> - <li class="subject-pop-from fl hidden">攻城狮</li> + <li class="subject-pop-from fl hidden"><span title="<%=homework.course.name %>(<%=current_time_and_term(homework.course) %>)"><%=homework.course.name %>(<%=current_time_and_term_short(homework.course) %>)</span></li> <li class="subject-pop-type fl"> <% case homework.homework_type %> <% when 1 %> diff --git a/app/views/users/_show_user_homeworks.html.erb b/app/views/users/_show_user_homeworks.html.erb index 13f9350fb..b9bbf6934 100644 --- a/app/views/users/_show_user_homeworks.html.erb +++ b/app/views/users/_show_user_homeworks.html.erb @@ -1,8 +1,8 @@ <div class="w985"> <a href="javascript:void(0);" class="popup-close" onclick="hideModal()"></a> <div class="f16 fb fontBlue mb10">选用题库中的题目</div> <div class="subject-list fl mr10"> - <a href="<%= user_homework_type_user_path(@user,:is_import => 1) %>" id="public_homeworks_choose" class="subjectChoose chooseActive fl" data-remote="true">公共题库</a> - <a href="<%= user_homework_type_user_path(@user,:type=>'2',:is_import => 1) %>" id="user_homeworks_choose" class="subjectChoose fl" data-remote="true">我的题库</a> + <a href="<%= user_homework_type_user_path(@user,:is_import => 1) %>" id="public_homeworks_choose" class="resource-tab resource-tab-active fl" data-remote="true">公共题库</a> + <a href="<%= user_homework_type_user_path(@user,:type=>'2',:is_import => 1) %>" id="user_homeworks_choose" class="resource-tab fl" data-remote="true">我的题库</a> <div id="homework_search_input"> <%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 1} %> </div> @@ -43,11 +43,11 @@ </div> <script type="text/javascript"> $("#public_homeworks_choose").click(function(){ - $(this).toggleClass("choose-active"); - $("#user_homeworks_choose").toggleClass("choose-active"); + $(this).toggleClass("resource-tab-active"); + $("#user_homeworks_choose").toggleClass("resource-tab-active"); }); $("#user_homeworks_choose").click(function(){ - $(this).toggleClass("choose-active"); - $("#public_homeworks_choose").toggleClass("choose-active"); + $(this).toggleClass("resource-tab-active"); + $("#public_homeworks_choose").toggleClass("resource-tab-active"); }); </script> diff --git a/app/views/users/_upload_resource.html.erb b/app/views/users/_upload_resource.html.erb index c973217f6..b72ec880b 100644 --- a/app/views/users/_upload_resource.html.erb +++ b/app/views/users/_upload_resource.html.erb @@ -1,54 +1,54 @@ -<!--<div class="resourceUploadPopup">--> - <span class="uploadDialogText">上传资源 </span> - <!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>--> - <div class="uploadBoxContainer"> - <%= form_tag(user_resource_create_user_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %> - <div> - <span id="attachments_fields" xmlns="http://www.w3.org/1999/html"> - <% if defined?(container) && container && container.saved_attachments %> - <script>alert('<% container%>')</script> - <% container.attachments.each_with_index do |attachment, i| %> - <span id="attachments_p<%= i %>" class="attachment"> - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> - <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> - <span class="ispublic-label"><%= l(:field_is_public)%>:</span> - <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'remove-upload')%> - <%= if attachment.id.nil? - #待补充代码 - else - link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') - end - %> - <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> - - <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - </span> - <% end %> - <% end %> - </span> - </div> - <div class="uploadBox"> - - <input type="hidden" name="attachment_type" value="1"> - <%= render :partial => 'attachment_list' %> - <div class="cl"></div> - <!--<a href="javascript:void(0);" class=" fr grey_btn mr40" onclick="closeModal();"><%#= l(:button_cancel)%></a>--> - <!--<a id="submit_resource" href="javascript:void(0);" class="blue_btn fr" onclick="submit_resource();"><%#= l(:button_confirm)%></a>--> - - </div> - <div class="uploadResourceIntr"> - <div class="uploadResourceName"><span id="upload_file_count">(未选择文件)</span></div> - <div class="uploadResourceIntr2">您可以上传小于<span class="c_red">50MB</span>的文件</div> - </div> - </div> - <div class="cl"></div> - <div style="margin-top: 10px" > - <div class="courseSendSubmit"> - <!--<a href="javascript:void(0);" class="sendSourceText" onclick="">确定</a>--> - <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %> - </div> - <div class="courseSendCancel"><a href="javascript:void(0);" id="upload_files_cancle_btn" class="sendSourceText" onclick="closeModal();">取消</a></div> - </div> - <% end %> - <div class="cl"></div> +<!--<div class="resourceUploadPopup">--> + <span class="uploadDialogText">上传资源 </span> + <!--<div class="resourcePopupClose"> <a href="javascript:void(0);" class="resourceClose" onclick="closeModal();"></a></div>--> + <div class="uploadBoxContainer"> + <%= form_tag(user_resource_create_user_path(:type=>type,:status=>status), :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %> + <div> + <span id="attachments_fields" xmlns="http://www.w3.org/1999/html"> + <% if defined?(container) && container && container.saved_attachments %> + <script>alert('<% container%>')</script> + <% container.attachments.each_with_index do |attachment, i| %> + <span id="attachments_p<%= i %>" class="attachment"> + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <span class="ispublic-label"><%= l(:field_is_public)%>:</span> + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'remove-upload')%> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + </span> + <% end %> + <% end %> + </span> + </div> + <div class="uploadBox"> + + <input type="hidden" name="attachment_type" value="1"> + <%= render :partial => 'attachment_list' %> + <div class="cl"></div> + <!--<a href="javascript:void(0);" class=" fr grey_btn mr40" onclick="closeModal();"><%#= l(:button_cancel)%></a>--> + <!--<a id="submit_resource" href="javascript:void(0);" class="blue_btn fr" onclick="submit_resource();"><%#= l(:button_confirm)%></a>--> + + </div> + <div class="uploadResourceIntr"> + <div class="uploadResourceName"><span id="upload_file_count">(未选择文件)</span></div> + <div class="uploadResourceIntr2"><!--您可以上传小于<span class="c_red">50MB</span>的文件--></div> + </div> + </div> + <div class="cl"></div> + <div style="margin-top: 10px" > + <div class="courseSendSubmit"> + <!--<a href="javascript:void(0);" class="sendSourceText" onclick="">确定</a>--> + <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %> + </div> + <div class="courseSendCancel"><a href="javascript:void(0);" id="upload_files_cancle_btn" class="sendSourceText" onclick="closeModal();">取消</a></div> + </div> + <% end %> + <div class="cl"></div> <!--</div>--> \ No newline at end of file diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index e2b893382..8329e8432 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -131,7 +131,7 @@ <div class="cl"></div> <% if homework_common.student_works.count != 0 %> <% sw = homework_common.student_works.reorder("created_at desc").first %> - <div class="mt10 homepagePostDeadline"> + <div class="mt10 homepagePostDeadline mb10"> # <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 </div> <% end %> @@ -142,30 +142,36 @@ <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %> - <div class="mt10"> + <div> <p class="mb10 fontGrey2"># <%=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"%>评阅了作品,优秀排行: </p> - <% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> - <% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> - <% student_works.each_with_index do |sw, i| %> - <div class="fl mr10 w100" style="text-align:center;"> - <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id), :alt => "学生头像" %> - <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => homework_common.id)%></p> - </a> - <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> - <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> - </div> - <% if i == 4 %> - <% break %> - <% end %> - <% end %> - <% if student_works.count > 5%> - <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> - <% end %> - <div class="cl"></div> </div> <% end %> + <div> + <% if homework_common.homework_type != 2 %> + <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> + <% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> + <% else %> + <% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> + <% end %> + <% student_works.each_with_index do |sw, i| %> + <div class="fl mr10 w100" style="text-align:center;"> + <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id), :alt => "学生头像" %> + <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_path(:homework => homework_common.id)%></p> + </a> + <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> + <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score<0 ? 0 : score) %>分</span></p> + </div> + <% if i == 4 %> + <% break %> + <% end %> + <% end %> + <% if student_works.count > 5%> + <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> + <% end %> + <div class="cl"></div> + </div> <% end %> <% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 %> @@ -244,7 +250,8 @@ <% end %> <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> <li> - <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%> + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", + :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%> </li> <% end %> <% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 910e799c8..8b72ec781 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -185,7 +185,7 @@ <div id="homework_editor" style="display: <%= edit_mode ? 'block':'none'%>"> <div class="mt10"> <% if edit_mode %> - <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='homework_textarea' name="homework_common[description]"><%=homework.description.html_safe %></textarea> + <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='homework_textarea' name="homework_common[description]"><%=homework.description %></textarea> <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %> <% else %> <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> diff --git a/app/views/users/import_into_container.js.erb b/app/views/users/import_into_container.js.erb index c977d99da..2a1ea3599 100644 --- a/app/views/users/import_into_container.js.erb +++ b/app/views/users/import_into_container.js.erb @@ -1,3 +1,3 @@ -<% if @flag == true%> -alert("发送成功") +<% if @flag == true%> +alert("发送成功") <% end %> \ No newline at end of file diff --git a/app/views/users/send_homework_to_course.js.erb b/app/views/users/send_homework_to_course.js.erb index 491156876..b06d8e434 100644 --- a/app/views/users/send_homework_to_course.js.erb +++ b/app/views/users/send_homework_to_course.js.erb @@ -1 +1,9 @@ -$("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>); \ No newline at end of file +$("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>); +$("#ajax-modal").html("<%=escape_javascript(render :partial => 'homework_post_notice') %>"); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" + + "<a href='javascript:' onclick='hideModal();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); +$('#ajax-modal').parent().css("top","50%").css("left","50%"); +$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup"); +$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); \ No newline at end of file diff --git a/app/views/users/user_homework_type.js.erb b/app/views/users/user_homework_type.js.erb index 1204f1798..701cf45fa 100644 --- a/app/views/users/user_homework_type.js.erb +++ b/app/views/users/user_homework_type.js.erb @@ -7,5 +7,9 @@ $("#homework_search_input").html("<%=escape_javascript(render :partial=>'homewor $("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>'); $("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>"); -$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>"); +$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_repository_search', :locals=>{:type=>@type,:is_import=>@is_import,:property=>@property}) %>"); +$("#homework_type_all").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 0) %>'); +$("#homework_type_nor").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 1) %>'); +$("#homework_type_pro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 2) %>'); +$("#homework_type_gro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 3) %>'); <% end %> diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 3e0342af7..4e928ca78 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -20,10 +20,11 @@ if(check.length == 0) { $("#choose_homework_notice").text("请先选择一个作业"); } else { + var hw_id = $('input[name="checkMenu"]:checked').val(); $("#choose_homework_notice").text(""); $.ajax({ type: 'get', - url: '/users/' + user_id + '/choose_user_course', + url: '/users/' + user_id + '/choose_user_course?homework='+hw_id, data:{send_id:$('input[name="checkMenu"]:checked').val()} }); } @@ -45,10 +46,10 @@ <ul class="resourcesSelect"> <li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a> <ul class="resourcesType"> - <li> <a href="/users/8523/user_resource?type=1" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部</a> </li> - <li> <a href="/users/8523/user_resource?type=2" class="homepagePostTypeAssignment postTypeGrey" data-method="get" data-remote="true">普通作业</a> </li> - <li> <a href="/users/8523/user_resource?type=3" class="program-btn postTypeGrey" data-method="get" data-remote="true" style="white-space:nowrap;">编程作业</a> </li> - <li> <a href="/users/8523/user_resource?type=5" class="group-btn resourcesGrey" data-method="get" data-remote="true">分组作业</a> </li> + <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 0) %>" id="homework_type_all" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部</a> </li> + <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 1) %>" id="homework_type_nor" class="homepagePostTypeAssignment postTypeGrey" data-method="get" data-remote="true">普通作业</a> </li> + <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 2) %>" id="homework_type_pro" class="program-btn postTypeGrey" data-method="get" data-remote="true" style="white-space:nowrap;">编程作业</a> </li> + <li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 3) %>" id="homework_type_gro" class="group-btn resourcesGrey" data-method="get" data-remote="true">分组作业</a> </li> </ul> </li> </ul> @@ -57,7 +58,7 @@ </ul> <div class="cl"></div> <div id="homework_search_input" class="mt10 fl"> - <%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 0} %> + <%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %> </div> <!--<form class="resourcesSearchloadBox mt10"> <input type="text" name="serach" placeholder="输入题库关键词进行搜索" class="searchResource" /> diff --git a/app/views/users/user_homeworks.js.erb b/app/views/users/user_homeworks.js.erb index ec9b2e004..a24b3d018 100644 --- a/app/views/users/user_homeworks.js.erb +++ b/app/views/users/user_homeworks.js.erb @@ -1,5 +1,3 @@ $("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>'); $("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>"); -/*$("#user_show_more_homework").replaceWith("<%#= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>");*/ - diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 6e01b90fb..f45eb11c2 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -21,16 +21,6 @@ $("#resource_search_form").submit(); } - function show_upload(){ - $("#ajax-modal").html('<%= escape_javascript( render :partial => 'upload_resource' ,:locals => {:user=>@user})%>'); - showModal('ajax-modal', '452px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before("<a href='javascript:void(0)' onclick='closeModal();' style='margin-left: 435px;' class='resourceClose'></a>"); - $('#ajax-modal').parent().css("top","50%").css("left","50%").css("position","absolute"); - $('#ajax-modal').parent().addClass("resourceUploadPopup"); - $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); - } - function show_public_resource(){ $("#resource_remote").html('<%= escape_javascript( render :partial => 'user_resource_info' ,:locals => { :tpye => 6}) %>'); } @@ -115,340 +105,5 @@ <div class="cl"></div> -<script> - var pageX = 0; - var pageY = 0; - //当前选中的行 - var line; - //已经选中的行,和当前选中的行的区别是:右键选中为line,换一行右键后,line变为last_line,line变为换行后的line - var last_line; - //资源名称 - var res_name; - //资源名称的链接 - var res_link; - var id; //资源id - var sendType = '1'; //发送到课程 1 发送到项目 2 - var lastSendType; //保存上次发送的发送类型 - $("#resources_list").mousedown(function(e) { - //如果是右键的话 - if (3 == e.which) { - if( $("#res_name").length != 0 || $("#ajax-indicator").is(":hidden") == false){ //其他ajax在执行的时候阻止操作 - e.preventDefault(); - return ; - } - document.oncontextmenu = function() {return false;} - pageX = e.clientX; - pageY = e.clientY; - $("#contextMenu").hide(); - $("#contextMenu").attr("style","display: block; position: fixed; top:" - + pageY - + "px; left:" - + pageX - + "px; width: 80px;"); - $("#contextMenu").show(); - //当前光标所在的对象 - - var ele = document.elementFromPoint(pageX,pageY); - //转换为jquery对象 - line = $(ele).parent(); - //如果上一条存在被选中,那么将上一条的背景色改为白色 - if(last_line != null){ - last_line.children().css("background-color", 'white'); - restore(); - last_line == null; - } - //如果当前的tag是li,那么还要li的父级元素 - if(line.get(0).tagName === 'LI'){ - line = line.parent(); - } - //将当前的元素的所有子元素的背景色改为蓝色 - line.children().css("background-color", '#e1e1e1'); - //将当前元素赋给 上一个对象 保存起来。 - last_line = line; - } - }); - //元素包含关系计算 - var contains = function(root, el) { - if (root.compareDocumentPosition) - return root === el || !!(root.compareDocumentPosition(el) & 16); - if (root.contains && el.nodeType === 1){ - return root.contains(el) && root !== el; - } - while ((el = el.parentNode)) - if (el === root) return true; - return false; - } - $(document.body).click(function(e) { - //在列表上的任何单击事件都要恢复原来的样子 - //隐藏右键菜单 - //e.preventDefault(); - $("#contextMenu").hide(); - if( $("#ajax-indicator").is(":hidden") == false && $("#res_name").length != 0 ){ //其他ajax在执行的时候或者res_name仍然存在阻止操作 - return ; - } - document.oncontextmenu = function() {return true;} - //如果当前行为空,那么要将当前行的拿到 - var ele; - if(line == null){ - ele = document.elementFromPoint(e.clientX, e.clientY); - line = $(ele).parent(); - //如果是在li上点击事件,那么要获得父组件 - if(line.get(0).tagName === 'LI'){ - line = line.parent(); - } - - } - //如果当前对象在表格里,将当前行改变为白色,这里主要是防止点击页面的其他链接的时候,那个链接背景色变白了 - if( contains($("#resources_list").get(0),line.get(0))){ - line.children().css("background-color", 'white'); - } - - //当前行恢复编辑状态到链接状态 - if(ele && ele.nodeName != 'INPUT') { - restore(); - } - line = null; - }); - //只要有一个选中了就是true - function checkboxSelected(){ - selected = false; - $("#resources_list").find("input[name='checkbox1[]']").each(function(){ - if($(this).attr('checked') == true){ - selected = true; - } - }); - return selected; - } - //只有全选才是true - function checkboxAllSelected(){ - allSelected = true; - $("#resources_list").find("input[name='checkbox1[]']").each(function(){ - if($(this).attr('checked') == undefined){ - allSelected = false; - } - }); - return allSelected; - } - //只有全部不选才是true - function checkboxAllDeselected(){ - allDeselected = true; - $("#resources_list").find("input[name='checkbox1[]']").each(function(){ - if($(this).attr('checked') == 'checked'){ - allDeselected = false; - } - }); - return allDeselected; - } - //查看所有的checkbox状态,并且按情况更改$("#checkboxAll")的状态 - function checkAllBox(checkbox){ - //只有选中当前checkbox且这个时候所有的checkbox都被选中了,$("#checkboxAll")才是被选中状态,其余都是非选中状态 - if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){ - $("#checkboxAll").attr('checked',true); - }else{ - $("#checkboxAll").attr('checked',false); - } - $("#res_count").html(getCheckBoxSeletedCount()); - - } - //获取当前checkbox选中的数目 - function getCheckBoxSeletedCount(){ - var i = 0; - $("#resources_list").find("input[name='checkbox1[]']").each(function(){ - if($(this).attr('checked') == 'checked'){ - i ++; - } - }); - return i; - } - //全选反选 - function all_select(){ - - if($("#checkboxAll").attr('checked')){ - $("#resources_list").find("input[name='checkbox1[]']").each(function(){ - $(this).attr('checked',true); - }); - $("#res_count").html(getCheckBoxSeletedCount()); - }else{ - $("#resources_list").find("input[name='checkbox1[]']").each(function(){ - $(this).attr('checked',false); - }); - $("#res_count").html(0); - } - } - //批量删除 - function batch_delete(){ - var data = $("#resources_list_form").serialize(); - if($("input[type=checkbox][data-has-history=Y]:checked").length != 0){ - alert("您只能删除没有历史记录的资源,请重新选择后再删除。"); - return; - } - if($("input[type=checkbox][data-deleteble=N]:checked").length != 0){ - alert("您只能删除自己上传的资源,请重新选择后再删除。"); - return; - } - - if(data != "" && confirm('确认要删除这些资源吗?')) { - $.post( - '<%= user_resource_delete_user_path(@user)%>', - $("#resources_list_form").serialize(),//只会对选中的控件进行序列化提交 - function (data) { - - } - ); - } - } - - - function show_send_(){ - $("#contextMenu").hide(); - document.oncontextmenu = function() {return true;} - line.children().css("background-color",'white'); - id = line.children().last().html(); - if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 - $.ajax({ - type: 'get', - url: '<%= search_user_project_user_path(@user)%>' + '?send_id=' + id, - data:{send_type:'file'} - }); - }else{ - $.ajax({ - type: 'get', - url: '<%= search_user_course_user_path(@user)%>' + '?send_id=' + id, - data:{send_type:'file'} - }); - } - } - - function batch_send(){ - if($("#resources_list_form").serialize() == ""){ - alert('暂时不支持多页选择,您当前页没有选择任何资源'); - return ; - } - if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 - $.ajax({ - type: 'get', - url: '<%= search_user_project_user_path(@user)%>' + '?' + $("#resources_list_form").serialize(), - data:{send_type:'file'} - }); - }else{ - $.ajax({ - type: 'get', - url: '<%= search_user_course_user_path(@user)%>' + '?'+ $("#resources_list_form").serialize(), - data:{send_type:'file'} - }); - - } - } - - function preview(){ - $("#contextMenu").hide(); - document.oncontextmenu = function() {return true;} - line.children().css("background-color",'white'); - id = line.children().last().html(); - $.ajax({ - type:'get', - url:'<%= resource_preview_user_path(@user)%>'+"?resource_id="+id - }); - } - - function rename(){ - $("#contextMenu").hide(); - document.oncontextmenu = function() {return true;} - line.children().css("background-color",'white'); - id = line.children().last().html(); - user_id = line.children().eq(5).html(); - if(user_id === '<%= User.current.id %>') { - res_name = line.children().eq(1).children().attr('title'); - res_link = line.children().eq(1).html(); - line.children().eq(1).html( - '<input name="res_name" id="res_name" ' + - 'style="height: 2em;line-height: 2em;overflow: hidden;" onblur="restore();" ' + - ' onkeypress="if(event.keyCode==13){event.preventDefault();this.blur();}" ' + - 'value="'+res_name+ - '"/> <input type="hidden" id ="res_id" name="res_id" value="'+id+'"/>'); - $("#res_name").focus(); - $("html,body").animate({scrollTop:$("#res_name").offset().top},1000) - }else{ - alert('您无法修改此资源!') - } - } - String.prototype.trim = function() { - var str = this, - str = str.replace(/^\s\s*/, ''), - ws = /\s/, - i = str.length; - while (ws.test(str.charAt(--i))); - return str.slice(0, i + 1); - } - - - - //恢复编辑状态到链接状态 - //如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态 - //如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示 - function restore(){ - //上一行不为空 且链接不为空 - if( last_line != null && res_link != null && res_link != '') { - name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ; - if (name == undefined || name === 'undefined' ){ //只要res_name没有值,那么就不是编辑状态 - return; - } - if( name && name != res_name.trim()){ - - if(confirm('确定修改为 '+name)){ - $.ajax({ - url: '<%=rename_resource_user_path(@user) %>'+ "?res_name="+$('#res_name').val() + "&res_id=" + $("#res_id").val(), - type:'get', - success:function (data) - { - if (data != 'fail' && name != undefined && name != 'undefined') {//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 - last_line.children().eq(1).html(res_link); - last_line.children().eq(1).children().attr('title', name); - last_line.children().eq(1).children().attr('href', data); - last_line.children().eq(1).children().html(name.length > 17 ? name.substring(0, 17) + '...' : name); - } else { - last_line.children().eq(1).html(res_link); - res_link = null; //如果修改失败,恢复之后将res_link置空 - } - } - } ); - }else{ - last_line.children().eq(1).html(res_link); - res_link = null; //如果没有做修改,恢复之后将res_link置空 - } - }else { - last_line.children().eq(1).html(res_link); - res_link = null;//如果没有做修改,恢复之后将res_link置空 - } - - - } - } - - function delete_file() { - $("#contextMenu").hide(); - document.oncontextmenu = function () { - return true; - } - line.children().css("background-color", 'white'); - id = line.children().last().html(); - user_id = line.children().eq(5).html(); - if(line.children().first().children().data('hasHistory') == 'Y'){ - alert('该资源存在历史版本,不能删除'); - return; - } - if(user_id === '<%= User.current.id%>') { - if (confirm('确定要删除资源"' + line.children().eq(1).children().attr('title').trim() + '"么?')) { - $.ajax({ - type: 'post', - url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id + '&type=' + $('#type').val() - }); - } - }else{ - alert('您无法删除此资源!') - } - } - -</script> diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml index 19b979d97..b59538bc9 100644 --- a/config/locales/courses/zh.yml +++ b/config/locales/courses/zh.yml @@ -15,7 +15,7 @@ zh: label_course_new: 新建课程 label_course_name: 课程名称 - label_homework: 课程作业 + label_homework: 作业 label_course_news: 课程通知 label_course_mail_news_reply: 课程通知回复 label_main_teacher: 主讲教师 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index e9d3ed813..114e67370 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -614,7 +614,7 @@ zh: label_homework_info: 提交情况 #huang label_course_news_description: '课程必须是高校正式开设的课程,或是围绕特定主题定期发布课程资料的公共开放课程;<br/>如果您想创建一个协作研究空间,请您前往“我的项目”页面创建项目,谢谢!' - label_course_board: 讨论区 + label_course_board: 问答区 label_version: 版本 label_version_new: 新建版本 @@ -1731,7 +1731,7 @@ zh: label_newbie_faq: '新手指引 & 问答' label_hot_project: '热门项目' label_borad_project: 项目讨论区 - label_borad_course: 课程讨论区 + label_borad_course: 课程问答区 label_borad_org_subfield: 资源栏目讨论区 view_borad_course: 课程讨论 label_memo_create_succ: 发布成功 diff --git a/db/migrate/20160303103231_add_homework_journal_to_course_contributor_scores.rb b/db/migrate/20160303103231_add_homework_journal_to_course_contributor_scores.rb index 505695fc0..e3d4310e6 100644 --- a/db/migrate/20160303103231_add_homework_journal_to_course_contributor_scores.rb +++ b/db/migrate/20160303103231_add_homework_journal_to_course_contributor_scores.rb @@ -1,5 +1,5 @@ -class AddHomeworkJournalToCourseContributorScores < ActiveRecord::Migration - def change - add_column :course_contributor_scores, :homework_journal_num, :integer, :default => 0 - end -end +class AddHomeworkJournalToCourseContributorScores < ActiveRecord::Migration + def change + add_column :course_contributor_scores, :homework_journal_num, :integer, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index c21580c90..b7066c999 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -99,8 +99,6 @@ ActiveRecord::Schema.define(:version => 20160304154643) do t.integer "quotes" t.integer "version" t.integer "attachment_id" - t.integer "is_publish", :default => 1 - t.date "publish_time" end create_table "attachments", :force => true do |t| @@ -1280,6 +1278,7 @@ ActiveRecord::Schema.define(:version => 20160304154643) do t.text "description" t.integer "creator_id" t.integer "home_id" + t.string "domain" t.boolean "is_public" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false @@ -1387,6 +1386,7 @@ ActiveRecord::Schema.define(:version => 20160304154643) do t.integer "changeset_num", :default => 0 t.integer "board_message_num", :default => 0 t.integer "board_num", :default => 0 + t.integer "act_num", :default => 0 t.integer "attach_num", :default => 0 t.datetime "commit_time" end diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index a1c96fb56..707d661ea 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -1125,3 +1125,7 @@ a.resource-tab-active {color:#fff; background-color:#269ac9; border-bottom:1px s .h34 {height:34px;} .resource-tab {font-size:16px; color:#4d4d4d; width:70px; padding:5px 10px; display:inline-block; text-align:left; border-bottom:1px solid #ddd;} a.resource-tab-active {color:#fff; background-color:#269ac9; border-bottom:1px solid #269ac9;} + +a.group-btn{ background: url(../images/course/hwork_icon.png) -2px -58px no-repeat !important; height:20px; display:block; padding-left:23px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} +a.program-btn{background: url(../images/homepage_icon.png) -86px -393px no-repeat; width:30px; height:20px; display:block; padding-left:23px; color:#888888;} +