From cd8f3bdea3394e00b6abb18247cb3e7e81ee2184 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Thu, 4 Jun 2015 17:49:53 +0800 Subject: [PATCH 01/28] ... --- app/views/courses/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 0feca0d1b..63285a2cd 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -35,7 +35,7 @@ :class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type, 'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link", 'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%> - <%if @controller_name=='ActivityNotifys' && !e.get_notify_is_read%> + <%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%> <%end%>
From d2c51f27b6c79baebf815d8c6a031789c3450e0a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 09:48:23 +0800 Subject: [PATCH 02/28] =?UTF-8?q?Bid=E5=8A=9F=E8=83=BD=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E5=BA=9F=E5=BC=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 2193 ++++++++++++++-------------- 1 file changed, 1097 insertions(+), 1096 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 35236414f..7db03aca1 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 +# From 59c4e04e37101bac8a6ad373f3c6afcb3e386514 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 09:57:33 +0800 Subject: [PATCH 03/28] =?UTF-8?q?=E5=88=A0=E9=99=A4bid=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 2 +- config/routes.rb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 7db03aca1..aa1c369a0 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -1,5 +1,5 @@ # # fq -#Bid功能已经废弃 +#Bid功能已经废弃,代码参考用 # class BidsController < ApplicationController # #Added by young # menu_item l(:label_homework), :only => [:edit, :udpate] diff --git a/config/routes.rb b/config/routes.rb index e166e37e5..d2c21f6ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -257,7 +257,6 @@ RedmineApp::Application.routes.draw do post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' # boards end - # delete 'bids/homework', :to => 'bids#homework_destroy' # Misc issue routes. TODO: move into resources match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues' @@ -764,7 +763,6 @@ RedmineApp::Application.routes.draw do delete 'attachment/:id', :to => 'attachments#delete_homework' match 'new_join', :to => 'courses#new_join', :as => 'try_join' match 'new_join_group', :to => 'courses#new_join_group', :as => 'try_join_group' - # match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post ######################## From 523dc9b343dae770e1ae6ed9ab38b32917790438 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 10:06:30 +0800 Subject: [PATCH 04/28] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E3=80=81=E5=8F=91=E5=B8=96=E5=9B=9E=E5=B8=96=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 9e36d15f4..c3cb3d8c9 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -94,8 +94,8 @@ 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() @@ -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] != '') From d9dd744fb1f20781c23bb5e9aabe0993bfc275d8 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 10:16:16 +0800 Subject: [PATCH 05/28] ... --- app/controllers/messages_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index c3cb3d8c9..b1da35cfc 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -99,7 +99,7 @@ class MessagesController < ApplicationController 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 @@ -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 From 8fcf7ac7a815bfed361a1fc617a5dc52802fd14f Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 10:25:42 +0800 Subject: [PATCH 06/28] ... --- app/views/courses/show.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 63285a2cd..60134381f 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -49,6 +49,8 @@ <% end%> <% end%> +<% elsif @controller_name=='ActivityNotifys' %> +

<%= l(:label_no_data) %>

<% end%> <% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
From 7bab135ac795e69001cc7fa89c8d90dae8260efc Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 10:25:58 +0800 Subject: [PATCH 07/28] =?UTF-8?q?1=E3=80=81=E4=B8=8A=E4=BC=A0=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=97=B6=E5=85=AC=E5=BC=80=E5=8D=95=E9=80=89=E6=A1=86?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=202=E3=80=81=E8=AF=BE=E7=A8=8B=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E6=9C=89=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_course_file.html.erb | 2 +- public/stylesheets/courses.css | 2 -- public/stylesheets/project.css | 2 -- public/stylesheets/public.css | 1 + 4 files changed, 2 insertions(+), 5 deletions(-) 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/public/stylesheets/courses.css b/public/stylesheets/courses.css index 7d4436704..bbc6f5b55 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -380,8 +380,6 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;} .attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';} .attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; } a.remove-upload:hover {text-decoration:none !important;} -.attachments_fields input.is_public_checkbox {width:20px;} - .attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;} a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;} diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 6cba7011f..a32a050d7 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -241,8 +241,6 @@ blockquote {background: #eeeeee;padding: 10px;margin-bottom: 10px;} #attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';} #attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; } a.remove-upload:hover {text-decoration:none !important;} -#attachments_fields input.is_public_checkbox {width:20px;} - #attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;} a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 306520f96..59431b3ad 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -438,3 +438,4 @@ a.box_close{background:url(../images/img_floatbox.png) -22px 0 no-repeat;} .tl{text-align: left;} img{max-width: 100%;} .attachments {clear: both;} +.is_public_checkbox{margin-left: 15px;margin-right: 10px;} From bf653fa94f37ec0fa0391167532cb814bc429e56 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 10:31:51 +0800 Subject: [PATCH 08/28] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/index.html.erb | 2 +- public/javascripts/course.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/public/javascripts/course.js b/public/javascripts/course.js index 0570ec437..74dceddc1 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -793,7 +793,7 @@ function SearchByName(obj,url,event) location.href = url + "&name=" + obj.val(); } } -function SearchByName(obj,url) +function SearchByName_1(obj,url) { location.href = url + "&name=" + obj.val(); } From a456616212ac7c0d964068e62eae1d5701a49715 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 10:33:42 +0800 Subject: [PATCH 09/28] ... --- app/controllers/activity_notifys_controller.rb | 4 +--- app/views/courses/show.html.erb | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) 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/views/courses/show.html.erb b/app/views/courses/show.html.erb index 60134381f..9bbe4ea5a 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -3,7 +3,9 @@ <%= l(:label_activity)%>

与我相关

- + + +
<% else %>

<%= l(:label_activity)%>

From c31e370ad62db1330dc298a058fbd49247f41544 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 10:37:24 +0800 Subject: [PATCH 10/28] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=9A=E9=80=89=E4=BA=BA=E6=88=91=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E3=80=81=E9=80=89=E5=85=A5=E6=88=91=E7=9A=84?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E8=AF=BE=E7=A8=8B=E5=BC=B9=E5=87=BA=E6=A1=86?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=8C=89=E9=92=AE=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/quote_resource_show.js.erb | 2 +- public/javascripts/course.js | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) 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/public/javascripts/course.js b/public/javascripts/course.js index 74dceddc1..b629530f0 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -757,8 +757,8 @@ function goTopEx() { } } -//匿评评分提示 $(function(){ + //匿评评分提示 $(".student_score_info").bind("mouseover",function(e){ //alert($(this).html()); $(this).find("div").show(); @@ -769,6 +769,8 @@ $(function(){ //alert($(this).html()); $(this).find("div").hide(); }); + + $("#about_project label").eq(1).remove(); }); //匿评弹框取消按钮 @@ -797,7 +799,3 @@ function SearchByName_1(obj,url) { location.href = url + "&name=" + obj.val(); } - -$(function(){ - $("#about_project label").eq(1).remove(); -}); \ No newline at end of file From 9d1100a9dfb0a6a56915ffc5602d54eb3ba628da Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 10:50:43 +0800 Subject: [PATCH 11/28] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=86=85=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E9=80=89=E4=BA=BA=E6=88=91=E7=9A=84=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_project_file_new.html.erb | 2 +- app/views/files/quote_resource_show_project.js.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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_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 From 8b0eb21d0828b7948a6a9056d94a3d5aea2ef2d6 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 11:17:00 +0800 Subject: [PATCH 12/28] =?UTF-8?q?=E5=85=B3=E6=B3=A8=E9=9C=80=E6=B1=82?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=8F=96=E6=B6=88=EF=BC=8C=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=BF=9B=E5=85=A5=E4=B8=AA=E4=BA=BA=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 84 ++++++++++++++--------------- lib/redmine.rb | 4 +- 2 files changed, 44 insertions(+), 44 deletions(-) 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/lib/redmine.rb b/lib/redmine.rb index 60488b8d0..ba0fd0cee 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -451,7 +451,7 @@ Redmine::MenuManager.map :user_enterprise_menu do |menu| menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name} - menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user} + # menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user} end @@ -459,7 +459,7 @@ Redmine::MenuManager.map :user_menu_self do |menu| menu.push :activity, {:controller => 'users', :action => 'show', :host => Setting.host_name } menu.push :user_information, {:controller => 'users', :action => 'info', :host => Setting.host_user} menu.push :user_project, {:controller => 'users', :action => 'user_projects', :host => Setting.host_name} - menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user} + # menu.push :requirement_focus, {:controller => 'users', :action => 'watch_bids', :host => Setting.host_user} menu.push :user_newfeedback, {:controller => 'users', :action => 'user_newfeedback', :host => Setting.host_user} end From f466084a17ab9d14956bd2bf2f31f45d22f636ec Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 11:22:38 +0800 Subject: [PATCH 13/28] =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=B0=B1=E4=B8=8D=E6=98=BE=E7=A4=BA=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_users.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 269017eb8..0ebdea211 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -218,7 +218,7 @@ <% end %> - <% unless @user.user_extensions.nil?&&@user.user_extensions.location.empty?%> + <% if @user.user_extensions && @user.user_extensions.location && !@user.user_extensions.location.empty?%> From 2e7c6c4afbdd0251a9fca2879f0379f2f02cbcb5 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 11:39:55 +0800 Subject: [PATCH 14/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug#2725=20:=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=90=9C=E7=B4=A2--=E9=BB=98=E8=AE=A4=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8D=E5=92=8C=E5=A7=93=E5=90=8D=E4=B8=80=E8=B5=B7?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/users_service.rb | 4 +++- app/views/users/search.html.erb | 4 ++-- app/views/welcome/_search_project.html.erb | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) 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/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 @@ <%#= hidden_field_tag 'project_type', project_type %>
From 427553d4e5b03ef789a682928f7ed42a4c49d9bb Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 13:56:13 +0800 Subject: [PATCH 15/28] =?UTF-8?q?=E8=80=81=E5=B8=88=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E3=80=81=E5=AD=A6=E7=94=9F=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E6=97=B6=E5=88=A0=E9=99=A4=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=B2=A1=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 8 ++++---- app/views/layouts/base_users.html.erb | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index ec0480c19..353108dc7 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -216,13 +216,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) } @@ -246,7 +246,7 @@ class AttachmentsController < ApplicationController end format.js - end + end end def delete_homework diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 0ebdea211..5686c9a1b 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -220,7 +220,6 @@ <% end %> <% if @user.user_extensions && @user.user_extensions.location && !@user.user_extensions.location.empty?%> - <%= l(:label_location) %>: From 18e41e562a3a71d877aa16c3f03b8831e1dabcc6 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 14:16:21 +0800 Subject: [PATCH 16/28] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E5=8A=A0=E4=B8=8A=E5=85=B6=E4=BB=96=E7=9A=84?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/show.html.erb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 589a0f25d..bf276925a 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} %> @@ -123,21 +124,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(){ From a967a86a1dbf8794287f13caccadfee9d63f950b Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 5 Jun 2015 14:24:50 +0800 Subject: [PATCH 17/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6500?= =?UTF-8?q?=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 12 ++++++++++++ .../projects/invite_members_by_mail.html.erb | 18 +++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3c34aa549..1793eb39c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -365,6 +365,18 @@ 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 + unless @inviter_lists.blank? + @inviter_lists.each do|inviter_list| + @inviters = [] + @waiters = [] + @inviters << inviter_list.user + @inviters_count = @inviters.size + unless inviter_list.user.member_of?(@project) + @waiters << inviter_list.user + @waiters_count = @waiters.size + end + end + end @is_zhuce = false respond_to do |format| format.html diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb index ce7ea2aa1..bb98b3356 100644 --- a/app/views/projects/invite_members_by_mail.html.erb +++ b/app/views/projects/invite_members_by_mail.html.erb @@ -79,19 +79,23 @@ <% end %> <%# 邀请用户的状态 %> <% unless @inviter_lists.blank? %> -
+
+ <% if @inviters_count > 0 %> 已邀请的用户
<% @inviter_lists.each do |inviter_list| %> - <%= inviter_list.user.name %>
+ <%= inviter_list.user.name unless inviter_list.user.nil? %>
<% end %> -
+ <% end %> +
+ <% unless @waiters_count == 0 %> 等待加入项目的用户
<% @inviter_lists.each do |inviter_list| %> - <% unless inviter_list.user.member_of?(@project) %> - <%= inviter_list.user.name %>
- <% end %> + <% unless inviter_list.user.member_of?(@project) %> + <%= inviter_list.user.name unless inviter_list.user.nil? %>
+ <% end %> <% end %> -
+ <% end %> +
<% end %>
From f7b3229065c264944ef42f32244bc48c5e9ee223 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 14:33:22 +0800 Subject: [PATCH 18/28] =?UTF-8?q?=E5=BD=93=E4=BD=9C=E5=93=81=E4=B8=AD?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=99=84=E4=BB=B6=E6=97=B6=EF=BC=8C=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 6 ++--- public/javascripts/application.js | 34 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 043552872..d932d8b4d 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -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 !!" diff --git a/public/javascripts/application.js b/public/javascripts/application.js index d9100b0bb..c514e8940 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -901,24 +901,30 @@ $(function(){ $('#download_homework_attachments').bind('ajax:complete', function (event, data, status, xhr) { if(status == 'success'){ var res = JSON.parse(data.responseText); - if(res.length<1){ + if(res.length == null){ + alert("该作业没有任何附件可下载"); + } + else if(res.length<1){ return; } - if(res.length==1){ - location.href = '/zipdown/download?file='+res[0].file;return; - } - document.getElementById('light').style.display='block'; - $container = $('#light .upload_box_ul'); - $container.empty(); - for(var i = 0; i 1){ - des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; - } else { - des = '第'+res[i].index+'个学生的作品下载'; + else + { + if(res.length==1){ + location.href = '/zipdown/download?file='+res[0].file;return; } - $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + document.getElementById('light').style.display='block'; + $container = $('#light .upload_box_ul'); + $container.empty(); + for(var i = 0; i 1){ + des = '第'+res[i].index+'-'+(res[i].count+res[i].index-1)+'个学生的作品下载'; + } else { + des = '第'+res[i].index+'个学生的作品下载'; + } + $('
  • '+(i+1)+'. '+des+'  (共'+res[i].size+'M)
  • ').appendTo($container); + } } } }); From 412efb28fe1dac0a0352a85ac52fa26414ea244d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 14:39:37 +0800 Subject: [PATCH 19/28] =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E6=89=93=E5=BC=80=E4=B8=80=E4=B8=AAtab?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_common/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 87bf37f04..1e8189ddb 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)%> From 54abe5d85820c3d6c8f991804563c3f1ca6589e8 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 5 Jun 2015 14:51:36 +0800 Subject: [PATCH 20/28] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=9A=84=E6=88=90=E5=91=98=E5=88=99=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/invite_members_by_mail.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/invite_members_by_mail.html.erb b/app/views/projects/invite_members_by_mail.html.erb index bb98b3356..7b3a4c552 100644 --- a/app/views/projects/invite_members_by_mail.html.erb +++ b/app/views/projects/invite_members_by_mail.html.erb @@ -87,7 +87,7 @@ <% end %> <% end %>
    - <% unless @waiters_count == 0 %> + <% unless @waiters_count.nil? %> 等待加入项目的用户
    <% @inviter_lists.each do |inviter_list| %> <% unless inviter_list.user.member_of?(@project) %> From a148c49fa9ba5a44a948342d1578d854b2608bc0 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 5 Jun 2015 15:02:22 +0800 Subject: [PATCH 21/28] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E7=BB=99=E5=87=BA?= =?UTF-8?q?=E6=BF=80=E6=B4=BB=E8=B4=A6=E5=8F=B7=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mailer/send_invite_in_project.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/mailer/send_invite_in_project.html.erb b/app/views/mailer/send_invite_in_project.html.erb index 6dbfcbda6..51b189f37 100644 --- a/app/views/mailer/send_invite_in_project.html.erb +++ b/app/views/mailer/send_invite_in_project.html.erb @@ -4,9 +4,9 @@

  • <%= l(:mail_issue_content)%> -

    <%= @subject %>

    -

    <%= link_to @project_url, @project_url%>

    -

    点击链接后,将自动为您注册账号

    +

    <%= @subject %>

    +

    点击链接激活账号,系统会依据给出的密码和账号自动登录Trustie平台。

    +

    <%= link_to @project_url, @project_url%>

    您的账号为:<%= @email %>

    密码为: <%= @password %>

    From 8adb00fccb70e5f865fd3f6f78c3ae1a38cd1b55 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 5 Jun 2015 15:26:14 +0800 Subject: [PATCH 22/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E9=82=AE=E4=BB=B6=E4=B8=AD=E6=A0=B7=E5=BC=8F=E5=92=8C?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=B8=8D=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mailer/message_posted.html.erb | 2 +- app/views/mailer/send_invite_in_project.html.erb | 2 +- app/views/mailer/wiki_content_added.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/mailer/message_posted.html.erb b/app/views/mailer/message_posted.html.erb index dbe41976a..2be4e486e 100644 --- a/app/views/mailer/message_posted.html.erb +++ b/app/views/mailer/message_posted.html.erb @@ -23,7 +23,7 @@
  • <%= l(:mail_issue_content)%> - <%= @message.content %> + <%= @message.content.html_safe? %>
  • diff --git a/app/views/mailer/send_invite_in_project.html.erb b/app/views/mailer/send_invite_in_project.html.erb index 51b189f37..ec559732f 100644 --- a/app/views/mailer/send_invite_in_project.html.erb +++ b/app/views/mailer/send_invite_in_project.html.erb @@ -5,7 +5,7 @@
  • <%= l(:mail_issue_content)%>

    <%= @subject %>

    -

    点击链接激活账号,系统会依据给出的密码和账号自动登录Trustie平台。

    +

    点击下面的链接即可激活账号,系统会根据给出的密码和账号自动登录Trustie平台。

    <%= link_to @project_url, @project_url%>

    您的账号为:<%= @email %>

    密码为: <%= @password %>

    diff --git a/app/views/mailer/wiki_content_added.html.erb b/app/views/mailer/wiki_content_added.html.erb index 8c83f62c8..c4f6929a8 100644 --- a/app/views/mailer/wiki_content_added.html.erb +++ b/app/views/mailer/wiki_content_added.html.erb @@ -1,3 +1,3 @@

    <%= l(:mail_body_wiki_content_added, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url), :author => h(@wiki_content.author)).html_safe %>
    -<%=h @wiki_content.comments %>

    +<%=h @wiki_content.comments.html_safe? %>

    From f67521164261784815f58c6c587bcd4241b50435 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 15:26:35 +0800 Subject: [PATCH 23/28] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8C=E6=B2=A1=E6=9C=89=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E5=A7=93=E5=90=8D=E5=B0=B1=E6=98=BE=E7=A4=BAlogin=EF=BC=8C?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E9=99=84=E4=BB=B6=E5=AF=BC=E5=87=BA=E4=B9=9F?= =?UTF-8?q?=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 6 +++--- app/models/user.rb | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index d932d8b4d..7eb06d270 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -60,7 +60,7 @@ class ZipdownController < ApplicationController 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.user.show_name + "_" + homework.name + ".zip", :type => detect_content_type(zipfile.file_path) if(zipfile) else render file: 'public/no_file_found.html' @@ -148,7 +148,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 @@ -168,7 +168,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/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 From bef1917c4efff2eb6837a0adc6668b0ec7008e0c Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 5 Jun 2015 15:32:19 +0800 Subject: [PATCH 24/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mailer/message_posted.html.erb | 2 +- app/views/mailer/wiki_content_added.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/mailer/message_posted.html.erb b/app/views/mailer/message_posted.html.erb index 2be4e486e..c55f4b000 100644 --- a/app/views/mailer/message_posted.html.erb +++ b/app/views/mailer/message_posted.html.erb @@ -23,7 +23,7 @@
  • <%= l(:mail_issue_content)%> - <%= @message.content.html_safe? %> + <%= @message.content.html_safe %>
  • diff --git a/app/views/mailer/wiki_content_added.html.erb b/app/views/mailer/wiki_content_added.html.erb index c4f6929a8..244597a1b 100644 --- a/app/views/mailer/wiki_content_added.html.erb +++ b/app/views/mailer/wiki_content_added.html.erb @@ -1,3 +1,3 @@

    <%= l(:mail_body_wiki_content_added, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url), :author => h(@wiki_content.author)).html_safe %>
    -<%=h @wiki_content.comments.html_safe? %>

    +<%=h @wiki_content.comments.html_safe %>

    From c62d468ed3d1c8970eaedc16014e1f9c798e3862 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 5 Jun 2015 15:54:56 +0800 Subject: [PATCH 25/28] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=96=B0=E9=97=BB=E5=92=8C=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mailer/send_for_user_activities.html.erb | 2 +- config/locales/projects/zh.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb index 81a65442f..da8b4c8c3 100644 --- a/app/views/mailer/send_for_user_activities.html.erb +++ b/app/views/mailer/send_for_user_activities.html.erb @@ -262,7 +262,7 @@ <% unless @project_news.first.nil? %>

      - <%= l(:label_course_news) %> + <%= l(:label_project_news) %> (<%= @project_news.count %>)

      <% @project_news.each do |project_new|%> diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 78f608a80..e01e2992c 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -86,7 +86,7 @@ zh: label_roadmap: 里程碑 #版本路线图 project_module_dts: DTS测试工具 label_project_tool_response: 用户反馈 - label_course_news: 项目新闻 + label_project_news: 项目新闻 label_project_overview: "项目简介" label_expend_information: 展开更多信息 From b4732814e6174d07742c2b429021907e7944a923 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 16:20:26 +0800 Subject: [PATCH 26/28] ... --- app/controllers/courses_controller.rb | 1 + app/helpers/activity_notifys_helper.rb | 7 +++++++ app/views/courses/show.html.erb | 23 ++++++++++++++++++++--- public/stylesheets/courses.css | 2 +- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 app/helpers/activity_notifys_helper.rb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 333ad77b1..e89f621c8 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 diff --git a/app/helpers/activity_notifys_helper.rb b/app/helpers/activity_notifys_helper.rb new file mode 100644 index 000000000..15fc43b54 --- /dev/null +++ b/app/helpers/activity_notifys_helper.rb @@ -0,0 +1,7 @@ +module ActivityNotifysHelper + def get_new_notify_count(container,type) + logger.info('xxoo') + query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=?',container.id,type,User.current.id); + return query.count() + end +end \ No newline at end of file diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 9bbe4ea5a..4fbf3ad43 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -1,7 +1,9 @@
      <% if @controller_name=='ActivityNotifys' %> - <%= l(:label_activity)%> -

      与我相关

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

      与我相关 + +

      @@ -80,6 +84,14 @@ \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index bbc6f5b55..edb70075b 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -677,7 +677,7 @@ input#score{ width:40px;} /* 与我相关 */ .new_icon{background:url(../images/new_icon.png) 0px 0px no-repeat; width:35px; height:15px; display:block;} -a.about_me{ width:80px;text-align:center;font-size:16px; color:#64bdd9; margin:10px 0 0 10px;} +a.about_me{text-align:center;font-size:16px; color:#64bdd9; margin:10px 0 0 10px;} a:hover.about_me{ color:#0781b4;} From 79893c4917548bb0b1f3dc09a888fa00479e2033 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 16:57:09 +0800 Subject: [PATCH 27/28] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=A0=B9=E6=8D=AE=E9=AA=8C=E8=AF=81=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E7=9B=B8=E5=BA=94=E7=A9=BA=E9=97=B4focus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/course.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/javascripts/course.js b/public/javascripts/course.js index b629530f0..4c0cae670 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -470,7 +470,15 @@ $(function(){ //老师提交 新建/修改 作业 function submit_homework(id) { - if(regex_homework_name()&®ex_evaluation_num()) + if(!regex_homework_name()) + { + $("#homework_name").focus(); + } + else if(!regex_evaluation_num()) + { + $("#evaluation_num").focus(); + } + else { homework_description_editor.sync(); $("#"+id).submit(); From c85fd9f7b8c2c81fc5282c33740dd3d7f600bdd2 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 5 Jun 2015 17:17:35 +0800 Subject: [PATCH 28/28] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=96=B0=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=A8=A1=E5=9D=97=E7=9A=84=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 7 ++--- .../mailer/send_for_user_activities.html.erb | 27 ++----------------- .../mailer/send_for_user_activities.text.erb | 24 ++--------------- 3 files changed, 8 insertions(+), 50 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 087fb6d73..1325ef613 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -115,14 +115,15 @@ 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") + # @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 @@ -157,7 +158,7 @@ class Mailer < ActionMailer::Base @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, + has_content = [@issues,@course_messages,@project_messages,@course_news,@project_news, @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty?} mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb index da8b4c8c3..e1712a15d 100644 --- a/app/views/mailer/send_for_user_activities.html.erb +++ b/app/views/mailer/send_for_user_activities.html.erb @@ -3,7 +3,7 @@ <%= @subject %> <% if @attachments.first || @course_news.first || @bids.first || - @homeworks.first || @course_journal_messages.first|| @course_messages.first %> + @course_journal_messages.first|| @course_messages.first %>

      <%= l(:label_course_overview)%>

      <% unless @course_news.first.nil? %> @@ -39,7 +39,7 @@ <% end %> - <% if !@bids.first.nil? || !@homeworks.first.nil? %> + <% if !@bids.first.nil? %>

        <%= l(:label_homework_overview) %>(<%= @bids.count %>)

        <% unless @bids.first.nil?%> @@ -65,29 +65,6 @@ <% end %> <% end %> - <% unless @homeworks.first.nil? %> - <% @homeworks.each do |homework| %> -
      • - - [ - - <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value), - :class=> "wmail_column", - :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %> - ] - - <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value), :class => "wmail_name", - :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%> - <%= l(:label_course_submit_homework) %> - - <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(:id => homework.bid.id,:token => @token.value), - :class => 'wmail_info', - :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" - %> - <%= format_time(homework.created_at) %> -
      • - <% end %> - <% end %>
      diff --git a/app/views/mailer/send_for_user_activities.text.erb b/app/views/mailer/send_for_user_activities.text.erb index 59735225d..2a2382301 100644 --- a/app/views/mailer/send_for_user_activities.text.erb +++ b/app/views/mailer/send_for_user_activities.text.erb @@ -1,6 +1,6 @@ <%= @subject %> <% if @attachments.first || @course_news.first || @bids.first || - @homeworks.first || @course_journal_messages.first|| @course_messages.first %> + @course_journal_messages.first|| @course_messages.first %> <%= l(:label_course_overview)%> <% unless @course_news.first.nil? %> <%= l(:label_course_news) %> @@ -27,7 +27,7 @@ <% end %> <% end %> - <% if !@bids.first.nil? || !@homeworks.first.nil? %> + <% if !@bids.first.nil? %> <%= l(:label_homework_overview) %><%= @bids.count %> <% unless @bids.first.nil?%> <% @bids.each do |bid| %> @@ -51,26 +51,6 @@ <% end %> <% end %> - <% unless @homeworks.first.nil? %> - <% @homeworks.each do |homework| %> - ▪[ - - <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value) - - %> - ] - - <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value) - %> - <%= l(:label_course_submit_homework) %> - - <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(homework.bid,:token => @token.value) - - - %> - <%= format_time(homework.created_at) %> - <% end %> - <% end %>