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/activity_notifys_controller.rb b/app/controllers/activity_notifys_controller.rb index c696836b2..01e4260ea 100644 --- a/app/controllers/activity_notifys_controller.rb +++ b/app/controllers/activity_notifys_controller.rb @@ -15,11 +15,10 @@ class ActivityNotifysController < ApplicationController end if( query != nil ) - logger.info('xxoo') limit = 10; @obj_count = query.count(); @obj_pages = Paginator.new @obj_count,limit,params['page'] - list = query.order('id desc').limit(limit).offset(@obj_pages.offset).all(); + list = query.order('is_read,id desc').limit(limit).offset(@obj_pages.offset).all(); events=[]; for item in list event = item.activity; @@ -29,7 +28,6 @@ class ActivityNotifysController < ApplicationController end @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} @controller_name = 'ActivityNotifys' - logger.info('aavv') end respond_to do |format| format.html {render :template => 'courses/show', :layout => 'base_courses'} diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index c310087f7..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' @@ -62,6 +63,16 @@ class AttachmentsController < ApplicationController render :action => 'file' end + def pdf?(file) + file.downcase.end_with?(".pdf") + end + + def direct_download + send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), + :type => detect_content_type(@attachment), + :disposition => 'attachment' #inline can open in browser + end + def download # modify by nwb # 下载添加权限设置 @@ -69,20 +80,30 @@ class AttachmentsController < ApplicationController if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) - convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html") - if File.exist?(convered_file) - send_file convered_file, :type => 'text/html; charset=utf-8', :disposition => 'inline' + if params[:preview] == 'true' + convered_file = @attachment.diskfile + #如果本身不是pdf文件,则先寻找是不是已转换化,如果没有则转化 + unless pdf?(convered_file) + convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".pdf") + unless File.exist?(convered_file) + office = Trustie::Utils::Office.new(@attachment.diskfile) + office.conver(convered_file) + end + end + if File.exist?(convered_file) && pdf?(convered_file) + send_file convered_file, :type => 'application/pdf; charset=utf-8', :disposition => 'inline' + else + direct_download + end else - send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'attachment' #inline can open in browser + direct_download end end else render_403 :message => :notice_not_authorized end rescue => e - redirect_to "http: //" + (Setting.host_name.to_s) +"/file_not_found.html" + redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" end #更新资源文件类型 @@ -196,13 +217,13 @@ class AttachmentsController < ApplicationController if @attachment.container.is_a?(News) format.html { redirect_to_referer_or news_path(@attachment.container) } elsif @attachment.container.is_a?(StudentWorksScore) - @is_destroy = true #根据ID删除页面对应的数据,js刷新页面 + @is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据,js刷新页面 format.js elsif @attachment.container.is_a?(HomeworkCommon) - @is_destroy = true #根据ID删除页面对应的数据,js刷新页面 + @is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据,js刷新页面 format.js elsif @attachment.container.is_a?(StudentWork) - @is_destroy = true #根据ID删除页面对应的数据,js刷新页面 + @is_destroy = true unless params[:attachment_id] #根据ID删除页面对应的数据,js刷新页面 format.js elsif @attachment.container.is_a?(Message) format.html { redirect_to_referer_or new_board_message_path(@attachment.container) } @@ -226,7 +247,7 @@ class AttachmentsController < ApplicationController end format.js - end + end end def delete_homework @@ -491,4 +512,8 @@ private format.js end end + + def has_login + render_403 unless User.current.logged? + end end diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 35236414f..aa1c369a0 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -1,1096 +1,1097 @@ -# fq -class BidsController < ApplicationController - #Added by young - menu_item l(:label_homework), :only => [:edit, :udpate] - menu_item :respond - menu_item :course, :only => :show_courseEx - menu_item :project, :only => [:show_project,:show_results, :new_submit_homework] - menu_item :homework_respond, :only => :homework_respond - menu_item :homework_statistics, :only => :homework_statistics - menu_item :edit, :only => :edit - - before_filter :auth_login1, :only => [:show_courseEx] - - before_filter :can_show_course,only: [] - before_filter :can_show_contest,only: [] - #Ended by young - before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, - :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] - # added by fq - before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] - # end - before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ] - - #before_filter :memberAccess, only: :show_project - - helper :watchers - helper :attachments - include AttachmentsHelper - include ApplicationHelper - include BidsHelper - - helper :projects - helper :words - helper :welcome - helper :project_score - - def find_project_by_bid_id - @bid = Bid.find(params[:id]) - @project = @bid.courses[0] - rescue ActiveRecord::RecordNotFound - render_404 - end - - def homework_ajax_modal - @bid = Bid.find_by_id(params[:id]) - # find_bid - respond_to do |format| - format.js - end - end - - - def index - @project_type = params[:project_type] - # Modified by nie - # @requirement_title = "4" - @offset, @limit = api_offset_and_limit({:limit => 10}) - if @project_type == '1' - @bids = Bid.visible.where('reward_type = ?', 3) - # elsif - # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) - else - @bids = Bid.visible.where('reward_type = ?', 1) - end - - @bids = @bids.like(params[:name]) if params[:name].present? - @bid_count = @bids.count - @bid_pages = Paginator.new @bid_count, @limit, params['page'] - - @offset ||= @bid_pages.reverse_offset - #added by nie - if params[:bid_sort_type].present? - case params[:bid_sort_type] - when '0' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(limit).all.reverse - end - @s_state = 0 - when '1' - unless @offset == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 - when '2' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - end - @s_state = 0 - end - else - unless @offset == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 - end - #end - end - #huang - def contest - - # Modified by nie - # @requirement_title = "4" - @offset, @limit = api_offset_and_limit({:limit => 10}) - - @bids = Bid.visible.where('reward_type = ?', 2) - - # elsif - # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) - @bids = @bids.like(params[:name]) if params[:name].present? - @bid_count = @bids.count - @bid_pages = Paginator.new @bid_count, @limit, params['page'] - - @offset ||= @bid_pages.reverse_offset - #added by nie - if params[:contest_sort_type].present? - case params[:contest_sort_type] - when '0' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(limit).all.reverse - end - @s_state = 0 - when '1' - unless @offset == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 - when '2' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - end - @s_state = 0 - end - else - unless @offset == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 - end - #end - end - - def fork - @courses = [] - @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) - @membership.each do |membership| - if membership.project.project_type == 1 - @courses << membership.project - end - end - end - - #将某个企业外包需求选为作业,目前此功能已放弃 - def create_fork - @homework = Bid.new - @homework.name = params[:bid][:name] - @homework.description = params[:bid][:description] - @homework.reward_type = 3 - # @bid.budget = params[:bid][:budget] - @homework.deadline = params[:bid][:deadline] - @homework.budget = 0 - @homework.author_id = User.current.id - @homework.commit = 0 - @homework.homework_type = 1 - @homework.is_evaluation = params[:bid][:is_evaluation] - @homework.parent_id = @bid.id - @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - # @bid. - if @homework.save - HomeworkForCourse.create(:course_id => params[:course], :bid_id => @homework.id) - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to course_for_bid_path(@homework) - else - @bid.safe_attributes = params[:bid] - @courses = [] - @membership = User.current.coursememberships.all#(:conditions => Project.visible_condition(User.current)) - @membership.each do |membership| - @courses << membership.course - end - render :action => 'fork' - end - end - - #有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认 - def show - @user = @bid.author - @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - @limit = 10 - @feedback_count = @jours.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - @offset ||= @feedback_pages.offset - @jour = @jours[@offset, @limit] - @state = false - - respond_to do |format| - layout_file = '' - case @bid.reward_type - when 3 - html_title(l(:label_question_student)) - layout_file = 'base_homework' - when 1 - layout_file = 'base_bids' - else - layout_file = 'base_contest' - end - format.html { - render :layout => layout_file - } - format.api - end - end - - def join_in_contest - if @bid.reward_type == 2 && params[:course_password] == @bid.password - JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id) - @state = 0 - else - @state = 1 - end - respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } - end - end - - def unjoin_in_contest - joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id) - joined.each do |join| - join.delete - end - respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } - end - end - - def new_join - - end - - # added by bai 增加了参与者和竞赛设置 - def show_participator - render :layout => 'base_contest' - end - - #配置竞赛 - def settings - if @bid.author.id == User.current.id - if @bid.reward_type == 2 - @contest = Bid.find_by_reward_type(@bid.reward_type) - render :layout => 'base_contest' - end - else - render_403 :message => :notice_not_contest_setting_authorized - end - end - #end - - # 显示课程作业,但是好像已经废弃 - def show_course - bids = Bid.where('parent_id = ?', @bid.id) - @courses = [] - for bid in bids - @courses << bid.courses.first - end - - respond_to do |format| - if @bid.reward_type == 3 - format.html { - render :layout => 'base_homework' - } - elsif @bid.reward_type == 1 - format.html { - render :layout => 'base_bids' - } - else - format.html { - render :layout => 'base_contest' - } - end - format.api - - end - end - - def show_bid_project - bids = Bid.where('parent_id = ?', @bid.id) - @projects = [] - for bid in bids - @projects += bid.biding_projects - end - - respond_to do |format| - if @bid.reward_type == 3 - format.html { - render :layout => 'base_homework' - } - elsif @bid.reward_type == 1 - format.html { - render :layout => 'base_bids' - } - else - format.html { - render :layout => 'base_contest' - } - end - format.api - - end - end - - def show_bid_user - bids = Bid.where('parent_id = ?', @bid.id) - @users = [] - for bid in bids - for project in bid.projects - @users += project.users - end - end - - respond_to do |format| - if @bid.reward_type == 3 - format.html { - render :layout => 'base_homework' - } - elsif @bid.reward_type == 1 - format.html { - render :layout => 'base_bids' - } - else - format.html { - render :layout => 'base_contest' - } - end - format.api - - end - end - - def show_project - # flash[:notice] = "" - @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) - @option = [] - @membership.each do |membership| - unless(membership.project.project_type==1) - if membership.user.allowed_to?(:quote_project,membership.project) - @option << membership.project - end - end - end - - # a = [1] - # @project = Project.where("id in []", a) - @user = @bid.author - @bidding_project = @bid.biding_projects.all - if params[:student_id].present? - @temp = [] - @bidding_project.each do |pro| - if pro.project && pro.project.project_status - if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id - @temp << pro - end - end - @temp - end - @bidding_project = @temp - else - #added by nie - @temp = [] - @bidding_project.each do |pro| - if pro.project && pro.project.project_status - @temp << pro - end - @temp - end - if @temp.size > 0 - @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} - end - #ended - end - - if @bid.homework_type == 1 - @homework = HomeworkAttach.new - #@homework_list = @bid.homeworks - #增加作业按评分排序, - @homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") - if params[:student_id].present? - @temp = [] - @homework_list.each do |pro| - if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id - @temp << pro - end - @temp - end - @homework_list = @temp - end - end - - respond_to do |format| - if @bid.reward_type == 3 - format.html { - render :layout => 'base_homework' - } - elsif @bid.reward_type == 1 - format.html { - render :layout => 'base_bids' - } - else - format.html { - render :layout => 'base_contest' - } - end - format.api - end - end - - # 显示作业课程 - # add by nwb - def show_courseEx - - if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?)) - @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current)) - @user = @bid.author - @bidding_project = @bid.biding_projects.all - - if params[:student_id].present? - @temp = [] - @bidding_project.each do |pro| - if pro.project && pro.project.project_status - if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id - @temp << pro - end - end - @temp - end - @bidding_project = @temp - else - #added by nie - @temp = [] - @bidding_project.each do |pro| - if pro.project && pro.project.project_status - @temp << pro - end - @temp - end - if @temp.size > 0 - @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} - end - #ended - end - - if @bid.homework_type - @homework = HomeworkAttach.new - @is_teacher = is_course_teacher(User.current,@bid.courses.first) - if @is_teacher - all_homework_list = HomeworkAttach.find_by_sql("SELECT * FROM (SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score - FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1 - WHERE table1.t_score IS NULL") - @not_batch_homework = true - @cur_type = 1 - else - all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, - (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, - (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = #{@is_teacher ? 1 : 0}) AS m_score - FROM homework_attaches - INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id - WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC") - @is_student_batch_homework = true - @cur_type = 4 - end - - @cur_page = params[:page] || 1 - # @homework_list = paginateHelper all_homework_list,10 - @homework_list = all_homework_list - @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count - if params[:student_id].present? - @temp = [] - @homework_list.each do |pro| - if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id - @temp << pro - end - @temp - end - @homework_list = @temp - end - end - - respond_to do |format| - if @bid.reward_type == 3 - format.html { - html_title(l(:label_homework_info)) - render :layout => 'base_homework' - } - elsif @bid.reward_type == 1 - format.html { - render :layout => 'base_bids' - } - else - format.html { - render :layout => 'base_contest' - } - end - format.api - end - else - render_403 :message => :notice_not_authorized - end - end - - ##### by huang - def show_project_homework - # flash[:notice] = "" - @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) - @option = [] - @membership.each do |membership| - end - # a = [1] - # @project = Project.where("id in []", a) - @user = @bid.author - @bidding_project = @bid.biding_projects - respond_to do |format| - if @bid.reward_type == 3 - format.html { - render :layout => 'base_homework' - } - elsif @bid.reward_type == 1 - format.html { - render :layout => 'base_bids' - } - else - format.html { - render :layout => 'base_contest' - } - end - format.api - end - end - - ###添加应标项目 - def add - project = Project.find(params[:bid]) - bid_message = params[:bid_for_save][:bid_message] - if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0 - if BidingProject.cerate_bidding(@bid.id, project.id, bid_message) - - # added by bai type ==1 需求,type==2 竞赛, type==3 作业 - if @bid.reward_type == 1 - flash.now[:notice] = l(:label_bidding_succeed) - - elsif @bid.reward_type == 2 - flash.now[:notice] = l(:label_bidding_contest_succeed) - - else @bid.reward_type == 3 - flash.now[:notice] = l(:label_bidding_homework_succeed) - end - # end - - end - else - if @bid.reward_type == 3 - flash.now[:error] = l(:label_bidding_homework_fail) - else - flash.now[:error] = l(:label_bidding_fail) - end - end - @bidding_project = @bid.biding_projects - respond_to do |format| - # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} - # format.html - format.html { redirect_to :back } - format.js - #format.api { render_api_ok } - end - end - - #删除已提交的项目作业(不删项目) - def delete - binding_project = params[:binding_project] - if can_delete_project_homework(BidingProject.find(binding_project),User.current) - if BidingProject.delete(binding_project) - redirect_to project_for_bid_url - else - render_403; - end - end - end - ## 新建留言 - def create - - if params[:bid_message][:message].size>0 - if params[:reference_content] - message = params[:bid_message][:message] + "\n" + params[:reference_content] - else - message = params[:bid_message][:message] - @m = message - end - refer_user_id = params[:bid_message][:reference_user_id].to_i - @bid.add_jour(User.current, message, refer_user_id) - end - @user = @bid.author - @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - @jour = paginateHelper @jours,10 - @bid.set_commit(@feedback_count) - respond_to do |format| - format.js - #format.api { render_api_ok } - end - - end - - ##删除留言 - def destroy - @user = @bid.author - if User.current.admin? || User.current.id == @user.id - JournalsForMessage.delete_message(params[:object_id]) - end - @jours = @bid.journals_for_messages.reverse - @limit = 10 - @feedback_count = @jours.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] - @offset ||= @feedback_pages.offset - @jour = @jours[@offset, @limit] - - @bid.set_commit(@feedback_count) - # if a_message.size > 5 - # @message = a_message[-5, 5] - # else - # @message = a_message - # end - # @message_count = a_message.count - - respond_to do |format| - # format.html - format.js - #format.api { render_api_ok } - end - end - - #删除作业 - #by xianbo - def homework_destroy - @bid_to_destroy = Bid.find params[:id] - course_url = course_homework_path(@bid_to_destroy.courses.first) - (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id - @bid_to_destroy.destroy - respond_to do |format| - format.html { redirect_to course_url } - format.js - #format.api { render_api_ok } - end - end - - #end by xianbo - ##引用 - def new - @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id] - if @jour - user = @jour.user - text = @jour.notes - else - user = @bid.author - text = @bid.description - end - # Replaces pre blocks with [...] - text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') - @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " - @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" - @id = user.id - rescue ActiveRecord::RecordNotFound - render_404 - end - - ##新建需求 - def new_bid - @bid = Bid.new - @bid.safe_attributes = params[:bid] - end - - #huang - def create_contest - @bid = Bid.new - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.reward_type = 2 - @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.password = params[:bid][:password] #added by bai - @bid.author_id = User.current.id - @bid.commit = 0 - if @bid.save - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to respond_url(@bid) - else - @bid.safe_attributes = params[:bid] - render :action => 'new_bid' - end - end - - # added by bai - def update_contest - @bid = Bid.find(params[:id]) - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.reward_type = 2 - @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.password = params[:bid][:password] - @bid.author_id = User.current.id - @bid.commit = 0 - if @bid.save - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to respond_url(@bid) - else - @bid.safe_attributes = params[:bid] - render :action => 'new_bid' - end - end - #huang - def new_contest - @bid = Bid.new - @bid.safe_attributes = params[:bid] - end - - def create_bid - @bid = Bid.new - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.reward_type = 1 - @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.author_id = User.current.id - @bid.commit = 0 - if @bid.save - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to respond_url(@bid) - else - @bid.safe_attributes = params[:bid] - render :action => 'new_bid' - end - end - - def create_homework - @bid = Bid.new - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.is_evaluation = params[:bid][:is_evaluation] - @bid.proportion = params[:bid][:proportion] - @bid.evaluation_num = params[:bid][:evaluation_num] - params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 - @bid.reward_type = 3 - # @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.budget = 0 - @bid.author_id = User.current.id - @bid.commit = 0 - @bid.homework_type = 1 - @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - # @bid. - if @bid.save - HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id) - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to course_homework_url(params[:course_id]) - else - @bid.safe_attributes = params[:bid] - @homework = @bid - @course = Course.find_by_id(params[:course_id]) - @course_id = @course.id - #respond_to do |format| - # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'} - # format.api { render_validation_errors(@bid) } - #end - render file: 'courses/new_homework', layout: 'base_courses' - end - end - - # modify by nwb\ - # 编辑作业 - def edit - @bid = Bid.find(params[:bid_id]) - if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first)) - @course_id = params[:course_id] - respond_to do |format| - format.html { - @course = Course.find(params[:course_id]) - @user= User.find(User.current.id) - render :layout => 'base_courses' - } - end - else - render_403 - end - end - - def update - @bid = Bid.find(params[:id]) - @course = @bid.courses.first#Project.find(params[:course_id]) - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.is_evaluation = params[:bid][:is_evaluation] - @bid.proportion = params[:bid][:proportion] - @bid.evaluation_num = params[:bid][:evaluation_num] - params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 - @bid.reward_type = 3 - @bid.deadline = params[:bid][:deadline] - @bid.budget = 0 - #@bid.author_id = User.current.id - @bid.commit = 0 - @bid.homework_type = 1 - @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - if @bid.save - flash[:notice] = l(:label_update_homework_succeed) - redirect_to course_homework_url(@course) - else - @bid.safe_attributes = params[:bid] - render :action => 'edit', :layout =>'base_courses' - end - end - - def new_submit_homework - #render html to prepare create submit homework - find_bid - find_bid - render :layout => 'base_homework' - end - - def add_homework - if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) - # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) - # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - - if hadcommittedhomework(User.current.id, @bid.id) == true - @homework_flag = l(:label_bidding_homework_committed) - else - @homework = HomeworkAttach.new - @homework.safe_attributes = params[:homeworkattach] - @homework.bid_id = @bid.id - @homework.user_id = User.current.id - @homework.save_attachments(params[:attachments]) - - render_attachment_warning_if_needed(@homework) - - @homework_flag = if @homework.save - l(:label_bidding_homework_succeed) - else - l(:label_bidding_homework_failed) - end - - if @homework.attachments.empty? - @homework.delete - #flash[:error] = l(:no_attachmens_allowed) - @homework_flag = l(:no_attachmens_allowed) - # else - end - end - end - - @homework_list = @bid.homeworks - respond_to do |format| - format.html{ - #redirect_to project_for_bid_path, notice: @homework_flag.to_s - flash[:notice] = @homework_flag.to_s - redirect_back_or_default(project_for_bid_path) - } - format.js - end - - end - - # 作业统计 - def homework_statistics - @course = @bid.courses.first - @member = [] - @course.memberships.each do |member| - unless (member.roles && Role.where('id = ? ', 3)).empty? - @member.push member - end - end - if @bid.homework_type = 1 - @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id) - @homework_type = true - else - - @homework_type = false - end - @user = @bid.author - render :layout => 'base_homework' - end - - def homework_respond - @user = @bid.author - render :layout => 'base_homework' - end - - def more - @jour = @bid.journals_for_messages - @jour.each_with_index {|j,i| j.indice = i+1} - @state = true - - respond_to do |format| - format.html { redirect_to :back } - format.js - #format.api { render_api_ok } - end - end - - def back - @jour = @bid.journals_for_messages - @jour.each_with_index {|j,i| j.indice = i+1} - @state = false - - respond_to do |format| - format.html { redirect_to :back } - format.js - #format.api { render_api_ok } - end - end - - #added by william - #used to set the bidding project reward - def set_reward - @b_p = nil - @biding_project_id = nil - - if params[:set_reward][:reward]&&((User.current.id==@bid.author_id)||User.current.admin) - # @bid_id = params[:id] - @biding_project_id = params[:set_reward][:b_id] - @b_p = BidingProject.find_by_id(@biding_project_id) - - # 把字段存进表中 - @b_p.update_reward(params[:set_reward][:reward].to_s) - end - - respond_to do |format| - format.js - end - end - - # added by william - # used to manage the bid and end the bid - def manage - - end - - # 启动匿评 - def start_anonymous_comment - @bid = Bid.find(params[:id]) - @course = @bid.courses.first - if(@bid.comment_status == 0) - homeworks = @bid.homeworks - if(homeworks && homeworks.size >= 2) - homeworks.each_with_index do |homework, index| - user = homework.user - n = @bid.evaluation_num - n = n < homeworks.size ? n : homeworks.size - 1 - assigned_homeworks = get_assigned_homeworks(homeworks, n, index) - assigned_homeworks.each do |h| - @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id) - @homework_evaluation.save - end - end - @bid.update_column('comment_status', 1) - @statue = 1 - else - @statue = 2 - end - else - @statue = 3 - end - - respond_to do |format| - format.js - end - end - - def stop_anonymous_comment - @bid = Bid.find(params[:id]) - - @bid.update_column('comment_status', 2) - - respond_to do |format| - format.js - end - end - - def alert_anonymous_comment - @bid = Bid.find params[:id] - @course = @bid.courses.first - @cur_size = 0 - @totle_size = 0 - if @bid.comment_status == 0 - @totle_size = searchStudent(@course).size - @cur_size = @bid.homeworks.size - elsif @bid.comment_status == 1 - @bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count} - @cur_size = 0 - @bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.is_teacher_score = 0").count} - end - @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) - respond_to do |format| - format.js - end - end - - private - - def get_assigned_homeworks(homeworks, n, index) - homeworks += homeworks - homeworks[index + 1 .. index + n] - end - - def find_bid - if params[:id] - @bid = Bid.find(params[:id], :include => [{:homeworks => :user}]) - @user = @bid.author - end - rescue - render_404 - end - - def memberAccess - # 是课程,则判断当前用户是否参加了课程 - return true if current_user.admin? - #return 0 if @bid.courses.first.project_type == Project::ProjectType_project - currentUser = User.current - render_403 unless currentUser.member_of_course?(@bid.courses.first) - end - - #验证是否显示课程 - def can_show_course - @first_page = FirstPage.find_by_page_type('project') - if @first_page.show_course == 2 - render_404 - end - end - - #验证是否显示竞赛 - def can_show_contest - @first_page = FirstPage.find_by_page_type('project') - if @first_page.show_contest == 2 - render_404 - end - end -end - +# # fq +#Bid功能已经废弃,代码参考用 +# class BidsController < ApplicationController +# #Added by young +# menu_item l(:label_homework), :only => [:edit, :udpate] +# menu_item :respond +# menu_item :course, :only => :show_courseEx +# menu_item :project, :only => [:show_project,:show_results, :new_submit_homework] +# menu_item :homework_respond, :only => :homework_respond +# menu_item :homework_statistics, :only => :homework_statistics +# menu_item :edit, :only => :edit +# +# before_filter :auth_login1, :only => [:show_courseEx] +# +# before_filter :can_show_course,only: [] +# before_filter :can_show_contest,only: [] +# #Ended by young +# before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, +# :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] +# # added by fq +# before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] +# # end +# before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ] +# +# #before_filter :memberAccess, only: :show_project +# +# helper :watchers +# helper :attachments +# include AttachmentsHelper +# include ApplicationHelper +# include BidsHelper +# +# helper :projects +# helper :words +# helper :welcome +# helper :project_score +# +# def find_project_by_bid_id +# @bid = Bid.find(params[:id]) +# @project = @bid.courses[0] +# rescue ActiveRecord::RecordNotFound +# render_404 +# end +# +# def homework_ajax_modal +# @bid = Bid.find_by_id(params[:id]) +# # find_bid +# respond_to do |format| +# format.js +# end +# end +# +# +# def index +# @project_type = params[:project_type] +# # Modified by nie +# # @requirement_title = "4" +# @offset, @limit = api_offset_and_limit({:limit => 10}) +# if @project_type == '1' +# @bids = Bid.visible.where('reward_type = ?', 3) +# # elsif +# # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) +# else +# @bids = Bid.visible.where('reward_type = ?', 1) +# end +# +# @bids = @bids.like(params[:name]) if params[:name].present? +# @bid_count = @bids.count +# @bid_pages = Paginator.new @bid_count, @limit, params['page'] +# +# @offset ||= @bid_pages.reverse_offset +# #added by nie +# if params[:bid_sort_type].present? +# case params[:bid_sort_type] +# when '0' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(limit).all.reverse +# end +# @s_state = 0 +# when '1' +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# when '2' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# end +# @s_state = 0 +# end +# else +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# end +# #end +# end +# #huang +# def contest +# +# # Modified by nie +# # @requirement_title = "4" +# @offset, @limit = api_offset_and_limit({:limit => 10}) +# +# @bids = Bid.visible.where('reward_type = ?', 2) +# +# # elsif +# # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) +# @bids = @bids.like(params[:name]) if params[:name].present? +# @bid_count = @bids.count +# @bid_pages = Paginator.new @bid_count, @limit, params['page'] +# +# @offset ||= @bid_pages.reverse_offset +# #added by nie +# if params[:contest_sort_type].present? +# case params[:contest_sort_type] +# when '0' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(limit).all.reverse +# end +# @s_state = 0 +# when '1' +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# when '2' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# end +# @s_state = 0 +# end +# else +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# end +# #end +# end +# +# def fork +# @courses = [] +# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) +# @membership.each do |membership| +# if membership.project.project_type == 1 +# @courses << membership.project +# end +# end +# end +# +# #将某个企业外包需求选为作业,目前此功能已放弃 +# def create_fork +# @homework = Bid.new +# @homework.name = params[:bid][:name] +# @homework.description = params[:bid][:description] +# @homework.reward_type = 3 +# # @bid.budget = params[:bid][:budget] +# @homework.deadline = params[:bid][:deadline] +# @homework.budget = 0 +# @homework.author_id = User.current.id +# @homework.commit = 0 +# @homework.homework_type = 1 +# @homework.is_evaluation = params[:bid][:is_evaluation] +# @homework.parent_id = @bid.id +# @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# # @bid. +# if @homework.save +# HomeworkForCourse.create(:course_id => params[:course], :bid_id => @homework.id) +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to course_for_bid_path(@homework) +# else +# @bid.safe_attributes = params[:bid] +# @courses = [] +# @membership = User.current.coursememberships.all#(:conditions => Project.visible_condition(User.current)) +# @membership.each do |membership| +# @courses << membership.course +# end +# render :action => 'fork' +# end +# end +# +# #有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认 +# def show +# @user = @bid.author +# @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') +# @limit = 10 +# @feedback_count = @jours.count +# @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] +# @offset ||= @feedback_pages.offset +# @jour = @jours[@offset, @limit] +# @state = false +# +# respond_to do |format| +# layout_file = '' +# case @bid.reward_type +# when 3 +# html_title(l(:label_question_student)) +# layout_file = 'base_homework' +# when 1 +# layout_file = 'base_bids' +# else +# layout_file = 'base_contest' +# end +# format.html { +# render :layout => layout_file +# } +# format.api +# end +# end +# +# def join_in_contest +# if @bid.reward_type == 2 && params[:course_password] == @bid.password +# JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id) +# @state = 0 +# else +# @state = 1 +# end +# respond_to do |format| +# format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } +# end +# end +# +# def unjoin_in_contest +# joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id) +# joined.each do |join| +# join.delete +# end +# respond_to do |format| +# format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } +# end +# end +# +# def new_join +# +# end +# +# # added by bai 增加了参与者和竞赛设置 +# def show_participator +# render :layout => 'base_contest' +# end +# +# #配置竞赛 +# def settings +# if @bid.author.id == User.current.id +# if @bid.reward_type == 2 +# @contest = Bid.find_by_reward_type(@bid.reward_type) +# render :layout => 'base_contest' +# end +# else +# render_403 :message => :notice_not_contest_setting_authorized +# end +# end +# #end +# +# # 显示课程作业,但是好像已经废弃 +# def show_course +# bids = Bid.where('parent_id = ?', @bid.id) +# @courses = [] +# for bid in bids +# @courses << bid.courses.first +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# +# end +# end +# +# def show_bid_project +# bids = Bid.where('parent_id = ?', @bid.id) +# @projects = [] +# for bid in bids +# @projects += bid.biding_projects +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# +# end +# end +# +# def show_bid_user +# bids = Bid.where('parent_id = ?', @bid.id) +# @users = [] +# for bid in bids +# for project in bid.projects +# @users += project.users +# end +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# +# end +# end +# +# def show_project +# # flash[:notice] = "" +# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) +# @option = [] +# @membership.each do |membership| +# unless(membership.project.project_type==1) +# if membership.user.allowed_to?(:quote_project,membership.project) +# @option << membership.project +# end +# end +# end +# +# # a = [1] +# # @project = Project.where("id in []", a) +# @user = @bid.author +# @bidding_project = @bid.biding_projects.all +# if params[:student_id].present? +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# end +# @temp +# end +# @bidding_project = @temp +# else +# #added by nie +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# @temp << pro +# end +# @temp +# end +# if @temp.size > 0 +# @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} +# end +# #ended +# end +# +# if @bid.homework_type == 1 +# @homework = HomeworkAttach.new +# #@homework_list = @bid.homeworks +# #增加作业按评分排序, +# @homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") +# if params[:student_id].present? +# @temp = [] +# @homework_list.each do |pro| +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# @temp +# end +# @homework_list = @temp +# end +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# end +# end +# +# # 显示作业课程 +# # add by nwb +# def show_courseEx +# +# if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?)) +# @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current)) +# @user = @bid.author +# @bidding_project = @bid.biding_projects.all +# +# if params[:student_id].present? +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# end +# @temp +# end +# @bidding_project = @temp +# else +# #added by nie +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# @temp << pro +# end +# @temp +# end +# if @temp.size > 0 +# @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} +# end +# #ended +# end +# +# if @bid.homework_type +# @homework = HomeworkAttach.new +# @is_teacher = is_course_teacher(User.current,@bid.courses.first) +# if @is_teacher +# all_homework_list = HomeworkAttach.find_by_sql("SELECT * FROM (SELECT homework_attaches.*, +# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, +# (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score +# FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1 +# WHERE table1.t_score IS NULL") +# @not_batch_homework = true +# @cur_type = 1 +# else +# all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, +# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, +# (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, +# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = #{@is_teacher ? 1 : 0}) AS m_score +# FROM homework_attaches +# INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id +# WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC") +# @is_student_batch_homework = true +# @cur_type = 4 +# end +# +# @cur_page = params[:page] || 1 +# # @homework_list = paginateHelper all_homework_list,10 +# @homework_list = all_homework_list +# @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count +# if params[:student_id].present? +# @temp = [] +# @homework_list.each do |pro| +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# @temp +# end +# @homework_list = @temp +# end +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# html_title(l(:label_homework_info)) +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# end +# else +# render_403 :message => :notice_not_authorized +# end +# end +# +# ##### by huang +# def show_project_homework +# # flash[:notice] = "" +# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) +# @option = [] +# @membership.each do |membership| +# end +# # a = [1] +# # @project = Project.where("id in []", a) +# @user = @bid.author +# @bidding_project = @bid.biding_projects +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# end +# end +# +# ###添加应标项目 +# def add +# project = Project.find(params[:bid]) +# bid_message = params[:bid_for_save][:bid_message] +# if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0 +# if BidingProject.cerate_bidding(@bid.id, project.id, bid_message) +# +# # added by bai type ==1 需求,type==2 竞赛, type==3 作业 +# if @bid.reward_type == 1 +# flash.now[:notice] = l(:label_bidding_succeed) +# +# elsif @bid.reward_type == 2 +# flash.now[:notice] = l(:label_bidding_contest_succeed) +# +# else @bid.reward_type == 3 +# flash.now[:notice] = l(:label_bidding_homework_succeed) +# end +# # end +# +# end +# else +# if @bid.reward_type == 3 +# flash.now[:error] = l(:label_bidding_homework_fail) +# else +# flash.now[:error] = l(:label_bidding_fail) +# end +# end +# @bidding_project = @bid.biding_projects +# respond_to do |format| +# # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} +# # format.html +# format.html { redirect_to :back } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #删除已提交的项目作业(不删项目) +# def delete +# binding_project = params[:binding_project] +# if can_delete_project_homework(BidingProject.find(binding_project),User.current) +# if BidingProject.delete(binding_project) +# redirect_to project_for_bid_url +# else +# render_403; +# end +# end +# end +# ## 新建留言 +# def create +# +# if params[:bid_message][:message].size>0 +# if params[:reference_content] +# message = params[:bid_message][:message] + "\n" + params[:reference_content] +# else +# message = params[:bid_message][:message] +# @m = message +# end +# refer_user_id = params[:bid_message][:reference_user_id].to_i +# @bid.add_jour(User.current, message, refer_user_id) +# end +# @user = @bid.author +# @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') +# @jour = paginateHelper @jours,10 +# @bid.set_commit(@feedback_count) +# respond_to do |format| +# format.js +# #format.api { render_api_ok } +# end +# +# end +# +# ##删除留言 +# def destroy +# @user = @bid.author +# if User.current.admin? || User.current.id == @user.id +# JournalsForMessage.delete_message(params[:object_id]) +# end +# @jours = @bid.journals_for_messages.reverse +# @limit = 10 +# @feedback_count = @jours.count +# @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] +# @offset ||= @feedback_pages.offset +# @jour = @jours[@offset, @limit] +# +# @bid.set_commit(@feedback_count) +# # if a_message.size > 5 +# # @message = a_message[-5, 5] +# # else +# # @message = a_message +# # end +# # @message_count = a_message.count +# +# respond_to do |format| +# # format.html +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #删除作业 +# #by xianbo +# def homework_destroy +# @bid_to_destroy = Bid.find params[:id] +# course_url = course_homework_path(@bid_to_destroy.courses.first) +# (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id +# @bid_to_destroy.destroy +# respond_to do |format| +# format.html { redirect_to course_url } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #end by xianbo +# ##引用 +# def new +# @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id] +# if @jour +# user = @jour.user +# text = @jour.notes +# else +# user = @bid.author +# text = @bid.description +# end +# # Replaces pre blocks with [...] +# text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') +# @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " +# @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" +# @id = user.id +# rescue ActiveRecord::RecordNotFound +# render_404 +# end +# +# ##新建需求 +# def new_bid +# @bid = Bid.new +# @bid.safe_attributes = params[:bid] +# end +# +# #huang +# def create_contest +# @bid = Bid.new +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.reward_type = 2 +# @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.password = params[:bid][:password] #added by bai +# @bid.author_id = User.current.id +# @bid.commit = 0 +# if @bid.save +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to respond_url(@bid) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'new_bid' +# end +# end +# +# # added by bai +# def update_contest +# @bid = Bid.find(params[:id]) +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.reward_type = 2 +# @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.password = params[:bid][:password] +# @bid.author_id = User.current.id +# @bid.commit = 0 +# if @bid.save +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to respond_url(@bid) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'new_bid' +# end +# end +# #huang +# def new_contest +# @bid = Bid.new +# @bid.safe_attributes = params[:bid] +# end +# +# def create_bid +# @bid = Bid.new +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.reward_type = 1 +# @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.author_id = User.current.id +# @bid.commit = 0 +# if @bid.save +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to respond_url(@bid) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'new_bid' +# end +# end +# +# def create_homework +# @bid = Bid.new +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.is_evaluation = params[:bid][:is_evaluation] +# @bid.proportion = params[:bid][:proportion] +# @bid.evaluation_num = params[:bid][:evaluation_num] +# params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 +# @bid.reward_type = 3 +# # @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.budget = 0 +# @bid.author_id = User.current.id +# @bid.commit = 0 +# @bid.homework_type = 1 +# @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# # @bid. +# if @bid.save +# HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id) +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to course_homework_url(params[:course_id]) +# else +# @bid.safe_attributes = params[:bid] +# @homework = @bid +# @course = Course.find_by_id(params[:course_id]) +# @course_id = @course.id +# #respond_to do |format| +# # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'} +# # format.api { render_validation_errors(@bid) } +# #end +# render file: 'courses/new_homework', layout: 'base_courses' +# end +# end +# +# # modify by nwb\ +# # 编辑作业 +# def edit +# @bid = Bid.find(params[:bid_id]) +# if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first)) +# @course_id = params[:course_id] +# respond_to do |format| +# format.html { +# @course = Course.find(params[:course_id]) +# @user= User.find(User.current.id) +# render :layout => 'base_courses' +# } +# end +# else +# render_403 +# end +# end +# +# def update +# @bid = Bid.find(params[:id]) +# @course = @bid.courses.first#Project.find(params[:course_id]) +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.is_evaluation = params[:bid][:is_evaluation] +# @bid.proportion = params[:bid][:proportion] +# @bid.evaluation_num = params[:bid][:evaluation_num] +# params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 +# @bid.reward_type = 3 +# @bid.deadline = params[:bid][:deadline] +# @bid.budget = 0 +# #@bid.author_id = User.current.id +# @bid.commit = 0 +# @bid.homework_type = 1 +# @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# if @bid.save +# flash[:notice] = l(:label_update_homework_succeed) +# redirect_to course_homework_url(@course) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'edit', :layout =>'base_courses' +# end +# end +# +# def new_submit_homework +# #render html to prepare create submit homework +# find_bid +# find_bid +# render :layout => 'base_homework' +# end +# +# def add_homework +# if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) +# # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) +# # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# +# if hadcommittedhomework(User.current.id, @bid.id) == true +# @homework_flag = l(:label_bidding_homework_committed) +# else +# @homework = HomeworkAttach.new +# @homework.safe_attributes = params[:homeworkattach] +# @homework.bid_id = @bid.id +# @homework.user_id = User.current.id +# @homework.save_attachments(params[:attachments]) +# +# render_attachment_warning_if_needed(@homework) +# +# @homework_flag = if @homework.save +# l(:label_bidding_homework_succeed) +# else +# l(:label_bidding_homework_failed) +# end +# +# if @homework.attachments.empty? +# @homework.delete +# #flash[:error] = l(:no_attachmens_allowed) +# @homework_flag = l(:no_attachmens_allowed) +# # else +# end +# end +# end +# +# @homework_list = @bid.homeworks +# respond_to do |format| +# format.html{ +# #redirect_to project_for_bid_path, notice: @homework_flag.to_s +# flash[:notice] = @homework_flag.to_s +# redirect_back_or_default(project_for_bid_path) +# } +# format.js +# end +# +# end +# +# # 作业统计 +# def homework_statistics +# @course = @bid.courses.first +# @member = [] +# @course.memberships.each do |member| +# unless (member.roles && Role.where('id = ? ', 3)).empty? +# @member.push member +# end +# end +# if @bid.homework_type = 1 +# @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id) +# @homework_type = true +# else +# +# @homework_type = false +# end +# @user = @bid.author +# render :layout => 'base_homework' +# end +# +# def homework_respond +# @user = @bid.author +# render :layout => 'base_homework' +# end +# +# def more +# @jour = @bid.journals_for_messages +# @jour.each_with_index {|j,i| j.indice = i+1} +# @state = true +# +# respond_to do |format| +# format.html { redirect_to :back } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# def back +# @jour = @bid.journals_for_messages +# @jour.each_with_index {|j,i| j.indice = i+1} +# @state = false +# +# respond_to do |format| +# format.html { redirect_to :back } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #added by william +# #used to set the bidding project reward +# def set_reward +# @b_p = nil +# @biding_project_id = nil +# +# if params[:set_reward][:reward]&&((User.current.id==@bid.author_id)||User.current.admin) +# # @bid_id = params[:id] +# @biding_project_id = params[:set_reward][:b_id] +# @b_p = BidingProject.find_by_id(@biding_project_id) +# +# # 把字段存进表中 +# @b_p.update_reward(params[:set_reward][:reward].to_s) +# end +# +# respond_to do |format| +# format.js +# end +# end +# +# # added by william +# # used to manage the bid and end the bid +# def manage +# +# end +# +# # 启动匿评 +# def start_anonymous_comment +# @bid = Bid.find(params[:id]) +# @course = @bid.courses.first +# if(@bid.comment_status == 0) +# homeworks = @bid.homeworks +# if(homeworks && homeworks.size >= 2) +# homeworks.each_with_index do |homework, index| +# user = homework.user +# n = @bid.evaluation_num +# n = n < homeworks.size ? n : homeworks.size - 1 +# assigned_homeworks = get_assigned_homeworks(homeworks, n, index) +# assigned_homeworks.each do |h| +# @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id) +# @homework_evaluation.save +# end +# end +# @bid.update_column('comment_status', 1) +# @statue = 1 +# else +# @statue = 2 +# end +# else +# @statue = 3 +# end +# +# respond_to do |format| +# format.js +# end +# end +# +# def stop_anonymous_comment +# @bid = Bid.find(params[:id]) +# +# @bid.update_column('comment_status', 2) +# +# respond_to do |format| +# format.js +# end +# end +# +# def alert_anonymous_comment +# @bid = Bid.find params[:id] +# @course = @bid.courses.first +# @cur_size = 0 +# @totle_size = 0 +# if @bid.comment_status == 0 +# @totle_size = searchStudent(@course).size +# @cur_size = @bid.homeworks.size +# elsif @bid.comment_status == 1 +# @bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count} +# @cur_size = 0 +# @bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.is_teacher_score = 0").count} +# end +# @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) +# respond_to do |format| +# format.js +# end +# end +# +# private +# +# def get_assigned_homeworks(homeworks, n, index) +# homeworks += homeworks +# homeworks[index + 1 .. index + n] +# end +# +# def find_bid +# if params[:id] +# @bid = Bid.find(params[:id], :include => [{:homeworks => :user}]) +# @user = @bid.author +# end +# rescue +# render_404 +# end +# +# def memberAccess +# # 是课程,则判断当前用户是否参加了课程 +# return true if current_user.admin? +# #return 0 if @bid.courses.first.project_type == Project::ProjectType_project +# currentUser = User.current +# render_403 unless currentUser.member_of_course?(@bid.courses.first) +# end +# +# #验证是否显示课程 +# def can_show_course +# @first_page = FirstPage.find_by_page_type('project') +# if @first_page.show_course == 2 +# render_404 +# end +# end +# +# #验证是否显示竞赛 +# def can_show_contest +# @first_page = FirstPage.find_by_page_type('project') +# if @first_page.show_contest == 2 +# render_404 +# end +# end +# end +# diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 333ad77b1..61354add7 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -6,6 +6,7 @@ class CoursesController < ApplicationController helper :members helper :words helper :attachments + helper :activity_notifys before_filter :auth_login1, :only => [:show, :feedback] menu_item :overview @@ -93,6 +94,9 @@ class CoursesController < ApplicationController def new_join @course = Course.find(params[:object_id]) + respond_to do |format| + format.js + end end # 课程搜索 @@ -339,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| @@ -835,7 +839,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} @@ -847,7 +851,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 06bc1fd38..d4a5cab24 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -1,6 +1,6 @@ class HomeworkCommonController < ApplicationController layout "base_courses" - before_filter :find_course, :only => [:index,:new,:create] + before_filter :find_course, :only => [:index,:new,:create,:next_step] 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] @@ -15,20 +15,37 @@ class HomeworkCommonController < ApplicationController end def new + respond_to do |format| + format.html + end + end + + #新建作业下一步 + def next_step + @homework_type = params[:homework_common_type] + @homework = HomeworkCommon.new @homework.safe_attributes = params[:homework_common] @homework.late_penalty = 0 @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') @homework.publish_time = Time.now.strftime('%Y-%m-%d') - #匿评作业相关属性 - @homework_detail_manual = HomeworkDetailManual.new - @homework_detail_manual.ta_proportion = 0.6 - @homework_detail_manual.absence_penalty = 0 - @homework_detail_manual.evaluation_num = 3 - @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 + if @homework_type == "1" + #匿评作业相关属性 + @homework_detail_manual = HomeworkDetailManual.new + @homework_detail_manual.ta_proportion = 0.6 + @homework_detail_manual.absence_penalty = 0 + @homework_detail_manual.evaluation_num = 3 + @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 + elsif @homework_type == "2" + #编程作业相关属性 + @homework_detail_programing = HomeworkDetailPrograming.new + @homework.homework_detail_programing = @homework_detail_programing + end + + respond_to do |format| format.html end @@ -49,15 +66,31 @@ class HomeworkCommonController < ApplicationController homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(homework) - #匿评作业相关属性 - homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = params[:evaluation_start] - homework_detail_manual.evaluation_end = params[:evaluation_end] - homework_detail_manual.evaluation_num = params[:evaluation_num] - homework_detail_manual.absence_penalty = params[:absence_penalty] - homework.homework_detail_manual = homework_detail_manual + if homework.homework_type == 2 + homework_detail_programing = HomeworkDetailPrograming.new + homework_detail_programing.language = "C++" + homework_detail_programing.standard_code = params[:standard_code] + + if params[:input] && params[:output] + params[:input].each do |k,v| + if params[:output][k] + + end + end + end + + homework.homework_detail_programing = homework_detail_programing + else + #匿评作业相关属性 + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = params[:evaluation_start] + homework_detail_manual.evaluation_end = params[:evaluation_end] + homework_detail_manual.evaluation_num = params[:evaluation_num] + homework_detail_manual.absence_penalty = params[:absence_penalty] + homework.homework_detail_manual = homework_detail_manual + end if homework.save respond_to do |format| diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 9e36d15f4..b1da35cfc 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -94,12 +94,12 @@ class MessagesController < ApplicationController update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE end # 与我相关动态的记录add start - if(@board.course_id>0) #项目的先不管 - teachers = searchTeacherAndAssistant(@board.course); + if(@board && @board.course) #项目的先不管 + teachers = searchTeacherAndAssistant(@board.course) for teacher in teachers if(teacher.user_id != User.current.id) notify = ActivityNotify.new() - if(@board.course_id>0) + if(@board.course) notify.activity_container_id = @board.course_id notify.activity_container_type = 'Course' else @@ -178,7 +178,7 @@ class MessagesController < ApplicationController end # 与我相关动态的记录add start - if(@board.course_id>0) #项目的先不管 + if(@board && @board.course) #项目的先不管 notifyto_arr = {} notifyto_arr[@topic.author_id] = @topic.author_id if( params[:parent_topic] != nil && params[:parent_topic] != '') @@ -188,7 +188,7 @@ class MessagesController < ApplicationController notifyto_arr.each do |k,user_id| if(user_id != User.current.id) notify = ActivityNotify.new() - if(@board.course_id>0) + if(@board.course) notify.activity_container_id = @board.course_id notify.activity_container_type = 'Course' else 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/projects_controller.rb b/app/controllers/projects_controller.rb index 3c34aa549..efe5a52ee 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -365,6 +365,21 @@ class ProjectsController < ApplicationController def invite_members_by_mail if User.current.member_of?(@project) || User.current.admin? @inviter_lists = InviteList.where(project_id:@project.id).all + @inviters = [] + @waiters = [] + unless @inviter_lists.blank? + @inviter_lists.each do|inviter_list| + unless inviter_list.user.nil? + if inviter_list.user.member_of?(@project) + @inviters << inviter_list.user + @inviters_count = @inviters.size + else + @waiters << inviter_list.user + @waiters_count = @waiters.size + end + end + end + end @is_zhuce = false respond_to do |format| format.html 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/users_controller.rb b/app/controllers/users_controller.rb index 0382e7be0..23053a48e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -25,7 +25,7 @@ class UsersController < ApplicationController menu_item :user_course, :only => :user_courses menu_item :user_homework, :only => :user_homeworks menu_item :user_project, :only => [:user_projects, :watch_projects] - menu_item :requirement_focus, :only => :watch_bids + # menu_item :requirement_focus, :only => :watch_bids menu_item :requirement_focus, :only => :watch_contests menu_item :user_newfeedback, :only => :user_newfeedback @@ -36,14 +36,14 @@ class UsersController < ApplicationController # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] - before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, + before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, - :watch_bids, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index] before_filter :auth_user_extension, only: :show @@ -141,25 +141,25 @@ class UsersController < ApplicationController ##added by fq def watch_bids - cond = 'bids.reward_type <> 1' - @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang - @offset, @limit = api_offset_and_limit({:limit => 10}) - @bid_count = @bids.count - @bid_pages = Paginator.new @bid_count, @limit, params['page'] - @offset ||= @bid_pages.reverse_offset - unless @offset == 0 - @bid = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - @bid = @bids.offset(@offset).limit(limit).all.reverse - end - - respond_to do |format| - format.html { - render :layout => 'base_users' - } - format.api - end + # cond = 'bids.reward_type <> 1' + # @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang + # @offset, @limit = api_offset_and_limit({:limit => 10}) + # @bid_count = @bids.count + # @bid_pages = Paginator.new @bid_count, @limit, params['page'] + # @offset ||= @bid_pages.reverse_offset + # unless @offset == 0 + # @bid = @bids.offset(@offset).limit(@limit).all.reverse + # else + # limit = @bid_count % @limit + # @bid = @bids.offset(@offset).limit(limit).all.reverse + # end + # + # respond_to do |format| + # format.html { + # render :layout => 'base_users' + # } + # format.api + # end end #new add by linchun @@ -215,24 +215,24 @@ class UsersController < ApplicationController # added by huang def user_homeworks - @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) - @memberships = [] - @membership.each do |membership| - if membership.project.project_type == 1 - @memberships << membership - end - end - @bid = [] - @memberships.each do |membership| - @bid += membership.project.homeworks - end - @bid = @bid.group_by {|bid| bid.courses.first.id} - unless User.current.admin? - if !@user.active? - render_404 - return - end - end + # @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) + # @memberships = [] + # @membership.each do |membership| + # if membership.project.project_type == 1 + # @memberships << membership + # end + # end + # @bid = [] + # @memberships.each do |membership| + # @bid += membership.project.homeworks + # end + # @bid = @bid.group_by {|bid| bid.courses.first.id} + # unless User.current.admin? + # if !@user.active? + # render_404 + # return + # end + # end end @@ -757,7 +757,7 @@ class UsersController < ApplicationController when '3' then @obj = Issue.find_by_id(@obj_id) when '4' then - @obj = Bid.find_by_id(@obj_id) + # @obj = Bid.find_by_id(@obj_id) when '5' then @obj = Forum.find_by_id(@obj_id) when '6' @@ -800,7 +800,7 @@ class UsersController < ApplicationController when '3' then @obj = Issue.find_by_id(@obj_id) when '4' then - @obj = Bid.find_by_id(@obj_id) + # @obj = Bid.find_by_id(@obj_id) when '5' then @obj = Forum.find_by_id(@obj_id) when '6' diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 043552872..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 @@ -30,8 +30,7 @@ class ZipdownController < ApplicationController if file_count > 0 zipfile = zip_bid bid else - render file: 'public/no_file_found.html' - return + zipfile = {:message => "no file"} end elsif params[:obj_class] == "HomeworkCommon" homework = HomeworkCommon.find params[:obj_id] @@ -41,8 +40,7 @@ class ZipdownController < ApplicationController if file_count > 0 zipfile = zip_homework_common homework else - render file: 'public/no_file_found.html' - return + zipfile = {:message => "no file"} end else logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!" @@ -61,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.lastname.nil? ? "" : homework.user.lastname) + (homework.user.firstname.nil? ? "" : homework.user.firstname) + - "_" + 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 @@ -150,7 +149,7 @@ class ZipdownController < ApplicationController end end out_file = find_or_pack(homework_attach.bid_id, homework_attach.user_id, digests.sort){ - zipping("#{homework_attach.user.lastname}#{homework_attach.user.firstname}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", + zipping("#{homework_attach.user.show_name}_#{((homework_attach.user.user_extensions.nil? || homework_attach.user.user_extensions.student_id.nil?) ? "" : homework_attach.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) } end @@ -170,7 +169,7 @@ class ZipdownController < ApplicationController end end out_file = find_or_pack(work.homework_common_id, work.user_id, digests.sort){ - zipping("#{work.user.lastname}#{work.user.firstname}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", + zipping("#{work.user.show_name}_#{((work.user.user_extensions.nil? || work.user.user_extensions.student_id.nil?) ? "" : work.user.user_extensions.student_id)}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true, not_exist_file) } end diff --git a/app/helpers/activity_notifys_helper.rb b/app/helpers/activity_notifys_helper.rb new file mode 100644 index 000000000..f2069a2d3 --- /dev/null +++ b/app/helpers/activity_notifys_helper.rb @@ -0,0 +1,6 @@ +module ActivityNotifysHelper + def get_new_notify_count(container,type) + 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/models/attachment.rb b/app/models/attachment.rb index 1e477ed04..f999e27d6 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -72,8 +72,8 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_create :office_conver, :be_user_score ,:act_as_forge_activity# user_score - after_update :be_user_score + after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score + after_update :office_conver, :be_user_score after_destroy :delete_from_disk,:down_user_score # add by nwb @@ -259,12 +259,14 @@ class Attachment < ActiveRecord::Base end def office_conver - saved_path = File.join(Rails.root, "files", "convered_office") - unless Dir.exist?(saved_path) - Dir.mkdir(saved_path) - end - convered_file = File.join(saved_path, self.disk_filename + ".html") - OfficeConverTask.new.conver(self.diskfile, convered_file) + # 不在这里做后台转换,换为点击时做转换 + # return unless %w(Project Course).include? (self.container_type) + # saved_path = File.join(Rails.root, "files", "convered_office") + # unless Dir.exist?(saved_path) + # Dir.mkdir(saved_path) + # end + # convered_file = File.join(saved_path, self.disk_filename + ".pdf") + # OfficeConverTask.new.conver(self.diskfile, convered_file) end # Copies the temporary file to its final location 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/mailer.rb b/app/models/mailer.rb index 087fb6d73..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) @@ -115,30 +115,45 @@ class Mailer < ActionMailer::Base count = courses.count count = count - 1 for i in 0..count do - bids = courses[i].homeworks.where("bids.created_on between '#{date_from}' and '#{date_to}'").order("bids.created_on desc") + bids = courses[i].homework_commons.where("homework_commons.created_at between '#{date_from}' and '#{date_to}'").order("homework_commons.created_at desc") attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC') @bids += bids if bids.count > 0 @attachments += attachments if attachments.count > 0 + end end # 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") + # @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at 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 @@ -148,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,@homeworks,@course_messages,@project_messages,@course_news,@project_news, - @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty?} + has_content = [@issues,@course_messages,@project_messages,@course_news,@project_news, + @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 @@ -198,8 +220,8 @@ class Mailer < ActionMailer::Base @title = "#@user #{t(:label_leave_your_message, :locale => 'zh')}" @issue_author_url = url_for(user_activities_url(@user)) @url = case journals_for_message.jour.class.to_s.to_sym # 判断留言的对象所属类型 - when :Bid - course_for_bid_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") + # when :Bid + # course_for_bid_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") when :Project return -1 if journals_for_message.jour.project_type == Project::ProjectType_project project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") @@ -235,12 +257,12 @@ class Mailer < ActionMailer::Base mail :to => @recipients, :subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} ", :filter => true - elsif journals_for_message.jour.class.to_s.to_sym == :Bid - if !journals_for_message.jour.author.notify_about? journals_for_message - return -1 - end - - mail :to => recipients, :subject => @title,:filter => true + # elsif journals_for_message.jour.class.to_s.to_sym == :Bid + # if !journals_for_message.jour.author.notify_about? journals_for_message + # return -1 + # end + # + # mail :to => recipients, :subject => @title,:filter => true elsif journals_for_message.jour.class.to_s.to_sym == :Contest if !journals_for_message.jour.author.notify_about? journals_for_message return -1 diff --git a/app/models/member.rb b/app/models/member.rb index 2936392ab..5b1e277d7 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -116,21 +116,23 @@ 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 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/models/user.rb b/app/models/user.rb index a1f00a234..b4723cceb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -277,15 +277,18 @@ class User < Principal end def show_name + name = "" unless self.user_extensions.nil? if self.user_extensions.identity == 2 - firstname + name = firstname else - lastname+firstname + name = lastname+firstname end else - lastname+firstname + name = lastname+firstname end + name = name.empty? || name.nil? ? login : name + name end ## end 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/services/users_service.rb b/app/services/users_service.rb index aff0a975c..7e8e775ed 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -255,7 +255,9 @@ class UsersService watcher.push(params[:user_id]) scope = scope.where("id not in (?)",watcher) end - scope = scope.like(params[:name],search_by) + #scope = scope.like(params[:name],search_by) + scope = scope.where("( LOWER(login) LIKE ? or LOWER(concat(lastname, firstname)) LIKE ? or LOWER(mail) LIKE ? )", + "%#{params[:name]}%","%#{params[:name]}%","%#{params[:name]}%") end #modify by yutao 2015/5/18 没有params[:user_id]参数时去掉"id not in (?)"条件 end else 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/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..5beee8601 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -253,7 +253,7 @@ }; params.get_ref_str_call=function(btn){ var div = btn.parent('div'); - var str = '
'+$('a',div).filter(':first').html()+' 写到:
'+$("input[nhname='nh_content_val']",div).val()+'
'; + var str = '
'+$('a',div).filter(':first').html()+' 写到:
'+$("input[nhname='nh_content_val']",div).val()+'
'; return str; } nh_init_board(params); diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb index f6b41b53f..525869901 100644 --- a/app/views/boards/_form_project.html.erb +++ b/app/views/boards/_form_project.html.erb @@ -47,6 +47,7 @@
  • +
    <% unless replying %> <% end %> diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index aed6b80e5..d5a5a7882 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -238,7 +238,7 @@ }; params.get_ref_str_call=function(btn){ var div = btn.parent('div'); - var str = '
    '+$('a',div).filter(':first').html()+' 写到:
    '+$("input[nhname='nh_content_val']",div).val()+'
    '; + var str = '
    '+$('a',div).filter(':first').html()+' 写到:
    '+$("input[nhname='nh_content_val']",div).val()+'
    '; return str; } nh_init_board(params); diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 589a0f25d..ba9583e7d 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,11 +1,11 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%#= javascript_include_tag "/assets/kindeditor/kindeditor-min" %> <% if @project %> <%= render :partial => 'project_show', locals: {project: @project} %> @@ -104,6 +105,7 @@ function nh_check_field(params){ } if(params.content.html()!=params.textarea.html() || params.issubmit==true){ params.textarea.html(params.content.html()); + params.content.sync(); //用上面那句ie11提交到服务器居然木有值 if(params.content.isEmpty()){ params.contentmsg.html('内容不能为空'); params.contentmsg.css({color:'#ff0000'}); @@ -123,21 +125,20 @@ function nh_init_board(params){ if(params.textarea.data('init') == undefined){ //初始化编辑器 var editor = params.kindutil.create(params.textarea, { - resizeType : 1, - allowPreviewEmoticons : false, - allowImageUpload : false, - minWidth:"1px", - width:"565px", - items : ['emoticons'], +// allowPreviewEmoticons : false, +// allowImageUpload : false, + resizeType : 1,minWidth:"1px",width:"565px",height:"150px", + allowFileManager:true,uploadJson:"/kindeditor/upload", + fileManagerJson:"/kindeditor/filemanager", afterChange:function(){//按键事件 nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); }, afterCreate:function(){ - var toolbar = $("div[class='ke-toolbar']",params.about_talk); - $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); - params.toolbar_container.append(toolbar); +// var toolbar = $("div[class='ke-toolbar']",params.about_talk); +// $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); +// params.toolbar_container.append(toolbar); } - }); + }).loadPlugin('paste'); //主题输入框按键事件 params.inputsubject.keyup(function(){ @@ -184,9 +185,17 @@ function nh_init_board(params){ if(params.quote_input!=undefined)params.quote_input.empty(); }else{ if(params.type=='reply'){ - params.jumphref.attr('href','#'+params.form.attr('id')); - params.jumphref[0].click(); - }else params.inputsubject.focus(); + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); + //params.jumphref.attr('href','#'+params.form.attr('id')); + //params.jumphref[0].click(); + }else{ + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); +// params.inputsubject.focus(); + } } }); params.textarea.data('init','1');//标记为已经初始化 diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index adbbf4780..2cb22ce89 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -1,31 +1,210 @@ + <%= javascript_include_tag "/assets/kindeditor/kindeditor" %> -
    +
    <%# reply_allow = JournalsForMessage.create_by_user? User.current %>

    <%= l(:label_leave_message) %>

    <% if !User.current.logged?%> -
    - <%= l(:label_user_login_tips) %> - <%= link_to l(:label_user_login_new), signin_path %> -
    -
    +
    + <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
    +
    <% else %> - <%= form_for('new_form', :method => :post, - :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%> - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor 'course_message',:height => '140px;',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;", + <%= form_for('new_form', :method => :post, + :url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%#= f.kindeditor 'course_message',:height => '140px;',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;", :placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250}%> - 取  消 - - <%= l(:button_leave_meassge)%> - - <% end %> + +

    + <% end %> +
    + <% end %>
    +
    +
    <%= render :partial => 'history',:locals => { :contest => @contest, :journals => @jour, :state => false} %>
      <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
    \ No newline at end of file + +
    + + \ No newline at end of file diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index e7c5a7c5e..e5f5fc0ec 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -29,9 +29,9 @@ :class => "delete", :title => l(:button_delete)) %> <% end %> <% if reply_allow %> - <%= link_to l(:label_bid_respond_quote),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %> - + <%#= link_to l(:label_bid_respond_quote),'', + {:focus => 'project_respond',:nhname=>"reply_btn", :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %> + <%= link_to l(:label_bid_respond_quote),'javascript:;',{:nhname=>"reply_btn"} %> <% end %>
    diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 788f47d2d..934a4eb33 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -32,7 +32,6 @@ \ 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 ebccfcaf4..8283e15b7 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -31,7 +31,7 @@ } showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); + $('#ajax-modal').before(""); $('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().addClass("popbox_polls"); } diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 043aea489..7f3e426fc 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -25,21 +25,22 @@ <% if file.is_public? || User.current.member_of_course?(course) %>
    - <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s,:class => "c_dblue f_14 f_b f_l hiddent" %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename, preview: true),:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> <%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %> <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> - - <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %> - + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %> + <% else %> <% end %> <% else %> <%= link_to("选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %> <% end %> + <%= link_to_attachment file, text: '下载', class: 'f_l re_open' %> <% else %> <% end %>
    @@ -65,4 +66,4 @@
      <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
    -
    \ No newline at end of file +
    diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index 35aa36195..81b69d754 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -18,7 +18,7 @@ <% project_attachments.each do |file| %>
    - <%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), download_named_attachment_path(file.id, file.filename, preview: true),:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> @@ -30,6 +30,7 @@ <% else %> <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% end %> + <%= link_to_attachment file, text: '下载', class: 'f_l re_open' %> <% end %>
    @@ -37,7 +38,7 @@

    文件大小:<%= number_to_human_size(file.filesize) %>

    <%= link_to( l(:button_delete), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%> -

    <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

    +

    <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

    @@ -51,4 +52,4 @@
      <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
    -
    \ No newline at end of file +
    diff --git a/app/views/files/_project_file_new.html.erb b/app/views/files/_project_file_new.html.erb index 1e217f991..878e6a75e 100644 --- a/app/views/files/_project_file_new.html.erb +++ b/app/views/files/_project_file_new.html.erb @@ -5,7 +5,7 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show_project',:locals => {:project => project}) %>'); showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before(""); + $('#ajax-modal').before(""); $('#ajax-modal').parent().css("top","40%").css("left","36%"); $('#ajax-modal').parent().addClass("popbox_polls"); } diff --git a/app/views/files/quote_resource_show.js.erb b/app/views/files/quote_resource_show.js.erb index fa1f8f4ca..76025fbd2 100644 --- a/app/views/files/quote_resource_show.js.erb +++ b/app/views/files/quote_resource_show.js.erb @@ -6,6 +6,6 @@ showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); +$('#ajax-modal').before(""); $('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file diff --git a/app/views/files/quote_resource_show_project.js.erb b/app/views/files/quote_resource_show_project.js.erb index d1a44e90f..41dc19fc5 100644 --- a/app/views/files/quote_resource_show_project.js.erb +++ b/app/views/files/quote_resource_show_project.js.erb @@ -6,6 +6,6 @@ showModal('ajax-modal', '513px'); $('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); +$('#ajax-modal').before(""); $('#ajax-modal').parent().css("top","30%").css("left","35%"); $('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file diff --git a/app/views/homework_common/_homework_common_form.html.erb b/app/views/homework_common/_homework_detail_manual_form.html.erb similarity index 87% rename from app/views/homework_common/_homework_common_form.html.erb rename to app/views/homework_common/_homework_detail_manual_form.html.erb index e3ef0d237..f70ec6017 100644 --- a/app/views/homework_common/_homework_common_form.html.erb +++ b/app/views/homework_common/_homework_detail_manual_form.html.erb @@ -4,19 +4,20 @@ *  <%= l(:field_name)%>:  - +

  • - - <% if edit_mode %> - <%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> - <% else %> - <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :description,:width=>'83%',:editor_id => 'homework_description_editor' %> - <% end %> +
    + <% if edit_mode %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor' %> + <% end %> +
  • diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb new file mode 100644 index 000000000..1a1804275 --- /dev/null +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -0,0 +1,90 @@ +
      +
    • + + +

      +
    • +
      +
    • + +
      + <% if edit_mode %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor' %> + <% end %> +
      +
    • +
      +
    • + + <%= render :partial => 'attachments/new_form', :locals => {:container => homework} %> +
    • +
      +
    • + + + <%= calendar_for('homework_end_time')%> +
      +
    • + +
      + +
    • + + <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %> +  分 +
      +
    • +
    +
    +

    编程评测设置

    +
    +
      +
    • + + +
      +
    • +
    • + + +
      +
    • + + <% if edit_mode %> + + <% else %> +
      +
    • + + +
    • +
    • + + +
    • +
    • + + + 测试 +
    • +
      +
      + <% end %> +
    +
    \ 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 f9d3f8b70..87977c6a9 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -8,7 +8,7 @@
  • <%= form_for @homework do |f| %> - <%= render :partial => 'homework_common/homework_common_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> + <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => true } %> 提交 <%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> <% end%> diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 87bf37f04..3208bb969 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -16,9 +16,9 @@
    <%= link_to(image_tag(url_to_avatar(homework.user), :width => "42", :height => "42"), user_path(homework.user), :class => "problem_pic fl") %>
    - <%= link_to(homework.user.lastname+homework.user.firstname, user_path(homework.user),:class => 'problem_name fl') %> + <%= link_to(homework.user.lastname+homework.user.firstname, user_path(homework.user),:class => 'problem_name fl',:target => "_blank") %> <%= l(:label_user_create_project_homework) %>: - <%= link_to(homework.name, student_work_index_path(:homework => homework.id), :class => 'problem_tit fl fb c_dblue') %> + <%= link_to(homework.name, student_work_index_path(:homework => homework.id), :class => 'problem_tit fl fb c_dblue',:target => "_blank") %>

    <%= l(:lebel_homework_commit)%> @@ -41,9 +41,9 @@ <%= homework.description.html_safe %>

    -
    - <% if !@entries.nil? && authorize_for('repositories', 'browse') %> - <%= 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} %> + +<% if !@entries.nil? && authorize_for('repositories', 'browse') %> + <%= 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 %> + +

    + <% 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 %> -

    - <% 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 %> + <% 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 %> - <% 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 %> - -

    查看如何提交代码: - <%= link_to(l(:label_how_commit_code_chinese), ch_usage_path, :class => "c_blue") %> - <%= link_to('English', en_usage_path, :class => "c_blue") %> + +

    查看如何提交代码: + <%= link_to(l(:label_how_commit_code_chinese), ch_usage_path, :class => "c_blue") %> + <%= link_to('English', en_usage_path, :class => "c_blue") %> -

    +
    <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index 5a339dc03..11ce7b080 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -6,13 +6,15 @@ <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> + <% else%> + -- <% end%>
  • <% if is_my_work%> - <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name %> + <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02" %> <% else%> - <%= link_to "匿名","javascript:void(0)"%> + <%= link_to "匿名","javascript:void(0)", :class => "c_blue02"%> <% end%>
  • diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 4e9f337c0..dfe61d3db 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -61,7 +61,7 @@
    - <%@work.student_works_scores.order("created_at desc").each do |score|%> + <%@work.student_works_scores.order("updated_at desc").each do |score|%>
    <%= render :partial => 'student_work_score',:locals => {:score => score}%>
    diff --git a/app/views/student_work/_student_work.html.erb b/app/views/student_work/_student_work.html.erb index e8fb2ce3a..e39cb130d 100644 --- a/app/views/student_work/_student_work.html.erb +++ b/app/views/student_work/_student_work.html.erb @@ -6,7 +6,7 @@
  • - <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name%> + <%= link_to student_work.user.show_name,user_path(student_work.user),:title => student_work.user.show_name, :class => "c_blue02"%>
  • <%= link_to student_work.name, student_work_path(student_work),:remote => true,:title => student_work.name, :class => "c_blue02"%> diff --git a/app/views/student_work/_student_work_score.html.erb b/app/views/student_work/_student_work_score.html.erb index c6ff0adae..8d10853f8 100644 --- a/app/views/student_work/_student_work_score.html.erb +++ b/app/views/student_work/_student_work_score.html.erb @@ -8,7 +8,7 @@ <%= score.score%>分 回复 - <%=format_time score.created_at %> + <%=format_time score.updated_at %>

    diff --git a/app/views/student_work/_student_work_title.html.erb b/app/views/student_work/_student_work_title.html.erb index 8162ea971..6fb7e248b 100644 --- a/app/views/student_work/_student_work_title.html.erb +++ b/app/views/student_work/_student_work_title.html.erb @@ -1,5 +1,5 @@

  • - 学号 + 学号
  • 学生姓名 diff --git a/app/views/student_work/add_score.js.erb b/app/views/student_work/add_score.js.erb index 5e6c4fe6d..0ba275d5d 100644 --- a/app/views/student_work/add_score.js.erb +++ b/app/views/student_work/add_score.js.erb @@ -2,7 +2,7 @@ $("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :parti $('#score_<%= @work.id%>').peSlider({range: 'min'}); <% if @is_new%> - $("#score_list_<%= @work.id%>").prepend("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); + $("#score_list_<%= @work.id%>").prepend("
    <%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>
    "); <% else %> $("#work_score_<%= @score.id%>").html("<%= escape_javascript(render :partial => 'student_work_score', :locals => {:score => @score}) %>"); <% end%> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 1cd665569..c9e8cd4c6 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -36,7 +36,7 @@ <% if @show_all%> - 搜索 + 搜索 <% end%> <% if @is_teacher%>
    diff --git a/app/views/users/_history.html.erb b/app/views/users/_history.html.erb index 9b5744251..d69b6b25b 100644 --- a/app/views/users/_history.html.erb +++ b/app/views/users/_history.html.erb @@ -11,7 +11,8 @@ <%= link_to journal.user, user_path(journal.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%><%= format_time(journal.created_on) %>
    -

    <%= textilizable journal.notes%>

    + +

    <%=journal.notes.html_safe%>

    <% ids = 'project_respond_form_'+ journal.id.to_s%> @@ -23,8 +24,9 @@ :class => "delete", :title => l(:button_delete)) %> <% end %> <% if reply_allow %> - <%= link_to l(:label_bid_respond_quote),'', - {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %> + <%#= link_to l(:label_bid_respond_quote),'', + {:focus => 'project_respond',:nhname=>'reply_btn', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea')); $('##{ids} textarea') ;return false;"} %> + <%= link_to l(:label_bid_respond_quote),'javascript:;',{:nhname=>'reply_btn'} %> <% end %> diff --git a/app/views/users/_user_jours.html.erb b/app/views/users/_user_jours.html.erb index b5badf60c..ee8d14841 100644 --- a/app/views/users/_user_jours.html.erb +++ b/app/views/users/_user_jours.html.erb @@ -1,3 +1,17 @@ + +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
    <% reply_allow = JournalsForMessage.create_by_user? User.current %> @@ -49,3 +63,169 @@ } + +
    + diff --git a/app/views/users/_user_show.html.erb b/app/views/users/_user_show.html.erb index 3bea6d420..8e3d27666 100644 --- a/app/views/users/_user_show.html.erb +++ b/app/views/users/_user_show.html.erb @@ -42,7 +42,7 @@ <%# memberships = user.memberships.all(:conditions => cond) %> <% user_courses = user_courses_list(user) %> <%= l(:label_x_course_contribute_to, :count => user_courses.count) %> - <%= ":" unless user_courses.empty? %> + <%#= ":" unless user_courses.empty? %> <% for course in user_courses %> <%# if course.name != nil %> <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.host_course} %><%= (user_courses.last == course) ? '' : ',' %> diff --git a/app/views/users/search.html.erb b/app/views/users/search.html.erb index ef1db3b0c..13979f79f 100644 --- a/app/views/users/search.html.erb +++ b/app/views/users/search.html.erb @@ -30,8 +30,8 @@