diff --git a/.gitignore b/.gitignore index fdb7a3c6b..22d9e17e6 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ vendor/cache /public/images/avatars /public/files /tags +/config/initializers/gitlab_config.rb diff --git a/Gemfile b/Gemfile index cf6e9f773..3027c16cd 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,8 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end -gem 'grack', path:'./lib/grack' +gem 'grack', path:'lib/grack' +gem 'gitlab', path: 'lib/gitlab-cli' gem 'rest-client' gem "mysql2", "= 0.3.18" gem 'redis-rails' @@ -45,7 +46,7 @@ group :development, :test do gem 'pry-stack_explorer' if RUBY_PLATFORM =~ /darwin/ gem 'puma' - end + end end gem 'rspec-rails', '~> 3.0' diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index af501fdf9..33d988e35 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -21,7 +21,6 @@ class AccountController < ApplicationController # prevents login action to be filtered by check_if_login_required application scope filter skip_before_filter :check_if_login_required - # Login request and validation def login if request.get? diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 477a8e2b9..9e935ae40 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -354,7 +354,7 @@ class AdminController < ApplicationController @schools = School.where('1=1') end @school_count = @schools.count - @school_pages = Paginator.new @school_count, per_page_option, params['page'] || 1 + @school_pages = Paginator.new @school_count, 100, params['page'] || 1 @schools = paginateHelper @schools,100 respond_to do |format| format.html diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 86c220bd2..6387a97a4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -38,7 +38,8 @@ class ApplicationController < ActionController::Base protect_from_forgery def handle_unverified_request super - cookies.delete(autologin_cookie_name) + raise(ActionController::InvalidAuthenticityToken) + # cookies.delete(autologin_cookie_name) end before_filter :find_first_page @@ -381,6 +382,11 @@ class ApplicationController < ActionController::Base if allowed true else + if params[:action] == 'show' + #更新申请结果反馈消息的状态 + messages = CourseMessage.where("course_message_type =? and course_id =? and user_id =? and viewed =?", 'CourseRequestDealResult', @course.id, User.current.id, false) + messages.update_all(:viewed => true) + end if @course && @course.archived? render_403 :message => :notice_not_authorized_archived_project else @@ -657,7 +663,8 @@ class ApplicationController < ActionController::Base if api_request? logger.error "Form authenticity token is missing or is invalid. API calls must include a proper Content-type header (text/xml or text/json)." end - render_error "Invalid form authenticity token." + #render_error "Invalid form authenticity token." + redirect_to signin_path(:login=>true) end def render_feed(items, options={}) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index ee953e913..37182dbcf 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -227,6 +227,8 @@ class AttachmentsController < ApplicationController format.js elsif @attachment.container.is_a?(Message) format.html { redirect_to_referer_or new_board_message_path(@attachment.container) } + elsif @attachment.container.is_a?(BlogComment) + format.html { redirect_to_referer_or user_blog_blog_comment_path(:user_id=>@attachment.container.author.id,:blog_id=>@attachment.container.blog_id,:id=>@attachment.container.id)} elsif @course.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } else diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb new file mode 100644 index 000000000..b92223edc --- /dev/null +++ b/app/controllers/blog_comments_controller.rb @@ -0,0 +1,150 @@ +class BlogCommentsController < ApplicationController + include ApplicationHelper + before_filter :find_user + def index + + end + def create + if User.current.logged? + @article = BlogComment.new + @article.author = User.current + @article.blog_id = params[:blog_id] + @article.safe_attributes = params[:blog_comment] + if request.post? + @article.save_attachments(params[:attachments]) + if @article.save + # 更新kindeditor上传的图片资源所有者 + # if params[:asset_id] + # ids = params[:asset_id].split(',') + # update_kindeditor_assets_owner ids,@article.id,OwnerTypeHelper::BLOGCOMMENT + # end + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blogs_path(:user_id=>params[:user_id]) + else + respond_to do |format| + format.html { + render :layout => 'new_base_user' + } + end + end + else + redirect_to signin_path + end + end + def new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def show + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def update + @article = BlogComment.find(params[:id]) + @article.safe_attributes = params[:blog_comment] + @article.save_attachments(params[:attachments]) + if @article.save + render_attachment_warning_if_needed(@article) + else + end + redirect_to user_blog_blog_comment_path(:user_id=>params[:user_id],:blog_id=>params[:blog_id],:id=>params[:id]) + end + def destroy + @article = BlogComment.find(params[:id]) + if @article.parent_id.nil? #如果是文章被删,那么跳转到用户博客界面,如果带了course_id过来,那么就要跳转到课程首页 + if params[:course_id] #如果带了课程id过来,说明这是课程大纲,不要删除,只需取消课程大纲就ok了 + @course = Course.find(params[:course_id]) + @course.outline = 0 + @course.save + redirect_to course_path(:id=>params[:course_id]) + else + @article.children.delete + @article.delete + redirect_to user_blogs_path(:user_id=>User.current) + end + + else#如果是回复被删, + if params[:course_id] #如果带了course_id过来了,那么这是要跳到课程大纲去的 + @article.delete + redirect_to syllabus_course_path(:id=>params[:course_id]) + else + root = @article.root + @article.delete + redirect_to user_blog_blog_comment_path(:user_id=>root.author_id,:blog_id=>root.blog_id,:id=>root.id) + end + + end + end + + def edit + @article = BlogComment.find(params[:id]) + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + + def quote + @blogComment = BlogComment.find(params[:id]) + @subject = @blogComment.title + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> " + @temp = BlogComment.new + @course_id = params[:course_id] + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}
#{@blogComment.content.html_safe}
".html_safe + respond_to do | format| + format.js + end + end + + #回复 + def reply + if params[:in_user_center] + @in_user_center = true + end + @article = BlogComment.find(params[:id]).root + @quote = params[:quote][:quote] + @blogComment = BlogComment.new + @blogComment.author = User.current + @blogComment.blog = Blog.find(params[:blog_id]) + params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @blogComment.safe_attributes = params[:blog_comment] + @blogComment.content = @quote + @blogComment.content + @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @article.children << @blogComment + @user_activity_id = params[:user_activity_id] + user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end + attachments = Attachment.attach_files(@blogComment, params[:attachments]) + render_attachment_warning_if_needed(@blogComment) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { + if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 + redirect_to syllabus_course_path(:id=>params[:course_id]) + else + redirect_to user_blog_blog_comment_path(:user_id=>@article.author_id,:blog_id=>@article.blog_id,:id=>@article) + end + + } + format.js + end + rescue Exception => e #如果上面的代码执行发生异常就捕获 + flash[:notice] = e.message + end + + private + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb new file mode 100644 index 000000000..07bf60464 --- /dev/null +++ b/app/controllers/blogs_controller.rb @@ -0,0 +1,47 @@ +class BlogsController < ApplicationController + before_filter :find_blog,:except => [:index,:create,:new] + before_filter :find_user + def index + @articls = @user.blog.articles + @article = BlogComment.new + respond_to do |format| + format.html {render :layout=>'new_base_user'} + end + end + def create + + end + def new + + end + def show + + end + def update + + end + def destory + + end + def edit + + end + private + def find_blog + if params[:blog_id] + @blog = Blog.find(params[:blog_id]) + else + render_404 + end + if @blog.nil? + #如果某个user的blog不存在,那么就创建一条 + @blog = Blog.create(:name=>User.find(params[:id]).realname , + :description=>'', + :author_id=>params[:id]) + end + end + + def find_user + @user = User.find(params[:user_id]) + end +end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7d26b2eca..1a561006a 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -31,27 +31,24 @@ class CoursesController < ApplicationController def join if User.current.logged? - cs = CoursesService.new - user = User.current - join = cs.join_course params,user - @state = join[:state] - course = join[:course] + cs = CoursesService.new + @user = User.current + join = cs.join_course params,@user + @state = join[:state] + @course = join[:course] + # else + # @course = Course.find_by_id params[:object_id] + # CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest') + # @state = 6 + # end else @state = 5 #未登录 end - # if @state == 1 || @state == 3 - # respond_to course_path(course.id) - # else - respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} } - end - #end - - rescue Exception => e - @state = 4 #已经加入了课程 + @object_id = params[:object_id] respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => nil, :object_id => nil} } + format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} } end + end def unjoin @@ -110,7 +107,7 @@ class CoursesController < ApplicationController courses = Course.visible @courses = paginateHelper courses,10 else - courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'") + courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'").order("time desc, created_at desc") @courses = paginateHelper courses,10 end @name = params[:name] @@ -291,14 +288,11 @@ class CoursesController < ApplicationController def export_course_member_excel @all_members = student_homework_score(0,0,0,"desc") filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}"; - # 如果是ie 需要转码 - if(/trident/.match(request.env["HTTP_USER_AGENT"]) != nil) - filename= URI::encode(filename) - end + respond_to do |format| format.xls { send_data(member_to_xls(@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{filename}.xls") + :filename => filename_for_content_disposition("#{filename}.xls")) } end end @@ -619,6 +613,10 @@ class CoursesController < ApplicationController 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) + #更新申请结果反馈消息的状态 + course_request_messages = CourseMessage.where("user_id =? and course_id =? and course_message_type =? and viewed =?", User.current.id, @course.id, 'CourseRequestDealResult', false) + course_request_messages.update_all(:viewed => true) + course_activities = @course.course_activities @canShowRealName = User.current.member_of_course? @course @page = params[:page] ? params[:page].to_i + 1 : 0 @@ -713,6 +711,41 @@ class CoursesController < ApplicationController end end + #从课程创建的老师那里选择课程大纲 + def course_outline + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles + @is_in_show_outline_page = params[:is_in_show_outline_page] + respond_to do |format| + format.js + end + end + + #根据关键字搜索,查找方法一样的,但返回内容不一样 + def search_course_outline + @article_title = params[:title] + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles.like(@article_title) + render :json=>@blog_articles.to_json + end + + #设置或者更改课程的大纲 + def set_course_outline + @course.outline = params[:outline_id] + @course.save + @is_in_show_outline_page = params[:is_in_show_outline_page] + respond_to do |format| + format.js + end + end + + #显示课程大纲 + def syllabus + @article = BlogComment.find(@course.outline) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end #删除课程 #删除课程只是将课程的is_delete状态改为false,is_delete为false状态的课程只有管理员可以看到 def destroy diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 057d962c8..dd8dc84c4 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -331,6 +332,9 @@ class FilesController < ApplicationController #modify by nwb if @project @addTag=false + if params[:in_project_toolbar] + @in_project_toolbar = params[:in_project_toolbar] + end container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) attachments = Attachment.attach_filesex(container, params[:attachments], params[:attachment_type]) render_attachment_warning_if_needed(container) @@ -362,6 +366,9 @@ class FilesController < ApplicationController end elsif @course @addTag=false + if params[:in_course_toolbar] + @in_course_toolbar = params[:in_course_toolbar] + end attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type]) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') @@ -378,6 +385,8 @@ class FilesController < ApplicationController tag_name = l(:label_media) when "4" tag_name = l(:label_code) + when "6" + tag_name = "论文" else tag_name = "" end diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index ee132ac29..710bb2f47 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -42,8 +42,8 @@ class GanttsController < ApplicationController respond_to do |format| format.html { render :action => "show", :layout => 'base_projects' }#by young - format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') - format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => "#{basename}.pdf") } + format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => filename_for_content_disposition("#{basename}.png")) } if @gantt.respond_to?('to_image') + format.pdf { send_data(@gantt.to_pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{basename}.pdf") ) } end end end diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 5dd5363b9..93459578c 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -33,7 +33,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(@all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_not_rated)}).xls") ) } end end @@ -66,7 +66,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}(#{l(:excel_been_rated)}).xls") ) } end end @@ -101,7 +101,7 @@ class HomeworkAttachController < ApplicationController format.js format.xls { send_data(homework_to_xls(all_homework_list), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") + :filename => filename_for_content_disposition("#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@bid.name}#{l(:excel_homework_list)}.xls") ) } end end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 9e3a4b836..687ef9503 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -6,8 +6,8 @@ class HomeworkCommonController < ApplicationController include StudentWorkHelper before_filter :find_course, :only => [:index,:new,:create] - before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr] - before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr] + before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] + before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] before_filter :member_of_course, :only => [:index] def index @@ -38,6 +38,7 @@ class HomeworkCommonController < ApplicationController def edit @user = User.current @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i respond_to do |format| format.html{render :layout => 'new_base_user'} end @@ -47,10 +48,18 @@ class HomeworkCommonController < ApplicationController if params[:homework_common] @homework.name = params[:homework_common][:name] @homework.description = params[:homework_common][:description] + if params[:homework_common][:publish_time] == "" + @homework.publish_time = Date.today + else + @homework.publish_time = params[:homework_common][:publish_time] + end @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new + if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 + homework_detail_manual.comment_status = 1 + end homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] @@ -80,8 +89,12 @@ class HomeworkCommonController < ApplicationController @homework_detail_programing.save if @homework_detail_programing if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) - else + elsif params[:is_in_course] == "0" redirect_to user_homeworks_user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + redirect_to user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + redirect_to course_path(@course.id) end end end @@ -93,8 +106,12 @@ class HomeworkCommonController < ApplicationController format.html { if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) - else + elsif params[:is_in_course] == "0" redirect_to user_homeworks_user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "0" + redirect_to user_path(User.current.id) + elsif params[:is_in_course] == "-1" && params[:course_activity] == "1" + redirect_to course_path(@course.id) end } end @@ -130,6 +147,9 @@ class HomeworkCommonController < ApplicationController else @statue = 3 end + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i end #关闭匿评 @@ -145,6 +165,9 @@ class HomeworkCommonController < ApplicationController # 匿评关闭消息邮件通知 send_message_anonymous_comment(@homework, m_status = 3) Mailer.send_mail_anonymous_comment_close(@homework).deliver + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i respond_to do |format| format.js end @@ -171,6 +194,22 @@ class HomeworkCommonController < ApplicationController @homework.student_works.map { |work| @cur_size += work.student_works_scores.where(:reviewer_role => 3).count} end @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + + def alert_forbidden_anonymous_comment + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] if params[:is_in_course] + @course_activity = params[:course_activity] if params[:course_Activity] respond_to do |format| format.js end @@ -215,6 +254,16 @@ class HomeworkCommonController < ApplicationController end end + #评分设置 + def score_rule_set + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] + end + private #获取课程 def find_course diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 923414583..e529dd3b9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -151,7 +151,7 @@ class IssuesController < ApplicationController format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } format.pdf { pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) } end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 6bb61e6a1..4dc2c52f5 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -159,6 +159,14 @@ class MembersController < ApplicationController if role && (role.name == "学生" || role.name == "Student") StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id) end + + #给新成员和老师发送加入课程的消息,发送者id放在CourseMessage的course_message_id字段中 + #course_message_type设置为JoinCourse + #status = 0 表示给学生发,status = 1表示给老师发 + course_join = CourseMessage.new(:user_id =>user_id, :course_message_id=>User.current.id,:course_id => @course.id,:course_message_type=>"JoinCourse", :content => role, :viewed => false, :status => 0) + course_join.save + CourseMessage.create(:user_id => User.current.id, :course_message_id => user_id, :course_id => @course.id, :course_message_type => "JoinCourse",:content => role, :viewed => false, :status => 1) + members << member #user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id) if (params[:membership][:role_ids]) @@ -305,7 +313,8 @@ class MembersController < ApplicationController grade.destroy end end - ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id) + #移出项目发送消息 + ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id) end respond_to do |format| format.html { redirect_to_settings_in_projects } @@ -333,6 +342,8 @@ class MembersController < ApplicationController end @roles = Role.givable.all[3..5] @members = @course.member_principals.includes(:roles, :principal).all.sort + #移出课程发送消息 + CourseMessage.create(:user_id => @member.user_id, :course_id => @course.id, :course_message_type => "RemoveFromCourse", :viewed => false, :course_message_id => User.current.id) end respond_to do |format| format.html { redirect_to_settings_in_courses } diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index a8f2a11f1..ec54ae8a4 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -413,7 +413,7 @@ class PollController < ApplicationController respond_to do |format| format.xls { send_data(poll_to_xls(poll_questions), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{@poll.polls_name}.xls") + :filename => filename_for_content_disposition("#{@poll.polls_name}.xls") ) } end end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f2f10d5b6..1f252cc24 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -29,12 +29,12 @@ class RepositoriesController < ApplicationController menu_item :repository menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers] default_search_scope :changesets - + before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] - before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo] + before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -42,7 +42,7 @@ class RepositoriesController < ApplicationController include RepositoriesHelper helper :project_score #@root_path = RepositoriesHelper::ROOT_PATH - + rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed def new @@ -62,8 +62,8 @@ class RepositoriesController < ApplicationController end end - - + + def newrepo scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first @repository = Repository.factory(scm) @@ -76,23 +76,23 @@ class RepositoriesController < ApplicationController render :layout => 'base_projects' end end - + def fork @repository_url = params[:repository_url] - + # @repository.url # system "htpasswd -mb "+@root_path+"user.passwd "+params[:repository][:identifier]+" "+@upasswd # system "echo -e '"+params[:project_id]+"-"+params[:repository][:identifier]+"-write:"+ - # " "+params[:repository][:identifier]+"' >> "+@root_path+"group.passwd" - system "git clone --bare "+@repository_url + # " "+params[:repository][:identifier]+"' >> "+@root_path+"group.passwd" + system "git clone --bare "+@repository_url # system "mv "+@project_path+"/hooks/post-update{.sample,}" # system "chmod a+x "+@project_path+"/hooks/post-update" # system "."+@project_path+"/hooks/post-update" # system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - # " \n"+ - # "Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+ - # " \n ' >>"+ - # @project_path+"/.htaccess" + # " \n"+ + # "Require group "+params[:project_id]+"-"+params[:repository][:identifier]+"-write \n "+ + # " \n ' >>"+ + # @project_path+"/.htaccess" flash[:notice] = l(:label_notice_fork_successed) @repositories = @project.repositories render :action => 'show', :layout => 'base_projects' @@ -115,77 +115,24 @@ update } def create - if params[:repository_scm].to_s == 'Gitlab' - # add by nwb - # 增加对gitlab版本库的支持 - attrs = pickup_extra_info - @repository = Repository.factory('Git') - @repository.safe_attributes = params[:repository] - if attrs[:attrs_extra].keys.any? - @repository.merge_extra_info(attrs[:attrs_extra]) - end - @repository.project = @project - if request.post? && @repository.save - redirect_to settings_project_url(@project, :tab => 'repositories') - else - redirect_to settings_project_url(@project, :tab => 'repositories') - end - else # 原逻辑 - ##xianbo - @root_path=RepositoriesHelper::ROOT_PATH - @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" - @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:upassword] || params[:repository][:password] - @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] - logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag - logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name - attrs = pickup_extra_info - if((@repository_tag!="")&¶ms[:repository_scm]=="Git") - params[:repository][:url]=@project_path - end - ###xianbo - @repository = Repository.factory(params[:repository_scm]) - @repository.safe_attributes = params[:repository] - if attrs[:attrs_extra].keys.any? - @repository.merge_extra_info(attrs[:attrs_extra]) - end - - @repository.project = @project - if request.post? && @repository.save - if(params[:repository_scm]=="Git") - system "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+" "+@repository_tag - system "echo -e '"+@repo_name+"-write:"+ - " "+@repo_name+"' >> "+@root_path+"htdocs/group.passwd" - system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s - system "git init --bare "+@project_path - system "mv "+@project_path+"/hooks/post-update{.sample,}" - system "chmod a+x "+@project_path+"/hooks/post-update" - system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - " \n"+ - "Require group "+@repo_name+"-write \n "+ - " \n ' >> "+ - @root_path+"htdocs/"+ @repository_name+"/.htaccess" - system "cd "+@project_path+" ;git update-server-info" - - File.open(@project_path+"/hooks/post-update", "w+") do |f| - f.write(HOOK_TEMPLATE) - end - - @repository.update_attributes(:login => User.current.login.to_s) - end - redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) - else if(@repository_tag.blank?) - #render :action => 'newrepo', :layout =>'base_projects' - redirect_to settings_project_url(@project, :tab => 'repositories',:repository => "pswd_is_null",:repository_error_message=>@repository.errors.full_messages) - else - redirect_to settings_project_url(@project, :tab => 'repositories',:repository => @repository,:repository_error_message=>@repository.errors.full_messages) - end - end - - + attrs = pickup_extra_info + @repository = Repository.factory('Git') + @repository.safe_attributes = params[:repository] + if attrs[:attrs_extra].keys.any? + @repository.merge_extra_info(attrs[:attrs_extra]) + end + @repository.project = @project + @repository.type = 'Repository::Gitlab' + @repository.url = @repository.identifier + if request.post? && @repository.save + s = Trustie::Gitlab::Sync.new + s.create_project(@project, @repository) + redirect_to settings_project_url(@project, :tab => 'repositories') + else + redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) end end - + def edit end @@ -228,15 +175,17 @@ update # Build a hash with repository usernames as keys and corresponding user ids as values @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h} flash[:notice] = l(:notice_successful_update) - redirect_to settings_project_url(@project, :tab => 'repositories') + respond_to do |format| + format.html{ + render :layout => "base_projects" + } + end elsif request.get? - respond_to do |format| - format.html{ - render :layout => "base_projects" - } - end - - + respond_to do |format| + format.html{ + render :layout => "base_projects" + } + end end end @@ -247,6 +196,16 @@ update redirect_to settings_project_url(@project, :tab => 'repositories') end + def to_gitlab + @project = Project.find(params[:project_id]) + @repository = Repository.find(params[:id]) + s = Trustie::Gitlab::Sync.new + s.sync_project(@project, path: params[:repo_name], import_url: @repository.url) + @repository.type = 'Repository::Gitlab' + @repository.save + redirect_to :controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab' + end + def show ## TODO: the below will move to filter, done. if !User.current.member_of?(@project) @@ -256,19 +215,19 @@ update end end - if params[:to] == 'gitlab' - g = Gitlab.client - g.post('/session', body: {email: User.current.mail, password: User.current.hashed_password}) - redirect_to "http://192.168.41.130:3000/gitlab-org/gitlab-shell/tree/master" - return - end + # unless @repository.gitlab? + # # redirect_to to_gitlab_project_repository_path(@project, @repository) + # render :to_gitlab + # return + # end #if( !User.current.member_of?(@project) || @project.hidden_repo) @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty? + # :name, :path, :kind, :size, :lastrev, :changeset @entries = @repository.entries(@path, @rev) + # @trees = g.trees(project, @path) @changeset = @repository.find_changeset_by_name(@rev) - #@project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT #@ip = RepositoriesHelper::REPO_IP_ADDRESS @@ -276,15 +235,32 @@ update @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) else #Modified by young - # (show_error_not_found; return) unless @entries - @changesets = @repository.latest_changesets(@path, @rev) + # (show_error_not_found; return) unless @entries + g = Gitlab.client + count = 0 + (0..100).each do |page| + if g.commits(@project.gpid,:page => page).count == 0 + break + else + count = count + g.commits(@project.gpid,:page => page).count + end + end + @changesets = g.commits(@project.gpid) + # @changesets = @repository.latest_changesets(@path, @rev) + # @changesets_count = @repository.latest_changesets(@path, @rev).count + @changesets_all_count = count + @changesets_latest_coimmit = @changesets[0] @properties = @repository.properties(@path, @rev) @repositories = @project.repositories @course_tag = params[:course] project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT ip = RepositoriesHelper::REPO_IP_ADDRESS - @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ - @repository.url.slice(project_path_cut, @repository.url.length).to_s + gitlab_address = Redmine::Configuration['gitlab_address'] + if @repository.type.to_s == "Repository::Gitlab" + @repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git" + else + @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s + @repository.url.slice(project_path_cut, @repository.url.length).to_s + end if @course_tag == 1 render :action => 'show', :layout => 'base_courses' else @@ -298,7 +274,11 @@ update def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry - @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) + g = Gitlab.client + @commits = g.commits(@project.gpid, page:params[:pamge]) + @commit = g.commit(@project.gpid,@rev) + # @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") + #@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) @properties = @repository.properties(@path, @rev) @changeset = @repository.find_changeset_by_name(@rev) render :layout => 'base_projects' @@ -310,10 +290,10 @@ update per_page_option, params['page'] @changesets = @repository.changesets. - limit(@changeset_pages.per_page). - offset(@changeset_pages.offset). - includes(:user, :repository, :parents). - all + limit(@changeset_pages.per_page). + offset(@changeset_pages.offset). + includes(:user, :repository, :parents). + all respond_to do |format| format.html { render :layout => 'base_projects' } @@ -327,6 +307,7 @@ update def entry entry_and_raw(false) + render :layout => 'base_projects' end def entry_and_raw(is_raw) @@ -339,8 +320,8 @@ update @content = @repository.cat(@path, @rev) (show_error_not_found; return) unless @content if is_raw || - (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || - ! is_entry_text_data?(@content, @path) + (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || + ! is_entry_text_data?(@content, @path) # Force the download send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) } send_type = Redmine::MimeType.of(@path) @@ -423,8 +404,8 @@ update filename = "changeset_r#{@rev}" filename << "_r#{@rev_to}" if @rev_to send_data @diff.join, :filename => "#{filename}.diff", - :type => 'text/x-patch', - :disposition => 'attachment' + :type => 'text/x-patch', + :disposition => 'attachment' else @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) @@ -435,7 +416,7 @@ update User.current.preference.save end @cache_key = "repositories/diff/#{@repository.id}/" + - Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}") + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}") unless read_fragment(@cache_key) @diff = @repository.diff(@path, @rev, @rev_to) unless @diff @@ -462,16 +443,16 @@ update def graph data = nil case params[:graph] - when "commits_per_month" - data = graph_commits_per_month(@repository) - when "commits_per_author" - data = graph_commits_per_author(@repository) - when "author_commits_per_month" - data = graph_author_commits_per_month(@repository) - when "author_commits_six_month" - data = author_commits_six_month(@repository) - when "author_code_six_months" - data = author_code_six_month(@repository) + when "commits_per_month" + data = graph_commits_per_month(@repository) + when "commits_per_author" + data = graph_commits_per_author(@repository) + when "author_commits_per_month" + data = graph_author_commits_per_month(@repository) + when "author_commits_six_month" + data = author_commits_six_month(@repository) + when "author_code_six_months" + data = author_code_six_month(@repository) end if data headers["Content-Type"] = "image/svg+xml" @@ -551,14 +532,14 @@ update @date_from = @date_to << 11 @date_from = Date.civil(@date_from.year, @date_from.month, 1) commits_by_day = Changeset.count( - :all, :group => :commit_date, - :conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) + :all, :group => :commit_date, + :conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) commits_by_month = [0] * 12 commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } changes_by_day = Change.count( - :all, :group => :commit_date, :include => :changeset, - :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) + :all, :group => :commit_date, :include => :changeset, + :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) changes_by_month = [0] * 12 changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } @@ -566,26 +547,26 @@ update 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)} graph = SVG::Graph::Bar.new( - :height => 300, - :width => 600, - :fields => fields.reverse, - :stack => :side, - :scale_integers => true, - :step_x_labels => 2, - :show_data_values => true, - :graph_title => l(:label_commits_per_month), - :show_graph_title => true + :height => 300, + :width => 600, + :fields => fields.reverse, + :stack => :side, + :scale_integers => true, + :step_x_labels => 2, + :show_data_values => true, + :graph_title => l(:label_commits_per_month), + :show_graph_title => true ) # 具状图 graph.add_data( - :data => commits_by_month[0..11].reverse, - :title => l(:label_revision_plural) + :data => commits_by_month[0..11].reverse, + :title => l(:label_revision_plural) ) graph.add_data( - :data => changes_by_month[0..11].reverse, - :title => l(:label_change_plural) + :data => changes_by_month[0..11].reverse, + :title => l(:label_change_plural) ) graph.burn @@ -610,23 +591,23 @@ update fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') } graph = SVG::Graph::BarHorizontal.new( - :height => 400, - :width => 600, - :fields => fields, - :stack => :side, - :scale_integers => true, - :show_data_values => true, - :rotate_y_labels => false, - :graph_title => l(:label_commits_per_author), - :show_graph_title => true + :height => 400, + :width => 600, + :fields => fields, + :stack => :side, + :scale_integers => true, + :show_data_values => true, + :rotate_y_labels => false, + :graph_title => l(:label_commits_per_author), + :show_graph_title => true ) graph.add_data( - :data => commits_data, - :title => l(:label_revision_plural) + :data => commits_data, + :title => l(:label_revision_plural) ) graph.add_data( - :data => changes_data, - :title => l(:label_change_plural) + :data => changes_data, + :title => l(:label_change_plural) ) graph.burn end @@ -637,7 +618,7 @@ update @date_from = @date_to << 12 @date_from = Date.civil(@date_from.year, @date_from.month, @date_from.day) commits_by_author = Changeset.count(:all, :group => :committer, - :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) + :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) commits_by_author = commits_by_author.to_a.sort! {|x, y| x.last <=> y.last}.last(25) fields = commits_by_author.collect {|r| r.first} diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 062b0fa34..d20a58b75 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -5,14 +5,18 @@ class SchoolController < ApplicationController def upload uploaded_io = params[:logo] school_id ||= params[:id] + s1 = School.find(school_id) unless uploaded_io.nil? File.open(Rails.root.join('public', 'images', 'school', school_id.to_s+'.png'), 'wb') do |file| file.write(uploaded_io.read) end - s1 = School.find(school_id) + s1.logo_link = '/images/school/'+school_id.to_s+'.png' - s1.save + end + s1.name = params[:name] unless params[:name].blank? + s1.province = params[:province] unless params[:province].blank? + s1.save redirect_to admin_schools_url(:school_name => params[:school_name]) end @@ -121,16 +125,18 @@ class SchoolController < ApplicationController end end if(condition == '') - @school = School.all + @school = School.page((params[:page].to_i || 1) - 1).per(100) + @school_count = School.count else - @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").all + @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").page((params[:page].to_i || 1) - 1).per(100) + @school_count = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count end result = [] # @school.each do |sc| # result << {:value=>sc.name,:data=>sc.id} # end - render :json => @school.to_json + render :json =>{ :schools => @school,:count=>@school_count}.to_json end #添加学校 diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index 85ea85241..0d1755294 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -84,7 +84,7 @@ class StoresController < ApplicationController respond_to do |format| format.xls { send_data(homework_to_xls(attachments), :type => "text/excel;charset=utf-8; header=present", - :filename => "#{l(:label_file_lost_list)}.xls") + :filename => filename_for_content_disposition("#{l(:label_file_lost_list)}.xls") ) } end end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index e5e1bf391..9ad46cd69 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,11 +3,11 @@ class StudentWorkController < ApplicationController include StudentWorkHelper 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] + 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] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :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] + before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] ### def program_test @@ -89,7 +89,9 @@ class StudentWorkController < ApplicationController else student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' end - if @is_teacher || @homework.homework_detail_manual.nil? #老师 || 超级管理员 显示所有列表 + #老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表 + if @is_teacher || @homework.homework_detail_manual.nil? || + (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name @show_all = true elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 @@ -108,8 +110,9 @@ class StudentWorkController < ApplicationController else @stundet_works = [] end + @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count else - if @is_teacher || @homework.homework_detail_manual.nil? #老师 || 超级管理员 显示所有列表 + if @is_teacher || @homework.homework_detail_manual.nil? || (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) #老师 || 超级管理员 显示所有列表 @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name @show_all = true elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 @@ -128,6 +131,7 @@ class StudentWorkController < ApplicationController else @stundet_works = [] end + @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name).count end @score = @b_sort == "desc" ? "asc" : "desc" @@ -164,6 +168,7 @@ class StudentWorkController < ApplicationController def create if params[:student_work] + @submit_result = true student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id] student_work ||= StudentWork.new student_work.name = params[:student_work][:name] @@ -179,7 +184,6 @@ class StudentWorkController < ApplicationController else student_work.late_penalty = 0 end - if student_work.save course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first if course_activity @@ -191,20 +195,16 @@ class StudentWorkController < ApplicationController user_activity.updated_at = Time.now user_activity.save end + @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_create) - redirect_to student_work_index_url(:homework => @homework.id) - } + format.js end return end end + @submit_result = false respond_to do |format| - format.html { - flash[:notice] = l(:notice_failed_create) - redirect_to new_student_work_url(:homework => @homework.id) - } + format.js end end @@ -221,24 +221,36 @@ class StudentWorkController < ApplicationController def update if params[:student_work] + @submit_result = true @work.name = params[:student_work][:name] @work.description = params[:student_work][:description] @work.project_id = params[:student_work][:project] @work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@work) if @work.save +=begin respond_to do |format| format.html { flash[:notice] = l(:notice_successful_edit) redirect_to student_work_index_url(:homework => @homework.id) } +=end + @student_work = @work + respond_to do |format| + format.js end return end end +=begin respond_to do |format| format.html{redirect_to edit_student_work_url(@work)} end +=end + @submit_result = false + respond_to do |format| + format.js + end end def show @@ -456,11 +468,36 @@ class StudentWorkController < ApplicationController student_work.save end end - respond_to do |format| - format.html{redirect_to student_work_index_url(:homework => @homework.id)} + if params[:student_path] + redirect_to student_work_index_url(:homework => @homework.id) + else + @user_activity_id = params[:user_activity_id] + @is_in_course = params[:is_in_course] + respond_to do |format| + format.js + end end end + def forbidden_anonymous_comment + @homework.update_column('anonymous_comment', 1) + homework_detail_manual = @homework.homework_detail_manual + homework_detail_programing = @homework.homework_detail_programing + if homework_detail_programing + homework_detail_manual.update_column('ta_proportion', 0.4) + homework_detail_programing.update_column('ta_proportion', 0.6) + else + homework_detail_manual.update_column('ta_proportion', 1.0) + end + @homework.student_works.each do |student_work| + set_final_score @homework,student_work + student_work.save + end + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + end + private #获取作业 def find_homework diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7adba7cbf..0d9588d24 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -239,6 +239,46 @@ class UsersController < ApplicationController end end + #处理加入课程成为教辅教师的请求 + #status 1 同意 2 拒绝 + def dealwith_apply_request + @msg = CourseMessage.find(params[:msg_id]) + #CourseMessage content存的是role 7教辅 9 教师 + case params[:agree] + when 'Y' + apply_user = User.find(@msg.course_message_id) + + if apply_user.member_of_course?(Course.find(@msg.course_id)) + #将角色改为老师或者教辅 + member = Course.find(@msg.course_id).members.where(:user_id=>apply_user.id).all[0] + member.role_ids = [@msg.content] # msg content保存的是申请的职位角色 + #删除为学生的记录 + joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,@msg.course_id) + joined.each do |join| + join.delete + end + + member.course_group_id = 0 + member.save + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) + @msg.update_attributes(:status=>1,:viewed=>1) + else + members = [] + members << Member.new(:role_ids => [@msg.content.to_i], :user_id => @msg.course_message_id) + Course.find(@msg.course_id).members << members + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1) + @msg.update_attributes(:status=>1,:viewed=>1) + end + + when 'N' + CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>2) + @msg.update_attributes(:status=>2,:viewed=>1) + end + respond_to do |format| + format.js + end + end + # added by bai def show_score @@ -328,7 +368,21 @@ class UsersController < ApplicationController if User.current == @user @page = params[:page] ? params[:page].to_i + 1 : 0 user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - @homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10) + + #判断当前用户在当前课程的身份 + visibleCourse = @user.courses.empty? ? [] : @user.courses.visible + homework_ids = [] + visibleCourse.each do |course| + if User.current.allowed_to?(:as_teacher,course) + homeworks = HomeworkCommon.where("course_id = #{course.id}") + homework_ids << homeworks.pluck(:id) unless homeworks.empty? + else + homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'") + homework_ids << homeworks.pluck(:id) unless homeworks.empty? + end + end + visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")" + @homework_commons = HomeworkCommon.where("id in #{visible_homework_ids}").order("created_at desc").limit(10).offset(@page * 10) @is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true) @is_in_course = params[:is_in_course].to_i || 0 respond_to do |format| @@ -453,8 +507,12 @@ class UsersController < ApplicationController homework = HomeworkCommon.new homework.name = params[:homework_common][:name] homework.description = params[:homework_common][:description] - homework.end_time = params[:homework_common][:end_time] || Time.now - homework.publish_time = Time.now + homework.end_time = params[:homework_common][:end_time] || Date.today + if params[:homework_common][:publish_time] == "" + homework.publish_time = Date.today + else + homework.publish_time = params[:homework_common][:publish_time] + end homework.homework_type = params[:homework_type].to_i || 1 homework.late_penalty = 10 homework.teacher_priority = 1 @@ -466,7 +524,11 @@ class UsersController < ApplicationController homework_detail_manual = HomeworkDetailManual.new homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 - homework_detail_manual.comment_status = 1 + if homework.publish_time > Date.today + homework_detail_manual.comment_status = 0 + else + homework_detail_manual.comment_status = 1 + end homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start] homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 @@ -878,6 +940,12 @@ class UsersController < ApplicationController end def show + #更新用户申请成为课程老师或教辅消息的状态 + 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 @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" @@ -903,10 +971,19 @@ class UsersController < ApplicationController when "current_user" @user_activities = UserActivity.where("user_id = #{@user.id} and ((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}))").order('updated_at desc').limit(10).offset(@page * 10) 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(','))+")" + @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}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) 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) + # @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(','))+")" + @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}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) end # @user_activities = paginateHelper @user_activities,500 @type = params[:type] diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index da6d48b8d..c0351c6da 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -82,14 +82,14 @@ class WikiController < ApplicationController @content = @page.content_for_version(params[:version]) if User.current.allowed_to?(:export_wiki_pages, @project) if params[:format] == 'pdf' - send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => "#{@page.title}.pdf") + send_data(wiki_page_to_pdf(@page, @project), :type => 'application/pdf', :filename => filename_for_content_disposition("#{@page.title}.pdf") ) return elsif params[:format] == 'html' export = render_to_string :action => 'export', :layout => false - send_data(export, :type => 'text/html', :filename => "#{@page.title}.html") + send_data(export, :type => 'text/html', :filename => filename_for_content_disposition("#{@page.title}.html")) return elsif params[:format] == 'txt' - send_data(@content.text, :type => 'text/plain', :filename => "#{@page.title}.txt") + send_data(@content.text, :type => 'text/plain', :filename => filename_for_content_disposition("#{@page.title}.txt") ) return end end @@ -286,7 +286,7 @@ class WikiController < ApplicationController send_data(export, :type => 'text/html', :filename => "wiki.html") } format.pdf { - send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => "#{@project.identifier}.pdf") + send_data(wiki_pages_to_pdf(@pages, @project), :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}.pdf") ) } end end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 6304055ed..6cc622c49 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -60,6 +60,11 @@ class WordsController < ApplicationController course_activity.updated_at = Time.now course_activity.save end + principal_activity = PrincipalActivity.where("principal_act_type='JournalsForMessage' and principal_act_id =#{parent_id}").first + if principal_activity + principal_activity.updated_at = Time.now + principal_activity.save + end user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first if user_activity user_activity.updated_at = Time.now @@ -243,7 +248,46 @@ class WordsController < ApplicationController flash[:error] = feedback.errors.full_messages[0] redirect_to course_feedback_url(params[:id]) end + end + #作业的回复 + def leave_homework_message + if User.current.logged? + @user = User.current + @homework_common = HomeworkCommon.find(params[:id]); + if params[:homework_message].size>0 && User.current.logged? && @user + feedback = HomeworkCommon.add_homework_jour(@user, params[:homework_message], params[:id]) + if (feedback.errors.empty?) + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE + end + + course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework_common.id}").first + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end + user_activity = UserActivity.where("act_type='HomeworkCommon' and act_id =#{@homework_common.id}").first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end + respond_to do |format| + format.js{ + @user_activity_id = params[:user_activity_id] + @is_in_course = params[:is_in_course] + @course_activity = params[:course_activity] + @homework_common_id = params[:homework_common_id] + } + end + else + flash[:error] = feedback.errors.full_messages[0] + end + end + else + render_403 + end end def add_brief_introdution diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ce11bded8..e5cd9b52b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -609,6 +609,17 @@ module ApplicationHelper return @result end + # 判断版本库是否初始为gitlab + def rep_is_gitlab?(project) + rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab") + return rep.blank? ? true :false + end + + # 获取单一gitlab项目 + def gitlab_repository(project) + rep = Repository.where("project_id =? and type =?", project.id,"Repository::Gitlab" ).first + end + # 判断当前用户是否为项目管理员 def is_project_manager?(user_id, project_id) @result = false @@ -2296,15 +2307,15 @@ module ApplicationHelper end #获取匿评相关连接代码 - def homework_anonymous_comment homework + def homework_anonymous_comment (homework, is_in_course, user_activity_id = -1, course_activity = -1) if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评" elsif homework.student_works.count >= 2 && homework.homework_detail_manual#作业份数大于2 case homework.homework_detail_manual.comment_status when 1 - link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' + link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' when 2 - link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' + link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' when 3 # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" end @@ -2355,14 +2366,18 @@ module ApplicationHelper else #学生显示提交作品、修改作品等按钮 work = cur_user_works_for_homework homework if work.nil? - link_to "提交作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' + link_to "提交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' else - if homework.homework_detail_manual && homework.homework_detail_manual.comment_status != 1 #匿评作业,且作业状态不是在开启匿评之前 + if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前 link_to "作品匿评", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品" - elsif homework.homework_type == 2 #编程作业不能修改作品 - link_to "修改作品", new_student_work_path(:homework => homework.id),:class => 'c_blue' + elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 + link_to "匿评结束", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "匿评已结束" + elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品 + link_to "修改作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' + elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") + link_to "修改作品(#{homework.student_works.count})", edit_student_work_path(work.id),:class => 'c_blue' else - link_to "修改作品", edit_student_work_path(work.id),:class => 'c_blue' + link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "作业截止后不可修改作品" end end end diff --git a/app/helpers/blog_comments_helper.rb b/app/helpers/blog_comments_helper.rb new file mode 100644 index 000000000..2b0c3e5bd --- /dev/null +++ b/app/helpers/blog_comments_helper.rb @@ -0,0 +1,2 @@ +module BlogCommentsHelper +end diff --git a/app/helpers/blogs_helper.rb b/app/helpers/blogs_helper.rb new file mode 100644 index 000000000..cc0dbd200 --- /dev/null +++ b/app/helpers/blogs_helper.rb @@ -0,0 +1,2 @@ +module BlogsHelper +end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f9fb31969..caca6fb1e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -36,7 +36,7 @@ module CoursesHelper #生成课程老师成员链接 def course_teacher_link teacher_num if User.current.member_of_course?(@course) || User.current.admin? - link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue' + link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue', :id => 'teacher_number' else content_tag 'span',teacher_num, :class => 'info_foot_num c_blue' end @@ -45,7 +45,7 @@ module CoursesHelper #生成课程学生列表连接 def course_student_link student_num if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) || User.current.admin? - link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue' + link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue', :id => "student_number" else content_tag 'span',student_num, :class => 'info_foot_num c_blue' end @@ -628,10 +628,10 @@ module CoursesHelper #重启、关闭课程按钮 def set_course_time course - id = "finish_course_#{course.id}" - linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) - desc = course_endTime_timeout?(course) ? l(:label_course_reload) : l(:label_course_closed) - link_to "#{desc}".html_safe, linkPath, :remote => true, :method => :post, :id => id, :confirm => l(:label_course_closed_tips, :desc => desc), :class => "pr_join_a" + # id = "finish_course_#{course.id}" + # linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) + # desc = course_endTime_timeout?(course) ? l(:label_course_reload) : l(:label_course_closed) + # link_to "#{desc}".html_safe, linkPath, :remote => true, :method => :post, :id => id, :confirm => l(:label_course_closed_tips, :desc => desc), :class => "pr_join_a" end #加入课程、退出课程按钮 diff --git a/app/helpers/homework_common_helper.rb b/app/helpers/homework_common_helper.rb index a03c4ccd7..2d3c72c20 100644 --- a/app/helpers/homework_common_helper.rb +++ b/app/helpers/homework_common_helper.rb @@ -57,12 +57,12 @@ module HomeworkCommonHelper end #根据传入作业确定跳转到开启匿评还是关闭匿评功能 - def alert_anonyoms_path homework,homework_detail_manual + def alert_anonyoms_path homework,homework_detail_manual,user_activity_id,is_in_course,course_activity link = "" if homework_detail_manual.comment_status == 1 - link = start_anonymous_comment_homework_common_url homework.id + link = start_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity elsif homework_detail_manual.comment_status == 2 - link = stop_anonymous_comment_homework_common_url homework.id + link = stop_anonymous_comment_homework_common_url homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course,:course_activity=>course_activity end link end diff --git a/app/helpers/owner_type_helper.rb b/app/helpers/owner_type_helper.rb index c03f2d19e..7119d4f60 100644 --- a/app/helpers/owner_type_helper.rb +++ b/app/helpers/owner_type_helper.rb @@ -7,4 +7,5 @@ module OwnerTypeHelper BID = 6 JOURNALSFORMESSAGE = 7 HOMEWORKCOMMON = 8 + BLOGCOMMENT=9 end \ No newline at end of file diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 41f25d1a3..51d1846d8 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -117,6 +117,22 @@ module ProjectsHelper end end + # 获取新增gitlab版本库 + def rep_gitlab(project) + rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab") + end + + # 获取新项目的版本库地址 + def rep_gitlab_url(project) + gitlab_address = Redmine::Configuration['gitlab_address'] + url = gitlab_address.to_s+"/"+project.owner.to_s+"/"+ rep_gitlab(project).first.identifier+"."+"git" + end + + # # 获取Forge历史版本库 + def rep_forge(project) + rep = Repository.where("project_id =? and type =?", project, "Repository::Git") + end + # Added by young def course_settings_tabs tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'}, diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 710b7488f..f32bef51b 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -25,6 +25,7 @@ module RepositoriesHelper end PROJECT_PATH_CUT = 40 REPO_IP_ADDRESS = Setting.host_repository + REPO_GITLAB_ADDRESS = "git.trustie.net" def format_revision(revision) if revision.respond_to? :format_identifier @@ -34,12 +35,21 @@ module RepositoriesHelper end end + def repository_creater rep + repository_creater = User.find_by_login(rep.login) unless rep.login.nil? + end + def truncate_at_line_break(text, length = 255) if text text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...') end end + def user_commit_rep(mail) + user = User.find_by_mail(mail) + user.nil? ? User.find(2) : User.find_by_mail(mail) + end + def render_properties(properties) unless properties.nil? || properties.empty? content = '' diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 0f728fc00..f7fb9b1aa 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -442,12 +442,7 @@ class Attachment < ActiveRecord::Base def self.attach_filesex(obj, attachments,attachment_type) - if obj.is_public? - public_status = true - else - public_status = false - end - result = obj.save_attachmentsex(attachments, User.current,attachment_type, public_status) + result = obj.save_attachmentsex(attachments, User.current,attachment_type) obj.attach_saved_attachments result end diff --git a/app/models/blog.rb b/app/models/blog.rb new file mode 100644 index 000000000..bd338cdad --- /dev/null +++ b/app/models/blog.rb @@ -0,0 +1,16 @@ +class Blog < ActiveRecord::Base + # attr_accessible :title, :body + include Redmine::SafeAttributes + belongs_to :user + has_many :articles, :class_name => 'BlogComment', :conditions => "#{BlogComment.table_name}.parent_id IS NULL ", :order => "#{BlogComment.table_name}.created_on DESC" + has_many :blog_comments, :dependent => :destroy, :order => "#{BlogComment.table_name}.created_on DESC" + belongs_to :last_comment, :class_name => 'BlogComment', :foreign_key => :last_comment_id + acts_as_tree :dependent => :nullify + #acts_as_list :scope => '(user_id = #{user_id} AND parent_id #{user_id ? = "#{parent_id}" : "IS NULL"})' + acts_as_watchable + + validates :name, presence: true, length: {maximum: 30} + validates :description, length: {maximum: 255} + + safe_attributes 'name', 'description' +end diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb new file mode 100644 index 000000000..27da33121 --- /dev/null +++ b/app/models/blog_comment.rb @@ -0,0 +1,59 @@ +class BlogComment < ActiveRecord::Base + # attr_accessible :title, :body + include Redmine::SafeAttributes + belongs_to :blog + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + + acts_as_tree :counter_cache => :comments_count, :order => "#{BlogComment.table_name}.sticky desc ,#{BlogComment.table_name}.created_on ASC" + acts_as_attachable + belongs_to :last_reply, :class_name => 'BlogComment', :foreign_key => 'last_comment_id' + # 虚拟关联 + has_many :user_acts, :class_name => 'UserAcivity',:as =>:act + acts_as_watchable + + validates_presence_of :title, :content + validates_length_of :title, :maximum => 255 + #validate :cannot_reply_to_locked_comment, :on => :create + safe_attributes 'title', 'content',"sticky", "locked" + + after_save :add_user_activity + before_destroy :destroy_user_activity + + scope :like, lambda {|arg| + if arg.blank? + where(nil) + else + pattern = "%#{arg.to_s.strip.downcase}%" + where(" LOWER(title) LIKE :p ", :p => pattern) + end + } + + #在个人动态里面增加当前动态 + def add_user_activity + if self.parent_id.nil? #只有发博文才插入动态 + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first + if user_activity + user_activity.save + else + user_activity = UserActivity.new + user_activity.act_id = self.id + user_activity.act_type = self.class.to_s + user_activity.container_type = "Blog" + user_activity.container_id = self.blog_id + user_activity.user_id = self.author_id + user_activity.save + end + end + end + + def destroy_user_activity + user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'") + user_activity.destroy_all + end + def deleted_attach_able_by? user + (user && user.logged? && (self.author == user) ) || user.admin? + end + + def project + end +end diff --git a/app/models/course.rb b/app/models/course.rb index 46599dbfc..7288c3b3b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -50,6 +50,8 @@ class Course < ActiveRecord::Base validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 before_save :self_validate + # 公开课程变成私有课程,所有资源都变成私有 + after_update :update_files_public after_create :create_board_sync, :act_as_course_activity, :act_as_course_message before_destroy :delete_all_members @@ -212,6 +214,14 @@ class Course < ActiveRecord::Base def self_validate end + + def update_files_public + unless self.is_public? + self.attachments.each do |a| + a.update_attributes(:is_public => false) + end + end + end # 创建课程讨论区 def create_board_sync diff --git a/app/models/course_message.rb b/app/models/course_message.rb index 65e91141c..11b0165c5 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -18,8 +18,10 @@ class CourseMessage < ActiveRecord::Base after_create :add_user_message def add_user_message - if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? - self.message_alls << MessageAll.new(:user_id => self.user_id) - end + #unless self.course_message_type == 'JoinCourseRequest' + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end + #end end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 796080645..8d421a98f 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -12,6 +12,7 @@ class HomeworkCommon < ActiveRecord::Base has_many :homework_tests, :dependent => :destroy has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 + has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy @@ -22,7 +23,8 @@ class HomeworkCommon < ActiveRecord::Base :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail, :act_as_course_activity, :act_as_course_message + after_create :act_as_activity, :send_mail, :act_as_course_message + after_save :act_as_course_activity after_destroy :delete_kindeditor_assets def act_as_activity @@ -32,17 +34,27 @@ class HomeworkCommon < ActiveRecord::Base #课程动态公共表记录 def act_as_course_activity if self.course - self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id) + if self.homework_detail_manual.comment_status == 0 + self.course_acts.destroy_all + else + if self.course_acts.size == 0 + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id) + end + end end end #课程作业消息记录 def act_as_course_message if self.course - self.course.members.each do |m| - # if m.user_id != self.user_id + if self.homework_detail_manual.comment_status == 0 + self.course_messages.destroy_all + else + self.course.members.each do |m| + # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) - # end + # end + end end end end @@ -53,13 +65,27 @@ class HomeworkCommon < ActiveRecord::Base end def send_mail - Mailer.run.homework_added(self) + if self.homework_detail_manual.comment_status != 0 + Mailer.run.homework_added(self) + end end def is_program_homework? self.homework_type == 2 && self.homework_detail_programing end + ###添加回复 + def self.add_homework_jour(user, notes, id , options = {}) + homework = HomeworkCommon.find(id) + if options.count == 0 + jfm = homework.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0) + else + jfm = homework.journals_for_messages.build(options) + end + jfm.save + jfm + end + delegate :language_name, :language, :to => :homework_detail_programing end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index faab129a6..5e40267cb 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -136,10 +136,8 @@ class JournalsForMessage < ActiveRecord::Base #用户动态公共表记录 def act_as_principal_activity - if self.jour_type == 'Principal' - unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0 - self.principal_acts << PrincipalActivity.new(:user_id => self.user_id, :principal_id => self.jour_id) - end + if self.jour_type == 'Principal' && self.m_parent_id.nil? + self.principal_acts << PrincipalActivity.new(:user_id => self.user_id, :principal_id => self.jour_id) end end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d797f1ce1..8891e6552 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -1009,6 +1009,16 @@ class Mailer < ActionMailer::Base end end + def join_course_request(course, user, role) + @receive = User.find(course.tea_id) + @course = course + @user = user + @role = role + @subject = "#{@user.show_name} #{l(:label_apply_join_course)} #{@course.name} " + mail :to => @receive.mail, + :subject => @subject + end + private @@ -1066,4 +1076,5 @@ class Mailer < ActionMailer::Base 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } return newpass end + end diff --git a/app/models/member.rb b/app/models/member.rb index 655c79895..ed7ee81e6 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -34,6 +34,7 @@ class Member < ActiveRecord::Base after_destroy :delete_ivite_list + def role end diff --git a/app/models/member_role.rb b/app/models/member_role.rb index 67122a636..4d493cb27 100644 --- a/app/models/member_role.rb +++ b/app/models/member_role.rb @@ -35,8 +35,11 @@ class MemberRole < ActiveRecord::Base !inherited_from.nil? end + include Trustie::Gitlab::ManageMember + private + def remove_member_if_empty if member.roles.empty? member.destroy diff --git a/app/models/memo.rb b/app/models/memo.rb index 33b24db50..7c4fbdcf1 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -9,7 +9,7 @@ class Memo < ActiveRecord::Base # 若是主题帖,则内容可以是空 #validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? } validates_length_of :subject, maximum: 50 - validates_length_of :content, maximum: 5000 + validates_length_of :content, maximum: 30000 validate :cannot_reply_to_locked_topic, :on => :create acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC" diff --git a/app/models/project.rb b/app/models/project.rb index fcc96c404..fd1012fa0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -770,7 +770,8 @@ class Project < ActiveRecord::Base 'project_type', 'dts_test', 'attachmenttype', - 'enterprise_name' + 'enterprise_name', + 'gpid' @@ -853,6 +854,10 @@ class Project < ActiveRecord::Base end end + def owner + User.find(self.user_id) + end + private def after_parent_changed(parent_was) @@ -1167,5 +1172,7 @@ class Project < ActiveRecord::Base :forge_act_id => self.id,:forge_act_type => "ProjectCreateInfo") fa.save! end + + end diff --git a/app/models/repository.rb b/app/models/repository.rb index 5680f05a7..94b7905c6 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -57,6 +57,11 @@ class Repository < ActiveRecord::Base safe_attributes 'url', :if => lambda {|repository, user| repository.new_record?} + + def gitlab? + self.type == 'Repository::Gitlab' + end + def repo_create_validation unless Setting.enabled_scm.include?(self.class.name.demodulize) errors.add(:type, :invalid) diff --git a/app/models/repository/gitlab.rb b/app/models/repository/gitlab.rb new file mode 100644 index 000000000..5ec725660 --- /dev/null +++ b/app/models/repository/gitlab.rb @@ -0,0 +1,259 @@ +#coding=utf-8 + +require 'redmine/scm/adapters/git_adapter' + +class Repository::Gitlab < Repository + + attr_protected :root_url + validates_presence_of :url + + def self.human_attribute_name(attribute_key_name, *args) + attr_name = attribute_key_name.to_s + if attr_name == "url" + attr_name = "path_to_repository" + end + super(attr_name, *args) + end + + def self.scm_adapter_class + Redmine::Scm::Adapters::GitlabAdapter + end + + def self.scm_name + 'Gitlab' + end + + def commits(authors, start_date, end_date, branch='master') + scm.commits(authors, start_date, end_date,branch).map {|commit| + [commit[:author], commit[:num]] + } + end + + def report_last_commit + extra_report_last_commit + end + + def extra_report_last_commit + return false if extra_info.nil? + v = extra_info["extra_report_last_commit"] + return false if v.nil? + v.to_s != '0' + end + + def supports_directory_revisions? + true + end + + def supports_revision_graph? + true + end + + def repo_log_encoding + 'UTF-8' + end + + # Returns the identifier for the given git changeset + def self.changeset_identifier(changeset) + changeset.scmid + end + + # Returns the readable identifier for the given git changeset + def self.format_changeset_identifier(changeset) + changeset.revision[0, 8] + end + + def branches + scm.branches + end + + def tags + scm.tags + end + + def default_branch + scm.default_branch + rescue Exception => e + logger.error "git: error during get default branch: #{e.message}" + nil + end + + def find_changeset_by_name(name) + if name.present? + changesets.where(:revision => name.to_s).first || + changesets.where('scmid LIKE ?', "#{name}%").first + end + end + + def entries(path=nil, identifier=nil) + entries = scm.entries(path, identifier, :report_last_commit => extra_report_last_commit) + load_entries_changesets(entries) + entries + end + + # With SCMs that have a sequential commit numbering, + # such as Subversion and Mercurial, + # Redmine is able to be clever and only fetch changesets + # going forward from the most recent one it knows about. + # + # However, Git does not have a sequential commit numbering. + # + # In order to fetch only new adding revisions, + # Redmine needs to save "heads". + # + # In Git and Mercurial, revisions are not in date order. + # Redmine Mercurial fixed issues. + # * Redmine Takes Too Long On Large Mercurial Repository + # http://www.redmine.org/issues/3449 + # * Sorting for changesets might go wrong on Mercurial repos + # http://www.redmine.org/issues/3567 + # + # Database revision column is text, so Redmine can not sort by revision. + # Mercurial has revision number, and revision number guarantees revision order. + # Redmine Mercurial model stored revisions ordered by database id to database. + # So, Redmine Mercurial model can use correct ordering revisions. + # + # Redmine Mercurial adapter uses "hg log -r 0:tip --limit 10" + # to get limited revisions from old to new. + # But, Git 1.7.3.4 does not support --reverse with -n or --skip. + # + # The repository can still be fully reloaded by calling #clear_changesets + # before fetching changesets (eg. for offline resync) + def fetch_changesets + scm_brs = branches + return if scm_brs.nil? || scm_brs.empty? + + h1 = extra_info || {} + h = h1.dup + repo_heads = scm_brs.map{ |br| br.scmid } + h["heads"] ||= [] + prev_db_heads = h["heads"].dup + if prev_db_heads.empty? + prev_db_heads += heads_from_branches_hash + end + return if prev_db_heads.sort == repo_heads.sort + + h["db_consistent"] ||= {} + if changesets.count == 0 + h["db_consistent"]["ordering"] = 1 + merge_extra_info(h) + self.save + elsif ! h["db_consistent"].has_key?("ordering") + h["db_consistent"]["ordering"] = 0 + merge_extra_info(h) + self.save + end + save_revisions(prev_db_heads, repo_heads) + end + + def save_revisions(prev_db_heads, repo_heads) + h = {} + opts = {} + opts[:reverse] = true + opts[:excludes] = prev_db_heads + opts[:includes] = repo_heads + + revisions = scm.revisions('', nil, nil, opts) + return if revisions.blank? + + # Make the search for existing revisions in the database in a more sufficient manner + # + # Git branch is the reference to the specific revision. + # Git can *delete* remote branch and *re-push* branch. + # + # $ git push remote :branch + # $ git push remote branch + # + # After deleting branch, revisions remain in repository until "git gc". + # On git 1.7.2.3, default pruning date is 2 weeks. + # So, "git log --not deleted_branch_head_revision" return code is 0. + # + # After re-pushing branch, "git log" returns revisions which are saved in database. + # So, Redmine needs to scan revisions and database every time. + # + # This is replacing the one-after-one queries. + # Find all revisions, that are in the database, and then remove them from the revision array. + # Then later we won't need any conditions for db existence. + # Query for several revisions at once, and remove them from the revisions array, if they are there. + # Do this in chunks, to avoid eventual memory problems (in case of tens of thousands of commits). + # If there are no revisions (because the original code's algorithm filtered them), + # then this part will be stepped over. + # We make queries, just if there is any revision. + limit = 100 + offset = 0 + revisions_copy = revisions.clone # revisions will change + while offset < revisions_copy.size + recent_changesets_slice = changesets.find( + :all, + :conditions => [ + 'scmid IN (?)', + revisions_copy.slice(offset, limit).map{|x| x.scmid} + ] + ) + # Subtract revisions that redmine already knows about + recent_revisions = recent_changesets_slice.map{|c| c.scmid} + revisions.reject!{|r| recent_revisions.include?(r.scmid)} + offset += limit + end + + revisions.each do |rev| + transaction do + # There is no search in the db for this revision, because above we ensured, + # that it's not in the db. + save_revision(rev) + end + end + h["heads"] = repo_heads.dup + merge_extra_info(h) + self.save + end + private :save_revisions + + def save_revision(rev) + parents = (rev.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact + changeset = Changeset.create( + :repository => self, + :revision => rev.identifier, + :scmid => rev.scmid, + :committer => rev.author, + :committed_on => rev.time, + :comments => rev.message, + :parents => parents + ) + unless changeset.new_record? + rev.paths.each { |change| changeset.create_change(change) } + end + changeset + end + private :save_revision + + def heads_from_branches_hash + h1 = extra_info || {} + h = h1.dup + h["branches"] ||= {} + h['branches'].map{|br, hs| hs['last_scmid']} + end + + def latest_changesets(path,rev,limit=10) + revisions = scm.revisions(path, nil, rev, :limit => limit, :all => false) + return [] if revisions.nil? || revisions.empty? + + changesets.find( + :all, + :conditions => [ + "scmid IN (?)", + revisions.map!{|c| c.scmid} + ] + ) + end + + def clear_extra_info_of_changesets + return if extra_info.nil? + v = extra_info["extra_report_last_commit"] + write_attribute(:extra_info, nil) + h = {} + h["extra_report_last_commit"] = v + merge_extra_info(h) + self.save + end + private :clear_extra_info_of_changesets +end diff --git a/app/models/role.rb b/app/models/role.rb index f363b52bf..8bf5ebc05 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -77,6 +77,27 @@ class Role < ActiveRecord::Base self.givable[3..5] end + GUEST = 10 + REPORTER = 20 + DEVELOPER = 30 + MASTER = 40 + OWNER = 50 + def to_gitlab_role + case self.position + when 1,2 + GUEST + when 5 + REPORTER + when 4 + DEVELOPER + when 3 + MASTER + else + GUEST + end + end + + # Copies attributes from another role, arg can be an id or a Role def copy_from(arg, options={}) return unless arg.present? diff --git a/app/models/user.rb b/app/models/user.rb index d66785460..edc29c015 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,6 +93,7 @@ class User < Principal has_many :changesets, :dependent => :nullify has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'" + has_one :blog, :class_name => 'Blog', :foreign_key => "author_id" has_one :api_token, :class_name => 'Token', :conditions => "action='api'" belongs_to :auth_source belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang @@ -217,6 +218,8 @@ class User < Principal # 更新邮箱用户或用户名的同事,同步更新邀请信息 after_update :update_invite_list + include Trustie::Gitlab::ManageUser + scope :in_group, lambda {|group| group_id = group.is_a?(Group) ? group.id : group.to_i where("#{User.table_name}.id IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id) @@ -255,6 +258,18 @@ class User < Principal # count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count end + def blog + @blog = Blog.where("author_id = #{self.id}").all[0] + if @blog.nil? + #如果某个user的blog不存在,那么就创建一条,并且跳转 + @blog = Blog.create(:name=>(User.find(self.id).realname.blank? ? User.find(self.id).login : User.find(self.id).realname ), + :description=>'', + :author_id=>self.id) + @blog.save + end + @blog + end + # 查询指派给我的缺陷记录 def count_new_issue_assign_to self.issue_assigns @@ -345,7 +360,7 @@ class User < Principal name end ## end - + #added by nie def count_new_journal_reply count = self.journal_reply.count @@ -1066,6 +1081,17 @@ class User < Principal end + private + def sync_gitlab_user + user = self + g = Gitlab.client + u = g.get("/users?search=#{user.mail}").first + unless u + u = g.create_user(user.mail, user.password, name: user.show_name, username: user.login, confirm: "true") + self.gid = u.id + puts "create user #{user.login}" + end + end end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index c2944fed5..e566a8f46 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -15,11 +15,11 @@ class CoursesService page_no = params[:page] || 1 if @school_id == "0" || @school_id.nil? @courses_all = Course.active.visible. - joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id") + joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id") else @courses_all = Course.active.visible. - joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). - where("#{Course.table_name}.school_id = ?", @school_id) + joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). + where("#{Course.table_name}.school_id = ?", @school_id) end @course_count = @courses_all.count @course_pages = Redmine::Pagination::Paginator.new @course_count, per_page_option,page_no @@ -299,23 +299,73 @@ class CoursesService #@state == 3 您已经加入了课程 #@state == 4 您加入的课程不存在 #@state == 5 您还未登录 + #@state == 6 申请成功,请等待审核完毕 + #@state == 7 您已经发送过申请了,请耐心等待 + #@state == 8 您已经是该课程的教师了 + #@state == 9 您已经是该课程的教辅了 + #@state == 10 您已经是该课程的管理员了 #@state 其他 未知错误,请稍后再试 def join_course params,current_user course = Course.find_by_id params[:object_id] + @state = 10 if course if course_endTime_timeout? course @state = 2 else - if current_user.member_of_course?(course) - @state = 3 + if current_user.member_of_course?(course) #如果已经是成员 + member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] + roleName = member.roles[0].name if member + if params[:course_password] == course.password + #如果加入角色为学生 并且当前是学生 + if params[:role] == "10" && roleName == "Student" + @state = 3 + #如果加入的角色为老师,并且当前已经是老师 + elsif params[:role] == "9" && roleName == "Teacher" + @state = 8 + #如果加入的角色教辅并且当前为教辅 + elsif params[:role] == "7" && roleName == "TeachingAsistant" + @state = 9 + elsif roleName == "Manager" + @state = 10 + #如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求 + elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" ) + #如果已经发送过消息了,那么就要给个提示 + if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0 + @state = 7 + else + Mailer.run.join_course_request(course, User.current, params[:role]) + CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) + @state = 6 + end + #如果加入角色是学生,但是是当前课程的教师或者教辅 + elsif params[:role] == "10" && roleName != "Student" + member.role_ids = [params[:role]] + member.save + StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + @state = 0 + end + else + @state = 1 + end else if params[:course_password] == course.password - members = [] - members << Member.new(:role_ids => [10], :user_id => current_user.id) - course.members << members - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) - @state = 0 + if params[:role] == "10" || params[:role] == nil + members = [] + members << Member.new(:role_ids => [10], :user_id => current_user.id) + course.members << members + StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + @state = 0 + else + #如果已经发送过消息了,那么就要给个提示 + if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0 + @state = 7 + else + Mailer.run.join_course_request(course, User.current, params[:role]) + CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0) + @state = 6 + end + end else @state = 1 end @@ -335,11 +385,11 @@ class CoursesService if course.is_public != 0 || current_user.member_of_course?(course) bids = course.homework_commons.page(params[:page] || 1).per(20).order('created_at DESC') bids = bids.like(params[:name]) if params[:name].present? - homeworks = [] - bids.each do |bid| - homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course)) - end - homeworks + homeworks = [] + bids.each do |bid| + homeworks << show_homework_info(course,bid,current_user,is_course_teacher(current_user,course)) + end + homeworks else raise '403' end @@ -410,10 +460,10 @@ class CoursesService #每个作业中学生最后提交的作业 homeworks = [] course.homework_commons.each do |bid| - homework_attach = bid.student_works.order('updated_at DESC').first - unless homework_attach.nil? - homeworks << homework_attach - end + homework_attach = bid.student_works.order('updated_at DESC').first + unless homework_attach.nil? + homeworks << homework_attach + end end unless homeworks.count == 0 homeworks.sort!{|order,newer| newer.updated_at <=> order.updated_at} @@ -432,21 +482,21 @@ class CoursesService result end - # 课程课件 - def course_attachments params - result = [] - course = Course.find(params[:course_id]) - attachments = course.attachments.order("created_on ") - if !params[:name].nil? && params[:name] != "" - attachments.each do |atta| - result << atta if atta.filename.include?(params[:name]) + # 课程课件 + def course_attachments params + result = [] + course = Course.find(params[:course_id]) + attachments = course.attachments.order("created_on ") + if !params[:name].nil? && params[:name] != "" + attachments.each do |atta| + result << atta if atta.filename.include?(params[:name]) - end - else - result = attachments - end - result - end + end + else + result = attachments + end + result + end # 课程学生列表 def course_members params @@ -487,20 +537,20 @@ class CoursesService end def del_assitant_teacher params - member = Member.where("user_id = ? and course_id = ?",params[:user_id],params[:course_id]) - member.each do |m| - m.destroy - end - user_admin = CourseInfos.where("user_id = ? and course_id = ?",params[:user_id], params[:course_id]) - if user_admin.size > 0 - user_admin.each do |user| - user.destroy - end - end - joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:course_id]) - joined.each do |join| - join.delete - end + member = Member.where("user_id = ? and course_id = ?",params[:user_id],params[:course_id]) + member.each do |m| + m.destroy + end + user_admin = CourseInfos.where("user_id = ? and course_id = ?",params[:user_id], params[:course_id]) + if user_admin.size > 0 + user_admin.each do |user| + user.destroy + end + end + joined = StudentsForCourse.where('student_id = ? and course_id = ?', params[:user_id],params[:course_id]) + joined.each do |join| + join.delete + end end def create_course_notice params ,current_user @@ -569,11 +619,11 @@ class CoursesService :open_anonymous_evaluation => open_anonymous_evaluation, #:homework_for_anonymous_comments => homework_for_anonymous_comments, :created_on => bid.created_at,:deadline => bid.end_time, - :homework_notsubmit_num => bid.course.members.count - bid.student_works.count, - :homework_submit_num => bid.student_works.count, - :homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid), - :student_evaluation_part => get_evaluation_part( bid ,3), - :ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?} + :homework_notsubmit_num => bid.course.members.count - bid.student_works.count, + :homework_submit_num => bid.student_works.count, + :homework_status_student => get_homework_status( bid),:homework_status_teacher => homework_status_desc( bid), + :student_evaluation_part => get_evaluation_part( bid ,3), + :ta_evaluation_part => get_evaluation_part( bid ,2),:homework_anony_type => bid.homework_type == 1 && !bid.homework_detail_manual.nil?} end @@ -585,9 +635,9 @@ class CoursesService homework_count = bid.homeworks.count #已提交的作业数量 student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count description = bid.description - #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 + #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 state = bid.comment_status - #end + #end open_anonymous_evaluation = bid.open_anonymous_evaluation {:course_name => course.name,:id => bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} @@ -684,12 +734,12 @@ class CoursesService latest_course_dynamics << {:time => latest_news.first.created_on } end # 课程讨论区 - latest_message = course.boards.first.topics.page(1).per(2) - unless latest_message.first.nil? - topic_count = course.boards.nil? ? 0 : course.boards.first.topics.count - topics = latest_message.all - latest_course_dynamics << {:time => latest_message.first.created_on} - end + latest_message = course.boards.first.topics.page(1).per(2) + unless latest_message.first.nil? + topic_count = course.boards.nil? ? 0 : course.boards.first.topics.count + topics = latest_message.all + latest_course_dynamics << {:time => latest_message.first.created_on} + end # 课程资源 # latest_attachment = course.attachments.order("created_on desc").page(1).per(2) # unless latest_attachment.first.nil? @@ -726,29 +776,29 @@ class CoursesService unless active_students.empty? latest_course_dynamics <<{:time=>"1970-01-01 0:0:0 +0800"} end - latest_course_dynamic = latest_course_dynamics.first - unless latest_course_dynamic.nil? - result << {:course_name => course.name, - :current_user_is_member => current_user.member_of_course?(course), - :current_user_is_teacher => is_course_teacher(current_user,course), - :course_id => course.id, - :course_img_url => url_to_avatar(course), - :course_time => course.time, - :course_term => course.term, - :news_count => notices_count, - :homework_count => homework_count, - :topic_count => topic_count, - :news => notices, - :homeworks => homeworkss, - :topics => topics, - :better_students => better_students, - :active_students => active_students, - :message => "", - :course_student_num=>course ? course.members.count : 0, - #:time_from_now=> distance_of_time_in_words(Time.now, latest_course_dynamic[:time].to_time) << "前", - :time_from_now=>time_from_now(latest_course_dynamic[:time].to_time), #.strftime('%Y-%m-%d %H:%M:%S').to_s, - :time=>latest_course_dynamic[:time].to_time} - end + latest_course_dynamic = latest_course_dynamics.first + unless latest_course_dynamic.nil? + result << {:course_name => course.name, + :current_user_is_member => current_user.member_of_course?(course), + :current_user_is_teacher => is_course_teacher(current_user,course), + :course_id => course.id, + :course_img_url => url_to_avatar(course), + :course_time => course.time, + :course_term => course.term, + :news_count => notices_count, + :homework_count => homework_count, + :topic_count => topic_count, + :news => notices, + :homeworks => homeworkss, + :topics => topics, + :better_students => better_students, + :active_students => active_students, + :message => "", + :course_student_num=>course ? course.members.count : 0, + #:time_from_now=> distance_of_time_in_words(Time.now, latest_course_dynamic[:time].to_time) << "前", + :time_from_now=>time_from_now(latest_course_dynamic[:time].to_time), #.strftime('%Y-%m-%d %H:%M:%S').to_s, + :time=>latest_course_dynamic[:time].to_time} + end end #返回数组集合 @@ -767,9 +817,9 @@ class CoursesService sql = "select users.*,ROUND(sum(student_works.final_score),2) score from student_works left outer join users on student_works.user_id = users.id" << " where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score desc limit #{page*10},10" sql_count = " select count(distinct(student_works.user_id) ) " << - " from student_works left outer join users on student_works.user_id = users.id " << - " where homework_common_id in " << - " ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) " + " from student_works left outer join users on student_works.user_id = users.id " << + " where homework_common_id in " << + " ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) " max_size = ActiveRecord::Base.connection().select_value(sql_count) user_list = User.find_by_sql(sql) else diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index ed43f455a..b316aa406 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -86,6 +86,9 @@ } function register(){ + if($("#loginUpButton").hasClass('loginUpDisableButton')){ + return; + } if($login_correct && $mail_correct && $passwd_correct && $passwd_comfirm_correct && $("#read_and_confirm").attr("checked") == 'checked'){ $("#main_reg_form").submit(); }else{ @@ -125,6 +128,11 @@ }); $mail.blur(function (event) { + if (/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ + $('#mail_req').html( '邮件格式不对').show(); + $mail_correct = false; + return ; + } if ($(this).is('#user_mail')) { $.get('<%=account_valid_ajax_path%>', { valid: "mail", @@ -182,6 +190,16 @@ $('#main_login_form').submit(); } } + + function changeRegisterBtn(checkbox){ + if(checkbox.checked == true){ + $("#loginUpButton").removeClass('loginUpDisableButton'); + $("#loginUpButton").addClass('loginUpButton'); + }else{ + $("#loginUpButton").removeClass('loginUpButton') + $("#loginUpButton").addClass('loginUpDisableButton'); + } + }
@@ -270,11 +288,11 @@
- +
我已阅读并接受Trustie服务协议条款
-
- 注册 +
+ 注册
<% end %> diff --git a/app/views/blog_comments/_attachments_links.html.erb b/app/views/blog_comments/_attachments_links.html.erb new file mode 100644 index 000000000..ca0f41d16 --- /dev/null +++ b/app/views/blog_comments/_attachments_links.html.erb @@ -0,0 +1,41 @@ +
+ <% for attachment in attachments %> + + + + <% if options[:length] %> + + <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true,:length => options[:length] -%> + (<%= number_to_human_size attachment.filesize , :precision => 0 %>) + <% if options[:deletable] %> + <%#= link_to image_tag('delete.png'), attachment_path(attachment), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + #:remote => true, + #:id => "attachments_" + attachment.id.to_s, + :title => l(:button_delete) %> + + <% end %> +
+ <% else %> + + <%= link_to_short_attachment attachment, :class => 'fl FilesName02', :download => true, :length => 45 -%> + (<%= number_to_human_size attachment.filesize , :precision => 0 %>) + <% if options[:deletable] %> + + <% end %> +
+ <% end %> + <% end %> + <% if defined?(thumbnails) && thumbnails %> + <% images = attachments.select(&:thumbnailable?) %> + <% if images.any? %> +
+ <% images.each do |attachment| %> +
<%= thumbnail_tag(attachment) %>
+ <% end %> +
+ <% end %> + <% end %> +
diff --git a/app/views/blog_comments/_blog_attachments.erb b/app/views/blog_comments/_blog_attachments.erb new file mode 100644 index 000000000..48fe91099 --- /dev/null +++ b/app/views/blog_comments/_blog_attachments.erb @@ -0,0 +1,78 @@ + +
+ +<% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %><%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %><%= l(:field_is_public) %>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
+ <% end %> + <% container.saved_attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> + <%= l(:field_is_public) %>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
+ <% end %> +<% end %> +
+
+ + <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> + + <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + 上传附件 + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => ie8? ? '' : 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js', :project => container), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> + + <%= l(:label_no_file_uploaded) %> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ diff --git a/app/views/blog_comments/_edit.html.erb b/app/views/blog_comments/_edit.html.erb new file mode 100644 index 000000000..d56557ce7 --- /dev/null +++ b/app/views/blog_comments/_edit.html.erb @@ -0,0 +1,53 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +
+
+
+
+ +

+
+
+ <%if User.current.id == user.id%> +
+ <%= f.check_box :sticky%> + <%= label_tag 'message_sticky', l(:label_board_sticky) %> + <%= f.check_box :locked%> + <%= label_tag 'message_locked', l(:label_board_locked) %> +
+
+ <% end %> +
+
+ <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + <%= f.kindeditor :content,:editor_id => 'message_content_editor', + :owner_id => article.nil? ? 0: article.id, + :owner_type => OwnerTypeHelper::BLOGCOMMENT, + :width => '100%', + :height => 300, + :minHeight=>300, + :class => 'talk_text fl', + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> +
+

+
+
+
+
+ <%= render :partial => 'blog_comments/blog_attachments', :locals => {:container => article} %> +
+
+
+
+ 确定 + + 取消 +
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/blog_comments/_new.html.erb b/app/views/blog_comments/_new.html.erb new file mode 100644 index 000000000..2a2281a40 --- /dev/null +++ b/app/views/blog_comments/_new.html.erb @@ -0,0 +1,62 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +
+
+
+
+ +

+
+ +
+ <%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %> + +
+
\ No newline at end of file diff --git a/app/views/blog_comments/_reply_form.html.erb b/app/views/blog_comments/_reply_form.html.erb new file mode 100644 index 000000000..cc4c0e952 --- /dev/null +++ b/app/views/blog_comments/_reply_form.html.erb @@ -0,0 +1,35 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +
  • + +
    <%= f.text_field :title, { size: 60, id: "message_subject",:class=>"talk_input w585 fl" }.merge({ hidden: "hidden"}) %>
    + +
    +
  • +
  • +
    +
  • +
  • +
    + + <%= text_area :quote,:quote,:style => 'display:none' %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + + + <%= f.kindeditor :content, :editor_id => 'message_content_editor', + :width => '99%', + :height => 100, + :minHeight=>100, + :input_html => { :id => 'message_content', + :class => 'talk_text fl', + :maxlength => 5000 }%> +
    +

    +
  • +
    +
  • +
    +
  • diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb new file mode 100644 index 000000000..61669058b --- /dev/null +++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb @@ -0,0 +1,34 @@ + + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    +
    +
    + <%= form_for @blog_comment, :as => :reply, :url => {:controller => 'blog_comments',:action => 'reply', :id => @blogComment.id}, :html => {:multipart => true, :id => 'new_form'} do |f| %> + + <% if course_id%> + + <% end %> + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/blog_comments/edit.html.erb b/app/views/blog_comments/edit.html.erb new file mode 100644 index 000000000..a878063db --- /dev/null +++ b/app/views/blog_comments/edit.html.erb @@ -0,0 +1,6 @@ +<% if User.current.logged? && User.current.id == @user.id %> + <%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id},:method=>'PUT', + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb new file mode 100644 index 000000000..088b2cf67 --- /dev/null +++ b/app/views/blog_comments/quote.js.erb @@ -0,0 +1,10 @@ +if($("#reply_message_<%= @blogComment.id%>").length > 0) { + $("#reply_message_<%= @blogComment.id%>").replaceWith("<%= escape_javascript(render :partial => 'blog_comments/simple_ke_reply_form', :locals => {:reply => @blogComment,:temp =>@temp,:subject =>@subject,:course_id=>@course_id}) %>"); + $(function(){ + $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); + $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); + init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%"); + }); +}else if($("#reply_to_message_<%= @blogComment.id%>").length >0) { + $("#reply_to_message_<%= @blogComment.id%>").replaceWith("

    "); +} \ No newline at end of file diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb new file mode 100644 index 000000000..1cb64b2b5 --- /dev/null +++ b/app/views/blog_comments/reply.js.erb @@ -0,0 +1,7 @@ +<% if @in_user_center%> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else%> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb new file mode 100644 index 000000000..54c9541f2 --- /dev/null +++ b/app/views/blog_comments/show.html.erb @@ -0,0 +1,175 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + + + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %> +
    +
    + <% if @article.author.id == User.current.id%> + + <%end%> + +
    + +
    + <% if @article.try(:author).try(:realname) == ' ' %> + <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% else %> + <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% end %> +
    +
    <%= format_time( @article.created_on)%>
    +
    +
    + <%= @article.content.html_safe%> +
    +
    +
    + <%#= link_to_attachments_course @topic, :author => false %> + <% if @article.attachments.any?%> + <% options = {:author => true, :deletable => false} %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %> + <% end %> +
    +
    +
    +
    +
    + <% count=0 %> + <% if @article.parent %> + <% count=@article.parent.children.count%> + <% else %> + <% count=@article.children.count%> + <% end %> +
    + <% unless count == 0 %> +
    +
    回复(<%=count %>)
    +
    + +
    +
    + <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> + +
    +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> +
    +
    + <%= reply.content.html_safe%> +
    +
    + <%= format_time(reply.created_on) %> + +
    +

    +
    +
    +
    + <% end %> +
    + + <% end %> +
    + <% if !@article.locked? && User.current.logged?%> +
    + +
    +
    + <%= form_for :blog_comment, :url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= render :partial => 'blog_comments/reply_form', :locals => {:f => f,:user=>@user,:article=>@article} %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-right: 5px;" %> + <% end %> +
    +
    +
    + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb new file mode 100644 index 000000000..33a3201c0 --- /dev/null +++ b/app/views/blogs/_article.html.erb @@ -0,0 +1,172 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
    +
    + <% if activity.author.id == User.current.id%> + + <%end%> +
    + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%> +
    +
    + + <% if activity.sticky == 1%> + 置顶 + <% end%> + <% if activity.locked%> +        + <% end%> +
    +
    + 发帖时间:<%= format_time(activity.created_on) %> +
    + +
    + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
    +
    +
    + <% if activity.attachments.any?%> + <% options = {:author => true, :deletable => false } %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => activity.attachments, :options => options, :is_float => true} %> + <% end %> +
    + +
    +
    +
    + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
    +
    +
    +
    回复( + <%= count %> + )
    +
    <%#=format_date(activity.updated_on)%>
    + <%if count > 3 %> + + <% end %> +
    + + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.children.reorder("created_on desc").each do |reply|%> + + <% replies_all_i=replies_all_i+1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
      +
      +
      + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
      +
      + <%= reply.content.html_safe %> +
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + + <% if !activity.locked? %> +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%> + + + + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    + <% end %> +
    +
    diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb new file mode 100644 index 000000000..e397da2cc --- /dev/null +++ b/app/views/blogs/_article_list.html.erb @@ -0,0 +1,101 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %> + + + +
    +
    +
    + <%= @user.name%>的博客 +
    +
    + <% if User.current.logged? && User.current.id == @user.id %> + <%= labelled_form_for @article, :url =>{:controller=>'blog_comments',:action => 'create',:user_id=>user.id , :blog_id => blog.id}, + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/new', :locals => {:f => f, :article => @article, :edit_mode => false, :user => @user} %> + <% end %> + <% end %> + + <% if topics%> + <% topics.each do |topic| %> + + <% if topic %> + <%= render :partial => 'blogs/article', :locals => {:activity => topic, :user_activity_id => topic.id} %> + <% end %> + <% end %> + + <%# if topics.count == 10 %> + + <%# end %> + <% end%> +
    + + diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb new file mode 100644 index 000000000..0e69d1654 --- /dev/null +++ b/app/views/blogs/index.html.erb @@ -0,0 +1,187 @@ + + +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> + + +<%= render :partial => 'blogs/article_list', :locals => {:blog=>@user.blog,:topics => @user.blog.articles.reorder("#{BlogComment.table_name}.sticky desc,#{BlogComment.table_name}.created_on desc"), :page => 0, :user => @user} %> + + + diff --git a/app/views/blogs/show.html.erb b/app/views/blogs/show.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/boards/_course_message_edit.html.erb b/app/views/boards/_course_message_edit.html.erb index 16807afb0..caa389945 100644 --- a/app/views/boards/_course_message_edit.html.erb +++ b/app/views/boards/_course_message_edit.html.erb @@ -12,5 +12,5 @@
    <%= render :partial => 'boards/course_new', - :locals => {:f => f, :edit_mode => edit_mode, :topic => topic} %> + :locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :course => course} %> \ No newline at end of file diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index 7892ed773..ea904a63f 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,3 +1,3 @@ -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>"); +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%"); diff --git a/app/views/common/_file.html.erb b/app/views/common/_file.html.erb index d4c0875c2..97443beea 100644 --- a/app/views/common/_file.html.erb +++ b/app/views/common/_file.html.erb @@ -8,7 +8,7 @@ <%= line_num %> -
    <%= line.html_safe %>
    +
    <%= line.html_safe %>
    <% line_num += 1 %> diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index aa99236df..a54e0667e 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -68,20 +68,31 @@ } } - function expand_reply_input(id) { - $(id).toggle(); - } - $(function () { init_activity_KindEditor_data(<%= activity.id%>, null, "87%"); showNormalImage('activity_description_<%= activity.id %>'); + if($("#intro_content_<%= activity.id %>").height() > 360) { + $("#intro_content_show_<%= activity.id %>").show(); + } + $("#intro_content_show_<%= activity.id %>").click(function(){ + $("#activity_description_<%= activity.id %>").toggleClass("maxh360"); + $("#activity_description_<%= activity.id%>").toggleClass("lh18"); + $("#intro_content_show_<%= activity.id %>").hide(); + $("#intro_content_hide_<%= activity.id %>").show(); + }); + $("#intro_content_hide_<%= activity.id %>").click(function(){ + $("#activity_description_<%= activity.id %>").toggleClass("maxh360"); + $("#activity_description_<%= activity.id%>").toggleClass("lh18"); + $("#intro_content_hide_<%= activity.id %>").hide(); + $("#intro_content_show_<%= activity.id %>").show(); + }); }); <% if activity && activity.course_act%> <% act = activity.course_act %> <% case activity.course_act_type.to_s %> <% when 'HomeworkCommon' %> - <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id} %> + <%= render :partial => 'users/course_homework', :locals => {:activity => act, :user_activity_id => activity.id, :course_activity => 1} %> <% when 'News' %> <%= render :partial => 'users/course_news', :locals => {:activity => act, :user_activity_id => activity.id} %> <% when 'Message' %> diff --git a/app/views/courses/_course_outlines_list.html.erb b/app/views/courses/_course_outlines_list.html.erb new file mode 100644 index 000000000..42ce30113 --- /dev/null +++ b/app/views/courses/_course_outlines_list.html.erb @@ -0,0 +1,32 @@ + +
    请选择课程大纲
    + +
    +
    + + + +
    +
    + + <%= form_tag(url_for(:controller=>'courses',:action=>'set_course_outline',:id=>course.id),:method=>'post',:remote=>'true') do %> + +
    + <% unless articles.blank? %> + <% articles.each do |article|%> + +
    发布时间:<%= format_date(article.created_at)%>
    + <% end %> + <% end %> +
    +
    +
    确定
    +
    取消
    +
    +
    +<% end %> diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 8e1e1c421..873144afe 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -4,33 +4,33 @@ 快速进入课程通道 \ No newline at end of file diff --git a/app/views/courses/course_outline.js.erb b/app/views/courses/course_outline.js.erb new file mode 100644 index 000000000..490361a24 --- /dev/null +++ b/app/views/courses/course_outline.js.erb @@ -0,0 +1,9 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'course_outlines_list',:locals => {:articles=>@blog_articles,:course=>@course,:show_page=>@is_in_show_outline_page}) %>'); +showModal('ajax-modal', '300px'); +//$('#ajax-modal').css('height','250px'); +$('#ajax-modal').css('padding-top','0px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(' '); +$('#ajax-modal').parent().css("top","30%").css("left","50%"); +$('#ajax-modal').parent().addClass("courseOutlinePopup"); +$('#ajax-modal').css("padding-left","16px")//.css("padding-bottom","16px"); diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb new file mode 100644 index 000000000..8102098d5 --- /dev/null +++ b/app/views/courses/join.js.erb @@ -0,0 +1,42 @@ +<% if @object_id && @state != 6 && @state !=4 %> +$("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@course, @user)) %>"); +<% end %> +<% if @state %> +<% if @state == 0 %> +alert("加入成功"); +hideModal(); +$("#try_join_course_link").replaceWith(" 'index',:course=>@course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品"); +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" +<% elsif @state == 1 %> +alert("密码错误"); +<% elsif @state == 2 %> +alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)"); +<% elsif @state == 3 %> +alert("您已经加入了课程"); +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" +<% elsif @state == 4 %> +alert("您加入的课程不存在"); +<% elsif @state == 5 %> +alert("您还未登录"); +<% elsif @state == 6 %> +alert("申请成功,请等待审核"); +hidden_join_course_form(); +<% elsif @state == 7%> + alert("您已经发送过申请了,请耐心等待"); +hidden_join_course_form(); +<% elsif @state == 8%> +alert("您已经是该课程的教师了"); +hidden_join_course_form(); +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" +<% elsif @state == 9%> +alert("您已经是该课程的教辅了"); +hidden_join_course_form(); +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" +<% elsif @state == 10%> +alert("您已经是该课程的管理员了"); +hidden_join_course_form(); +window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>" +<% else %> +alert("未知错误,请稍后再试"); +<% end %> +<% end %> diff --git a/app/views/courses/join_private_courses.js.erb b/app/views/courses/join_private_courses.js.erb index 8a1680030..0c44770bd 100644 --- a/app/views/courses/join_private_courses.js.erb +++ b/app/views/courses/join_private_courses.js.erb @@ -1,3 +1,4 @@ +$('#topnav_course_menu').hide(); $('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>'); showModal('ajax-modal', '540px'); $('#ajax-modal').css('height','390px'); diff --git a/app/views/courses/set_course_outline.js.erb b/app/views/courses/set_course_outline.js.erb new file mode 100644 index 000000000..e920005cd --- /dev/null +++ b/app/views/courses/set_course_outline.js.erb @@ -0,0 +1,8 @@ +hideModal(); +<%if @course.tea_id == User.current.id && @course.outline == 0 %> +<% else %> + $("#course_outline_bar").html(' ') +<%end %> +<%#if @is_in_show_outline_page && @is_in_show_outline_page == 'Y'%> + window.location.href='<%=syllabus_course_path(@course) %>'; +<%# end %> diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index a462db79d..a90be14ea 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -36,8 +36,8 @@
  • - <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %> - <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %> + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"time_selected"} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term_selected"} %>
  • @@ -92,4 +92,17 @@ -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/courses/syllabus.html.erb b/app/views/courses/syllabus.html.erb new file mode 100644 index 000000000..bb3421cba --- /dev/null +++ b/app/views/courses/syllabus.html.erb @@ -0,0 +1,212 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + + + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %> +
    +
    + <% if User.current && @article.author.id == User.current.id%> +
    +
      +
    • +
        +
      • + 重设大纲 +
      • +
      • + <%= link_to( + '取消大纲', + {:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id}, + :method => :delete, + :data => {:confirm => '您确定要取消么?'}, + :class => 'postOptionLink' + ) if User.current && User.current.id == @article.author.id %> +
      • +
      +
    • +
    +
    + + + + + + + + + <%end%> + +
    + +
    + <% if @article.try(:author).try(:realname) == ' ' %> + <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% else %> + <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% end %> +
    +
    <%= format_time( @article.created_on)%>
    +
    +
    + <%= @article.content.html_safe%> +
    +
    +
    + <%#= link_to_attachments_course @topic, :author => false %> + <% if @article.attachments.any?%> + <% options = {:author => true, :deletable => false} %> + <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %> + <% end %> +
    +
    +
    +
    +
    + <% count=0 %> + <% if @article.parent %> + <% count=@article.parent.children.count%> + <% else %> + <% count=@article.children.count%> + <% end %> +
    + <% unless count == 0 %> +
    +
    回复(<%=count %>)
    +
    + +
    +
    + <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> + +
    +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> +
    +
    + <%= reply.content.html_safe%> +
    +
    + <%= format_time(reply.created_on) %> + +
    +

    +
    +
    +
    + <% end %> +
    + + <% end %> +
    + <% if !@article.locked? && User.current.logged?%> + + + + + + + + + + + + + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@article.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for 'blog_comment',:url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id},:method => "post",:html => {:multipart => true, :id => 'message_form'} do |f|%> + + + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index 50d14b7ee..01e5dca5f 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -1,4 +1,54 @@ -
    + +<% checkBox = (@course.present? && @course.is_public?) ? 'public' : 'private'%> + +<% if @course %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");', + :style => ie8? ? '': 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> +<% else %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => ie8? ? '': 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> +<% end %> + + + + + <%= l(:label_no_file_uploaded)%> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) +
    + +
    <% if defined?(container) && container && container.saved_attachments %> <% container.attachments.each_with_index do |attachment, i| %> @@ -20,30 +70,5 @@ <% end %> <% end %> -
    - - -<%= file_field_tag 'attachments[dummy][file]', - :id => '_file', - :class => ie8? ? '':'file_selector', - :multiple => true, - :onchange => 'addInputFiles(this);', - :style => ie8? ? '': 'display:none', - :data => { - :max_file_size => Setting.attachment_max_size.to_i.kilobytes, - :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), - :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, - :upload_path => uploads_path(:format => 'js'), - :description_placeholder => l(:label_optional_description), - :field_is_public => l(:field_is_public), - :are_you_sure => l(:text_are_you_sure), - :file_count => l(:label_file_count), - :delete_all_files => l(:text_are_you_sure_all) - } %> - - - - <%= l(:label_no_file_uploaded)%> - - (<%= l(:label_max_size) %>: - <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) +
    +
    \ No newline at end of file diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 8283e15b7..4176b72d0 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -26,6 +26,9 @@ case 4: $('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show',:locals => {:course => @course,:course_attachment_type => 4}) %>'); break; + case 6: + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show',:locals => {:course => @course,:course_attachment_type => 6}) %>'); + break; default: $('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show',:locals => {:course => @course,:course_attachment_type => 5}) %>'); } @@ -77,6 +80,7 @@ 软件 |  媒体 |  代码 |  + 论文 |  其他

    <% end %> diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 3c6d545db..4cc249c20 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -39,7 +39,7 @@ <% else %> - 私有 + 私有 <% end %> diff --git a/app/views/files/_new_style_attachment_list.html.erb b/app/views/files/_new_style_attachment_list.html.erb new file mode 100644 index 000000000..af679c4d3 --- /dev/null +++ b/app/views/files/_new_style_attachment_list.html.erb @@ -0,0 +1,33 @@ + +<% checkBox = (@course.present? && @course.is_public?) ? 'public' : 'private'%> + + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file#{container.id}", + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => "addInputFiles_board(this, '#{container.id}');", + :style => ie8? ? '': 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> + + + + + <%= l(:label_no_file_uploaded)%> + +(<%= l(:label_max_size) %>: +<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) +
    +
    + + +
    \ No newline at end of file diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb new file mode 100644 index 000000000..9c7021383 --- /dev/null +++ b/app/views/files/_upload_course_files.erb @@ -0,0 +1,42 @@ + +
    +
    +

    <%= l(:label_upload_files)%>

    +
    + <%= error_messages_for 'attachment' %> + + + <%= form_tag(course_files_path(course), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + + +
    + 课件 |  + 软件 |  + 媒体 |  + 代码 |  + 论文 |  + 其他 +
    +
    +
    + <%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %> +
    +
    + <%= l(:button_cancel)%> + <%= l(:button_confirm)%> + + <% end %> +
    + +
    + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
    + + \ No newline at end of file diff --git a/app/views/files/_upload_show.html.erb b/app/views/files/_upload_show.html.erb index e11a4bf38..21cd94d8d 100644 --- a/app/views/files/_upload_show.html.erb +++ b/app/views/files/_upload_show.html.erb @@ -1,7 +1,7 @@ -
    +
    -

    <%= l(:label_upload_files)%>

    +

    <%= l(:label_upload_files)%>

    <%= error_messages_for 'attachment' %> diff --git a/app/views/files/_upload_show_project.html.erb b/app/views/files/_upload_show_project.html.erb index 25a03b347..53c57b3c6 100644 --- a/app/views/files/_upload_show_project.html.erb +++ b/app/views/files/_upload_show_project.html.erb @@ -1,16 +1,17 @@ -
    +
    -

    <%= l(:label_upload_files)%>

    +

    <%= l(:label_upload_files)%>

    <%= error_messages_for 'attachment' %> <%= form_tag(project_files_path(project), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> - <%= render :partial => 'attachement_list',:locals => {:project => project} %> + + <%= render :partial => 'files/attachement_list',:locals => {:project => project} %>
    - <%= l(:button_cancel)%> + <%= l(:button_cancel)%> <%= l(:button_confirm)%> <% end %>
    diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 81810344e..9de7aa042 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -22,27 +22,36 @@ $("#attachments_fields").children().remove(); $("#upload_file_count").text("未上传文件"); $('#upload_file_div').slideToggle('slow'); <% if @project %> - closeModal(); - $("#resource_list").html('<%= j(render partial: "project_file_new" ,locals: {project: @project}) %>'); - $("#project_files_count_info").html("<%= @all_attachments.count%>"); - $("#project_files_count_nav").html("(<%= @all_attachments.count%>)") -// 添加文件上传成功提示 - <% unless params[:attachments].nil? %> - var div = $('
    文件上传成功!
    '); - $("#course_list").prepend(div); - setTimeout( function(){div.remove();},3000) + hideModal(); + <%if @in_project_toolbar%> + window.location.href = '<%= project_files_path(@project)%>' + <%else%> + + $("#resource_list").html('<%= j(render partial: "project_file_new" ,locals: {project: @project}) %>'); + $("#project_files_count_info").html("<%= @all_attachments.count%>"); + $("#project_files_count_nav").html("(<%= @all_attachments.count%>)") + // 添加文件上传成功提示 + <% unless params[:attachments].nil? %> + var div = $('
    文件上传成功!
    '); + $("#course_list").prepend(div); + setTimeout( function(){div.remove();},3000) + <% end %> <% end %> <%elsif @course%> - closeModal(); - $("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); - $("#courses_files_count_info").html("<%= @all_attachments.count%>"); - $("#courses_files_count_nav").html("(<%= @all_attachments.count%>)") - // 添加文件上传成功提示, - <% unless params[:attachments].nil? %> - var div = $('
    文件上传成功!
    '); - $("#course_list").prepend(div); - setTimeout( function(){div.remove();},3000) - <% end %> + hideModal(); + <%if @in_course_toolbar %> + window.location.href='<%= course_files_path(@course)%>' + <%else%> + $("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); + $("#courses_files_count_info").html("<%= @all_attachments.count%>"); + $("#courses_files_count_nav").html("(<%= @all_attachments.count%>)") + // 添加文件上传成功提示, + <% unless params[:attachments].nil? %> + var div = $('
    文件上传成功!
    '); + $("#course_list").prepend(div); + setTimeout( function(){div.remove();},3000) + <% end %> + <%end%> <% end %> <% end %> $(document).ready(img_thumbnails); diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 782efbb22..3dad88868 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -247,7 +247,7 @@ tagId = id; taggableType = type; width = parseInt(domEle.css('width').replace('px', '')) >= 100 ? parseInt(domEle.css('width').replace('px', '')) : 100 - domEle.html(''); + domEle.html(''); domEle.parent().css("border", "1px solid #ffffff"); $("#renameTagName").focus(); } @@ -295,8 +295,8 @@ // }else{ //否则就要更新tag名称了 //// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){ 去掉询问 // $.post( -// '<%= update_tag_name_path %>', -// {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%= @course.id%>} +// '<%#= update_tag_name_path %>', +// {"taggableId": tagId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim(),"courseId":<%#= @course.id%>} // ) //// }else{ //// ele.parent().css("border",""); diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 8314c3902..5bbc52db2 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,96 +1,5 @@ <%= javascript_include_tag 'new_user','/assets/kindeditor/pasteimg','/assets/kindeditor/kindeditor' %> -
    -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/homework_common/_alert_anonyoms.html.erb b/app/views/homework_common/_alert_anonyoms.html.erb index 73f240b02..3b1f6f692 100644 --- a/app/views/homework_common/_alert_anonyoms.html.erb +++ b/app/views/homework_common/_alert_anonyoms.html.erb @@ -34,7 +34,7 @@

    <% end %>
    - + 确  定 diff --git a/app/views/homework_common/_set_evalutation_att.html.erb b/app/views/homework_common/_set_evalutation_att.html.erb index 01d9351ee..d51713e9a 100644 --- a/app/views/homework_common/_set_evalutation_att.html.erb +++ b/app/views/homework_common/_set_evalutation_att.html.erb @@ -7,7 +7,7 @@ 开启匿评
    - <%= calendar_for('evaluation_start_time')%> + <%#= calendar_for('evaluation_start_time')%>

    @@ -18,7 +18,7 @@ 关闭匿评
    - <%= calendar_for('evaluation_end_time')%> + <%#= calendar_for('evaluation_end_time')%>

    diff --git a/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb b/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb new file mode 100644 index 000000000..5177f4d92 --- /dev/null +++ b/app/views/homework_common/alert_forbidden_anonymous_comment.js.erb @@ -0,0 +1,6 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/alert_forbidden_anonymous', :locals => {:user_activity_id => @user_activity_id,:is_in_course => @is_in_course,:course_activity => @course_activity}) %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + "
    "); +$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed"); \ No newline at end of file diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index 5fc11728b..ac772171d 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -1,12 +1,24 @@
    编辑作业
    @@ -17,6 +29,7 @@
    <%= form_for @homework do |f| %> +
    <%= render :partial => 'users/user_homework_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %>
    diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 3d8752dd8..3b3877228 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -1,6 +1,7 @@ \ No newline at end of file diff --git a/app/views/layouts/base_forums.html.erb b/app/views/layouts/base_forums.html.erb index d32fbf4ed..e03ac2fc5 100644 --- a/app/views/layouts/base_forums.html.erb +++ b/app/views/layouts/base_forums.html.erb @@ -61,14 +61,14 @@ function addTag(){ if(<%=@forum.creator.id == User.current.id%>) { if ($("input[name='addTag']").val().trim() != "" ) { - if($("input[name='addTag']").val().trim().length <= 14) { + if($("input[name='addTag']").val().trim().length <= 120) { $.get( '<%= add_forum_tag_forum_path(@forum)%>' + "?tag_str=" + $("input[name='addTag']").val(), {} ); $("input[name='addTag']").val(''); }else{ - alert("标签名字长度不能超过14个字符"); + alert("标签名字长度不能超过120个字符"); } } } diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 02085b95a..d2186118d 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -12,8 +12,8 @@ <%= favicon %> <%= javascript_heads %> <%= heads_for_theme %> - <%= stylesheet_link_tag 'public', 'pleft', 'project','prettify','jquery/jquery-ui-1.9.2','header' %> - <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move' %> + <%= stylesheet_link_tag 'public', 'pleft', 'project','prettify','jquery/jquery-ui-1.9.2','header','repository' %> + <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','attachments' %> <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> @@ -76,7 +76,7 @@
    - <%= l(:label_member) %>(<%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue' %>) + <%= l(:label_member) %>(<%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue', :id => 'project_members_number' %>) <%= l(:label_user_watcher) %>(<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'info_foot_num c_blue' %>) <% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %> @@ -223,6 +223,16 @@ } ); } + + function project_files_upload() + { + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/upload_project_files_on_navbar',:locals => {:container => @project}) %>'); + showModal('ajax-modal', '513px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top","40%").css("left","36%"); + $('#ajax-modal').parent().addClass("popbox_polls"); + }
    123
    diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index f3adb0155..1eddeb517 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -46,7 +46,7 @@
    <% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %> @@ -71,27 +71,38 @@
    +
    +
    + <%= link_to(@user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count, + {:controller => 'blogs', :action => 'index', :user_id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %> +
    +
    + + <%= link_to('博客', + {:controller => 'blogs', :action => 'index', :user_id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %> +
    +
    +
    <%= link_to User.watched_by(@user.id).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"homepageImageNumber" %>
    -
    关注
    +
    + <%= link_to '关注', {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"homepageImageNumber" %> +
    <%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber", :id => "user_fans_number"%>
    -
    粉丝
    -
    -
    -
    -
    - <%= link_to(format("%.2f" ,get_option_number(@user,1).total_score ).to_i, - {:controller => 'users', :action => 'show_new_score', :remote => true, :id => @user.id }, :class => 'homepageImageNumber',:id => 'user_score') %> +
    + + <%= link_to '粉丝', {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber", :id => "user_fans_number"%>
    -
    积分
    + +
    @@ -103,7 +114,21 @@ 课程 <% if is_current_user%> <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> - <%=link_to "", new_course_path(:host=> Setting.host_course), :class => "homepageMenuSetting fr", :title => "新建课程"%> +
    +
      +
    • +
        +
      • + <%= link_to "新建课程", new_course_path(:host=> Setting.host_course), :class => "menuGrey"%> +
      • + +
      • + <%= link_to "加入课程",join_private_courses_courses_path,:remote => true,:class => "menuGrey",:method => "post"%> +
      • +
      +
    • +
    +
    <% else%> <%=link_to "", join_private_courses_courses_path, :class => "homepageMenuSetting fr",:remote => true, :title => "加入课程"%> <% end%> @@ -201,5 +226,13 @@
    + diff --git a/app/views/mailer/join_course_request.html.erb b/app/views/mailer/join_course_request.html.erb new file mode 100644 index 000000000..61b7eaa6f --- /dev/null +++ b/app/views/mailer/join_course_request.html.erb @@ -0,0 +1,14 @@ +
    +
      + +
    • <%= l(:mail_issue_content)%> + +

      <%= @user.show_name %> 请求成为课程:<%=link_to @course.name, course_url(@course) %>的<%= @role.eql?('9') ? '老师': '教辅' %>

      +

      <%=link_to user_message_url(@receive),user_message_url(@receive)%>

      +
      +
    • + +
    + +
    +
    diff --git a/app/views/mailer/join_course_request.text.erb b/app/views/mailer/join_course_request.text.erb new file mode 100644 index 000000000..62e2315c5 --- /dev/null +++ b/app/views/mailer/join_course_request.text.erb @@ -0,0 +1,4 @@ +<%= @user.show_name %>申请成为课程<%= @course.name %>的<%= @role.eql?('9') ? '老师': '教辅' %> +<%=link_to user_message_url(@receive),user_message_url(@receive)%> + + diff --git a/app/views/members/create.js.erb b/app/views/members/create.js.erb index 976f5c724..8a6500572 100644 --- a/app/views/members/create.js.erb +++ b/app/views/members/create.js.erb @@ -4,6 +4,7 @@ <% else%> $('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>'); hideOnLoad(); + $("#project_members_number").html("<%= @project.members.count %>"); alert("<%= @succes_message%>"); <% end%> <%elsif @course%> @@ -11,6 +12,8 @@ alert("<%= @create_member_error_messages%>"); <% else%> $('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); + $("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>"); + $("#student_number").html("<%= studentCount(@course) %>"); alert("添加成功"); <% end%> hideOnLoad(); diff --git a/app/views/members/destroy.js.erb b/app/views/members/destroy.js.erb index b6f206e05..b331f15a4 100644 --- a/app/views/members/destroy.js.erb +++ b/app/views/members/destroy.js.erb @@ -1,7 +1,10 @@ <%if @project%> $('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>'); + $("#project_members_number").html("<%= @project.members.count %>"); // $('#tab-content-members').html('<%#= escape_javascript(render :partial => 'projects/settings/members') %>'); <%elsif @course%> $('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); + $("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>") + $("#student_number").html("<%= studentCount(@course) %>"); <%end%> hideOnLoad(); diff --git a/app/views/members/update.js.erb b/app/views/members/update.js.erb index c5ef983e7..7c27e39fc 100644 --- a/app/views/members/update.js.erb +++ b/app/views/members/update.js.erb @@ -2,6 +2,8 @@ $('#pro_st_tbc_03').html('<%= escape_javascript(render :partial => 'projects/settings/new_members') %>'); <%elsif @course%> $('#course_members_setting').html('<%= escape_javascript(render :partial => 'courses/course_members') %>'); +$("#teacher_number").html("<%= searchTeacherAndAssistant(@course).count %>") +$("#student_number").html("<%= studentCount(@course) %>"); <%end%> hideOnLoad(); diff --git a/app/views/memos/edit.html.erb b/app/views/memos/edit.html.erb index 7ab460555..b2b7d73f0 100644 --- a/app/views/memos/edit.html.erb +++ b/app/views/memos/edit.html.erb @@ -2,22 +2,23 @@ \ No newline at end of file diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index 0859e5e19..43535153d 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -7,99 +7,90 @@ <%= str = error_messages_for 'repository' %> <% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %> <% ip = RepositoriesHelper::REPO_IP_ADDRESS %> +<%# 提示 %> +<% if @project.repositories.count>1 %> +
    + 项目管理员您好!近日平台完成了版本库升级,以后每个项目将唯一的对应一个版本库。请您按照以下步骤完成项目版本库的更新: +

    1. 点击下面的"创建版本库按钮",为本项目创建一个新的版本库;

    +

    2. 从本项目的历史版本库中选择一个您将使用的版本库,将其完整的克隆(clone)到本地(需要提供您之前设置的版本库口令),然后推送(push)到新建的版本库(注意不能仅推送代码,否则之前各开发者的提交记录将丢失)。

    +

    3. 本项目的历史版本库将在您新建版本库的一周内自动隐藏,如果您以后需要这些版本库,请与网站联系,我们将为您提供这些版本库的所有数据。

    +
    +<% end %> +<%# 新建版本库 %> +<% if @project.repositories.count == 0 || rep_is_gitlab?(@project) %> +
    + + + <% course_tag = @project.project_type %> + <% if User.current.allowed_to?(:manage_repository, @project) %> + + <%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %>

    + <% end %> +
    +
    + + <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %> +
    +
      +
    • + + <%= select_tag('repository_scm', + options_for_select(["Git"],@repository.class.name.demodulize), + :data => {:remote => true, :method => 'get'}) %> + <% if @repository && ! @repository.class.scm_available %> + <%= l(:text_scm_command_not_available) %> + <% end %> +
    • +
    • + + + *<%=l(:label_repository_name)%>: + <%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %> + <% unless @repository.identifier_frozen? %> + <%=l(:text_length_between,:min=>1,:max=>254)< + <% end %> +
    • +
      +
    + <%=l(:lable_project_rep_create) %> + <%=l(:button_cancel)%> +
    + <% end %> +
    +<% end %> + + <% if @project.repositories.any? %> + <%= render :partial => 'projects/settings/rep_gitlab', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %> + <%#= render :partial => 'projects/settings/rep_forge', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %> +
    历史版本库
    - - - - - - - - - <% @project.repositories.sort.each do |repository| %> - - - - + <% rep_forge(@project).sort.each do |repository| %> + + + <%if repository.scm_name=="Git"%> - + <% rep_url = "http://" + repository.login.to_s + '_'+ repository.identifier.to_s + "@" + ip.to_s + h( repository.url.slice(project_path_cut, repository.url.length)) %> + <%else %> - + <% end %> - - <% end %>
    <%= l(:field_identifier) %> <%= l(:field_repository_is_default) %><%= l(:label_scm) %> <%= l(:label_repository_path) %>
    - <%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %> <%= checked_image repository.is_default? %><%=h repository.scm_name %>
    + <%= repository.identifier %><%=h repository.scm_name %> <%=truncate( 'http://' << repository.login.to_s << '_'<< repository.identifier.to_s << '@'<< ip.to_s << h( repository.url.slice(project_path_cut, repository.url.length)),:length=>20)%> + + + + <%#= rep_url %> + + <%=h truncate(repository.url,:length=>10) %><%=h truncate(repository.url,:length=>10) %> - <% if repository.scm_name=="Git"%> - <%if User.current.allowed_to?(:manage_repository, @project) %> - <%= link_to(l(:label_user_plural), committers_repository_path(repository)) %> - <% end %> - <% end %> - - <% if repository.login.to_s==User.current.login.to_s %> - <%= delete_new_link repository_path(repository) %> - <% end %>
    <% else %> -

    <%= l(:label_repository_no_data) %>

    +

    温馨提示:<%= l(:label_repository_no_data) %>

    <% end %> -<%# 新建版本库 %> -<% if @project.repositories.count == 0 %> - - - <% course_tag = @project.project_type %> - <% if User.current.allowed_to?(:manage_repository, @project) %> - - <%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %>

    - <% end %> -
    -
    - <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %> -
    -
      -
    • - - <%= select_tag('repository_scm', - options_for_select(["Git"],@repository.class.name.demodulize), - :data => {:remote => true, :method => 'get'})%> - <% if @repository && ! @repository.class.scm_available %> - <%= l(:text_scm_command_not_available) %> - <% end %> -
    • - <% unless judge_main_repository(@project) %> -
    • - - <%= f.check_box :is_default, :label => "", :no_label => true %>

      -
    • - <% end %> -
    • - - - - <%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %> - <% unless @repository.identifier_frozen? %> - <%=l(:text_length_between,:min=>1,:max=>254)< - <% end %> -
    • -
    • - - <%= f.password_field :upassword, :label=> "", :no_label => true%> - <%= l(:label_upassword_info)%> -
    • -
      -
    - <%=l(:button_save)%> - <%=l(:button_cancel)%> -
    - <% end %> - -<% end %> diff --git a/app/views/projects/settings/_rep_forge.html.erb b/app/views/projects/settings/_rep_forge.html.erb new file mode 100644 index 000000000..e25849c38 --- /dev/null +++ b/app/views/projects/settings/_rep_forge.html.erb @@ -0,0 +1,38 @@ + + + 历史版本 + + + + + + + + + <% rep_forge(project).sort.each do |repository| %> + + + + + <%if repository.scm_name=="Git"%> + + <%else %> + + <% end %> + + + + <% end %> + +
    <%= l(:field_identifier) %> <%= l(:field_repository_is_default) %><%= l(:label_scm) %> <%= l(:label_repository_path) %>
    + <%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %> <%= checked_image repository.is_default? %><%=h repository.scm_name %> <%=truncate( 'http://' << repository.login.to_s << '_'<< repository.identifier.to_s << '@'<< ip.to_s << h( repository.url.slice(project_path_cut, repository.url.length)),:length=>20)%><%=h truncate(repository.url,:length=>10) %> + <% if repository.scm_name=="Git"%> + <%if User.current.allowed_to?(:manage_repository, @project) %> + <%= link_to(l(:label_user_plural), committers_repository_path(repository)) %> + <% end %> + <% end %> + + <% if repository.login.to_s==User.current.login.to_s %> + <%= delete_new_link repository_path(repository) %> + <% end %>
    \ No newline at end of file diff --git a/app/views/projects/settings/_rep_gitlab.html.erb b/app/views/projects/settings/_rep_gitlab.html.erb new file mode 100644 index 000000000..1de706b5d --- /dev/null +++ b/app/views/projects/settings/_rep_gitlab.html.erb @@ -0,0 +1,26 @@ +<% rep_gitlab(project).sort.each do |repository| %> + + + + + + + + + + + + + <%if repository.scm_name=="Gitlab"%> + + <%else %> + + <% end %> + +<% end %> + +
    <%= l(:field_identifier) %><%= l(:label_scm) %> <%= l(:label_repository_path) %>
    + <%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %> + <%=h repository.scm_name %> + <%=truncate(rep_gitlab_url(project), :length => 360) %> + <%=h truncate(repository.url,:length=>10) %>
    \ No newline at end of file diff --git a/app/views/repositories/_breadcrumbs.html.erb b/app/views/repositories/_breadcrumbs.html.erb index db570d948..84111afeb 100644 --- a/app/views/repositories/_breadcrumbs.html.erb +++ b/app/views/repositories/_breadcrumbs.html.erb @@ -1,32 +1,13 @@ -<%= link_to @repository.identifier.present? ? h(@repository.identifier) : 'root', - {:action => 'show', :id => @project, - :repository_id => @repository.identifier_param, - :path => nil, :rev => @rev }, - :class=>"fl c_blue f14 fb" %> -<% - dirs = path.split('/') - if 'file' == kind - filename = dirs.pop - end - link_path = '' - dirs.each do |dir| - next if dir.blank? - link_path << '/' unless link_path.empty? - link_path << "#{dir}" -%> - / <%= link_to h(dir), :action => 'show', :id => @project, :repository_id => @repository.identifier_param, - :path => to_path_param(link_path), :rev => @rev %> -<% end %> -<% if filename %> - / <%= link_to h(filename), - :action => 'changes', :id => @project, :repository_id => @repository.identifier_param, - :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %> -<% end %> -<% - # @rev is revsion or Git and Mercurial branch or tag. - # For Mercurial *tip*, @rev and @changeset are nil. - rev_text = @changeset.nil? ? @rev : format_revision(@changeset) -%> -

    <%= "@ #{h rev_text}" unless rev_text.blank? %>

    +
    + <%= link_to @repository.identifier.present? ? h(@repository.identifier) : 'root', + {:action => 'show', :id => @project, + :repository_id => @repository.identifier_param, + :path => nil, :rev => @rev }, + :class => "repository-title-dec" + %> + / + <%=link_to @project.owner, user_path(@project.owner), :class => "repository-title-dec" %> + +
    <% html_title(with_leading_slash(path)) -%> diff --git a/app/views/repositories/_dir_list.html.erb b/app/views/repositories/_dir_list.html.erb index 26ba05bb6..771d4d1ec 100644 --- a/app/views/repositories/_dir_list.html.erb +++ b/app/views/repositories/_dir_list.html.erb @@ -1,17 +1,6 @@
    - - - - -<% if @repository.report_last_commit %> - - - - -<% end %> - - + <%= render :partial => 'dir_list_content' %> diff --git a/app/views/repositories/_dir_list_content.html.erb b/app/views/repositories/_dir_list_content.html.erb index e595a77dd..81706c25e 100644 --- a/app/views/repositories/_dir_list_content.html.erb +++ b/app/views/repositories/_dir_list_content.html.erb @@ -7,6 +7,7 @@ - + + <% if @repository.report_last_commit %> diff --git a/app/views/repositories/_form.html.erb b/app/views/repositories/_form.html.erb index bc5a060db..8c169d7be 100644 --- a/app/views/repositories/_form.html.erb +++ b/app/views/repositories/_form.html.erb @@ -31,12 +31,7 @@ <%= f.text_field :login, :size => 30 %>

    -

    - <%= f.password_field :password, :size => 30, :name => 'ignore', - :value => ((@repository.new_record? || @repository.password.blank?) ? '' : ('x'*15)), - :onfocus => "this.value=''; this.name='repository[password]';", - :onchange => "this.name='repository[password]';" %> -

    +

    diff --git a/app/views/repositories/_form_create.html.erb b/app/views/repositories/_form_create.html.erb index d8c30143e..11dce9cd4 100644 --- a/app/views/repositories/_form_create.html.erb +++ b/app/views/repositories/_form_create.html.erb @@ -26,7 +26,6 @@ border:none <%= l(:text_scm_command_not_available) %> <% end %>

    -

    <%= f.check_box :is_default, :label => :field_repository_is_default %>

    @@ -36,8 +35,6 @@ border:none <%= l(:text_repository_identifier_info).html_safe %> <% end %>

    -

    <%= f.password_field :upassword, :required =>true, :label=> :field_password %> - <%= l(:label_upassword_info)%>

    <%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save)) %> diff --git a/app/views/repositories/_navigation.html.erb b/app/views/repositories/_navigation.html.erb index d8ce218eb..c3e154f17 100644 --- a/app/views/repositories/_navigation.html.erb +++ b/app/views/repositories/_navigation.html.erb @@ -1,34 +1,33 @@ -<% content_for :header_tags do %> - <%= javascript_include_tag 'repository_navigation' %> -<% end %> - -<%= link_to l(:label_statistics), + +<%#= link_to l(:label_statistics), {:action => 'stats', :id => @project, :repository_id => @repository.identifier_param}, :class => 'mt3 c_blue fl' if @repository.supports_all_revisions? %> +

    + <% content_for :header_tags do %> + <%= javascript_include_tag 'repository_navigation' %> + <% end %> -<%= form_tag({:action => controller.action_name, - :id => @project, - :repository_id => @repository.identifier_param, - :path => to_path_param(@path), - :rev => nil}, - {:method => :get, :id => 'revision_selector', :class => "fl c_grey02 ml5"}) do -%> - - <% if !@repository.branches.nil? && @repository.branches.length > 0 -%> - | <%= l(:label_branch) %>: - <%= select_tag :branch, - options_for_select([''] + @repository.branches, @rev), - :id => 'branch' %> - <% end -%> - <% if !@repository.tags.nil? && @repository.tags.length > 0 -%> - | <%= l(:label_tag) %>: - <%= select_tag :tag, - options_for_select([''] + @repository.tags, @rev), - :id => 'tag' %> - <% end -%> - <% if @repository.supports_all_revisions? %> - | <%= l(:label_revision) %>: - <%= text_field_tag 'rev', @rev, :size => 8 %> - <% end %> -<% end -%> + <%= form_tag({:action => controller.action_name, + :id => @project, + :repository_id => @repository.identifier_param, + :path => to_path_param(@path), + :rev => nil}, + {:method => :get, :id => 'revision_selector'}) do -%> + + <% if !@repository.branches.nil? && @repository.branches.length > 0 -%> + <%= l(:label_branch) %>: + <%= select_tag :branch, options_for_select([''] + @repository.branches, @rev), :id => 'branch' %> + <% end -%> + + <% if !@repository.tags.nil? && @repository.tags.length > 0 -%> + <%= select_tag :tag, options_for_select([''] + @repository.tags, @rev), :id => 'tag', :style=>" display:none" %> + <% end -%> + + <% if @repository.supports_all_revisions? %> + <%= hidden_field_tag 'rev', @rev, :size => 8 %> + <% end %> + <% end -%> + +
    diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index 891952559..837096c89 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -1,53 +1,51 @@ -<% show_revision_graph = ( @repository.supports_revision_graph? && path.blank? ) %> -<%= if show_revision_graph && revisions && revisions.any? - indexed_commits, graph_space = index_commits(revisions, @repository.branches) do |scmid| - url_for( - :controller => 'repositories', - :action => 'revision', - :id => project, - :repository_id => @repository.identifier_param, - :rev => scmid) - end - render :partial => 'revision_graph', - :locals => { - :commits => indexed_commits, - :space => graph_space - } - end %> <%= form_tag( {:controller => 'repositories', :action => 'diff', :id => project, :repository_id => @repository.identifier_param, :path => to_path_param(path)}, :method => :get ) do %>
    <%= l(:field_name) %><%= l(:field_filesize) %><%= l(:label_revision) %><%= l(:label_age) %><%= l(:field_author) %><%= l(:field_comments) %>
    "> <% if entry.is_dir? %> +<%# 展开文件目录 %>   <% end %> <%= link_to h(ent_name), - {:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, + {:action => (entry.is_dir? ? 'show' : 'entry'), :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(ent_path), :rev => @rev}, :class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(ent_name)}")%> <%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %><%= link_to_revision(entry.changeset, @repository) if entry.changeset %> <%= distance_of_time_in_words(entry.lastrev.time, Time.now) if entry.lastrev && entry.lastrev.time %>
    - - - - - - - - + + + + + + + + <% show_diff = revisions.size > 1 %> <% line_num = 1 %> <% revisions.each do |changeset| %> - - <% id_style = (show_revision_graph ? "padding-left:#{(graph_space + 1) * 20}px" : nil) %> - <%= content_tag(:td, :class => 'id', :style => id_style) do %> - <%= link_to_revision(changeset, @repository) %> - <% end %> - - - - - - - <% line_num += 1 %> + <% end %>
    #<%= l(:label_date) %><%= l(:field_author) %><%= l(:field_comments) %>
    <%= radio_button_tag('rev', changeset.identifier, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('#cbto-#{line_num+1}').attr('checked',true);") if show_diff && (line_num < revisions.size) %><%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').attr('checked')) {$('#cb-#{line_num-1}').attr('checked',true);}") if show_diff && (line_num > 1) %><%= format_time(changeset.committed_on) %><%= h truncate(changeset.author.to_s, :length => 30) %><%= textilizable(truncate_at_line_break(changeset.comments)) %>

    - <%= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %> + <%#= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %>

    + <% end %> diff --git a/app/views/repositories/_summary.html.erb b/app/views/repositories/_summary.html.erb new file mode 100644 index 000000000..3bd86cd45 --- /dev/null +++ b/app/views/repositories/_summary.html.erb @@ -0,0 +1,37 @@ +
    + +
    +
    + + + +
    +
    + +
    \ No newline at end of file diff --git a/app/views/repositories/changes.html.erb b/app/views/repositories/changes.html.erb index 302c839ba..428799f07 100644 --- a/app/views/repositories/changes.html.erb +++ b/app/views/repositories/changes.html.erb @@ -1,18 +1,20 @@ <%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %> -
    - <%= render :partial => 'navigation' %> +
    +

    <%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>

    -

    <%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => (@entry ? @entry.kind : nil), :revision => @rev } %>

    +
    + <%= render :partial => 'navigation' %> +
    +
    <%= render :partial => 'link_to_functions' %> <%= render_properties(@properties) %> -
    -<%= render(:partial => 'revisions', - :locals => {:project => @project, :path => @path, :revisions => @changesets, :entry => @entry }) unless @changesets.empty? %> +
    + <%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @commits, :entry => @entry }) unless @commits.empty? %>
    <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/app/views/repositories/committers.html.erb b/app/views/repositories/committers.html.erb index ccb037e09..93350889d 100644 --- a/app/views/repositories/committers.html.erb +++ b/app/views/repositories/committers.html.erb @@ -1,4 +1,8 @@ -

    <%= l(:label_repository) %>

    +
    +
    +

    <%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>

    +
    +
    <%= simple_format(l(:text_repository_usernames_mapping)) %> diff --git a/app/views/repositories/diff.html.erb b/app/views/repositories/diff.html.erb index a3afebfff..4e40bd5e8 100644 --- a/app/views/repositories/diff.html.erb +++ b/app/views/repositories/diff.html.erb @@ -1,4 +1,7 @@ -

    <%= l(:label_revision) %> <%= @diff_format_revisions %> <%=h @path %>

    +
    +

    <%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>

    +
    +

    <%= l(:label_revision_path) %> :<%=h @path %>

    <%= form_tag({:action => 'diff', :id => @project, diff --git a/app/views/repositories/entry.html.erb b/app/views/repositories/entry.html.erb index 5aea99dcc..bb2fa6dae 100644 --- a/app/views/repositories/entry.html.erb +++ b/app/views/repositories/entry.html.erb @@ -1,15 +1,17 @@ <%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %> +
    +
    + <%= render :partial => 'navigation' %> +
    -
    - <%= render :partial => 'navigation' %> +

    <%= l(:label_revision_path) %> :<%= @path %>

    + + <%= render :partial => 'link_to_functions' %> + + <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> + + <% content_for :header_tags do %> + <%= stylesheet_link_tag "scm" %> + <% end %>
    -

    <%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'file', :revision => @rev } %>

    - -<%= render :partial => 'link_to_functions' %> - -<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> - -<% content_for :header_tags do %> -<%= stylesheet_link_tag "scm" %> -<% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 28a260178..9601e5188 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -1,83 +1,65 @@ <%= call_hook(:view_repositories_show_contextual, {:repository => @repository, :project => @project}) %>
    -

    版本库

    +

    <%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>

    -
    - <%= render :partial => 'breadcrumbs', - :locals => {:path => @path, :kind => 'dir', :revision => @rev} %> - <%= render :partial => 'navigation' %> -
    - -
    -
    -

    - <% if @repository.type.to_s=="Repository::Git" %> - <%= @repos_url %> - <% else %> - <%= h @repository.url %> - <% end %> -

    + <% if @entries.nil? %> + <%# 未提交代码提示 %> +
    + <% if @entries.nil? && authorize_for('repositories', 'browse') %> +
    + 该版本库还没有上传代码! +
    + <% end %> + <% if @repository.type.to_s=="Repository::Gitlab" %> + 版本库地址:<%= @repos_url %> + <% else %> + 版本库地址:<%= h @repository.url %> + <% end %> + +
    +
    + <% else %> + <%= render :partial => 'navigation' %> +
    克隆网址:
    + + + +
    Fork 0
    +
    +
    + <% if @changesets && !@changesets.empty? %> + <%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %> +
    <%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %>
    +
    提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
    +
    <%= @changesets_latest_coimmit.message %>
    +
    + <% end %> + + <%= @repository.branches.count %> 个分支 + -

    - (<%= l(:label_all_revisions) %><%= @repositories.sort.collect { |repo| - link_to h(repo.name), - {:controller => 'repositories', :action => 'show', - :id => @project, :repository_id => repo.identifier_param, :rev => nil, :path => nil}, - :class => 'repository' + (repo == @repository ? ' selected' : ''), - :class => "mb10 break_word c_orange" }.join(' | ').html_safe %>) -

    -
    + + <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev} %> 提交 + +
    + <% end %>
    + + <% if !@entries.nil? && authorize_for('repositories', 'browse') %> + <%# 数据统计 %> + <%#= render :partial => 'summary' %> + <%# end %> <%= render :partial => 'dir_list' %> <% end %> <%= render_properties(@properties) %> -<% if authorize_for('repositories', 'revisions') %> - <%# if @changesets && !@changesets.empty? %> -

    - <%= l(:label_latest_revision_plural) %> -

    - <%= render :partial => 'revisions', - :locals => {:project => @project, :path => @path, - :revisions => @changesets, :entry => nil} %> - <%# end %> +<%= render_properties(@properties) %> -

    - <% has_branches = (!@repository.branches.nil? && @repository.branches.length > 0) - sep = '' %> - <% if @repository.supports_all_revisions? && @path.blank? %> - <%= link_to l(:label_view_all_revisions), {:action => 'revisions', :id => @project, - :repository_id => @repository.identifier_param}, - :class => "orange_u_btn" %> - <% sep = '|' %> - <% end %> - <% if @repository.supports_directory_revisions? && (has_branches || !@path.blank? || !@rev.blank?) %> - <%= sep %> - <%= link_to l(:label_view_revisions), - {:action => 'changes', - :path => to_path_param(@path), - :id => @project, - :repository_id => @repository.identifier_param, - :rev => @rev}, - :class => "orange_u_btn" %> - <% end %> -

    - <% if @repository.supports_all_revisions? %> - <% content_for :header_tags do %> - <%= auto_discovery_link_tag( - :atom, params.merge( - {:format => 'atom', :action => 'revisions', - :id => @project, :page => nil, :key => User.current.rss_key})) %> - <% end %> - <% end %> -<% end %> - -

    点击查看如何提交代码

    -
    +如何提交代码 <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/app/views/repositories/to_gitlab.html.erb b/app/views/repositories/to_gitlab.html.erb new file mode 100644 index 000000000..d06c087ed --- /dev/null +++ b/app/views/repositories/to_gitlab.html.erb @@ -0,0 +1,12 @@ +
    +

    + <%= l(:label_repository_migrate_dec) %> +

    +<%= form_for(@repository, url: to_gitlab_project_repository_path(@project, @repository)) do |f| %> + + +<% end %> + + <%= l(:label_repository_name_dec) %> + +
    \ No newline at end of file diff --git a/app/views/school/upload_logo.html.erb b/app/views/school/upload_logo.html.erb index 023069dd0..01071fb81 100644 --- a/app/views/school/upload_logo.html.erb +++ b/app/views/school/upload_logo.html.erb @@ -11,7 +11,7 @@ function showPreview(source) { } -<%= form_tag(upload_school_path(@school.id),method: "post", multipart: true) do %> +<%= form_tag(upload_school_path(@school.id),method: "post", multipart: true,:id => "school_form") do %> <%#= text_field_tag 'school'%>
    @@ -19,16 +19,58 @@ function showPreview(source) { 上传图片 <%= file_field_tag 'logo',:style => "display:none;", :id => "file", :onchange => "showPreview(this)"%>
    -
    学校名称:
    +
    学校名称:
    学校省份: - +
    - - + + <%#= submit_tag('提交',:class=>'mr5') %> <%#= submit_tag('取消') %>
    <% end %> + diff --git a/app/views/student_work/_add_score.html.erb b/app/views/student_work/_add_score.html.erb index 961f351de..0258b3b83 100644 --- a/app/views/student_work/_add_score.html.erb +++ b/app/views/student_work/_add_score.html.erb @@ -16,7 +16,7 @@ <%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work,:score => score} %>
    <%end%> - 提交 + 提交
  • <% end%> \ No newline at end of file diff --git a/app/views/student_work/_alert_forbidden_anonymous.html.erb b/app/views/student_work/_alert_forbidden_anonymous.html.erb new file mode 100644 index 000000000..55f21048f --- /dev/null +++ b/app/views/student_work/_alert_forbidden_anonymous.html.erb @@ -0,0 +1,16 @@ +
    +
    +

    禁用匿评

    +

    + 禁用匿评后学生将不能对作品进行互评,且匿评不能再开启,是否确定禁用匿评? +

    + +
    +
    \ No newline at end of file diff --git a/app/views/student_work/_evaluation_un_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb index 9a21e109b..4ed0a538a 100644 --- a/app/views/student_work/_evaluation_un_title.html.erb +++ b/app/views/student_work/_evaluation_un_title.html.erb @@ -1,6 +1,6 @@ diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index 4a6a4eb68..81d868a50 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -1,62 +1,63 @@ - - - + + + diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index b5ff8f064..fd541c643 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -3,21 +3,21 @@ -
    - <%@student_work_scores.each do |score|%> -
    - <%= render :partial => 'student_work_score',:locals => {:score => score,:is_last => score == @student_work_scores.last}%> +
    + <%student_work_scores.each do |student_score|%> +
    + <%= render :partial => 'student_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%>
    <% end%>
    - 收起 + 收起
    \ No newline at end of file diff --git a/app/views/student_work/_set_score_rule.html.erb b/app/views/student_work/_set_score_rule.html.erb index 7deed7fb8..26e3b06cb 100644 --- a/app/views/student_work/_set_score_rule.html.erb +++ b/app/views/student_work/_set_score_rule.html.erb @@ -1,63 +1,9 @@ -<%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id},:method => "post") do |f|%> -
    - 评分设置 -
    - 迟交扣分 - -
    -
    - 缺评扣分 - -
    - - <% if homework.homework_type == 2%> -
    - 系统评分 - <%= select_tag :sy_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "markPercentage"} %> -
    - - - <% else%> - - <% end%> - -
    - 教辅评分 - <%= select_tag :ta_proportion,options_for_select(ta_proportion_option_to(100-(homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i),homework.homework_detail_manual.ta_proportion), {:class => "markPercentage"} %> -
    -
    - 学生匿评 - -
    -
    - 教师优先 - /> - 教师评分为最终评分 -
    -
    -
    - 确定 -
    -
    - 取消 -
    -
    -
    -
    -<% end%> +<% if student_path%> + <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:student_path => student_path},:method => "post") do |f|%> + <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> + <% end%> +<% else %> + <%= form_for('new_form',:url => {:controller => 'student_work',:action => 'set_score_rule',:homework => homework.id,:user_activity_id=>user_activity_id,:is_in_course=>is_in_course},:method => "post",:remote => true) do |f|%> + <% render :partial => 'student_work/set_score_rule_detail', :locals => {:homework => homework, :f => f}%> + <% end%> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/_set_score_rule_detail.html.erb b/app/views/student_work/_set_score_rule_detail.html.erb new file mode 100644 index 000000000..4739fba47 --- /dev/null +++ b/app/views/student_work/_set_score_rule_detail.html.erb @@ -0,0 +1,63 @@ +
    + 评分设置 +
    + 迟交扣分 + +
    +
    + 缺评扣分 + +
    + + <% if homework.homework_type == 2%> +
    + 系统评分 + <%= select_tag :sy_proportion,options_for_select(ta_proportion_option,homework.homework_detail_programing.ta_proportion), {:class => "markPercentage"} %> +
    + + + <% else%> + + <% end%> + +
    + 教辅评分 + <%= select_tag :ta_proportion,options_for_select(ta_proportion_option_to(100-(homework.homework_detail_programing ? homework.homework_detail_programing.ta_proportion * 100 : 0).to_i),homework.homework_detail_manual.ta_proportion), {:class => "markPercentage"} %> +
    + <% if homework.anonymous_comment == 0 %> +
    + 学生匿评 + +
    + <% end %> +
    + 教师优先 + /> + 教师评分为最终评分 +
    +
    +
    + 确定 +
    +
    + 取消 +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index cfc4129a8..286d5eb39 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -3,21 +3,21 @@ -
    - <%@student_work_scores.each do |score|%> -
    - <%= render :partial => 'student_work_score',:locals => {:score => score,:is_last => score == @student_work_scores.last}%> +
    + <%student_work_scores.each do |student_score|%> +
    + <%= render :partial => 'student_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%>
    <% end%>
    - 收起 + 收起
    \ No newline at end of file diff --git a/app/views/student_work/_student_work_attachment_form.html.erb b/app/views/student_work/_student_work_attachment_form.html.erb index 7802f6eb6..265ff9be7 100644 --- a/app/views/student_work/_student_work_attachment_form.html.erb +++ b/app/views/student_work/_student_work_attachment_form.html.erb @@ -1,35 +1,35 @@ -
    - - -
    - - <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> - <%= file_field_tag 'attachments[dummy][file]', - :id => "_file#{work.id}", - :class => 'file_selector', - :multiple => true, - :onchange => "addInputFiles_board(this, '#{work.id}');", - :style => 'display:none', - :data => { - :max_file_size => Setting.attachment_max_size.to_i.kilobytes, - :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), - :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, - :upload_path => uploads_path(:format => 'js'), - :description_placeholder => l(:label_optional_description), - :field_is_public => l(:field_is_public), - :are_you_sure => l(:text_are_you_sure), - :file_count => l(:label_file_count), - :delete_all_files => l(:text_are_you_sure_all), - :containerid => "#{work.id}" - } %> - - <%= l(:label_no_file_uploaded) %> - - (<%= l(:label_max_size) %>: - <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) - - <% content_for :header_tags do %> - <%= javascript_include_tag 'attachments' %> - <% end %> -
    - +
    + + +
    + + <%= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'sub_btn mb0' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file#{work.id}", + :class => 'file_selector', + :multiple => true, + :onchange => "addInputFiles_board(this, '#{work.id}');", + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all), + :containerid => "#{work.id}" + } %> + + <%= l(:label_no_file_uploaded) %> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
    + diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index 197fecac9..64f097114 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -1,9 +1,12 @@ -
    +
    作品 - (<%= @stundet_works.count%>) + (已有<%= @student_work_count%>人提交) + <% if !@is_teacher && @stundet_works.empty?%> + 您尚未提交作品 + <% end %> <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%>
    @@ -12,6 +15,7 @@
    <%= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> <% end%> +
    @@ -31,6 +35,14 @@ <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> <% end%>
    -
    +
    + <% if student_work.user == User.current && !@is_evaluation %> + <% if @homework.homework_type == 2%> + <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% else %> + <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% end %> + <% end %> +
    <% end%> \ No newline at end of file diff --git a/app/views/student_work/_work_attachments.html.erb b/app/views/student_work/_work_attachments.html.erb index a75f68f70..098bb94d0 100644 --- a/app/views/student_work/_work_attachments.html.erb +++ b/app/views/student_work/_work_attachments.html.erb @@ -2,7 +2,7 @@
    <%= link_to_short_attachment attachment, :class => 'link_file_a fl', :download => true -%> <%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload fl', :confirm => l(:text_are_you_sure)) if attachment.id && User.current == attachment.author %> - (<%= number_to_human_size attachment.filesize %>) + (<%= number_to_human_size attachment.filesize %>)
    <% end -%> diff --git a/app/views/student_work/_work_information.html.erb b/app/views/student_work/_work_information.html.erb new file mode 100644 index 000000000..f8a55a03d --- /dev/null +++ b/app/views/student_work/_work_information.html.erb @@ -0,0 +1,33 @@ +
    +
    + 请您确认刚刚上传的作品信息 +

    + 作品名称:<%=@student_work.name%> +

    +

    + 作品描述:<%=@student_work.description%> +

    +

    + 件: + <% if @student_work.attachments.empty? %> + <%= "无附件"%> + <% else %> +

    + <%= render :partial => 'work_attachments_status', :locals => {:attachments => @student_work.attachments, :status => 2} %> +
    + <% end %> +

    +
    + +
    +
    + + \ No newline at end of file diff --git a/app/views/student_work/create.js.erb b/app/views/student_work/create.js.erb new file mode 100644 index 000000000..42b1db8b8 --- /dev/null +++ b/app/views/student_work/create.js.erb @@ -0,0 +1,16 @@ +<% if @submit_result%> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>'); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before("" + + ""); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); +<% else %> + window.location.href = '<%= new_student_work_url(:homework => @homework.id)%>'; +<% end %> + +function clickCanel() { + hideModal('#popbox02'); + window.location.href = '<%= student_work_index_url(:homework => @homework.id)%>'; +} \ No newline at end of file diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index 25a65f039..517a238b0 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -26,7 +26,7 @@
    - <%= labelled_form_for @work,:html => { :multipart => true } do |f|%> + <%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%>
    提示:作品名称和描述中不要出现真实的姓名信息
    @@ -52,7 +52,7 @@
    - 确定 + 确定 <%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
    @@ -60,3 +60,12 @@ <% end%>
    + \ No newline at end of file diff --git a/app/views/student_work/forbidden_anonymous_comment.js.erb b/app/views/student_work/forbidden_anonymous_comment.js.erb new file mode 100644 index 000000000..a72c29509 --- /dev/null +++ b/app/views/student_work/forbidden_anonymous_comment.js.erb @@ -0,0 +1,7 @@ +<% if @user_activity_id == -1 %> +$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); +init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +<% else %> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index e28cdb1e2..b0e70c9b0 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -20,7 +20,7 @@ //设置评分规则 function set_score_rule(){ - $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework}) %>'); + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/set_score_rule',:locals => {:homework => @homework,:student_path => true}) %>'); showModal('ajax-modal', '350px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + @@ -28,6 +28,33 @@ $('#ajax-modal').parent().css("top","25%").css("left","35%").css("position","fixed"); } + $(function(){ + $("#homework_info_hidden").click(function(){ + $("#homeworkInformation").hide(); + $("#homework_info_hidden").hide(); + $("#homework_info_show").show(); + }); + $("#homework_info_show").click(function(){ + $("#homework_info_show").hide(); + $("#homeworkInformation").show(); + $("#homework_info_hidden").show(); + }); + + if($("#homework_description").height() > 54) { + $("#homeworkDetailShow").show(); + } + $("#homeworkDetailShow").click(function(){ + $("#homeworkDetail").toggleClass("max_h54"); + $("#homeworkDetailShow").hide(); + $("#homeworkDetailHide").show(); + }); + $("#homeworkDetailHide").click(function(){ + $("#homeworkDetail").toggleClass("max_h54"); + $("#homeworkDetailHide").hide(); + $("#homeworkDetailShow").show(); + }); + }); +
    @@ -91,6 +118,79 @@
    +
    +
    + + <% if @homework.homework_detail_manual%> + <% if @homework.homework_detail_manual.comment_status == 0 %> + 未发布 + <% elsif @homework.homework_detail_manual.comment_status == 1%> + <% if @homework.anonymous_comment == 0%> + 未开启匿评 + <% else %> + 匿评已禁用 + <% end %> + 作品提交中 + <% elsif @homework.homework_detail_manual.comment_status == 2%> + <% if @homework.anonymous_comment == 0%> + 匿评中 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% elsif @homework.homework_detail_manual.comment_status == 3%> + <% if @homework.anonymous_comment == 0%> + 匿评已结束 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% end%> + <% end%> + [ 隐藏作业信息 ] +
    +
    发布者:<%= @homework.user.show_name %>
    +
    +
    <%= @homework.description.html_safe %>
    +
    + + +
    +
    + <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @homework.attachments} %> +
    +
    +
    +
    截止时间:<%= @homework.end_time %> 23:59
    + <% if @homework.homework_detail_manual.comment_status == 0 %> +
    发布时间:<%= @homework.publish_time %> 00:00
    + <% end %> + <% if @homework.homework_detail_manual%> + <% if @homework.homework_detail_manual.comment_status == 1%> + <% end_time = @homework.end_time.to_time.to_i + 24*60*60 - 1 %> + <% if end_time >= Time.now.to_i %> +
    提交剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60) %> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    提交已截止
    + <% end %> + <% elsif @homework.homework_detail_manual.comment_status == 2%> + <% end_time = @homework.homework_detail_manual.evaluation_end.to_time.to_i + 24*60*60 - 1 %> + <% if end_time >= Time.now.to_i %> +
    匿评剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60)%> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    匿评已截止
    + <% end %> + <% end%> + <% end%> +
    +
    +
    +
    +
    diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 09544d004..fdf1e31a3 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -59,6 +59,10 @@
    <%= @homework.description.html_safe %>
    +
    + <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => @homework.attachments} %> +
    +
    @@ -69,7 +73,7 @@ :url => {:controller => 'student_work', :action => 'create', :homework => @homework.id - }) do |f|%> + },:remote=>true ) do |f| %>
    提示:作品名称和描述中不要出现真实的姓名信息
    @@ -107,11 +111,20 @@
    - 确定 + 确定 <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%>
    <% end%>
    - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/student_work/set_score_rule.js.erb b/app/views/student_work/set_score_rule.js.erb new file mode 100644 index 000000000..ff3a0e7ed --- /dev/null +++ b/app/views/student_work/set_score_rule.js.erb @@ -0,0 +1,8 @@ +clickCanel(); +<% if @user_activity_id %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else %> + $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); + init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb index e6b99c146..d61c4b9a1 100644 --- a/app/views/student_work/show.js.erb +++ b/app/views/student_work/show.js.erb @@ -3,9 +3,9 @@ if($("#about_hwork_<%= @work.id%>").children().length > 0){ } else{ <% if @homework.homework_type == 2%> - $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show') %>"); + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'programing_work_show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>"); <% else%> - $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show') %>"); + $("#about_hwork_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work =>@work,:score =>@score,:student_work_scores => @student_work_scores}) %>"); <% end%> $('#score_<%= @work.id%>').peSlider({range: 'min'}); } \ No newline at end of file diff --git a/app/views/student_work/update.js.erb b/app/views/student_work/update.js.erb new file mode 100644 index 000000000..79733db31 --- /dev/null +++ b/app/views/student_work/update.js.erb @@ -0,0 +1,16 @@ +<% if @submit_result%> +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>'); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("anonymos"); +<% else %> +window.location.href = '<%= edit_student_work_url(@work)%>'; +<% end %> + +function clickCanel() { + hideModal('#popbox02'); + window.location.href = '<%= student_work_index_url(:homework => @homework.id)%>'; +} \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 2d3bc68de..38a4d6edd 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -1,5 +1,5 @@ <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> -
    +
    <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %> @@ -13,15 +13,32 @@ <% end %> TO <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%>
    - + + <% count=activity.journals_for_messages.count %> +
    +
    +
    +
    + 回复(<%= count %>) +
    +
    + <%if count>3 %> + + <% end %> +
    + + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> +
      +
      +
      + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
      +
      + <%= comment.notes.html_safe %>
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %> + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index 28cb368d6..27549f6d9 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -67,7 +67,7 @@ <% end %> <%= format_time(comment.created_on) %>
    -
    +
    <%= comment.notes.html_safe %>
    <% fetch_user_leaveWord_reply(comment).each do |reply| unless fetch_user_leaveWord_reply(comment).nil? %>
    diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index cc8a6c0f2..669953afa 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -11,7 +11,6 @@ .ke-inline-block{display: none;} div.ke-container{float:left;} -<% first_user_activity = user_activities.first.id unless user_activities.first.nil? %> <% user_activities.each do |user_activity| if user_activities %> <% unless user_activity.act_type == "ProjectCreateInfo" %> @@ -48,13 +62,13 @@ <% if act %> <% case user_activity.act_type.to_s %> <% when 'HomeworkCommon' %> - <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <%= 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,:first_user_activity =>first_user_activity,:page => page} %> + <%= 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,:first_user_activity =>first_user_activity,:page => page} %> + <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'Poll' %> - <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity_id => user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <%= 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 %> @@ -63,11 +77,11 @@ <% if act %> <% case user_activity.act_type.to_s %> <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'Message' %> - <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'ProjectCreateInfo'%> - <%= render :partial => 'project_create', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <%= render :partial => 'project_create', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% end %> <% end %> <% when 'Principal' %> @@ -77,9 +91,16 @@ <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% 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 %> - <%= render :partial => 'project_create', :locals => {:activity => user_activity,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %> + <%= render :partial => 'project_create', :locals => {:activity => user_activity,:user_activity_id =>user_activity.id} %> <% end %> <% end %> <% end %> diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb new file mode 100644 index 000000000..c1219eb25 --- /dev/null +++ b/app/views/users/_user_blog.html.erb @@ -0,0 +1,119 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
    +
    +
    + <% if @ctivity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.author.name.to_s+" | 博客", user_blogs_path(:user_id=>activity.author_id), :class => "newsBlue ml15" %> +
    +
    +
    + <%= link_to activity.title.to_s, user_blog_blog_comment_path(:user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id), :class => "postGrey" %> +
    + <% if activity.sticky == 1%> + 置顶 + <% end%> + <% if activity.locked%> +        + <% end%> +
    +
    + +
    + 发布时间:<%= format_time(activity.created_on) %> +
    +
    +
    + <%= activity.content.html_safe %> +
    +
    +
    + + +
    +
    +
    +
    + <% count=activity.children.count %> +
    +
    +
    +
    + 回复(<%= count %>) +
    +
    <%#= format_date(activity.updated_on) %>
    + <%if count>3 %> + + <% end %> +
    + + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.children.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %> +
      +
      +
      + <% if comment.try(:author).try(:realname) == ' ' %> + <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
      +
      + <%= comment.content.html_safe %>
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + + <% if activity.locked == false && User.current.logged?%> +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id},:method => "post", :remote => true) do |f|%> + + + + + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    + <% end %> +
    +
    \ 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 new file mode 100644 index 000000000..0c2a28e5c --- /dev/null +++ b/app/views/users/_user_homework_detail.html.erb @@ -0,0 +1,190 @@ +<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> +
    +
    +
    + <%=link_to image_tag(url_to_avatar(homework_common.user),width:"50px", height: "50px"), user_activities_path(homework_common.user.id)%> +
    +
    +
    + <%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%> + TO + <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> +
    + + + <% if homework_common.homework_detail_manual%> + <% if homework_common.homework_detail_manual.comment_status == 0 %> + 未发布 + <% elsif homework_common.homework_detail_manual.comment_status == 1%> + <% if homework_common.anonymous_comment == 0%> + 未开启匿评 + <% else %> + 匿评已禁用 + <% end %> + 作品提交中 + <% elsif homework_common.homework_detail_manual.comment_status == 2%> + <% if homework_common.anonymous_comment == 0%> + 匿评中 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% elsif homework_common.homework_detail_manual.comment_status == 3%> + <% if homework_common.anonymous_comment == 0%> + 匿评已结束 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% end%> + <% end%> + +
    +
    + <%= user_for_homework_common homework_common,is_teacher %> +
    + <% if homework_common.homework_type == 2 && is_teacher%> +
    + <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> +
    + <% end %> + <% if homework_common.homework_type == 2%> +
    + 语言: + <%= homework_common.language_name%> +
    + <% end %> +
    + <%= l(:label_end_time)%>:<%= homework_common.end_time%> 23:59 +
    + <% if homework_common.homework_detail_manual.comment_status == 0 %> +
    + <%= l(:label_publish_time)%>:<%= homework_common.publish_time%> 00:00 +
    + <% end %> +
    +
    +
    + <%= homework_common.description.html_safe %> +
    +
    +
    + + +
    +
    + <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %> +
    +
    + <% if is_teacher%> + <% comment_status = homework_common.homework_detail_manual.comment_status%> +
    +
      +
    • +
        +
      • + <%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1), :class => "postOptionLink"%> +
      • +
      • + <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> +
      • +
      • + <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course),:class => "postOptionLink", :remote => true) %> +
      • + <% if homework_common.anonymous_comment == 0 &&(comment_status == 0 || comment_status == 1)%> +
      • + <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common),:class => "postOptionLink", :remote => true)%> +
      • + <% end %> + <% if homework_common.anonymous_comment == 0%> +
      • + <%= homework_anonymous_comment(homework_common, is_in_course) %> +
      • + <% end %> + <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> +
      • + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%> +
      • + <% end %> +
      +
    • +
    +
    + <% end%> +
    +
    +
    + + <% count=homework_common.journals_for_messages.count %> +
    +
    +
    +
    + 回复(<%= count %>) +
    +
    + <%if count>3 %> + + <% end %> +
    + + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% homework_common.journals_for_messages.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> +
      +
      +
      + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
      +
      + <%= comment.notes.html_safe %>
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => homework_common.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'homework_common_id',params[:homework_common_id],:value =>homework_common.id %> + <%= hidden_field_tag 'is_in_course',params[:is_in_course],:value =>is_in_course %> + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 6167e4e10..6d929ac5f 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -21,6 +21,10 @@ <%= calendar_for('homework_end_time')%>
    +
    + + <%= calendar_for('homework_publish_time')%> +

    @@ -52,8 +56,9 @@ <% if edit_mode %> 确定 - <%= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%> - <% else %> + <%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%> + 取消 + <% else %> 发送 取消 diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index 44f992bb4..2e530d489 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -1,83 +1,56 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %> + <% homework_commons.each do |homework_common|%> - <% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> -
    -
    -
    - <%=link_to image_tag(url_to_avatar(homework_common.user),width:"50px", height: "50px"), user_activities_path(homework_common.user.id)%> -
    -
    -
    - <%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%> - TO - <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> -
    - + + <%= render :partial => 'users/user_homework_detail', :locals => {:homework_common => homework_common,:is_in_course => is_in_course} %> <% end%> <% if homework_commons.count == 10%> <% if is_in_course == 1%> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index 43ec2a0c2..33e08f4e8 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -60,7 +60,7 @@ <% end %> <%= format_time(comment.created_on) %>
    -
    +
    <%= comment.notes.html_safe %>
    <% end %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 86b44f66d..da649663d 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -37,7 +37,7 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - <% if ma.course_message_type == "HomeworkCommon" %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status.nil?%>
    @@ -96,7 +103,7 @@ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %> ">发布的作业:
  • - <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), + <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> @@ -107,22 +114,16 @@ <%= User.current.lastname + User.current.firstname %>同学您好! <%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师发布的作业截止日期快到了:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    提交截止:<%= ma.course_message.end_time %>  24点

    -

    匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点

    -

    迟交扣分:<%= ma.course_message.late_penalty %>分

    -

    请同学们抓紧时间提交自己的作品,谢谢!

    - <% else %> -

    <%= User.current.lastname + User.current.firstname %>老师您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师发布的作业截止日期快到了:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    提交截止:<%= ma.course_message.end_time %>  24点

    -

    匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  24点

    -

    匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点

    -

    迟交扣分:<%= ma.course_message.late_penalty %>分

    -

    缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分

    -

    您可以修改作业内容、评分规则、匿评过程等,谢谢!

    +
      +
    • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
    • 提交截止:<%= ma.course_message.end_time %>  23:59
    • +
    • 匿评开始:<%= ma.course_message.homework_detail_manual.evaluation_start %>  23:59
    • +
    • 匿评关闭:<%= ma.course_message.homework_detail_manual.evaluation_end %>  23:59
    • +
    • 迟交扣分:<%= ma.course_message.late_penalty %>分
    • +
    • 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
    • +

      请抓紧时间提交您的作品,谢谢!

      +
    <% end %>
  •    截止时间快到了!
  • @@ -150,14 +151,15 @@ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师' : '同学' %>您好! <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>开启了匿评,作业详情如下:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分

    -

    - 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %>  24点 -

    +
      +
    • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
    • +
    • 作业标题:<%= ma.course_message.name %>
    • +
    • 缺评扣分:<%= ma.course_message.homework_detail_manual.absence_penalty %>分
    • +
    • 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %>  23:59
    • +
    <% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%> -

    请您尽早完成匿评!如果您在规定时间内未完成匿评,一次将被扣<%= ma.course_message.homework_detail_manual.absence_penalty %>分。

    +

    请您尽早完成匿评!如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。

    +

    例如,您缺评了两份作品,则您的最终成绩将被扣除 <%= ma.course_message.homework_detail_manual.absence_penalty %> * 2 = <%= ma.course_message.homework_detail_manual.absence_penalty * 2 %>分

    <% end%>
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -180,8 +182,10 @@ <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher,ma.course_message.course) ? '老师':'同学'%>您好! <%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname+"老师") %>关闭了匿评,作业详情如下:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    +
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -206,14 +210,14 @@

    <%= User.current.lastname + User.current.firstname %><%= User.current.allowed_to?(:as_teacher, ma.course_message.course) ? '老师':'同学'%>您好! <%= User.current.eql?(ma.course_message.user) ?"您":(ma.course_message.user.lastname + ma.course_message.user.firstname + "老师") %>启动作业匿评失败! -

    失败原因:提交作品的人数低于2人

    -

    -

    作业详情如下:

    -

    课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年' + ma.course_message.course.term %>)

    -

    作业标题:<%= ma.course_message.name %>

    -

    - 提交截止:<%= ma.course_message.end_time%>  24点 +

    +
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -300,21 +304,18 @@ <%= User.current.show_name %>同学您好! <%= ma.course_message.reviewer_role == 3? "匿名用户" : (ma.course_message.user.show_name + "老师")%><%= ma.status == 0? "评阅了您的作品":"重新评阅了您的作品"%>。详情如下:

    -

    课程名称:<%= ma.course.name %>(<%= ma.course.time.to_s + '年'+ ma.course.term %>)

    -

    作业标题:<%=ma.course_message.student_work.homework_common.name %>

    - <% content = ma.content.gsub("作业评分:","").split("    评语:")%> +

    - 作品评分:<%= content[0] %> -

    - <% if content.size > 1 %> -
    作品评语:
    -
    <%= content[1] %>
    - <% end %> -

    - 本次作业将在<%= ma.course_message.student_work.homework_common.homework_detail_manual.evaluation_end %>  24点结束匿评,到时您将可以看到所有其他同学的作品啦!大家可以进一步互相学习。 -

    -

    - 期待您取得更大的进步! + 本次作业将在<%= ma.course_message.student_work.homework_common.homework_detail_manual.evaluation_end %>  23:59结束匿评,到时您将可以看到所有其他同学的作品啦!大家可以进一步互相学习。 期待您取得更大的进步!

    <% end %> @@ -350,7 +351,7 @@
  • <%= link_to ma.course_message.user.lastname + ma.course_message.user.firstname + - "#{ma.course_message.user.members.where("course_id=?", ma.course.id).first.roles.first.name=='Student'?"同学":"老师"}", + "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"}", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">回复了作品评论:
  • @@ -362,14 +363,14 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -378,12 +379,13 @@ <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %>
    <% end %> @@ -420,10 +427,185 @@

    课程名称:<%= ma.course_message.name %>

    开课学期:<%= ma.course_message.time.to_s + '年' + ma.course_message.term %>

    -
    课程描述:
    -
    <%= ma.course_message.description.html_safe %>
    -

    学时总数:<%= ma.course_message.class_period%>

    +

    课程ID:<%= ma.course_message.id %>

    +

    课程密码:<%= ma.course_message.password %>

    +

    学时总数:<%= ma.course_message.class_period %>

    创建时间:<%= format_time(ma.course_message.created_at) %>

    +

    您可以点击左上角的“配置”按钮,修改课程基本信息,添加及删除课程成员。您也可以把课程ID及密码告诉学生和其他成员,让他们输入ID及密码加入课程。

    + <% if ma.course_message.is_public %> +

    您的课程是公开的,所有人都能访问您的课程。若不想设置为公开,您可以在配置中设置。

    + <% else %> +

    您的课程是私有的,非课程成员不能访问您的课程。如果想设置为公开,您可以在配置中设置。

    + <% end %> + +
  • <%= time_tag(ma.created_at).html_safe %>
  • + + <% end %> + <% if ma.course_message_type == "JoinCourseRequest" %> + + <% end %> + <% if ma.course_message_type == "CourseRequestDealResult" %> + + <% end %> + + + <% if ma.course_message_type == "JoinCourse" and ma.status == 0 %> + + <% end %> + + + <% if ma.course_message_type == "JoinCourse" and ma.status == 1 %> + + <% end %> + + + <% if ma.course_message_type == "RemoveFromCourse" %> + diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb index 9a9bec10d..94890a368 100644 --- a/app/views/users/_user_message_forge.html.erb +++ b/app/views/users/_user_message_forge.html.erb @@ -36,7 +36,7 @@ :onmouseout => "message_titile_hide($(this))" %>