diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index f8ca1d0e2..e1e99447d 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -24,7 +24,7 @@ class AdminController < ApplicationController before_filter :require_admin helper :sort helper :Users - helper :Settings + helper :Settings,SchoolHelper include SortHelper def index @@ -65,7 +65,17 @@ class AdminController < ApplicationController #管理员界面课程资源列表 def course_resource_list - @resource = Attachment.where(:container_type => 'Course') + + if params[:sort] == 'file_size' + @resource = Attachment.where(:container_type => 'Course').order("filesize desc") + elsif params[:sort] == 'file_upload' + @resource = Attachment.where(:container_type => 'Course').order("created_on desc") + elsif params[:sort] == 'file_download_times' + @resource = Attachment.where(:container_type => 'Course').order("downloads desc") + else + @resource = Attachment.where(:container_type => 'Course').order("created_on desc") + end + @resource = paginateHelper @resource,30 @page = (params['page'] || 1).to_i - 1 @@ -76,7 +86,17 @@ class AdminController < ApplicationController #管理员界面項目资源列表 def project_resource_list - @pro_resource = Attachment.where(:container_type => 'Project') + + if params[:sort] == 'file_size' + @pro_resource = Attachment.where(:container_type => 'Project').order("filesize desc") + elsif params[:sort] == 'file_upload' + @pro_resource = Attachment.where(:container_type => 'Project').order("created_on desc") + elsif params[:sort] == 'file_download_times' + @pro_resource = Attachment.where(:container_type => 'Project').order("downloads desc") + else + @pro_resource = Attachment.where(:container_type => 'Project').order("created_on desc") + end + @pro_resource = paginateHelper @pro_resource,30 @page = (params['page'] || 1).to_i - 1 @@ -92,9 +112,9 @@ class AdminController < ApplicationController case params[:format] when 'xml', 'json' - @offset, @limit = api_offset_and_limit({:limit => 15}) + @offset, @limit = api_offset_and_limit({:limit => 50}) else - @limit = 15#per_page_option + @limit = 50 #per_page_option end @status = params[:status] || 1 @@ -374,7 +394,13 @@ class AdminController < ApplicationController #组织 def organization - @organizations = Organization.all + @organizations = Organization.find_by_sql("SELECT * FROM organizations ORDER BY created_at DESC") + #@organizations = Organization.all.order("created_at desc") + @organization_count = @organizations.count + @organization_pages = Paginator.new @organization_count, 30, params['page'] || 1 + @organizations = paginateHelper @organizations,30 + + @page = (params['page'] || 1).to_i - 1 respond_to do |format| format.html end @@ -382,17 +408,14 @@ class AdminController < ApplicationController #学校列表 def schools - @school_name = params[:school_name] - if @school_name && @school_name != '' - @schools = School.where("name like '%#{@school_name}%'") - elsif @school_name.nil? - @schools = [] - else @school_name && @school_name == ' ' - @schools = School.where('1=1') - end + + @schools = School.find_by_sql("SELECT * FROM schools ORDER BY created_at DESC") @school_count = @schools.count - @school_pages = Paginator.new @school_count, 100, params['page'] || 1 - @schools = paginateHelper @schools,100 + + @school_pages = Paginator.new @school_count, 30, params['page'] || 1 + @schools = paginateHelper @schools,30 + + @page = (params['page'] || 1).to_i - 1 respond_to do |format| format.html end @@ -525,7 +548,8 @@ class AdminController < ApplicationController #作业 def homework - @homework = HomeworkCommon.order('end_time desc') + #@homework = HomeworkCommon.order('end_time desc') + @homework = HomeworkCommon.order( 'created_at desc ') @homework = paginateHelper @homework,30 @page = (params['page'] || 1).to_i - 1 respond_to do |format| diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 9853b4dc1..1dacffb6f 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -70,8 +70,8 @@ class AttachmentsController < ApplicationController def direct_download @attachment.increment_download send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'attachment' #inline can open in browser + :type => detect_content_type(@attachment), + :disposition => 'attachment' #inline can open in browser end def direct_download_history @@ -175,7 +175,7 @@ class AttachmentsController < ApplicationController @attachment = Attachment.find(params[:attachmentid]) if @attachment != nil filedense = params[:newtype].to_s - # d = Iconv.conv("unicodebig","utf-8",filedense) + # d = Iconv.conv("unicodebig","utf-8",filedense) if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public) @attachment.is_public = 1 else @@ -210,9 +210,9 @@ class AttachmentsController < ApplicationController if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) if stale?(:etag => thumbnail) send_file thumbnail, - :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'inline' + :filename => filename_for_content_disposition(@attachment.filename), + :type => detect_content_type(@attachment), + :disposition => 'inline' end else # No thumbnail for the attachment or thumbnail could not be created @@ -292,10 +292,10 @@ class AttachmentsController < ApplicationController respond_to do |format| if !@attachment.container.nil? && - (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) && - @attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && - @attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon) || - @attachment.container.is_a?(StudentWork)) + (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) && + @attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && + @attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon) || + @attachment.container.is_a?(StudentWork)) if @attachment.container.is_a?(News) format.html { redirect_to_referer_or news_path(@attachment.container) } elsif @attachment.container.is_a?(StudentWorksScore) @@ -327,25 +327,25 @@ class AttachmentsController < ApplicationController elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgDocumentComment) format.html {redirect_to_referer_or org_document_comment_path(@attachment.container)} else - if @project.nil? - format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } - else + if @project.nil? + format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } + else format.html { redirect_to_referer_or project_path(@project) } - end + end end format.js - end + end end def delete_homework - @bid = @attachment.container.bid - # Make sure association callbacks are called - container = @attachment.container - @attachment.container.attachments.delete(@attachment) - #if container.attachments.empty? - #container.delete - #end + @bid = @attachment.container.bid + # Make sure association callbacks are called + container = @attachment.container + @attachment.container.attachments.delete(@attachment) + #if container.attachments.empty? + #container.delete + #end respond_to do |format| format.html { redirect_to_referer_or respond_path(@bid) } @@ -594,7 +594,7 @@ class AttachmentsController < ApplicationController end end -private + private def find_project @attachment = Attachment.find(params[:id]) # Show 404 if the filename in the url is wrong @@ -608,7 +608,7 @@ private @attachment.container.board.course) @course = @attachment.container.board.course else - unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' + unless @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' @project = @attachment.project end end @@ -628,7 +628,7 @@ private def read_authorize if @attachment.container_type == "HomeworkAttach" || @attachment.container_type == 'Bid' - true + true #User.current.allowed_to?(:view_homework_attaches, @attachment.project) ? true : deny_access else @attachment.visible? ? true : deny_access @@ -654,14 +654,16 @@ private def renderTag @attachmentNew = Attachment.find(params[:attchmentId]) - respond_to do |format| + respond_to do |format| format.js end end def has_login - unless @attachment && @attachment.container_type == "PhoneAppVersion" - render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) + unless @attachment && @attachment.container_type == "Organization" + unless @attachment && @attachment.container_type == "PhoneAppVersion" + render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) + end end end end diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 7220eec27..0224a587d 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -71,18 +71,18 @@ class BlogCommentsController < ApplicationController @course.save redirect_to course_path(:id=>params[:course_id]) else - @article.children.delete - @article.delete + @article.children.destroy + @article.destroy redirect_to user_blogs_path(:user_id=>User.current) end else#如果是回复被删, if params[:course_id] #如果带了course_id过来了,那么这是要跳到课程大纲去的 - @article.delete + @article.destroy redirect_to syllabus_course_path(:id=>params[:course_id]) else root = @article.root - @article.delete + @article.destroy redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id) end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index c8518e8a3..a77346d89 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -70,31 +70,16 @@ class BoardsController < ApplicationController def show # 讨论区消息状态更新(已读和未读) if @project - query_forge_messages = @board.messages - query_forge_messages.each do |query_forge_message| - query = query_forge_message.forge_messages - query.each do |forge_message| - if User.current.id == forge_message.user_id - forge_message.update_attributes(:viewed => true) - end - end - end + ForgeMessage.where("user_id =? and project_id =? and viewed =?", User.current.id, @project.id, 0).update_all(:viewed => true) # 更新@消息为已读 - @project.boards.each do |board| - board.messages.each do |m| - User.current.at_messages.unviewed('Message', m.id).each {|x| x.viewed!} - end - end + # 注释掉这句是因为和上面的方法代码重复,一个类型的消息,已经更新就不需要再更新 + # @project.boards.each do |board| + # board.messages.each do |m| + # User.current.at_messages.unviewed('Message', m.id).each {|x| x.viewed!} + # end + # end elsif @course - query_course_messages = @board.messages - query_course_messages.each do |query_course_message| - query = query_course_message.course_messages - query.each do |course_message| - if User.current.id == course_message.user_id - course_message.update_attributes(:viewed => true) - end - end - end + CourseMessage.where("user_id =? and course_id =? and viewed =?", User.current.id, @course.id, 0).update_all(:viewed => true) end sort_init 'updated_on', 'desc' diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index dfa30915e..515b94392 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -852,7 +852,7 @@ class CoursesController < ApplicationController # return # end # 统计访问量 - @course.update_attribute(:visits, @course.visits.to_i + 1) + @course.update_column(:visits, @course.visits.to_i + 1) #更新创建课程消息状态 create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages.update_all(:viewed => true) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7ae1b85f8..cf94da8d9 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -458,10 +458,16 @@ class FilesController < ApplicationController if params[:in_project_toolbar] @in_project_toolbar = params[:in_project_toolbar] end - # 发送邮件 attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type]) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + # 发送邮件 Mailer.run.attachments_added(attachments[:files]) + # 生成动态 + attachments[:files].each do |file| + ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment") + end + # 更新资源总数, 根据上传的附件数累加 + @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil? end # end if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array) @@ -485,11 +491,6 @@ class FilesController < ApplicationController end end end - # 更新资源总数, 根据上传的附件数累加 - unless @project.project_score.nil? - @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) - end - # end # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", @@ -622,6 +623,36 @@ class FilesController < ApplicationController @attachtype = 0 @contenttype = 0 + respond_to do |format| + format.js + # format.html { + # redirect_to org_subfield_files_url(@org_subfield) + # } + end + # 组织添加附件,为了修改图片 + elsif params[:organization_id] + @organization = Organization.find(params[:organization_id]) + @addTag=false + # atttchment_type = 0为logo 1为banner + if params[:logo] + attachments = Attachment.attach_filesex(@organization, params[:attachments], false) + else + attachments = Attachment.attach_filesex(@organization, params[:attachments], true) + end + # TODO: 临时用 nyan + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [Organization.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@organization.id)] + + show_attachments @containers + @tag_list = attachment_tag_list @all_attachments + @attachtype = 0 + @contenttype = 0 + respond_to do |format| format.js # format.html { diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 17111b3f3..b1d16debb 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -37,16 +37,6 @@ class MessagesController < ApplicationController # Show a topic and its replies def show -=begin - if @course - topic_id = params[:r]?params[:r]:params[:id] - parent_id = params[:id] - url = course_boards_path(@course,:topic_id => topic_id,:parent_id=>parent_id); - redirect_to url - return; - end -=end - @isReply = true page = params[:page] # Find the page of the requested reply @@ -54,16 +44,7 @@ class MessagesController < ApplicationController offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i]) page = 1 + offset / REPLIES_PER_PAGE end - @reply_count = @topic.children.count - # @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page - # @replies = @topic.children. - # includes(:author, :attachments, {:board => :project}). - # reorder("#{Message.table_name}.created_on DESC"). - # limit(@reply_pages.per_page). - # offset(@reply_pages.offset). - # all - @reply = Message.new(:subject => "RE: #{@message.subject}") if @course messages_replies = @topic.children. diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index ba4c1f18f..661073cdc 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -11,7 +11,7 @@ class OrgSubfieldsController < ApplicationController sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" if SubfieldSubdomainDir.find_by_sql(sql).count == 0 - SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir]) + SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase) end end @subfield.update_attributes(:field_type => params[:field_type]) @@ -130,6 +130,12 @@ class OrgSubfieldsController < ApplicationController @organization = @org_subfield.organization end + def update_status + @subfield = OrgSubfield.find(params[:id]) + @organization = Organization.find(@subfield.organization_id) + @subfield.update_attributes(:status => params[:status]) + end + def show_attachments obj @attachments = [] obj.each do |container| diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 239253d82..a24bcd9a4 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -28,18 +28,25 @@ class OrganizationsController < ApplicationController helper :project_score helper :issues include UsersHelper - before_filter :find_organization, :only => [:show, :members, :apply_subdomain] + before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout] layout 'base_org' def index end + + def new @organization = Organization.new render :layout => 'new_base' end def edit - @organization = Organization.find(params[:id]) + # @organization = Organization.find(params[:id]) + begin + @organization = Organization.where("id =?", params[:id]) + ensure + render_404 + end end def destroy @@ -56,6 +63,7 @@ class OrganizationsController < ApplicationController @organization.description = params[:organization][:description] @organization.is_public = params[:organization][:is_public] @organization.allow_guest_download = params[:organization][:allow_guest_download] == '1' ? 1 : 0 + @organization.show_mode = 0 @organization.creator_id = User.current.id member = OrgMember.new(:user_id => User.current.id) @@ -67,50 +75,170 @@ class OrganizationsController < ApplicationController end def show - if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) - @organization = Organization.find(params[:id]) - # 统计访问量 - @organization.update_attribute(:visits, @organization.visits.to_i + 1) - if params[:org_subfield_id] - @org_subfield = OrgSubfield.find(params[:org_subfield_id]) - @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 - @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) + # 组织新类型 show_mode:判断标准 1为新类型,0为旧 + if @organization.show_mode == 1 && params[:org_subfield_id].nil? && params[:list] .nil? + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + # REDO:时间紧,暂时先这样 + @org_logo_attchment = Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 0 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first + @org_banner_attchment = Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 1 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first + + @subfield_content = @organization.org_subfields.order("priority") + @organization = Organization.find(params[:id]) + # 统计访问量 + @organization.update_column(:visits, @organization.visits.to_i + 1) + + # @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + # @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + # @org_acts = 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) + + 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) + project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 + course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + @project_acts = get_project_activities_org @organization, project_ids + @course_acts = get_course_activities_org @organization, course_ids + #@org_acts = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc') + #@project_acts = OrgActivity.where("(container_id =? and container_type =?) " + + # "or (container_type ='Project' and org_act_type in ('Issue','Message') and container_id in (#{project_ids.join(',')})) ", + # @organization.id, 'Organization').order('updated_at desc').limit(8) + + #@course_acts = OrgActivity.where("(container_id =? and container_type =?) " + + # "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", + # @organization.id, 'Organization').order('updated_at desc').limit(8) + + + + # 项目两种动态 + #@project_acts = get_project_activities_org @organization + + # 课程动态 + #@project_acts_issues = get_project_activities_org @organization + #@course_acts = get_course_activities_org @organization + + render :layout => 'base_org_newstyle' 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) - project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 - course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 0 - course_types = "('Message','News','HomeworkCommon','Poll','Course')" - case params[:type] - when nil - @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + - "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ - "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", - @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - when 'project_issue' - @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'project_message' - @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'org' - @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_homework' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_news' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_message' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_poll' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - end - end - @page = params[:page] ? params[:page].to_i : 1 - respond_to do |format| - format.html - format.js + render_403 end else - render_403 + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @organization = Organization.find(params[:id]) + # 统计访问量 + @organization.update_column(:visits, @organization.visits.to_i + 1) + if params[:org_subfield_id] + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + @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) + 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) + project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 + course_ids = (@organization.courses.map(&:id)-shield_course_ids) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + case params[:type] + when nil + @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + + "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_issue' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_message' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'org' + @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_homework' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_news' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_message' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_poll' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + end + end + @page = params[:page] ? params[:page].to_i : 1 + respond_to do |format| + format.html + format.js + end + else + render_403 + end end + + end + + def get_project_message_activities_org org + project_ids = org.projects.map{|project| project.id}.join(",") + unless project_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'Message' order by updated_at desc limit 2;") + else + project_acts = nil + end + end + + def get_project_issue_activities_org org + project_ids = org.projects.map{|project| project.id}.join(",") + unless project_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;") + end + + # 获取整过项目的动态 + def get_project_activities_org org, project_ids + unless project_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids.join(',')}) and container_type = 'project' + and org_act_type in ('Message', 'Issue') order by updated_at desc limit 8;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids}) and container_type = 'project' and org_act_type = 'issue' order by updated_at desc limit 4;") + end + + # 获取整过课程的动态 + def get_course_activities_org org, course_ids + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids.join(',')}) and container_type = 'course' + and org_act_type in ('HomeworkCommon', 'Poll', 'Message', 'News', 'Course') order by updated_at desc limit 8;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' order by updated_at desc limit 5;") + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;") + end + + def get_course_homework_activities_org org + course_ids = org.courses.map{|course| course.id}.join(",") + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' order by updated_at desc limit 5;") + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'HomeworkCommon' order by updated_at desc limit 1;") + end + + def get_course_message_activities_org org + course_ids = org.courses.map{|course| course.id}.join(",") + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'Message' order by updated_at desc limit 1;") + else + project_acts = nil + end + end + + def get_course_news_activities_org org + course_ids = org.courses.map{|course| course.id}.join(",") + unless course_ids.blank? + project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'News' order by updated_at desc limit 1;") + else + project_acts = nil + end + #project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids}) and container_type = 'course' and org_act_type = 'News' order by updated_at desc limit 1;") end def update @@ -120,12 +248,17 @@ 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.show_mode = params[:show_mode] #@organization.name = params[:organization][:name] @organization.save respond_to do |format| + if @organization.show_mode == 1 + format.html { redirect_to organization_path(@organization)} + else format.html { redirect_to setting_organization_path(@organization)} end end + end def check_uniq @check = false; @@ -157,11 +290,6 @@ class OrganizationsController < ApplicationController end end - - def clear_org_avatar_temp - - end - def set_homepage @org = Organization.find(params[:id]) @org.home_id = params[:home_id] @@ -224,8 +352,8 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.name like '#{condition}'"+ - "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id})" + sql = "select courses.* from courses inner join members on courses.id = members.course_id where members.user_id = #{User.current.id} and courses.is_public = 1 and courses.name like '#{condition}'"+ + "and courses.id not in (select distinct org_courses.course_id from org_courses where org_courses.organization_id = #{@organization.id}) and courses.is_delete=0" #user_courses = Course.find_by_sql(sql) @courses = Course.find_by_sql(sql) # @added_course_ids = @organization.courses.map(&:id) @@ -268,8 +396,8 @@ class OrganizationsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.name like '#{condition}'" + - " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id})" + sql = "select projects.* from projects inner join members on projects.id = members.project_id where members.user_id = #{User.current.id} and projects.status != 9 and projects.is_public = 1 and projects.name like '#{condition}'" + + " and projects.id not in (select org_projects.project_id from org_projects where organization_id = #{@organization.id}) and status=1" #user_projects = Course.find_by_sql(sql) @projects = Course.find_by_sql(sql) # @added_course_ids = @organization.projects.map(&:id) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2ced977be..113e37af3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -295,34 +295,32 @@ class ProjectsController < ApplicationController def show # 更新消息为已读 update_message_status(User.current, @project) + # over if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end # 统计访问量 - @project.update_attribute(:visits, @project.visits.to_i + 1) + @project.update_column(:visits, @project.visits + 1) + # over @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) @page = params[:page] ? params[:page].to_i + 1 : 0 # 根据私密性,取出符合条件的所有数据 if User.current.member_of?(@project) || User.current.admin? case params[:type] when nil - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo', 'Attachment')",@project).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'Project', 'Attachment')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'issue' - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'news' - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'message' - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'attachment' - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Attachment'",@project).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Attachment'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) end else - @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public - = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc") - .page(params['page'|| 1]).per(10); + @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10); end - boards = @project.boards.includes(:last_message => :author).all - @topic_count = @project.boards.count # 根据对应的请求,返回对应的数据 respond_to do |format| format.html @@ -560,18 +558,9 @@ class ProjectsController < ApplicationController end def update_message_status(user, project) - project_invite_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =?", user, project, "ProjectInvite") - project_invite_messages.each do |project_invite_message| - project_invite_message.update_attribute(:viewed, true) - end - #更新被加入项目消息的viewed字段 - join_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "JoinProject") - join_project_messages.each do |join_project| - join_project.update_attribute(:viewed, true) - end - #更新被移出项目消息的viewed字段 - remove_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "RemoveFromProject") - remove_project_messages.update_all(:viewed => true) + # 更新加入项目消息 + project__messages = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'JoinProject', 'RemoveFromProject') and user_id =? and project_id =? ", user, project) + project__messages.update_all(:viewed => true) unless project__messages.blank? end def message_invite(message_id, key) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index a698823e5..36a48f2a3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -5,14 +5,14 @@ class StudentWorkController < ApplicationController include ApplicationHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:program_test_ex,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] before_filter :is_logged, :only => [:index] - ### + ### def program_test is_test = params[:is_test] == 'true' resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')} @@ -49,13 +49,127 @@ class StudentWorkController < ApplicationController resultObj[:time] = student_work_test.created_at.to_s(:db) resultObj[:index] = student_work.student_work_tests.count end - end end render :json => resultObj end + #行尾空格替换成□ + def space_replace_1(str) + for i in 0 .. str.size + tChar = str[i] + if tChar != ' ' && tChar != "\n" + sFlag = false + eFlag = false + elsif tChar == ' ' && sFlag == false + tStart = i + sFlag = true + elsif tChar == "\n" + tEnd = i - 1 + if sFlag == true + for j in tStart .. tEnd + str[j] = "□" + end + sFlag = false + end + end + end + end + +#由于负载问题 不要使用全局变量 +#根据传入的tIndex确定是第几次测试 +#之后如果觉得很卡 可以改成将结果传回JS再以参数形式传回来 + def program_test_ex + is_test = params[:is_test] == 'true' + resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T'),tseq:1,tcount:1,testid:1} #保存每测试一次返回的结果 + + student_work = find_or_save_student_work(is_test) + + resultObj[:tcount] = @homework.homework_tests.size + + unless student_work + resultObj[:status] = 100 + else + if @homework.homework_type == 2 && @homework.homework_detail_programing + #找到第index个测试的输入输出 + index = params[:tIndex].to_i + resultObj[:tseq] = index + test = @homework.homework_tests[index - 1] + + #请求测试 + result = test_realtime_ex(test, params[:src]) + + if result["status"].to_i != -2 + #result["results"].first['output'] = result["results"].first['output'].gsub(" ","□") + #result["results"].first['result'] = result["results"].first['result'].gsub(" ","□") + space_replace_1(result["results"].first['output']) + space_replace_1(result["results"].first['result']) + end + + logger.debug result + + #-1 默认值 0全部正确并结束 2 超时 -2 编译错误 + resultObj[:status] = -1 + resultObj[:results] = result["results"].first #本次测试结果 + resultObj[:error_msg] = result["error_msg"] #编译错误时的信息 + + if result["status"].to_i == -2 #编译错误 + resultObj[:results] = result["error_msg"] + resultObj[:status] = -2 + elsif result["results"][0]["status"].to_i == 2 + resultObj[:status] = 2 + end + + unless student_work.save + resultObj[:status] = 200 + else + student_work.name = params[:title] + student_work.description = params[:src] + + if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") + student_work.late_penalty = @homework.late_penalty + else + student_work.late_penalty = 0 + end + + #每次从数据库取出上次的结果加上本次的结果再存入数据库 + status = result["status"] + if index == 1 + student_work_test = student_work.student_work_tests.build(status: status, + results: [resultObj[:results]],src: params[:src]) + student_work_test.save! + resultObj[:testid] = student_work_test.id + else + #先从数据库取出result + student_work_test = StudentWorkTest.find(params[:testid]) + results = student_work_test.results + results << resultObj[:results] + student_work_test.results = results + student_work_test.status = (result["status"] != 0 ? result["status"] : student_work_test.status) + student_work_test.save! + status = student_work_test.status + resultObj[:testid] = student_work_test.id + end + + #超时或编译错误则直接返回了并存入数据库 + if resultObj[:status] == 2 || resultObj[:status] == -2 || index == @homework.homework_tests.size + if status == 0 + resultObj[:status] = 0 + end + student_work.save! + resultObj[:time] = student_work_test.created_at.to_s(:db) + resultObj[:index] = student_work.student_work_tests.count + end + + #渲染返回结果 + render :json => resultObj + end + end + end + end + + def index # 作业消息状态更新 @homework.course_messages.each do |homework_message| @@ -63,6 +177,13 @@ class StudentWorkController < ApplicationController homework_message.update_attributes(:viewed => true) if homework_message.viewed == 0 end end + + #修改作品提示消息更新 + student_work_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, StudentWork.name, 0) + student_work_messages.each do |message| + message.update_attribute(:viewed, true) + end + # 作品打分消息状态更新 studentworks_scores = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @homework.course, "StudentWorksScore", 0) studentworks_scores.each do |studentworks_score| @@ -230,12 +351,12 @@ class StudentWorkController < ApplicationController render_403 return end - @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count end @score = @b_sort == "desc" ? "asc" : "desc" - + # 消息传过来的ID + @message_student_work_id = params[:student_work_id] respond_to do |format| format.js format.html @@ -369,6 +490,8 @@ class StudentWorkController < ApplicationController @work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@work) if @work.save + #如果学生作品被打分后修改,应该给老师提示 + send_message_to_teacher(@work) if @homework.homework_type == 3 @student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0) @@ -457,7 +580,7 @@ class StudentWorkController < ApplicationController end end end - redirect_to user_homeworks_user_path(User.current.id) + redirect_to student_homeworks_user_path(User.current.id) end def retry_work @@ -987,7 +1110,6 @@ class StudentWorkController < ApplicationController student_work end - def test_realtime(student_work, src) url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json" @@ -1011,6 +1133,28 @@ class StudentWorkController < ApplicationController JSON.parse(res.body) end + def test_realtime_ex(test, src) + url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json" + + factor = [] + factor << {input: test.input, output: test.output} + + solutions = { + src:src, + language:@homework.homework_detail_programing.language, + factor: factor + } + uri = URI(url) + body = solutions.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + JSON.parse(res.body) + end + #成绩计算 def set_final_score homework,student_work if homework && homework.homework_detail_manual diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9039fd041..e59e33516 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -119,49 +119,46 @@ class UsersController < ApplicationController # @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count case params[:type] when nil + # 系统消息为管理员发送,我的消息中包含有系统消息 @message_alls = [] - messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user, "SystemMessage", "SystemMessage").order("created_at desc") + messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc") messages.each do |message_all| @message_alls << message_all.message end when 'unviewed' @message_alls = [] - messages = MessageAll.where("user_id =?", @user).order("created_at desc") + messages = MessageAll.where("user_id =?", @user.id).includes(:message).order("created_at desc") messages.each do |message_all| # 在点击或者刷新消息列表后未读的消息存放在数组 if message_all.message_type != "SystemMessage"&& !message_all.message.nil? && message_all.message.viewed == 0 @message_alls << message_all.message end end - #课程相关消息 when 'homework' - @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?", @user).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?", @user.id).order("created_at desc") when 'course_message' - @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user.id).order("created_at desc") when 'course_news' # 课程通知包含发布的通知和回复的通知 - @message_alls = CourseMessage.where("course_message_type in (?, ? ,?)", "News", "Comment", "Course").where("user_id =?", @user).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =?", @user.id).order("created_at desc") when 'poll' - @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") - + @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user.id).order("created_at desc") #项目相关消息 when 'issue' - @message_alls = ForgeMessage.where("forge_message_type =? or forge_message_type =?" , "Issue", "Journal").where("user_id=?", @user).order("created_at desc") + @message_alls = ForgeMessage.where("forge_message_type in ('Issue', 'Journal') and user_id =?" , @user.id).order("created_at desc") when 'forge_message' - @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") + @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user.id).order("created_at desc") when 'forge_news' - @message_alls = ForgeMessage.where("forge_message_type in (?,?) and user_id =?", "News", "Comment", @user).order("created_at desc") + @message_alls = ForgeMessage.where("forge_message_type in (?,?) and user_id =?", "News", "Comment", @user.id).order("created_at desc") when 'apply' - @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject', 'JoinProject', 'RemoveFromProject') and user_id =?", @user).order("created_at desc") - + @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject', 'JoinProject', 'RemoveFromProject') and user_id =?", @user.id).order("created_at desc") #贴吧消息 when 'forum' - @message_alls = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") - + @message_alls = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user.id).order("created_at desc") #用户留言 when 'user_feedback' - @message_alls = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + @message_alls = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user.id).order("created_at desc") else render_404 return @@ -717,6 +714,7 @@ class UsersController < ApplicationController end student_work.save + send_message_to_teacher(student_work) homework.update_attributes(:updated_at => Time.now) update_course_activity(homework.class,homework.id) update_user_activity(homework.class,homework.id) @@ -838,8 +836,8 @@ class UsersController < ApplicationController render_403 return end - user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} + user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} + user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 @@ -888,11 +886,11 @@ class UsersController < ApplicationController def user_ref_resource_search search = params[:search].to_s.strip.downcase if(params[:type].blank? || params[:type] == "1") #全部 - user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 + user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','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 (filename like '%#{search}%') ").order("created_on desc") elsif params[:type] == "2" #课程资源 - user_course_ids = User.current.courses.map { |c| c.id} + user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") elsif params[:type] == "3" #项目资源 @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") @@ -1209,21 +1207,19 @@ class UsersController < ApplicationController def show # 统计访问量 - unless User.current == @user - @user.update_attribute(:visits, @user.visits.to_i + 1) - end + @user.update_column(:visits, @user.visits.to_i + 1) unless User.current == @user #更新用户申请成为课程老师或教辅消息的状态 if params[:course_id] != nil join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) join_course_messages.update_all(:viewed => true) end - shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id) - shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) + shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" - course_types = "('Message','News','HomeworkCommon','Poll','Course')" + course_types = "('Message','News','HomeworkCommon','Poll','Course','JournalsForMessage')" project_types = "('Message','Issue','ProjectCreateInfo')" principal_types = "JournalsForMessage" if params[:type].present? @@ -1236,6 +1232,8 @@ class UsersController < ApplicationController @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10) when "course_poll" @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Poll'").order('updated_at desc').limit(10).offset(@page * 10) + when "course_journals" + @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'JournalsForMessage'").order('updated_at desc').limit(10).offset(@page * 10) when "project_issue" @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page * 10) when "project_message" @@ -1253,7 +1251,13 @@ class UsersController < ApplicationController end else # @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10) - blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" + # blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" + # 减少数据库交互 + watched_user_ids = User.watched_by(@user.id).count == 0 ? " " : ("," + User.watched_by(@user.id).map{|u| u.id.to_s }.join(',')) + user_ids = "(" + @user.id.to_s + watched_user_ids + ")" + watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") + blog_ids = "(" + watched_user_blog_ids + ")" + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + @@ -1575,16 +1579,14 @@ class UsersController < ApplicationController # 上传用户资源 def user_resource_create - user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} + user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} + user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id} @user = User.find(params[:id]) # 保存文件 attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true) @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.id} - user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 @@ -1614,8 +1616,10 @@ class UsersController < ApplicationController @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end end + @status = params[:status] @type = params[:type] + @path = user_resource_user_path(User.current, :type => @type) @limit = 25 @is_remote = true @atta_count = @attachments.count @@ -1673,6 +1677,7 @@ class UsersController < ApplicationController end @status = params[:status] @type = params[:type] + @path = user_resource_user_path(User.current, :type => @type) @limit = 25 @is_remote = true @atta_count = @attachments.count @@ -1697,6 +1702,7 @@ class UsersController < ApplicationController .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 } end @search = params[:search] + @type = params[:type] #这里仅仅是传递需要发送的资源id @send_id = params[:send_id] @send_ids = params[:checkbox1] || params[:send_ids] @@ -1715,6 +1721,7 @@ class UsersController < ApplicationController @projects = @user.projects.visible end @search = params[:search] + @type = params[:type] #这里仅仅是传递需要发送的资源id @send_id = params[:send_id] @send_ids = params[:checkbox1] || params[:send_ids] #搜索的时候 和 直接 用表格提交的时候的send_ids @@ -1811,11 +1818,41 @@ class UsersController < ApplicationController else @flag = false end + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_project_ids = User.current.projects.map {|p| p.id} user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc") + if(params[:type].blank? || params[:type] == "1") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end + elsif params[:type] == "6" # 公共资源 + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end + end @type = params[:type] @limit = 25 + @path = user_resource_user_path(User.current, :type => @type) @user = User.current @is_remote = true @atta_count = @attachments.count @@ -1922,11 +1959,42 @@ class UsersController < ApplicationController else @flag=true end + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_project_ids = User.current.projects.map {|p| p.id} user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc") + if(params[:type].blank? || params[:type] == "1") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end + elsif params[:type] == "6" # 公共资源 + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end + end + @status = params[:status] @type = params[:type] @limit = 25 + @path = user_resource_user_path(User.current, :type => @type) @user = User.current @is_remote = true @atta_count = @attachments.count @@ -2020,11 +2088,41 @@ class UsersController < ApplicationController else @flag=true end + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_project_ids = User.current.projects.map {|p| p.id} user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc") + if(params[:type].blank? || params[:type] == "1") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end + elsif params[:type] == "6" # 公共资源 + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end + end @type = params[:type] @limit = 25 + @path = user_resource_user_path(User.current, :type => @type) @user = User.current @is_remote = true @atta_count = @attachments.count @@ -2367,7 +2465,7 @@ class UsersController < ApplicationController # 获取我的资源 def get_my_resources author_id, user_course_ids, user_project_ids, order, score - 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')) "+ + 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}") end @@ -2473,15 +2571,15 @@ class UsersController < ApplicationController # 资源库 分为全部 课程资源 项目资源 附件 def user_resource - @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" - @score = @b_sort == "desc" ? "asc" : "desc" # 别人的资源库是没有权限去看的 if User.current.id.to_i != params[:id].to_i render_403 return end - user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.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} + user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 @@ -2538,8 +2636,8 @@ class UsersController < ApplicationController @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.id} - user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} + user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} + user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) @@ -2563,6 +2661,10 @@ class UsersController < ApplicationController end def import_resources_search + if User.current.id.to_i != params[:id].to_i + render_403 + return + end @resource_id = params[:mul_id] @resource_type = params[:mul_type] @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @@ -2571,15 +2673,10 @@ class UsersController < ApplicationController @switch_search = params[:name].nil? ? " " : params[:name] search = "%#{@switch_search.strip.downcase}%" # 别人的资源库是没有权限去看的 - if User.current.id.to_i != params[:id].to_i - render_403 - return - end - @resource_id = params[:mul_id] if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} + user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} + user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } # user_org_ids = User.current.organizations.map {|o| o.id} @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search) elsif params[:type] == "6" # 公共资源 @@ -2659,8 +2756,8 @@ class UsersController < ApplicationController @user = User.current @switch_search = params[:search].nil? ? " " : params[:search] search = "%#{@switch_search.strip.downcase}%" - user_course_ids = User.current.courses.map {|c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} + user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} + user_project_ids = User.current.projects.map {|p| p.status != 9 && p.id } if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部 if params[:status] == "2" @attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search) @@ -2718,6 +2815,7 @@ class UsersController < ApplicationController name = "%"+name+"%" @orgs = User.current.organizations.where("name like ?", name) @user = User.current + @type = params[:type] respond_to do |format| format.html {render :layout => 'static_base'} format.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3a5cdb1a1..828123675 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -764,7 +764,7 @@ module ApplicationHelper # 判断版本库是否初始为gitlab def rep_is_gitlab?(project) - rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab") + rep = project.repositories.where("type =?", "Repository::Gitlab") return rep.blank? ? true :false end @@ -2104,6 +2104,8 @@ module ApplicationHelper attachment.container.board.course course = attachment.container.board.course candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) + elsif attachment.container.class.to_s=="Organization" + candown = true elsif attachment.container.class.to_s=="HomeworkAttach" candown = true elsif attachment.container.class.to_s=="StudentWorksScore" @@ -2137,6 +2139,20 @@ module ApplicationHelper end + #如果学生作品被打分后修改,应该给老师提示 + def send_message_to_teacher student_work + if StudentWork === student_work + if student_work.student_works_scores.any? + course = student_work.homework_common.course + course.members.map(&:user_id).uniq.each do|user_id| + if User.find(user_id).allowed_to?(:as_teacher, course) + student_work.course_messages << CourseMessage.new(:user_id => user_id, :course_id => course.id, :viewed => false, :status => 1) + end + end + end + end + end + private def wiki_helper @@ -3044,3 +3060,7 @@ def is_default_field? field (field.name == 'activity' || field.name == 'course' || field.name == 'project') && field.field_type == 'default' end +def host_with_protocol + return Setting.protocol + "://" + Setting.host_name +end + diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 37c7deb4c..64531a6f4 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -24,40 +24,20 @@ module CoursesHelper def find_excelletn_course keywords, current_course # 获取tag匹配结果ID a_tags = [] - # kc = keywords.to_a - Course.visible.where("is_excellent =? and is_public =?", 1, 1).each do |ec| + Course.where("is_excellent =? and is_public =?", 1, 1).each do |ec| if ec.tags.any?{|value| current_course.name.include?(value.to_s)} a_tags << ec.id end end - # sql = "SELECT distinct c.* FROM `courses` c, tags t, taggings ts where t.id = ts.tag_id and ts.taggable_id = c.id and c.is_excellent = 1 and is_delete = 0 and - # ts.taggable_type = 'Course' and t.name like '%#{keywords}%'" - # a_tags = Course.find_by_sql(sql).select{|course| course.is_public ==1 unless User.current.member_of_course?(course)} - # 通过elastic结果获取精品课程 - a_courses = [] - #courses = Course.search(keywords) - #courses.each do |c| - # a_courses << c.id - #end - a_courses << a_tags unless a_tags.length == 0 # 课程本身不能搜索显示自己 - excellent_ids = a_courses.flatten.uniq.delete_if{|i| i == current_course.id} - limit = 5 - excellent_ids.length.to_i + excellent_ids = a_tags.uniq.delete_if{|i| i == current_course.id} sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id - and c.is_excellent =1 and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;" - default_ecourse_ids = Course.find_by_sql(sql).flatten - # REDO:时间紧,待优化 - default_ids =[] - default_ecourse_ids.each do |de| - default_ids << de.id - end - default_ids = default_ids - excellent_ids - #default_ecourse = Course.where("id is not in (?)", ids).find_by_sql(sql).flatten.delete_if{|i| i == current_course.id}.flatten - arr_result = excellent_ids << default_ids - arr_result = arr_result.flatten.first(5) - return arr_result - # 过滤条件:精品课程、本身不在搜索范围 - #e_courses = Course.where("is_excellent =? and id in (?)",1, arr_result).where("id !=?", current_course.id) + and (c.is_excellent =1 or c.excellent_option =1) and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;" + default_ids = Course.find_by_sql(sql).flatten.map { |c| c.id } + excellent_ids << default_ids.flatten + arr_result = excellent_ids.flatten.uniq.first(5) + excellent_courses = Course.find(arr_result) + return excellent_courses end # 判断精品课程是否可见,非课程成员无法查看私有课程 @@ -258,7 +238,7 @@ module CoursesHelper # 学生人数计算 # add by nwb def studentCount course - course ? course.student.count.to_s : 0#course.student.count + course ? course.student.count.to_i : 0#course.student.count end #课程成员数计算 @@ -293,12 +273,17 @@ module CoursesHelper def searchTeacherAndAssistant project #searchPeopleByRoles(project, TeacherRoles) members = [] - project.members.each do |m| + project.members.includes(:user).each do |m| members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) end members end + def TeacherAndAssistantCount course + students_count = course.student.count + number = course.members.count - students_count + end + def search_student_in_group(project, course_group_id) #searchPeopleByRoles(project, StudentRoles) members = [] @@ -766,7 +751,7 @@ module CoursesHelper #加入课程、退出课程按钮 def join_in_course_header(course, user, options=[]) if user.logged? - joined = course.members.map{|member| member.user_id}.include? user.id + joined = course.members.includes(:user).map{|member| member.user_id}.include? user.id text = joined ? l(:label_course_exit_student) : l(:label_course_join_student) url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id) method = joined ? 'delete' : 'post' diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index bef6b580c..b161e29e9 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -111,9 +111,9 @@ module IssuesHelper def principals_options_for_isuue_list(project) if User.current.member_of?(project) - project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0]) + project.members.includes(:user).order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["<< #{l(:label_me)} >>", User.current.id]).unshift(["指派给", 0]) else - project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["指派给", 0]) + project.members.includes(:user).order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["指派给", 0]) end end diff --git a/app/helpers/org_member_helper.rb b/app/helpers/org_member_helper.rb index fd70a0516..e16051eaf 100644 --- a/app/helpers/org_member_helper.rb +++ b/app/helpers/org_member_helper.rb @@ -9,7 +9,7 @@ module OrgMemberHelper principals = paginateHelper scope,10 s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| - link_to text, org_member_autocomplete_org_member_index_path(parameters.merge(:q => params[:q],:flag => true,:org=> org, :format => 'js')), :remote => true + link_to text, host_with_protocol + "/org_member/org_member_autocomplete?" + parameters.merge(:q => params[:q],:flag => true,:org=> org, :format => 'js').to_query, :remote => true } s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) end diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 69c355313..4faa802a5 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,6 +1,7 @@ # encoding: utf-8 module OrganizationsHelper include ApplicationHelper + include FilesHelper def find_user_not_in_current_org_by_name org @@ -28,4 +29,48 @@ module OrganizationsHelper end end + def get_message_org(org_id, field_id) + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and org_subfield_id = #{field_id} and parent_id is null order by updated_at desc limit 8;") + end + + def get_message_reply_org(org_id, ids) + # OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id is not null order by updated_at desc limit 1;") + OrgDocumentComment.find_by_sql("SELECT * FROM org_document_comments where organization_id = #{org_id} and parent_id in (#{ids}) order by updated_at desc limit 1;") + end + + def get_attach_org(field_id) + Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") + end + + def get_attach_org2(field) + org_attachments = field.attachments + attachments = User.current.admin? ? org_attachments : visable_attachemnts(org_attachments) + return attachments.sort_by{|x| x.created_on}.reverse.first(6) + # Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") + end + + # 从内容中获取路径 + def get_image_path_from_content content + r = Regexp.new(/src="\/files\/uploads\/image(.+?)"/) + if r.match(content).nil? + image_path = nil + else + image_path = r.match(content)[1] + end + end + + #排列下拉框 + def subfield_status_option + type = [] + option1 = [] + option1 << "列表" + option1 << "1" + type << option1 + option2 = [] + option2 << "图片" + option2 << "0" + type << option2 + type + end + end diff --git a/app/helpers/school_helper.rb b/app/helpers/school_helper.rb index 0528cb7ac..075d2b039 100644 --- a/app/helpers/school_helper.rb +++ b/app/helpers/school_helper.rb @@ -1,2 +1,15 @@ module SchoolHelper + def schoolMember_num school + count = student_num(school) + teacher_num(school) + count.to_s + end + + def student_num school + UserExtensions.find_by_sql("SELECT * FROM user_extensions WHERE occupation = '#{school.name}' AND identity = '1'").count + end + + def teacher_num school + UserExtensions.find_by_sql("SELECT * FROM user_extensions AS ue, schools AS s WHERE ue.school_id = s.id AND s.name = '#{school.name}' AND ue.identity = '0'").count + end + end diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index df5c872f8..4e11e153e 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -130,7 +130,7 @@ module StudentWorkHelper def revise_attachment_status homework, attach date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d") status = "" - if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < date)) + if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time.to_s < date)) status = "此时其他同学作品已公开" else status = "此时其他同学作品尚未公开" diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 714da9920..754bd4dee 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -23,6 +23,7 @@ class Attachment < ActiveRecord::Base belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'" belongs_to :org_subfield, foreign_key: 'container_id', conditions: "attachements.container_type = 'OrgSubfield'" + belongs_to :organization, foreign_key: 'container_id', conditions: "attachements.container_type = 'Organization'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" @@ -90,7 +91,7 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_save :act_as_course_activity,:act_as_forge_activity + after_save :act_as_course_activity after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score diff --git a/app/models/organization.rb b/app/models/organization.rb index 248783a26..427cd4c10 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -8,6 +8,8 @@ class Organization < ActiveRecord::Base has_many :org_courses, :dependent => :destroy has_many :org_subfields, :dependent => :destroy has_many :users, :through => :org_members + has_many :files + acts_as_attachable validates_uniqueness_of :name after_create :save_as_org_activity, :add_default_subfields diff --git a/app/models/principal.rb b/app/models/principal.rb index dd376f609..0c87ec0c6 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -42,9 +42,9 @@ class Principal < ActiveRecord::Base if q.blank? where({}) else - pattern = "%#{q}%" + pattern = "%#{q}%".gsub("/","//").gsub("_","/_") # sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ") - sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p)" + sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) escape '/' or LOWER(login) LIKE LOWER(:p) escape '/' or LOWER(mail) LIKE LOWER(:p) escape '/'" params = {:p => pattern} if q =~ /^(.+)\s+(.+)$/ a, b = "#{$1}%", "#{$2}%" diff --git a/app/models/project.rb b/app/models/project.rb index 32677143d..184b3c7af 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -108,7 +108,8 @@ class Project < ActiveRecord::Base has_many :tags, :through => :project_tags, :class_name => 'Tag' has_many :project_tags, :class_name => 'ProjectTags' # 动态级联删除 - has_many :forge_activities, :class_name => 'ForgeActivity', :dependent => :destroy + has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + #has_many :forge_activities, :class_name => 'ForgeActivity', :as =>:forge_act, :dependent => :destroy # 关联虚拟表 has_many :forge_messages, :class_name =>'ForgeMessage', :as => :forge_message, :dependent => :destroy @@ -1212,9 +1213,7 @@ class Project < ActiveRecord::Base # Author lizanle # Description 新建项目要在ForgeActivities中加一条数据。 def acts_as_forge_activities - fa = ForgeActivity.new(:user_id => User.current.id,:project_id => self.id, - :forge_act_id => self.id,:forge_act_type => "ProjectCreateInfo") - fa.save! + self.forge_acts << ForgeActivity.new(:user_id => User.current.id, :project_id => self.id) end diff --git a/app/models/user.rb b/app/models/user.rb index 4e62f3bd0..dc7a3e741 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -340,13 +340,15 @@ class User < Principal message_new_time.onclick_time = User.current.last_login_on.nil? ? Time.now : User.current.last_login_on message_new_time.save end - course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count - forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count - user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count - user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count - system_messages_count = SystemMessage.where("created_at >?", User.current.onclick_time.onclick_time).count - at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count - org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", User.current.id,0, User.current.onclick_time.onclick_time).count + user = User.current + onclick_time = user.onclick_time.onclick_time + course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count + forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count + user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count + user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count + system_messages_count = SystemMessage.where("created_at >?", onclick_time).count + at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count + org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count end diff --git a/app/views/admin/course_resource_list.html.erb b/app/views/admin/course_resource_list.html.erb index 4316555f7..2e83a96aa 100644 --- a/app/views/admin/course_resource_list.html.erb +++ b/app/views/admin/course_resource_list.html.erb @@ -10,16 +10,16 @@ 资源名称 - 资源大小 + <%= link_to "资源大小",admin_course_resource_list_path(:sort => "file_size") %> 资源类型 - 上传时间 + <%= link_to "上传时间",admin_course_resource_list_path(:sort => "file_upload") %> - 下载次数 + <%= link_to "下载次数",admin_course_resource_list_path(:sort => "file_download_times") %> 上传者 @@ -61,4 +61,6 @@ \ No newline at end of file + + +<% html_title(l(:label_course_resource_list)) -%> \ No newline at end of file diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb index e21ba32aa..59426455a 100644 --- a/app/views/admin/excellent_courses.html.erb +++ b/app/views/admin/excellent_courses.html.erb @@ -72,4 +72,6 @@ <% end %> - \ No newline at end of file + + +<% html_title(l(:label_excellent_courses_list)) -%> \ No newline at end of file diff --git a/app/views/admin/homework.html.erb b/app/views/admin/homework.html.erb index 7260d68ff..03472d0a0 100644 --- a/app/views/admin/homework.html.erb +++ b/app/views/admin/homework.html.erb @@ -22,24 +22,27 @@ 提交作品数 - 提交截止日期 + 作业发布日期 <%@count=@page*30 %> <% for homework in @homework do %> + <% unless homework.nil? %> <% @count+=1 %> <%=@count %> - <%=link_to(homework.name, student_work_index_path(:homework => homework.id))%> + <%=link_to(homework.try(:name), student_work_index_path(:homework => homework.id))%> + <% if homework.course %> <%= link_to(homework.course.name, course_path(homework.course.id)) %> + <% end %> <%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'> <% if homework.try(:user).try(:realname) == ' '%> <%= link_to(homework.try(:user), user_path(homework.user_id)) %> @@ -51,9 +54,10 @@ <%=link_to(StudentWork.where('homework_common_id=?',homework.id).count, student_work_index_path(:homework => homework.id))%> - <%=format_date(homework.end_time) %> + <%=format_date( homework.created_at ) %> + <% end %> <% end %> diff --git a/app/views/admin/latest_login_teachers.html.erb b/app/views/admin/latest_login_teachers.html.erb index 05f20ba8d..c1889bce1 100644 --- a/app/views/admin/latest_login_teachers.html.erb +++ b/app/views/admin/latest_login_teachers.html.erb @@ -45,6 +45,9 @@ 用户身份 + + 用户单位 + @@ -59,7 +62,7 @@ <%=format_time(teacher.last_login_on) %> - <%=teacher.user_id %> + <%= teacher.user_id %> <%= teacher.login%><% else %><%=teacher.try(:realname) %><% end %>'> <% if teacher.try(:realname) == ' '%> @@ -69,11 +72,14 @@ <% end %> - <%=link_to(teacher.login, user_path(teacher.user_id)) %> + <%= link_to(teacher.login, user_path(teacher.user_id)) %> 老师 + + <%= teacher.school_id.nil? ? "" : (School.find teacher.school_id).try(:name) %> + <% end %> @@ -82,3 +88,5 @@ + +<% html_title(l(:label_latest_login_teacher_list)) -%> \ No newline at end of file diff --git a/app/views/admin/latest_login_users.html.erb b/app/views/admin/latest_login_users.html.erb index 17680a8c8..a9e8e2feb 100644 --- a/app/views/admin/latest_login_users.html.erb +++ b/app/views/admin/latest_login_users.html.erb @@ -46,6 +46,9 @@ 用户身份 + + 用户单位 + @@ -88,6 +91,17 @@ <% end %> <% end%> + + <% unless user.user_extensions.nil? %> + <% if user.user_extensions.identity.to_i == 0 %> + + <% occupation = user.user_extensions.school_id.nil? ? "" : (School.where("id =?", user.user_extensions.school_id)).first.try(:name) %> + <%= occupation.blank? ? user.user_extensions.occupation : occupation %> + <% else %> + <%= user.user_extensions.occupation %> + <% end %> + <% end %> + <% end %> diff --git a/app/views/admin/organization.html.erb b/app/views/admin/organization.html.erb index 582b8b44a..6fde09ede 100644 --- a/app/views/admin/organization.html.erb +++ b/app/views/admin/organization.html.erb @@ -24,7 +24,8 @@ "> - <%= link_to org.name,home_path(:organization => org.id) %> + <%#= link_to org.name,home_path(:organization => org.id) %> + <%= link_to org.name, organization_path(org) %> @@ -40,4 +41,8 @@ -<% html_title(l(:label_project_plural)) -%> + + + diff --git a/app/views/admin/project_resource_list.html.erb b/app/views/admin/project_resource_list.html.erb index c245f73b8..8e8bd8c92 100644 --- a/app/views/admin/project_resource_list.html.erb +++ b/app/views/admin/project_resource_list.html.erb @@ -10,16 +10,16 @@ 资源名称 - 资源大小 + <%= link_to "资源大小",admin_project_resource_list_path(:sort => "file_size") %> 资源类型 - 上传时间 + <%= link_to "上传时间",admin_project_resource_list_path(:sort => "file_upload") %> - 下载次数 + <%= link_to "下载次数",admin_project_resource_list_path(:sort => "file_download_times") %> 上传者 @@ -61,4 +61,6 @@ \ No newline at end of file + + +<% html_title(l(:label_project_resource_list)) -%> \ No newline at end of file diff --git a/app/views/admin/schools.html.erb b/app/views/admin/schools.html.erb index d19e9b3b9..f52d1f060 100644 --- a/app/views/admin/schools.html.erb +++ b/app/views/admin/schools.html.erb @@ -1,43 +1,64 @@

<%=l(:label_school_plural)%>

-<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %> - <%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%> - -<% end %> + + + +
- - - - + + + - <% @schools.each do |school|%> + <% @count=@page * 30 %> + <% @schools.each do |school| %> "> - + + - + + @@ -50,4 +71,4 @@ <%= pagination_links_full @school_pages, @school_count ,:per_page_links => true, :remote => false, :flag => true %> -<% html_title(l(:label_project_plural)) -%> +<% html_title(l(:label_school_plural)) -%> diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 12aa95a16..2a757fdee 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -40,7 +40,10 @@ <%= sort_header_tag('admin', :caption => l(:field_admin), :default_order => 'desc') %> <%= sort_header_tag('created_on', :caption => l(:field_created_on), :default_order => 'desc') %> <%= sort_header_tag('last_login_on', :caption => l(:field_last_login_on), :default_order => 'desc') %> - + <%#= sort_header_tag('user_occupation', :caption => l(:field_occupation), :default_order => 'desc') %> + + + @@ -53,8 +56,11 @@ - + <% occupation = user.user_extensions.identity == 0 ? School.where("id=?",user.user_extensions.school_id).first.try(:name) : user.user_extensions.occupation %> + + + + <% end -%> diff --git a/app/views/attachments/_activity_attach.html.erb b/app/views/attachments/_activity_attach.html.erb index 32e796382..3cc429185 100644 --- a/app/views/attachments/_activity_attach.html.erb +++ b/app/views/attachments/_activity_attach.html.erb @@ -3,14 +3,14 @@
- <%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw400', :download => true -%> + <%= link_to_short_attachment attachment,:length=> 58, :class => 'hidden link_file_a fl newsBlue mw380', :download => true -%> ( <%= number_to_human_size attachment.filesize %>) - <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "c_orange" %>, + <%= link_to h(truncate(attachment.author.name, length: 15, omission: '...')),user_path(attachment.author),:class => "c_orange" %>, <%= format_time(attachment.created_on) %>
diff --git a/app/views/boards/_course_show_detail.html.erb b/app/views/boards/_course_show_detail.html.erb index bc7b9667e..d465571c5 100644 --- a/app/views/boards/_course_show_detail.html.erb +++ b/app/views/boards/_course_show_detail.html.erb @@ -2,20 +2,7 @@ <%= import_ke(enable_at: false, prettify: false) %> <%= javascript_include_tag "create_kindeditor" %> <% end %> - - -<% if topics%> +<% if topics %> <% topics.each do |topic| %> <% if topic %> - <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id,:is_course=>1,:is_board=>1} %> + <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id, :is_course => 1, :is_board=>1} %> <% end %> <% end %> <% if topics.count == 10 %> - <%= link_to "点击展开更多",boards_topic_path(@board, :course_id => @board.course.id ,:page => page),:id => "show_more_course_topic",:remote => "true",:class => "loadMore mt10 f_grey"%> <% end %> <% end%> - diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 9dd5c78ca..6cc755b61 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -192,6 +192,4 @@ function nh_init_board(params){ }); } } - - diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index bdbcabff0..763748ad7 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -50,7 +50,7 @@ -<% course_activities.each do |activity| if course_activities %> +<% course_activities.includes(:course_act).each do |activity| if course_activities %> - <% if activity && activity.course_act%> + <% if activity && activity.course_act %> <% act = activity.course_act %> <% case activity.course_act_type.to_s %> <% when 'HomeworkCommon' %> diff --git a/app/views/courses/_course_activity_users.html.erb b/app/views/courses/_course_activity_users.html.erb new file mode 100644 index 000000000..a0cac45f7 --- /dev/null +++ b/app/views/courses/_course_activity_users.html.erb @@ -0,0 +1,59 @@ +<% unless contributor_course_scor(course.id).count == 0 %> + +<% end %> \ No newline at end of file diff --git a/app/views/courses/_course_heroes.html.erb b/app/views/courses/_course_heroes.html.erb new file mode 100644 index 000000000..5e9851594 --- /dev/null +++ b/app/views/courses/_course_heroes.html.erb @@ -0,0 +1,21 @@ +<% hero_homework_scores = hero_homework_score(course, "desc") %> +<% unless hero_homework_scores.map(&:score).detect{|s| s.to_i != 0}.nil? %> + +<% end %> \ No newline at end of file diff --git a/app/views/courses/_recommendation.html.erb b/app/views/courses/_recommendation.html.erb index a0c659493..1db2edf57 100644 --- a/app/views/courses/_recommendation.html.erb +++ b/app/views/courses/_recommendation.html.erb @@ -1,9 +1,8 @@ -<% unless excellent_course_recommend(course).length == 0 %> +<% exc_course = excellent_course_recommend(course) %> +<% unless exc_course.length == 0 %> + + + + + + + + + +
+
+
+
+ <% if User.current.admin_of_org?(@organization) %> + + <% else %> + + <% end %> + <%= render :partial => 'organizations/org_logined_header' %> +
+
+
+ + + + + + + + <% @subfield_content.each do |field| %> + <% if is_default_field?(field) %> + <% case field.name %> + <% when 'course' %> +
+ <% if field.status == 0 %> +
+

课程动态

+ <% if @course_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+
    + <% unless @course_acts.nil? %> + <%= render :partial => 'organizations/org_new_course_pic', :locals => {:activities => @course_acts.first(3)} %> + <% end %> +
    + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
    +
+
+ <% end %> +
+ <% else %> +
+

课程动态

+ <% if @course_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+ <%= render :partial => 'organizations/org_new_course_act_list', :locals =>{:activities => @course_acts, :field => field, :organization => @organization} %> + +
+
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% end %> + + +
+ <% end %> +
+ <% when 'project' %> +
+ <% if field.status == 0 %> +
+

项目动态

+ <% if @project_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+
    + <% unless @project_acts.nil? %> + <%= render :partial => 'organizations/org_new_project_pic', :locals => {:activities => @project_acts.first(3)} %> + <% end %> +
    + <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
    +
+
+ <% end %> + +
+ <% else %> +
+

项目动态

+ <% if @project_acts.blank? %> + +
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+ <%= render :partial => 'organizations/org_new_project_act_list', :locals =>{:activities => @project_acts, :field => field, :organization => @organization} %> + +
+
+ <%= link_to "More", organization_path(@organization, :list =>1), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% end %> + +
+ <% end %> +
+ <% end %> + <% else %> + <% if field.field_type == "Post" %> <%# 讨论类型 %> + <% org_subfield = OrgSubfield.find(field.id) %> + <% org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0 %> + <% org_acts = 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') %> + <%# message_ats = get_message_org(@organization.id, field.id) %> + <%# ids = field.org_document_comments.map{|o| o.id}.join(",") %> +
+ <% if field.status == 0 %> +
+

<%= field.name %>

+ <% if org_acts.blank? %> + +
+ <% 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 "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+
    + + <% org_acts.first(3).each do |act| %> + <%= render :partial => 'organizations/org_new_forum_pic', :locals => {:activity => act, :field => field, :organization => @organization} %> + <% end %> +
    +
+ <% 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 "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+
+ <% end %> + +
+ <% else %> +
+

<%= field.name %>

+ <% if org_acts.blank? %> + +
+ <% 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 "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> +
+ <% else %> +
+ <% org_acts.each do |act| %> + <%= render :partial => 'organizations/org_new_forum_list', :locals => {:activity => act, :field => field, :organization => @organization} %> + <% end %> + +
+
+ <% 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 "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> + <% end %> +
+ <% end %> + +
+
+ <% end %> +
+ <% elsif field.field_type == "Resource" %> + <% org_attachs = get_attach_org2(field) %> +
+
+

<%= field.name %>

+ <% if org_attachs.blank? %> + +
+ <% 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 "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", org_subfield_files_path(field), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% else %> +
+ <%= render :partial => 'organizations/org_new_resource', :locals => {:org_attachs => org_attachs} %> + +
+ +
+ <% 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 "More", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% else %> + <%= link_to "More", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <% else %> + <%= link_to "More", org_subfield_files_path(field), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> + <%#= link_to "More", organization_path(@organization, :org_subfield_id => field.id), :class => "more-btn-center mt30" , :target => "_blank" %> +
+ <% end %> + +
+
+
+
+ <% end %> + <% end %> + <% end %> + + + + +
+
+ Top + + + + +
+ + + + <%#= call_hook :view_layouts_base_body_bottom %> + + + diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 5ad25d5bd..4ce35802d 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -29,7 +29,7 @@ showMathMenuMSIE: false, tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} }); - + @@ -44,8 +44,6 @@
- - <%#= render :partial => 'layouts/new_header'%>
@@ -104,20 +102,6 @@ <% end %> <%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %> - <%= field.hide==0?"设为隐藏":"设为可见" %> + <%= field.hide==0?"隐藏":"可见" %> <%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr10" %> 编辑 @@ -68,6 +99,34 @@ <% end %> \ No newline at end of file diff --git a/app/views/organizations/show_org_subfield.js.erb b/app/views/organizations/show_org_subfield.js.erb index 165b07afd..78b404b6f 100644 --- a/app/views/organizations/show_org_subfield.js.erb +++ b/app/views/organizations/show_org_subfield.js.erb @@ -1,2 +1,2 @@ -$("#hide_<%= @org_subfield.id %>").text("设为隐藏"); +$("#hide_<%= @org_subfield.id %>").text("隐藏"); $("#org_subfield_<%= @org_subfield.id %>").css("display", "block"); \ No newline at end of file diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index f9faa26d6..bb6cdad0c 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -73,15 +73,14 @@ <% case activity.forge_act_type %> - <% when "ProjectCreateInfo" %> + <% when "Project" %> <%= render :partial => 'projects/project_create', :locals => {:activity => activity, :user_activity_id => activity.id} %> <% when "Issue" %> <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %> - <% when "Message" %> - <%= render :partial => 'users/project_message', :locals => {:activity => activity.forge_act,:user_activity_id =>activity.id,:is_course=>1,:is_board=>0} %> + <%= render :partial => 'users/project_message', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :is_course => 1, :is_board => 0} %> <% when "News" %> <% if !activity.forge_act.nil? and activity.forge_act.project %> diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index 20d6df9ba..997d28f6d 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -18,7 +18,7 @@ <% if @homework.homework_detail_manual.comment_status == 3 && work.user != User.current%>
  • - <%= render :partial => 'student_work_praise' %> + <%= render :partial => 'student_work_praise',:locals => {:work => work} %>
  • <% end%>
    @@ -53,21 +53,36 @@ <% else %>
      - <% test.results.each_with_index do |x, i| %> + + <% test.results.reverse.each_with_index do |x, i| %> + <% unless x.nil? %>
    • - 测试<%=i+1%> + 测试<%=test.results.size-i%> <% if x["status"].to_i != 0 %> - 测试错误! + <% if x["status"].to_i == 2 %> + 超时! + <% else %> + 测试错误! + <% end %> 您的输出: -
      <%=x["result"]%>
      +
      <%=x["result"].force_encoding("UTF-8")%> 
      正确输出: -
      <%=x["output"]%>
      + +
      <%=x["output"]%>
      + <% if x["status"].to_i == 2 %> + 耗时: +
      <%=x["time_used"]%>毫秒
      + <% end %>
      <% else %> - 测试正确! + + 测试正确! + +
      <% end %>
    • + <% end %> <% end %>
    diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 67c04d71f..dc2fdafb6 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -25,7 +25,7 @@ <% if @homework.homework_detail_manual.comment_status == 3 && !is_my_work %>
  • - <%= render :partial => 'student_work_praise' %> + <%= render :partial => 'student_work_praise',:locals => {:work => work} %>
  • <% end%>
    diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index f9f55456b..8b2f57723 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -46,8 +46,8 @@ <% end%> diff --git a/app/views/users/_send_homework_to_course.html.erb b/app/views/users/_send_homework_to_course.html.erb index b19fbd1a8..67fd36c3c 100644 --- a/app/views/users/_send_homework_to_course.html.erb +++ b/app/views/users/_send_homework_to_course.html.erb @@ -1,4 +1,4 @@ -
    +
    发送到
    @@ -8,33 +8,9 @@
    - <%= form_tag send_homework_to_course_user_path(user),:remote=>true,:id=>'choose_course_list_form' %> -
    - <%= hidden_field_tag(:send_id, send_id) %> -
    - <% if !courses.empty? %> - <% courses.each do |course| %> -
      -
    • - -
    • -
    • <%= truncate(course.name,:lendght=>25) + '['+current_time_and_term(course) + ']'%>
    • -
    - <% end %> -
    +
    + <%= render :partial => "users/send_homework_to_course_form", :locals => {:user => user, :courses => courses, :send_id => send_id} %>
    -
    - -
    -
    - 确定 -
    -
    - 取消 -
    -
    -
    - <% end %>
    - <% unless user_activity.act_type == "ProjectCreateInfo" %> - <% act= user_activity.act %> - <% case user_activity.container_type.to_s %> - <% when 'Course' %> - <% if act %> - <% case user_activity.act_type.to_s %> - <% when 'HomeworkCommon' %> - <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:course_activity => 0} %> - <% when 'News' %> - <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> - <% when 'Message'%> - <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> - <% when 'Poll' %> - <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity_id => user_activity.id} %> - <% when 'Course'%> - <%= render :partial => 'users/course_create', :locals => {:activity => act, :user_activity_id => act.id} %> - <% end %> - <% end %> - <% when 'Project' %> - <% if act %> - <% case user_activity.act_type.to_s %> - <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id, :user_id => user_id} %> - <% when 'Message' %> - <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> - <% when 'ProjectCreateInfo'%> - <%= render :partial => 'project_create', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> - <% end %> - <% end %> - <% when 'Principal' %> - <% if act %> - <% case user_activity.act_type.to_s %> - <% when 'JournalsForMessage' %> - <% unless act.private == 1 && (!User.current || (User.current && act.jour_id != User.current.id && act.user_id != User.current.id)) %> - <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_activity=>1} %> - <% end %> - <% end %> - <% end %> - <% when 'Blog'%> - <%if act %> - <% case user_activity.act_type.to_s %> - <% when 'BlogComment' %> - <%= render :partial => 'user_blog', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> - <% end %> - <% end %> - <% end %> - <% else %> + <% if user_activity.act_type == "ProjectCreateInfo" %> <%= render :partial => 'project_create', :locals => {:activity => user_activity,:user_activity_id =>user_activity.id} %> + <% else %> + <% act= user_activity.act %> + <%if act %> + + <% case user_activity.container_type.to_s %> + <% when 'Course' %> + <% case user_activity.act_type.to_s %> + <% when 'HomeworkCommon' %> + <%# cache (act) do %> + <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:course_activity => 0} %> + <%# end %> + <% when 'News' %> + <%# cache [act, act.comments.count] do %> + <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> + <%# end %> + <% when 'Message'%> + <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> + <% when 'Poll' %> + <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity_id => user_activity.id} %> + <% when 'Course'%> + <%# cache (act) do %> + <%= render :partial => 'users/course_create', :locals => {:activity => act, :user_activity_id => act.id} %> + <%# end%> + <% when 'JournalsForMessage'%> + <%= render :partial => 'users/course_journalsformessage', :locals => {:activity => act, :user_activity_id => user_activity.id} %> + <% end %> + <% when 'Project' %> + <% case user_activity.act_type.to_s %> + <% when 'Issue' %> + <%# cache [act, act.journals.count, act.attachments.count] do%> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id, :user_id => user_id} %> + <%# end %> + <% when 'Message' %> + <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> + <% when 'ProjectCreateInfo'%> + <%# cache (act) do %> + <%= render :partial => 'project_create', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> + <%# end %> + <% end %> + <% when 'Principal' %> + <% case user_activity.act_type.to_s %> + <% when 'JournalsForMessage' %> + <% unless act.private == 1 && (!User.current || (User.current && act.jour_id != User.current.id && act.user_id != User.current.id)) %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_activity=>1} %> + <% end %> + <% end %> + <% when 'Blog'%> + <%# cache (act) do %> + <% case user_activity.act_type.to_s %> + <% when 'BlogComment' %> + <%= render :partial => 'user_blog', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> + <% end %> + <%# end %> + <% end %> + + <% end %> + <% end %> <% end %> - <% end %> <% end %> <% if user_activities.count == 10%> diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb index 089171c3d..8f0c6acaf 100644 --- a/app/views/users/_user_at_message.html.erb +++ b/app/views/users/_user_at_message.html.erb @@ -21,13 +21,6 @@ <%= link_to ma.subject.html_safe, ma.url, :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> <% end %> -
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> \ 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 a196ee6c0..780b1c6eb 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -155,7 +155,7 @@ <% 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| %> + <% student_works.includes(:user).each_with_index do |sw, i| %>
    <% if User.current.member_of_course?(homework_common.course) || User.current.admin? || homework_common.is_open == 1 %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 7de1ce417..ccd329852 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -370,7 +370,7 @@ ">回复了作品评论:
  • - <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> @@ -424,6 +424,28 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> + + + <% if ma.course_message_type == "StudentWork" && ma.status == 1 %> +
      +
    • + <%= link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %> +
    • +
    • + <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "同学", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> + ">重新提交了作品: +
    • +
    • + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.homework_common_id, :show_work_id => ma.course_message_id), + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%#= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}" %> + + +
    • +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> <% if ma.course_message_type == "Course" %>
      diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index 574411055..1fd981d73 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -15,9 +15,6 @@ -
    • <%= time_tag(ma.created_at).html_safe %>
    <% end %> @@ -38,21 +35,6 @@ -
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -74,21 +56,6 @@ -
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -114,9 +81,6 @@ - <% unless User.current.member_of?(ma.project) %>
  • <%=link_to "同意加入", {:controller => 'projects', :action => 'member', :id => ma.project_id, :message_id =>ma.id, :key => ma.secret_key}, @@ -144,13 +108,6 @@
  • -
  •    截止时间快到了!
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -169,13 +126,6 @@ -
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -197,11 +147,6 @@ -
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -210,37 +155,14 @@
  • <%=link_to image_tag(url_to_avatar(ma.forge_message.author), :width => "30", :height => "30"), user_path(ma.forge_message.author) %>
  • <%=link_to ma.forge_message.author, user_path(ma.forge_message.author), :class => "newsBlue homepageNewsPublisher" %> "><%= ma.forge_message.parent_id.nil? ? "发布了项目帖子:" : "评论了项目帖子:" %>
  • - <% if ma.forge_message.parent_id.nil? %> -
  • - <%= link_to ma.forge_message.subject, project_boards_path(ma.forge_message.project, - :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, - :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %> - - -
  • - - <% else %> -
  • - <%= link_to ma.forge_message.subject, project_boards_path(ma.forge_message.project, - :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, - :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %> - - -
  • - - <% end %> +
  • + <%= link_to ma.forge_message.subject, project_boards_path(ma.forge_message.project, + :parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id, + :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %> + + + +
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -260,13 +182,6 @@ -
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -281,11 +196,6 @@ -
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> diff --git a/app/views/users/_user_message_forum.html.erb b/app/views/users/_user_message_forum.html.erb index d18292068..716fef349 100644 --- a/app/views/users/_user_message_forum.html.erb +++ b/app/views/users/_user_message_forum.html.erb @@ -15,13 +15,6 @@ - <% else %>
  • <%= link_to ma.memo.content.html_safe, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> @@ -29,13 +22,6 @@
  • - <% end %>
  • <%= time_tag(ma.memo.created_at).html_safe %>
  • diff --git a/app/views/users/_user_message_system.html.erb b/app/views/users/_user_message_system.html.erb index a80d35bd4..72241636f 100644 --- a/app/views/users/_user_message_system.html.erb +++ b/app/views/users/_user_message_system.html.erb @@ -15,14 +15,6 @@ -
  • <%= time_tag(ma.created_at).html_safe %>
  • <%# end %> diff --git a/app/views/users/_user_message_userfeedaback.html.erb b/app/views/users/_user_message_userfeedaback.html.erb index 894eedbfc..1898090aa 100644 --- a/app/views/users/_user_message_userfeedaback.html.erb +++ b/app/views/users/_user_message_userfeedaback.html.erb @@ -24,7 +24,6 @@ <% end %>
  • <%= time_tag(ma.journals_for_message.created_on).html_safe %>
  • - <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/_user_resource_info.html.erb b/app/views/users/_user_resource_info.html.erb index bea78130a..a3bc45481 100644 --- a/app/views/users/_user_resource_info.html.erb +++ b/app/views/users/_user_resource_info.html.erb @@ -42,7 +42,190 @@
  • 预览
  • 重命名
  • -
  • 发送
  • +
  • 发送
  • 删除
  • - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb index c05a2ebd0..8db83aefc 100644 --- a/app/views/users/add_exist_file_to_course.js.erb +++ b/app/views/users/add_exist_file_to_course.js.erb @@ -1,6 +1,7 @@ <% if @flag == true%> $("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true, :path => @path %>'); $("#res_count").html(0); $("#checkboxAll").attr('checked',false); $("#res_all_count").html(<%= @atta_count%>); diff --git a/app/views/users/add_exist_file_to_org.js.erb b/app/views/users/add_exist_file_to_org.js.erb index 9bfe1230a..c6e7f4011 100644 --- a/app/views/users/add_exist_file_to_org.js.erb +++ b/app/views/users/add_exist_file_to_org.js.erb @@ -1,6 +1,7 @@ <% if @flag == true%> $("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true, :path => @path %>'); $("#res_count").html(0); $("#checkboxAll").attr('checked',false); $("#res_all_count").html(<%= @atta_count%>); diff --git a/app/views/users/add_exist_file_to_project.js.erb b/app/views/users/add_exist_file_to_project.js.erb index ed38fa066..4c24f4932 100644 --- a/app/views/users/add_exist_file_to_project.js.erb +++ b/app/views/users/add_exist_file_to_project.js.erb @@ -1,6 +1,7 @@ <% if @flag == true%> $("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true, :path => @path %>'); $("#res_count").html(0); $("#checkboxAll").attr('checked',false); $("#res_all_count").html(<%= @atta_count%>); diff --git a/app/views/users/choose_user_course.js.erb b/app/views/users/choose_user_course.js.erb index 508004816..64f3708f8 100644 --- a/app/views/users/choose_user_course.js.erb +++ b/app/views/users/choose_user_course.js.erb @@ -1,7 +1,11 @@ +<% if params[:is_observe].nil? %> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/send_homework_to_course', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>'); showModal('ajax-modal', '452px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); $('#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 +$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); +<% else %> + $("#send_homework_to_course_form").html("<%= escape_javascript(render :partial => 'users/send_homework_to_course_form', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>"); +<% end %> \ No newline at end of file diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index f8ce5cee4..f8635194d 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -11,42 +11,52 @@ }); +
    -
    <%= @is_test ? '模拟答题' : '提交作品' %>
    @@ -123,22 +133,34 @@ <% else %>
      - <% test.results.each_with_index do |x, i| %> -
    • 测试<%=i+1%> + <% test.results.reverse.each_with_index do |x, i| %> + <% unless x.nil? %> +
    • 测试<%=test.results.size-i%> <% if x["status"].to_i != 0 %> - 测试错误! + <% if x["status"].to_i == 2 %> + 超时! + <% else %> + 测试错误! + <% end %> 您的输出: -
      <%=x["result"]%>
      +
      <%=x["result"]%> 
      正确输出: -
      <%= x["output"] %>
      +
      <%= x["output"] %>
      + <% if x["status"].to_i == 2 %> +  耗时: +
      <%=x["time_used"]%>毫秒
      + <% end %>
    • <% else %> - 测试正确! + 测试正确! + +
      <% end %> <% end %> + <% end %>
    <% end %> diff --git a/app/views/users/search_user_course.js.erb b/app/views/users/search_user_course.js.erb index f4509987f..f30970dc4 100644 --- a/app/views/users/search_user_course.js.erb +++ b/app/views/users/search_user_course.js.erb @@ -9,18 +9,28 @@ //$("#upload_box").css('left','').css('top',''); //$("#upload_box").html('<%#= escape_javascript( render :partial => "resource_share_popup" ,:locals => {:courses=>@course,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>'); //$("#upload_box").css('display','block'); -<% if params[:send_type].present? && params[:send_type] == 'news' %> -$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_news_to_course' , :locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); -<% elsif params[:send_type] == 'file' %> -$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_popup' , :locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); -<% elsif params[:send_type] == 'message' %> -$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_message_to_course' ,:locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); +<% if params[:is_observe].nil? %> + <% if params[:send_type].present? && params[:send_type] == 'news' %> + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_news_to_course' , :locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); + <% elsif params[:send_type] == 'file' %> + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_popup' , :locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids, :type=>@type}) %>'); + <% elsif params[:send_type] == 'message' %> + $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_message_to_course' ,:locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); + <% end %> + showModal('ajax-modal', '452px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#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"); + var val = $("#search_course_input").val(); + $("#search_course_input").val("").focus().val(val); +<% else %> + <% if params[:send_type] == 'news' %> + $("#course_news_form").html("<%= escape_javascript(render :partial => 'users/course_news_form', :locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>") + <% elsif params[:send_type] == 'file' %> + $("#course_file_form").html("<%= escape_javascript(render :partial => 'users/course_file_form', :locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>"); + <% elsif params[:send_type] == 'message' %> + $("#course_message_form").html("<%= escape_javascript(render :partial => 'users/course_message_form', :locals => {:courses => @course, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>"); + <% end %> <% end %> -showModal('ajax-modal', '452px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); -$('#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"); -var val = $("#search_course_input").val(); -$("#search_course_input").val("").focus().val(val); diff --git a/app/views/users/search_user_org.js.erb b/app/views/users/search_user_org.js.erb index ee12e9439..f2caf8b41 100644 --- a/app/views/users/search_user_org.js.erb +++ b/app/views/users/search_user_org.js.erb @@ -1,7 +1,8 @@ +<% if params[:is_observe].nil? %> <% if params[:send_type].present? && params[:send_type] == 'news' %> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_news_to_org' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>'); <% elsif params[:send_type] == 'file' %> -$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_orgs' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>'); +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_orgs' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids,:type => @type})%>'); <% elsif params[:send_type] == 'message' %> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_message_to_org' ,:locals => {:orgs=>@orgs,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>'); <% end %> @@ -12,4 +13,13 @@ $('#ajax-modal').parent().css("top","50%").css("left","50%"); $('#ajax-modal').parent().addClass("popbox").addClass("shareDP"); $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); var val = $("#search_org_input").val(); -$("#search_org_input").val("").focus().val(val); \ No newline at end of file +$("#search_org_input").val("").focus().val(val); +<% else %> + <% if params[:send_type] == 'news' %> + $("#org_news_form").html("<%= escape_javascript(render :partial => 'users/org_news_form', :locals => {:orgs => @orgs,:user=> @user,:send_id => @send_id, :send_ids => @send_ids}) %>"); + <% elsif params[:send_type] == 'file' %> + $("#org_file_form").html("<%= escape_javascript(render :partial => 'users/org_file_form', :locals => {:orgs => @orgs,:user=> @user,:send_id => @send_id, :send_ids => @send_ids}) %>"); + <% elsif params[:send_type] == 'message' %> + $("#org_message_form").html("<%= escape_javascript(render :partial => 'users/org_message_form', :locals => {:orgs => @orgs,:user=> @user,:send_id => @send_id, :send_ids => @send_ids}) %>"); + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/users/search_user_project.js.erb b/app/views/users/search_user_project.js.erb index d58c56ca9..37d078662 100644 --- a/app/views/users/search_user_project.js.erb +++ b/app/views/users/search_user_project.js.erb @@ -1,7 +1,8 @@ +<% if params[:is_observe].nil? %> <% if params[:send_type].present? && params[:send_type] == 'news' %> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_news_to_project', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); <% elsif params[:send_type] == 'file' %> -$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_project_popup', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_project_popup', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids,:type => @type}) %>'); <% elsif params[:send_type] == 'message' %> $("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/share_message_to_project', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); <% end %> @@ -14,3 +15,12 @@ $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); //$("#search_project_input").focus(); var val = $("#search_project_input").val(); $("#search_project_input").val("").focus().val(val); +<% else %> +<% if params[:send_type] == 'news' %> +$("#project_news_form").html("<%= escape_javascript(render :partial => 'users/project_news_form', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>"); +<% elsif params[:send_type] == 'file' %> +$("#project_file_form").html("<%= escape_javascript(render :partial => 'users/project_file_form', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>"); +<% elsif params[:send_type] == 'message' %> +$("#project_message_form").html("<%= escape_javascript(render :partial => 'users/project_message_form', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>"); +<% end %> +<% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index fa4eaacbe..2fe9ab079 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -14,6 +14,7 @@
  • <%= link_to "论坛动态", {:controller => "users", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%>
  • <%= link_to "问卷动态", {:controller => "users", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> +
  • <%= link_to "课程留言", {:controller => "users", :action => "show", :type => "course_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%> @@ -30,7 +31,7 @@
    • 更多
    • -
    • <%= link_to "留言动态", {:controller => "users", :action => "show", :type => "user_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%> +
    • <%= link_to "个人留言", {:controller => "users", :action => "show", :type => "user_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%>
    • <%= link_to "我的动态", {:controller => "users", :action => "show", :type => "current_user"}, :class =>"homepagePostTypeMine postTypeGrey"%>
    • <%= link_to "全部动态", {:controller => "users", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%>
    diff --git a/app/views/users/show.js.erb b/app/views/users/show.js.erb index eb5de9c6a..33013c36d 100644 --- a/app/views/users/show.js.erb +++ b/app/views/users/show.js.erb @@ -1,2 +1,2 @@ -$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type} )%>"); +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} )%>"); diff --git a/app/views/users/user_commit_homework.html.erb b/app/views/users/user_commit_homework.html.erb index 0f3c4810f..cab3c55ab 100644 --- a/app/views/users/user_commit_homework.html.erb +++ b/app/views/users/user_commit_homework.html.erb @@ -2,36 +2,46 @@ @@ -90,21 +100,33 @@ <% else %>
      - <% test.results.each_with_index do |x, i| %> -
    • 测试<%=i+1%> + <% test.results.reverse.each_with_index do |x, i| %> + <% unless x.nil? %> +
    • 测试<%=test.results.size-i%> <% if x["status"].to_i != 0 %> - 测试错误! + <% if x["status"].to_i == 2 %> + 超时! + <% else %> + 测试错误! + <% end %> 您的输出: -
      <%=x["result"]%>
      +
      <%=x["result"]%> 
      正确输出: -
      <%=x["output"]%>
      +
      <%=x["output"]%>
      + <% if x["status"].to_i == 2 %> +  耗时: +
      <%=x["time_used"]%>毫秒
      + <% end %>
    • <% else %> - 测试正确! + 测试正确! + +
      <% end %> + <% end %> <% end %>
    diff --git a/app/views/users/user_resource_create.js.erb b/app/views/users/user_resource_create.js.erb index e818f2870..d28898e0a 100644 --- a/app/views/users/user_resource_create.js.erb +++ b/app/views/users/user_resource_create.js.erb @@ -1,15 +1,15 @@ -closeModal(); -$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); -$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>'); -$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -$("#res_all_count").html(<%= @atta_count%>); -$("#res_count").html(0); -$("#checkboxAll").attr('checked',false); -//更新状态 -$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); -$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); -$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); -$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); -$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); -$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); +closeModal(); +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true, :path => @path %>'); +$("#res_all_count").html(<%= @atta_count%>); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); +//更新状态 +$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); +$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); +$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); +$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); +$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); +$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); $("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>'); \ No newline at end of file diff --git a/app/views/users/user_resource_delete.js.erb b/app/views/users/user_resource_delete.js.erb index 9583274c6..ffb056e28 100644 --- a/app/views/users/user_resource_delete.js.erb +++ b/app/views/users/user_resource_delete.js.erb @@ -1,14 +1,14 @@ -$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); -$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>'); -$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -$("#res_all_count").html(<%= @atta_count%>); -$("#res_count").html(0); -$("#checkboxAll").attr('checked',false); -//更新状态 -$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); -$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); -$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); -$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); -$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); -$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true, :path => @path %>'); +$("#res_all_count").html(<%= @atta_count%>); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); +//更新状态 +$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); +$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); +$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); +$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); +$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); +$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); $("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>'); \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 3da533eb7..033f12ad2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1523,6 +1523,9 @@ en: label_excellent_courses_list: excellent_courses label_course_resource_list: course_resource_list label_project_resource_list: project_resource_list + label_organization_list: organzation_list + label_latest_login_teacher_list: latest_login_teacher_list + label_latest_login_user_list: latest_login_teacher_list #api label_recently_updated_notification: Recently updated notification @@ -1535,3 +1538,12 @@ en: error_upload_avatar_to_large: "too big (%{max_size})" not_valid_image_file: not a valid image file + #resource + label_resource_name: Resource_name + label_resource_type: Rescource_type + label_resource_size: Rescource_size + label_resource_upload_date: Resource_upload_date + label_resource_download_times: Resource_download_times + label_resource_upload_author: Resource_upload_author + label_resource_belongs_course: Resource_belongs_course + label_resource_belongs_project: Resource_belongs_project diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 37d26dbd8..e67ca806d 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -563,6 +563,7 @@ zh: label_overall_activity: 活动概览 label_new: 新建 label_latest_login_user_list: 最近登录用户列表 + label_latest_login_teacher_list: 最近登录教师列表 label_logged_as: 登录为 label_environment: 环境 @@ -678,6 +679,7 @@ zh: label_repository: 版本库 label_course_repository: 代码库 label_browse: 上传文件 + label_browse_org: 上传图片 label_branch: 分支 label_tag: 标签 label_revision: 修订 @@ -2111,4 +2113,14 @@ zh: # 课程推荐 label_homework_commont: 作业 - label_homework_recommendation: 课程推荐 \ No newline at end of file + label_homework_recommendation: 课程推荐 + + #资源 + label_resource_name: 资源名称 + label_resource_type: 资源类型 + label_resource_size: 资源大小 + label_resource_upload_date: 上传时间 + label_resource_download_times: 下载次数 + label_resource_upload_author: 上传者 + label_resource_belongs_course: 所属课程 + label_resource_belongs_project: 所属项目 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 327c6af8d..b92e8ad77 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,14 @@ RedmineApp::Application.routes.draw do end end resources :organizations do + resource :files do + member do + + end + collection do + + end + end resources :org_document_comments do member do @@ -112,6 +120,7 @@ RedmineApp::Application.routes.draw do member do match 'update_sub_dir', :via => [:put] match 'update_priority', :via => [:put] + match 'update_status', :via => [:post] end resource :boards end @@ -273,7 +282,7 @@ RedmineApp::Application.routes.draw do get 'absence_penalty_list' get 'evaluation_list' # post 'set_program_score' - post 'program_test' + post 'program_test_ex' post 'set_score_rule' end end diff --git a/db/migrate/20160321071740_add_index_to_message_alls.rb b/db/migrate/20160321071740_add_index_to_message_alls.rb new file mode 100644 index 000000000..d3e095da5 --- /dev/null +++ b/db/migrate/20160321071740_add_index_to_message_alls.rb @@ -0,0 +1,5 @@ +class AddIndexToMessageAlls < ActiveRecord::Migration + def change + add_index :message_alls, [:user_id, :message_id, :created_at] + end +end diff --git a/db/migrate/20160321073042_add_index_to_course_messages.rb b/db/migrate/20160321073042_add_index_to_course_messages.rb new file mode 100644 index 000000000..ede54779b --- /dev/null +++ b/db/migrate/20160321073042_add_index_to_course_messages.rb @@ -0,0 +1,5 @@ +class AddIndexToCourseMessages < ActiveRecord::Migration + def change + add_index :course_messages, [:user_id, :course_id, :created_at] + end +end diff --git a/db/migrate/20160321073107_add_index_to_memo_messages.rb b/db/migrate/20160321073107_add_index_to_memo_messages.rb new file mode 100644 index 000000000..59bf69fb5 --- /dev/null +++ b/db/migrate/20160321073107_add_index_to_memo_messages.rb @@ -0,0 +1,5 @@ +class AddIndexToMemoMessages < ActiveRecord::Migration + def change + add_index :memo_messages, [:user_id, :forum_id, :created_at] + end +end diff --git a/db/migrate/20160321073227_add_index_to_user_feedback_messages.rb b/db/migrate/20160321073227_add_index_to_user_feedback_messages.rb new file mode 100644 index 000000000..c067f58d8 --- /dev/null +++ b/db/migrate/20160321073227_add_index_to_user_feedback_messages.rb @@ -0,0 +1,5 @@ +class AddIndexToUserFeedbackMessages < ActiveRecord::Migration + def change + add_index :user_feedback_messages, [:user_id, :created_at] + end +end diff --git a/db/migrate/20160321075815_add_index_to_forge_messages.rb b/db/migrate/20160321075815_add_index_to_forge_messages.rb new file mode 100644 index 000000000..ada345501 --- /dev/null +++ b/db/migrate/20160321075815_add_index_to_forge_messages.rb @@ -0,0 +1,5 @@ +class AddIndexToForgeMessages < ActiveRecord::Migration + def change + add_index :forge_messages, [:user_id, :project_id, :created_at] + end +end diff --git a/db/migrate/20160321080116_add_forgetype_to_forge_messages.rb b/db/migrate/20160321080116_add_forgetype_to_forge_messages.rb new file mode 100644 index 000000000..5dbd96340 --- /dev/null +++ b/db/migrate/20160321080116_add_forgetype_to_forge_messages.rb @@ -0,0 +1,5 @@ +class AddForgetypeToForgeMessages < ActiveRecord::Migration + def change + add_index :forge_messages, [:forge_message_id, :forge_message_type] + end +end diff --git a/db/migrate/20160321080336_add_usertype_to_user_feedback_messages.rb b/db/migrate/20160321080336_add_usertype_to_user_feedback_messages.rb new file mode 100644 index 000000000..6a40ad444 --- /dev/null +++ b/db/migrate/20160321080336_add_usertype_to_user_feedback_messages.rb @@ -0,0 +1,5 @@ +class AddUsertypeToUserFeedbackMessages < ActiveRecord::Migration + def change + add_index :user_feedback_messages, [:journals_for_message_id] + end +end diff --git a/db/migrate/20160321080412_add_memotype_to_memo_messages.rb b/db/migrate/20160321080412_add_memotype_to_memo_messages.rb new file mode 100644 index 000000000..0e79cd8f6 --- /dev/null +++ b/db/migrate/20160321080412_add_memotype_to_memo_messages.rb @@ -0,0 +1,5 @@ +class AddMemotypeToMemoMessages < ActiveRecord::Migration + def change + add_index :memo_messages, [:memo_id, :memo_type] + end +end diff --git a/db/migrate/20160321080825_add_feed_to_user_feedback_messages.rb b/db/migrate/20160321080825_add_feed_to_user_feedback_messages.rb new file mode 100644 index 000000000..98a3e2c3e --- /dev/null +++ b/db/migrate/20160321080825_add_feed_to_user_feedback_messages.rb @@ -0,0 +1,5 @@ +class AddFeedToUserFeedbackMessages < ActiveRecord::Migration + def change + add_index :course_messages, [:course_message_type] + end +end diff --git a/db/migrate/20160321085313_add_index_mtye_to_message_alls.rb b/db/migrate/20160321085313_add_index_mtye_to_message_alls.rb new file mode 100644 index 000000000..8f5c734c4 --- /dev/null +++ b/db/migrate/20160321085313_add_index_mtye_to_message_alls.rb @@ -0,0 +1,5 @@ +class AddIndexMtyeToMessageAlls < ActiveRecord::Migration + def change + add_index :message_alls, [:message_type] + end +end diff --git a/db/migrate/20160322032610_change_domain_name_to_lowercase.rb b/db/migrate/20160322032610_change_domain_name_to_lowercase.rb new file mode 100644 index 000000000..35a82477d --- /dev/null +++ b/db/migrate/20160322032610_change_domain_name_to_lowercase.rb @@ -0,0 +1,14 @@ +class ChangeDomainNameToLowercase < ActiveRecord::Migration + def up + Secdomain.all.each do |domain| + domain.update_attribute(:subname, domain.subname.downcase) + end + + SubfieldSubdomainDir.all.each do |dir| + dir.update_attribute(:name, dir.name.downcase) + end + end + + def down + end +end diff --git a/db/migrate/20160324052634_change_project_create_type.rb b/db/migrate/20160324052634_change_project_create_type.rb new file mode 100644 index 000000000..8beca180d --- /dev/null +++ b/db/migrate/20160324052634_change_project_create_type.rb @@ -0,0 +1,8 @@ +class ChangeProjectCreateType < ActiveRecord::Migration + def up + execute("update forge_activities set forge_act_type = 'Project' where forge_act_type = 'ProjectCreateInfo'") + end + + def down + end +end diff --git a/db/migrate/20160324074942_add_index_to_forge_activities.rb b/db/migrate/20160324074942_add_index_to_forge_activities.rb new file mode 100644 index 000000000..e4e17ec44 --- /dev/null +++ b/db/migrate/20160324074942_add_index_to_forge_activities.rb @@ -0,0 +1,5 @@ +class AddIndexToForgeActivities < ActiveRecord::Migration + def change + add_index :forge_activities, [:project_id, :forge_act_id, :created_at, :forge_act_type], :name => "forge_act_index" + end +end diff --git a/db/migrate/20160325030146_add_index_to_course_actiivities.rb b/db/migrate/20160325030146_add_index_to_course_actiivities.rb new file mode 100644 index 000000000..3449ef6a1 --- /dev/null +++ b/db/migrate/20160325030146_add_index_to_course_actiivities.rb @@ -0,0 +1,5 @@ +class AddIndexToCourseActiivities < ActiveRecord::Migration + def change + add_index :course_activities, [:course_id, :course_act_id, :course_act_type, :created_at], :name => "course_act_index" + end +end diff --git a/db/migrate/20160325030423_add_index_to_user_activities.rb b/db/migrate/20160325030423_add_index_to_user_activities.rb new file mode 100644 index 000000000..f14f0d7ce --- /dev/null +++ b/db/migrate/20160325030423_add_index_to_user_activities.rb @@ -0,0 +1,5 @@ +class AddIndexToUserActivities < ActiveRecord::Migration + def change + add_index :user_activities, [:act_id, :act_type, :container_id, :created_at], :name => "user_act_index" + end +end diff --git a/db/migrate/20160328022312_add_coulumn_show_mode_to_organizations.rb b/db/migrate/20160328022312_add_coulumn_show_mode_to_organizations.rb new file mode 100644 index 000000000..11f3fa22e --- /dev/null +++ b/db/migrate/20160328022312_add_coulumn_show_mode_to_organizations.rb @@ -0,0 +1,5 @@ +class AddCoulumnShowModeToOrganizations < ActiveRecord::Migration + def change + add_column :organizations, :show_mode, :integer, :default => 0 + end +end diff --git a/db/migrate/20160328022623_set_show_mode_for_organizations.rb b/db/migrate/20160328022623_set_show_mode_for_organizations.rb new file mode 100644 index 000000000..719dfc1ff --- /dev/null +++ b/db/migrate/20160328022623_set_show_mode_for_organizations.rb @@ -0,0 +1,12 @@ +class SetShowModeForOrganizations < ActiveRecord::Migration + def up + Organization.transaction do + Organization.all.each do |org| + org.update_attribute(:show_mode, 0) + end + end + end + + def down + end +end diff --git a/db/migrate/20160329014316_update_one_student_teacher_score.rb b/db/migrate/20160329014316_update_one_student_teacher_score.rb new file mode 100644 index 000000000..cf56db220 --- /dev/null +++ b/db/migrate/20160329014316_update_one_student_teacher_score.rb @@ -0,0 +1,17 @@ +class UpdateOneStudentTeacherScore < ActiveRecord::Migration + def up + work = StudentWork.find 49774 + score = StudentWorksScore.new + score.score = 100 + score.user_id = 7318 + score.student_work_id = work.id + score.reviewer_role = 1 + if score.save + work.teacher_score = score.score + end + work.save + end + + def down + end +end diff --git a/db/migrate/20160331063938_add_status_to_org_subfields.rb b/db/migrate/20160331063938_add_status_to_org_subfields.rb new file mode 100644 index 000000000..70ce25e0c --- /dev/null +++ b/db/migrate/20160331063938_add_status_to_org_subfields.rb @@ -0,0 +1,5 @@ +class AddStatusToOrgSubfields < ActiveRecord::Migration + def change + add_column :org_subfields, :status, :integer, :default => true + end +end diff --git a/db/migrate/20160405021915_delete_anonymous_work.rb b/db/migrate/20160405021915_delete_anonymous_work.rb new file mode 100644 index 000000000..1677b248a --- /dev/null +++ b/db/migrate/20160405021915_delete_anonymous_work.rb @@ -0,0 +1,19 @@ +class DeleteAnonymousWork < ActiveRecord::Migration + def up + student_works = StudentWork.where("homework_common_id = 2882").map{|work| work.id} unless StudentWork.where("homework_common_id = 2882").empty? + student_work_ids = "(" + student_works.join(",") + ")" + student_work_scores = StudentWorksScore.where("student_work_id in #{student_work_ids}") + unless student_work_scores.empty? + student_work_scores.each do |sscore| + student_work = StudentWork.find sscore.student_work_id + student_work.student_score = 0 unless student_work.nil? + student_work.absence_penalty = 0 + sscore.destroy + student_work.save + end + end + end + + def down + end +end diff --git a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb index 6b22496b6..f5b48544d 100644 --- a/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb +++ b/lib/plugins/acts_as_attachable/lib/acts_as_attachable.rb @@ -140,6 +140,7 @@ module Redmine if file && file.size > 0 a = Attachment.create(:file => file, :author => author) elsif token + # 通过token值找到对应的attachment a = Attachment.find_by_token_only(token) if a a.filename = attachment['filename'] unless attachment['filename'].blank? diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index 50fc50b38..4a343ebf4 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -14,7 +14,7 @@ module RailsKindeditor output = ActiveSupport::SafeBuffer.new output << text_area_tag(name, content, input_html) output << javascript_tag(js_replace(id, options.merge(window_onload: 'true', - :autoHeightMode=>false, + :autoHeightMode=>true,#yuanke 所有调用该方法创建的KE都自动增高 afterCreate: eval_str(at_id, at_type), emotionsBasePath: 'http://' + Setting.host_name ))) @@ -29,7 +29,7 @@ module RailsKindeditor output_buffer = ActiveSupport::SafeBuffer.new output_buffer << build_text_area_tag(name, method, self, options, input_html) output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true', - :autoHeightMode=>false, + :autoHeightMode=>true,#yuanke 所有调用该方法创建的KE都自动增高 afterCreate: eval_str(at_id, at_type), emotionsBasePath: 'http://' + Setting.host_name ))) diff --git a/lib/redmine/pagination.rb b/lib/redmine/pagination.rb index 41702e2ce..9132f973c 100644 --- a/lib/redmine/pagination.rb +++ b/lib/redmine/pagination.rb @@ -1,336 +1,342 @@ -# 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. - -module Redmine - module Pagination - class Paginator - attr_reader :item_count, :per_page, :page, :page_param - def initialize(*args) - if args.first.is_a?(ActionController::Base) - args.shift - ActiveSupport::Deprecation.warn "Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments." - end - item_count, per_page, page, page_param = *args - - @item_count = item_count - @per_page = per_page - page = (page || 1).to_i - if page < 1 - page = 1 - end - @page = page - @page_param = page_param || :page - end - - def offset - (page - 1) * per_page - end - - ## fq - def reverse_offset - offset = @item_count-@per_page*page - if offset < 0 - offset = 0 - end - offset - end - ## end - - - def first_page - if item_count > 0 - 1 - end - end - - def previous_page - if page > 1 - page - 1 - end - end - - def next_page - if last_item < item_count - page + 1 - end - end - - def last_page - if item_count > 0 - (item_count - 1) / per_page + 1 - end - end - - def first_item - item_count == 0 ? 0 : (offset + 1) - end - - def last_item - l = first_item + per_page - 1 - l > item_count ? item_count : l - end - - def linked_pages - pages = [] - if item_count > 0 - pages += [first_page, page, last_page] - pages += ((page-2)..(page+2)).to_a.select {|p| p > first_page && p < last_page} - end - pages = pages.compact.uniq.sort - if pages.size > 1 - pages - else - [] - end - end - - def items_per_page - ActiveSupport::Deprecation.warn "Paginator#items_per_page will be removed. Use #per_page instead." - per_page - end - - def current - ActiveSupport::Deprecation.warn "Paginator#current will be removed. Use .offset instead of .current.offset." - self - end - end - - # Paginates the given scope or model. Returns a Paginator instance and - # the collection of objects for the current page. - # - # Options: - # :parameter name of the page parameter - # - # Examples: - # @user_pages, @users = paginate User.where(:status => 1) - # - def paginate(scope, options={}) - options = options.dup - finder_options = options.extract!( - :conditions, - :order, - :joins, - :include, - :select - ) - if scope.is_a?(Symbol) || finder_options.values.compact.any? - return deprecated_paginate(scope, finder_options, options) - end - - paginator = paginator(scope.count, options) - collection = scope.limit(paginator.per_page).offset(paginator.offset).to_a - - return paginator, collection - end - - def deprecated_paginate(arg, finder_options, options={}) - ActiveSupport::Deprecation.warn "#paginate with a Symbol and/or find options is depreceted and will be removed. Use a scope instead." - klass = arg.is_a?(Symbol) ? arg.to_s.classify.constantize : arg - scope = klass.scoped(finder_options) - paginate(scope, options) - end - - def paginator(item_count, options={}) - options.assert_valid_keys :parameter, :per_page - - page_param = options[:parameter] || :page - page = (params[page_param] || 1).to_i - per_page = options[:per_page] || per_page_option - Paginator.new(item_count, per_page, page, page_param) - end - - module Helper - include Redmine::I18n - # Renders the pagination links for the given paginator. - # - # Options: - # :per_page_links if set to false, the "Per page" links are not rendered - # - def pagination_links_full(*args) - pagination_links_each(*args) do |text, parameters, options| - if block_given? - yield text, parameters, options - else - link_to text, params.merge(parameters), options - end - end - end - - # Yields the given block with the text and parameters - # for each pagination link and returns a string that represents the links - # def pagination_links_each(paginator, count=nil, options={}, &block) - # options.assert_valid_keys :per_page_links - # - # per_page_links = options.delete(:per_page_links) - # per_page_links = false if count.nil? - # page_param = paginator.page_param - # - # html = '' - # if paginator.previous_page - # # \xc2\xab(utf-8) = « - # text = "\xc2\xab " + l(:label_previous) - # html << yield(text, {page_param => paginator.previous_page}, :class => 'previous') + ' ' - # end - # - # previous = nil - # paginator.linked_pages.each do |page| - # if previous && previous != page - 1 - # html << content_tag('span', '...', :class => 'spacer') + ' ' - # end - # if page == paginator.page - # html << content_tag('span', page.to_s, :class => 'current page') - # else - # html << yield(page.to_s, {page_param => page}, :class => 'page') - # end - # html << ' ' - # previous = page - # end - # - # if paginator.next_page - # # \xc2\xbb(utf-8) = » - # text = l(:label_next) + " \xc2\xbb" - # html << yield(text, {page_param => paginator.next_page}, :class => 'next') + ' ' - # end - # - # html << content_tag('span', "(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})", :class => 'items') + ' ' - # - # if per_page_links != false && links = per_page_links(paginator, &block) - # html << content_tag('span', links.to_s, :class => 'per-page') - # end - # - # html.html_safe - # end - #Added by Nie guanghui - #Designed for pagination. - def pagination_links_each(paginator, count=nil, options={}, &block) - #options.assert_valid_keys :per_page_links - - #per_page_links = options.delete(:per_page_links) - per_page_links = options[:per_page_links] - remote = options[:remote] ? options[:remote] : false - flag = options[:flag] ? options[:flag] : false - per_page_links = false if count.nil? - page_param = paginator.page_param - - html = '' - if paginator.previous_page - # \xc2\xab(utf-8) = « - if flag - text = l(:label_previous) - else - text = "\xc2\xab " + l(:label_previous) - end - html << '
  • ' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '
  • ' + ' ' - end - unless paginator.previous_page - if paginator.next_page - if flag - text = l(:label_previous) - else - text = "\xc2\xab " + l(:label_previous) - end - html << '
  • ' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '
  • ' + ' ' - end - end - - previous = nil - paginator.linked_pages.each do |page| - if previous && previous != page - 1 - if flag - html << '
  • ' << content_tag('a', '...', :class => 'c_blue') << '
  • ' + ' ' - else - html << '
  • ' << content_tag('span', '...', :class => 'spacer ') << '
  • ' + ' ' - end - end - if page == paginator.page - if flag - html << '
  • ' << content_tag('a', page.to_s, :class => 'current-page c_white') << '
  • ' - else - html << '
  • ' << content_tag('span', page.to_s, :class => 'current-page') << '
  • ' - end - else - html << '
  • ' << yield(page.to_s, {page_param => page}, :class => 'page c_blue', :remote => remote) << '
  • ' - end - html << ' ' - previous = page - end - - if paginator.next_page - if flag - text = l(:label_next) - else - text = l(:label_next) + " \xc2\xbb" - end - html << '
  • ' << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << '
  • ' + ' ' - end - - unless paginator.next_page - if paginator.previous_page - if flag - text = l(:label_next) - else - text = l(:label_next) + " \xc2\xbb" - end - html << "
  • " << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << "
  • " + ' ' - end - end - - # html << content_tag('span', "(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})", :class => 'items') + ' ' - # - # if per_page_links != false && links = per_page_links(paginator, &block) - # html << content_tag('span', links.to_s, :class => 'per-page') - # end - - html.html_safe - end - - # Renders the "Per page" links. - def per_page_links(paginator, &block) - values = per_page_options(paginator.per_page, paginator.item_count) - if values.any? - links = values.collect do |n| - if n == paginator.per_page - content_tag('span', n.to_s) - else - yield(n, :per_page => n, paginator.page_param => nil) - end - end - l(:label_display_per_page, links.join(', ')).html_safe - end - end - - def per_page_options(selected=nil, item_count=nil) - options = Setting.per_page_options_array - if item_count && options.any? - if item_count > options.first - max = options.detect {|value| value >= item_count} || item_count - else - max = item_count - end - options = options.select {|value| value <= max || value == selected} - end - if options.empty? || (options.size == 1 && options.first == selected) - [] - else - options - end - end - end - 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. + +module Redmine + module Pagination + class Paginator + attr_reader :item_count, :per_page, :page, :page_param + def initialize(*args) + if args.first.is_a?(ActionController::Base) + args.shift + ActiveSupport::Deprecation.warn "Paginator no longer takes a controller instance as the first argument. Remove it from #new arguments." + end + item_count, per_page, page, page_param = *args + + @item_count = item_count + @per_page = per_page + page = (page || 1).to_i + if page < 1 + page = 1 + end + @page = page + @page_param = page_param || :page + end + + def offset + (page - 1) * per_page + end + + ## fq + def reverse_offset + offset = @item_count-@per_page*page + if offset < 0 + offset = 0 + end + offset + end + ## end + + + def first_page + if item_count > 0 + 1 + end + end + + def previous_page + if page > 1 + page - 1 + end + end + + def next_page + if last_item < item_count + page + 1 + end + end + + def last_page + if item_count > 0 + (item_count - 1) / per_page + 1 + end + end + + def first_item + item_count == 0 ? 0 : (offset + 1) + end + + def last_item + l = first_item + per_page - 1 + l > item_count ? item_count : l + end + + def linked_pages + pages = [] + if item_count > 0 + pages += [first_page, page, last_page] + pages += ((page-2)..(page+2)).to_a.select {|p| p > first_page && p < last_page} + end + pages = pages.compact.uniq.sort + if pages.size > 1 + pages + else + [] + end + end + + def items_per_page + ActiveSupport::Deprecation.warn "Paginator#items_per_page will be removed. Use #per_page instead." + per_page + end + + def current + ActiveSupport::Deprecation.warn "Paginator#current will be removed. Use .offset instead of .current.offset." + self + end + end + + # Paginates the given scope or model. Returns a Paginator instance and + # the collection of objects for the current page. + # + # Options: + # :parameter name of the page parameter + # + # Examples: + # @user_pages, @users = paginate User.where(:status => 1) + # + def paginate(scope, options={}) + options = options.dup + finder_options = options.extract!( + :conditions, + :order, + :joins, + :include, + :select + ) + if scope.is_a?(Symbol) || finder_options.values.compact.any? + return deprecated_paginate(scope, finder_options, options) + end + + paginator = paginator(scope.count, options) + collection = scope.limit(paginator.per_page).offset(paginator.offset).to_a + + return paginator, collection + end + + def deprecated_paginate(arg, finder_options, options={}) + ActiveSupport::Deprecation.warn "#paginate with a Symbol and/or find options is depreceted and will be removed. Use a scope instead." + klass = arg.is_a?(Symbol) ? arg.to_s.classify.constantize : arg + scope = klass.scoped(finder_options) + paginate(scope, options) + end + + def paginator(item_count, options={}) + options.assert_valid_keys :parameter, :per_page + + page_param = options[:parameter] || :page + page = (params[page_param] || 1).to_i + per_page = options[:per_page] || per_page_option + Paginator.new(item_count, per_page, page, page_param) + end + + module Helper + include Redmine::I18n + # Renders the pagination links for the given paginator. + # + # Options: + # :per_page_links if set to false, the "Per page" links are not rendered + # + def pagination_links_full(*args) + page = "" + pagination_links_each(*args) do |text, parameters, options| + if block_given? + yield text, parameters, options + else + if args[2].nil? || args[2][:path].nil? + link_to text, params.merge(parameters), options + else + page = "&page=" + parameters[:page].to_s unless parameters[:page].nil? + link_to text, args[2][:path].to_s + page, options + end + end + end + end + + # Yields the given block with the text and parameters + # for each pagination link and returns a string that represents the links + # def pagination_links_each(paginator, count=nil, options={}, &block) + # options.assert_valid_keys :per_page_links + # + # per_page_links = options.delete(:per_page_links) + # per_page_links = false if count.nil? + # page_param = paginator.page_param + # + # html = '' + # if paginator.previous_page + # # \xc2\xab(utf-8) = « + # text = "\xc2\xab " + l(:label_previous) + # html << yield(text, {page_param => paginator.previous_page}, :class => 'previous') + ' ' + # end + # + # previous = nil + # paginator.linked_pages.each do |page| + # if previous && previous != page - 1 + # html << content_tag('span', '...', :class => 'spacer') + ' ' + # end + # if page == paginator.page + # html << content_tag('span', page.to_s, :class => 'current page') + # else + # html << yield(page.to_s, {page_param => page}, :class => 'page') + # end + # html << ' ' + # previous = page + # end + # + # if paginator.next_page + # # \xc2\xbb(utf-8) = » + # text = l(:label_next) + " \xc2\xbb" + # html << yield(text, {page_param => paginator.next_page}, :class => 'next') + ' ' + # end + # + # html << content_tag('span', "(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})", :class => 'items') + ' ' + # + # if per_page_links != false && links = per_page_links(paginator, &block) + # html << content_tag('span', links.to_s, :class => 'per-page') + # end + # + # html.html_safe + # end + #Added by Nie guanghui + #Designed for pagination. + def pagination_links_each(paginator, count=nil, options={}, &block) + #options.assert_valid_keys :per_page_links + + #per_page_links = options.delete(:per_page_links) + per_page_links = options[:per_page_links] + remote = options[:remote] ? options[:remote] : false + flag = options[:flag] ? options[:flag] : false + per_page_links = false if count.nil? + page_param = paginator.page_param + + html = '' + if paginator.previous_page + # \xc2\xab(utf-8) = « + if flag + text = l(:label_previous) + else + text = "\xc2\xab " + l(:label_previous) + end + html << '
  • ' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '
  • ' + ' ' + end + unless paginator.previous_page + if paginator.next_page + if flag + text = l(:label_previous) + else + text = "\xc2\xab " + l(:label_previous) + end + html << '
  • ' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '
  • ' + ' ' + end + end + + previous = nil + paginator.linked_pages.each do |page| + if previous && previous != page - 1 + if flag + html << '
  • ' << content_tag('a', '...', :class => 'c_blue') << '
  • ' + ' ' + else + html << '
  • ' << content_tag('span', '...', :class => 'spacer ') << '
  • ' + ' ' + end + end + if page == paginator.page + if flag + html << '
  • ' << content_tag('a', page.to_s, :class => 'current-page c_white') << '
  • ' + else + html << '
  • ' << content_tag('span', page.to_s, :class => 'current-page') << '
  • ' + end + else + html << '
  • ' << yield(page.to_s, {page_param => page}, :class => 'page c_blue', :remote => remote) << '
  • ' + end + html << ' ' + previous = page + end + + if paginator.next_page + if flag + text = l(:label_next) + else + text = l(:label_next) + " \xc2\xbb" + end + html << '
  • ' << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << '
  • ' + ' ' + end + + unless paginator.next_page + if paginator.previous_page + if flag + text = l(:label_next) + else + text = l(:label_next) + " \xc2\xbb" + end + html << "
  • " << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << "
  • " + ' ' + end + end + + # html << content_tag('span', "(#{paginator.first_item}-#{paginator.last_item}/#{paginator.item_count})", :class => 'items') + ' ' + # + # if per_page_links != false && links = per_page_links(paginator, &block) + # html << content_tag('span', links.to_s, :class => 'per-page') + # end + + html.html_safe + end + + # Renders the "Per page" links. + def per_page_links(paginator, &block) + values = per_page_options(paginator.per_page, paginator.item_count) + if values.any? + links = values.collect do |n| + if n == paginator.per_page + content_tag('span', n.to_s) + else + yield(n, :per_page => n, paginator.page_param => nil) + end + end + l(:label_display_per_page, links.join(', ')).html_safe + end + end + + def per_page_options(selected=nil, item_count=nil) + options = Setting.per_page_options_array + if item_count && options.any? + if item_count > options.first + max = options.detect {|value| value >= item_count} || item_count + else + max = item_count + end + options = options.select {|value| value <= max || value == selected} + end + if options.empty? || (options.size == 1 && options.first == selected) + [] + else + options + end + end + end + end +end diff --git a/public/assets/kindeditor/kindeditor-min.js b/public/assets/kindeditor/kindeditor-min.js index 7b35f52fb..d91af51eb 100644 --- a/public/assets/kindeditor/kindeditor-min.js +++ b/public/assets/kindeditor/kindeditor-min.js @@ -174,7 +174,7 @@ function(a,c){var d=J(c,["prop","delete"])<0?b.plugin.getSelectedCell:b.plugin.g function(a,d){c[d]&&b.afterCreate(function(){Ka(this.edit.doc,c[d],function(){b.cmd.selection();b.clickToolbar(d)})});b.clickToolbar(d,function(){b.focus().exec(d,null)})});b.afterCreate(function(){function c(){f.range.moveToBookmark(j);f.select();X&&(a("div."+l,i).each(function(){a(this).after("
    ").remove(!0)}),a("span.Apple-style-span",i).remove(!0),a("span.Apple-tab-span",i).remove(!0),a("span[style]",i).each(function(){a(this).css("white-space")=="nowrap"&&a(this).remove(!0)}),a("meta",i).remove()); var d=i[0].innerHTML;i.remove();d!==""&&(X&&(d=d.replace(/(
    )\1/ig,"$1")),b.pasteType===2&&(d=d.replace(/(<(?:p|p\s[^>]*)>) *(<\/p>)/ig,""),/schemas-microsoft-com|worddocument|mso-\w+/i.test(d)?d=nb(d,b.filterMode?b.htmlTags:a.options.htmlTags):(d=U(d,b.filterMode?b.htmlTags:null),d=b.beforeSetHtml(d))),b.pasteType===1&&(d=d.replace(/ /ig," "),d=d.replace(/\n\s*\n/g,"\n"),d=d.replace(/]*>/ig,"\n"),d=d.replace(/<\/p>]*>/ig,"\n"),d=d.replace(/<[^>]+>/g,""),d=d.replace(/ {2}/g,"  "), b.newlineTag=="p"?/\n/.test(d)&&(d=d.replace(/^/,"

    ").replace(/$/,"

    ").replace(/\n/g,"

    ")):d=d.replace(/\n/g,"
    $&")),b.insertHtml(d,!0))}var d=b.edit.doc,f,j,i,l="__kindeditor_paste__",m=!1;a(d.body).bind("paste",function(p){if(b.pasteType===0)p.stop();else if(!m){m=!0;a("div."+l,d).remove();f=b.cmd.selection();j=f.range.createBookmark();i=a('

    ',d).css({position:"absolute",width:"1px",height:"1px",overflow:"hidden",left:"-1981px",top:a(j.start).pos().y+ -"px","white-space":"nowrap"});a(d.body).append(i);if(o){var s=f.range.get(!0);s.moveToElementText(i[0]);s.select();s.execCommand("paste");p.preventDefault()}else f.range.selectNodeContents(i[0]),f.select();setTimeout(function(){c();m=!1},0)}})});b.beforeGetHtml(function(a){o&&A<=8&&(a=a.replace(/]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b){return unescape(b)}),a=a.replace(/(]*)?>)/ig,function(a,b,c){if(!/\s+type="[^"]+"/i.test(a))return b+' type="text"'+ +"px","white-space":"nowrap"});a(d.body).append(i);if(o||Yb){var s=f.range.get(!0);s.moveToElementText(i[0]);s.select();s.execCommand("paste");p.preventDefault()}else f.range.selectNodeContents(i[0]),f.select();setTimeout(function(){c();m=!1},0)}})});b.beforeGetHtml(function(a){o&&A<=8&&(a=a.replace(/]*data-ke-input-tag="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b){return unescape(b)}),a=a.replace(/(]*)?>)/ig,function(a,b,c){if(!/\s+type="[^"]+"/i.test(a))return b+' type="text"'+ c;return a}));return a.replace(/(<(?:noscript|noscript\s[^>]*)>)([\s\S]*?)(<\/noscript>)/ig,function(a,b,c,d){return b+fa(c).replace(/\s+/g," ")+d}).replace(/]*class="?ke-(flash|rm|media)"?[^>]*>/ig,function(a){var a=I(a),b=ba(a.style||""),c=pb(a["data-ke-tag"]),d=l(b.width,""),b=l(b.height,"");/px/i.test(d)&&(d=t(d));/px/i.test(b)&&(b=t(b));c.width=l(a.width,d);c.height=l(a.height,b);return Ma(c)}).replace(/]*class="?ke-anchor"?[^>]*>/ig,function(a){a=I(a);return''}).replace(/]*data-ke-script-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b,c){return""+unescape(c)+"<\/script>"}).replace(/]*data-ke-noscript-attr="([^"]*)"[^>]*>([\s\S]*?)<\/div>/ig,function(a,b,c){return""+unescape(c)+""}).replace(/(<[^>]*)data-ke-src="([^"]*)"([^>]*>)/ig,function(a,b,c){a=a.replace(/(\s+(?:href|src)=")[^"]*(")/i,function(a,b,d){return b+fa(c)+d});return a=a.replace(/\s+data-ke-src="[^"]*"/i, "")}).replace(/(<[^>]+\s)data-ke-(on\w+="[^"]*"[^>]*>)/ig,function(a,b,c){return b+c})});b.beforeSetHtml(function(a){o&&A<=8&&(a=a.replace(/]*>|<(select|button)[^>]*>[\s\S]*?<\/\1>/ig,function(a){var b=I(a);if(ba(b.style||"").display=="none")return'
    ';return a}));return a.replace(/]*type="([^"]+)"[^>]*>(?:<\/embed>)?/ig,function(a){a=I(a);a.src=l(a.src,"");a.width=l(a.width,0);a.height=l(a.height,0);return qb(b.themesPath+ diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 060898b88..74013be54 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -251,7 +251,7 @@ K.options = { langType : 'zh_CN', urlType : '', newlineTag : 'p', - resizeType : 2, + resizeType : 1, syncType : 'form', pasteType : 2, dialogAlignType : 'page', @@ -4938,7 +4938,7 @@ KEditor.prototype = { afterSetHtml : function(fn) { return this.handler('afterSetHtml', fn); }, - create : function() { + create : function() {K var self = this, fullscreenMode = self.fullscreenMode; if (self.isCreated) { return self; @@ -5076,8 +5076,11 @@ KEditor.prototype = { self.afterSetHtml(); }, afterCreate : function() { - self.edit = edit = this; + self.loadPlugin('autoheight'); + self.edit = edit = this; self.cmd = edit.cmd; + //edit.iframe[0].scroll = 'no'; + //edit.doc.body.style.overflowY = 'hidden'; self._docMousedownFn = function(e) { if (self.menu) { self.hideMenu(); @@ -6015,6 +6018,7 @@ _plugin('core', function(K) { 'white-space' : 'nowrap' }); K(doc.body).append(div); + if (_IE) { var rng = cmd.range.get(true); rng.moveToElementText(div[0]); diff --git a/public/assets/kindeditor/plugins/autoheight/autoheight.js b/public/assets/kindeditor/plugins/autoheight/autoheight.js index b63dc7062..82928ff0c 100644 --- a/public/assets/kindeditor/plugins/autoheight/autoheight.js +++ b/public/assets/kindeditor/plugins/autoheight/autoheight.js @@ -9,7 +9,7 @@ KindEditor.plugin('autoheight', function(K) { var self = this; - + //self.autoHeightMode = true; if (!self.autoHeightMode) { return; } diff --git a/public/images/org_new_style/banner.jpg b/public/images/org_new_style/banner.jpg new file mode 100644 index 000000000..3cf23c4e5 Binary files /dev/null and b/public/images/org_new_style/banner.jpg differ diff --git a/public/images/org_new_style/cd-top-arrow.svg b/public/images/org_new_style/cd-top-arrow.svg new file mode 100644 index 000000000..e80e10297 --- /dev/null +++ b/public/images/org_new_style/cd-top-arrow.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/public/images/org_new_style/con-left1.jpg b/public/images/org_new_style/con-left1.jpg new file mode 100644 index 000000000..f4936fa85 Binary files /dev/null and b/public/images/org_new_style/con-left1.jpg differ diff --git a/public/images/org_new_style/con-left2.jpg b/public/images/org_new_style/con-left2.jpg new file mode 100644 index 000000000..b7b7f3472 Binary files /dev/null and b/public/images/org_new_style/con-left2.jpg differ diff --git a/public/images/org_new_style/con-right.gif b/public/images/org_new_style/con-right.gif new file mode 100644 index 000000000..d49c2003e Binary files /dev/null and b/public/images/org_new_style/con-right.gif differ diff --git a/public/images/org_new_style/default-img.jpg b/public/images/org_new_style/default-img.jpg new file mode 100644 index 000000000..e345ca3d7 Binary files /dev/null and b/public/images/org_new_style/default-img.jpg differ diff --git a/public/images/org_new_style/default-img2.jpg b/public/images/org_new_style/default-img2.jpg new file mode 100644 index 000000000..8d194d605 Binary files /dev/null and b/public/images/org_new_style/default-img2.jpg differ diff --git a/public/images/org_new_style/default-img2.png b/public/images/org_new_style/default-img2.png new file mode 100644 index 000000000..3a824b1f6 Binary files /dev/null and b/public/images/org_new_style/default-img2.png differ diff --git a/public/images/org_new_style/detailimg4.jpg b/public/images/org_new_style/detailimg4.jpg new file mode 100644 index 000000000..22b3e674d Binary files /dev/null and b/public/images/org_new_style/detailimg4.jpg differ diff --git a/public/images/org_new_style/icons.png b/public/images/org_new_style/icons.png new file mode 100644 index 000000000..d31d59a88 Binary files /dev/null and b/public/images/org_new_style/icons.png differ diff --git a/public/images/org_new_style/img1.jpg b/public/images/org_new_style/img1.jpg new file mode 100644 index 000000000..acfee71e5 Binary files /dev/null and b/public/images/org_new_style/img1.jpg differ diff --git a/public/images/org_new_style/img2.jpg b/public/images/org_new_style/img2.jpg new file mode 100644 index 000000000..72741b981 Binary files /dev/null and b/public/images/org_new_style/img2.jpg differ diff --git a/public/images/org_new_style/logo.jpg b/public/images/org_new_style/logo.jpg new file mode 100644 index 000000000..689bd958a Binary files /dev/null and b/public/images/org_new_style/logo.jpg differ diff --git a/public/images/org_new_style/pic1.jpg b/public/images/org_new_style/pic1.jpg new file mode 100644 index 000000000..8866da4cb Binary files /dev/null and b/public/images/org_new_style/pic1.jpg differ diff --git a/public/images/org_new_style/pic2.jpg b/public/images/org_new_style/pic2.jpg new file mode 100644 index 000000000..1ad7665e7 Binary files /dev/null and b/public/images/org_new_style/pic2.jpg differ diff --git a/public/images/org_new_style/pic3.jpg b/public/images/org_new_style/pic3.jpg new file mode 100644 index 000000000..5f276d3df Binary files /dev/null and b/public/images/org_new_style/pic3.jpg differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 2eaac8c39..9c3afd48b 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1,1222 +1,1240 @@ -//= require_directory ./rateable -//= require jquery.min -//= require jquery.infinitescroll - -/* Redmine - project management software - Copyright (C) 2006-2013 Jean-Philippe Lang */ - -//动态高度控制 -function description_show_hide(id){ - showNormalImage('activity_description_'+id); - if($("#intro_content_"+id).height() > 810) { - $("#intro_content_show_"+id).show(); - } - $("#intro_content_show_"+id).click(function(){ - $("#activity_description_"+id).toggleClass("maxh360"); - $("#intro_content_show_"+id).hide(); - $("#intro_content_hide_"+id).show(); - }); - $("#intro_content_hide_"+id).click(function(){ - $("#activity_description_"+id).toggleClass("maxh360"); - $("#intro_content_hide_"+id).hide(); - $("#intro_content_show_"+id).show(); - }); -} - -function cleanArray (actual){ - var newArray = new Array(); - for (var i = 0; i< actual.length; i++){ - if (actual[i]){ - newArray.push(actual[i]); - } - } - return newArray; -} - -function checkAll(id, checked) { - if (checked) { - $('#'+id).find('input[type=checkbox]').attr('checked', true); - } else { - $('#'+id).find('input[type=checkbox]').removeAttr('checked'); - } -} - -function toggleCheckboxesBySelector(selector) { - var all_checked = true; - $(selector).each(function(index) { - if (!$(this).is(':checked')) { all_checked = false; } - }); - $(selector).attr('checked', !all_checked); -} - -function showAndScrollTo(id, focus) { - $('#'+id).show(); - if (focus !== null) { - $('#'+focus).focus(); - } - $('html, body').animate({scrollTop: $('#'+id).offset().top}, 400); -} - -function toggleRowGroup(el) { - var tr = $(el).parents('tr').first(); - var n = tr.next(); - tr.toggleClass('open'); - while (n.length && !n.hasClass('group')) { - n.toggle(); - n = n.next('tr'); - } -} - -function collapseAllRowGroups(el) { - var tbody = $(el).parents('tbody').first(); - tbody.children('tr').each(function(index) { - if ($(this).hasClass('group')) { - $(this).removeClass('open'); - } else { - $(this).hide(); - } - }); -} - -function expandAllRowGroups(el) { - var tbody = $(el).parents('tbody').first(); - tbody.children('tr').each(function(index) { - if ($(this).hasClass('group')) { - $(this).addClass('open'); - } else { - $(this).show(); - } - }); -} - -function toggleAllRowGroups(el) { - var tr = $(el).parents('tr').first(); - if (tr.hasClass('open')) { - collapseAllRowGroups(el); - } else { - expandAllRowGroups(el); - } -} - -function toggleFieldset(el) { - var fieldset = $(el).parents('fieldset').first(); - fieldset.toggleClass('collapsed'); - fieldset.children('div').toggle(); -} - -function hideFieldset(el) { - var fieldset = $(el).parents('fieldset').first(); - fieldset.toggleClass('collapsed'); - fieldset.children('div').hide(); -} - -function initFilters(){ - $('#add_filter_select').change(function(){ - addFilter($(this).val(), '', []); - }); - $('#filters-table td.field input[type=checkbox]').each(function(){ - toggleFilter($(this).val()); - }); - $('#filters-table td.field input[type=checkbox]').on('click',function(){ - toggleFilter($(this).val()); - }); - $('#filters-table .toggle-multiselect').on('click',function(){ - toggleMultiSelect($(this).siblings('select')); - }); - $('#filters-table input[type=text]').on('keypress', function(e){ - if (e.keyCode == 13) submit_query_form("query_form"); - }); -} - -function addFilter(field, operator, values) { - var fieldId = field.replace('.', '_'); - var tr = $('#tr_'+fieldId); - if (tr.length > 0) { - tr.show(); - } else { - buildFilterRow(field, operator, values); - } - $('#cb_'+fieldId).attr('checked', true); - toggleFilter(field); - $('#add_filter_select').val('').children('option').each(function(){ - if ($(this).attr('value') == field) { - $(this).attr('disabled', true); - } - }); -} - -function buildFilterRow(field, operator, values) { - var fieldId = field.replace('.', '_'); - var filterTable = $("#filters-table"); - var filterOptions = availableFilters[field]; - var operators = operatorByType[filterOptions['type']]; - var filterValues = filterOptions['values']; - var i, select; - - var tr = $('
    ').attr('id', 'tr_'+fieldId).html( - '' + - '' + - '' - ); - filterTable.append(tr); - - select = tr.find('td.operator select'); - for (i=0;i').val(operators[i]).text(operatorLabels[operators[i]]); - if (operators[i] == operator) { option.attr('selected', true); } - select.append(option); - } - select.change(function(){ toggleOperator(field); }); - - switch (filterOptions['type']){ - case "list": - case "list_optional": - case "list_status": - case "list_subprojects": - tr.find('td.values').append( - '' + - ' 复选/multi-select' - ); - select = tr.find('td.values select'); - if (values.length > 1) { select.attr('multiple', true); } - for (i=0;i'); - if ($.isArray(filterValue)) { - option.val(filterValue[1]).text(filterValue[0]); - if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);} - } else { - option.val(filterValue).text(filterValue); - if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);} - } - select.append(option); - } - break; - case "date": - case "date_past": - tr.find('td.values').append( - '' + - ' ' + - ' '+labelDayPlural+'' - ); - $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions); - $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions); - $('#values_'+fieldId).val(values[0]); - break; - case "string": - case "text": - tr.find('td.values').append( - '' - ); - $('#values_'+fieldId).val(values[0]); - break; - case "relation": - tr.find('td.values').append( - '' + - '' - ); - $('#values_'+fieldId).val(values[0]); - select = tr.find('td.values select'); - for (i=0;i'); - option.val(filterValue[1]).text(filterValue[0]); - if (values[0] == filterValue[1]) { option.attr('selected', true); } - select.append(option); - } - case "integer": - case "float": - tr.find('td.values').append( - '' + - ' ' - ); - $('#values_'+fieldId+'_1').val(values[0]); - $('#values_'+fieldId+'_2').val(values[1]); - break; - } -} - -function toggleFilter(field) { - var fieldId = field.replace('.', '_'); - if ($('#cb_' + fieldId).is(':checked')) { - $("#operators_" + fieldId).show().removeAttr('disabled'); - toggleOperator(field); - } else { - $("#operators_" + fieldId).hide().attr('disabled', true); - enableValues(field, []); - } -} - -function enableValues(field, indexes) { - var fieldId = field.replace('.', '_'); - $('#tr_'+fieldId+' td.values .value').each(function(index) { - if ($.inArray(index, indexes) >= 0) { - $(this).removeAttr('disabled'); - $(this).parents('span').first().show(); - } else { - $(this).val(''); - $(this).attr('disabled', true); - $(this).parents('span').first().hide(); - } - - if ($(this).hasClass('group')) { - $(this).addClass('open'); - } else { - $(this).show(); - } - }); -} - -function toggleOperator(field) { - var fieldId = field.replace('.', '_'); - var operator = $("#operators_" + fieldId); - switch (operator.val()) { - case "!*": - case "*": - case "t": - case "ld": - case "w": - case "lw": - case "l2w": - case "m": - case "lm": - case "y": - case "o": - case "c": - enableValues(field, []); - break; - case "><": - enableValues(field, [0,1]); - break; - case "t+": - case ">t-": - case "0) { - lis.eq(i-1).show(); - } -} - -function displayTabsButtons() { - var lis; - var tabsWidth = 0; - var el; - $('div.tabs').each(function() { - el = $(this); - lis = el.find('ul').children(); - lis.each(function(){ - if ($(this).is(':visible')) { - tabsWidth += $(this).width() + 6; - } - }); - if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) { - el.find('div.tabs-buttons').hide(); - } else { - el.find('div.tabs-buttons').show(); - } - }); -} - -function setPredecessorFieldsVisibility() { - var relationType = $('#relation_relation_type'); - if (relationType.val() == "precedes" || relationType.val() == "follows") { - $('#predecessor_fields').show(); - } else { - $('#predecessor_fields').hide(); - } -} - -function showModal(id, width) { - var el = $('#'+id).first(); - if (el.length === 0 || el.is(':visible')) {return;} - var title = el.find('h3.title').text(); - el.dialog({ - width: width, - modal: true, - resizable: false, - dialogClass: 'modal', - title: title - }); - el.find("input[type=text], input[type=submit]").first().focus(); -} - -function hideModal(el) { - var modal; - if (el) { - modal = $(el).parents('.ui-dialog-content'); - } else { - modal = $('#ajax-modal'); - } - modal.dialog("close"); -} - -function submitPreview(url, form, target) { - $.ajax({ - url: url, - type: 'post', - data: $('#'+form).serialize(), - success: function(data){ - $('#'+target).html(data); - } - }); -} - -function collapseScmEntry(id) { - $('.'+id).each(function() { - if ($(this).hasClass('open')) { - collapseScmEntry($(this).attr('id')); - } - $(this).hide(); - }); - $('#'+id).removeClass('open'); -} - -function expandScmEntry(id) { - $('.'+id).each(function() { - $(this).show(); - if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) { - expandScmEntry($(this).attr('id')); - } - }); - $('#'+id).addClass('open'); -} - -function scmEntryClick(id, url) { - el = $('#'+id); - if (el.hasClass('open')) { - collapseScmEntry(id); - el.addClass('collapsed'); - return false; - } else if (el.hasClass('loaded')) { - expandScmEntry(id); - el.removeClass('collapsed'); - return false; - } - if (el.hasClass('loading')) { - return false; - } - el.addClass('loading'); - $.ajax({ - url: url, - success: function(data){ - el.after(data); - el.addClass('open').addClass('loaded').removeClass('loading'); - } - }); - return true; -} - -function randomKey(size) { - var chars = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); - var key = ''; - for (i = 0; i < size; i++) { - key += chars[Math.floor(Math.random() * chars.length)]; - } - return key; -} - -// Can't use Rails' remote select because we need the form data -function updateIssueFrom(url) { - $.ajax({ - url: url, - type: 'post', - data: $('#issue-form').serialize() - }); -} - -function updateBulkEditFrom(url) { - $.ajax({ - url: url, - type: 'post', - data: $('#bulk_edit_form').serialize() - }); -} - -function clearMessage(id) { - $('#'+id).val(""); -} - - -function observeAutocompleteField(fieldId, url, options) { - $(document).ready(function() { - $('#'+fieldId).autocomplete($.extend({ - source: url, - select: function(e,ui){self.location="/issues/"+ui.item.value;}, - minLength: 1, - search: function(){$('#'+fieldId).addClass('ajax-loading');}, - response: function(){$('#'+fieldId).removeClass('ajax-loading'); - } - }, options)); - $('#'+fieldId).addClass('autocomplete'); - - }); - -} - -function observeSearchfield(fieldId, targetId, url) { - $('#'+fieldId).each(function() { - var $this = $(this); - $this.addClass('autocomplete'); - $this.attr('data-value-was', $this.val()); - var check = function() { - var val = $this.val(); - if ($this.attr('data-value-was') != val){ - $this.attr('data-value-was', val); - $.ajax({ - url: url, - type: 'get', - data: {q: $this.val()}, - success: function(data){ if(targetId) $('#'+targetId).html(data); }, - beforeSend: function(){ $this.addClass('ajax-loading'); }, - complete: function(){ $this.removeClass('ajax-loading'); } - }); - } - }; - var reset = function() { - if (timer) { - clearInterval(timer); - timer = setInterval(check, 300); - } - }; - var timer = setInterval(check, 300); - $this.bind('keyup click mousemove', reset); - }); -} - -function observeProjectModules() { - var f = function() { - /* Hides trackers and issues custom fields on the new project form when issue_tracking module is disabled */ - if ($('#project_enabled_module_names_issue_tracking').attr('checked')) { - $('#project_trackers').show(); - }else{ - $('#project_trackers').hide(); - } - }; - - $(window).load(f); - $('#project_enabled_module_names_issue_tracking').change(f); -} - -function initMyPageSortable(list, url) { - $('#list-'+list).sortable({ - connectWith: '.block-receiver', - tolerance: 'pointer', - update: function(){ - $.ajax({ - url: url, - type: 'post', - data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})} - }); - } - }); - $("#list-top, #list-left, #list-right").disableSelection(); -} - -var warnLeavingUnsavedMessage; -function warnLeavingUnsaved(message) { - warnLeavingUnsavedMessage = message; - - $('form').submit(function(){ - $('textarea').removeData('changed'); - }); - $('textarea').change(function(){ - $(this).data('changed', 'changed'); - }); - window.onbeforeunload = function(){ - var warn = false; - $('textarea').blur().each(function(){ - if ($(this).data('changed')) { - warn = true; - } - }); - if (warn) {return warnLeavingUnsavedMessage;} - }; -} - -function setupHeartBeat(){ - var time = 60*1000*30; // 30 mins - setInterval(function(){$.getJSON('/account/heartbeat');},time); -} - -function setupAjaxIndicator() { - $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) { - if(settings && settings.url && settings.url.match(/account\/heartbeat$/)){ - return; - } - if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') { - $('#ajax-indicator').show(); - } - }); - - $('#ajax-indicator').bind('ajaxStop', function() { - $('#ajax-indicator').hide(); - if(MathJax && MathJax.Hub) - MathJax.Hub.Queue(['Typeset', MathJax.Hub]); //如果是ajax刷新页面的话,手动执行MathJax的公式显示 - try{ - prettyPrint(); //如果刷新出来的页面如果存在代码行的话,也需要美化 - }catch (e){ - - } - }); -} - -function hideOnLoad() { - $('.hol').hide(); -} - -function addFormObserversForDoubleSubmit() { - $('form[method=post]').each(function() { - if (!$(this).hasClass('multiple-submit')) { - $(this).submit(function(form_submission) { - if ($(form_submission.target).attr('data-submitted')) { - form_submission.preventDefault(); - } else { - $(form_submission.target).attr('data-submitted', true); - } - }); - } - }); -} - -function blockEventPropagation(event) { - event.stopPropagation(); - event.preventDefault(); -} - -function toggleAndSettingWordsVal(parent_widget, text_widget, value){ - text_widget.val(value) - parent_widget.slideToggle(400) -} -function transpotUrl (scope) { - $(scope).each(function(){ - var tmpContent = $(this).html(); - tmpContent = tmpContent.replace(/(^|[^\"\'])(http|ftp|mms|rstp|news|https)(\:\/\/[^<\s\+,,]+)/gi,"$1$2$3<\/a>"); - // tmpContent = tmpContent.replace(/(^|[^\/])(www\.[^<\s\+,,]+)/gi,"$1$2"); - $(this).html(tmpContent); - }); -} - -$(document).ready(setupAjaxIndicator); -$(document).ready(setupHeartBeat); -$(document).ready(hideOnLoad); -$(document).ready(addFormObserversForDoubleSubmit); - -function img_thumbnails() { - $('.thumbnails a').colorbox({rel:'nofollow'}); - $('.attachments').find('a').each(function(index, element) { - var href_value = $(element).attr('href'); - if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) { - $(element).colorbox({rel:'nofollow'}); - } - }); - $('.for_img_thumbnails').find('a').each(function(index, element) { - var href_value = $(element).attr('href'); - if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) { - $(element).colorbox({rel:'nofollow'}); - } - }); -} -$(document).ready(img_thumbnails); - -function TimeClose(dateText, inst) { - if(inst.id=="issue_start_date"){ - time=dateText; - } -} -var time=new Date(); -function TimeBeforeShow(input){ - if(input.id=="issue_due_date"){ - //var minDate = $(input).datepicker('option', 'minDate'); - var tempdata=$("#issue_start_date").attr("value"); - - $(input).datepicker('option', 'minDate',new Date(tempdata.replace(/-/g, "/"))); - //$('.selector').datepicker('option', 'minDate', '12/25/2012'); - } -} - -function SetMinValue(){ - /// var tempdata=$("#issue_start_date").attr("value"); - //$('.selector').datepicker('option', 'minDate', '12/25/2012'); - //alert(tempdata); - //$("#issue_due_date").datepicker({ - // minDate: new Date(2014,08,23) - //var datepickerOptions= - //{dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}; - //alert( $('.issue_due_date').length); - //$('.selector')[1].datepicker('option', 'minDate', new Date(2014, 0 - 8, 23)); - //$("#issue_due_date").datepicker(datepickerOptions); - //$("##{issue_due_date}").datepicker(datepickerOptions); - //$("#issue_due_date").datepicker( - // {dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true} - //) - //}); -} -function PrecentChange(obj){ - var _v= obj; - if(_v==100) - { - //var select=$("select[id='issue_status_id']"); - $("select[id='issue_status_id']").find("option[value='3']").attr("selected","selected"); - } - else if(_v==0) - { - //alert(1); - $("select[id='issue_status_id']").find("option[value='1']").attr("selected","selected"); - } - else if(_v!=100&&_v!=0) - { - // alert(2); - $("select[id='issue_status_id']").find("option[value='2']").attr("selected","selected"); - } -} - -//added by lizanle 日期選擇js -function HS_DateAdd(interval,number,date){ - number = parseInt(number); - if (typeof(date)=="string"){var date = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2])} - if (typeof(date)=="object"){var date = date} - switch(interval){ - case "y":return new Date(date.getFullYear()+number,date.getMonth(),date.getDate()); break; - case "m":return new Date(date.getFullYear(),date.getMonth()+number,checkDate(date.getFullYear(),date.getMonth()+number,date.getDate())); break; - case "d":return new Date(date.getFullYear(),date.getMonth(),date.getDate()+number); break; - case "w":return new Date(date.getFullYear(),date.getMonth(),7*number+date.getDate()); break; - } -} -function checkDate(year,month,date){ - var enddate = ["31","28","31","30","31","30","31","31","30","31","30","31"]; - var returnDate = ""; - if (year%4==0){enddate[1]="29"} - if (date>enddate[month]){returnDate = enddate[month]}else{returnDate = date} - return returnDate; -} - -function WeekDay(date){ - var theDate; - if (typeof(date)=="string"){theDate = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2]);} - if (typeof(date)=="object"){theDate = date} - return theDate.getDay(); -} -function HS_calender(){ - var lis = ""; - var style = ""; - /*可以把下面的css剪切出去独立一个css文件*/ - style +=""; - - var now; - if (typeof(arguments[0])=="string"){ - selectDate = arguments[0].split("-"); - var year = selectDate[0]; - var month = parseInt(selectDate[1])-1+""; - var date = selectDate[2]; - now = new Date(year,month,date); - }else if (typeof(arguments[0])=="object"){ - now = arguments[0]; - } - var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate(); - var lastMonthDate = WeekDay(now.getFullYear()+"-"+now.getMonth()+"-01"); - var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01"); - var thisMonthEndDate = thisMonthLastDate.getDate(); - var thisMonthEndDay = thisMonthLastDate.getDay(); - var todayObj = new Date(); - today = todayObj.getFullYear()+"-"+todayObj.getMonth()+"-"+todayObj.getDate(); - - for (i=0; i" + lis; - lastMonthEndDate--; - } - for (i=1; i<=thisMonthEndDate; i++){ // Current Month's Date - - if(today == now.getFullYear()+"-"+now.getMonth()+"-"+i){ - var todayString = now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i; - lis += "
  • "+i+"
  • "; - }else{ - lis += "
  • "+i+"
  • "; - } - - } - var j=1; - for (i=thisMonthEndDay; i<6; i++){ // Next Month's Date - lis += "
  • "+j+"
  • "; - j++; - } - lis += style; - - var CalenderTitle = "»"; - CalenderTitle += "«"; - CalenderTitle += ""+now.getFullYear()+""+(parseInt(now.getMonth())+1).toString()+"月"; - - if (arguments.length>1){ - arguments[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis; - arguments[1].parentNode.innerHTML = CalenderTitle; - - }else{ - var CalenderBox = style+"
    "+CalenderTitle+"
      "+lis+"
    "; - return CalenderBox; - } -} -function _selectThisDay(d){ - var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode; - boxObj.targetObj.value = d.title; - boxObj.parentNode.removeChild(boxObj); -} -function closeCalender(d){ - var boxObj = d.parentNode.parentNode.parentNode; - boxObj.parentNode.removeChild(boxObj); -} - -function CalenderselectYear(obj){ - var opt = ""; - var thisYear = obj.innerHTML; - for (i=1970; i<=2020; i++){ - if (i==thisYear){ - opt += ""; - }else{ - opt += ""; - } - } - opt = ""; - obj.parentNode.innerHTML = opt; -} - -function selectThisYear(obj){ - HS_calender(obj.value+"-"+obj.parentNode.parentNode.getElementsByTagName("span")[1].getElementsByTagName("a")[0].innerHTML+"-1",obj.parentNode); -} - -function CalenderselectMonth(obj){ - var opt = ""; - var thisMonth = obj.innerHTML; - for (i=1; i<=12; i++){ - if (i==thisMonth){ - opt += ""; - }else{ - opt += ""; - } - } - opt = ""; - obj.parentNode.innerHTML = opt; -} -function selectThisMonth(obj){ - HS_calender(obj.parentNode.parentNode.getElementsByTagName("span")[0].getElementsByTagName("a")[0].innerHTML+"-"+obj.value+"-1",obj.parentNode); -} -function HS_setDate(inputObj){ - var calenderObj = document.createElement("span"); - calenderObj.innerHTML = HS_calender(new Date()); - calenderObj.style.position = "absolute"; - calenderObj.targetObj = inputObj; - inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling); -} -//lizanle 刷新函数 -function redo() { - window.location.reload() -} - -function encodeHomeworkUrl(url, is_base64){ - if(typeof is_base64 === 'boolean' && is_base64){ - return '/zipdown/download?base64file='+url; - } - var file = encodeURI(url).replace(/\+/g, '%2B'); - return '/zipdown/download?file='+file; -} - -//// 作业附件删除 -$(function(){ - $('.attachments a.delete-homework-icon').bind('ajax:complete', //this will work - function(event, data, status, xhr) { //note parametes - $(this).parent('p').remove(); - console.log("delete complete."); - }); - - $('a.tb_all').bind('ajax:complete', function (event, data, status, xhr) { - if(status == 'success'){ - var res = JSON.parse(data.responseText); - if(res.length<1){ - return; - } - - if(res.length==1){ - if(res[0].base64file){ - location.href = encodeHomeworkUrl(res[0].base64file, true);return; - } - location.href = encodeHomeworkUrl(res[0].file);return; - } - - document.getElementById('light').style.display='block'; - $container = $('#light .upload_box_ul'); - $container.empty(); - for(var i = 0; i 1){ - des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; - } else { - des = '第'+res[i].index+'个学生的作品下载'; - } - - if(res[i].base64file){ - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); - } else { - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); - } - } - } - }); - $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { - if(status == 'success'){ - var res = JSON.parse(data.responseText); - if(res.length == null){ - alert("该作业没有任何附件可下载"); - } - else if(res.length<1){ - return; - } - else - { - if(res.length==1){ - if(res[0].base64file){ - location.href = encodeHomeworkUrl(res[0].base64file, true);return; - } - location.href = encodeHomeworkUrl(res[0].file);return; - } - document.getElementById('light').style.display='block'; - $container = $('#light .upload_box_ul'); - $container.empty(); - for(var i = 0; i 1){ - des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; - } else { - des = '第'+res[i].index+'个学生的作品下载'; - } - - if(res[i].base64file){ - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); - } else { - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); - } - - } - } - } - }); -}); - - -//firefox的pre标签换行 -$(document).ready(function () { - var userAgent = navigator.userAgent.toLowerCase(); - var browser = { - version: (userAgent.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/) || [])[1], - safari: /webkit/.test(userAgent), - opera: /opera/.test(userAgent), - msie: /msie/.test(userAgent) && !/opera/.test(userAgent), - mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) - }; - if (browser.mozilla || browser.opera){ - $("pre").addClass("break_word_firefox"); - } - else{ - $("pre").addClass("break_word"); - } -}); - -//点击发送资源弹出框中的组织,要更改选择栏目中的内容 -//@dom 选中的radio,值为org_id -function change_org_subfield(url){ - $.ajax({ - type:'get', - url:url - }) -} - -//点击图片即显示大图 -function showNormalImage(id) { - var description_images=$('div#'+id).find("img"); - if (description_images.length>0) { - for (var i=0; i").attr("href",image.attr('src')); - image.wrap(element); - $(image).parent().colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); - } - //$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框 - } - -} - - -//文件、帖子、通知分享 -function org_id_click(){ - var sendText = $("input[name='org_id']:checked").next().text(); - var orgDirection = "目标地址:"; - $(".orgDirection").text(orgDirection + sendText); -} -function subfield_click(){ - var sendText = $("input[name='org_id']:checked").next().text(); - var orgDirection = "目标地址:"; - var sendColumn = $("input[name='subfield']:checked").next().text(); - $(".orgDirection").text(orgDirection + sendText + " / " + sendColumn); -} - -//send_type:发送的类型,file对应文件,message对应帖子,news对应通知或新闻 -function observeSearchfieldOnInput(fieldId, url,send_id,send_ids, send_type) { - $('#'+fieldId).each(function() { - var $this = $(this); - $this.addClass('autocomplete'); - $this.attr('data-value-was', $this.val()); - var check = function() { - var val = $this.val(); - if ($this.attr('data-value-was') != val){ - $this.attr('data-value-was', val); - $.ajax({ - url: url, - type: 'get', - data: {search: $this.val(),send_id:send_id,send_ids:send_ids, send_type:send_type}, - success: function(data){ }, - beforeSend: function(){ $this.addClass('ajax-loading'); }, - complete: function(){ $this.removeClass('ajax-loading'); } - }); - } - }; - var reset = function() { - if (timer) { - clearInterval(timer); - timer = setInterval(check, 300); - } - }; - var timer = setInterval(check, 300); - $this.bind('keyup click mousemove', reset); - }); -} -function check_des(event){ - if($(".sectionContent").find('input[type="radio"]:checked').length <= 0){ - event.preventDefault(); - $(".orgDirection").text('目标地址组织不能为空'); - return false; - }else if($(".columnContent").find('input[type="radio"]:checked').length <= 0){ - event.preventDefault(); - $(".orgDirection").text('目标地址栏目不能为空'); - return false; - }else{ - return true; - } -} - -var sendType = '1'; -var lastSendType ;//初始为发送到我的课程 -function show_send(id, user_id, send_type){ - if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 - $.ajax({ - type: 'get', - url: '/users/' + user_id + '/search_user_project', - data:{send_id:id, send_type:send_type} - }); - }else if(lastSendType == '1'){ - $.ajax({ - type: 'get', - url: '/users/' + user_id + '/search_user_course', - data:{send_id:id, send_type:send_type} - }); - }else if( lastSendType == '3'){//组织 - $.ajax({ - type: 'get', - url: '/users/' + user_id + '/search_user_org', - data:{send_id:id, send_type:send_type} - }); - }else{ - $.ajax({ - type: 'get', - url: '/users/' + user_id + '/search_user_course', - data:{send_id:id, send_type:send_type} - }); - } -} - -//id 发送的id -//发送的id数组 -//send_type:发送的类型,file对应文件,message对应帖子,news对应通知或新闻 -function chooseSendType(res_id,res_ids, user_id, send_type){ - - sendType = $(".resourcesSendType").val(); - if (sendType === lastSendType) { - return; - } else if(lastSendType != null) { //不是第一次点击的时候 - if (sendType == '1') { - $.ajax({ - type: 'get', - url: '/users/' + user_id + '/search_user_course', - data:{send_id:res_id, send_type:send_type} - }); - } else if(sendType == '2') { - $.ajax({ - type: 'get', - url: '/users/' + user_id + '/search_user_project', - data:{send_id:res_id, send_type:send_type} - }); - }else if(sendType == '3'){ - $.ajax({ - type: 'get', - url: '/users/' + user_id + '/search_user_org', - data:{send_id:res_id, send_type:send_type} - }); - } - } - lastSendType = sendType; -} - -//组织新建和配置中,选择组织为私有后,disbled掉允许游客下载选项 -function disable_down(source, des, hint){ - if (source.attr("checked")){ - des.attr("disabled", false); - hint.html(""); - } - else{ - des.attr("checked", false); - des.attr("disabled", true); - hint.html("(私有组织不允许游客下载资源)"); - - } -} - -function getRootPath(){ - //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp - var curWwwPath=window.document.location.href; - //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp - var pathName=window.document.location.pathname; - var pos=curWwwPath.indexOf(pathName); - //获取主机地址,如: http://localhost:8083 - var localhostPaht=curWwwPath.substring(0,pos); - //获取带"/"的项目名,如:/uimcardprj -// var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); - var projectName=""; - return(localhostPaht+projectName); -} -//自动保存草稿 -var editor2; -function elocalStorage(editor,mdu){ - if (window.sessionStorage){ - editor2 = editor; - var oc = window.sessionStorage.getItem('content'+mdu); - if(oc !== null ){ - var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; - $('#e_tips').html(h); - } - setInterval(function() { - d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - var s = d.getSeconds(); - h = h < 10 ? '0' + h : h; - m = m < 10 ? '0' + m : m; - s = s < 10 ? '0' + s : s; - if(!editor.isEmpty()){ - add_data("content",mdu,editor.html()); - $('#e_tip').html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 "); - $('#e_tips').html(""); - } - },10000); - - }else{ - $('.ke-edit').after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); - } -} -function add_data(k,mdu,d){ - window.sessionStorage.setItem(k+mdu,d); -} -function rec_data(k,mdu){ - if(window.sessionStorage.getItem(k+mdu) !== null){ - editor2.html(window.sessionStorage.getItem(k+mdu)); - clear_data(k,mdu); - } -} -function clear_data(k,mdu){ - window.sessionStorage.removeItem(k+mdu); - if(k == 'content'){ - $("#e_tips").html(""); - }else{ - $("#e_tip").html(""); - } -} +//= require_directory ./rateable +//= require jquery.min +//= require jquery.infinitescroll + +/* Redmine - project management software + Copyright (C) 2006-2013 Jean-Philippe Lang */ + +//动态高度控制 +function description_show_hide(id){ + showNormalImage('activity_description_'+id); + if($("#intro_content_"+id).height() > 810) { + $("#intro_content_show_"+id).show(); + } + $("#intro_content_show_"+id).click(function(){ + $("#activity_description_"+id).toggleClass("maxh360"); + $("#intro_content_show_"+id).hide(); + $("#intro_content_hide_"+id).show(); + }); + $("#intro_content_hide_"+id).click(function(){ + $("#activity_description_"+id).toggleClass("maxh360"); + $("#intro_content_hide_"+id).hide(); + $("#intro_content_show_"+id).show(); + }); +} + +function cleanArray (actual){ + var newArray = new Array(); + for (var i = 0; i< actual.length; i++){ + if (actual[i]){ + newArray.push(actual[i]); + } + } + return newArray; +} + +function checkAll(id, checked) { + if (checked) { + $('#'+id).find('input[type=checkbox]').attr('checked', true); + } else { + $('#'+id).find('input[type=checkbox]').removeAttr('checked'); + } +} + +function toggleCheckboxesBySelector(selector) { + var all_checked = true; + $(selector).each(function(index) { + if (!$(this).is(':checked')) { all_checked = false; } + }); + $(selector).attr('checked', !all_checked); +} + +function showAndScrollTo(id, focus) { + $('#'+id).show(); + if (focus !== null) { + $('#'+focus).focus(); + } + $('html, body').animate({scrollTop: $('#'+id).offset().top}, 400); +} + +function toggleRowGroup(el) { + var tr = $(el).parents('tr').first(); + var n = tr.next(); + tr.toggleClass('open'); + while (n.length && !n.hasClass('group')) { + n.toggle(); + n = n.next('tr'); + } +} + +function collapseAllRowGroups(el) { + var tbody = $(el).parents('tbody').first(); + tbody.children('tr').each(function(index) { + if ($(this).hasClass('group')) { + $(this).removeClass('open'); + } else { + $(this).hide(); + } + }); +} + +function expandAllRowGroups(el) { + var tbody = $(el).parents('tbody').first(); + tbody.children('tr').each(function(index) { + if ($(this).hasClass('group')) { + $(this).addClass('open'); + } else { + $(this).show(); + } + }); +} + +function toggleAllRowGroups(el) { + var tr = $(el).parents('tr').first(); + if (tr.hasClass('open')) { + collapseAllRowGroups(el); + } else { + expandAllRowGroups(el); + } +} + +function toggleFieldset(el) { + var fieldset = $(el).parents('fieldset').first(); + fieldset.toggleClass('collapsed'); + fieldset.children('div').toggle(); +} + +function hideFieldset(el) { + var fieldset = $(el).parents('fieldset').first(); + fieldset.toggleClass('collapsed'); + fieldset.children('div').hide(); +} + +function initFilters(){ + $('#add_filter_select').change(function(){ + addFilter($(this).val(), '', []); + }); + $('#filters-table td.field input[type=checkbox]').each(function(){ + toggleFilter($(this).val()); + }); + $('#filters-table td.field input[type=checkbox]').on('click',function(){ + toggleFilter($(this).val()); + }); + $('#filters-table .toggle-multiselect').on('click',function(){ + toggleMultiSelect($(this).siblings('select')); + }); + $('#filters-table input[type=text]').on('keypress', function(e){ + if (e.keyCode == 13) submit_query_form("query_form"); + }); +} + +function addFilter(field, operator, values) { + var fieldId = field.replace('.', '_'); + var tr = $('#tr_'+fieldId); + if (tr.length > 0) { + tr.show(); + } else { + buildFilterRow(field, operator, values); + } + $('#cb_'+fieldId).attr('checked', true); + toggleFilter(field); + $('#add_filter_select').val('').children('option').each(function(){ + if ($(this).attr('value') == field) { + $(this).attr('disabled', true); + } + }); +} + +function buildFilterRow(field, operator, values) { + var fieldId = field.replace('.', '_'); + var filterTable = $("#filters-table"); + var filterOptions = availableFilters[field]; + var operators = operatorByType[filterOptions['type']]; + var filterValues = filterOptions['values']; + var i, select; + + var tr = $('
    ').attr('id', 'tr_'+fieldId).html( + '' + + '' + + '' + ); + filterTable.append(tr); + + select = tr.find('td.operator select'); + for (i=0;i').val(operators[i]).text(operatorLabels[operators[i]]); + if (operators[i] == operator) { option.attr('selected', true); } + select.append(option); + } + select.change(function(){ toggleOperator(field); }); + + switch (filterOptions['type']){ + case "list": + case "list_optional": + case "list_status": + case "list_subprojects": + tr.find('td.values').append( + '' + + ' 复选/multi-select' + ); + select = tr.find('td.values select'); + if (values.length > 1) { select.attr('multiple', true); } + for (i=0;i'); + if ($.isArray(filterValue)) { + option.val(filterValue[1]).text(filterValue[0]); + if ($.inArray(filterValue[1], values) > -1) {option.attr('selected', true);} + } else { + option.val(filterValue).text(filterValue); + if ($.inArray(filterValue, values) > -1) {option.attr('selected', true);} + } + select.append(option); + } + break; + case "date": + case "date_past": + tr.find('td.values').append( + '' + + ' ' + + ' '+labelDayPlural+'' + ); + $('#values_'+fieldId+'_1').val(values[0]).datepicker(datepickerOptions); + $('#values_'+fieldId+'_2').val(values[1]).datepicker(datepickerOptions); + $('#values_'+fieldId).val(values[0]); + break; + case "string": + case "text": + tr.find('td.values').append( + '' + ); + $('#values_'+fieldId).val(values[0]); + break; + case "relation": + tr.find('td.values').append( + '' + + '' + ); + $('#values_'+fieldId).val(values[0]); + select = tr.find('td.values select'); + for (i=0;i'); + option.val(filterValue[1]).text(filterValue[0]); + if (values[0] == filterValue[1]) { option.attr('selected', true); } + select.append(option); + } + case "integer": + case "float": + tr.find('td.values').append( + '' + + ' ' + ); + $('#values_'+fieldId+'_1').val(values[0]); + $('#values_'+fieldId+'_2').val(values[1]); + break; + } +} + +function toggleFilter(field) { + var fieldId = field.replace('.', '_'); + if ($('#cb_' + fieldId).is(':checked')) { + $("#operators_" + fieldId).show().removeAttr('disabled'); + toggleOperator(field); + } else { + $("#operators_" + fieldId).hide().attr('disabled', true); + enableValues(field, []); + } +} + +function enableValues(field, indexes) { + var fieldId = field.replace('.', '_'); + $('#tr_'+fieldId+' td.values .value').each(function(index) { + if ($.inArray(index, indexes) >= 0) { + $(this).removeAttr('disabled'); + $(this).parents('span').first().show(); + } else { + $(this).val(''); + $(this).attr('disabled', true); + $(this).parents('span').first().hide(); + } + + if ($(this).hasClass('group')) { + $(this).addClass('open'); + } else { + $(this).show(); + } + }); +} + +function toggleOperator(field) { + var fieldId = field.replace('.', '_'); + var operator = $("#operators_" + fieldId); + switch (operator.val()) { + case "!*": + case "*": + case "t": + case "ld": + case "w": + case "lw": + case "l2w": + case "m": + case "lm": + case "y": + case "o": + case "c": + enableValues(field, []); + break; + case "><": + enableValues(field, [0,1]); + break; + case "t+": + case ">t-": + case "0) { + lis.eq(i-1).show(); + } +} + +function displayTabsButtons() { + var lis; + var tabsWidth = 0; + var el; + $('div.tabs').each(function() { + el = $(this); + lis = el.find('ul').children(); + lis.each(function(){ + if ($(this).is(':visible')) { + tabsWidth += $(this).width() + 6; + } + }); + if ((tabsWidth < el.width() - 60) && (lis.first().is(':visible'))) { + el.find('div.tabs-buttons').hide(); + } else { + el.find('div.tabs-buttons').show(); + } + }); +} + +function setPredecessorFieldsVisibility() { + var relationType = $('#relation_relation_type'); + if (relationType.val() == "precedes" || relationType.val() == "follows") { + $('#predecessor_fields').show(); + } else { + $('#predecessor_fields').hide(); + } +} + +function showModal(id, width) { + var el = $('#'+id).first(); + if (el.length === 0 || el.is(':visible')) {return;} + var title = el.find('h3.title').text(); + el.dialog({ + width: width, + modal: true, + resizable: false, + dialogClass: 'modal', + title: title + }); + el.find("input[type=text], input[type=submit]").first().focus(); +} + +function hideModal(el) { + var modal; + if (el) { + modal = $(el).parents('.ui-dialog-content'); + } else { + modal = $('#ajax-modal'); + } + modal.dialog("close"); +} + +function submitPreview(url, form, target) { + $.ajax({ + url: url, + type: 'post', + data: $('#'+form).serialize(), + success: function(data){ + $('#'+target).html(data); + } + }); +} + +function collapseScmEntry(id) { + $('.'+id).each(function() { + if ($(this).hasClass('open')) { + collapseScmEntry($(this).attr('id')); + } + $(this).hide(); + }); + $('#'+id).removeClass('open'); +} + +function expandScmEntry(id) { + $('.'+id).each(function() { + $(this).show(); + if ($(this).hasClass('loaded') && !$(this).hasClass('collapsed')) { + expandScmEntry($(this).attr('id')); + } + }); + $('#'+id).addClass('open'); +} + +function scmEntryClick(id, url) { + el = $('#'+id); + if (el.hasClass('open')) { + collapseScmEntry(id); + el.addClass('collapsed'); + return false; + } else if (el.hasClass('loaded')) { + expandScmEntry(id); + el.removeClass('collapsed'); + return false; + } + if (el.hasClass('loading')) { + return false; + } + el.addClass('loading'); + $.ajax({ + url: url, + success: function(data){ + el.after(data); + el.addClass('open').addClass('loaded').removeClass('loading'); + } + }); + return true; +} + +function randomKey(size) { + var chars = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'); + var key = ''; + for (i = 0; i < size; i++) { + key += chars[Math.floor(Math.random() * chars.length)]; + } + return key; +} + +// Can't use Rails' remote select because we need the form data +function updateIssueFrom(url) { + $.ajax({ + url: url, + type: 'post', + data: $('#issue-form').serialize() + }); +} + +function updateBulkEditFrom(url) { + $.ajax({ + url: url, + type: 'post', + data: $('#bulk_edit_form').serialize() + }); +} + +function clearMessage(id) { + $('#'+id).val(""); +} + + +function observeAutocompleteField(fieldId, url, options) { + $(document).ready(function() { + $('#'+fieldId).autocomplete($.extend({ + source: url, + select: function(e,ui){self.location="/issues/"+ui.item.value;}, + minLength: 1, + search: function(){$('#'+fieldId).addClass('ajax-loading');}, + response: function(){$('#'+fieldId).removeClass('ajax-loading'); + } + }, options)); + $('#'+fieldId).addClass('autocomplete'); + + }); + +} + +function observeSearchfield(fieldId, targetId, url) { + $('#'+fieldId).each(function() { + var $this = $(this); + $this.addClass('autocomplete'); + $this.attr('data-value-was', $this.val()); + var check = function() { + var val = $this.val(); + if ($this.attr('data-value-was') != val){ + $this.attr('data-value-was', val); + $.ajax({ + url: url, + type: 'get', + data: {q: $this.val()}, + success: function(data){ if(targetId) $('#'+targetId).html(data); }, + beforeSend: function(){ $this.addClass('ajax-loading'); }, + complete: function(){ $this.removeClass('ajax-loading'); } + }); + } + }; + var reset = function() { + if (timer) { + clearInterval(timer); + timer = setInterval(check, 300); + } + }; + var timer = setInterval(check, 300); + $this.bind('keyup click mousemove', reset); + }); +} + +function observeProjectModules() { + var f = function() { + /* Hides trackers and issues custom fields on the new project form when issue_tracking module is disabled */ + if ($('#project_enabled_module_names_issue_tracking').attr('checked')) { + $('#project_trackers').show(); + }else{ + $('#project_trackers').hide(); + } + }; + + $(window).load(f); + $('#project_enabled_module_names_issue_tracking').change(f); +} + +function initMyPageSortable(list, url) { + $('#list-'+list).sortable({ + connectWith: '.block-receiver', + tolerance: 'pointer', + update: function(){ + $.ajax({ + url: url, + type: 'post', + data: {'blocks': $.map($('#list-'+list).children(), function(el){return $(el).attr('id');})} + }); + } + }); + $("#list-top, #list-left, #list-right").disableSelection(); +} + +var warnLeavingUnsavedMessage; +function warnLeavingUnsaved(message) { + warnLeavingUnsavedMessage = message; + + $('form').submit(function(){ + $('textarea').removeData('changed'); + }); + $('textarea').change(function(){ + $(this).data('changed', 'changed'); + }); + window.onbeforeunload = function(){ + var warn = false; + $('textarea').blur().each(function(){ + if ($(this).data('changed')) { + warn = true; + } + }); + if (warn) {return warnLeavingUnsavedMessage;} + }; +} + +function setupHeartBeat(){ + var time = 60*1000*30; // 30 mins + setInterval(function(){$.getJSON('/account/heartbeat');},time); +} + +function setupAjaxIndicator() { + $('#ajax-indicator').bind('ajaxSend', function(event, xhr, settings) { + if(settings && settings.url && settings.url.match(/account\/heartbeat$/)){ + return; + } + if ($('.ajax-loading').length === 0 && settings.contentType != 'application/octet-stream') { + $('#ajax-indicator').show(); + } + }); + + $('#ajax-indicator').bind('ajaxStop', function() { + $('#ajax-indicator').hide(); + if(MathJax && MathJax.Hub) + MathJax.Hub.Queue(['Typeset', MathJax.Hub]); //如果是ajax刷新页面的话,手动执行MathJax的公式显示 + try{ + prettyPrint(); //如果刷新出来的页面如果存在代码行的话,也需要美化 + }catch (e){ + + } + }); +} + +function hideOnLoad() { + $('.hol').hide(); +} + +function addFormObserversForDoubleSubmit() { + $('form[method=post]').each(function() { + if (!$(this).hasClass('multiple-submit')) { + $(this).submit(function(form_submission) { + if ($(form_submission.target).attr('data-submitted')) { + form_submission.preventDefault(); + } else { + $(form_submission.target).attr('data-submitted', true); + } + }); + } + }); +} + +function blockEventPropagation(event) { + event.stopPropagation(); + event.preventDefault(); +} + +function toggleAndSettingWordsVal(parent_widget, text_widget, value){ + text_widget.val(value) + parent_widget.slideToggle(400) +} +function transpotUrl (scope) { + $(scope).each(function(){ + var tmpContent = $(this).html(); + tmpContent = tmpContent.replace(/(^|[^\"\'])(http|ftp|mms|rstp|news|https)(\:\/\/[^<\s\+,,]+)/gi,"$1$2$3<\/a>"); + // tmpContent = tmpContent.replace(/(^|[^\/])(www\.[^<\s\+,,]+)/gi,"$1$2"); + $(this).html(tmpContent); + }); +} + +$(document).ready(setupAjaxIndicator); +$(document).ready(setupHeartBeat); +$(document).ready(hideOnLoad); +$(document).ready(addFormObserversForDoubleSubmit); + +function img_thumbnails() { + $('.thumbnails a').colorbox({rel:'nofollow'}); + $('.attachments').find('a').each(function(index, element) { + var href_value = $(element).attr('href'); + if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) { + $(element).colorbox({rel:'nofollow'}); + } + }); + $('.for_img_thumbnails').find('a').each(function(index, element) { + var href_value = $(element).attr('href'); + if (/\.(jpg|png|gif|bmp|jpeg|PNG|BMP|GIF|JPG|JPEG)$/.test(href_value)) { + $(element).colorbox({rel:'nofollow'}); + } + }); +} +$(document).ready(img_thumbnails); + +function TimeClose(dateText, inst) { + if(inst.id=="issue_start_date"){ + time=dateText; + } +} +var time=new Date(); +function TimeBeforeShow(input){ + if(input.id=="issue_due_date"){ + //var minDate = $(input).datepicker('option', 'minDate'); + var tempdata=$("#issue_start_date").attr("value"); + + $(input).datepicker('option', 'minDate',new Date(tempdata.replace(/-/g, "/"))); + //$('.selector').datepicker('option', 'minDate', '12/25/2012'); + } +} + +function SetMinValue(){ + /// var tempdata=$("#issue_start_date").attr("value"); + //$('.selector').datepicker('option', 'minDate', '12/25/2012'); + //alert(tempdata); + //$("#issue_due_date").datepicker({ + // minDate: new Date(2014,08,23) + //var datepickerOptions= + //{dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true}; + //alert( $('.issue_due_date').length); + //$('.selector')[1].datepicker('option', 'minDate', new Date(2014, 0 - 8, 23)); + //$("#issue_due_date").datepicker(datepickerOptions); + //$("##{issue_due_date}").datepicker(datepickerOptions); + //$("#issue_due_date").datepicker( + // {dateFormat: 'yy-mm-dd',minDate: new Date(2014,08,23), showOn: 'button', buttonImageOnly: true, buttonImage: "path_to_image('/images/calendar.png')", showButtonPanel: true, showWeek: true, showOtherMonths: true, selectOtherMonths: true} + //) + //}); +} +function PrecentChange(obj){ + var _v= obj; + if(_v==100) + { + //var select=$("select[id='issue_status_id']"); + $("select[id='issue_status_id']").find("option[value='3']").attr("selected","selected"); + } + else if(_v==0) + { + //alert(1); + $("select[id='issue_status_id']").find("option[value='1']").attr("selected","selected"); + } + else if(_v!=100&&_v!=0) + { + // alert(2); + $("select[id='issue_status_id']").find("option[value='2']").attr("selected","selected"); + } +} + +//added by lizanle 日期選擇js +function HS_DateAdd(interval,number,date){ + number = parseInt(number); + if (typeof(date)=="string"){var date = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2])} + if (typeof(date)=="object"){var date = date} + switch(interval){ + case "y":return new Date(date.getFullYear()+number,date.getMonth(),date.getDate()); break; + case "m":return new Date(date.getFullYear(),date.getMonth()+number,checkDate(date.getFullYear(),date.getMonth()+number,date.getDate())); break; + case "d":return new Date(date.getFullYear(),date.getMonth(),date.getDate()+number); break; + case "w":return new Date(date.getFullYear(),date.getMonth(),7*number+date.getDate()); break; + } +} +function checkDate(year,month,date){ + var enddate = ["31","28","31","30","31","30","31","31","30","31","30","31"]; + var returnDate = ""; + if (year%4==0){enddate[1]="29"} + if (date>enddate[month]){returnDate = enddate[month]}else{returnDate = date} + return returnDate; +} + +function WeekDay(date){ + var theDate; + if (typeof(date)=="string"){theDate = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2]);} + if (typeof(date)=="object"){theDate = date} + return theDate.getDay(); +} +function HS_calender(){ + var lis = ""; + var style = ""; + /*可以把下面的css剪切出去独立一个css文件*/ + style +=""; + + var now; + if (typeof(arguments[0])=="string"){ + selectDate = arguments[0].split("-"); + var year = selectDate[0]; + var month = parseInt(selectDate[1])-1+""; + var date = selectDate[2]; + now = new Date(year,month,date); + }else if (typeof(arguments[0])=="object"){ + now = arguments[0]; + } + var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate(); + var lastMonthDate = WeekDay(now.getFullYear()+"-"+now.getMonth()+"-01"); + var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01"); + var thisMonthEndDate = thisMonthLastDate.getDate(); + var thisMonthEndDay = thisMonthLastDate.getDay(); + var todayObj = new Date(); + today = todayObj.getFullYear()+"-"+todayObj.getMonth()+"-"+todayObj.getDate(); + + for (i=0; i" + lis; + lastMonthEndDate--; + } + for (i=1; i<=thisMonthEndDate; i++){ // Current Month's Date + + if(today == now.getFullYear()+"-"+now.getMonth()+"-"+i){ + var todayString = now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i; + lis += "
  • "+i+"
  • "; + }else{ + lis += "
  • "+i+"
  • "; + } + + } + var j=1; + for (i=thisMonthEndDay; i<6; i++){ // Next Month's Date + lis += "
  • "+j+"
  • "; + j++; + } + lis += style; + + var CalenderTitle = "»"; + CalenderTitle += "«"; + CalenderTitle += ""+now.getFullYear()+""+(parseInt(now.getMonth())+1).toString()+"月"; + + if (arguments.length>1){ + arguments[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis; + arguments[1].parentNode.innerHTML = CalenderTitle; + + }else{ + var CalenderBox = style+"
    "+CalenderTitle+"
      "+lis+"
    "; + return CalenderBox; + } +} +function _selectThisDay(d){ + var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode; + boxObj.targetObj.value = d.title; + boxObj.parentNode.removeChild(boxObj); +} +function closeCalender(d){ + var boxObj = d.parentNode.parentNode.parentNode; + boxObj.parentNode.removeChild(boxObj); +} + +function CalenderselectYear(obj){ + var opt = ""; + var thisYear = obj.innerHTML; + for (i=1970; i<=2020; i++){ + if (i==thisYear){ + opt += ""; + }else{ + opt += ""; + } + } + opt = ""; + obj.parentNode.innerHTML = opt; +} + +function selectThisYear(obj){ + HS_calender(obj.value+"-"+obj.parentNode.parentNode.getElementsByTagName("span")[1].getElementsByTagName("a")[0].innerHTML+"-1",obj.parentNode); +} + +function CalenderselectMonth(obj){ + var opt = ""; + var thisMonth = obj.innerHTML; + for (i=1; i<=12; i++){ + if (i==thisMonth){ + opt += ""; + }else{ + opt += ""; + } + } + opt = ""; + obj.parentNode.innerHTML = opt; +} +function selectThisMonth(obj){ + HS_calender(obj.parentNode.parentNode.getElementsByTagName("span")[0].getElementsByTagName("a")[0].innerHTML+"-"+obj.value+"-1",obj.parentNode); +} +function HS_setDate(inputObj){ + var calenderObj = document.createElement("span"); + calenderObj.innerHTML = HS_calender(new Date()); + calenderObj.style.position = "absolute"; + calenderObj.targetObj = inputObj; + inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling); +} +//lizanle 刷新函数 +function redo() { + window.location.reload() +} + +function encodeHomeworkUrl(url, is_base64){ + if(typeof is_base64 === 'boolean' && is_base64){ + return '/zipdown/download?base64file='+url; + } + var file = encodeURI(url).replace(/\+/g, '%2B'); + return '/zipdown/download?file='+file; +} + +//// 作业附件删除 +$(function(){ + $('.attachments a.delete-homework-icon').bind('ajax:complete', //this will work + function(event, data, status, xhr) { //note parametes + $(this).parent('p').remove(); + console.log("delete complete."); + }); + + $('a.tb_all').bind('ajax:complete', function (event, data, status, xhr) { + if(status == 'success'){ + var res = JSON.parse(data.responseText); + if(res.length<1){ + return; + } + + if(res.length==1){ + if(res[0].base64file){ + location.href = encodeHomeworkUrl(res[0].base64file, true);return; + } + location.href = encodeHomeworkUrl(res[0].file);return; + } + + document.getElementById('light').style.display='block'; + $container = $('#light .upload_box_ul'); + $container.empty(); + for(var i = 0; i 1){ + des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; + } else { + des = '第'+res[i].index+'个学生的作品下载'; + } + + if(res[i].base64file){ + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + } else { + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + } + } + } + }); + $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { + if(status == 'success'){ + var res = JSON.parse(data.responseText); + if(res.length == null){ + alert("该作业没有任何附件可下载"); + } + else if(res.length<1){ + return; + } + else + { + if(res.length==1){ + if(res[0].base64file){ + location.href = encodeHomeworkUrl(res[0].base64file, true);return; + } + location.href = encodeHomeworkUrl(res[0].file);return; + } + document.getElementById('light').style.display='block'; + $container = $('#light .upload_box_ul'); + $container.empty(); + for(var i = 0; i 1){ + des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; + } else { + des = '第'+res[i].index+'个学生的作品下载'; + } + + if(res[i].base64file){ + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + } else { + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + } + + } + } + } + }); +}); + + +//firefox的pre标签换行 +$(document).ready(function () { + var userAgent = navigator.userAgent.toLowerCase(); + var browser = { + version: (userAgent.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/) || [])[1], + safari: /webkit/.test(userAgent), + opera: /opera/.test(userAgent), + msie: /msie/.test(userAgent) && !/opera/.test(userAgent), + mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) + }; + if (browser.mozilla || browser.opera){ + $("pre").addClass("break_word_firefox"); + } + else{ + $("pre").addClass("break_word"); + } +}); + +//点击发送资源弹出框中的组织,要更改选择栏目中的内容 +//@dom 选中的radio,值为org_id +function change_org_subfield(url){ + $.ajax({ + type:'get', + url:url + }) +} + +//点击图片即显示大图 +function showNormalImage(id) { + var description_images=$('div#'+id).find("img"); + if (description_images.length>0) { + for (var i=0; i").attr("href",image.attr('src')); + image.wrap(element); + $(image).parent().colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); + } + //$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框 + } + +} + + +//文件、帖子、通知分享 +function org_id_click(){ + var sendText = $("input[name='org_id']:checked").next().text(); + var orgDirection = "目标地址:"; + $(".orgDirection").text(orgDirection + sendText); +} +function subfield_click(){ + var sendText = $("input[name='org_id']:checked").next().text(); + var orgDirection = "目标地址:"; + var sendColumn = $("input[name='subfield']:checked").next().text(); + $(".orgDirection").text(orgDirection + sendText + " / " + sendColumn); +} + +//send_type:发送的类型,file对应文件,message对应帖子,news对应通知或新闻 +function observeSearchfieldOnInput(fieldId, url,send_id,send_ids, send_type) { + $('#'+fieldId).each(function() { + var $this = $(this); + $this.addClass('autocomplete'); + $this.attr('data-value-was', $this.val()); + var check = function() { + var val = $this.val(); + if ($this.attr('data-value-was') != val){ + $this.attr('data-value-was', val); + $.ajax({ + url: url, + type: 'get', + data: {search: $this.val(),send_id:send_id,send_ids:send_ids, send_type:send_type, is_observe:true}, + success: function(data){ }, + beforeSend: function(){ $this.addClass('ajax-loading'); }, + complete: function(){ $this.removeClass('ajax-loading'); } + }); + } + }; + var reset = function() { + if (timer) { + clearInterval(timer); + timer = setInterval(check, 500); + } + }; + var timer = setInterval(check, 500); + $this.bind('keyup click mousemove', reset); + }); +} +function check_des(event){ + if($(".sectionContent").find('input[type="radio"]:checked').length <= 0){ + event.preventDefault(); + $(".orgDirection").text('目标地址组织不能为空'); + return false; + }else if($(".columnContent").find('input[type="radio"]:checked').length <= 0){ + event.preventDefault(); + $(".orgDirection").text('目标地址栏目不能为空'); + return false; + }else{ + return true; + } +} + +var sendType = '1'; +var lastSendType ;//初始为发送到我的课程 +function show_send(id, user_id, send_type){ + if (lastSendType === '2'){ //如果已经发送过一次了,那么就应该沿用上次发送的类型。 + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_project', + data:{send_id:id, send_type:send_type} + }); + }else if(lastSendType == '1'){ + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_course', + data:{send_id:id, send_type:send_type} + }); + }else if( lastSendType == '3'){//组织 + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_org', + data:{send_id:id, send_type:send_type} + }); + }else{ + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_course', + data:{send_id:id, send_type:send_type} + }); + } +} + +//id 发送的id +//发送的id数组 +//send_type:发送的类型,file对应文件,message对应帖子,news对应通知或新闻 +function chooseSendType(res_id,res_ids, user_id, send_type){ + + sendType = $(".resourcesSendType").val(); + if (sendType === lastSendType) { + return; + } else if(lastSendType != null) { //不是第一次点击的时候 + if (sendType == '1') { + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_course', + data:{send_id:res_id, send_type:send_type} + }); + } else if(sendType == '2') { + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_project', + data:{send_id:res_id, send_type:send_type} + }); + }else if(sendType == '3'){ + $.ajax({ + type: 'get', + url: '/users/' + user_id + '/search_user_org', + data:{send_id:res_id, send_type:send_type} + }); + } + } + lastSendType = sendType; +} + +//组织新建和配置中,选择组织为私有后,disbled掉允许游客下载选项 +function disable_down(source, des, hint){ + if (source.attr("checked")){ + des.attr("disabled", false); + hint.html(""); + } + else{ + des.attr("checked", false); + des.attr("disabled", true); + hint.html("(私有组织不允许游客下载资源)"); + + } +} + +function getRootPath(){ + //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp + var curWwwPath=window.document.location.href; + //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp + var pathName=window.document.location.pathname; + var pos=curWwwPath.indexOf(pathName); + //获取主机地址,如: http://localhost:8083 + var localhostPaht=curWwwPath.substring(0,pos); + //获取带"/"的项目名,如:/uimcardprj +// var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); + var projectName=""; + return(localhostPaht+projectName); +} +//自动保存草稿 +var editor2; +function elocalStorage(editor,mdu){ + if (window.sessionStorage){ + editor2 = editor; + var oc = window.sessionStorage.getItem('content'+mdu); + if(oc !== null ){ + var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; + $('#e_tips').html(h); + } + setInterval(function() { + d = new Date(); + var h = d.getHours(); + var m = d.getMinutes(); + var s = d.getSeconds(); + h = h < 10 ? '0' + h : h; + m = m < 10 ? '0' + m : m; + s = s < 10 ? '0' + s : s; + if(!editor.isEmpty()){ + add_data("content",mdu,editor.html()); + $('#e_tip').html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 "); + $('#e_tips').html(""); + } + },10000); + + }else{ + $('.ke-edit').after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); + } +} +function add_data(k,mdu,d){ + window.sessionStorage.setItem(k+mdu,d); +} +function rec_data(k,mdu){ + if(window.sessionStorage.getItem(k+mdu) !== null){ + editor2.html(window.sessionStorage.getItem(k+mdu)); + clear_data(k,mdu); + } +} +function clear_data(k,mdu){ + window.sessionStorage.removeItem(k+mdu); + if(k == 'content'){ + $("#e_tips").html(""); + }else{ + $("#e_tip").html(""); + } +} + +function expand_reply(container,btnid){ + var target = $(container); + var btn = $(btnid); + if(btn.data('init')=='0'){ + btn.data('init',1); + btn.html('收起回复'); + target.show(); + }else{ + btn.data('init',0); + btn.html('展开更多'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + } +} diff --git a/public/javascripts/des_kindEditor.js b/public/javascripts/des_kindEditor.js index 3a05c909d..126d2a334 100644 --- a/public/javascripts/des_kindEditor.js +++ b/public/javascripts/des_kindEditor.js @@ -54,7 +54,7 @@ function nh_check_field(params){ params.content.sync(); if(params.content.isEmpty()){ - params.contentmsg.html('内容不能为空'); + params.contentmsg.html('请输入文章描述'); params.contentmsg.css({color:'#ff0000'}); }else{ params.contentmsg.html('填写正确'); @@ -131,7 +131,7 @@ function init_des_data(){ }); params.submit_btn.click(function () { params.editor.sync(); - params.form[0].submit(); + params.form.submit(); }); params.textarea.data('init', 1); $(this).show(); diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js index b478e2d9b..70f00db98 100644 --- a/public/javascripts/homework.js +++ b/public/javascripts/homework.js @@ -31,35 +31,81 @@ $(function(){ if(!valid_form()){ return; } + /* + $.post( + '/student_work/program_test_ex', + {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test}, + function(data,status){ + tested = true; + console.log(data); + if(data.index <=0){ + data.index = $('.ProResultTop').length+1; + } - $.ajax({ - url: '/student_work/program_test', - type: 'POST', - timeout: 60*1000, - data: {homework: homework_id, student_work_id: student_work_id, src: src, title: title, is_test: is_test} - }).done(function(data){ - tested = true; - console.log(data); - if(data.index <=0){ - data.index = $('.ProResultTop').length+1; - } - if (typeof cb == 'function') {cb(data); return;} - var html=bt('t:result-list',data); - $('.ProResult').prepend(html); + if (typeof cb == 'function') {cb(data); return;} - if (data.status==0 && is_test != 'true') { - var r=confirm("答题正确,是否立刻提交?"); - if (r) { - $(".HomeWorkCon form").submit(); + var html=bt('t:result-list',data); + $('.ProResult').prepend(html); + + if (data.status==0 && is_test != 'true') { + var r=confirm("答题正确,是否立刻提交?"); + if (r) { + $(".HomeWorkCon form").submit(); + } } } - }).fail(function(xhr, status){ - if(status == 'timeout'){ - alert("您的答案超时了, 请检查代码是否存在死循环的错误."); - } else { - alert("测试失败,服务器出错.") - } - }); + ); + */ + //先测试一次并返回测试集个数及结果再判断是否需要继续进行测试 + var test_post = function(i, testid){ + $.post( + '/student_work/program_test_ex', + {homework: homework_id, student_work_id: student_work_id, + src: src, title: title, is_test: is_test,tIndex:i, + testid: testid}, + function(data,status){ + var tSeq = data.tseq; + var tCount = data.tcount; + console.log("tSeq="+tSeq); + console.log("tCount="+tCount); + tested = true; + console.log(data); + if(data.index <=0){ + data.index = $('.ProResultTop').length+1; + } + + var html=bt('t:result-list',data); + $('.ProResult').prepend(html); + + if (data.status==0 && is_test != 'true') { + if (typeof cb == 'function') {cb(data); return;} + var r=confirm("答题正确,是否立刻提交?"); + if (r) { + $(".HomeWorkCon form").submit(); + } + return; + } + + //2 超时 -2 编译错误 测试结束 + if (data.status == 2 || data.status == -2 || tSeq >= tCount ){ + if (typeof cb == 'function') {cb(data); return;} + return; + } + + test_post(i+1, data.testid); + } + ).fail(function(xhr, status){ + if(status == 'timeout'){ + alert("您的答案超时了, 请检查代码是否存在死循环的错误."); + } else { + alert("测试失败,服务器出错."); + } + return; + }); + + }; + + test_post(1, 0); }; $('#test-program-btn').on('click', test_program); @@ -377,6 +423,10 @@ $(function(){ var src = ''; if(language==4){ src = '\ +//注意\n\ + //1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\ + //2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\ + //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\ import java.io.*;\n\ import java.util.*;\n\ \n\ @@ -396,8 +446,12 @@ class Main\n\ '; } else if(language==1){ - src = '#include \n\ -\n\ + src = '\ +//注意\n\ + //1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\ + //2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\ + //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\ +#include \n\ int main()\n\ {\n\ //获取参数方式 scanf\n\ @@ -413,6 +467,10 @@ int main()\n\ '; } else if(language==2){ src = '\ +//注意\n\ + //1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\ + //2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\ + //3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),每行末尾的所有空格用□表示\n\ #include \n\ using namespace std;\n\ \n\ @@ -430,6 +488,10 @@ int main()\n\ '; } else if(language==3){ src = '\ +#注意\n\ + #1:该程序每次运行的时间必须小于200毫秒,否则会超时,程序超时将不会测试剩余的测试集\n\ + #2:该程序每次运行使用的内存不能超过1M,否则会返回错误\n\ + #3:该程序每次运行输出的结果最多显示100个字符(多余的不显示),空格用□表示\n\ import sys \n\ \n\ #获取参数方式,使用raw_input\n\ diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 7dd3fd74f..cd9d60d07 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -419,6 +419,7 @@ a:hover.ping_sub{ background:#14a8b9;} /*.ping_distop span a{ float:right; width:20px; height:20px; background:url(images/star.png) -24px 0 no-repeat; margin-right:3px;}*/ .list_style ol li{list-style-type: decimal;margin-left: 20px;} .list_style ul li{list-style-type: disc;margin-left: 20px;} +span.author { font-size: 0.9em; color: #888; } /* 创建作品 work */ .Newwork{ width:668px; height:418px;} @@ -442,6 +443,7 @@ a:hover.tijiao{ background:#0f99a9;} .members_left ul li span{ float:left; text-align:center; color:#484747;} .w150{ text-align:center; width:150px;min-height: 10px;} .width150{width:150px;min-height: 10px;} +.width120{width:120px;min-height: 10px;} .f_b{ font-weight: bold;} .members_right label{ margin-left:15px;} .N_search{ height:20px; border:1px solid #999;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 94e3fa85a..4558437a2 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -99,6 +99,7 @@ a.linkGrey6:hover {color:#ffffff !important;} .mr40{ margin-right:40px !important;} .mr65 {margin-right: 65px;} .mw20{ margin: 0 20px;} +.mw380 {max-width: 380px !important;} .mw400 {max-width: 400px !important;} .mt-20 {margin-top:-20px;} .mt-4 {margin-top: -4px;} @@ -496,7 +497,7 @@ a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; .resourceSharePopup {width:300px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;} .sendText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; width:110px; display:inline-block; font-weight: bold;} .resourcesSendTo {float:left; height:20px; margin-top:15px;} -.boxContainer {height:33px; line-height:33px; position:relative} +.boxContainer {height:auto; line-height:33px; position:relative} .resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;} .resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} .resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} @@ -1482,8 +1483,7 @@ a.choose-active {background-color:#269ac9; color:#ffffff;} .subject-list-from {width:145px; text-align:center;} /*视频播放默认图标*/ -.mediaIco{margin: 30px 0 30px 20px;} +.mediaIco{margin: 30px 0 30px 20px;width: 200px;} a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;} a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;} a.st_img { display:block;width:32px; height:32px; border:1px solid #CCC; padding:1px;} -a:hover.st_img { border:1px solid #1c9ec7; } diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index f2a3dd3c9..3a203c10d 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -18,12 +18,12 @@ .orgUrlInput {width:200px; outline:none; border:1px solid #eaeaea; height:22px;} a.saveBtn {padding:3px 5px; background-color:#269ac9; color:#ffffff;} a.saveBtn:hover {background-color:#297fb8;} -.orgMemberList {width:460px; float:left;} +.orgMemberList {width:480px; float:left;} .orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px;} .orgListUser {width:85px; float:left;} .orgListRole {width:180px; float:left;} .orgOrder {width:30px; float:left;margin-right:10px;text-align:center;} -.orgMemContainer {width:228px;} +.orgMemContainer {width:208px;} .orgMemberAdd {float:right;} .orgAddSearch {border:1px solid #dddddd; outline:none; width:180px; height:22px; color:#9b9b9b;} .undis {display:none;} @@ -75,7 +75,8 @@ a.linkGrey8:hover {color:#585858;} #orgUserName {display:inline-block;} .org_login_list a {color:#269ac9;} -.orgListStatus {width:55px; float:left;} +.orgListStatus {width:40px; float:left;} +.orgListStatusList {width:58px; float:left;} .personalUrl {border:1px solid #dddddd; width:75px; outline:none; white-space:nowrap; padding-left:2px;} .reCon{ margin:5px; width:710px;} .retop{width:710px; height:40px; background:#eaeaea; padding:5px;} diff --git a/public/stylesheets/org_new_style.css b/public/stylesheets/org_new_style.css new file mode 100644 index 000000000..5e73949a6 --- /dev/null +++ b/public/stylesheets/org_new_style.css @@ -0,0 +1,332 @@ +@charset "utf-8"; +/* CSS Document */ +body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{ margin:0; padding:0;} +body,table,input,textarea,select,button { font-family: "微软雅黑","宋体"; font-size:12px;line-height:1.5; background:#fff;} +div,img,tr,td,table{ border:0;} +table,tr,td{border:0;cellspacing:0; cellpadding:0;} +ol,ul,li{ list-style-type:none} +a:link,a:visited{color:#000;text-decoration:none;} +a:hover{color:#29156f;} + +.fl{ float:left;} +.fr{ float:right;} +.cl{ clear:both;overflow:hidden;} +.mr40{ margin-right:40px;} +.mr30{ margin-right:30px;} +.mb20{ margin-bottom:20px;} +.mb70{ margin-bottom:70px;} +.bg-grey{ background:#f2f2f2;} + +/** header **/ +.header{ width:100%; height:60px; padding:5px 0 0px; } +.header-con{ width:1200px; margin:0 auto; } +.logo{ position:relative; } +.logo-img{ height:52px; } +.login{ margin-top:15px;} +.login a{ color:#000; font-size:14px; margin-top:10px; } +.logo-add{ display:block; top:3px; left:0px; position:absolute; width:20px; height:20px;background:url(../images/org_new_style/icons.png) -7px -573px no-repeat;} + + +/*.header{ width:100%; height:60px; background:#29146f; padding:5px 0 0px; }*/ +/*.header-con{ width:1200px; margin:0 auto;}*/ +/*.logo,.logo img{ display:block; height:52px; }*/ +/*a.login{ background:url(../images/org_new_style/icons.png) -7px -11px no-repeat; width:146px; height:55px; margin-right:40px; margin-top:11px;}*/ +/*a:hover.login{ background:url(../images/org_new_style/icons.png) -7px -88px no-repeat; }*/ +/*a.register{ background:url(../images/org_new_style/icons.png) -190px -11px no-repeat; width:158px; height:55px; ;margin-top:11px;}*/ +/*a:hover.register{ background:url(../images/org_new_style/icons.png) -190px -88px no-repeat; }*/ +/*.login{ margin-top:15px;}*/ +/*.login a{ color:#fff; font-size:14px; margin-top:10px; }*/ +/** nav **/ +.nav-box{ width:100%; padding:0px 0 5px; background:#eeeeee;} +.nav-con{width:1200px; margin:0 auto; background:#eee;} +.nav{ } +.nav a{ display:block; padding:15px 10px; font-size:18px; color:#666666; background:#eee; border-top:3px solid #eee; margin-right:20px; } +a.navact{border-top:3px solid #ffbd18;} +.nav a:hover{border-top:3px solid #ffbd18;} + +/*.nav-box{ width:1200px; height:60px; margin:0 auto;}*/ +/*.nav a{ display:block; padding:15px 10px; font-size:18px; color:#000; margin-right:20px; }*/ +/*.navact{border-bottom:3px solid #ffbd18;}*/ +/*.nav a:hover{border-bottom:3px solid #ffbd18;}*/ +/*.searchbox{ width:338px; height:57px; border:1px solid #ccc; -webkit-border-radius: 3px;border-radius: 3px; margin:10px 0px 0 0;}*/ +/*.search-input{width:270px; height:40px; color:#bebebe; font-size:18px; border:1px solid #ccc; -webkit-border-radius: 3px;border-radius: 3px;border:0px; background:none; margin:10px 0 0 20px;}*/ +/*.search-input:hover{ border:none;color:#fff; }*/ +/*a.search-icon{ background:url(../images/org_new_style/icons.png) -387px -11px no-repeat; width:40px; height:40px; margin-top:8px;}*/ +/*a:hover.search-icon{ background:url(../images/org_new_style/icons.png) -387px -89px no-repeat;}*/ +/*.searchbox:hover{ background:#999999; color:#fff;}*/ + +/* banner */ +.banner{ width:100%; height:304px; color:#fff; text-align:center; line-height:2.4;position:relative;} +.banner-inner{ width:100%; margin:0 auto; text-align:center;} +.banner-img{ height:313px;} +.banner-txt{position:absolute; top:25%; left:35%; width:500px; padding:30px 0; margin:0 auto; background-color:rgba(255,255,255,.3); } +.banner-add{ display:block; position:absolute; top:10%; left:20%;width:27px; height:27px; background:url(../images/org_new_style/icons.png) -39px -570px no-repeat;} +.banner h1{ font-size:42px;} +.banner p{font-size:40px; color:#fff;} + +/*.banner{ width:100%; height:304px; background:#070317; color:#fff; text-align:center; line-height:2.4;}*/ +/*.banner-inner{ width:1500px; margin:0 auto; position:relative; text-align:center;}*/ +/*.banner-img{ height:304px;}*/ +/*.banner-txt{position:absolute; top:30%; left:0%; width:1500px; margin:0 auto;}*/ +/*.banner h1{ font-size:42px;}*/ +/*.banner a{font-size:28px; color:#fff;}*/ +/*.banner a:hover{ text-decoration:underline;}*/ +/*.banner p{ font-size:18px;}*/ +/*.banner span{ font-size:16px;}*/ + +/** box1 **/ +.box1{ width:100%; padding:60px 0;} +.content{ width:1200px; margin:0 auto;} +.box-top{ margin:0 auto; text-align:center; margin-bottom:45px; } +.box-title{ width:355px; height:67px; margin:0 auto; border-top:1px solid #ccc; border-bottom:1px solid #ccc; color:#000; text-align:center; font-size:40px; font-weight: lighter; margin-bottom:2px;} +.box-title-p{ font-size:20px; color:#999999;} +.row{ width:1200px; margin: 0 auto; } +.row-box1{ width:365px;} +.row-img{ margin-bottom:10px; width:365px; height:230px; display:block;} +.row-time{ color:#ffbd18; font-size:14px; font-weight:bold; line-height:1.9;} +.row-title{ font-size:16px; font-weight:bold; line-height:1.9;display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.row-con { display:block; } +.row-con:hover{ color:#29156f; } +.row-txt{line-height:2.4; padding-bottom:10px; margin-bottom:10px; color:#888;} +.row-txt:hover{color:#29156f;} +.row-txt-line{border-bottom:1px solid #cccccc; width:365px;} +.row-box2{ width:388px; border:1px solid #ccc; border-bottom:none;} +.row-con2 a{ display:block;padding:20px 10px; border-bottom:1px solid #ccc;} +.row-con2 a:hover{ background:#29156f; color:#fff;} +.row-con2 a:hover{ color:#fff;} +.row-txt2{line-height:2.4; color:#888;} +.row-txt2:hover{ color:#fff; } + +/*.box1{ width:100%; padding:60px 0;}*/ +/*.content{ width:1200px; margin:0 auto;}*/ +/*.box-top{ margin:0 auto; text-align:center; margin-bottom:45px; }*/ +/*.box-title{ width:355px; height:67px; margin:0 auto; background:#29156f; color:#fff; text-align:center; font-size:40px; font-weight: lighter; margin-bottom:2px;}*/ +/*.box-title-p{ font-size:20px; color:#999999;}*/ +/*.row{ width:1200px; margin: 0 auto; }*/ +/*.row-box1{ width:365px;}*/ +/*.row-img{ margin-bottom:10px; width:365px; height:230px; display:block;}*/ +/*.row-time{ color:#ffbd18; font-size:14px; font-weight:bold; line-height:1.9;}*/ +/*.row-title{ font-size:16px; font-weight:bold; line-height:1.9;display:block;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}*/ +/*.row-con { display:block; }*/ +/*.row-con:hover{ color:#29156f; }*/ +/*.row-txt{line-height:2.4; padding-bottom:10px; margin-bottom:10px; color:#888;}*/ +/*.row-txt:hover{color:#29156f;}*/ +/*.row-txt-line{border-bottom:1px solid #cccccc; width:365px;}*/ +/*a.btn-more{ display:block; font-size:14px; width:110px; height:40px; -webkit-border-radius: 3px;border-radius: 3px;background:#ffbd18; color:#fff; text-align:center; line-height:3.0;}*/ +/*a:hover.btn-more{ background:#29156f;}*/ +/*.row-box2{ width:388px; border:1px solid #ccc; border-bottom:none;}*/ +/*.row-con2 a{ display:block;padding:20px 10px; border-bottom:1px solid #ccc;}*/ +/*.row-con2 a:hover{ background:#29156f; color:#fff;}*/ +/*.row-con2 a:hover{ color:#fff;}*/ +/*.row-txt2{line-height:2.4; color:#888;}*/ +/*.row-txt2:hover{ color:#fff; }*/ + +/** 活动专区 **/ +.con-left{ width:618px;} +.con-left-box{ margin-bottom:20px; height:96px; display:block;} +.con-left-img{ width:175px; height:96px;} +.con-left-txt{ width:360px; margin-left:15px; font-size:14px; color:#888; padding-top:8px; line-height:1.9; height:75px; overflow:hidden;text-overflow:ellipsis;display:-webkit-box; + -webkit-line-clamp:3;-webkit-box-orient:vertical;} +.con-left-txt:hover{color:#29156f;} +.con-left-pre{ margin-top:15px; } +a.con-back-btn{ display: block;width:25px;height:25px;background:url(../images/org_new_style/icons.png) no-repeat -38px -505px ;} +a.con-arrow-btn{ display: block;width:25px;height:25px;background:url(../images/org_new_style/icons.png) no-repeat -12px -505px ; opacity:.5;} +.con-right{ width:532px; height:170px; background:#f6f6f6 ; padding:25px;} +.con-right p{background: url(../images/org_new_style/con-right.gif) no-repeat 0 0;line-height:1.9; width:415px; padding:40px 0 0 20px; font-size:14px; color:#888; margin-left:20px;} +.con-r-img img{ border:3px solid #e6473b; -moz-border-radius: 50px; -webkit-border-radius: 50px;border-radius: 50px; display:block; width:67px; height:67px;} +.con-r-img img:hover{border:3px solid #29156f;} +.con-name{ font-size:18px; font-weight:bold; margin-top:5px;} +.con-r-img { text-align:center;} +.con-r-pre{ margin-top:20px;} +a.pre-arrow,a.pre-back{ display:block; width:25px; height:10px; background:#29156f; margin-left:5px;} +a.pre-back{ background:#888;} +/** footer **/ +.footer{ height:150px; background:#bbb; width:100%;} +.footer-con{ width:1200px; padding:30px 0 0 60px; margin:0 auto; text-align:center; font-size:14px; color:#fff;} +.footer-con ul{ display:block; width:430px; height:50px; margin:0 auto; } +.footer-con ul li a{font-size:18px; color:#fff; margin-right:35px; font-weight:bold;} +/** download **/ +.row-ziyuan{ width:570px; border-bottom:1px solid #e6e6e6; padding:15px 0;margin: 0px 15px;} +.ziyuan-box{ width:420px; margin-right:20px;} +.ziyuan-box span{ margin-right:5px;} +.ziyuan-title{ display:block; width:420px; font-size:16px;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.ziyuan-box p{display:block; width:420px; color:#888; font-size:12px; line-height:2.5;} +a.download-btn{ display:block; border:1px solid #ccc; margin-top:10px; font-size:14px; width:70px; height:27px;-webkit-border-radius: 3px;border-radius:3px;color:#888; text-align:center; line-height:1.9;} +a:hover.download-btn{ background:#29146f; color:#fff; border:none;} +.user-img,.user-img img{ margin-right:10px; -moz-border-radius: 50px; -webkit-border-radius: 50px;border-radius: 50px; display:block; width:40px; height:40px;} +.ml60{ margin-left:60px;} +.user-img img{border:2px solid #e6473b; } +.user-img img:hover{border:2px solid #29156f;} + + +.article-lwrap{ width:760px; border-bottom:1px solid #E4E4E4; padding:10px 0;} +.item-txt{ width:555px;} +.item-img,.item-img img{ width:180px; height:120px;} +.item-title{ display:block; width:555px; font-size:18px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-bottom:5px;} +.item-bd{ width:555px; font-size:14px !important; color:#888; line-height:1.9; height:55px; overflow:hidden;text-overflow:ellipsis;display:-webkit-box; + -webkit-line-clamp:2;-webkit-box-orient:vertical; } +.item-bd:hover{color:#29156f;} +a.read-more{ color:red;} +a:hover.read-more{ text-decoration:underline;} +.publisher-hd,.publisher-hd img{ margin-right:10px; -moz-border-radius: 50px; -webkit-border-radius: 50px;border-radius: 50px; display:block; width:28px; height:28px;} +.left-info li,left-info li a{ float:left;} +.item-btm,.publisher-name,.pass-time{ margin-top:5px;} +.pass-time{ margin-left:20px; color:#888;} +.right-info{background:url(../images/org_new_style/icons.png) no-repeat -41px -541px ; width:15px; height:16px; padding-left:20px; color:#888; margin-top:5px;} +.nopic{ width:760px;} +.article-lwrap{ width:760px; border-bottom:1px solid #E4E4E4; padding:20px 0;} +.item-title-r{ display:block; width:400px; font-size:18px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.article-rwrap{ width:400px; border-bottom:1px dashed #E4E4E4; padding:12px 0;} + +.course-list ul{ } +.course-list ul li{ display:block; width:370px; float:left; margin:0 15px;} +.course-list h5{display:block; width:380px; font-size:18px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } +.course-list-img,.course-list-img img{ width:370px; height:220px; margin-bottom:10px;} + +/*用户图像*/ +.topnav_login_list{ border:1px solid #eaeaea; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-7px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); margin-top: 1px;} +.topnav_login_list a{color:#269ac9;} +.topnav_login_list li{ } +.homepageProfileMenuIcon {background:url(../images/nav_icon.png) 30px -155px no-repeat; width:65px; height:54px; position:relative; display:inline-block; line-height:0;} +.homepageLeft {width:240px; float:left; margin-right:10px; margin-bottom:10px;} +.none {display: none;} + + +/** backtop **/ +.cd-top { + display: inline-block; + height: 60px; + width: 60px; + position: fixed; + bottom: 40px; + right: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.05); + /* image replacement properties */ + overflow: hidden; + text-indent: 100%; + white-space: nowrap; + background: rgba(108, 108, 108, 0.8) url(../images/org_new_style/cd-top-arrow.svg) no-repeat center 50%; + visibility: hidden; + opacity: 0; + -webkit-transition: all 0.3s; + -moz-transition: all 0.3s; + transition: all 0.3s; +} +.cd-top.cd-is-visible { + /* the button becomes visible */ + visibility: visible; + opacity: 1; +} +.cd-top.cd-fade-out { + /* 如果用户继续向下滚动,这个按钮的透明度会变得更低 */ + opacity: .5; +} +.no-touch .cd-top:hover { + background-color: #29156f; + opacity: 1; +} + +a.more-btn-center{ display:block; border:1px solid #ccc; color:#000; margin-top:10px; width:120px; height:38px;font-size:14px; -webkit-border-radius: 25px;border-radius:25px;text-align:center; line-height:38px; margin:0 auto; margin-top:30px;} +a:hover.more-btn-center{ background:#aaa; color:#fff;} +.mt30{ margin-top:30px;} + +/*a.more-btn{ display:block; background:#ccc; color:#fff; margin-top:10px; width:100px; height:38px;font-size:14px; -webkit-border-radius: 5px;border-radius:5px;text-align:center; line-height:38px;}*/ +/*a.more-btn{ display:block; border:1px solid #ccc; color:#000; margin-top:10px; width:120px; height:38px;font-size:14px; -webkit-border-radius: 25px;border-radius:25px;text-align:center; line-height:38px; margin:0 auto; margin-top:30px;}*/ +/*a.more-btn-center{ display:block; border:1px solid #ccc; color:#000; margin-top:10px; width:120px; height:38px;font-size:14px; -webkit-border-radius: 25px;border-radius:25px;text-align:center; line-height:38px; margin:0 auto; margin-top:30px;}*/ +/*a:hover.more-btn{ background:#29146f; color:#fff;}*/ +/*a:hover.more-btn-center{ background:#29146f; color:#fff;}*/ +/*.mt30{ margin-top:30px;}*/ + +.nocontent{ font-size:30px; color:#888; margin:150px auto; text-align:center;} + +/** 帖子列表模式 **/ +.note-box{ width:515px; } +.note-box span{ margin-right:5px;} +.note-title{ display:block; width:515px; font-size:16px;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;} +.note-box p{display:block; width:515px; color:#888; font-size:12px; line-height:2.5;} +.right-info2{background:url(../images/org_new_style/icons.png) no-repeat -41px -540px ; width:15px; line-height:1.9; height:16px; padding-left:20px; color:#888; margin-top:5px;} + +.upload_con h2 { + display: block; + background: #eaeaea; + font-size: 14px; + color: #343333; + height: 31px; + width: auto; + margin-top: 25px; + padding-left: 20px; + padding-top: 5px; +} +a.blue_btn { + background: #64bdd9; + color: #fff; + font-size: 14px; + font-weight: normal; + padding: 2px 8px; + text-align: center; + cursor: pointer; +} +a.grey_btn { + background: #d9d9d9; + color: #656565; + font-size: 14px; + font-weight: normal; + text-align: center; + margin-left: 10px; + margin-bottom: 10px; + padding: 2px 10px; +} +span.add_attachment { + font-size: 80%; + line-height: 2.5em; +} +.c_dark { + color: #2d2d2d; +} +.upload_filename { + background: url(../images/pic_file.png) 0 -20px no-repeat; + color: #7f7f7f; + width: 270px; + border: none; + padding-left: 20px; + margin-right: 10px; + margin-bottom: 5px; + white-space: nowrap; + text-overflow: ellipsis; +} +.profiler-results.profiler-left { + left: 0px; +} +.profiler-results { + z-index: 2147483643; + position: fixed; + top: 0px; +} + +.filename { background: url(../images/pic_file.png) 0 -25px no-repeat;color: #3ca5c6;max-width: 150px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;} +.ajax-waiting input.upload_filename {background:url(../images/hourglass.png) no-repeat 0px 50%;} +.ajax-loading input.upload_filename {background:url(../images/loading.gif) no-repeat 0px 50%;} +div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; } +.upload_filename{ background: url(../images/pic_file.png) 0 -20px no-repeat;color: #7f7f7f;width: 270px;border: none; padding-left: 20px;margin-right: 10px;margin-bottom: 5px; white-space: nowrap; text-overflow:ellipsis;} +.evaluation{position: relative;} +.evaluation_submit{position: absolute;right: 0px;bottom: 0px;} +.student_work_search{background-color: #64bdd9;color: white !important;padding: 2px 7px;margin-left: 10px;cursor: pointer; } + + + + + + + + + + + + + + + + + + + diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 0a3732ced..1834dec12 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -147,6 +147,7 @@ h4{ font-size:14px; color:#3b3b3b;} .w90{ width:90px;} .w100{width: 100px;} .w125{width:125px;} +.w180{width:180px;} .w210{ width:210px;} .w150{ width:150px;} .w170{width:170px;} @@ -180,6 +181,7 @@ h4{ font-size:14px; color:#3b3b3b;} .h150{ height:150px;} .p10 {padding-left:10px; padding-right:10px;} .mw360 {max-width: 360px !important;} +.mw380 {max-width: 380px !important;} .mw400 {max-width: 400px !important;} .mh18 {max-height: 18px;} @@ -448,7 +450,7 @@ a:hover.search_btn{ background: #0fa9bb;} .resourceSharePopup {width:300px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;} .sendText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; width:110px; display:inline-block; font-weight: bold;} .resourcesSendTo {float:left; height:20px; margin-top:15px;} -.boxContainer {height:33px; line-height:33px; position:relative} +.boxContainer {height:auto; line-height:33px; position:relative} .resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;} .resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} .resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} @@ -1136,4 +1138,4 @@ a.program-btn{background: url(../images/homepage_icon.png) -86px -393px no-repea .mediaIco{margin: 30px 0 30px 20px;width: 200px;} /*排序样式*/ a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;} -a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;} +a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;}
    + 序号 + LOGO + 学校名称 + 用户数 + + 创建时间 + + 编辑高校信息 +
    - <%= school.id %> + + + <% @count +=1 %> + + <%=@count %> <%= image_tag(school.logo_link,width:40,height:40) %> + - <%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %> + <%= link_to school.name,"http://#{Setting.host_name}/?school_id=#{school.id}" %> + + <%= schoolMember_num(school) %> + + <%= format_time(school.created_at) %> + <%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %> <%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> 用户单位
    <%= checked_image user.admin? %> <%= format_time(user.created_on) %> <%= change_status_link(user) %> - <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %> <%= truncate( occupation, :length => 12 ) %> <%= change_status_link(user) %> <%= delete_link user_path(user, :back_url => admin_users_path(params)) unless User.current == user %>