diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 02dfe9a45..2246c35db 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -144,8 +144,9 @@ class AccountController < ApplicationController when '1' #register_by_email_activation(@user) unless @user.new_record? - flash[:notice] = l(:notice_account_register_done) - render action: 'email_valid', locals: {:mail => @user.mail} + redirect_to account_email_valid_path(:mail => @user.mail, :user_id => @user.id) + # flash[:notice] = l(:notice_account_register_done) + # render action: 'email_valid', locals: {:mail => @user.mail} end when '3' #register_automatically(@user) @@ -244,8 +245,18 @@ class AccountController < ApplicationController end def email_valid - + begin + @mail_type = params[:mail].split("@")[1] + @user = User.find(params[:user_id]) + rescue + return render_404 + end + respond_to do |format| + format.html { render :layout => "base_mail"} + format.js + end end + def resendmail result = {:status=>1, :email=>""} user = User.find(params[:user]) if params[:user] diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 21653b3e4..c46c039ce 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -500,6 +500,10 @@ class ApplicationController < ActionController::Base #��ȡ�γ� def find_course @course= Course.find(params[:id]) + if @course.is_delete == 1 and !User.current.admin? + render_404 + return + end rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 8e7e883ff..493b313cf 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -67,6 +67,30 @@ class BoardsController < ApplicationController else render_403 end + elsif @contest + if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest))) + @boards = @contest.boards.includes(:last_message => :author).all + if @contest.boards.empty? + @board = @contest.boards.build + @board.name = " #{l(:label_board_contest) }" + @board.description = @contest.name.to_s + @board.project_id = -1 + @board.course_id = -1 + if @board.save + @boards = @contest.boards.includes(:last_message => :author).all + end + end + if params[:board_id] + @board = Board.find params[:board_id].to_i + else + unless @contest.boards.where("parent_id is NULL").empty? + @board = @contest.boards.where("parent_id is NULL").first + end + end + show and return + else + render_403 + end end end @@ -116,6 +140,25 @@ class BoardsController < ApplicationController else @topics = []; end + elsif @contest + if (@board) + @topic_count = @board.topics.count(); + @topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10 + @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all(); + else + @board = @contest.boards.build + @board.name = " #{l(:label_board_contest) }"#self.name + @board.description = @contest.name.to_s + @board.project_id = -1 + @board.course_id = -1 + if @board.save + @topic_count = @board.topics.count(); + @topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10 + @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all(); + else + @topics = [] + end + end end #根据 赞+回复数排序 @@ -162,6 +205,10 @@ class BoardsController < ApplicationController @left_nav_type = 2 @params=params render :action => 'show', :layout => 'base_courses' + elsif @contest + @left_nav_type = 4 + @params=params + render :action => 'show', :layout => 'base_contests' end } format.atom { @@ -296,6 +343,8 @@ private @board = @project.boards.find(params[:id]) if params[:id] elsif @course @board = @course.boards.find(params[:id]) if params[:id] + elsif @contest + @board = @contest.boards.find(params[:id]) if params[:id] end rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/controllers/contest_members_controller.rb b/app/controllers/contest_members_controller.rb index 99c63bfe2..c9760682b 100644 --- a/app/controllers/contest_members_controller.rb +++ b/app/controllers/contest_members_controller.rb @@ -38,7 +38,7 @@ class ContestMembersController < ApplicationController #status = 0 表示给学生发,status = 1表示给老师发 course_join = ContestMessage.new(:user_id =>user_id, :contest_message_id=>User.current.id,:contest_id => @contest.id,:contest_message_type=>"JoinContest", :content => role_ids, :viewed => false, :status => 0) course_join.save - ContestMessage.create(:user_id => User.current.id, :contest_message_id => user_id, :contest_message_id => @contest.id, :contest_message_type => "JoinContest",:content => role_ids, :viewed => false, :status => 1) + #ContestMessage.create(:user_id => User.current.id, :contest_message_id => user_id, :contest_message_id => @contest.id, :contest_message_type => "JoinContest",:content => role_ids, :viewed => false, :status => 1) end end @contest.contest_members << members diff --git a/app/controllers/contestant_works_controller.rb b/app/controllers/contestant_works_controller.rb index 1c95d71e3..a73775ae8 100644 --- a/app/controllers/contestant_works_controller.rb +++ b/app/controllers/contestant_works_controller.rb @@ -93,11 +93,11 @@ class ContestantWorksController < ApplicationController def show #@score = student_work_score @work,User.current @is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin? - # if @homework.homework_detail_manual.comment_status == 2 && !@is_teacher && @work.user != User.current - # @student_work_scores = @work.student_works_scores.where("user_id = #{User.current.id} and reviewer_role = 3").order("updated_at desc") - # else - # @student_work_scores = student_work_score_record(@work) - # end + if @contestwork.work_status == 3 && User.current.judge_of_contest?(@contest) && @contestwork.online_evaluation + @student_work_scores = @work.contestant_work_scores.where("user_id = #{User.current.id} and reviewer_role = 2").order("updated_at desc") + else + @student_work_scores = contestant_work_score_record(@work) + end respond_to do |format| format.js end @@ -362,6 +362,54 @@ class ContestantWorksController < ApplicationController end end + def add_score + @is_last = params[:is_last] == "true" + @is_teacher = User.current.admin_of_contest?(@contest) || User.current.judge_of_contest?(@contest) || User.current.admin? + #老师、教辅可以随时评分,学生只能在匿评作业的匿评阶段进行评分 + render_403 and return unless User.current.judge_of_contest?(@contest) && @contestwork.work_status == 3 + @is_last_a = @work.contestant_work_scores.empty? + @new_score = ContestantWorkScore.new + @new_score.score = params[:score].to_i + @new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" + @new_score.user_id = User.current.id + @new_score.contestant_work_id = @work.id + @new_score.reviewer_role = 2 + + # if User.current.admin? + # @new_score.reviewer_role = 1 + # else + # role = User.current.members.where("course_id = ?",@course.id).first.roles.where("is_current = 1").first.name + # @new_score.reviewer_role = get_role_by_name(role) + # end + # if @score + # if @is_teacher + # @is_new = true + # @is_last_a = false + # else + # @is_new = false + # end + # else + # @is_new = true + # end + + @new_score.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@new_score) + + if @new_score.save + @contestwork.update_column('updated_at', Time.now) + update_contest_activity(@contestwork.class,@contestwork.id) + update_user_activity(@contestwork.class,@contestwork.id) + if @work.save + @work = @contestwork.contestant_works.select("contestant_works.*,contestant_works.work_score as score").where(:id => @work.id).first + @count = @contestwork.contestant_works.has_committed.count + @student_work_scores = contestant_work_score_record @work + respond_to do |format| + format.js + end + end + end + end + private def hsd_committed_work?(user, homework) sw = ContestantWork.where("user_id =? and work_id =?", user, homework).first diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index d3c1f9a4e..5295477f5 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -3,11 +3,13 @@ class ContestsController < ApplicationController include ContestsHelper helper :contest_members + helper :users - before_filter :find_contest, :only => [:show, :settings, :update, :contest_activities, :search_member, :private_or_public, :switch_role] + before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :search_member, :private_or_public, :switch_role, :set_invite_code_halt, :renew] before_filter :is_logged, :only => [:index, :new, :create] - before_filter :is_admin?, :only => [:settings] + before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy] before_filter :is_member?, :only => [:show, :contest_activities] + layout "base_contests" def show @@ -105,6 +107,10 @@ class ContestsController < ApplicationController end end + def destroy + @contest.update_attributes(:is_delete => true) + end + def private_or_public @contest.update_attributes(:is_public => !@contest.is_public) @@ -169,8 +175,12 @@ class ContestsController < ApplicationController end case params[:agree] when 'Y' - member = ContestMember.new(:user_id => apply_user.id) - Contest.find(applied_contest.contest_id).contest_members << member + if ContestMember.where(:user_id => apply_user.id).first.nil? + member = ContestMember.new(:user_id => apply_user.id) + Contest.find(applied_contest.contest_id).contest_members << member + else + member = ContestMember.where(:user_id => apply_user.id).first + end contest_member_roles = member.contest_member_roles if integer_ids.include?(14) && integer_ids.include?(13) @@ -181,8 +191,8 @@ class ContestsController < ApplicationController end ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>1) - applied_contest.applied_messages.update_all(:status => 1, :viewed => 1) - @msg.update_attributes(:status => 1, :viewed => 1) + applied_contest.applied_messages.update_all(:status => 1, :viewed => 1, :applied_user_id => User.current.id) + @msg.update_attributes(:status => 1, :viewed => 1, :applied_user_id => User.current.id) applied_contest.update_attributes(:status => 1) if integer_ids.include?(15) ContestantForContest.create(:student_id => apply_user.id, :contest_id =>applied_contest.contest_id) @@ -190,8 +200,8 @@ class ContestsController < ApplicationController when 'N' ContestMessage.create(:user_id => apply_user.id, :contest_id => applied_contest.contest_id, :viewed => false,:contest_message_id=>User.current.id,:content=>applied_contest.role,:contest_message_type=>'ContestRequestDealResult',:status=>2) - applied_contest.applied_messages.update_all(:status => 2, :viewed => 1) - @msg.update_attributes(:status => 2, :viewed => 1) + applied_contest.applied_messages.update_all(:status => 2, :viewed => 1, :applied_user_id => User.current.id) + @msg.update_attributes(:status => 2, :viewed => 1, :applied_user_id => User.current.id) applied_contest.update_attributes(:status => 2) end respond_to do |format| @@ -226,6 +236,23 @@ class ContestsController < ApplicationController end end + # 邀请码停用/启用 + def set_invite_code_halt + if User.current.admin_of_contest?(@contest) || User.current.admin? + @contest.update_attribute('invite_code_halt', @contest.invite_code_halt == 0 ? 1 : 0) + end + end + + # 恢复已删除的竞赛 + def renew + if User.current.admin? + @contest.update_attributes(:is_delete => false) + redirect_to contest_path(@contest) + else + return 404 + end + end + private def find_contest @@ -234,6 +261,10 @@ class ContestsController < ApplicationController return end @contest = Contest.find(params[:id]) + if @contest.is_delete and !User.current.admin? + render_404 + return + end rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 3332f1207..63d8429ba 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -49,8 +49,30 @@ class ForumsController < ApplicationController end else respond_to do |format| - format.html { redirect_to signin_path } - end + format.html { redirect_to signin_path } + end + end + end + + def mail_feedback + @user = User.where(:id => params[:user_id]).first + unless @user.nil? + cs = CommentService.new + @memo, message = cs.create_feedback params, @user + end + respond_to do |format| + format.js + end + end + + def forum_create_memo + @memo = Memo.new + @my_forums_count = Forum.where(:creator_id => User.current.id).count + @my_memos_count = Memo.where(:author_id => User.current.id).count + @forums = Forum.reorder("topic_count desc,updated_at desc") + respond_to do |format| + format.js + format.html {render layout: 'base_new_forum'} end end @@ -96,35 +118,41 @@ class ForumsController < ApplicationController end def index - @offset, @limit = api_offset_and_limit({:limit => 10}) + order = "" + @order_str = "" if(params[:reorder_complex]) - @type="reorder_complex" - @str=params[:reorder_complex] - @forums_all = Forum.reorder("topic_count #{params[:reorder_complex]},updated_at #{params[:reorder_complex]}") + order = " last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}" + @order_str = "reorder_complex="+params[:reorder_complex] elsif(params[:reorder_popu]) - @type="reorder_popu" - @str=params[:reorder_popu] - @forums_all = Forum.reorder("topic_count #{params[:reorder_popu]}") + order = "replies_count #{params[:reorder_popu]}" + @order_str = "reorder_popu="+params[:reorder_popu] elsif(params[:reorder_time]) - @type="reorder_time" - @str=params[:reorder_time] - @forums_all = Forum.reorder("updated_at #{params[:reorder_time]}") + order = "#{Memo.table_name}.updated_at #{params[:reorder_time]}" + @order_str = "reorder_time="+params[:reorder_time] else - params[:reorder_complex] = "desc" - @type="reorder_complex" - @str=params[:reorder_complex] - @forums_all = Forum.reorder("topic_count desc,updated_at desc") + order = "#{Memo.table_name}.updated_at desc" + @order_str = "reorder_time=desc" end - @forums_count = @forums_all.count - @forums_pages = Paginator.new @forums_count, @limit, params['page'] - - @offset ||= @forums_pages.offset - @forums = @forums_all.offset(@offset).limit(@limit).all - #@forums = Forum.all + @memo = Memo.new(:forum => @forum) + @memos = Memo.where("parent_id is null") + @topic_count = @memos.count + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @memos = @memos.includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + reorder(order). + preload(:author, {:last_reply => :author}). + all + @forums = Forum.reorder("topic_count desc,updated_at desc") + @my_forums_count = Forum.where(:creator_id => User.current.id).count + @my_memos_count = Memo.where(:author_id => User.current.id).count + @errors = params[:errors] respond_to do |format| - format.html # index.html.erb format.js - format.json { render json: @forums } + format.html { + render :layout => 'base_new_forum' + }# show.html.erb + format.json { render json: @forum } end end @@ -153,22 +181,21 @@ class ForumsController < ApplicationController @memo = Memo.new(:forum => @forum) @topic_count = @forum.topics.count @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - @memos = @forum.topics. - # reorder("#{Memo.table_name}.sticky DESC"). - includes(:last_reply). + @memos = @forum.topics.includes(:last_reply). limit(@topic_pages.per_page). offset(@topic_pages.offset). reorder(order). preload(:author, {:last_reply => :author}). all - @memos - @my_topic_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is null").count - @my_replies_count = Memo.where("forum_id = #{@forum.id} and author_id = #{User.current.id} and parent_id is not null").count + @my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count + @my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count @errors = params[:errors] + # 推荐贴吧 + @forums = Forum.where("id !=?", @forum.id).reorder("topic_count desc,updated_at desc").first(3) respond_to do |format| format.js format.html { - render :layout => 'base_forums' + render :layout => 'base_new_forum' }# show.html.erb format.json { render json: @forum } end @@ -178,9 +205,9 @@ class ForumsController < ApplicationController # GET /forums/new.json def new @forum = Forum.new - respond_to do |format| format.html # new.html.erb + format.js format.json { render json: @forum } end end @@ -188,6 +215,10 @@ class ForumsController < ApplicationController # GET /forums/1/edit def edit @forum = Forum.find(params[:id]) + respond_to do |format| + format.html + format.js + end end # POST /forums @@ -200,18 +231,17 @@ class ForumsController < ApplicationController # Author lizanle # Description after save后需要进行资源记录的更新 # owner_type = 2 对应的是 forum - @save_flag=true + @save_flag = true if params[:asset_id] ids = params[:asset_id].split(',') - update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM + update_kindeditor_assets_owner ids, @forum.id, OwnerTypeHelper::FORUM end #end respond_to do |format| - format.js + format.js{ redirect_to forums_path, notice: l(:label_forum_create_succ)} format.html { redirect_to @forum, notice: l(:label_forum_create_succ) } format.json { render json: @forum, status: :created, location: @forum } end - else @save_flag=false respond_to do |format| @@ -227,15 +257,14 @@ class ForumsController < ApplicationController # PUT /forums/1.json def update @forum = Forum.find(params[:id]) - respond_to do |format| if @forum.update_attributes(params[:forum]) - format.js {render :text=> true} + format.js format.html { redirect_to @forum, notice: l(:label_forum_update_succ) } format.json { head :no_content } else flash.now[:error] = "#{l :label_forum_update_fail}: #{@forum.errors.full_messages[0]}" - format.js { render :text=> false} + format.js format.html { render action: "edit" } format.json { render json: @forum.errors, status: :unprocessable_entity } end @@ -254,6 +283,19 @@ class ForumsController < ApplicationController end end + # 更新贴吧描述 + def update_memo_description + @forum = Forum.find(params[:id]) + if @forum.blank? + result = { :result => false } + else + forum_decription = params[:forum][:description] + @forum.update_attributes(:description => forum_decription ) + result = { :result => true } + end + render :json => result + end + def search_forum # @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'") q = "%#{params[:name].strip}%" @@ -296,15 +338,24 @@ class ForumsController < ApplicationController #检查forum的名字 def check_forum_name - forum_name_exist = true - if params[:forum_id] - forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false - else - forum_name_exist = Forum.where("name = '#{params[:forum_name]}' ").count >= 1 ? true : false + begin + forum_name = params[:forum_name] + result = Forum.find_by_name(forum_name).blank? ? {:result => true} : {:result => false} + rescue Exception => e + puts e end - render :text => forum_name_exist + render :json => result + # if params[:forum_id] + # forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false + # else + # forum_name_exist = Forum.where("name = '#{params[:forum_name]}' ").count >= 1 ? true : false + # end + # render :text => forum_name_exist end + + + #添加论坛tag def add_forum_tag @forum = Forum.find(params[:id]) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 69a1b829c..25b12e52a 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -1,6 +1,6 @@ class MemosController < ApplicationController default_search_scope :memos - before_filter :find_forum, :only => [:new, :create, :preview] + before_filter :find_forum, :only => [:new, :create, :preview, :update] before_filter :find_attachments, :only => [:preview] before_filter :find_memo, :except => [:new, :create, :preview] before_filter :authenticate_user_edit, :only => [:edit, :update] @@ -29,32 +29,25 @@ class MemosController < ApplicationController def new @memo = Memo.new - @memo.forum_id = @forum.id - + @my_forums_count = Forum.where(:creator_id => User.current.id).count + @my_memos_count = Memo.where(:author_id => User.current.id).count + @forums = Forum.reorder("topic_count desc,updated_at desc") respond_to do |format| - format.html { - render action: :new ,layout: 'base' - } + format.js + format.html {render layout: 'base_new_forum'} format.json { render json: @memo } end end def create - if params[:quote].nil? @quote = "" else @quote = params[:quote] end - - - #unless params[:quote].nil? - # @quote = params[:quote][:quote] - #end - @memo = Memo.new(params[:memo]) - @memo.forum_id = params[:forum_id] + @memo.forum_id = @forum.id @memo.author_id = User.current.id if params[:memo][:parent_id] @@ -78,24 +71,20 @@ class MemosController < ApplicationController asset.save end end - #end - format.js - format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } - format.json { render json: @memo, status: :created, location: @memo } + format.js + format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } + format.json { render json: @memo, status: :created, location: @memo } else flash.now[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" format.js format.html { redirect_to( forum_path(Forum.find(params[:forum_id]),:errors=>@memo.errors.full_messages[0])) } format.json { render json: @memo.errors, status: :unprocessable_entity } - #end - end end end REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE) def show - # 更新贴吧帖子留言对应的memo_messages的viewed字段 unless @memo.children.blank? @memo.children.each do |child| @@ -148,7 +137,7 @@ class MemosController < ApplicationController respond_to do |format| format.js - format.html {render :layout=> 'base_forums'}#:layout=> 'base_forums', + format.html {render :layout => 'base_new_forum'} format.json { render json: @memo } format.xml { render xml: @memo } end @@ -157,13 +146,16 @@ class MemosController < ApplicationController def edit @my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count @my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count + @forums = Forum.reorder("topic_count desc,updated_at desc") @replying = false respond_to do |format| - format.html {render :layout=>'base_forums'} + format.html {render :layout => 'base_new_forum'} end end def update + # 注意,如果不需要 + @flag = false respond_to do |format| if( #@memo.update_column(:subject, params[:memo][:subject]) && @@ -173,10 +165,11 @@ class MemosController < ApplicationController @memo.update_column(:subject,params[:memo][:subject]) && @memo.update_column(:updated_at,Time.now)) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) + @memo.forum_id = @forum.id @flag = @memo.save # @memo.root.update_attribute(:updated_at, @memo.updated_at) format.js - format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"} + format.html {redirect_to back_memo_url, notice: "#{l :label_memo_update_succ}"} else format.js format.html { render action: "edit" } @@ -207,7 +200,9 @@ class MemosController < ApplicationController end def find_forum - @forum = Forum.find(params[:forum_id]) + forum_name = params[:forum_name].strip unless params[:forum_name].nil? + @forum = forum_name ? Forum.find_by_name(forum_name) : Forum.find(params[:forum_id]) + # @forum = Forum.find(params[:forum_id]) rescue ActiveRecord::RecordNotFound render_404 nil diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 51fcdcc2d..2e71f7340 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -82,6 +82,13 @@ class MessagesController < ApplicationController format.js format.html {render :layout => 'base_projects'} end + elsif @contest + @left_nav_type = 4 + respond_to do |format| + format.js + format.html { render :layout => 'base_contests' } + end + #render :action => "show", :layout => "base_courses"#by young else # @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page # @replies = @topic.children. @@ -94,7 +101,7 @@ class MessagesController < ApplicationController @organization = @org_subfield.organization respond_to do |format| format.js - format.html {render :layout => 'base_org'} + format.html { render :layout => 'base_org' } end end end @@ -111,6 +118,8 @@ class MessagesController < ApplicationController is_public = @project.is_public elsif @course is_public = @course.is_public + elsif @contest + is_public = @contest.is_public end # 公开项目/课程上传的资源是公开的,私有项目上传的是私有的 @message.save_attachments_containers(params[:attachments], User.current, is_public) @@ -128,6 +137,8 @@ class MessagesController < ApplicationController redirect_to project_boards_path(@project) elsif @course redirect_to course_boards_path(@course, :board_id => @board.id) + elsif @contest + redirect_to contest_boards_path(@contest, :board_id => @board.id) end else redirect_to board_message_url(@board, @message) @@ -138,9 +149,11 @@ class MessagesController < ApplicationController redirect_to project_boards_path(@project, :flag => true) elsif @course redirect_to course_boards_path(@course, :board_id => @board.id, :flag => true) + elsif @contest + redirect_to contest_boards_path(@contest, :board_id => @board.id, :flag => true) end else - layout_file = @project ? 'base_projects' : 'base_courses' + layout_file = @project ? 'base_projects' : (@course ? 'base_courses' : 'base_contests') render :action => 'new', :layout => layout_file end @@ -149,7 +162,7 @@ class MessagesController < ApplicationController @left_nav_type = 2 respond_to do |format| format.html { - layout_file = @project ? 'base_projects' : 'base_courses' + layout_file = @project ? 'base_projects' : (@course ? 'base_courses' : 'base_contests') render :layout => layout_file } end @@ -187,6 +200,7 @@ class MessagesController < ApplicationController end update_course_activity(@topic.class,@topic.id) + update_contest_activity(@topic.class,@topic.id) update_user_activity(@topic.class,@topic.id) update_forge_activity(@topic.class,@topic.id) update_org_activity(@topic.class,@topic.id) @@ -226,6 +240,8 @@ class MessagesController < ApplicationController (render_403; return false) unless @message.editable_by?(User.current) elsif @course (render_403; return false) unless @message.course_editable_by?(User.current) + elsif @contest + (render_403; return false) unless @message.contest_editable_by?(User.current) else (render_403; return false) unless @message.org_subfield_editable_by?(User.current) end @@ -243,12 +259,16 @@ class MessagesController < ApplicationController redirect_to project_path(@project) elsif @course redirect_to course_activity_path(@course) + elsif @contest + redirect_to contest_activities_contest_path(@contest) end elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1 if @project redirect_to project_boards_path(@project) elsif @course redirect_to course_boards_path(@course) + elsif @contest + redirect_to contest_boards_path(@contest) end else redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)) @@ -265,6 +285,9 @@ class MessagesController < ApplicationController elsif @course @left_nav_type = 2 layout_file = 'base_courses' + elsif @contest + @left_nav_type = 4 + layout_file = 'base_contests' elsif @org_subfield @organization = @org_subfield.organization layout_file = 'base_org' @@ -292,6 +315,8 @@ class MessagesController < ApplicationController (render_403; return false) unless @message.destroyable_by?(User.current) elsif @course (render_403; return false) unless @message.course_destroyable_by?(User.current) + elsif @contest + (render_403; return false) unless @message.contest_destroyable_by?(User.current) else (render_403; return false) unless @message.org_subfield_editable_by?(User.current) end @@ -322,6 +347,18 @@ class MessagesController < ApplicationController else redirect_to course_boards_path(@course) end + elsif @contest + if params[:is_course] && params[:is_course].to_i == 0 + redirect_to user_contest_community_path(User.current.id) + elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 0 + redirect_to contest_activities_contest_path(@contest) + elsif params[:is_course] && params[:is_course].to_i == 1 && params[:is_board] && params[:is_board].to_i == 1 + redirect_to contest_boards_path(@contest) + elsif @message.parent + redirect_to board_message_url(@board, @message.parent, :r => r) + else + redirect_to contest_boards_path(@contest) + end elsif @org_subfield if params[:is_board] redirect_to organization_path(:id => @org_subfield.organization_id, :org_subfield_id => @org_subfield.id) @@ -400,8 +437,10 @@ class MessagesController < ApplicationController @board = Board.find(params[:board_id]) if @board.project_id != -1 && @board.project_id != nil @project = @board.project - elsif @board.course_id + elsif @board.course_id && @board.course_id != -1 @course = @board.course + elsif @board.contest_id + @contest = @board.contest else @org_subfield = @board.org_subfield @organization = @org_subfield diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5b94dd75c..20e0463d0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4087,6 +4087,7 @@ class UsersController < ApplicationController # 用户竞赛列表 def user_contestlist # 我创建的竞赛 + @contest_community = "竞赛" @my_contests = @user.contests.where(:user_id => @user.id).order("created_at desc") @my_contests_count = @my_contests.count # 我参与的竞赛 diff --git a/app/controllers/works_controller.rb b/app/controllers/works_controller.rb index 01457bc00..4b64e7fb1 100644 --- a/app/controllers/works_controller.rb +++ b/app/controllers/works_controller.rb @@ -2,8 +2,9 @@ class WorksController < ApplicationController layout "base_contests" before_filter :find_contest, :only => [:index,:new,:create] - before_filter :find_contestwork, :only => [:edit,:update,:destroy,:score_rule_set,:alert_open_student_works,:open_student_works,:set_score_open,:alert_score_open_modal] - before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:alert_open_student_works,:open_student_works] + before_filter :find_contestwork, :only => [:edit,:update,:destroy,:score_rule_set,:open_contestant_works,:set_score_open,:alert_score_open_modal, + :set_score_rule] + before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:open_contestant_works] before_filter :member_of_contest, :only => [:index] def index @@ -71,6 +72,13 @@ class WorksController < ApplicationController homework.work_status = homework.publish_time > Date.today ? 0 : 1 + work_detail_manual = WorkDetailManual.new + + work_detail_manual.evaluation_start = homework.end_time + 7 + work_detail_manual.evaluation_end = work_detail_manual.evaluation_start + 7 + work_detail_manual.evaluation_num = 3 + homework.work_detail_manual = work_detail_manual + #分组作业 if homework.work_type == 3 homework_detail_group = WorkDetailGroup.new @@ -81,6 +89,7 @@ class WorksController < ApplicationController end if homework.save + work_detail_manual.save if work_detail_manual homework_detail_group.save if homework_detail_group redirect_to works_path(:contest => @contest.id) end @@ -101,7 +110,14 @@ class WorksController < ApplicationController end param_end_time = Time.parse(params[:homework_common][:end_time]).strftime("%Y-%m-%d") homework_end_time = Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") + work_detail_manual = @contestwork.work_detail_manual if homework_end_time != param_end_time + eval_start = work_detail_manual.evaluation_start + if eval_start.nil? || (eval_start <= param_end_time && @contestwork.work_status <= 2) + work_detail_manual.evaluation_start = @contestwork.end_time + 7 + work_detail_manual.evaluation_end = work_detail_manual.evaluation_start + 7 + end + if homework_end_time > param_end_time @contestwork.contestant_works.each do |st| if param_end_time < Time.parse(st.commit_time.to_s).strftime("%Y-%m-%d") @@ -129,6 +145,8 @@ class WorksController < ApplicationController #status = false if @contestwork.publish_time <= Date.today && @contestwork.work_status == 0 @contestwork.work_status = 1 + elsif @contestwork.end_time < Date.today && @contestwork.work_status == 1 + @contestwork.work_status = 2 #status = true end @@ -146,6 +164,7 @@ class WorksController < ApplicationController if @contestwork.save @homework_detail_group.save if @homework_detail_group + work_detail_manual.save if work_detail_manual @hw_status = params[:hw_status].to_i if @hw_status == 1 @@ -180,20 +199,80 @@ class WorksController < ApplicationController def destroy if @contestwork.destroy respond_to do |format| - format.html { + format.js { @hw_status = params[:hw_status].to_i - if @hw_status == 1 - redirect_to user_contest_community_path(User.current.id) - elsif @hw_status == 2 - redirect_to contest_path(@contest.id) - else - redirect_to works_path(:contest => @contest.id) - end } end end end + def alert_score_open_modal + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @hw_status = params[:hw_status].to_i + end + + def set_score_open + @contestwork.update_attribute('score_open', params[:score_open].to_i) + @user_activity_id = params[:user_activity_id].to_i + @hw_status = params[:hw_status].to_i + @is_teacher = User.current.admin? || User.current.admin_of_contest?(@contest) + end + + def open_contestant_works + @contestwork.update_attributes(:is_open => !@contestwork.is_open) + + @user_activity_id = params[:user_activity_id] + @hw_status = params[:hw_status].to_i + @is_teacher = User.current.admin? || User.current.admin_of_contest?(@contest) + end + + def score_rule_set + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @hw_status = params[:hw_status].to_i + end + + def set_score_rule + # 未启动在线评审时才能更改评审参数 + if @contestwork.work_status < 3 + @contestwork.online_evaluation = params[:online_evaluation] ? 1 : 0 + + # 如果开启在线评审 + if params[:online_evaluation] + work_detail_manual = @contestwork.work_detail_manual + work_detail_manual.evaluation_start = params[:evaluation_start] + work_detail_manual.evaluation_end = params[:evaluation_end] + work_detail_manual.evaluation_num = params[:evaluation_limit].to_i == 1 ? params[:evaluation_num] : -1 + work_detail_manual.save + end + end + + score_valid = params[:score_valid].to_i == 1 ? true : false + if score_valid != @contestwork.score_valid + @contestwork.score_valid = score_valid + @contestwork.contestant_works.has_committed.each do |c_work| + c_work.save + end + end + @contestwork.save + if params[:student_path] && params[:student_path] == "true" + redirect_to contestant_works_path(:work => @contestwork.id) + else + @user_activity_id = params[:user_activity_id].to_i + @hw_status = params[:hw_status].to_i + respond_to do |format| + format.js + end + end + end + private #获取竞赛 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a69442297..415913e93 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -37,6 +37,16 @@ module ApplicationHelper # super # end + # 公共分页 + def paginator_list objs, objs_count, limit, is_remote + @is_remote = is_remote + @objs_count = objs.count + @obj_pages = Paginator.new @objs_count, limit, params['page'] || 1 + @offset ||= @obj_pages.offset + @objs = paginateHelper @attachments,25 + end + + # 获取竞赛的管理人员 def contest_managers contest contest.contest_members.select{|cm| cm.roles.to_s.include?("ContestManager")} @@ -3097,20 +3107,14 @@ module ApplicationHelper else #学生显示提交作品、修改作品等按钮 work = cur_user_works_for_work homework project = cur_user_projects_for_work homework - if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") + if work.nil? && homework.work_status == 1 if homework.work_type ==3 && project.nil? && homework.work_detail_group.base_on_project link_to "提交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品' else link_to "提交作品(#{count})", new_contestant_work_path(:work => homework.id),:class => 'c_blue' end - elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") - if homework.work_type ==3 && project.nil? && homework.work_detail_group.base_on_project - link_to "补交作品(#{count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品' - else - link_to "补交作品(#{count})", new_contestant_work_path(:work => homework.id),:class => 'c_red' - end else - if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id + if homework.work_status == 1 && work.user_id == User.current.id link_to "修改作品(#{count})", edit_contestant_work_path(work.id),:class => 'c_blue' else link_to "查看作品(#{count})", contestant_works_path(:work =>homework.id, :tab => 2), :class => 'c_blue', :title => "不可修改作品" @@ -3958,6 +3962,8 @@ def get_cw_status contest_work else str += '作品补交中' end + elsif contest_work.work_status == 2 + str += '提交已截止' end str end diff --git a/app/helpers/contestant_works_helper.rb b/app/helpers/contestant_works_helper.rb index 29f31455f..aa60c304b 100644 --- a/app/helpers/contestant_works_helper.rb +++ b/app/helpers/contestant_works_helper.rb @@ -13,4 +13,44 @@ module ContestantWorksHelper end str end + + #成绩计算 + def set_final_score contestwork, contestant_work + if contestwork.online_evaluation + if contestwork.score_valid + if ContestantWorkScore.find_by_sql("SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id").count < 2 + judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") + else + judge_score = ContestantWorkScore.find_by_sql("SELECT (SUM(score)-MIN(score)-MAX(score))/(COUNT(score)-2) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") + end + @work.work_score = judge_score.first.score.try(:round, 2).to_f + else + judge_score = ContestantWorkScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM contestant_work_scores WHERE contestant_work_id = #{contestant_work.id} AND reviewer_role = 2 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") + @work.work_score = judge_score.first.score.try(:round, 2).to_f + end + else + contestant_work.work_score = nil + end + end + + #获取学生作品的评分记录:同一个评委只显示最后一次评分 + def contestant_work_score_record work + sql = "SELECT MAX(id) id FROM contestant_work_scores WHERE reviewer_role = 2 AND score IS NOT NULL AND contestant_work_id = #{work.id} GROUP BY user_id" + tea_ts_ids = ContestantWorkScore.find_by_sql sql + tea_ts_ids = tea_ts_ids.empty? ? "(-1)" : "(" + tea_ts_ids.map{|tea| tea.id}.join(",") + ")" + scores = work.contestant_work_scores.where("score IS NULL or reviewer_role = 3 or id in #{tea_ts_ids}").order("updated_at desc") + return scores + end + + #获取指定评分的角色 + def student_work_score_role score + case score.reviewer_role + when 1 + role = "管理员" + when 2 + role = "评委" + when 3 + role = "参赛者" + end + end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 651f3a811..8b2d7c73c 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -869,4 +869,20 @@ module UsersHelper end return user_ids end + + # 获取竞赛申请者的角色 + def get_role_str role + str = "" + case role + when 1 + str = "管理员" + when 2 + str = "评委" + when 3 + str = "参赛者" + when 4 + str = "管理员、评委" + end + str + end end diff --git a/app/models/applied_contest.rb b/app/models/applied_contest.rb index 1e26211c9..7c5e9ba7e 100644 --- a/app/models/applied_contest.rb +++ b/app/models/applied_contest.rb @@ -8,7 +8,7 @@ class AppliedContest < ActiveRecord::Base has_many :applied_messages, :class_name => 'AppliedMessage', :as => :applied, :dependent => :destroy after_create :send_appliled_message - # 仅仅给项目管理人员发送消息 + # 仅仅给竞赛管理人员发送消息 def send_appliled_message case self.role when '13' @@ -17,11 +17,9 @@ class AppliedContest < ActiveRecord::Base role = 2 when '15' role = 3 - else - role = 4 end contest_managers(self.contest).each do |member| - self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :applied_user_id => self.user_id, :role => role) + self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => 0, :viewed => false, :role => role) end # end end diff --git a/app/models/board.rb b/app/models/board.rb index d8b29f5cd..38051adb9 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -20,6 +20,7 @@ class Board < ActiveRecord::Base belongs_to :project,:touch => true belongs_to :course,:touch=>true belongs_to :org_subfield, :touch => true + belongs_to :contest, :touch => true has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC" has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC" belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id @@ -55,6 +56,8 @@ class Board < ActiveRecord::Base @valid_parents ||= project.boards - self_and_descendants elsif course @valid_parents ||= course.boards - self_and_descendants + elsif contest + @valid_parents ||= contest.boards - self_and_descendants end end diff --git a/app/models/comment.rb b/app/models/comment.rb index f0add239f..e0563104e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -26,6 +26,7 @@ class Comment < ActiveRecord::Base # 课程/项目 消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy + has_many :contest_messages, :class_name => 'ContestMessage', :as => :contest_message, :dependent => :destroy #end has_many :praise_tread, as: :praise_tread_object, dependent: :destroy has_one :praise_tread_cache, as: :object, dependent: :destroy @@ -54,12 +55,22 @@ class Comment < ActiveRecord::Base # ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content # end end + elsif self.commented.contest + if self.author_id != self.commented.author_id + self.contest_messages << ContestMessage.new(:user_id => self.commented.author_id, :contest_id => self.commented.contest.id, :viewed => false) + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count + # if count == 0 + # content = strip_html self.comments.html_safe, 200 + # ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + # end + end else # 项目相关 # if self.author_id != self.commented.author_id # self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) # #content = strip_html self.comments.html_safe, 200 # #ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content # end + end end diff --git a/app/models/contest.rb b/app/models/contest.rb index b4f36330d..e2693afaf 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -13,6 +13,9 @@ class Contest < ActiveRecord::Base has_many :users, :through => :members has_many :contestants, :class_name => 'ContestantForContest', :source => :user has_many :works + has_many :contestant_work_projects, :dependent => :destroy + has_many :boards, :dependent => :destroy, :order => "position ASC" + has_many :news, :dependent => :destroy, :include => :author @@ -24,7 +27,7 @@ class Contest < ActiveRecord::Base validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]*$/ before_destroy :delete_all_members - #after_create :act_as_contest_activity + after_create :create_board_sync scope :visible, lambda {|*args| where(Contest.where("is_delete =?", 0).visible_condition(args.shift || User.current, *args)) } @@ -108,4 +111,19 @@ class Contest < ActiveRecord::Base end code end + + # 创建竞赛讨论区 + def create_board_sync + @board = self.boards.build + #self.name=" #{l(:label_borad_course) }" + @board.name = " #{l(:label_board_contest) }"#self.name + @board.description = self.name.to_s + @board.project_id = -1 + @board.course_id = -1 + if @board.save + logger.debug "[Contest Model] ===> #{@board.to_json}" + else + logger.error "[Contest Model] ===> Auto create board when contest saved, because #{@board.full_messages}" + end + end end diff --git a/app/models/contestant_work.rb b/app/models/contestant_work.rb index 3db9dd160..a1d2a9bb0 100644 --- a/app/models/contestant_work.rb +++ b/app/models/contestant_work.rb @@ -1,4 +1,5 @@ class ContestantWork < ActiveRecord::Base + include ContestantWorksHelper belongs_to :work belongs_to :user belongs_to :project @@ -8,6 +9,9 @@ class ContestantWork < ActiveRecord::Base has_many :contestant_work_scores, :dependent => :destroy has_many :contest_messages, :class_name =>'ContestMessage', :as => :contest_message, :dependent => :destroy has_many :attachments, :dependent => :destroy + has_many :contestant_work_evaluation_distributions + + before_save :set_work_score scope :has_committed, lambda{where("work_status != 0 and work_status != 3")} scope :no_copy, lambda{where("work_status != 3")} @@ -20,4 +24,8 @@ class ContestantWork < ActiveRecord::Base self.contest_messages << ContestMessage.new(:user_id => self.user_id, :contest_id => self.work.contest_id, :viewed => false, :status => false) end end + + def set_work_score + set_final_score self.work,self + end end diff --git a/app/models/contestant_work_evaluation_distribution.rb b/app/models/contestant_work_evaluation_distribution.rb new file mode 100644 index 000000000..eb8308043 --- /dev/null +++ b/app/models/contestant_work_evaluation_distribution.rb @@ -0,0 +1,5 @@ +class ContestantWorkEvaluationDistribution < ActiveRecord::Base + belongs_to :user + belongs_to :contestant_work + attr_accessible :user_id, :contestant_work_id +end diff --git a/app/models/contestant_work_score.rb b/app/models/contestant_work_score.rb index b051647a6..8aa29024f 100644 --- a/app/models/contestant_work_score.rb +++ b/app/models/contestant_work_score.rb @@ -2,4 +2,6 @@ class ContestantWorkScore < ActiveRecord::Base belongs_to :contestant_work belongs_to :user attr_accessible :comment, :reviewer_role, :score, :contestant_work_id, :user_id + + has_many :journals_for_messages end diff --git a/app/models/message.rb b/app/models/message.rb index 312893415..177b5f7ee 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -86,7 +86,7 @@ class Message < ActiveRecord::Base # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score - after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message, :delay_message_send + after_create :act_as_course_activity, :act_as_forge_activity, :act_as_contest_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message, :delay_message_send #before_save :be_user_score scope :visible, lambda {|*args| @@ -188,6 +188,18 @@ class Message < ActiveRecord::Base board.course end + def contest + board.contest + end + + def contest_editable_by?(usr) + usr && usr.logged? && (usr.admin_of_contest?(contest) || self.author == usr || usr.admin?) + end + + def contest_destroyable_by?(usr) + usr && usr.logged? && (usr.admin_of_contest?(contest) || self.author == usr || usr.admin?) + end + def course_editable_by?(usr) usr && usr.logged? && (usr.allowed_to?(:edit_messages, course) || (self.author == usr && usr.allowed_to?(:edit_own_messages, course))) end @@ -223,6 +235,7 @@ class Message < ActiveRecord::Base #动态的更新 def update_activity update_course_activity(self.class, self.id) + update_contest_activity(self.class, self.id) update_user_activity(self.class, self.id) update_forge_activity(self.class, self.id) update_org_activity(self.class, self.id) @@ -269,6 +282,13 @@ class Message < ActiveRecord::Base end end + #竞赛动态公共表记录 + def act_as_contest_activity + if self.contest && self.parent_id.nil? + self.contest_acts << ContestActivity.new(:user_id => self.author_id,:contest_id => self.board.contest_id) + end + end + # 课程讨论区添加消息: # 老师发帖所有人都能收到消息 # 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息 @@ -324,6 +344,29 @@ class Message < ActiveRecord::Base # end end end + elsif self.contest + if self.parent_id.nil? # 主贴 + self.contest.contest_members.includes(:user).each do |m| + if self.author.admin_of_contest?(self.contest) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 + #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count + # if count == 0 + # content = strip_html self.subject, 200 + # ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + # end + end + end + else # 回帖 + parent_author_id = Message.find(self.parent_id).author_id + if parent_author_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 + self.contest_messages << ContestMessage.new(:user_id => parent_author_id, :contest_id => self.board.contest_id, :viewed => false) + # count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count + # if count == 0 + # content = strip_html self.content.html_safe, 200 + # ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + # end + end + end end end @@ -346,6 +389,25 @@ class Message < ActiveRecord::Base self.delay.contain_messages_message(dm) end + end + elsif self.contest + if self.parent_id.nil? # 发帖 + dm = [] + self.contest.contest_members.includes(:user).each do |m| + if self.author.admin_of_contest?(self.contest) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息 + dm << {contest_message_type:'Message',contest_message_id:self.id, :user_id => m.user_id, + :contest_id => self.board.contest_id, :viewed => false} + if dm.size >= 30 + self.delay.contain_contest_messages_message(dm) + dm.clear + end + end + end + + unless dm.empty? + self.delay.contain_contest_messages_message(dm) + end + end end end @@ -354,6 +416,10 @@ class Message < ActiveRecord::Base CourseMessage.create(vs) end + def contain_contest_messages_message vs + ContestMessage.create(vs) + end + #更新用户分数 -by zjc def be_user_score #新建message且无parent的为发帖 diff --git a/app/models/news.rb b/app/models/news.rb index e06166494..4c0e58238 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -69,7 +69,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send + after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send, :act_as_contest_message after_update :update_activity after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score @@ -216,6 +216,16 @@ class News < ActiveRecord::Base end end + def act_as_contest_message + if self.contest_id + self.contest.contest_members.each do | m| + if m.user_id != self.author_id + self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false) + end + end + end + end + def delay_news_send if self.course @@ -240,7 +250,7 @@ class News < ActiveRecord::Base vs = [] self.contest.contest_members.each do | m| if m.user_id != self.author_id - vs << {course_message_type:'Contest',course_message_id:self.id, :user_id => m.user_id, + vs << {contest_message_type:'Contest',contest_message_id:self.id, :user_id => m.user_id, :contest_id => self.contest_id, :viewed => false} if vs.size >= 30 diff --git a/app/models/project.rb b/app/models/project.rb index 8300daf82..e48a5296c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -43,7 +43,8 @@ class Project < ActiveRecord::Base end end - has_many :student_work_projects,:dependent => :destroy + has_many :student_work_projects, :dependent => :destroy + has_many :contestant_work_projects, :dependent => :destroy has_many :student_works has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" diff --git a/app/models/user.rb b/app/models/user.rb index 8d9751a38..e9aa1dde8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1063,6 +1063,7 @@ class User < Principal # Admin users are authorized for anything else return true if admin? + # 课程:作品关联项目的老师也可以访问私有项目 course_ids = context.student_work_projects.blank? ? "(-1)" : "(" + context.student_work_projects.map{|swp| swp.course_id}.join(",") + ")" courses = Course.where("id in #{course_ids}") courses.each do |course| @@ -1070,6 +1071,16 @@ class User < Principal return true end end + + # 竞赛:作品关联项目的管理员也可以访问私有项目 + contest_ids = context.contestant_work_projects.map{|swp| swp.contest_id} + contests = Contest.where(:id => contest_ids) + contests.each do |contest| + if self.admin_of_contest?(contest) + return true + end + end + roles = roles_for_project(context) return false unless roles roles.any? {|role| diff --git a/app/models/work.rb b/app/models/work.rb index 02c7b5a08..8d264508a 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -1,10 +1,12 @@ class Work < ActiveRecord::Base + # work_status 0:未发布/挂起 1:提交中 2:提交截止 3:启动在线评审 4:评审结束 belongs_to :user belongs_to :contest attr_accessible :description, :end_time, :is_delete, :is_open, :name, :publish_time, :score_open, :work_status, :work_type, :contest_id, :user_id include ApplicationHelper has_one :work_detail_group, :dependent => :destroy + has_one :work_detail_manual, :dependent => :destroy has_many :contestant_work_projects, :dependent => :destroy has_many :contestant_works, :dependent => :destroy, :conditions => "is_delete != 1" has_many :journals_for_messages, :as => :jour, :dependent => :destroy @@ -60,10 +62,8 @@ class Work < ActiveRecord::Base if self.work_status == 0 self.contest_messages.destroy_all else - self.contest.contest_members.each do |m| - if m.user_id != self.user_id - self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false) - end + self.contest.contestants.each do |m| + self.contest_messages << ContestMessage.new(:user_id => m.student_id, :contest_id => self.contest_id, :viewed => false) end end end diff --git a/app/models/work_detail_manual.rb b/app/models/work_detail_manual.rb new file mode 100644 index 000000000..1e468b58a --- /dev/null +++ b/app/models/work_detail_manual.rb @@ -0,0 +1,4 @@ +class WorkDetailManual < ActiveRecord::Base + belongs_to :work + attr_accessible :evaluation_end, :evaluation_num, :evaluation_start, :work_id +end diff --git a/app/services/contests_service.rb b/app/services/contests_service.rb index 10f1bb7e1..b4bb1acde 100644 --- a/app/services/contests_service.rb +++ b/app/services/contests_service.rb @@ -23,13 +23,18 @@ class ContestsService else if params[:invite_code].present? role_ids = params[:role] - role_str = role_ids.join(",").to_s #如果已经发送过消息了,那么就要给个提示 - if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :role => role_str, :status => 0).count != 0 + if AppliedContest.where(:contest_id => contest.id, :user_id => current_user.id, :status => 0).count != 0 @state = 7 else - AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_str, :status => 0) + if role_ids.size == 1 + AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_ids[0], :status => 0) + else + role_ids.each do |role_id| + AppliedContest.create(:contest_id => contest.id, :user_id => current_user.id, :role => role_id, :status => 0) + end + end @state = 6 end else diff --git a/app/views/account/email_activation.html.erb b/app/views/account/email_activation.html.erb index 9655efcf4..d02715e43 100644 --- a/app/views/account/email_activation.html.erb +++ b/app/views/account/email_activation.html.erb @@ -49,7 +49,7 @@ data: {user: user, text: $(".email_prompt_mes").val() }, type: "POST", success: function (data) { - var htmlvalue = "

您的留言已发送

我们将尽快处理好,并通过邮件通知您。感谢您的反馈!

" + var htmlvalue = "

您的留言已发送

我们将尽快处理好并通知您。感谢您的反馈!

" pop_up_box(htmlvalue, 580, 30, 45); $(".email_prompt_mes").val(""); } diff --git a/app/views/account/email_valid.html.erb b/app/views/account/email_valid.html.erb index 611902047..423057da6 100644 --- a/app/views/account/email_valid.html.erb +++ b/app/views/account/email_valid.html.erb @@ -1,16 +1,61 @@ +<%= l(:label_regiter_account)%> - - - <%= l(:label_regiter_account)%> - - - <% email = @user.mail.split("@")[1] %> +
+
+

注册成功! + 请在24小时内点击邮件中的链接来激活您的账号。

+

请登录邮箱(<%= @mail_type %>)收取账号激活邮件。
点击邮件中的激活链接,方可使用该账号 +

+

+ <%= l(:label_check_email)%> +     <%= link_to "".html_safe, { :controller => 'account', :action => 'resendmail', :user => @user}, :remote => true, :method => 'get' %> +

+ + +
+
+ -
- -

- <%= l(:label_email_valid)%>

- -
-
-
-

<%= l(:notice_email_register_time) %>

-
-
- <%= l(:notice_email_arrival)%> : <%= @user.mail %> -
-

- <%= l(:label_check_email)%> -     <%= link_to "".html_safe, { :controller => 'account', :action => 'resendmail', :user => @user}, :remote => true, :method => 'get' %> - -

- - - - -
- -
-
-
- -
- - - \ No newline at end of file diff --git a/app/views/boards/_contest_boardlist.html.erb b/app/views/boards/_contest_boardlist.html.erb new file mode 100644 index 000000000..96a6af0e0 --- /dev/null +++ b/app/views/boards/_contest_boardlist.html.erb @@ -0,0 +1,80 @@ +
+
+
+

讨论区列表

+
+ 排序: + <%= link_to "时间", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 1 %> + <%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> + <%= link_to "人气", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "sortTxt", :remote => true %> + <% if @type.to_i == 2 %> + <%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> + <% end %> +
+
+
+ <% if topics.any? %> + <% topics.each do |activity| %> +
+
+ <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal fl" %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "list-title-normal f1" %> + <% end %> + <% if activity.sticky == 1 %> + + <% end%> + <% if activity.locked %> + + <% end %> + <%# u = User.where("id=?",activity.author_id).first%> +
+
+ + + + + + + + +
+ + 发帖人:<%= link_to activity.author.show_name, user_path(activity.author), :class => "link-blue" %> + + 更新:<%= format_time(activity.children.any? ? activity.children.last[:created_on] : activity[:created_on] ) %> + <% all_comments = []%> + <% count=Message.where("root_id = #{activity.id}").count %> +

<%= count>0 ? "#{count}" : "0" %>回复|<%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %>

+
+
+
+ <% end %> +
+
    + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> +
+
+
+ <% else %> +
+

没有数据可以显示!

+ <% end %> +
+
+
+ \ No newline at end of file diff --git a/app/views/boards/_contest_message_edit.html.erb b/app/views/boards/_contest_message_edit.html.erb new file mode 100644 index 000000000..6921c57b5 --- /dev/null +++ b/app/views/boards/_contest_message_edit.html.erb @@ -0,0 +1,16 @@ + +
+
+
+ 编辑帖子 +
+
+ <%= render :partial => 'boards/contest_new', + :locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :contest => contest} %> +
\ No newline at end of file diff --git a/app/views/boards/_contest_new.html.erb b/app/views/boards/_contest_new.html.erb new file mode 100644 index 000000000..e2d89b835 --- /dev/null +++ b/app/views/boards/_contest_new.html.erb @@ -0,0 +1,194 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> +<% end %> + +<%= error_messages_for 'message' %> +
+
+
+
+ +

+
+ +
+ <%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %> + +
+
\ No newline at end of file diff --git a/app/views/boards/_contest_show.html.erb b/app/views/boards/_contest_show.html.erb new file mode 100644 index 000000000..1552a3e2b --- /dev/null +++ b/app/views/boards/_contest_show.html.erb @@ -0,0 +1,43 @@ + + +
+
+
+ <%= @board.parent_id.nil? ? "竞赛讨论区" : "#{@board.name}" %> +
+ + <% is_teacher = User.current.logged? && (User.current.admin? || User.current.admin_of_contest?(@board.contest)) %> + <%# if is_teacher %> + <%#= link_to "添加子栏目", settings_course_path(@board.course.id,'boards'), :class => "link-blue fr mt5" %> + <%# end %> +
+
+ <% if User.current.logged? %> + <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'contest_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :contest => @board.contest} %> + <% end %> + <% end %> +
+ <%= render :partial=> 'contest_show_detail',:locals =>{:topics => @topics, :page => 0} %> +
+ diff --git a/app/views/boards/_contest_show_detail.html.erb b/app/views/boards/_contest_show_detail.html.erb new file mode 100644 index 000000000..1e8cb88bb --- /dev/null +++ b/app/views/boards/_contest_show_detail.html.erb @@ -0,0 +1,8 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false) %> + <%= javascript_include_tag "create_kindeditor" %> +<% end %> + +<% if @topics || topics %> + <%= render :partial => 'boards/contest_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %> +<% end %> \ No newline at end of file diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index ac50c0ee9..778aee89e 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -36,6 +36,8 @@ <%= render :partial => 'project_show', locals: {:topics => @topics, :page => 0, project: @project} %> <% elsif @course %> <%= render :partial => 'course_show', :locals => {:topics => @topics, :page => 0, :course => @course} %> +<% elsif @contest %> + <%= render :partial => 'contest_show', :locals => {:topics => @topics, :page => 0, :contest => @contest} %> <% end %> diff --git a/app/views/contest_members/create.js.erb b/app/views/contest_members/create.js.erb index 124339124..450753d47 100644 --- a/app/views/contest_members/create.js.erb +++ b/app/views/contest_members/create.js.erb @@ -1,12 +1,14 @@ <%if @contest%> <% if @create_member_error_messages%> -alert("<%= @create_member_error_messages%>"); +notice_box("<%= @create_member_error_messages%>"); +//alert("<%= @create_member_error_messages%>"); <% else %> $('#game-setting-content-2').html('<%= escape_javascript(render :partial => 'contests/members') %>'); $("#admin_num").html("<%= contest_managers(@contest).count %>"); $("#judge_num").html("<%= contest_judges(@contest).count %>"); $("#contestant_num").html("<%= contest_contestants(@contest).count %>"); -alert("添加成功"); +notice_box("添加成功"); +//alert("添加成功"); <% end%> hideOnLoad(); <%end%> diff --git a/app/views/contest_members/destroy.js.erb b/app/views/contest_members/destroy.js.erb index 8df2dd685..2456636be 100644 --- a/app/views/contest_members/destroy.js.erb +++ b/app/views/contest_members/destroy.js.erb @@ -1,3 +1,4 @@ +hideModal(); $('#game-setting-content-2').html('<%= escape_javascript(render :partial => 'contests/members') %>'); $("#admin_num").html("<%= contest_managers(@contest).count %>"); $("#judge_num").html("<%= contest_judges(@contest).count %>"); diff --git a/app/views/contestant_works/_add_score.html.erb b/app/views/contestant_works/_add_score.html.erb new file mode 100644 index 000000000..09eea4808 --- /dev/null +++ b/app/views/contestant_works/_add_score.html.erb @@ -0,0 +1,50 @@ +<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_contestant_works_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%> +
  • + 评价: + <%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>500),:maxlength => 500 %> +
    +
  • +

    +
  • + 评分: + + + +
  • +
  • + 批阅结果: +
    + <%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work,:score => score} %> +
    +
    + + 提交 +
    +
  • +<% end%> + \ No newline at end of file diff --git a/app/views/contestant_works/_contestant_work_list.html.erb b/app/views/contestant_works/_contestant_work_list.html.erb index af20fb1a7..041bbf8f5 100644 --- a/app/views/contestant_works/_contestant_work_list.html.erb +++ b/app/views/contestant_works/_contestant_work_list.html.erb @@ -13,12 +13,12 @@ <% my_work = cur_user_works_for_work @contestwork %> <% if !@is_teacher && !@is_judge && my_work.nil? && User.current.member_of_contest?(@contest) %> 您尚未提交作品 - <% unless @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %> + <% if @contestwork.work_status == 1 && (@contestwork.work_type != 3 ||(@contestwork.work_type == 3 && !@contestwork.work_detail_group.base_on_project)) %> <%=link_to "提交作品", new_contestant_work_path(:work => @contestwork.id),:class => 'blueCir ml5 f12' %> <% end %> - <% elsif !@is_teacher && !@is_judge && my_work &&Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + <% elsif !@is_teacher && !@is_judge && my_work && @contestwork.work_status > 1 && !@stundet_works.empty?%> 截止日期已过,已提交且不可修改 - <% elsif !@is_teacher && !@is_judge && my_work &&Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + <% elsif !@is_teacher && !@is_judge && my_work && @contestwork.work_status == 1 && !@stundet_works.empty?%> <% if @contestwork.work_type == 3 %> 组长已提交,组长还可修改 <% else %> diff --git a/app/views/contestant_works/_contestant_work_score.html.erb b/app/views/contestant_works/_contestant_work_score.html.erb new file mode 100644 index 000000000..78997527f --- /dev/null +++ b/app/views/contestant_works/_contestant_work_score.html.erb @@ -0,0 +1,44 @@ + + diff --git a/app/views/contestant_works/_contestant_work_score_records.html.erb b/app/views/contestant_works/_contestant_work_score_records.html.erb new file mode 100644 index 000000000..38a55a1a3 --- /dev/null +++ b/app/views/contestant_works/_contestant_work_score_records.html.erb @@ -0,0 +1,8 @@ +<%student_work_scores.each do |student_score|%> +
    + <%= render :partial => 'contestant_work_score',:locals => {:score => student_score,:is_last => student_score == student_work_scores.last}%> +
    +<% end%> +<% if is_member_work && student_work_scores.empty? && !@is_teacher %> +

    暂无评分

    +<% end %> \ No newline at end of file diff --git a/app/views/contestant_works/_show.html.erb b/app/views/contestant_works/_show.html.erb index 910e4c95c..c570ea565 100644 --- a/app/views/contestant_works/_show.html.erb +++ b/app/views/contestant_works/_show.html.erb @@ -15,7 +15,7 @@ <%=format_time work.commit_time %> - <% if work.user == User.current && Time.parse(@contestwork.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") %> + <% if work.user == User.current && @contestwork.work_status == 1 %>
  • <%= link_to("", contestant_work_path(work),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "pic_del",:title=>"删除") %> @@ -76,7 +76,7 @@
  • - + @@ -94,7 +94,7 @@ - + --> @@ -104,8 +104,8 @@ <% end %> - - + +
    diff --git a/app/views/contestant_works/_work_post_brief.html.erb b/app/views/contestant_works/_work_post_brief.html.erb index d2f26031b..5f216b4fe 100644 --- a/app/views/contestant_works/_work_post_brief.html.erb +++ b/app/views/contestant_works/_work_post_brief.html.erb @@ -7,7 +7,7 @@ <%=get_cw_status(homework).html_safe %>
    diff --git a/app/views/contestant_works/add_score.js.erb b/app/views/contestant_works/add_score.js.erb new file mode 100644 index 000000000..2750ae178 --- /dev/null +++ b/app/views/contestant_works/add_score.js.erb @@ -0,0 +1,18 @@ +<% is_member_work = @contestwork.work_type == 3 && @work.contestant_work_projects.empty? %> +$("#add_student_score_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'add_score',:locals => {:work => @work,:score => @new_score,:is_member_work => is_member_work}) %>"); +$('#score_<%= @work.id%>').peSlider({range: 'min'}); + +<% score_open = @is_teacher || @contestwork.score_open == 1 || @work.user == User.current %> + +$("#score_list_<%= @work.id%>").html("<%=escape_javascript(render :partial => 'contestant_work_score_records', :locals => {:student_work_scores => @student_work_scores, :is_member_work => is_member_work}) %>"); +var num = $("#work_num_<%= @work.id%>").html(); +$("#score_list_<%= @work.id%>").removeAttr("style"); + +<% if @contestwork.work_type == 3 %> +$("#student_work_<%= @work.id%>").html("<%= escape_javascript(render :partial => 'contest_evaluation_un_group_work', :locals => {:student_work => @work}) %>"); +<% else %> +$("tr[id='student_work_<%= @work.id%>']").replaceWith("<%= escape_javascript(render :partial => 'contest_evaluation_un_work',:locals => {:student_work => @work, :index => 1, :score_open => score_open}) %>"); +$("#work_num_<%= @work.id%>").html(num); +<% end %> + +$("#student_work_count").html("<%=@count %>"); diff --git a/app/views/contestant_works/index.html.erb b/app/views/contestant_works/index.html.erb index 33b23e215..3681e2f29 100644 --- a/app/views/contestant_works/index.html.erb +++ b/app/views/contestant_works/index.html.erb @@ -98,14 +98,14 @@ <% end %> <% hcommons.each_with_index do |homework_common,index |%> <% if homework_common.id == @contestwork.id %> - <%="题目 #{hcommons.count - index}" %> + <%="提交 #{hcommons.count - index}" %> <% end %> <% end%> diff --git a/app/views/contests/destroy.js.erb b/app/views/contests/destroy.js.erb new file mode 100644 index 000000000..50f17fa9d --- /dev/null +++ b/app/views/contests/destroy.js.erb @@ -0,0 +1,2 @@ +hideModal(); +window.location.href = "<%=user_contest_community_path(User.current) %>"; \ No newline at end of file diff --git a/app/views/contests/set_invite_code_halt.js.erb b/app/views/contests/set_invite_code_halt.js.erb new file mode 100644 index 000000000..e5ae1c38b --- /dev/null +++ b/app/views/contests/set_invite_code_halt.js.erb @@ -0,0 +1,2 @@ +$("#contest_base_info").html("<%= escape_javascript(render :partial => 'contests/contest_base_info') %>"); +hideModal(); \ No newline at end of file diff --git a/app/views/contests/show.html.erb b/app/views/contests/show.html.erb index 7e3adac62..5a81d99d3 100644 --- a/app/views/contests/show.html.erb +++ b/app/views/contests/show.html.erb @@ -10,10 +10,10 @@
    - <% if (@contest.description.nil? || @contest.description == "") && User.current.admin_of_contest?(@contest) %> + <% if (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) && User.current.admin_of_contest?(@contest) %>
    -

    请尽快补充竞赛说明,赢得更多参赛

    - <% elsif (@contest.description.nil? || @contest.description == "") %> +

    请尽快补充竞赛说明,赢得更多参赛者的青睐吧~

    + <% elsif (@contest.description.nil? || (@contest.description == "" && @contest.attachments.blank?)) %>

    尚未发布竞赛说明,敬请期待~

    <% else %> diff --git a/app/views/forums/_edit.html.erb b/app/views/forums/_edit.html.erb new file mode 100644 index 000000000..e19068ef1 --- /dev/null +++ b/app/views/forums/_edit.html.erb @@ -0,0 +1,52 @@ +
    +
    +

    新建贴吧

    + +
    +
    +
    + <%= labelled_form_for @forum, :html => {:id => "forum_new", :remote => true} do |f| %> + <%= render :partial => "forums/form", :locals => {:f => f} %> + <% end %> +
    +
    + + \ No newline at end of file diff --git a/app/views/forums/_emali_valid_tip.html.erb b/app/views/forums/_emali_valid_tip.html.erb new file mode 100644 index 000000000..c81dab4ca --- /dev/null +++ b/app/views/forums/_emali_valid_tip.html.erb @@ -0,0 +1,25 @@ +
    +
    +

    提示

    + +
    +
    +
    +
      +
    • + <% if !@user.nil? %> +

      反馈成功,我们将尽快处理好并通知您。感谢您的反馈!

      + <% else %> +

      反馈失败,请先登录!

      + <% end %> +
    • +
    • + <% if @flag == 6 %> + <%= link_to "知道了", project_path(@project), :class => "sy_btn_blue" %> + <% else %> + 知道了 + <% end %> +
    • +
    +
    +
    \ No newline at end of file diff --git a/app/views/forums/_file_form.html.erb b/app/views/forums/_file_form.html.erb index 9bbbc9188..cbb53c2cc 100644 --- a/app/views/forums/_file_form.html.erb +++ b/app/views/forums/_file_form.html.erb @@ -47,7 +47,8 @@ <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> <%#= button_tag "文件浏览", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'AnnexBtn fl mt3' %> - 上传附件 + <%= button_tag "上传附件", :id => "upload_attachments", :type=>"button", :onclick=>"$('#_file').click();",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => 'file_selector', diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb new file mode 100644 index 000000000..cc2037e75 --- /dev/null +++ b/app/views/forums/_form.html.erb @@ -0,0 +1,70 @@ + +
    + 取消 + 确定 +
    + + + \ No newline at end of file diff --git a/app/views/forums/_forum_tag_list.html.erb b/app/views/forums/_forum_tag_list.html.erb index 1cae58619..e083840d2 100644 --- a/app/views/forums/_forum_tag_list.html.erb +++ b/app/views/forums/_forum_tag_list.html.erb @@ -1,8 +1,10 @@ <% forum.reload.tag_list.each do |tag|%> - <%= tag %> - <%if forum.creator.id == User.current.id%> - × + <% if forum.creator.id == User.current.id %> + <%= tag %> + × + <% else %> + <%= tag %> <% end %> <% end %> \ No newline at end of file diff --git a/app/views/forums/_my_count_message.html.erb b/app/views/forums/_my_count_message.html.erb new file mode 100644 index 000000000..fec466754 --- /dev/null +++ b/app/views/forums/_my_count_message.html.erb @@ -0,0 +1,16 @@ +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => 50, :height => 50,:alt=>'贴吧图像' ), user_path( User.current) %>
    +
    +
    我在问吧
    +
    +
    <%= @my_memos_count %>
    +
    回答
    +
    +
    + +
    +
    +
    diff --git a/app/views/forums/_new.html.erb b/app/views/forums/_new.html.erb new file mode 100644 index 000000000..05b5ff42e --- /dev/null +++ b/app/views/forums/_new.html.erb @@ -0,0 +1,12 @@ +
    +
    +

    新建贴吧

    + +
    +
    +
    + <%= labelled_form_for @forum, :html => {:id => "forum_new", :remote => false} do |f| %> + <%= render :partial => "form", :locals => {:f => f} %> + <% end %> +
    +
    diff --git a/app/views/forums/_right_bar.html.erb b/app/views/forums/_right_bar.html.erb new file mode 100644 index 000000000..1bd6ead7a --- /dev/null +++ b/app/views/forums/_right_bar.html.erb @@ -0,0 +1,14 @@ + + <% @forums.each_with_index do |forum, i| %> +
    +

    <%= link_to forum.name, forum_path(forum), :class => "" %>

    + + +
    + <% end %> \ No newline at end of file diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb index 80b77a79b..2bd29a748 100644 --- a/app/views/forums/_show_topics.html.erb +++ b/app/views/forums/_show_topics.html.erb @@ -5,6 +5,19 @@ $(function(){ showNormalImage('postDetailDes_<%= topic.id %>'); autoUrl('postDetailDes_<%= topic.id %>'); + if($("#intro_content_<%= topic.id %>").height() > 300) { + $("#intro_content_show_<%= topic.id %>").show(); + } + $("#intro_content_show_<%= topic.id %>").click(function(){ + $("#postDetailDes_<%= topic.id %>").toggleClass("maxh300"); + $("#intro_content_show_<%= topic.id %>").hide(); + $("#intro_content_hide_<%= topic.id %>").show(); + }); + $("#intro_content_hide_<%= topic.id %>").click(function(){ + $("#postDetailDes_<%= topic.id %>").toggleClass("maxh300"); + $("#intro_content_hide_<%= topic.id %>").hide(); + $("#intro_content_show_<%= topic.id %>").show(); + }); });
    @@ -23,9 +36,14 @@ <%= get_praise_num(topic)%>
    -
    <%= topic.content.html_safe%> - +
    +
    + <%= topic.content.html_safe%> +
    + + +
    <% author = topic.last_reply.try(:author)%> <% if author%>
    最后回复:<%= author.show_name%>
    @@ -36,10 +54,10 @@
    <% end %> -
    \ No newline at end of file diff --git a/app/views/forums/create.js.erb b/app/views/forums/create.js.erb index ee8172cbd..39bebe20a 100644 --- a/app/views/forums/create.js.erb +++ b/app/views/forums/create.js.erb @@ -1,7 +1,5 @@ <%if @save_flag%> -//$('#new_forum_div').slideToggle();$('#create_btn').parent().slideToggle(); -//$('#reorder_time').click(); - window.location.href= "<%= host_with_protocol %>"+"/forums/" + "<%= @forum.id%>" +$("#forum_right_bar").html('<%= escape_javascript( render :partial => 'forums/right_bar') %>'); <%else%> $("#error").html("<%= @forum.errors.full_messages[0]%>").show(); <%end %> diff --git a/app/views/forums/edit.js.erb b/app/views/forums/edit.js.erb new file mode 100644 index 000000000..98fbc95b7 --- /dev/null +++ b/app/views/forums/edit.js.erb @@ -0,0 +1,5 @@ +var htmlvalue = "<%= escape_javascript(render :partial => 'forums/edit') %>"; +pop_box_new(htmlvalue,460,190); + + + diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 9b18070a8..bc6665913 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -1,176 +1,159 @@ -<%= javascript_include_tag 'new_user' %> -<%= stylesheet_link_tag 'css/common','css/public'%> - - -
    -
    -
    - -
    - <%= render :partial => 'post_banner' ,:locals => {:order_type=>@type,:order_str=>@str}%> - - - - - - -
    -
    - <%= render :partial => 'forum_list',:locals => {:forums=>@forums}%> -
    -
      - <%= pagination_links_full @forums_pages, @forums_count ,:per_page_links => true,:remote =>true,:flag=>true%> -
    +
    +
    + + + +
    + <%= link_to "发布新帖",new_forum_memo_path(:forum_id => Forum.first.id), :class => "c_white db creatPostIcon bBlue" %> +
    -
    -
    +
    +
    + <%= render :partial => 'show_topics',:locals => {:memos => @memos} %> +
    + +<%= render :partial => "forums/my_count_message" %> + +
    +
    +

    问吧

    + <%= link_to "新建贴吧", new_forum_path, :class => "btn-blue btn fr mt5 mr5", :remote => true %> +
    +
    + <%= render :partial => "forums/right_bar" %> + <% if @forums.count > 10 %> + 点击展开更多 + <% end %> +
    +
    + + \ No newline at end of file diff --git a/app/views/forums/index.js.erb b/app/views/forums/index.js.erb index 642c3c20a..6df357975 100644 --- a/app/views/forums/index.js.erb +++ b/app/views/forums/index.js.erb @@ -1,4 +1,4 @@ //$("#postBanner").html("<%#= render :partial => 'post_banner' ,:locals => {:order_type=>@type,:order_str=>@str }%>"); -$("#forum_list").html("<%= escape_javascript(render :partial => 'forum_list',:locals => {:forums=>@forums}) %>"); +$("#forum_list").html("<%= escape_javascript(render :partial => 'show_topics', :locals => {:memos => @memos}) %>"); //这里出现一个问题竟然是单双引号引起的。注意!! -$("#pages").html('<%= pagination_links_full @forums_pages, @forums_count,:per_page_links => false,:remote =>true,:flag=>true%>'); \ No newline at end of file +$("#pages").html('<%= pagination_links_full @topic_pages, @topic_count ,:per_page_links => true, :remote => true, :flag => true, :is_new => true %>'); \ No newline at end of file diff --git a/app/views/forums/mail_feedback.js.erb b/app/views/forums/mail_feedback.js.erb new file mode 100644 index 000000000..880eae92b --- /dev/null +++ b/app/views/forums/mail_feedback.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%= escape_javascript(render :partial => 'forums/emali_valid_tip') %>"; +pop_box_new(htmlvalue,380,250); \ No newline at end of file diff --git a/app/views/forums/new.js.erb b/app/views/forums/new.js.erb new file mode 100644 index 000000000..64d5e49c9 --- /dev/null +++ b/app/views/forums/new.js.erb @@ -0,0 +1,5 @@ +var htmlvalue = "<%= escape_javascript(render :partial => 'forums/new') %>"; +pop_box_new(htmlvalue,560,390); + + + diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 61ffb8b10..d07a42ed5 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,59 +1,42 @@ <%= content_for(:header_tags) do %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> - <%= javascript_include_tag 'new_user' %> <% end %> + - -
    - -
    +
    +
    - +
    + <%= link_to "我要提问", new_forum_memo_path(:forum_id => @forum), :class => "c_white db creatPostIcon bBlue" %> + +
    - <%= render :partial => 'show_topics',:locals => {:memos=>@memos}%> + <%= render :partial => 'show_topics',:locals => {:memos => @memos}%> +
    +
    + +
    +
    + <%= render :partial => "memos/my_count_message" %>
    - - - - - - - - - - -
    +
    +
    +
    +

    推荐问吧

    +
    + <%= render :partial => "forums/right_bar" %> +
    +
    + + diff --git a/app/views/layouts/base_forums.html.erb b/app/views/layouts/base_forums.html.erb index cc1780030..4b259e9f4 100644 --- a/app/views/layouts/base_forums.html.erb +++ b/app/views/layouts/base_forums.html.erb @@ -219,7 +219,7 @@
    <%= link_to image_tag(url_to_avatar(User.current),:width=>50,:height => 50,:alt=>'贴吧图像' ),user_path( User.current) %>
    -
    我在贴吧
    +
    我在贴吧
    diff --git a/app/views/layouts/base_mail.html.erb b/app/views/layouts/base_mail.html.erb new file mode 100644 index 000000000..982dbed63 --- /dev/null +++ b/app/views/layouts/base_mail.html.erb @@ -0,0 +1,59 @@ + + + + + <%=h html_title %> + <%= render :partial => "layouts/point_browser" %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= javascript_include_tag "jquery.leanModal.min" %> + <%= javascript_include_tag 'seems_rateable/jRating','prettify', 'seems_rateable/rateable'%> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + <%= stylesheet_link_tag 'css/common','css/structure','css/public', 'css/moduel', 'css/font-awesome', 'css/popup', :media => 'all'%> + + + + + + +
    + +
    + +
    +
    +
    +
    +
    + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    +
    +
    +
    + + + +
    +
    +
    +<%= render :partial => 'layouts/footer' %> +
    +<%= call_hook :view_layouts_base_body_bottom %> + + diff --git a/app/views/layouts/base_new_forum.html.erb b/app/views/layouts/base_new_forum.html.erb new file mode 100644 index 000000000..5690209e0 --- /dev/null +++ b/app/views/layouts/base_new_forum.html.erb @@ -0,0 +1,58 @@ + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','application','prettify', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= stylesheet_link_tag 'css/common','css/structure','css/public','css/forum','css/popup' ,:media => 'all'%> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + + + + + +
    + +
    + + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    +
    + +
    +<%= render :partial => 'layouts/footer' %> +
    +<% if hidden_unproject_infos %> + <%= render :partial => 'layouts/new_feedback' %> +<% end %> + + + +<%= call_hook :view_layouts_base_body_bottom %> + + + + + +<%= javascript_include_tag('jquery-1.8.3-ui-1.9.2-ujs-2.0.3', 'application', 'jquery.colorbox-min') %> + + diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 42912fcd5..5778949aa 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -244,7 +244,7 @@ <%= link_to "竞赛社区", user_contest_community_path(User.current), :class => "fl" , :target => "_blank"%>
      -
    • +
    • <%= link_to user_contest_count > 0 ? "竞赛#{user_contest_count}".html_safe : "竞赛", user_contest_community_path(User.current), :id => "user_contest_list", :target => "_blank" %>
    • diff --git a/app/views/mailer/register.html.erb b/app/views/mailer/register.html.erb index 146456358..d7df6cd41 100644 --- a/app/views/mailer/register.html.erb +++ b/app/views/mailer/register.html.erb @@ -37,7 +37,7 @@ (如果链接点击无效,请手动复制链接并粘贴到浏览器地址栏中,然后按“回车”打开页面即可)

      -
      +

      扫一扫,关注 Trustie 微信公众号,更方便获任务通知,作业等提醒
      diff --git a/app/views/memos/_form.html.erb b/app/views/memos/_form.html.erb index 961e54ded..1128d0a86 100644 --- a/app/views/memos/_form.html.erb +++ b/app/views/memos/_form.html.erb @@ -1,3 +1,111 @@ -<%= error_messages_for 'bid' %> -

      <%= f.text_field :content, :required => true, :size => 60, :style => "width:150px;" %>

      -

      <%= hidden_field_tag 'subject'||=@memo.subject %> \ No newline at end of file +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> +<% end %> + +

      +
      +
        +
      • + <%= f.text_field :subject, :no_label => true, :id => "memo_subject", :maxlength => "50", :style => "width:708px", :onblur => "check_memo_name();", :onfocus => "$('#memo_name_error_tips').hide();", :onmouseover => "this.style.borderColor='#d9d9d9'", :class => "wenba-tiwen-input", :placeholder => "请输入标题" %> + + +
      • +
      • + <%= f.kindeditor :content, :editor_id => "memo_content", :height => 300, :no_label => true %> +
      • + +
      • + <%= render :partial => 'forums/file_form', :locals => {:container => @memo} %> +
      • +
      +
        +

        请选择分类

        + <% @forums.each do |forum| %> + + <% end %> +
      + +
      + <%= link_to "取消", forum_path(@forum), :class => "btn fr" %> + 确定 +
      +
      +
      + + \ No newline at end of file diff --git a/app/views/memos/_my_count_message.html.erb b/app/views/memos/_my_count_message.html.erb new file mode 100644 index 000000000..e01ebfe18 --- /dev/null +++ b/app/views/memos/_my_count_message.html.erb @@ -0,0 +1,157 @@ +
      +
      +
      <%= link_to image_tag(url_to_avatar(@forum.creator),:width => 75,:height => 75,:alt => '贴吧图像' ), user_path( @forum.creator) %> + +
      +
      + <% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %> +
      吧主:
      + <%= user_name %> + +
      +
      +
      + <%= link_to @forum.name, forum_path(@forum), :class => "f16 fontBlue", :style => "word-break: break-all; word-wrap:break-word;white-space:pre-wrap;" %> +
      +
      +
      + <%= h @forum.description.html_safe%> + <% if @forum.creator.id == User.current.id %> + + <%= image_tag('signature_edit.png',{:width => 12,:height => 12}) %> + + <% end %> +
      + + + + + + + + + + + + + <% if @forum.creator.id == User.current.id %> + + <%= link_to "编辑贴吧", edit_forum_path(@forum), :class => "linkGrey3", :remote => true %> + 删除贴吧 + + + <% end %> +
      + <% unless params[:controller] == "forums" %> +
      + <%= link_to "我要提问".html_safe, new_forum_memo_path(:forum_id => @forum) %> +
      + <% end %> +
      + \ No newline at end of file diff --git a/app/views/memos/_new.html.erb b/app/views/memos/_new.html.erb new file mode 100644 index 000000000..153e93f2b --- /dev/null +++ b/app/views/memos/_new.html.erb @@ -0,0 +1,33 @@ +
      +
      +
        +
      • + +
      • +
      • + +
      • +
      • + +

        (未选择文件) 您可以上传小于50MB的文件

        +
      • +
      + +
      + + +
      +
      +
      \ No newline at end of file diff --git a/app/views/memos/_praise_tread.html.erb b/app/views/memos/_praise_tread.html.erb index a92cc9a26..31d24af17 100644 --- a/app/views/memos/_praise_tread.html.erb +++ b/app/views/memos/_praise_tread.html.erb @@ -21,7 +21,7 @@ <%#= link_to image_tag("/images/praise_tread/praise_true.png",weight:"22px", height:"22px",:title => l(:label_issue_praise)), :controller=>"praise_tread",:action=>"praise_plus",:remote=>true,:obj_id => obj.id,:obj_type => obj.class,:horizontal => horizontal %> - <%= get_praise_num(obj)%> + <%= get_praise_num(obj)%> diff --git a/app/views/memos/edit.html.erb b/app/views/memos/edit.html.erb index 6806e0996..fdbd778bc 100644 --- a/app/views/memos/edit.html.erb +++ b/app/views/memos/edit.html.erb @@ -39,33 +39,19 @@ } } -
      -
      编辑帖子
      + -
      - <%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %> - -
      - - -
      -
      - <%= kindeditor_tag 'memo[content]',@memo.content,:height=>300,:editor_id=>'memo_content'%> -
      -
      - - <%= render :partial => 'forums/file_form', :locals => {:container => @memo} %> - - -
      -
      - <% end %> +<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id => 'new_memo'}) do |f| %> + <%= render :partial => "memos/form", :locals => {:f => f} %> +<% end %> + +
      + <%= render :partial => "memos/my_count_message" %>
      + -
      +
      <%= link_to image_tag(url_to_avatar(@memo.author),:width=>50,:height => 50,:alt=>'贴吧图像' ),user_path(@memo.author) %> @@ -96,6 +100,12 @@
      +
      + <%= render :partial => "memos/my_count_message" %> +
      + + + + +
      +
      +
      + <%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %> +
      +
      + <% if User.current.logged? %> + + <%end%> + +
      +
      + <%= link_to @topic.author.show_name, user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> +
      +
      <%= format_time( @topic.created_on)%>
      +
      +
      + <%= @topic.content.html_safe%> +
      +
      +
      + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @topic} %> +
      +
      +
      +
      +
      +
      +
      +
      回复 + <%= @reply_count>0 ? "(#{@reply_count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>@topic, :user_activity_id=>@topic.id,:type=>"activity"}%> + +
      +
      + <%# all_comments = []%> + <%# comments = get_all_children(all_comments, @topic) %> +
      + <%= render :partial => "messages/contest_show_replies" %> +
      + +
      + <% if !@topic.locked? && User.current.logged? %> +
      + +
      +
      + <%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'course_board_canel_message_replay();', :class => "grey_btn fr c_white mt10 mr5 ml10" %> + <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'course_board_submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-left: 50px;" %> + <% end %> +
      +
      +
      + <% end %> +
      +
      + diff --git a/app/views/messages/_contest_show_replies.html.erb b/app/views/messages/_contest_show_replies.html.erb new file mode 100644 index 000000000..b9c179ff2 --- /dev/null +++ b/app/views/messages/_contest_show_replies.html.erb @@ -0,0 +1,60 @@ +<% @replies.each do |reply| %> + +
      +
      + <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
      +
      + <%= render :partial => 'users/message_contents', :locals => {:comment => reply, :type => 'Message', :user_activity_id => @topic.id}%> + +
      + <%= reply.content.html_safe%> +
      +
      +
      + + + <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %> + + + <%= link_to( + l(:button_reply), + {:action => 'quote', :id => reply}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> + + + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => reply}, + :method => :post, + :id => "delete_reply_#{reply.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if reply.contest_destroyable_by?(User.current) %> + + +
      +
      +
      +

      +
      +
      +
      +<% end %> +<% if @limit_count > @page * @limit + 10 %> +
      +
      + + + <%= link_to '点击展开更多回复', board_message_path(@topic.board_id, @topic, :page => @page),:remote=>true %> +
      +
      +<% end %> \ No newline at end of file diff --git a/app/views/messages/destroy.js.erb b/app/views/messages/destroy.js.erb index 8c269c1c3..17a482c37 100644 --- a/app/views/messages/destroy.js.erb +++ b/app/views/messages/destroy.js.erb @@ -7,6 +7,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re <%elsif @course%> $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); +<%elsif @contest%> +$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); <% elsif @org_subfield %> $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); <%end%> diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index 324b1edf1..83f2e7293 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -24,6 +24,19 @@ :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %> <% end %>
      +<% elsif @message.contest %> +
      + <%= form_for @message, { + :as => :message, + :url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board}, + :html => {:multipart => true, + :id => 'message-form', + :method => :post} + } do |f| %> + <%= render :partial => 'boards/contest_message_edit', + :locals => {:f => f, :edit_mode => true, :topic => @message, :contest => @message.contest} %> + <% end %> +
      <% elsif @message.board.org_subfield %> <%= form_for @message, { :as => :message, diff --git a/app/views/messages/reply.js.erb b/app/views/messages/reply.js.erb index 8c269c1c3..17a482c37 100644 --- a/app/views/messages/reply.js.erb +++ b/app/views/messages/reply.js.erb @@ -7,6 +7,8 @@ $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(re <%elsif @course%> $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/course_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); +<%elsif @contest%> +$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/contest_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); <% elsif @org_subfield %> $("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'organizations/org_message_post_reply', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); <%end%> diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 428c51f22..adde5d160 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -2,6 +2,8 @@ <%= render :partial => 'project_show', locals: {project: @project} %> <% elsif @course %> <%= render :partial => 'course_show', locals: {course: @course} %> +<% elsif @contest %> + <%= render :partial => 'contest_show', locals: {contest: @contest} %> <% else %> <%= render :partial => 'org_subfield_show', :locals => {:org_subfield => @org_subfield} %> <% end %> diff --git a/app/views/student_work/_add_score.html.erb b/app/views/student_work/_add_score.html.erb index 40779c9f3..7d01dbca4 100644 --- a/app/views/student_work/_add_score.html.erb +++ b/app/views/student_work/_add_score.html.erb @@ -1,7 +1,7 @@ <%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%>
    • 评价: - <%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %> + <%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>500),:maxlength => 500 %>
    • diff --git a/app/views/users/_collect_contest.html.erb b/app/views/users/_collect_contest.html.erb index a76701ea0..b5add18de 100644 --- a/app/views/users/_collect_contest.html.erb +++ b/app/views/users/_collect_contest.html.erb @@ -1,7 +1,7 @@ <% member = ContestMember.where("user_id = #{@user.id} and contest_id = #{contest.id}").first %> <% if User.current == @user %> <% if member %> - <%= link_to "", cancel_or_collect_user_path(@user, :contest => contest.id), :class => "#{member.is_collect == true ? 'icons_project_favorite mt3' : 'icons_project_star mt3'}", :target => '_blank', :remote => true, :title => "#{member.is_collect == true ? '点击将其从个人主页的项目列表中移除' : '点击将其添加至个人主页的项目列表中'}" %> + <%= link_to "", cancel_or_collect_user_path(@user, :contest => contest.id), :class => "#{member.is_collect == true ? 'icons_project_favorite mt3' : 'icons_project_star mt3'}", :target => '_blank', :remote => true, :title => "#{member.is_collect == true ? '点击将其从左侧导航的竞赛列表中移除' : '点击将其添加至左侧导航的竞赛列表中'}" %> <% end %> <% else %> <% if member %> diff --git a/app/views/users/_contest_list_contents.html.erb b/app/views/users/_contest_list_contents.html.erb index 3d02dd46c..3d9b290c8 100644 --- a/app/views/users/_contest_list_contents.html.erb +++ b/app/views/users/_contest_list_contents.html.erb @@ -11,8 +11,7 @@

      更新时间:<%= format_date(contest.updated_at) %>     - <% contestUser = User.where("id=?", contest.user_id).first %> - 单位:<%= contestUser.user_extensions.school_id.blank? ? "无" : contestUser.user_extensions.school.name %> + 创建者:<%= contest.user.show_name %>

      diff --git a/app/views/users/_contest_message.html.erb b/app/views/users/_contest_message.html.erb new file mode 100644 index 000000000..e76438d16 --- /dev/null +++ b/app/views/users/_contest_message.html.erb @@ -0,0 +1,92 @@ +
      +
      +
      + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author, :host => Setting.host_user), :alt => "用户头像" %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> +
      +
      +
      + <%= link_to activity.author.show_name, user_path(activity.author, :host=>Setting.host_user), :class => "newsBlue mr15" %> + TO + <% str = is_course == 1 ? "#{activity.board.parent.nil? ? '竞赛讨论区' : activity.board.name}" : activity.contest.name.to_s+" | #{activity.board.parent.nil? ? '竞赛讨论区' : activity.board.name}" %> + <%= link_to str, contest_boards_path(activity.contest), :class => "newsBlue ml15"%> +
      + + <% if activity.sticky == 1 %> + 置顶 + <% end%> + <% if activity.locked %> +        + <% end %> +
      +
      + 发帖时间:<%= format_time(activity.created_on) %> +
      +
      + 更新时间:<%= format_time(ContestActivity.where("contest_act_type='#{activity.class}' and contest_act_id =#{activity.id}").first.updated_at) %> +
      +
      + <% if activity.parent_id.nil? %> + <% content = activity.content %> + <% else %> + <% content = activity.parent.content %> + <% end %> + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %> +
      + + +
      +
      + <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> +
      + + <% if User.current.logged? %> + + <% end %> + +
      +
      +
      +
      +
      + <%=render :partial => 'users/contest_message_post_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %> +
      +
      +
      + diff --git a/app/views/users/_contest_message_post_reply.html.erb b/app/views/users/_contest_message_post_reply.html.erb new file mode 100644 index 000000000..02d7abdd4 --- /dev/null +++ b/app/views/users/_contest_message_post_reply.html.erb @@ -0,0 +1,35 @@ +<% all_replies = Message.where("root_id = #{activity.id}").reorder("created_on desc") %> +<% count = all_replies.count %> +<% no_children_comments = get_no_children_comments all_replies %> +<%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :expand_more =>no_children_comments[:three_more]} %> + +<% if count > 0 %> +
      + <%= render :partial => 'users/message_replies', :locals => {:comments => no_children_comments[:no_children_comments], :user_activity_id => user_activity_id, :type => 'Message', :activity_id =>activity.id}%> +
      +<% end %> +<% if !activity.locked? %> +
      +
      <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
      +
      + <% if User.current.logged? %> +
      + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id},:method => "post", :remote => true) do |f|%> + + +
      + + +
      +

      + <% end%> +
      +
      + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %> +
      +
      +
      +
      +<% end %> diff --git a/app/views/users/_contest_work.html.erb b/app/views/users/_contest_work.html.erb index 7d1744303..d4bca6c3f 100644 --- a/app/views/users/_contest_work.html.erb +++ b/app/views/users/_contest_work.html.erb @@ -8,20 +8,22 @@
      <%= link_to activity.user.show_name, user_path(activity.user,:host=>Setting.host_user), :class => "newsBlue mr15" %> - TO - <% if hw_status == 3 || hw_status == 2 %> - <%= link_to "作品", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%> + <% if hw_status == 3 %> + <% elsif hw_status == 2 %> + TO + <%= link_to "提交", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%> <% else %> - <%= link_to activity.contest.name.to_s+" | 竞赛作品", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%> + TO + <%= link_to activity.contest.name.to_s+" | 竞赛提交", works_path(:contest => activity.contest.id), :class => "newsBlue ml15"%> <% end %>
      <%=get_cw_status(activity).html_safe %> diff --git a/app/views/users/_contest_work_base_info.html.erb b/app/views/users/_contest_work_base_info.html.erb index 8f9f2e5c7..f6b6c433c 100644 --- a/app/views/users/_contest_work_base_info.html.erb +++ b/app/views/users/_contest_work_base_info.html.erb @@ -49,7 +49,22 @@ <%= link_to "编 辑",edit_work_path(activity, :hw_status => hw_status), :class => "wpostOptionLink"%>
    • - <%= link_to "删 除",work_path(activity, :hw_status => hw_status),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "wpostOptionLink" %> + 删除 +
    • +
    • + <%= link_to("评分设置", score_rule_set_work_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true) %> +
    • + <% if (!activity.online_evaluation && !activity.is_open && activity.work_status == 2) || (activity.online_evaluation && activity.work_status == 4 && !activity.is_open) %> +
    • + 公开作品 +
    • + <% elsif activity.is_open %> +
    • + 取消公开 +
    • + <% end %> +
    • + <%= link_to("成绩公开范围", alert_score_open_modal_work_path(activity,:user_activity_id => user_activity_id, :hw_status => hw_status),:class => "wpostOptionLink", :remote => true) %>
    diff --git a/app/views/users/_course_boardlist.html.erb b/app/views/users/_course_boardlist.html.erb index d060bd8b9..9224fcc36 100644 --- a/app/views/users/_course_boardlist.html.erb +++ b/app/views/users/_course_boardlist.html.erb @@ -60,7 +60,8 @@
    <% else %> -

    <%= l(:label_no_data) %>

    +
    +

    没有数据可以显示!

    <% end %>
    diff --git a/app/views/users/_join_contest_applied_message.html.erb b/app/views/users/_join_contest_applied_message.html.erb index 3a6b5f3d3..2baa3a9ea 100644 --- a/app/views/users/_join_contest_applied_message.html.erb +++ b/app/views/users/_join_contest_applied_message.html.erb @@ -13,23 +13,12 @@ :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> - <% if applied_contest.role - role_str = "" - if applied_contest.role.include?('13') && applied_contest.role.include?('14') - role_str = "管理员、评委" - elsif applied_contest.role.include?('13') - role_str = "管理员" - elsif applied_contest.role.include?('14') - role_str = "评委" - elsif applied_contest.role.include?('15') - role_str = "参赛者" - end - end %> - 申请以<%= role_str %>的身份加入竞赛: + <%= message_user.user_extensions.school_id.blank? ? "" : "来自"+message_user.user_extensions.school.name+"," %> + 申请以"<%= get_role_str ma.role %>"的身份加入竞赛:
  • - <% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + role_str %> + <% content = message_user.show_name + "申请成为班级\"" + "#{contest.name}" + "\"的" + get_role_str(ma.role) %> <%= link_to contest.name, contest_path(contest.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}", :target => '_blank', :title => "#{content}" %>
  • @@ -41,9 +30,9 @@ | <%= link_to '拒绝',dealwith_apply_request_contest_path(contest,:agree=>'N',:msg_id=>ma.id),:remote=>'true',:class=>'linkBlue'%> <% elsif ma.status == 1%> - 已同意申请 + <%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : "管理员" %>已同意 <% elsif ma.status == 2%> - 已拒绝申请 + <%= ma.applied_user_id ? User.find(ma.applied_user_id).show_name : "管理员" %>已拒绝 <%end %> diff --git a/app/views/users/_message_contents.html.erb b/app/views/users/_message_contents.html.erb index 265a4ab0e..24cd020c7 100644 --- a/app/views/users/_message_contents.html.erb +++ b/app/views/users/_message_contents.html.erb @@ -1,5 +1,5 @@
    - <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user), :class => "newsBlue mr10 f14" %> + <%= link_to comment.creator_user.show_name, user_path(comment.creator_user), :class => "newsBlue mr10 f14" %> <%= time_from_now(comment.respond_to?(:created_on) ? comment.created_on : comment.created_at) %>
    <% if !comment.parent.nil? && !comment.parent.parent.nil? %> diff --git a/app/views/users/_message_replies.html.erb b/app/views/users/_message_replies.html.erb index 86f5f8220..9f810a052 100644 --- a/app/views/users/_message_replies.html.erb +++ b/app/views/users/_message_replies.html.erb @@ -36,7 +36,7 @@ <% end %> - <% if comment.course_destroyable_by?(User.current) || comment.destroyable_by?(User.current) %> + <% if comment.course_destroyable_by?(User.current) || comment.destroyable_by?(User.current) || comment.contest_destroyable_by?(User.current) %> <%= link_to( l(:button_delete), delete_board_message_path(comment,:board_id =>comment.board.id, :user_activity_id => user_activity_id, :activity_id => activity_id), diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index b8341f023..9778c6b4f 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -74,7 +74,7 @@
    - <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => user_activity_id, :content => activity.description} %> + <%= render :partial => "users/intro_content", :locals => {:user_activity_id => user_activity_id, :content => activity.description} %>
    diff --git a/app/views/users/_project_issue_detail.html.erb b/app/views/users/_project_issue_detail.html.erb index cb160c3b5..34c131a89 100644 --- a/app/views/users/_project_issue_detail.html.erb +++ b/app/views/users/_project_issue_detail.html.erb @@ -58,7 +58,8 @@ - <%= form_tag({:controller => 'issues', :action => 'update', :id => activity.id, :issue_detail => true, :type => "assigned"},:remote=>'true', :method => :put, :id=>"issue_query_assign_form_#{activity.id}", :class => 'query_form') do %> + <%= form_tag({:controller => 'issues', :action => 'update', :id => activity.id, :issue_detail => true, :type => "assigned"}, + :remote=>'true', :method => :put, :id => "issue_query_assign_form_#{activity.id}", :class => 'query_form') do %>
  •  指派  : 

    diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 0b32d2793..85a2c09c5 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -90,7 +90,7 @@ <% when 'News' %> <%= render :partial => 'contest_news', :locals => {:activity => act, :user_activity_id => user_activity.id} %> <% when 'Message' %> - <%#= render :partial => 'contest_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_contest => 0, :is_board => 0} %> + <%= render :partial => 'contest_message', :locals => {:activity => act, :user_activity_id => user_activity.id, :is_course => 0, :is_board => 0} %> <% when 'Contest' %> <%= render :partial => 'users/contest_create', :locals => {:activity => act, :user_activity_id => act.id} %> <% when 'JournalsForMessage' %> diff --git a/app/views/users/_user_message_contest.html.erb b/app/views/users/_user_message_contest.html.erb index 21ab5b873..c2c18837a 100644 --- a/app/views/users/_user_message_contest.html.erb +++ b/app/views/users/_user_message_contest.html.erb @@ -32,5 +32,191 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • - <% end %> + + + <% elsif ma.contest_message_type == "JoinContest" and ma.status == 0 %> + + + + <% elsif ma.contest_message_type == "JoinContest" and ma.status == 1 %> + + + + <% elsif ma.contest_message_type == "RemoveFromContest" %> + + + + <% elsif ma.contest_message_type == "Work" && ma.status.nil? && ma.contest_message %> + + + + <% elsif ma.contest_message_type == "Work" && ma.status == 1 && ma.contest_message %> + + + + <% elsif ma.contest_message_type == "News" && ma.contest_message %> + + + + <% elsif ma.contest_message_type == "Comment" && ma.contest_message %> + + + + <% elsif ma.contest_message_type == "Message" && !ma.nil? && !ma.contest_message.nil? %> + + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index edc94d6cc..9c0e61af6 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -66,7 +66,7 @@ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %> 发布了班级作业: -
  • +
  • <% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %> <%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", diff --git a/app/views/users/_work_opr.html.erb b/app/views/users/_work_opr.html.erb index e35ff1de2..eb5355246 100644 --- a/app/views/users/_work_opr.html.erb +++ b/app/views/users/_work_opr.html.erb @@ -1,11 +1,11 @@ <% work = cur_user_works_for_work activity %> <% if activity.work_type == 3 && User.current.contestant_of_contest?(activity.contest) && activity.work_detail_group.base_on_project %> <% projects = cur_user_projects_for_work activity %> - <% if work.nil? && projects.nil? %> + <% if work.nil? && projects.nil? && activity.work_status == 1 %>
    <%=link_to "关联项目",new_student_work_project_contestant_works_path(:work => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id),remote: true,:class=> 'c_blue', :title=> '请各组长关联项目' %>
    - <% elsif work.nil? %> + <% elsif work.nil? && activity.work_status == 1 %>
    <%=link_to "取消关联",cancel_relate_project_contestant_works_path(:work => activity.id,:hw_status=>hw_status,:user_activity_id=>user_activity_id), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %>
    diff --git a/app/views/users/contest_community.html.erb b/app/views/users/contest_community.html.erb index 0b4b971eb..adac07d6d 100644 --- a/app/views/users/contest_community.html.erb +++ b/app/views/users/contest_community.html.erb @@ -12,7 +12,7 @@
  • <%= link_to @user == User.current ? "我的动态" : "他的动态", {:controller => "users", :action => "contest_community", :type => "current_user"}, :class => "homepagePostTypeMine postTypeGrey" %>
  • <%= link_to "作品动态", {:controller => "users", :action => "contest_community", :type => "contest_work"}, :class => "homepagePostTypeAssignment postTypeGrey" %>
  • <%= link_to "通知动态", {:controller => "users", :action => "contest_community", :type => "contest_news"}, :class => "homepagePostTypeNotice postTypeGrey" %>
  • - +
  • <%= link_to "论坛动态", {:controller => "users", :action => "contest_community", :type => "contest_message"}, :class => "homepagePostTypeForum postTypeGrey" %>
  • <% end %> diff --git a/app/views/users/contest_community.js.erb b/app/views/users/contest_community.js.erb new file mode 100644 index 000000000..1273e7455 --- /dev/null +++ b/app/views/users/contest_community.js.erb @@ -0,0 +1,6 @@ +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities', + :locals => {:user_activities => @user_activities, + :page => @page, + :type => @type, + :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id), + :action => "contest_community"} )%>"); \ No newline at end of file diff --git a/app/views/works/_alert_score_open_modal.html.erb b/app/views/works/_alert_score_open_modal.html.erb new file mode 100644 index 000000000..e7191c654 --- /dev/null +++ b/app/views/works/_alert_score_open_modal.html.erb @@ -0,0 +1,42 @@ +
    +
    +

    成绩公开范围

    + +
    +
    + <%= form_for('new_form',:url =>{:controller => 'works',:action => 'set_score_open',:id => @contestwork.id,:user_activity_id => @user_activity_id, :hw_status => @hw_status}, + :method => "post", :remote => true) do |f|%> +
    +
    +
      +
    • +
        +
      • + +
      • +
      • + value="1" name="score_open"/> + +
      • +
      • + value="0" name="score_open"/> + +
      • +
      +
    • +
    +
      + +
    +
    + 确定 + 取消 +
    + +
    + <% end%> +
    \ No newline at end of file diff --git a/app/views/works/_set_score_rule.html.erb b/app/views/works/_set_score_rule.html.erb new file mode 100644 index 000000000..02c1c98f0 --- /dev/null +++ b/app/views/works/_set_score_rule.html.erb @@ -0,0 +1,136 @@ +
    +
    +

    评分设置

    + +
    +
    + <%= form_for('new_form',:url =>{:controller => 'works',:action => 'set_score_rule',:work => homework.id,:student_path => student_path,:user_activity_id=>user_activity_id,:hw_status=>hw_status},:method => "post", :remote => !student_path) do |f|%> +
    +
    +
      +
    • + value="1"/> + +
      +
        +
      • + +
        + +
        +
        +

        +
      • +
      • + +
        + +
        +
        +

        +
      • +
      • + +
        +
          +
        • + + + +
          +

          +
        • +
        • + + +
        • +
        +
      • +
      +
    • +
    • + +
      +
        +
      • + + +
        +
      • +
      • + + +
        +
      • +
      +
    • +
    +
      + + + + + + + + +
    +
    + 确定 + 取消 +
    +
    + <% end %> +
    + + \ No newline at end of file diff --git a/app/views/works/alert_score_open_modal.js.erb b/app/views/works/alert_score_open_modal.js.erb new file mode 100644 index 000000000..d43c94239 --- /dev/null +++ b/app/views/works/alert_score_open_modal.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%= escape_javascript(render :partial => 'works/alert_score_open_modal') %>"; +pop_box_new(htmlvalue, 400, 200); \ No newline at end of file diff --git a/app/views/works/destroy.js.erb b/app/views/works/destroy.js.erb new file mode 100644 index 000000000..f20508f5b --- /dev/null +++ b/app/views/works/destroy.js.erb @@ -0,0 +1,8 @@ +hideModal(); +<% if @hw_status == 1 %> + window.location.href = "<%=user_contest_community_path(User.current.id) %>" +<% elsif @hw_status == 2 %> + window.location.href = "<%=contest_path(@contest.id) %>" +<% else %> + window.location.href = "<%=works_path(:contest => @contest.id) %>" +<% end %> \ No newline at end of file diff --git a/app/views/works/index.html.erb b/app/views/works/index.html.erb index e83e6d97b..12f0d67f8 100644 --- a/app/views/works/index.html.erb +++ b/app/views/works/index.html.erb @@ -44,14 +44,14 @@