diff --git a/Gemfile b/Gemfile index f3b06c2d4..da3b3b4d7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,11 +1,13 @@ source 'https://rubygems.org/' -### 这里执行bundle config mirror.https://rubygems.org https://gems.ruby-china.org 切换到ruby-china源 +### ����ִ��bundle config mirror.https://rubygems.org https://gems.ruby-china.org �л���ruby-chinaԴ unless RUBY_PLATFORM =~ /w32/ # unix-like only gem 'iconv' end +#gem 'certified' + gem 'wechat',path: 'lib/wechat' gem 'grack', path:'lib/grack' gem 'gitlab', path: 'lib/gitlab-cli' diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index b11194b30..67904d11e 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -47,6 +47,7 @@ module Mobile blog_comment_expose :created_at blog_comment_expose :lasted_comment blog_comment_expose :id + blog_comment_expose :locked blog_comment_expose :praise_count expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| if c.is_a? (::BlogComment) diff --git a/app/api/mobile/entities/message.rb b/app/api/mobile/entities/message.rb index 912b07e62..051c92886 100644 --- a/app/api/mobile/entities/message.rb +++ b/app/api/mobile/entities/message.rb @@ -51,6 +51,7 @@ module Mobile message_expose :replies_count message_expose :praise_count message_expose :created_on + message_expose :locked message_expose :id message_expose :lasted_comment expose :message_children,using:Mobile::Entities::Message do |c,opt| diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 0fd4cc2c9..1478bceae 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -162,6 +162,7 @@ class CoursesController < ApplicationController @subPage_title = l :label_student_list @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' # @is_remote = true + @sort_type = 'score' @score_sort_by = "desc" q = "#{params[:name].strip}" if params[:incourse] @@ -185,9 +186,11 @@ class CoursesController < ApplicationController group.course_id = @course.id group.save end + @sort_type = 'score' + @score_sort_by = "desc" @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @is_remote = true - @members = student_homework_score(0,0, 10,"desc") + @members = student_homework_score(0,0, 10,@score_sort_by) @course_groups = @course.course_groups end @@ -196,7 +199,9 @@ class CoursesController < ApplicationController @subPage_title = l :label_student_list @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true - + @sort_type = 'score' + @score_sort_by = "desc" + @members = student_homework_score(0,0, 10,@score_sort_by) @course_groups = @course.course_groups end @@ -281,6 +286,7 @@ class CoursesController < ApplicationController @render_file = 'new_member_list' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true + @sort_type = 'score' @score_sort_by = "desc" if params[:group_id] && params[:group_id] != "0" @group = CourseGroup.find(params[:group_id]) @@ -298,6 +304,7 @@ class CoursesController < ApplicationController @render_file = 'new_member_list' @score_sort_by = "desc" + @sort_type = "score" @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @role = params[:role].nil? ? '2':params[:role] @is_remote = true @@ -312,7 +319,7 @@ class CoursesController < ApplicationController if @course.open_student == 1 || User.current.member_of_course?(@course) @subPage_title = l :label_student_list page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @all_members = student_homework_score(0,page, 10,"desc") + @all_members = student_homework_score(0,page, 10,@score_sort_by) @members = @all_members else render_403 @@ -350,28 +357,29 @@ class CoursesController < ApplicationController @subPage_title = l :label_student_list @render_file = 'new_member_list' @is_remote = true + @sort_type = params[:sort_type] if params[:sort_type] @score_sort_by = params[:sort_by] if params[:sort_by] @search_name = params[:search_name] if params[:search_name] group_id = params[:group_id] if !@search_name.nil? if group_id == '0' page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name) + @results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by,@sort_type), @search_name) @result_count = @results.count # @results = paginateHelper @results, 10 else @group = CourseGroup.find(group_id) - @results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by),@search_name) + @results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type),@search_name) @result_count = @results.count # @results = paginateHelper @results, 10 end else if group_id == '0' page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @results = student_homework_score(0,page, 10,@score_sort_by) + @results = student_homework_score(0,page, 10,@score_sort_by,@sort_type) else @group = CourseGroup.find(group_id) - @results = student_homework_score(group_id, 0, 0,@score_sort_by) + @results = student_homework_score(group_id, 0, 0,@score_sort_by,@sort_type) end end end @@ -384,6 +392,15 @@ class CoursesController < ApplicationController end end + # 显示每个学生的作业评分详情 + def show_member_act_score + @member = Member.find(params[:member_id]) if params[:member_id] + respond_to do |format| + format.html {render :layout => 'course_base'} + format.js + end + end + def handle_course courses, activities course_activity_count_array=activities.values() course_array=[] @@ -1149,7 +1166,7 @@ class CoursesController < ApplicationController end end - def student_homework_score(groupid,start_from, nums, score_sort_by) + def student_homework_score(groupid,start_from, nums, score_sort_by, sort_type = 'score') start_from = start_from * nums sql_select = "" if groupid == 0 @@ -1159,11 +1176,13 @@ class CoursesController < ApplicationController WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} AND student_works.user_id = members.user_id - ) AS score + ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = 577 AND ccs.user_id = members.user_id + ) AS act_score FROM members JOIN students_for_courses ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id - WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}" + WHERE members.course_id = #{@course.id} ORDER BY #{sort_type} #{score_sort_by}" else sql_select = "SELECT members.*,( SELECT SUM(student_works.work_score) @@ -1171,11 +1190,13 @@ class CoursesController < ApplicationController WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} AND student_works.user_id = members.user_id - ) AS score + ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = 577 AND ccs.user_id = members.user_id + ) AS act_score FROM members JOIN students_for_courses ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id - WHERE members.course_id = #{@course.id} AND members.course_group_id = #{groupid} ORDER BY score #{score_sort_by}" + WHERE members.course_id = #{@course.id} AND members.course_group_id = #{groupid} ORDER BY #{sort_type} #{score_sort_by}" end sql = ActiveRecord::Base.connection() homework_scores = Member.find_by_sql(sql_select) @@ -1225,8 +1246,7 @@ class CoursesController < ApplicationController sheet1[5,i+4] = "第"+(i+1).to_s+"次" end sheet1[5,homeworks.count+4] = "总成绩" - sheet1[5,0] = "排名" - sheet1[5,0] = "排名" + sheet1[5,homeworks.count+5] = "活跃度" count_row = 6 members.each_with_index do |member, i| sheet1[count_row,0]= i+1 @@ -1236,14 +1256,15 @@ class CoursesController < ApplicationController homeworks.each_with_index do |homework, j| student_works = homework.student_works.where("user_id = #{member.user.id}") if student_works.empty? - sheet1[count_row,j+4] = format("%0.2f",0) + sheet1[count_row,j+4] = 0 else final_score = student_works.first.final_score.nil? ? 0 : student_works.first.final_score score = final_score - student_works.first.absence_penalty - student_works.first.late_penalty - sheet1[count_row,j+4] = format("%0.2f",score <0 ? 0:score) + sheet1[count_row,j+4] = score <0 ? 0:score.round(2) end end - sheet1[count_row,homeworks.count+4] = format("%0.2f",member.score.nil? ? 0:member.score.to_s) + sheet1[count_row,homeworks.count+4] = member.score.nil? ? 0:member.score.round(2) + sheet1[count_row,homeworks.count+5] = member.act_score.nil? ? 0:member.act_score count_row += 1 end diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index d1a8b23dd..c6047d227 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -79,7 +79,7 @@ class OrgDocumentCommentsController < ApplicationController def add_reply @document = OrgDocumentComment.find(params[:id]).root - @act = OrgActivity.find(params[:id]) + @act = OrgActivity.find(params[:act_id]) @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) @comment.content = params[:org_content] @document.children << @comment diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 661073cdc..c628b25fc 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -15,6 +15,12 @@ class OrgSubfieldsController < ApplicationController end end @subfield.update_attributes(:field_type => params[:field_type]) + # 如果栏目是教师,不参入类型的配置,定义为右三模式 + # 新增模块命名规则,左边1开头,右边2开头,以前的不变 + # eg:23 右三 + if params[:field_type] == "Comptec" + @subfield.update_attributes(:status => 23) + end else @res = false end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 3709dd24b..c94f734e1 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -28,7 +28,7 @@ class OrganizationsController < ApplicationController helper :project_score helper :issues include UsersHelper - before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout] + before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers] layout 'base_org' def index @@ -98,10 +98,26 @@ class OrganizationsController < ApplicationController else if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) + # params[:org_subfield_id] 存在即对应的栏目,否则进入组织动态 if params[:org_subfield_id] @org_subfield = OrgSubfield.find(params[:org_subfield_id]) - @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 - @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + if @org_subfield.field_type == "Comptec" || @org_subfield.field_type == "Compstu" + + # @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,( SELECT `courses`.* FROM `courses` INNER JOIN `members` ON `courses`.`id` = `members`.`course_id` WHERE `members`.`user_id` = u.id AND (courses.status<>9)) as course_count + # from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + # @org_count = @org_teachers.count + # @limit = 25 + # @is_remote = true + # @atta_count = @attachments.count + # @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + # @offset ||= @atta_pages.offset + # #@curse_attachments_all = @all_attachments[@offset, @limit] + # @attachments = paginateHelper @attachments,25 + else + @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + end else shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) @@ -142,6 +158,57 @@ class OrganizationsController < ApplicationController end + def teachers + unless @organization.allow_set_teachers + render_403 + return + end + q = params[:search].nil? ? "" : "#{params[:search].strip}" + @field = OrgSubfield.find(params[:org_subfield_id]) + @type = params[:type] + if @type == "courses" || @type.nil? + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif @type == "students" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif @type == "resources" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif @type == "famous" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + end + limit = 10 + # @is_remote = true + @teachers_count = @org_teachers.count + @atta_pages = Paginator.new @teachers_count, limit, params['page'] || 1 + @offset ||= @atta_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @org_teachers = paginateHelper @org_teachers, limit + respond_to do |format| + format.html + format.js + end + end + + def searchmember_by_name members, name + #searchPeopleByRoles(project, StudentRoles) + mems = [] + if name != "" + name = name.to_s.downcase + members.each do |m| + username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase + if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name)) + mems << m + end + end + else + mems = members + end + mems + end + def get_project_message_activities_org org project_ids = org.projects.map{|project| project.id}.join(",") unless project_ids.blank? @@ -221,6 +288,7 @@ class OrganizationsController < ApplicationController # @organization.domain = params[:organization][:domain] @organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0 @organization.allow_guest_download = params[:organization][:allow_guest_download] == 'on' ? 1 : 0 + @organization.allow_teacher = params[:organization][:allow_teacher] == 'on' ? 1 : 0 @organization.show_mode = params[:show_mode] #@organization.name = params[:organization][:name] @organization.save @@ -403,6 +471,18 @@ class OrganizationsController < ApplicationController end end + # 设置为名师 + def set_excellent_teacher + @ex_teacher = User.find(params[:user]) + @ex_teacher.update_column(:excellent_teacher, 1) + end + + # 取消名师 + def reset_excellent_teacher + @ex_teacher = User.find(params[:user]) + @ex_teacher.update_column(:excellent_teacher, 0) + end + def hide_org_subfield @org_subfield = OrgSubfield.find(params[:org_subfield_id]) @org_subfield.update_attribute(:hide, 1) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b73ecf9b9..4a148bb8b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -32,9 +32,9 @@ class RepositoriesController < ApplicationController before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] - before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked] + before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -95,6 +95,13 @@ class RepositoriesController < ApplicationController end + # 一键ZIP下载 + def project_archive + g = Gitlab.client + g.get() + # g.project_archive(params[:gpid].to_i, params[:rev]) + end + # 判断用户是否已经fork过该项目 def has_forked?(project, user) projects = Project.where("user_id =?", user) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 121711a85..deab2feb6 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -123,6 +123,7 @@ class StudentWorkController < ApplicationController #-1 默认值 0全部正确并结束 2 超时 -2 编译错误 resultObj[:status] = -1 resultObj[:results] = result["results"].first #本次测试结果 + result["error_msg"] = result["error_msg"][0..2047] resultObj[:error_msg] = result["error_msg"] #编译错误时的信息 #该状态用于存入CodeTests @@ -499,6 +500,7 @@ class StudentWorkController < ApplicationController render_403 return end + @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name).count end @score = @b_sort == "desc" ? "asc" : "desc" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8995a5aee..a81ade3fa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -509,7 +509,7 @@ class UsersController < ApplicationController def choose_user_course homework = HomeworkCommon.find params[:send_id].to_i - if homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) + if homework.user != User.current && homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i) if ah.empty? @status = 2 @@ -630,9 +630,9 @@ class UsersController < ApplicationController visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") elsif params[:type] == "2" #我的题库 - courses = @user.courses.where("is_delete = 0") + courses = @user.courses.where("is_delete = 1") course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id in #{course_ids}").order("#{@order} #{@b_sort}") + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}") elsif params[:type] == "3" #申请题库 none_visible_course = Course.where("is_delete = 1") none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")" @@ -672,7 +672,7 @@ class UsersController < ApplicationController def show_homework_detail homework = HomeworkCommon.find params[:homework].to_i - if homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) + if homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) && User.current != homework.user ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework].to_i) if ah.empty? @status = 2 @@ -719,15 +719,15 @@ class UsersController < ApplicationController @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}") end elsif params[:type] == "2" #我的题库 - courses = @user.courses.where("is_delete = 0") + courses = @user.courses.where("is_delete = 1") course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" if @order == "course_name" - sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" + sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" @homeworks = HomeworkCommon.find_by_sql(sql) elsif @order == "user_name" - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") else - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") end elsif params[:type] == "3" #申请题库 apply_homeworks = ApplyHomework.where("user_id = ?",@user.id) @@ -2618,6 +2618,9 @@ class UsersController < ApplicationController # 获取我的资源 def get_my_resources author_id, user_course_ids, user_project_ids, order, score + unless author_id.to_i.to_s == author_id + author_id = User.find_by_login(author_id).id + end attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2625,6 +2628,7 @@ class UsersController < ApplicationController # 获取我的资源查询结果 def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) + author_id = User.find_by_login(author_id).id @attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2632,6 +2636,7 @@ class UsersController < ApplicationController # 获取我的课程资源 def get_course_resources author_id, user_course_ids, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2639,6 +2644,7 @@ class UsersController < ApplicationController # 获取我的课程资源中搜索结果 def get_course_resources_search author_id, user_course_ids, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2656,6 +2662,7 @@ class UsersController < ApplicationController # 获取我的项目资源 def get_project_resources author_id, user_project_ids, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2663,6 +2670,7 @@ class UsersController < ApplicationController # 获取我的项目资源搜索 def get_project_resources_search author_id, user_project_ids, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2680,12 +2688,14 @@ class UsersController < ApplicationController # 获取我上传的附件 def get_attch_resources author_id, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', 'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我上传的附件搜索结果 def get_attch_resources_search author_id, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', 'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2704,11 +2714,13 @@ class UsersController < ApplicationController # 获取我的用户类型资源 def get_principal_resources author_id, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源搜索 def get_principal_resources_search author_id, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2725,7 +2737,7 @@ class UsersController < ApplicationController # 资源库 分为全部 课程资源 项目资源 附件 def user_resource # 别人的资源库是没有权限去看的 - if User.current.id.to_i != params[:id].to_i + if User.current.id.to_i != @user.id.to_i render_403 return end @@ -2780,13 +2792,13 @@ class UsersController < ApplicationController # 导入资源 def import_resources # 别人的资源库是没有权限去看的 - if User.current.id.to_i != params[:id].to_i + @user = User.find_by_login(params[:id]) + if User.current != @user render_403 return end @resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id] @resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project" - @user = User.find(params[:id]) @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @score = @b_sort == "desc" ? "asc" : "desc" user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bbf67f6a3..229aceb1c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,6 +33,19 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter + + def user_path(resource, parameters = {}) + if Fixnum === resource + resource = User.find(resource) + end + super + end + + # def user_blogs_path(resource,parameters={}) + # super + # end + + def update_visiti_count container container.update_column(:visits, container.visits + 1) end diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 917ccc01c..cba4fa210 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -148,4 +148,43 @@ module OrganizationsHelper org_acts end + def org_subfield_had_created?(org, type) + sub_field = org.org_subfields.select{|subfield| subfield.field_type == type} + result = sub_field.length > 0 ? true : false + result + end + + def org_subfield_type(field) + case field.field_type + when "Post" + result = "帖子" + when "Resource" + result = "资源" + when "Compstu" + result = "学生" + when "Comptec" + result = "教师" + when "Complex" + result = "综合" + end + end + + def org_teacher_resource_count user + results = Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count + end + + def org_teacher_course_count user + results = Course.find_by_sql("select * from courses where courses.tea_id = #{user.id}").count + end + + def org_student_course_count user + course_ids = user.courses.map { |c| c.is_delete == 0 && c.id} + results = Member.find_by_sql("select id from courses where courses.tea_id = #{user.id}").count + end + + def excellent_teachers + User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 order by course_count desc").first(5) + end + end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 998ace441..f11a48a80 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -29,8 +29,8 @@ class HomeworkCommon < ActiveRecord::Base :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail, :act_as_course_message - after_update :update_activity, :wechat_message + after_create :act_as_activity, :send_mail + after_update :update_activity after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -60,11 +60,11 @@ class HomeworkCommon < ActiveRecord::Base self.course.members.each do |m| # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) - count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count - if count == 0 - ws = WechatService.new - ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") - end + #count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count + #if count == 0 + # ws = WechatService.new + # ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + #end # end end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 79ddcd917..d5d148117 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -262,7 +262,7 @@ class Issue < ActiveRecord::Base # set default values for new records only self.status ||= IssueStatus.default self.priority ||= IssuePriority.default - self.watcher_user_ids = [] + # self.watcher_user_ids = [] end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 4b5ac227f..68b747ab9 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -260,6 +260,10 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.jour.user_id self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.course.id, :viewed => false) end + else + if self.user_id != self.parent.user_id + self.course_messages << CourseMessage.new(:user_id => self.parent.user_id,:course_id => self.jour.course.id, :viewed => false) + end end count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count if count == 0 diff --git a/app/models/organization.rb b/app/models/organization.rb index 8f9d290eb..311a37bf8 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -26,4 +26,8 @@ class Organization < ActiveRecord::Base def switch_type self.show_mode.to_i == 1 ? true : false end + + def allow_set_teachers + self.allow_teacher.to_i == 1 ? true : false + end end diff --git a/app/models/school.rb b/app/models/school.rb index 6cafb0473..b9a1d88cb 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -5,4 +5,5 @@ class School < ActiveRecord::Base def to_s self.name.to_s end + end diff --git a/app/models/user.rb b/app/models/user.rb index 9e4f227b7..035aff625 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -309,6 +309,20 @@ class User < Principal end # ====================================================================== + def my_workplace + self.user_extensions.try(:occupation).to_s + end + + def my_blogs_count + self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count + end + + def my_students + my_students=StudentsForCourse.find_by_sql("SELECT SUM(student_count) as students_count, c.tea_id FROM courses c, (SELECT course_id , COUNT(id) AS student_count FROM students_for_courses GROUP BY course_id) AS ct + WHERE c.id= ct.course_id and c.tea_id = #{self.id} GROUP BY c.tea_id").first + results = my_students.blank? ? 0 : my_students.students_count + results + end # 查询用户未读过的记录 # 用户留言记录 @@ -1073,16 +1087,25 @@ class User < Principal anonymous_user end + def self.is_id?(id) + Fixnum===id || id.to_i.to_s == id + end + # refactor User model find function, # return anonymous user when can not find user id = user_id def self.find (*args, &block) begin + return find_by_login(args.first) if args.size==1 && !is_id?(args.first) super rescue self.anonymous end # super end + + def to_param + login + end # Salts all existing unsalted passwords # It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password)) # This method is used in the SaltPasswords migration and is to be kept as is diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index c7e4a7428..1050a59b9 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -36,7 +36,7 @@

取消 - 留言 + 留言 <% end %> <% end %> @@ -55,9 +55,6 @@ \ No newline at end of file diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index a24835fc1..875b9ec4c 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -54,9 +54,16 @@
-<% end %> \ No newline at end of file +<% end %> + \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 6180dac8e..24a0ad047 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -42,9 +42,16 @@
-<% end %> \ No newline at end of file +<% end %> + \ No newline at end of file diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index eef7546e5..99c48a3ab 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -90,7 +90,7 @@ ''+ ''+ ''+ ''+ ' -
+
    <% @subfield_content.each do |field| %> <% if is_default_field?(field) %> @@ -105,6 +105,7 @@
      <% field.sub_domains.each do |subdomain| %>
    • <%=link_to subdomain.name, org_subfield_sub_domain_sub_document_comments_path(subdomain, :org_subfield_id => field.id), :class => "sn-link-grey" %>
    • +
    • |
    • <% end %>
@@ -156,6 +157,8 @@ <%= render :partial => 'organizations/org_subfield_rightM', :locals => {:field => field} %> <% elsif field.status.to_i == 8 %> <%= render :partial => 'organizations/org_subfield_rightD', :locals => {:field => field} %> + <% elsif field.status.to_i == 23 %> + <%= render :partial => 'organizations/org_subfield_rightM2', :locals => {:field => field} %> <% end %> <% end %>
@@ -190,16 +193,19 @@ diff --git a/app/views/layouts/base_sub_domain.html.erb b/app/views/layouts/base_sub_domain.html.erb index b2d26d309..871e2cdea 100644 --- a/app/views/layouts/base_sub_domain.html.erb +++ b/app/views/layouts/base_sub_domain.html.erb @@ -1,187 +1,191 @@ - - - - - <%= h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= javascript_heads %> - <%= heads_for_theme %> - <%= stylesheet_link_tag 'org_new_style','jquery/jquery-ui-1.9.2', 'org2' %> - <%= javascript_include_tag 'cookie','project', 'organization','header','prettify','select_list_move','org'%> - <%= javascript_include_tag 'attachments' %> - <%#= call_hook :view_layouts_base_html_head %> - - <%#= yield :header_tags -%> - - - - - - - - - - - - - - - -
-
-
- <%= render :partial => 'organizations/org_logined_header' %> - - -
-
    - <% @subfield_content.each do |field| %> - <% if is_default_field?(field) %> - <% case field.name %> - <% when 'activity' %> - - <% when 'course' %> - - <% when 'project' %> - - <% end %> - <% else %> - <% if field.field_type == "Post" && field.hide == 0 %> - - - - <% elsif field.field_type == "Resource" && field.hide == 0 %> - - <% end %> - <% end %> - <% end %> - <% if User.current.admin_of_org?(@organization) %> - - <% end %> -
-
-
-
- banner image - -
-
-
-
-<%# 更新访问数,刷新的时候更新访问次数 %> - <% update_visiti_count @organization %> -<%# over %> - - - - <%= render_flash_messages %> - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
- - -
- - -
- - - - - - - - + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= stylesheet_link_tag 'org_new_style','jquery/jquery-ui-1.9.2', 'org2' %> + <%= javascript_include_tag 'cookie','project', 'organization','header','prettify','select_list_move','org'%> + <%= javascript_include_tag 'attachments' %> + <%#= call_hook :view_layouts_base_html_head %> + + <%#= yield :header_tags -%> + + + + + + + + + + + + + + + +
+
+
+ <%= render :partial => 'organizations/org_logined_header' %> +
+ +
+ +
+
    + <% @subfield_content.each do |field| %> + <% if is_default_field?(field) %> + <% case field.name %> + <% when 'activity' %> + + <% when 'course' %> + + <% when 'project' %> + + <% end %> + <% else %> + <% if field.field_type == "Post" && field.hide == 0 %> + + + + <% elsif field.field_type == "Resource" && field.hide == 0 %> + + <% end %> + <% end %> + <% end %> + <% if User.current.admin_of_org?(@organization) %> + + <% end %> +
+
+
+
+ banner image + +
+
+
+
+<%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @organization %> +<%# over %> + + + + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
+ + +
+ + +
+ + + + + + + + diff --git a/app/views/org_document_comments/add_reply.js.erb b/app/views/org_document_comments/add_reply.js.erb index 79858dd03..d904cb920 100644 --- a/app/views/org_document_comments/add_reply.js.erb +++ b/app/views/org_document_comments/add_reply.js.erb @@ -1,2 +1,2 @@ -$("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document,:flag => params[:flag], :act => @act}) %>"); +$("#organization_document_<%= @document.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document,:flag => params[:flag], :act => @act}) %>"); sd_create_editor_from_data(<%= @act.id %>,"","100%", "<%=@act.class.to_s%>"); diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb index 3e08d9f9e..5cc6d5c91 100644 --- a/app/views/org_subfields/create.js.erb +++ b/app/views/org_subfields/create.js.erb @@ -4,6 +4,7 @@ :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); $("#sub_field_left_lists").html(""); $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); + $("#org_excellent_teachers").html("<%= escape_javascript(render :partial => 'organizations/setting_excellent_teachers') %>"); <% end %> $("#subfield_name").val(""); $("#sub_dir").val(""); \ No newline at end of file diff --git a/app/views/org_subfields/destroy.js.erb b/app/views/org_subfields/destroy.js.erb index d069b1cd8..c14eeae8f 100644 --- a/app/views/org_subfields/destroy.js.erb +++ b/app/views/org_subfields/destroy.js.erb @@ -2,4 +2,5 @@ $("#org_subfield_list").html(""); $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); $("#sub_field_left_lists").html(""); -$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); +$("#org_excellent_teachers").html("<%= escape_javascript(render :partial => 'organizations/setting_excellent_teachers') %>"); \ No newline at end of file diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 39837df88..4340213a4 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -91,7 +91,7 @@ <% end %> <% else %>
- <% if field.field_type == "Post" %> + <% if field.field_type == "Post" || field.field_type == "Complex" || field.field_type == "Compstu" || field.field_type == "Comptec" %>
<% if !field.subfield_subdomain_dir.nil? %> @@ -101,9 +101,13 @@ <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> <% end %> <% else %> - <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <% if field.field_type == "Comptec" %> + <%= link_to "#{field.name}", teachers_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <% else %> + <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <% end %> <% end %> - <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <% if User.current.logged? and User.current.admin_of_org?(organization) && field.field_type != "Comptec" %> <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子" %> <% end %>
@@ -118,7 +122,6 @@ <% end %> - <% else %>
<% if !field.subfield_subdomain_dir.nil? %> diff --git a/app/views/organizations/_org_subfield_leftM1.html.erb b/app/views/organizations/_org_subfield_leftM1.html.erb index 4e1eebb94..e7481ce0a 100644 --- a/app/views/organizations/_org_subfield_leftM1.html.erb +++ b/app/views/organizations/_org_subfield_leftM1.html.erb @@ -24,8 +24,9 @@ <%= format_date activity.updated_at %>
-

<%= activity.description.to_s.html_safe %>

+
<%= activity.description.to_s.html_safe %>
+
<%=link_to "查看全文>>", activity.name.to_s, student_work_index_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% elsif act.org_act_type == "Message" %> <% activity = Message.find(act.org_act_id) %> @@ -37,16 +38,13 @@ <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> <% end %>

- <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% end %> + <%= link_to activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %>

<%= format_date activity.updated_on %>
-

<%= activity.content.to_s.html_safe %>

+
<%= activity.content.to_s.html_safe %>
+
<%=link_to "查看全文>>", activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% elsif act.org_act_type == "News" %> <% activity = News.find(act.org_act_id) %> @@ -62,8 +60,10 @@ <%= format_date activity.created_on %>
-

<%= activity.description.to_s.html_safe %>

+
<%= activity.description.to_s.html_safe %>
+ +
<%=link_to "查看全文>>", activity.title.to_s, news_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% elsif act.org_act_type == "Poll" %> <% activity = Poll.find(act.org_act_id) %> @@ -86,8 +86,9 @@ <%= format_date activity.published_at %>
-

<%= activity.polls_description.to_s.html_safe %>

+
<%= activity.polls_description.to_s.html_safe %>
+
<%=link_to "查看全文>>", poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% end %> <% end %> @@ -116,8 +117,9 @@ <%= format_date activity.updated_on %>
-

<%= activity.description.to_s.html_safe %>

+
<%= activity.description.to_s.html_safe %>
+
<%=link_to "查看全文>>", activity.subject.to_s, issue_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% elsif act.org_act_type == "Message" %> <% activity = Message.find(act.org_act_id) %> @@ -128,17 +130,14 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> <% end %> -

- <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% end %> +

+ <%= link_to activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %>

<%= format_date activity.updated_on %>
-

<%= activity.content.to_s.html_safe %>

+
<%= activity.content.to_s.html_safe %>
+
<%=link_to "查看全文>>", activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% elsif act.org_act_type == "News" %> <% activity = News.find(act.org_act_id) %> @@ -154,8 +153,9 @@ 2016-04-08
-

<%= activity.description.to_s.html_safe %>

+
<%= activity.description.to_s.html_safe %>
+
<%=link_to "查看全文>>", news_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% end %> <% end %> @@ -190,8 +190,9 @@ <%= format_date document.created_at %>
-

<%= document.content.to_s.html_safe %>

+
<%= document.content.to_s.html_safe %>
+
<%=link_to "查看全文>>", org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% else activity.container_type == 'OrgSubfield' %> <% if activity.org_act_type == 'Message' and activity.org_act_id and Message.where("id=#{activity.org_act_id}").count > 0 %> @@ -209,17 +210,14 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> <% end %> -

- <% if message.parent_id.nil? %> - <%= link_to message.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h3-title" %> - <% end %> +

+ <%= link_to message.parent_id.nil? ? message.subject.to_s.html_safe : message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h3-title" %>

<%= format_date message.created_on %>
-

<%= content.to_s.html_safe %>

+
<%= content.to_s.html_safe %>
+
<%=link_to "查看全文>>", message.parent_id.nil? ? message.subject.to_s.html_safe : message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% else %>
@@ -237,7 +235,14 @@ <%= format_date message.created_on %>
-

<%= content.to_s.html_safe %>

+
<%= content.to_s.html_safe %>
+
+
+ <% if message.parent_id.nil? %> + <%=link_to "查看全文>>", message.subject.to_s.html_safe, board_message_path(message.board,message), :target => "_blank", :class => "sn-link-grey2 sn-fr" %> + <% else %> + <%=link_to "查看全文>>", message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => "_blank", :class => "sn-link-grey2 sn-fr" %> + <% end %>
<% end %> @@ -256,8 +261,9 @@ <%= format_date news.created_on %>
-

<%= news.description.to_s.html_safe %>

+
<%= news.description.to_s.html_safe %>
+
<%=link_to "查看全文>>", news.title.to_s, news_path(news), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
<% end %> <% end %> @@ -266,4 +272,14 @@ <% end %> <% end %> + + diff --git a/app/views/organizations/_org_subfield_rightD.html.erb b/app/views/organizations/_org_subfield_rightD.html.erb index 398f679e1..2953d1a0a 100644 --- a/app/views/organizations/_org_subfield_rightD.html.erb +++ b/app/views/organizations/_org_subfield_rightD.html.erb @@ -10,7 +10,7 @@ <% org_acts = get_subfield_acts field %> <% unless org_acts.blank? %> <% activity = org_acts.first %> -
+
<% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> <% document = activity.org_act %> <% org_subfield_id = params[:org_subfield_id] %> @@ -52,13 +52,13 @@ <% end %>
<% else %> -
+
<% end %> <% elsif field.field_type == "Resource" %> <% org_attachs = get_attach_org2(field) %> -
+
<% if !field.subfield_subdomain_dir.nil? %> <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> <%= link_to image_tag("/images/default_blank/right-03.jpg", :width => "369", :height => "169"), show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :target => "_blank" %> diff --git a/app/views/organizations/_org_subfield_rightM.html.erb b/app/views/organizations/_org_subfield_rightM.html.erb index e8dfa6b3f..d1b86f047 100644 --- a/app/views/organizations/_org_subfield_rightM.html.erb +++ b/app/views/organizations/_org_subfield_rightM.html.erb @@ -23,7 +23,8 @@ <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "104", :height => "104"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class => "fl sn-index-wximg" %> <% end %> -

<%=link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>

+

<%=link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank" %>

+
<% else activity.container_type == 'OrgSubfield' %> @@ -39,6 +40,7 @@ <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "104", :height => "104"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class => "fl sn-index-wximg" %> <% end %>

<%=link_to message.content.to_s.html_safe, board_message_url_in_org(message.board.id, message.id), :target => "_blank" %>

+
<% else %> @@ -51,6 +53,7 @@ <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "104", :height => "104"), board_message_path(message.board, activity), :target => "_blank", :class => "fl sn-index-wximg" %> <% end %>

<%=link_to message.content.to_s.html_safe, board_message_path(message.board, activity), :target => "_blank" %>

+
<% end %> @@ -66,6 +69,7 @@ <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "104", :height => "104"), news_path(news), :target => "_blank", :class => "fl sn-index-wximg" %> <% end %>

<%=link_to news.description.to_s.html_safe, news_path(news), :target => "_blank" %>

+
<% end %> @@ -96,3 +100,12 @@ <% end %> <% end %> + + diff --git a/app/views/organizations/_org_subfield_rightM2.html.erb b/app/views/organizations/_org_subfield_rightM2.html.erb new file mode 100644 index 000000000..1482f64a2 --- /dev/null +++ b/app/views/organizations/_org_subfield_rightM2.html.erb @@ -0,0 +1,33 @@ +<% unless excellent_teachers.count == 0 %> +
+

<%= field.name %> + <%= link_to "更多", teachers_organization_path(@organization, :type => "famous", :org_subfield_id => field.id), :target => "_blank", :class => "more" %> +

+ <% excellent_teachers.each do |teacher| %> +
+ <%= link_to image_tag(url_to_avatar(teacher), :width => "60", :height => "60", :class => "sn-fl sn-avatar-circle", :style => "display:block;"), user_path(teacher), :alt => "用户头像", :target => '_blank' %> + +
+ <%=link_to teacher.try(:realname) ? teacher.try(:realname) :teacher.try(:login), user_path(teacher), :class => "sn-teacher-name sn-hidden", :title => '', :target => '_blank' %> + <%= teacher.my_workplace %>
+
+ <% unless teacher.my_blogs_count == 0 %> + 博客 <%= teacher.my_blogs_count %> + <% end %> + <% unless teacher.courses.count == 0 %> + 课程 <%= teacher.courses.count %> + <% end %> + <% unless teacher.my_students == 0 %> + 学生 <%= teacher.my_students %> + <% end %> +
+
+
+ <% end %> +
+ + +<% end %> + diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb new file mode 100644 index 000000000..f2523fb9f --- /dev/null +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -0,0 +1,59 @@ +<% org_teachers.each do |org_teacher| %> + <% school = School.where("id =?", org_teacher.school_id).first %> +
+
+
+ <%= link_to image_tag(url_to_avatar(org_teacher), :width => "90", :height => "90"), user_url_in_org(org_teacher), :alt => "用户头像" %> +
+
+
<%=link_to org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname), user_url_in_org(org_teacher) %> + <% unless school.nil? %> + <%= school.name %> + <% end %> + <% unless org_teacher.nil? %> + <%= org_teacher.technical_title %>
+ <% end %> +
+
<%= org_teacher.courses.count %>
+
课程数
+
+
+
+
<%= org_teacher.my_students %>
+
学生数
+
+
+
+
<%= org_teacher_resource_count(org_teacher) %>
+
资源数
+
+
+ <% if User.current.admin_of_org?(@organization) %> + <%= org_teacher.excellent_teacher==0?"设为名师":"取消设置" %> + + <% else %> + + + + + + <% end %> +
+
+
+<% end %> + + \ No newline at end of file diff --git a/app/views/organizations/_setting_excellent_teachers.html.erb b/app/views/organizations/_setting_excellent_teachers.html.erb new file mode 100644 index 000000000..ea6c1c9a6 --- /dev/null +++ b/app/views/organizations/_setting_excellent_teachers.html.erb @@ -0,0 +1,6 @@ +<% if @organization.allow_set_teachers && !org_subfield_had_created?(@organization, "Comptec") %> +
  • + + +
  • +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_show_students.html.erb b/app/views/organizations/_show_students.html.erb new file mode 100644 index 000000000..7f8d90203 --- /dev/null +++ b/app/views/organizations/_show_students.html.erb @@ -0,0 +1,36 @@ +
    +
    + + + +
    +
    +
    +
    +
    +
    +
    尹刚国防科学技术大学教授
    +
    +
    6000
    +
    课程数
    +
    +
    +
    +
    500
    +
    学生数
    +
    +
    +
    +
    8000
    +
    资源数
    +
    +
    + 添加 +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/organizations/_show_teachers.html.erb b/app/views/organizations/_show_teachers.html.erb new file mode 100644 index 000000000..355e5a731 --- /dev/null +++ b/app/views/organizations/_show_teachers.html.erb @@ -0,0 +1,22 @@ +
    +
    + <%= form_tag( url_for(:controller => 'organizations', :action => 'teacher_search'), + :remote => true , :method => 'get', :id => 'resource_search_form') do %> + + <%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none', :class => "teacher-search-icon fl" %> + + <% end %> + + + + +
    +
    +
    + <%=render 'organizations/org_teachers_list' %> +
    +
    \ No newline at end of file diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 4619ed337..f16e53b0e 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -8,7 +8,6 @@
  • 操作
  • - <% subfields.each do |field| %> <% if is_default_field?(field) %> <% name = get_default_name(field) %> @@ -32,10 +31,9 @@ <%= select( :name,:group_id, subfield_status_option_default, { :include_blank => false,:selected => field.status}, - { :onchange=>"update_status('#update_status_form_#{field.id}');", :id =>"field_status_id", :name => "status",:class=>"undis class-edit fl", :style => "width:56px;"}) %> + { :onchange=>"update_status('#update_status_form_#{field.id}');", :id =>"field_status_id", :name => "status",:class=>"undis class-edit fl", :style => "width:56px;"}) %> <% end %> <% end %> -
  • 默认
  • <%= field.hide==0?"隐藏":"可见" %> @@ -59,21 +57,20 @@
  • 新增
  • - <% if field.field_type == "Resource" %> - 列表 + <% if field.field_type == "Resource" || field.field_type == "Comptec" %> + 默认 <% else %> <%= form_tag({:controller => 'org_subfields', :action => 'update_status', :id => field.id,},:remote=>'true', :method => 'post', :id=>"update_status_form_#{field.id}", :class => 'query_form') do %>
    <%= select( :name,:group_id, subfield_status_option, - { :include_blank => false,:selected => field.status}, - {:onchange=>"update_status('#update_status_form_#{field.id}');", :id =>"field_status_id", :name => "status",:class=>"undis class-edit fl", :style => "width:56px;"}) %> + { :include_blank => false,:selected => field.status}, + { :onchange=>"update_status('#update_status_form_#{field.id}');", :id =>"field_status_id", :name => "status",:class=>"undis class-edit fl", :style => "width:56px;"}) %> <% end %> - <% end %>
  • -
  • <%= field.field_type == "Post" ? "帖子" : "资源" %>
  • +
  • <%= org_subfield_type field %>
  • - - - - +
    + <%= render :partial => 'organizations/setting_excellent_teachers' %> +
  • 新增
  • diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index f217f006e..d93ead84b 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -5,46 +5,46 @@ <% end %> <% if params[:show_homepage].nil? and User.current.logged? %> -
    -
    <%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %>
    - <% if params[:org_subfield_id].nil? %> -
    + <% end %> + <% end %> <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 and params[:org_subfield_id].nil? %> <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> - <%= render :partial => 'show_home_page', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> + <%= render :partial => 'show_home_page', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> <% end %> <% if @org_activities %> <%= render :partial => 'organizations/org_activities', @@ -67,3 +67,6 @@ + + + diff --git a/app/views/organizations/teacher_search.js.erb b/app/views/organizations/teacher_search.js.erb new file mode 100644 index 000000000..6b27f0998 --- /dev/null +++ b/app/views/organizations/teacher_search.js.erb @@ -0,0 +1 @@ +$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list')%>'); diff --git a/app/views/organizations/teachers.html.erb b/app/views/organizations/teachers.html.erb new file mode 100644 index 000000000..c368adef7 --- /dev/null +++ b/app/views/organizations/teachers.html.erb @@ -0,0 +1,39 @@ +
    +
    + <% if @type == "famous" %> + 名师列表 + <% else %> + <%= @field.name %> + <% end %> +
    +
    +
    + +
    + <%=render 'organizations/org_teachers_list', :org_teachers => @org_teachers %> +
    +
    + +
    +
    \ No newline at end of file diff --git a/app/views/organizations/teachers.js.erb b/app/views/organizations/teachers.js.erb new file mode 100644 index 000000000..cd7323a4a --- /dev/null +++ b/app/views/organizations/teachers.js.erb @@ -0,0 +1,3 @@ +$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list', :locals => {:org_teachers => @org_teachers})%>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @teachers_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); +$("#org_teacher_search").attr('href','<%= teachers_organization_path(@organization, :type => @type) %>'); \ No newline at end of file diff --git a/app/views/poll/_new_MC.html.erb b/app/views/poll/_new_MC.html.erb index e5f2a6b82..268ce18b1 100644 --- a/app/views/poll/_new_MC.html.erb +++ b/app/views/poll/_new_MC.html.erb @@ -5,7 +5,7 @@
    - +
    @@ -35,7 +35,7 @@ -<% end%> \ No newline at end of file +<% end%> + \ No newline at end of file diff --git a/app/views/poll/_new_MCQ.html.erb b/app/views/poll/_new_MCQ.html.erb index 43b41f95d..0fbb588c5 100644 --- a/app/views/poll/_new_MCQ.html.erb +++ b/app/views/poll/_new_MCQ.html.erb @@ -3,7 +3,7 @@
    - +
    @@ -33,7 +33,7 @@
    -<% end%> \ No newline at end of file +<% end%> + \ No newline at end of file diff --git a/app/views/poll/_new_mulit.html.erb b/app/views/poll/_new_mulit.html.erb index 8a2205760..d25d34542 100644 --- a/app/views/poll/_new_mulit.html.erb +++ b/app/views/poll/_new_mulit.html.erb @@ -3,7 +3,7 @@
    - +
    @@ -13,7 +13,7 @@
    -<% end%> \ No newline at end of file +<% end%> + \ No newline at end of file diff --git a/app/views/poll/_new_single.html.erb b/app/views/poll/_new_single.html.erb index 7588bf3b4..fe8e7b604 100644 --- a/app/views/poll/_new_single.html.erb +++ b/app/views/poll/_new_single.html.erb @@ -3,12 +3,12 @@
    - +
    -<% end%> \ No newline at end of file +<% end%> + \ No newline at end of file diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index e08b13033..73c783794 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -51,8 +51,8 @@ function chooseQuestionType(quest_type,quest_id){ } function add_MC(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>"); - $("#poll_questions_title").focus(); + $("#new_poll_question_new").html("<%= escape_javascript(render :partial => 'new_MC') %>"); + $("#poll_questions_title_new").focus(); } function insert_MC(quest_type,quest_num,quest_id){ @@ -94,7 +94,7 @@ function add_MC(){ ''+ ''+ '
    '+ ''+ '