diff --git a/Gemfile b/Gemfile index 660a7ff49..d9f683840 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,7 @@ group :assets do gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', :platforms => :ruby + gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index d4c34ffec..ee623d9ff 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -10,7 +10,7 @@ module Mobile else f[field] end - elsif f.is_a?(::Bid) + elsif f.is_a?(::HomeworkCommon) if f.respond_to?(field) f.send(field) else diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 353108dc7..4ecff7a40 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -23,6 +23,7 @@ class AttachmentsController < ApplicationController before_filter :delete_authorize, :only => [:destroy] before_filter :authorize_global, :only => [:upload] before_filter :authorize_attachment_download1, :only => [:download] + before_filter :has_login #before_filter :login_without_softapplication, only: [:download] accept_api_auth :show, :download, :upload require 'iconv' @@ -79,9 +80,7 @@ class AttachmentsController < ApplicationController if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) - if params[:force] == 'true' - direct_download - else + if params[:preview] == 'true' convered_file = @attachment.diskfile #如果本身不是pdf文件,则先寻找是不是已转换化,如果没有则转化 unless pdf?(convered_file) @@ -96,6 +95,8 @@ class AttachmentsController < ApplicationController else direct_download end + else + direct_download end end else @@ -511,4 +512,8 @@ private format.js end end + + def has_login + render_403 unless User.current.logged? + end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e89f621c8..7302af89d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -60,7 +60,7 @@ class CoursesController < ApplicationController end end - + def join_private_courses respond_to do |format| format.js @@ -73,14 +73,14 @@ class CoursesController < ApplicationController c = cs.edit_course params,@course,User.current @course = c[:course] if @course.errors.full_messages.count <= 0 - respond_to do |format| - format.html { - # render :layout => 'base_courses' - flash[:notice] = l(:notice_successful_update) - redirect_to settings_course_url(@course) - } - format.api { render_api_ok } - end + respond_to do |format| + format.html { + # render :layout => 'base_courses' + flash[:notice] = l(:notice_successful_update) + redirect_to settings_course_url(@course) + } + format.api { render_api_ok } + end else respond_to do |format| format.html { @@ -94,6 +94,9 @@ class CoursesController < ApplicationController def new_join @course = Course.find(params[:object_id]) + respond_to do |format| + format.js + end end # 课程搜索 @@ -305,7 +308,7 @@ class CoursesController < ApplicationController def member ## 有角色参数的才是课程,没有的就是项目 if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) - + @render_file = 'new_member_list' @score_sort_by = "desc" @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @@ -340,8 +343,8 @@ 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)}"; - # 如果是ie11 需要转码 - if(/rv\:11\.0/.match(request.env["HTTP_USER_AGENT"]) != nil) + # 如果是ie 需要转码 + if(/trident/.match(request.env["HTTP_USER_AGENT"]) != nil) filename= URI::encode(filename) end respond_to do |format| @@ -447,24 +450,24 @@ class CoursesController < ApplicationController end else respond_to do |format| - format.html { - # render :layout => 'base_courses' - flash[:notice] = l(:notice_successful_create) - if params[:continue] - redirect_to new_course_url(attrs, :course => '0') - elsif params[:course_continue] - redirect_to new_course_url(:course => '1') - else - redirect_to settings_course_url(@course, :course_type => 1) - end - } - format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) } - end + format.html { + # render :layout => 'base_courses' + flash[:notice] = l(:notice_successful_create) + if params[:continue] + redirect_to new_course_url(attrs, :course => '0') + elsif params[:course_continue] + redirect_to new_course_url(:course => '1') + else + redirect_to settings_course_url(@course, :course_type => 1) + end + } + format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) } + end end end def course - @school_id = params[:school_id] + @school_id = params[:school_id] per_page_option = 10 if @school_id == "0" or @school_id.nil? @courses_all = Course.active.visible. @@ -548,8 +551,8 @@ class CoursesController < ApplicationController def index if !User.current.admin? - render_404 - return + render_404 + return end @course_type = params[:course_type] @school_id = params[:school_id] @@ -598,7 +601,7 @@ class CoursesController < ApplicationController respond_to do |format| format.html { - render :layout => 'base' + render :layout => 'base' } format.atom { courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all @@ -692,24 +695,31 @@ class CoursesController < ApplicationController # 显示老师和助教的活动 # @authors = searchTeacherAndAssistant(@course) @authors = course_all_member(@course) + Dir.glob("#{Rails.root}/app/models/*.rb").sort.each { |file| require file } events = [] - @authors.each do |author| - @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, - :with_subprojects => false, - :author => author.user) + key = "course_events_#{@course.id}".to_sym + if Rails.env.production? && Setting.course_cahce_enabled? + events = Rails.cache.read(key) || [] + end + if events.empty? + @authors.each do |author| + @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, + :with_subprojects => false, + :author => author.user) - @activity.scope_select {|t| has["show_#{t}"]} - # modify by nwb - # 添加私密性判断 - if User.current.member_of_course?(@course)|| User.current.admin? - events += @activity.events(@days, @course.created_at) - else - events += @activity.events(@days, @course.created_at, :is_public => 1) + @activity.scope_select {|t| has["show_#{t}"]} + # modify by nwb + # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? + events += @activity.events(@days, @course.created_at) + else + events += @activity.events(@days, @course.created_at, :is_public => 1) + end end - + Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled? end else - # @author = @course.teacher + # @author = @course.teacher @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, :with_subprojects => false, :author => @author) @@ -827,7 +837,7 @@ class CoursesController < ApplicationController def can_show_course @first_page = FirstPage.find_by_page_type('project') if @first_page.try(:show_course) == 2 - render_404 + render_404 end end @@ -836,7 +846,7 @@ class CoursesController < ApplicationController sql_select = "" if groupid == 0 sql_select = "SELECT members.*,( - SELECT SUM(student_works.final_score) + SELECT AVG(student_works.final_score) FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} @@ -848,7 +858,7 @@ class CoursesController < ApplicationController WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}" else sql_select = "SELECT members.*,( - SELECT SUM(student_works.final_score) + SELECT AVG(student_works.final_score) FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{@course.id} diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 3077c4eca..d5e62127d 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -3,7 +3,8 @@ class HomeworkCommonController < ApplicationController 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] before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment] - caches_action :index + before_filter :member_of_course, :only => [:index] + def index homeworks = @course.homework_commons.order("created_at desc") @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) @@ -29,7 +30,6 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') @homework.homework_detail_manual = @homework_detail_manual - respond_to do |format| format.html end @@ -61,7 +61,6 @@ class HomeworkCommonController < ApplicationController homework.homework_detail_manual = homework_detail_manual if homework.save - expire_action(:controller => 'homework_common', :action => 'index') respond_to do |format| format.html { flash[:notice] = l(:notice_successful_create) @@ -107,7 +106,6 @@ class HomeworkCommonController < ApplicationController render_attachment_warning_if_needed(@homework) if @homework.save && @homework_detail_manual.save - expire_action(:controller => 'homework_common', :action => 'index') respond_to do |format| format.html { flash[:notice] = l(:notice_successful_edit) @@ -127,7 +125,6 @@ class HomeworkCommonController < ApplicationController def destroy if @homework.destroy - expire_action(:controller => 'homework_common', :action => 'index') respond_to do |format| format.html {redirect_to homework_common_index_path(:course => @course.id)} end @@ -207,6 +204,11 @@ class HomeworkCommonController < ApplicationController render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? end + #当前用户是不是课程的成员 + def member_of_course + render_403 unless User.current.member_of_course?(@course) || User.current.admin? + end + def get_assigned_homeworks(student_works, n, index) student_works += student_works student_works[index + 1 .. index + n] diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 32ec3dad2..d8a9d88c3 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,8 +1,8 @@ class PollController < ApplicationController - before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll] + before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll] before_filter :find_container, :only => [:new,:create, :index] before_filter :is_member_of_course, :only => [:index,:show,:poll_result] - before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll,:close_poll] + before_filter :is_course_teacher, :only => [:new,:create,:edit,:update,:destroy,:publish_poll,:republish_poll,:close_poll,:export_poll] include PollHelper def index if @course @@ -360,6 +360,17 @@ class PollController < ApplicationController end end + #导出问卷 + def export_poll + poll_questions = @poll.poll_questions + 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") + } + end + end + private def find_poll_and_course @poll = Poll.find params[:id] @@ -438,4 +449,59 @@ class PollController < ApplicationController end pu end + + #将poll中题目转换为Excel + def poll_to_xls poll_questions + xls_report = StringIO.new + book = Spreadsheet::Workbook.new + sheet1 = book.create_worksheet :name => "poll" + blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 + count_row = 0 + poll_questions.each do |poll_question| + if poll_question.question_type == 1 || poll_question.question_type == 2 + sheet1.row(count_row).default_format = blue + sheet1[count_row,0]= l(:label_poll_question_num,:num => poll_question.question_number) + sheet1[count_row + 1,0] = l(:label_poll_subtotal) + sheet1[count_row + 2,0] = l(:label_poll_proportion) + poll_question.poll_answers.each_with_index do |poll_answer,i| + sheet1[count_row, i + 1] = poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") + sheet1[count_row + 1, i + 1] = poll_answer.poll_votes.count + sheet1[count_row + 2, i + 1] = statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)).to_s + "%" + end + sheet1[count_row + 3,0] = l(:label_poll_valid_commit) + sheet1[count_row + 3,1] = total_answer(poll_question.id) + count_row += 5 + else + sheet1.row(count_row).default_format = blue + sheet1[count_row,0] = l(:label_poll_question_num,:num => poll_question.question_number) + sheet1[count_row,1] = poll_question.question_title + count_row += 1 + poll_question.poll_votes.each do |poll_vote| + sheet1[count_row,0] = poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") + count_row += 1 + end + count_row += 1 + end + end + + sheet1.row(count_row).default_format = blue + sheet1[count_row ,0] = l(:label_bidding_user_studentname) + poll_questions.each_with_index do |poll_question, i| + sheet1[count_row ,i + 1] = poll_question.question_title + end + count_row += 1 + @poll.users.each do |user| + sheet1[count_row ,0] = user.show_name + poll_questions.each_with_index do |poll_question, i| + if poll_question.question_type == 1 || poll_question.question_type == 2 + sheet1[count_row ,i + 1] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") if poll_vote.poll_answer}.join(";") + else + sheet1[count_row ,i + 1] = user.poll_votes.where(:poll_question_id => poll_question.id).map{|poll_vote| poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/ /," ")}.join(";") + end + end + count_row += 1 + end + book.write xls_report + xls_report.string + end end \ No newline at end of file diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 6f4a9f84c..8c5561d74 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -66,7 +66,6 @@ class StudentWorkController < ApplicationController stundet_work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(stundet_work) if stundet_work.save - expire_action(:controller => 'homework_common', :action => 'index') respond_to do |format| format.html { flash[:notice] = l(:notice_successful_create) @@ -122,7 +121,6 @@ class StudentWorkController < ApplicationController def destroy if @work.destroy - expire_action(:controller => 'homework_common', :action => 'index') respond_to do |format| format.html { redirect_to student_work_index_url(:homework => @homework.id) @@ -255,13 +253,13 @@ class StudentWorkController < ApplicationController #是不是当前课程的成员 #当前课程成员才可以看到作品列表 def member_of_course - render_403 unless User.current.member_of_course? @course || User.current.admin? + render_403 unless User.current.member_of_course? @course end #判断是不是当前作品的提交者 #提交者 && (非匿评作业 || 未开启匿评) 可以编辑作品 def author_of_work - render_403 unless (User.current.id == @work.user_id || User.current.admin?) && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 ) + render_403 unless User.current.id == @work.user_id && (@homework.homework_type != 1 || @homework.homework_detail_manual.comment_status == 1 ) end #根据条件过滤作业结果 diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 12fead4f2..71c445dc4 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -24,7 +24,7 @@ class TestController < ApplicationController end @paths = homeworks_attach_path zipfile = ziping homeworks_attach_path - send_file zipfile, :filename => bid.name, + send_file zipfile, :filename => filename_for_content_disposition(bid.name), :type => detect_content_type(zipfile) rescue Errno::ENOENT => e logger.error "[Errno::ENOENT] ===> #{e}" diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 20b855fd8..9ce107f8b 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -219,7 +219,7 @@ class WelcomeController < ApplicationController # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select url = request.original_url.gsub('/','') - if url.include?(Setting.host_course.gsub('/','')) + if url.include?(Setting.url_course.gsub('/','')) if @first_page.show_course == 1 course render :course @@ -228,7 +228,7 @@ class WelcomeController < ApplicationController end return 0 - elsif url.include?(Setting.host_contest.gsub('/','')) + elsif url.include?(Setting.url_contest.gsub('/','')) if @first_page.show_contest == 1 contest render :contest @@ -237,7 +237,7 @@ class WelcomeController < ApplicationController end return 0 - elsif url.include?(Setting.host_user.gsub('/','')) + elsif url.include?(Setting.url_user.gsub('/','')) #redirect_to(:controller => "users", :action => "index") end diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 7eb06d270..53b40942a 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -11,7 +11,7 @@ class ZipdownController < ApplicationController def download if User.current.logged? begin - send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => params[:filename], :type => detect_content_type(params[:file]) + send_file "#{OUTPUT_FOLDER}/#{params[:file]}", :filename => filename_for_content_disposition(params[:filename]), :type => detect_content_type(params[:file]) rescue => e render file: 'public/no_file_found.html' end @@ -59,9 +59,10 @@ class ZipdownController < ApplicationController if homework != nil unless homework.attachments.empty? zipfile = zip_homework_by_user homework - send_file zipfile.file_path, :filename => ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) + - "_" + homework.user.show_name + - "_" + homework.name + ".zip", :type => detect_content_type(zipfile.file_path) if(zipfile) + filename = ((homework.user.user_extensions.nil? || homework.user.user_extensions.student_id.nil?) ? "" : homework.user.user_extensions.student_id) + + "_" + homework.user.show_name + + "_" + homework.name + ".zip" + send_file zipfile.file_path, :filename => filename_for_content_disposition(filename), :type => detect_content_type(zipfile.file_path) if(zipfile) else render file: 'public/no_file_found.html' end diff --git a/app/helpers/activity_notifys_helper.rb b/app/helpers/activity_notifys_helper.rb index 15fc43b54..f2069a2d3 100644 --- a/app/helpers/activity_notifys_helper.rb +++ b/app/helpers/activity_notifys_helper.rb @@ -1,7 +1,6 @@ module ActivityNotifysHelper def get_new_notify_count(container,type) - logger.info('xxoo') - query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=?',container.id,type,User.current.id); + query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=? and is_read=0',container.id,type,User.current.id); return query.count() end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5ae70fd7c..5af4e2038 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2330,4 +2330,11 @@ module ApplicationHelper def cur_user_works_for_homework homework homework.student_works.where("user_id = ?",User.current).first end + + def file_preview_tag(file, html_options={}) + if %w(pdf pptx doc docx xls xlsx).any?{|x| file.filename.downcase.end_with?(x)} + link_to '预览', download_named_attachment_path(file.id, file.filename, preview: true),html_options + end + end + end diff --git a/app/models/activity.rb b/app/models/activity.rb index e871ae735..5ec778641 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -5,4 +5,6 @@ class Activity < ActiveRecord::Base validates :act_id, presence: true validates :act_type, presence: true validates :user_id, presence: true + + include Trustie::Cache::ClearCourseEvent end diff --git a/app/models/bid.rb b/app/models/bid.rb index ccd6198bb..f5cb5a3b7 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -10,158 +10,158 @@ homework_type == 1 文件提交 homework_type == 2 Project提交 =end class Bid < ActiveRecord::Base - Enterprise = 1 - Contest = 2 - Homework = 3 - HomeworkFile = 1 - HomeworkProject = 2 - attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password - include Redmine::SafeAttributes - include ApplicationHelper - has_many_kindeditor_assets :assets, :dependent => :destroy - belongs_to :author, :class_name => 'User', :foreign_key => :author_id - belongs_to :course - has_many :biding_projects, :dependent => :destroy - has_many :projects, :through => :biding_projects - has_many :courses_member, :class_name => 'User', :through => :courses - has_many :journals_for_messages, :as => :jour, :dependent => :destroy - has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy - has_many :homework_for_courses, :dependent => :destroy - has_many :courses, :through => :homework_for_courses, :source => :course - has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy - has_many :homework_evaluations, :through => :homeworks - has_many :join_in_contests, :dependent => :destroy - has_many :praise_tread, as: :praise_tread_object, dependent: :destroy - # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" - acts_as_attachable - - NAME_LENGTH_LIMIT = 60 - DESCRIPTION_LENGTH_LIMIT = 3000 - validates :name, length: {maximum: NAME_LENGTH_LIMIT}, presence: true - validates :description, length: {maximum: DESCRIPTION_LENGTH_LIMIT} - validates :author_id, presence: true - validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/} - validates :name, length: {maximum: NAME_LENGTH_LIMIT} - validates :budget, format: { with: ->(p) { if p.reward_type == 1 then /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/ - elsif p.reward_type == 3 then /^(\d+)$|^(\d+).([0-9]{1})$/ end } } - - validate :validate_user - validate :validate_reward_type - after_create :act_as_activity - after_destroy :delete_kindeditor_assets - scope :visible, lambda {|*args| - nil - } - - scope :like, lambda {|arg| - if arg.blank? - where(nil) - else - pattern = "%#{arg.to_s.strip.downcase}%" - where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern) - end - } - - scope :course_visible, lambda {|*args| - includes(:courses).where(Course.allowed_to_condition(args.shift || User.current, :view_homeworks, *args)) - } - - acts_as_watchable - acts_as_taggable - - acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, - :description => :description, - :author => :author, - :url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}} - - acts_as_activity_provider :type => 'homeworks', - :author_key => :author_id - - acts_as_activity_provider :find_options => {:include => [:projects, :author]}, - :author_key => :author_id - - safe_attributes 'name', - 'description', - 'budget', - 'deadline', - 'homework_type', - 'reward_type', - 'password' - - + # Enterprise = 1 + # Contest = 2 + # Homework = 3 + # HomeworkFile = 1 + # HomeworkProject = 2 + # attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password + # include Redmine::SafeAttributes + # include ApplicationHelper + # has_many_kindeditor_assets :assets, :dependent => :destroy + # belongs_to :author, :class_name => 'User', :foreign_key => :author_id + # belongs_to :course + # has_many :biding_projects, :dependent => :destroy + # has_many :projects, :through => :biding_projects + # has_many :courses_member, :class_name => 'User', :through => :courses + # has_many :journals_for_messages, :as => :jour, :dependent => :destroy + # has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + # has_many :homework_for_courses, :dependent => :destroy + # has_many :courses, :through => :homework_for_courses, :source => :course + # has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy + # has_many :homework_evaluations, :through => :homeworks + # has_many :join_in_contests, :dependent => :destroy + # has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + # # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" + # acts_as_attachable + # + # NAME_LENGTH_LIMIT = 60 + # DESCRIPTION_LENGTH_LIMIT = 3000 + # validates :name, length: {maximum: NAME_LENGTH_LIMIT}, presence: true + # validates :description, length: {maximum: DESCRIPTION_LENGTH_LIMIT} + # validates :author_id, presence: true + # validates :deadline, presence: true, format: {:with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/} + # validates :name, length: {maximum: NAME_LENGTH_LIMIT} + # validates :budget, format: { with: ->(p) { if p.reward_type == 1 then /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/ + # elsif p.reward_type == 3 then /^(\d+)$|^(\d+).([0-9]{1})$/ end } } + # + # validate :validate_user + # validate :validate_reward_type + # after_create :act_as_activity + # after_destroy :delete_kindeditor_assets + # scope :visible, lambda {|*args| + # nil + # } + # + # scope :like, lambda {|arg| + # if arg.blank? + # where(nil) + # else + # pattern = "%#{arg.to_s.strip.downcase}%" + # where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern) + # end + # } + # + # scope :course_visible, lambda {|*args| + # includes(:courses).where(Course.allowed_to_condition(args.shift || User.current, :view_homeworks, *args)) + # } + # + # acts_as_watchable + # acts_as_taggable + # + # acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, + # :description => :description, + # :author => :author, + # :url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}} + # + # acts_as_activity_provider :type => 'homeworks', + # :author_key => :author_id + # + # acts_as_activity_provider :find_options => {:include => [:projects, :author]}, + # :author_key => :author_id + # # safe_attributes 'name', - # 'description', - # 'deadline' - def add_jour(user, notes, reference_user_id = 0, options = {}) - if options.count == 0 - jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) - self.journals_for_messages << jfm - jfm - else - jfm = self.journals_for_messages.build(options) - jfm.save - jfm - end - end - - def self.creat_bids(budget, deadline, name, description=nil, reward_type) - self.create(:author_id => User.current.id, :budget => budget, - :deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type) - # self.acts << Activity.new(:user_id => self.author_id) - end - - def update_bids(budget, deadline, name, description=nil) - if(User.current.id == self.author_id) - self.name = name - self.budget = budget - self.deadline = deadline - self.description = description - self.save - end - end - - def delete_bids - unless self.nil? - if User.current.id == self.author_id - self.destroy - end - end - end - - def set_commit(commit) - self.update_attribute(:commit, commit) - end - - private - - def validate_user - errors.add :author_id, :invalid if author.nil? || !author.active? - end - - def validate_reward_type - errors.add :reward_type, :invalid if self.reward_type == 0 - end - - def act_as_activity - self.acts << Activity.new(:user_id => self.author_id) - end - - # used to validate weather the user is the creater of the bid - # added by william - def validate_bid_manager(user_id) - unless user_id.nil? - if self.author_id == user_id - return true - else - return false - end - end - end - - # Time 2015-04-01 14:19:06 - # Author lizanle - # Description 删除对应课程通知的图片资源 - def delete_kindeditor_assets - delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::BID - end + # 'description', + # 'budget', + # 'deadline', + # 'homework_type', + # 'reward_type', + # 'password' + # + # + # # safe_attributes 'name', + # # 'description', + # # 'deadline' + # def add_jour(user, notes, reference_user_id = 0, options = {}) + # if options.count == 0 + # jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id) + # self.journals_for_messages << jfm + # jfm + # else + # jfm = self.journals_for_messages.build(options) + # jfm.save + # jfm + # end + # end + # + # def self.creat_bids(budget, deadline, name, description=nil, reward_type) + # self.create(:author_id => User.current.id, :budget => budget, + # :deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type) + # # self.acts << Activity.new(:user_id => self.author_id) + # end + # + # def update_bids(budget, deadline, name, description=nil) + # if(User.current.id == self.author_id) + # self.name = name + # self.budget = budget + # self.deadline = deadline + # self.description = description + # self.save + # end + # end + # + # def delete_bids + # unless self.nil? + # if User.current.id == self.author_id + # self.destroy + # end + # end + # end + # + # def set_commit(commit) + # self.update_attribute(:commit, commit) + # end + # + # private + # + # def validate_user + # errors.add :author_id, :invalid if author.nil? || !author.active? + # end + # + # def validate_reward_type + # errors.add :reward_type, :invalid if self.reward_type == 0 + # end + # + # def act_as_activity + # self.acts << Activity.new(:user_id => self.author_id) + # end + # + # # used to validate weather the user is the creater of the bid + # # added by william + # def validate_bid_manager(user_id) + # unless user_id.nil? + # if self.author_id == user_id + # return true + # else + # return false + # end + # end + # end + # + # # Time 2015-04-01 14:19:06 + # # Author lizanle + # # Description 删除对应课程通知的图片资源 + # def delete_kindeditor_assets + # delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::BID + # end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index e94a29867..6b75552c0 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -19,4 +19,5 @@ class ForgeActivity < ActiveRecord::Base validates :project_id,presence: true validates :forge_act_id,presence: true validates :forge_act_type, presence: true + end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index b15c9b2d1..5b4a06ad2 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -23,10 +23,11 @@ class JournalsForMessage < ActiveRecord::Base :foreign_key => 'jour_id', :conditions => "#{self.table_name}.jour_type = 'Project' " belongs_to :course, - :foreign_key => 'jour_id' + :foreign_key => 'jour_id', :touch => true belongs_to :jour, :polymorphic => true + belongs_to :m_parent,:class_name => 'JournalsForMessage',:foreign_key => 'm_parent_id', :touch => true belongs_to :user belongs_to :homework_attach belongs_to :student_works_score diff --git a/app/models/mailer.rb b/app/models/mailer.rb index ec46917d9..8488fc1d0 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -103,7 +103,7 @@ class Mailer < ActionMailer::Base course_ids = courses.map {|course| course.id}.join(",") # 查询user的缺陷,项目中成员都能收到 - sql = "select * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}' + sql = "select DISTINCT * from members m, issues i where i.project_id = m.project_id and m.user_id='#{user.id}' and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc" @issues = Issue.find_by_sql(sql) @@ -125,21 +125,35 @@ class Mailer < ActionMailer::Base # user 提交的作业 # @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") - # 查询user在课程。项目中发布的讨论帖子 - messages = Message.find_by_sql("select me.* from messages me, boards b, members m where - b.id = me.board_id and b.project_id = m.project_id and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + # 查询user所在项目添加wiki + @wiki_contents = WikiContent.find_by_sql("select DISTINCT wc.* from wikis w, members m, projects p, wiki_pages wp, wiki_contents wc where + m.user_id = '#{user.id}' and m.project_id = p.id and w.project_id = p.id and w.id = wp.wiki_id and wc.page_id = wp.id and w.project_id>0 + and (wc.updated_on between '#{date_from}' and '#{date_to}') order by updated_on desc") + + # 查询user在课程中发布的讨论帖子 + course_mesages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where + b.id = me.board_id and b.course_id = m.course_id + and b.course_id is not Null and m.user_id = '#{user.id}' + and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + + # 查询user在项目中发布的讨论帖子 + project_messages = Message.find_by_sql("select DISTINCT me.* from messages me, boards b, members m where + b.id = me.board_id and b.project_id = m.project_id + and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") @course_messages ||= [] @project_messages ||= [] - unless messages.first.nil? - messages.each do |msg| - if msg.project - @project_messages << msg - elsif msg.course - @course_messages << msg - end + unless course_mesages.first.nil? + course_mesages.each do |msg| + @course_messages << msg end end + unless project_messages.first.nil? + project_messages.each do |msg| + @project_messages << msg + end + end + # wiki # 查询user在课程中发布的通知,项目中发的新闻 @course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n @@ -149,17 +163,24 @@ class Mailer < ActionMailer::Base and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : [] # 查询user在课程及个人中留言 - @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where - jour_type='Course' and user_id = #{user.id} - and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") - @user_journal_messages = user.journals_for_messages.where("m_parent_id IS NULL and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC') + @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, courses c + where m.user_id = '#{user.id}' and c.id = m.course_id and jfm.jour_id = c.id + and jfm.jour_type='Course' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + + @user_journal_messages = user.journals_for_messages.where("jour_type='Principal' and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC') + + # 查询user在项目中留言(用户反馈) + @project_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT jfm.* from journals_for_messages jfm, members m, projects p + where m.user_id = '#{user.id}' and p.id = m.project_id and jfm.jour_id = p.id + and jfm.jour_type='Project' and (jfm.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") + # 查询user新建贴吧或发布帖子 @forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc") @memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id})) and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc") has_content = [@issues,@course_messages,@project_messages,@course_news,@project_news, - @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty?} + @course_journal_messages,@user_journal_messages,@project_journal_messages,@forums,@memos,@attachments,@bids,@wiki_contents].any? {|o| !o.empty?} mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 mail :to => user.mail,:subject => subject if has_content diff --git a/app/models/member.rb b/app/models/member.rb index 2936392ab..057ea9570 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -116,21 +116,33 @@ class Member < ActiveRecord::Base # 查找每个学生每个作业的评分 def student_homework_score - score_count = 0 homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score FROM student_works,homework_commons WHERE student_works.homework_common_id = homework_commons.id AND homework_commons.course_id = #{self.course_id} AND student_works.user_id = #{self.user_id}") - homework_score.each do |homework| - mem_score = 0 - if homework[:score] - mem_score = homework[:score] - end - score_count = score_count + mem_score - end + score_count = StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f [homework_score, format("%0.2f", score_count)] end + + def student_work_score + StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}") + end + + #当前课程的作业列表 + def homework_common_list + HomeworkCommon.where(:course_id => self.course_id) + end + + #当前学生在指定作业内的得分 + def homework_common_score homework_common + StudentWork.select("final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id) + end + + def student_work_score_avg + StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f + end + protected def validate_role diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 49170bf30..d4a197aff 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -330,7 +330,7 @@ class CoursesService def homework_list params,current_user course = Course.find(params[:id]) if course.is_public != 0 || current_user.member_of_course?(course) - bids = course.homeworks.order('deadline DESC') + bids = course.homework_commons.order('end_time DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] bids.each do |bid| @@ -375,9 +375,9 @@ class CoursesService unless latest_attachment.nil? latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message =>latest_attachment.author.realname<< l(:label_recently_updated_courseware,:locale => get_user_language(current_user))<<":"< 4,:time => latest_bid.updated_on,:message => latest_bid.author.realname< get_user_language(current_user))<<":"< 4,:time => latest_bid.updated_at,:message => latest_bid.user.realname< get_user_language(current_user))<<":"< order.created_on} - end - latest_bid_message = messages.first - unless latest_bid_message.nil? - latest_course_dynamics << {:type => 4,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))} - end + # messages = [] + # course.homework_commons.each do |hc| + # jour = hc.journals_for_messages.order("created_on desc").first + # unless jour.nil? + # messages << jour + # end + # end + # unless messages.count == 0 + # messages.sort!{|order,newer| newer.created_on <=> order.created_on} + # end + # latest_bid_message = messages.first + # unless latest_bid_message.nil? + # latest_course_dynamics << {:type => 4,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))} + # end #每个作业中学生最后提交的作业 homeworks = [] - course.homeworks.each do |bid| - homework_attach = bid.homeworks.order('updated_at DESC').first + course.homework_commons.each do |bid| + homework_attach = bid.student_works.order('updated_at DESC').first unless homework_attach.nil? homeworks << homework_attach end @@ -533,21 +533,21 @@ class CoursesService mems end def show_homework_info course,bid,current_user,is_course_teacher - author_real_name = bid.author.lastname + bid.author.firstname - many_times = course.homeworks.index(bid) + 1 + author_real_name = bid.user.lastname + bid.user.firstname + many_times = course.homework_commons.index(bid) + 1 name = bid.name - homework_count = bid.homeworks.count #已提交的作业数量 - student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count + homework_count = bid.student_works.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 - state = bid.comment_status + state = bid.homework_detail_manual.comment_status unless is_course_teacher homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user end #end - open_anonymous_evaluation = bid.open_anonymous_evaluation - {:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.author,:author_real_name => author_real_name, :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,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_on,:deadline => bid.deadline} + open_anonymous_evaluation = bid.homework_detail_manual.comment_status + {:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.user,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => 0, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_at,:deadline => bid.end_time} end diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index 2e7f59888..2a2c6613c 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -14,21 +14,21 @@ class HomeworkService # state=1 关闭匿评 # state=2 匿评结束 def show_homework params - @bid = Bid.find(params[:id]) - course = @bid.courses.first - author = @bid.author.lastname + @bid.author.firstname - many_times = course.homeworks.index(@bid) + 1 + @bid = HomeworkCommon.find(params[:id]) + course = @bid.course + author = @bid.user.lastname + @bid.user.firstname + many_times = course.homework_commons.index(@bid) + 1 name = @bid.name - homework_count = @bid.homeworks.count #已提交的作业数量 - student_questions_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count + homework_count = @bid.student_works.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 - state = @bid.comment_status + state = @bid.homework_detail_manual.comment_status #end - open_anonymous_evaluation = @bid.open_anonymous_evaluation - jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - {:course_name => course.name,:course_id => course.id,:id => @bid.id, :author => @bid.author,:author_real_name =>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,:created_on => @bid.created_on,:deadline => @bid.deadline,:jours => jours} + open_anonymous_evaluation = @bid.homework_type + #jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + {:course_name => course.name,:course_id => course.id,:id => @bid.id, :author => @bid.user,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => 0, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:created_on => @bid.created_at,:deadline => @bid.end_time,:jours => nil} end # 启动作业匿评前提示信息 diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb index ab5cdd484..846d2a61d 100644 --- a/app/views/applied_project/applied_join_project.js.erb +++ b/app/views/applied_project/applied_join_project.js.erb @@ -1,9 +1,11 @@ +// @status: 0 该项目不存在;1 不重复加入;2 成功加入; 3 已是项目成员;其它 加入失败 <% if @status == 0%> alert("<%= l('project.join.tips.notexist') %>"); <% elsif @status == 1%> alert("<%= l('project.join.tips.repeat') %>"); <% elsif @status == 2%> alert("<%= l('project.join.tips.success') %>"); + hideModal($("#popbox")); <% elsif @status == 3%> alert("<%= l('project.join.tips.has') %>"); <%else%> diff --git a/app/views/attachments/_course_file_links.html.erb b/app/views/attachments/_course_file_links.html.erb index d32025787..e651c0a93 100644 --- a/app/views/attachments/_course_file_links.html.erb +++ b/app/views/attachments/_course_file_links.html.erb @@ -53,7 +53,7 @@ <% end %> <% if options[:author] %> - <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>, + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "author_name" %>, <%= format_time(attachment.created_on) %> <% end %> diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 845e2b6a0..3dbc8d8ba 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -1,11 +1,13 @@ +
<% 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) %>: + <%= 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? #待补充代码 diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index fe0e9ab97..b6d934c64 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -29,7 +29,7 @@ <% is_float ||= false %> <% for attachment in attachments %>
-

+

<%if is_float%>

<% end%> diff --git a/app/views/bids/_fork_form.html.erb b/app/views/bids/_fork_form.html.erb deleted file mode 100644 index 7a7010794..000000000 --- a/app/views/bids/_fork_form.html.erb +++ /dev/null @@ -1,25 +0,0 @@ - -<%= error_messages_for 'bid' %> - -

<%= l(:label_fork_form_new_description) %>

- - -

<%= l(:label_choose_course) %><%= select_tag 'course', course_options_for_select(@courses) %>

-

<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :value => @bid.name %>

- - -

-<%= f.text_area :description, :rows => 8, :value => @bid.description, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT %>

- -

<%= f.text_field :deadline, :value => nil,:required => true, :size => 60, :style => "width:150px;" , :readonly => true %><%= calendar_for('bid_deadline')%> - -

<%= f.select :is_evaluation, is_evaluation_option %> -

<%= l(:label_attachment_plural) %> -

<%= render :partial => 'attachments/form', :locals => {:container => @homework} %>

-
\ No newline at end of file diff --git a/app/views/bids/_form_contest.html.erb b/app/views/bids/_form_contest.html.erb deleted file mode 100644 index ccd16f15e..000000000 --- a/app/views/bids/_form_contest.html.erb +++ /dev/null @@ -1,36 +0,0 @@ - - -<%= error_messages_for 'bid' %> - -

<%= l(:label_bids_form_contest_new_description) %>

-

<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_name)}" %>

- -

<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_description)}" %>

- -

<%= f.text_field :password, :size => 60, :style => "width:488px;margin-left: 10px;" %>

- -

- <%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %> - - -

- -

<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :readonly => true, :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('bid_deadline')%>

diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb index 37121d720..da3d19267 100644 --- a/app/views/bids/edit.html.erb +++ b/app/views/bids/edit.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> <%= labelled_form_for @bid,:html => { :multipart => true } do |f| %> <%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}",:f=>f,:edit_mode => true} %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/bids/show_bid_user.html.erb b/app/views/bids/show_bid_user.html.erb deleted file mode 100644 index f4d7b2642..000000000 --- a/app/views/bids/show_bid_user.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -
- <% for user in @bid.watcher_users %> -
  • - - - - - -
    <%= image_tag(url_to_avatar(user), :class => "avatar") %> - - - - - - - - - -
    <%= content_tag "div", link_to_user(user), :class => "project_avatar_name" %> -

    - <% unless user.memberships.empty? %> - <%= l(:label_x_contribute_to, :count => user.memberships.count) %> - <% for member in user.memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% end %> -

    <%= l(:label_user_joinin) %><%= format_date(user.created_on) %> -
-<% end %> -
\ No newline at end of file diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 48e5a870d..7eed593d9 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -66,7 +66,31 @@
@@ -92,7 +116,7 @@
-