diff --git a/Gemfile b/Gemfile index fb0312d5b..58373cb06 100644 --- a/Gemfile +++ b/Gemfile @@ -32,7 +32,7 @@ group :development do if RUBY_VERSION >= '2.0.0' gem 'pry-byebug' else - gem 'pry-debugger' + # gem 'pry-debugger' end gem 'pry-stack_explorer' gem 'better_errors', '~> 1.1.0' diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index a22012390..be97fdb6e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -15,7 +15,7 @@ class BidsController < ApplicationController before_filter :can_show_contest,only: [] #Ended by young before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, - :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] + :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] # added by fq before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] # end @@ -48,7 +48,7 @@ class BidsController < ApplicationController format.js end end - + def index @project_type = params[:project_type] @@ -57,8 +57,8 @@ class BidsController < ApplicationController @offset, @limit = api_offset_and_limit({:limit => 10}) if @project_type == '1' @bids = Bid.visible.where('reward_type = ?', 3) - # elsif - # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) + # elsif + # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) else @bids = Bid.visible.where('reward_type = ?', 1) end @@ -71,33 +71,33 @@ class BidsController < ApplicationController #added by nie if params[:bid_sort_type].present? case params[:bid_sort_type] - when '0' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(limit).all.reverse - end - @s_state = 0 - when '1' - unless @offset == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 - when '2' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - end - @s_state = 0 + when '0' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(limit).all.reverse + end + @s_state = 0 + when '1' + unless @offset == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 + when '2' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + end + @s_state = 0 end else unless @offset == 0 @@ -109,7 +109,7 @@ class BidsController < ApplicationController end @s_state = 1 end - #end + #end end #huang def contest @@ -130,33 +130,33 @@ class BidsController < ApplicationController #added by nie if params[:contest_sort_type].present? case params[:contest_sort_type] - when '0' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(limit).all.reverse - end - @s_state = 0 - when '1' - unless @offset == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse - end - @s_state = 1 - when '2' - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - limit = @limit if limit == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - end - @s_state = 0 + when '0' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(limit).all.reverse + end + @s_state = 0 + when '1' + unless @offset == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse + end + @s_state = 1 + when '2' + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + limit = @limit if limit == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + end + @s_state = 0 end else unless @offset == 0 @@ -168,7 +168,7 @@ class BidsController < ApplicationController end @s_state = 1 end - #end + #end end def fork @@ -176,11 +176,12 @@ class BidsController < ApplicationController @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) @membership.each do |membership| if membership.project.project_type == 1 - @courses << membership.project + @courses << membership.project end end end + #将某个企业外包需求选为作业,目前此功能已放弃 def create_fork @homework = Bid.new @homework.name = params[:bid][:name] @@ -215,6 +216,7 @@ class BidsController < ApplicationController end end + #有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认 def show @user = @bid.author @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') @@ -229,12 +231,12 @@ class BidsController < ApplicationController layout_file = '' case @bid.reward_type when 3 - html_title(l(:label_question_student)) - layout_file = 'base_homework' - when 1 - layout_file = 'base_bids' - else - layout_file = 'base_contest' + html_title(l(:label_question_student)) + layout_file = 'base_homework' + when 1 + layout_file = 'base_bids' + else + layout_file = 'base_contest' end format.html { render :layout => layout_file @@ -242,7 +244,7 @@ class BidsController < ApplicationController format.api end end - + def join_in_contest if @bid.reward_type == 2 && params[:course_password] == @bid.password JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id) @@ -250,53 +252,44 @@ class BidsController < ApplicationController else @state = 1 end - respond_to do |format| - # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} - # TO_DO format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } end end - + def unjoin_in_contest - joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id) - joined.each do |join| join.delete end - respond_to do |format| - # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } end end - - def new_join - # added by fq + def new_join end - + # added by bai 增加了参与者和竞赛设置 def show_participator render :layout => 'base_contest' - end - + + #配置竞赛 def settings - if @bid.author.id == User.current.id - if @bid.reward_type == 2 - @contest = Bid.find_by_reward_type(@bid.reward_type) - render :layout => 'base_contest' - end - else - render_403 :message => :notice_not_contest_setting_authorized - end + if @bid.author.id == User.current.id + if @bid.reward_type == 2 + @contest = Bid.find_by_reward_type(@bid.reward_type) + render :layout => 'base_contest' + end + else + render_403 :message => :notice_not_contest_setting_authorized + end end #end - # 显示课程 + # 显示课程作业,但是好像已经废弃 def show_course bids = Bid.where('parent_id = ?', @bid.id) @courses = [] @@ -311,12 +304,12 @@ class BidsController < ApplicationController } elsif @bid.reward_type == 1 format.html { - render :layout => 'base_bids' - } + render :layout => 'base_bids' + } else - format.html { - render :layout => 'base_contest' - } + format.html { + render :layout => 'base_contest' + } end format.api @@ -337,12 +330,12 @@ class BidsController < ApplicationController } elsif @bid.reward_type == 1 format.html { - render :layout => 'base_bids' - } + render :layout => 'base_bids' + } else - format.html { - render :layout => 'base_contest' - } + format.html { + render :layout => 'base_contest' + } end format.api @@ -365,12 +358,12 @@ class BidsController < ApplicationController } elsif @bid.reward_type == 1 format.html { - render :layout => 'base_bids' - } + render :layout => 'base_bids' + } else - format.html { - render :layout => 'base_contest' - } + format.html { + render :layout => 'base_contest' + } end format.api @@ -459,9 +452,7 @@ class BidsController < ApplicationController def show_courseEx if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?)) - # flash[:notice] = "" @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current)) - @user = @bid.author @bidding_project = @bid.biding_projects.all @@ -569,12 +560,12 @@ class BidsController < ApplicationController } elsif @bid.reward_type == 1 format.html { - render :layout => 'base_bids' - } + render :layout => 'base_bids' + } else - format.html { - render :layout => 'base_contest' - } + format.html { + render :layout => 'base_contest' + } end format.api end @@ -586,19 +577,19 @@ class BidsController < ApplicationController bid_message = params[:bid_for_save][:bid_message] if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0 if BidingProject.cerate_bidding(@bid.id, project.id, bid_message) - + # added by bai type ==1 需求,type==2 竞赛, type==3 作业 if @bid.reward_type == 1 flash.now[:notice] = l(:label_bidding_succeed) - + elsif @bid.reward_type == 2 flash.now[:notice] = l(:label_bidding_contest_succeed) - + else @bid.reward_type == 3 - flash.now[:notice] = l(:label_bidding_homework_succeed) + flash.now[:notice] = l(:label_bidding_homework_succeed) end # end - + end else if @bid.reward_type == 3 @@ -609,11 +600,11 @@ class BidsController < ApplicationController end @bidding_project = @bid.biding_projects respond_to do |format| - # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} - # format.html + # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} + # format.html format.html { redirect_to :back } format.js - #format.api { render_api_ok } + #format.api { render_api_ok } end end @@ -647,7 +638,7 @@ class BidsController < ApplicationController @bid.set_commit(@feedback_count) respond_to do |format| format.js - #format.api { render_api_ok } + #format.api { render_api_ok } end end @@ -674,9 +665,9 @@ class BidsController < ApplicationController # @message_count = a_message.count respond_to do |format| - # format.html + # format.html format.js - #format.api { render_api_ok } + #format.api { render_api_ok } end end @@ -689,7 +680,7 @@ class BidsController < ApplicationController respond_to do |format| format.html { redirect_to :back } format.js - #format.api { render_api_ok } + #format.api { render_api_ok } end end @@ -698,11 +689,11 @@ class BidsController < ApplicationController def new @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id] if @jour - user = @jour.user - text = @jour.notes + user = @jour.user + text = @jour.notes else - user = @bid.author - text = @bid.description + user = @bid.author + text = @bid.description end # Replaces pre blocks with [...] text = text.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]') @@ -711,7 +702,7 @@ class BidsController < ApplicationController @id = user.id rescue ActiveRecord::RecordNotFound render_404 - end + end ##新建需求 def new_bid @@ -743,15 +734,15 @@ class BidsController < ApplicationController end end -# added by bai - def update_contest + # added by bai + def update_contest @bid = Bid.find(params[:id]) @bid.name = params[:bid][:name] @bid.description = params[:bid][:description] @bid.reward_type = 2 @bid.budget = params[:bid][:budget] @bid.deadline = params[:bid][:deadline] - @bid.password = params[:bid][:password] + @bid.password = params[:bid][:password] @bid.author_id = User.current.id @bid.commit = 0 if @bid.save @@ -825,31 +816,31 @@ class BidsController < ApplicationController @course = Course.find_by_id(params[:course_id]) @course_id = @course.id #respond_to do |format| - # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'} - # format.api { render_validation_errors(@bid) } - #end + # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'} + # format.api { render_validation_errors(@bid) } + #end render file: 'courses/new_homework', layout: 'base_courses' end end # modify by nwb\ # 编辑作业 - def edit - @bid = Bid.find(params[:bid_id]) - if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first)) - @course_id = params[:course_id] - respond_to do |format| - format.html { - @course = Course.find(params[:course_id]) - @user= User.find(User.current.id) - render :layout => 'base_courses' - } - end + def edit + @bid = Bid.find(params[:bid_id]) + if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first)) + @course_id = params[:course_id] + respond_to do |format| + format.html { + @course = Course.find(params[:course_id]) + @user= User.find(User.current.id) + render :layout => 'base_courses' + } + end else render_403 end end - + def update @bid = Bid.find(params[:id]) @course = @bid.courses.first#Project.find(params[:course_id]) @@ -858,7 +849,7 @@ class BidsController < ApplicationController @bid.is_evaluation = params[:bid][:is_evaluation] @bid.proportion = params[:bid][:proportion] @bid.evaluation_num = params[:bid][:evaluation_num] - @bid.open_anonymous_evaluation = params[:bid][:open_anonymous_evaluation] + params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 @bid.reward_type = 3 @bid.deadline = params[:bid][:deadline] @bid.budget = 0 @@ -881,38 +872,38 @@ class BidsController < ApplicationController find_bid render :layout => 'base_homework' end - + def add_homework if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - + if hadcommittedhomework(User.current.id, @bid.id) == true - @homework_flag = l(:label_bidding_homework_committed) + @homework_flag = l(:label_bidding_homework_committed) else - @homework = HomeworkAttach.new - @homework.safe_attributes = params[:homeworkattach] - @homework.bid_id = @bid.id - @homework.user_id = User.current.id - @homework.save_attachments(params[:attachments]) - - render_attachment_warning_if_needed(@homework) - - @homework_flag = if @homework.save - l(:label_bidding_homework_succeed) - else - l(:label_bidding_homework_failed) - end - - if @homework.attachments.empty? - @homework.delete - #flash[:error] = l(:no_attachmens_allowed) - @homework_flag = l(:no_attachmens_allowed) - # else - end - end + @homework = HomeworkAttach.new + @homework.safe_attributes = params[:homeworkattach] + @homework.bid_id = @bid.id + @homework.user_id = User.current.id + @homework.save_attachments(params[:attachments]) + + render_attachment_warning_if_needed(@homework) + + @homework_flag = if @homework.save + l(:label_bidding_homework_succeed) + else + l(:label_bidding_homework_failed) + end + + if @homework.attachments.empty? + @homework.delete + #flash[:error] = l(:no_attachmens_allowed) + @homework_flag = l(:no_attachmens_allowed) + # else + end + end end - + @homework_list = @bid.homeworks respond_to do |format| format.html{ @@ -931,7 +922,7 @@ class BidsController < ApplicationController @member = [] @course.memberships.each do |member| unless (member.roles && Role.where('id = ? ', 3)).empty? - @member.push member + @member.push member end end if @bid.homework_type = 1 @@ -958,7 +949,7 @@ class BidsController < ApplicationController respond_to do |format| format.html { redirect_to :back } format.js - #format.api { render_api_ok } + #format.api { render_api_ok } end end @@ -970,7 +961,7 @@ class BidsController < ApplicationController respond_to do |format| format.html { redirect_to :back } format.js - #format.api { render_api_ok } + #format.api { render_api_ok } end end @@ -999,7 +990,7 @@ class BidsController < ApplicationController def manage end - + # 启动匿评 def start_anonymous_comment @bid = Bid.find(params[:id]) @@ -1031,7 +1022,7 @@ class BidsController < ApplicationController end end - def stop_anonymous_comment + def stop_anonymous_comment @bid = Bid.find(params[:id]) @bid.update_column('comment_status', 2) @@ -1039,7 +1030,7 @@ class BidsController < ApplicationController respond_to do |format| format.js end - end + end def alert_anonymous_comment @bid = Bid.find params[:id] @@ -1060,7 +1051,7 @@ class BidsController < ApplicationController end private - + def get_assigned_homeworks(homeworks, n, index) homeworks += homeworks homeworks[index + 1 .. index + n] diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index f797c7a2f..bdbbb8e37 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -66,15 +66,28 @@ class BoardsController < ApplicationController 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" @topic_count = @board.topics.count - @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - @topics = @board.topics. - reorder("#{Message.table_name}.sticky DESC"). - includes(:last_reply). - limit(@topic_pages.per_page). - offset(@topic_pages.offset). - order(sort_clause). - preload(:author, {:last_reply => :author}). - all + if @project + @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] + @topics = @board.topics. + reorder("#{Message.table_name}.sticky DESC"). + includes(:last_reply). + limit(@topic_pages.per_page). + offset(@topic_pages.offset). + order(sort_clause). + preload(:author, {:last_reply => :author}). + all + elsif @course + board_topics = @board.topics. + reorder("#{Message.table_name}.sticky DESC"). + includes(:last_reply). + # limit(@topic_pages.per_page). + # offset(@topic_pages.offset). + order(sort_clause). + preload(:author, {:last_reply => :author}). + all + @topics = paginateHelper board_topics,10 + end + @message = Message.new(:board => @board) #modify by nwb if @project diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index f9ad609cc..ebdb18c08 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -33,28 +33,6 @@ class CoursesController < ApplicationController join = cs.join_course params,User.current @state = join[:state] course = join[:course] - #course = Course.find_by_id params[:object_id] - #if course - # if course_endTime_timeout? course - # @state = 2 - # else - # if User.current.member_of_course?(course) - # @state = 3 - # else - # if params[:course_password] == course.password - # members = [] - # members << Member.new(:role_ids => [10], :user_id => User.current.id) - # course.members << members - # StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id]) - # @state = 0 - # else - # @state = 1 - # end - # end - # end - #else - # @state = 4 - #end else @state = 5 #未登录 end @@ -71,25 +49,14 @@ class CoursesController < ApplicationController def unjoin if User.current.logged? - # - # @member = Member.where('course_id = ? and user_id = ?', params[:object_id], User.current.id) - # @member.first.destroy - # - # joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id]) - # joined.each do |join| - # join.delete - # end cs = CoursesService.new cs.exit_course params,User.current end - respond_to do |format| - # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}} format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} } end end - def join_private_courses respond_to do |format| @@ -119,36 +86,6 @@ class CoursesController < ApplicationController format.api { render_validation_errors(@course) } end end - #@course.safe_attributes = params[:course] - #@course.time = params[:time] - #@course.term = params[:term] - #@course.class_period = params[:class_period] - #if @course.save - # if params[:course][:is_public] == '0' - # course_status = CourseStatus.find_by_course_id(@course.id) - # course_status.destroy if course_status - # elsif params[:course][:is_public] == '1' - # course_status = CourseStatus.find_by_course_id(@course.id) - # course_status.destroy if course_status - # course_status = CourseStatus.create(:course_id => @course.id, :grade => 0) - # end - # - # respond_to do |format| - # format.html { - # flash[:notice] = l(:notice_successful_update) - # redirect_to settings_course_url(@course) - # } - # format.api { render_api_ok } - # end - #else - # respond_to do |format| - # format.html { - # settings - # render :action => 'settings' - # } - # format.api { render_validation_errors(@course) } - # end - #end end def new_join @@ -160,7 +97,6 @@ class CoursesController < ApplicationController def search courses_all = Course.all_course name = params[:name] - #(redirect_to courses_url, :notice => l(:label_sumbit_empty);return) if name.blank? if name.blank? @courses = [] @courses_all = [] @@ -242,22 +178,19 @@ class CoursesController < ApplicationController def searchmembers @subPage_title = l :label_student_list - @render_file = 'member_list' - @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' - @is_remote = true + @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' + # @is_remote = true @score_sort_by = "desc" q = "#{params[:name].strip}" - #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:incourse] - @results = searchmember_by_name(student_homework_score(0,0,0,"desc"), q) - + results = searchmember_by_name(student_homework_score(0,0,0,"desc"), q) elsif params[:ingroup] @group = CourseGroup.find(params[:search_group_id]) - @results = searchmember_by_name(student_homework_score(@group.id,0,0,"desc"), q) + results = searchmember_by_name(student_homework_score(@group.id,0,0,"desc"), q) end @is_remote = true - @result_count = @results.count - @results = paginateHelper @results, 10 + @result_count = results.count + @results = paginateHelper results, 10 @search_name = q end @@ -269,7 +202,7 @@ class CoursesController < ApplicationController group.course_id = @course.id group.save end - @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' + @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @is_remote = true @course_groups = @course.course_groups @@ -303,17 +236,26 @@ class CoursesController < ApplicationController valid_attr = params[:valid] valid_value = params[:value] - - faker = CourseGroup.new + group_id = params[:group_id] + # faker = CourseGroup.new if valid_attr.eql?('name') - faker.name = valid_value - faker.course_id = params[:course_id] - faker.valid? - req[:valid] = faker.errors[:name].blank? - req[:message] = faker.errors[:name] + course = Course.find params[:course_id] + group_names = course.course_groups.map{|group| group.name unless group.id.to_s == group_id}.select{|group| !group.nil?} + if group_names.include?(valid_value) + req[:valid] = false + req[:message] = l(:modal_valid_unpassing) + else + req[:valid] = true + req[:message] = l(:modal_valid_passing) + end + # faker.name = valid_value + # faker.course_id = params[:course_id] + # faker.valid? + # req[:valid] = faker.errors[:name].blank? + # req[:message] = faker.errors[:name] end - req[:message] = l(:modal_valid_passing) if req[:message].blank? + # req[:message] = l(:modal_valid_passing) if req[:message].blank? render :json => req end def join_group @@ -341,35 +283,28 @@ class CoursesController < ApplicationController end def searchgroupmembers @subPage_title = l :label_student_list - @render_file = 'member_list' + @render_file = 'new_member_list' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true @score_sort_by = "desc" if params[:group_id] && params[:group_id] != "0" @group = CourseGroup.find(params[:group_id]) - @results = student_homework_score(@group.id,0, 0,"desc") @results = paginateHelper @results, 10 - - else page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) @results = student_homework_score(0,page_from, 10,"desc") @results = paginateHelper_for_members @results, 10 end - - - end - def member ## 有角色参数的才是课程,没有的就是项目 if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) - @render_file = 'member_list' + @render_file = 'new_member_list' @score_sort_by = "desc" - @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' + @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @role = params[:role].nil? ? '2':params[:role] @is_remote = true @course_groups = @course.course_groups if @course.course_groups @@ -383,12 +318,9 @@ class CoursesController < ApplicationController @subPage_title = l :label_student_list page = params[:page].nil? ? 0 : (params['page'].to_i - 1) @all_members = student_homework_score(0,page, 10,"desc") - + # @all_members = @course.members @members = paginateHelper_for_members @all_members, 10 - - end - respond_to do |format| if params[:page] format.js @@ -396,12 +328,9 @@ class CoursesController < ApplicationController format.html {render :layout => 'base_courses'} end end - - # render :layout => 'base_courses' else render_403 end - end def export_course_member_excel @@ -415,20 +344,9 @@ class CoursesController < ApplicationController end def member_score_sort - - # @teachers= searchTeacherAndAssistant(@course) @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' - # @role = params[:role] - # @course_groups = @course.course_groups if @course.course_groups - # @show_serch = params[:role] == '2' @subPage_title = l :label_student_list - @render_file = 'member_list' - # @results = params[:result] if params[:result] - # unless @result.nil? - # @results = @result.reverse - # - # end - # @results = paginateHelper @results@score_sort_by = "desc" + @render_file = 'new_member_list' @is_remote = true @score_sort_by = params[:sort_by] if params[:sort_by] @search_name = params[:search_name] if params[:search_name] @@ -436,7 +354,6 @@ class CoursesController < ApplicationController if !@search_name.nil? if group_id == '0' page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name) @result_count = @results.count @results = paginateHelper @results, 10 @@ -450,7 +367,6 @@ class CoursesController < ApplicationController if group_id == '0' page = params[:page].nil? ? 0 : (params['page'].to_i - 1) @results = student_homework_score(0,page, 10,@score_sort_by) - @results = paginateHelper_for_members @results, 10 else @group = CourseGroup.find(group_id) @@ -458,32 +374,25 @@ class CoursesController < ApplicationController @results = paginateHelper @results, 10 end end - end # 显示每个学生的作业评分详情 def show_member_score - @member_score = Member.find(params[:member_id]) if params[:member_id] respond_to do |format| format.html {render :layout => 'course_base'} format.js - end - end def handle_course courses, activities course_activity_count_array=activities.values() - course_array=[] i=0; courses.each do |course| course_array[i]=course i=i+1 end - courses=desc_sort_course_by_avtivity(course_activity_count_array, course_array) - return courses end @@ -522,57 +431,6 @@ class CoursesController < ApplicationController format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) } end end - #if User.current.user_extensions.identity - # @course = Course.new - # @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s - # @course.safe_attributes = params[:course] - # @course.tea_id = User.current.id - # # added by bai - # @course.term = params[:term] - # @course.time = params[:time] - # #@course.school_id = params[:occupation] - # @course.school_id = User.current.user_extensions.school_id - # @course.setup_time = params[:setup_time] - # @course.endup_time = params[:endup_time] - # @course.class_period = params[:class_period] - #end - # - #@issue_custom_fields = IssueCustomField.sorted.all - #@trackers = Tracker.sorted.all - # - #if @course.save - # #unless User.current.admin? - # r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first - # m = Member.new(:user => User.current, :roles => [r]) - # m.project_id = -1 - # course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id) - # #user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id) - # if params[:course][:is_public] == '1' - # course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag) - # end - # @course.members << m - # @course.course_infos << course - # #end - # respond_to do |format| - # format.html { - # flash[:notice] = l(:notice_successful_create) - # if params[:continue] - # redirect_to new_course_url(attrs, :course => '0') - # elsif params[:course_continue] - # redirect_to new_course_url(:course => '1') - # else - # redirect_to settings_course_url(@course, :course_type => 1) - # end - # } - # format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) } - # end - # else - # #@course.destroy - # respond_to do |format| - # format.html { render :action => 'new', :layout => 'base' } #Added by young - # format.api { render_validation_errors(@course) } - # end - # end end def course @@ -590,54 +448,28 @@ class CoursesController < ApplicationController @course_count = @courses_all.count @course_pages = Paginator.new @course_count, per_page_option, params['page'] - - #gcm activity count - @course_activity_count=Hash.new - #count initialize @courses_all.each do |course| @course_activity_count[course.id]=0 end - - #@course_activity_count=get_course_activity @courses_all,@course_activity_count - #gcm end - - case params[:course_sort_type] when '0' @courses = @courses_all.order("created_on desc") @s_type = 0 @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - - #gcm @course_activity_count=get_course_activity @courses,@course_activity_count - #gcmend - when '1' @courses = @courses_all.order("course_ac_para desc") @s_type = 1 @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - - #gcm @course_activity_count=get_course_activity @courses,@course_activity_count - #gcmend - when '2' @courses = @courses_all.order("watchers_count desc") @s_type = 2 @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - - #gcm @course_activity_count=get_course_activity @courses,@course_activity_count - #gcmend - - #gcm when '3' - - #gcm @course_activity_count=get_course_activity @courses_all,@course_activity_count - #gcmend - @courses=handle_course @courses_all,@course_activity_count @s_type = 3 @courses = @courses[@course_pages.offset, @course_pages.per_page] @@ -645,11 +477,7 @@ class CoursesController < ApplicationController @s_type = 0 @courses = @courses_all.order("created_on desc") @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - - #gcm @course_activity_count=get_course_activity @courses,@course_activity_count - #gcmend - end respond_to do |format| @@ -657,9 +485,6 @@ class CoursesController < ApplicationController render :layout => 'base' } format.api { - # @offset, @limit = api_offset_and_limit - # @course_count = Course.visible.count - # @courses = Course.visible.offset(@offset).limit(@limit).order('lft').all } format.atom { courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all @@ -668,20 +493,16 @@ class CoursesController < ApplicationController end end - def new @course_type = params[:course_type] ||= params[:course] @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all - @course = Course.new @course.safe_attributes = params[:course] month = Time.now.month - - render :layout => 'base' + render :layout => 'new_base' end - def desc_sort_course_by_avtivity(activity_count, courses) return courses if activity_count.size<2 (activity_count.size-2).downto(0) do |i| @@ -758,22 +579,11 @@ class CoursesController < ApplicationController def homework if @course.is_public != 0 || User.current.member_of_course?(@course) || User.current.admin? - @offset, @limit = api_offset_and_limit({:limit => 10}) - @bids = @course.homeworks.order('deadline ASC') - @bids = @bids.like(params[:name]) if params[:name].present? - @bid_count = @bids.count - @bid_pages = Paginator.new @bid_count, @limit, params['page'] - - @offset ||= @bid_pages.reverse_offset - unless @offset == 0 - @bids = @bids.offset(@offset).limit(@limit).all.reverse - else - limit = @bid_count % @limit - if limit == 0 - limit = 10 - end - @bids = @bids.offset(@offset).limit(limit).all.reverse - end + bids = @course.homeworks.order('created_on DESC') + bids = bids.like(params[:name]) if params[:name].present? + @bids = paginateHelper bids,10 + @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) + @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) render :layout => 'base_courses' else render_403 @@ -785,6 +595,7 @@ class CoursesController < ApplicationController @homework = Bid.new @homework.safe_attributes = params[:bid] @homework.open_anonymous_evaluation = 1 + @homework.deadline = (Time.now + 3600 * 24).strftime('%Y-%m-%d') if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] )) render :layout => 'base_courses' else @@ -848,26 +659,19 @@ class CoursesController < ApplicationController end def show - - # try to redirect to the requested menu item if params[:jump] && redirect_to_course_menu_item(@course, params[:jump]) return end - @users_by_role = @course.users_by_role if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) end - - @key = User.current.rss_key #新增内容 @days = Setting.activity_days_default.to_i - if params[:from] begin; @date_to = params[:from].to_date + 1; rescue; end end - has = { "show_course_files" => true, "show_course_news" => true, @@ -877,9 +681,7 @@ class CoursesController < ApplicationController "show_homeworks" => true } @date_to ||= Date.today + 1 - # @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date - #@date_from = @date_to - @days-1.years @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) @author ||= @course.teacher # 决定显示所用用户或单个用户活动 @@ -889,13 +691,11 @@ class CoursesController < ApplicationController @activity.scope_select {|t| has["show_#{t}"]} # modify by nwb # 添加私密性判断 - if User.current.member_of_course?(@course)|| User.current.admin? events = @activity.events(@days, @course.created_at) else events = @activity.events(@days, @course.created_at, :is_public => 1) end - # 无新动态时,显示老动态 if events.count == 0 if User.current.member_of_course?(@course)|| User.current.admin? @@ -904,20 +704,10 @@ class CoursesController < ApplicationController events = @activity.events(:is_public => 1) end end - - @offset, @limit = api_offset_and_limit({:limit => 10}) - @events_count = events.count - @events_pages = Paginator.new @events_count, @limit, params['page'] - @offset ||= @events_pages.offset - events = events.slice(@offset,@limit) - + events = paginateHelper events,10 @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} # documents @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' - # 这写变量发现没有用而且拖慢速度 - #@teachers= searchTeacherAndAssistant(@course) - #@canShowRealName = isCourseTeacher(User.current.id,@course) - if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) end @@ -947,10 +737,6 @@ class CoursesController < ApplicationController offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i]) page = 1 + offset / @limit end - - #@feedback_count = @jours.count - #@feedback_pages = Paginator.new @feedback_count, @limit, page - #@offset ||= @feedback_pages.offset @jour = paginateHelper @jours,10 @state = false respond_to do |format| @@ -990,7 +776,6 @@ class CoursesController < ApplicationController end private - def allow_join course if course_endTime_timeout? course respond_to do |format| @@ -1021,38 +806,38 @@ class CoursesController < ApplicationController if groupid == 0 if nums == 0 sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id -AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) GROUP BY members.user_id -UNION all -SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} AND -students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND -members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) -) -GROUP BY members.user_id ORDER BY score #{score_sort_by}" + WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id + AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) GROUP BY members.user_id + UNION all + SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} AND + students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND + members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) + ) + GROUP BY members.user_id ORDER BY score #{score_sort_by}" else sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id -AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) GROUP BY members.user_id -UNION all -SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} AND -students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND -members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) -) -GROUP BY members.user_id ORDER BY score #{score_sort_by} limit #{start_from}, #{nums}" + WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id + AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) GROUP BY members.user_id + UNION all + SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} AND + students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND + members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) + ) + GROUP BY members.user_id ORDER BY score #{score_sort_by} limit #{start_from}, #{nums}" end else sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id - and members.course_group_id = #{groupid} AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) - GROUP BY members.user_id -UNION all -SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} -and members.course_group_id = #{groupid} AND -students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND -members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) -) -GROUP BY members.user_id ORDER BY score #{score_sort_by}" + WHERE members.course_id = #{@course.id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{@course.id}) AND members.user_id = homework_attaches.user_id + and members.course_group_id = #{groupid} AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id}) + GROUP BY members.user_id + UNION all + SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{@course.id} + and members.course_group_id = #{groupid} AND + students_for_courses.course_id = #{@course.id} and members.user_id = students_for_courses.student_id AND + members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{@course.id} ) + ) + GROUP BY members.user_id ORDER BY score #{score_sort_by}" end sql = ActiveRecord::Base.connection() homework_scores = Member.find_by_sql(sql_select) @@ -1068,7 +853,7 @@ GROUP BY members.user_id ORDER BY score #{score_sort_by}" #当加入,退出分班时查询分班的学生 def search_group_members group @subPage_title = l :label_student_list - @render_file = 'member_list' + @render_file = 'new_member_list' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true @score_sort_by = "desc" diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index d2a253c2a..b50b2720f 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -44,18 +44,35 @@ class MessagesController < ApplicationController end @reply_count = @topic.children.count - @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page - @replies = @topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.created_on DESC"). - limit(@reply_pages.per_page). - offset(@reply_pages.offset). - all + # @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page + # @replies = @topic.children. + # includes(:author, :attachments, {:board => :project}). + # reorder("#{Message.table_name}.created_on DESC"). + # limit(@reply_pages.per_page). + # offset(@reply_pages.offset). + # all @reply = Message.new(:subject => "RE: #{@message.subject}") if @course + messages_replies = @topic.children. + includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC"). + #limit(@reply_pages.per_page). + #offset(@reply_pages.offset). + all + @replies = paginateHelper messages_replies,10 + @reply = Message.new(:subject => "RE: #{@message.subject}") render :action => "show", :layout => "base_courses"#by young else + @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page + @replies = @topic.children. + includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC"). + limit(@reply_pages.per_page). + offset(@reply_pages.offset). + all + + @reply = Message.new(:subject => "RE: #{@message.subject}") render :action => "show", :layout => "base_projects"#by young end end @@ -76,6 +93,13 @@ class MessagesController < ApplicationController layout_file = @project ? 'base_projects' : 'base_courses' render :action => 'new', :layout => layout_file end + else + respond_to do |format| + format.html { + layout_file = @project ? 'base_projects' : 'base_courses' + render :layout => layout_file + } + end end end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index b44e8a348..617e56575 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -70,13 +70,13 @@ class NewsController < ApplicationController scope = @course ? @course.news.course_visible : News.course_visible @news_count = scope.count - @news_pages = Paginator.new @news_count, @limit, params['page'] - @offset ||= @news_pages.offset - @newss = scope.all(:include => [:author, :course], - :order => "#{News.table_name}.created_on DESC", - :offset => @offset, - :limit => @limit) - + #@news_pages = Paginator.new @news_count, @limit, params['page'] + #@offset ||= scope_page.offset + scope_order = scope.all(:include => [:author, :course], + :order => "#{News.table_name}.created_on DESC") + # :offset => @offset, + # :limit => @limit) + @newss = paginateHelper scope_order,10 respond_to do |format| format.html { @news = News.new diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 5bd5fb0e3..e26901320 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -73,7 +73,7 @@ class TagsController < ApplicationController @issues_results, @bids_results, @forums_results, - @attachments_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@obj_flag,@selected_tags) @@ -109,7 +109,7 @@ class TagsController < ApplicationController @issues_results, @bids_results, @forums_results, - @attachments_results, + @attachments_results, @contests_results, @courses_results, @open_source_projects_results= refresh_results(@obj_id,@show_flag) @@ -248,6 +248,8 @@ class TagsController < ApplicationController @obj = OpenSourceProject.find_by_id(@obj_id) when '9' @obj = Course.find_by_id(@obj_id) + when '10' + @obj = Attachment.find_by_id(@obj_id) else @obj = nil end @@ -315,6 +317,14 @@ class TagsController < ApplicationController when '8' @obj = OpenSourceProject.find_by_id(obj_id) @obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags)) + when '10' + @obj = Attachment.find_by_id(obj_id) + + # modifed by Long Jun + # this is used to find the attachments that came from the same project and tagged with the same tag. + #@result = get_attachments_by_project_tag(selected_tags, @obj) + @result = get_attachments_by_tag(selected_tags) + @obj_pages, @attachments_results, @results_count = for_pagination(@result) when '9' then @obj = Course.find_by_id(obj_id) @obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags)) @@ -380,7 +390,9 @@ class TagsController < ApplicationController when '8' return 'OpenSourceProject' when '9' - return 'Course' + return 'Course' + when '10' + return 'Attachment' else render_error :message => e.message return diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a5cfc2b16..c8168455c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -124,6 +124,20 @@ module ApplicationHelper end end + #重载上面方法,增加样式显示 + def link_to_user_header user,canShowRealName=false,options={} + if user.is_a?(User) + if canShowRealName + name = h(user.realname(options[:format])) + else + name = h(user.name(options[:format])) + end + link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => options[:class] + else + h(user.to_s) + end + end + # Displays a link to +issue+ with its subject. # Examples: # @@ -285,7 +299,7 @@ module ApplicationHelper onclick = "$('##{id}').slideToggle(); " onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ") onclick << "return false;" - link_to(name, "#", :onclick => onclick) + link_to(name, "#", :onclick => onclick,:class => options[:class]) end def image_to_function(name, function, html_options = {}) @@ -1651,6 +1665,17 @@ module ApplicationHelper @public_forum = Forum.find(1) end + #获取用户未过期的课程 + def get_user_course user + courses_doing = [] + user.courses.each do |course| + if !course_endTime_timeout?(course) + courses_doing.push course + end + end + courses_doing + end + private def wiki_helper @@ -1876,7 +1901,7 @@ module ApplicationHelper def render_dynamic_nav home_link = link_to l(:field_homepage), {:controller => 'welcome', :action => 'index'} - home_link = "
  • " << home_link << "
  • " + home_link = "
  • " << home_link << "
  • " # bootstrap_render_dynamic_nav content_tag :ul, (home_link.html_safe+bootstrap_render_dynamic_nav) end @@ -1917,7 +1942,7 @@ module ApplicationHelper content_li = '' nav_list.collect do |nav_item| - content_li << content_tag(:li, nav_item) + content_li << content_tag(:li, nav_item, :class => 'topnav_a fl') end content_li.html_safe end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 50dd79a08..2e07421f8 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -34,6 +34,16 @@ module AttachmentsHelper :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} end end + + def link_to_attachments_course(container, options = {}) + options.assert_valid_keys(:author, :thumbnails) + + if container.attachments.any? + options = {:deletable => container.attachments_deletable?, :author => true}.merge(options) + render :partial => 'attachments/course_file_links', + :locals => {:attachments => container.attachments, :options => options, :thumbnails => (options[:thumbnails] && Setting.thumbnails_enabled?)} + end + end def attach_delete(project) if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index bd017757a..384fcaa9b 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -25,6 +25,40 @@ module CoursesHelper # searchTeacherAndAssistant(project).count end + #课程模块需要展示的模块 + def course_model + @nav_dispaly_course_all_label = 1 + @nav_dispaly_forum_label = 1 + @nav_dispaly_course_label = nil + @nav_dispaly_store_all_label = 1 + end + + #生成课程老师成员链接 + def course_teacher_link teacher_num + if User.current.member_of_course?(@course) + link_to "#{teacher_num}", course_member_path(@course, :role => 1), :class => 'info_foot_num c_blue' + else + content_tag 'span',teacher_num, :class => 'info_foot_num c_blue' + end + end + + #生成课程学生列表连接 + def course_student_link student_num + if (User.current.logged? && @course.open_student == 1) || (User.current.member_of_course?(@course)) + link_to "#{student_num}", course_member_path(@course, :role => 2), :class => 'info_foot_num c_blue' + else + content_tag 'span',student_num, :class => 'info_foot_num c_blue' + end + end + + def course_poll_count + Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}").count + end + + def course_feedback_count + @course.journals_for_messages.where('m_parent_id IS NULL').count + end + # 返回学生数量,即roles表中定义的Reporter #def studentCount project # searchStudent(project).count @@ -624,4 +658,82 @@ module CoursesHelper return activities end + #获取某个课程的动态数 + def course_activity_count course + course_activity_count=Hash.new + course_activity_count[course.id]=0 + count = get_course_activity([course],course_activity_count)[course.id] + count.nil? ? 0 : count + end + + #重启、关闭课程按钮 + def set_course_time course + id = "finish_course_#{course.id}" + linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) + desc = course_endTime_timeout?(course) ? l(:label_course_reload) : l(:label_course_closed) + link_to "#{desc}".html_safe, linkPath, :remote => true, :method => :post, :id => id, :confirm => l(:label_course_closed_tips, :desc => desc), :class => "pr_join_a" + end + + #加入课程、退出课程按钮 + def join_in_course_header(course, user, options=[]) + if user.logged? + joined = user.member_of_course? course + text = joined ? ("".html_safe + l(:label_course_exit_student)) : ("".html_safe + l(:label_course_join_student)) + url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id) + method = joined ? 'delete' : 'post' + if joined + link = "#{l(:label_course_join_student)}" + link_to(text, url, :remote => true, :method => method, :class => "pr_join_a", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out)) + else + link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a") + "#{l(:label_course_exit_student)}".html_safe + end + else + link = "#{l(:label_course_join_student)}" + + "#{l(:label_course_exit_student)}" + end + link.html_safe + end + + def bid_anonymous_comment bid + if bid.open_anonymous_evaluation == 1 + if bid.homeworks.count >= 2 + case bid.comment_status + when 0 + link = link_to '启动匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit' + when 1 + link = link_to '关闭匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit' + when 2 + link = "匿评结束".html_safe + end + else + link = "启动匿评".html_safe + end + else + link = "启动匿评".html_safe + end + link + end + + def student_new_homework bid + user_homework = cur_user_homework_for_bid bid + if user_homework && user_homework.empty? + link_to l(:label_commit_homework), new_exercise_book_path(bid),:class => 'fr mr10 work_edit' + else + "作业已交".html_safe + end + end + + def student_anonymous_comment bid + if bid.open_anonymous_evaluation == 1 + case bid.comment_status + when 0 + "未开启匿评".html_safe + when 1 + "正在匿评中".html_safe + when 2 + "匿评已结束".html_safe + end + else + "未启用匿评".html_safe + end + end end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 17b68c3f6..284ee8c43 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -20,6 +20,8 @@ module TagsHelper @obj= Contest.find_by_id(obj_id) when '9' @obj= Course.find_by_id(obj_id) + when '10' + @obj = Attachment.find_by_id(obj_id) else raise Exception, '[TagsHelper] ===> tag type unknow.' end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 294d895a5..8974a52d3 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -45,6 +45,26 @@ module WatchersHelper link_to text, url, :remote => true, :method => method, :class => css end + + def watcher_link_with_id(objects, user, options=[]) + return '' unless user && user.logged? + objects = Array.wrap(objects) + + watched = objects.any? {|object| object.watched_by?(user)} + @watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or objects.first.instance_of?(Contest) or (objects.first.instance_of?(Bid))) + css = options[:class] + + text = @watch_flag ? + (watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch)) + + url = watch_path( + :object_type => objects.first.class.to_s.underscore, + :object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort) + ) + method = watched ? 'delete' : 'post' + + link_to text, url, :remote => true, :method => method, :class => css,:id=>options[:id] + end ############## added by linchun def new_watcher_link(objects, user, options=[]) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index c689d699d..7c816ec19 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -239,6 +239,8 @@ class CoursesService course.time = params[:time] course.term = params[:term] course.class_period = params[:class_period] + params[:course][:is_public] ? course.is_public = 1 : course.is_public = 0 + params[:course][:open_student] ? course.open_student = 1 : course.open_student = 0 if course.save if params[:course][:is_public] == '0' course_status = CourseStatus.find_by_course_id(course.id) diff --git a/app/views/attachments/_course_file_links.html.erb b/app/views/attachments/_course_file_links.html.erb new file mode 100644 index 000000000..d32025787 --- /dev/null +++ b/app/views/attachments/_course_file_links.html.erb @@ -0,0 +1,72 @@ +
    + <% is_float ||= false %> + <% for attachment in attachments %> +

    + <%if is_float%> +

    + <% end%> + + <% if options[:length] %> + <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true,:length => options[:length] -%> + <% else %> + <%= link_to_short_attachment attachment, :class => ' link_file_board', :download => true -%> + <% end %> + + <%if is_float%> +
    + <% end%> + + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', + :action => 'show', + :id => attachment, + :filename => attachment.filename%> + <% end %> + + <%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %> + + ( + <%= number_to_human_size attachment.filesize %>) + + <% if options[:deletable] %> + <% if attachment.container_type == 'HomeworkAttach' %> + <%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id}, + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete delete-homework-icon', + :remote => true, + :title => l(:button_delete) %> + <% else %> + <%= link_to image_tag('delete.png'), attachment_path(attachment), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + #:remote => true, + #:id => "attachments_" + attachment.id.to_s, + :title => l(:button_delete) %> + <% end %> + <% end %> + <% if options[:wrap] %> +
    +   + <% end %> + <% if options[:author] %> + + <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author) %>, + <%= format_time(attachment.created_on) %> + + <% end %> +

    + <% end %> + <% if defined?(thumbnails) && thumbnails %> + <% images = attachments.select(&:thumbnailable?) %> + <% if images.any? %> +
    + <% images.each do |attachment| %> +
    <%= thumbnail_tag(attachment) %>
    + <% end %> +
    + <% end %> + <% end %> +
    diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb index 301c49506..39c760690 100644 --- a/app/views/attachments/_form_course.html.erb +++ b/app/views/attachments/_form_course.html.erb @@ -38,7 +38,7 @@ <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> -<%= button_tag l(:button_browse), :type=>"button", :onclick=>"_file.click()" %> +<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()",:class =>"sub_btn",:style => ie8? ? 'display:none' : '' %> <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => 'file_selector', @@ -56,7 +56,7 @@ :file_count => l(:label_file_count), :delete_all_files => l(:text_are_you_sure_all) } %> -<%= l(:label_no_file_uploaded)%> +<%= l(:label_no_file_uploaded)%> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) diff --git a/app/views/attachments/_new_form.html.erb b/app/views/attachments/_new_form.html.erb new file mode 100644 index 000000000..696d223fd --- /dev/null +++ b/app/views/attachments/_new_form.html.erb @@ -0,0 +1,59 @@ +
    + + <% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + + <% end %> + <% container.saved_attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + + <% end %> +<% end %> + + <% project = project %> + + <%= button_tag "文件浏览", :type=>"button", :onclick=>"_file.click()",:onmouseover => 'this.focus()',:class => 'sub_btn' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js',:project =>project), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :delete_all_files => l(:text_are_you_sure_all) + } %> + + <%= l(:label_no_file_uploaded)%> + + (<%= l(:label_max_size) %>: + <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> + + + +
    \ No newline at end of file diff --git a/app/views/avatar/_new_avatar_form.html.erb b/app/views/avatar/_new_avatar_form.html.erb new file mode 100644 index 000000000..8ca08c766 --- /dev/null +++ b/app/views/avatar/_new_avatar_form.html.erb @@ -0,0 +1,27 @@ + + <%= image_tag(url_to_avatar(source), id: "avatar_image", :width =>"60", :height =>"60",:alt=>"上传图片")%> + +<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "upbtn fl" %> +上传图片 +<%= file_field_tag 'avatar[image]', + :id => nil, + :class => 'upload_file ', + :size => "1", + :multiple => false, + :onchange => 'addInputAvatar(this);', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :file_type => Redmine::Configuration['pic_types'].to_s, + :type_support_message => l(:error_pic_type), + :upload_path => upload_avatar_path(:format => 'js'), + :description_placeholder => nil ,# l(:label_optional_description) + :source_type => source.class.to_s, + :source_id => source.id.to_s + } %> + +<% content_for :header_tags do %> + <%= javascript_include_tag 'avatars' %> +<% end %> +
    \ No newline at end of file diff --git a/app/views/bids/_alert_anonyoms.html.erb b/app/views/bids/_alert_anonyoms.html.erb index f26487126..6467b3f27 100644 --- a/app/views/bids/_alert_anonyoms.html.erb +++ b/app/views/bids/_alert_anonyoms.html.erb @@ -3,18 +3,8 @@ 开启匿评功能 -<%= javascript_include_tag 'attachments' %> - -
    - <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles&Role.where(id: [3, 4, 7, 9] )).size >0))%> - <%= link_to(l(:label_course_homework_new), {:controller => 'courses', :action => 'new_homework'}, :class => 'icon icon-add') %> - <% else %> - - <%= l(:label_coursejoin_tip) %> - - <% end %> +
    +

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

    -
    - <%= render :partial => 'bids/bid_homework_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %> +
    +

    + <%= l(:label_totle)%><%= @obj_count%><%= l(:label_homework_count)%> +

    + <%= link_to( l(:label_course_homework_new), new_homework_course_path(@course), :class => 'problem_new_btn fl c_dorange') if @is_teacher %> +
    - -
    -
    -
    -

    课程: <%= @course.name%>

    -

    上传作业

    - +<% @bids.each do |bid|%> +
    + <%= link_to(image_tag(url_to_avatar(bid.author), :width => "42", :height => "42"), user_path(bid.author), :class => "problem_pic fl") %> +
    + <%= link_to(bid.author.lastname+bid.author.firstname, user_path(bid.author),:class => 'problem_name fl') %> + <%= l(:label_user_create_project_homework) %>: + <%= link_to(bid.name, course_for_bid_path(bid), :class => 'problem_tit fl fb c_dblue') %> +
    +

    <%= l(:lebel_homework_commit)%> ( <%= link_to bid.homeworks.count, course_for_bid_path(bid.id), :class => 'c_red'%> )

    + <% if @is_teacher%> + <%= bid_anonymous_comment(bid)%> + <%= link_to(l(:button_edit),edit_bid_path(:course_id =>@course.id, :bid_id => bid.id), :class => "fr mr10 work_edit") %> + <% elsif @is_student%> + <%= student_anonymous_comment bid %> + <%= student_new_homework bid %> + <% end %> +
    + +
    +
    + <%= textilizable bid, :description %> +
    -
    - + + <%= l(:label_end_time)%>:<%= bid.deadline%> + <% if betweentime(bid.deadline) < 0 %> + + <%= l(:label_commit_limit)%> + + <% else %> + +
    +
    + <% end %> +
    +
    -
    - +<% end%> -<% html_title(l(:label_homework)) -%> \ No newline at end of file +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    +
    \ No newline at end of file diff --git a/app/views/courses/join_group.js.erb b/app/views/courses/join_group.js.erb index 7bdefdb9f..e0db2b440 100644 --- a/app/views/courses/join_group.js.erb +++ b/app/views/courses/join_group.js.erb @@ -1,2 +1,2 @@ -$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>"); +$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>"); $("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>"); \ No newline at end of file diff --git a/app/views/courses/join_private_courses.js.erb b/app/views/courses/join_private_courses.js.erb index 254311ce7..23dc551f7 100644 --- a/app/views/courses/join_private_courses.js.erb +++ b/app/views/courses/join_private_courses.js.erb @@ -3,7 +3,7 @@ showModal('ajax-modal', '510px'); $('#ajax-modal').css('height','330px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + - ""); + ""); $('#ajax-modal').parent().removeClass("alert_praise"); $('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().addClass("alert_box"); diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index e2c1fb418..ce336373b 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -1,81 +1,9 @@ - - -<%= stylesheet_link_tag 'course_group', :media => 'all' %> - -
    - -
    - <% if @subPage_title == l(:label_student_list) %> -
    - <%= render :partial => 'groups_name', :locals => {:course_groups => @course_groups} %> -
    - <% end %> - -
    - -
    - <%= error_messages_for 'member' %> - <%= render :partial => @render_file, :locals => {:members => @members} %> -
    +
    +

    <%= @subPage_title%>

    +<% if @subPage_title == l(:label_student_list)%> + <%= render :partial => 'course_student', :locals => {:members => @members} %> +<% else%> + <%= render :partial => 'course_teacher', :locals => {:members => @members} %> +<% end%> diff --git a/app/views/courses/member_score_sort.js.erb b/app/views/courses/member_score_sort.js.erb index c6ff97164..926836356 100644 --- a/app/views/courses/member_score_sort.js.erb +++ b/app/views/courses/member_score_sort.js.erb @@ -1,4 +1,4 @@ /** * Created by Administrator on 2014/12/3. */ -$("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>"); \ No newline at end of file +$("#member_content").html("<%= escape_javascript( render :partial => "new_member_list", :locals => {:members => @results})%>"); \ No newline at end of file diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index b9422ba64..3d1a3f6a4 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -1,16 +1,56 @@ -<% @nav_dispaly_course_all_label = 1 - @nav_dispaly_forum_label = 1 - @nav_dispaly_course_label = nil - @nav_dispaly_store_all_label = 1 %> -

    <%=l(:label_course_new)%>

    -<%= labelled_form_for @course do |f| %> -
    - <%= render :partial => 'course_form', :locals => { :f => f } %> - - <%= submit_tag l(:button_create), :class => "enterprise"%> - - - <%= javascript_tag "$('#course_name').focus();" %> -
    -<% end %> -<% html_title(l(:label_course_new)) -%> \ No newline at end of file +
    +

    <%= l(:permission_new_course)%>

    +
    +
    +
      + <%= labelled_form_for @course do |f| %> +
    • + + + +
    • +
      +
    • + + + +
    • +
      +
    • + + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %> +
    • +
      +
    • + + +
      + 学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。 +
    • +
    • + + +
      +
    • +
    • + + + (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。) +
      +
    • +
    • + + + (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表) +
      +
    • +
    • + 提交 + 取消 +
      +
    • + <% end%> +
    +
    +
    \ No newline at end of file diff --git a/app/views/courses/new_homework.html.erb b/app/views/courses/new_homework.html.erb index 2e0b35c6d..b8a8e4a42 100644 --- a/app/views/courses/new_homework.html.erb +++ b/app/views/courses/new_homework.html.erb @@ -1,115 +1,3 @@ - - -

    <%=l(:label_course_new_homework)%>

    - <%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %> -
    - <%= render :partial => 'homework_form', :locals => { :f => f } %> - - <%= l(:button_create)%> - <%= javascript_tag "$('#bid_name').focus();" %> - <% end %> -
    \ No newline at end of file + <%= render :partial => 'bids/new_homework_form', :locals => { :bid => @homework,:bid_id => "new_bid" } %> +<% end %> \ No newline at end of file diff --git a/app/views/courses/searchmembers.js.erb b/app/views/courses/searchmembers.js.erb index efe47a9c0..1d3c0ad21 100644 --- a/app/views/courses/searchmembers.js.erb +++ b/app/views/courses/searchmembers.js.erb @@ -1,4 +1,4 @@ /** * Created by Administrator on 2014/12/2. */ -$("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>"); \ No newline at end of file +$("#member_content").html("<%= escape_javascript( render :partial => 'new_member_list', :locals => {:members => @results})%>"); \ No newline at end of file diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index c2030ffec..43261f4e2 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -1,3 +1,60 @@ -

    <%=l(:label_settings)%>

    -<%= render_tabs course_settings_tabs %> -<% html_title(l(:label_settings)) -%> +
    +

    <%= l(:label_course_modify_settings)%>

    +
    +
    +
      + <%= labelled_form_for @course do |f| %> +
    • + <%= render :partial => "avatar/new_avatar_form", :locals => {source: @course} %> +
      +
    • +
    • + + + +
    • +
      +
    • + + + +
    • +
      +
    • + + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{} %> +
    • +
      +
    • + + +
      + 学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。 +
    • +
    • + + +
      +
    • +
    • + + id="course_is_public" name="course[is_public]" type="checkbox"> + (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。) +
      +
    • +
    • + + id="course_open_student" name="course[open_student]" type="checkbox" style="margin-left: 1px;"/> + (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表) +
      +
    • +
    • + 提交 + <%= link_to l(:button_cancel), course_path(@course), :class => "blue_btn grey_btn fl c_white" %> +
      +
    • + <% end %> +
    +
    +
    \ No newline at end of file diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 9c91908d2..c0b2f1eb6 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -1,143 +1,50 @@ +
    +

    <%= l(:label_activity)%>

    +
    <% if @events_by_day != nil && @events_by_day.size >0 %> -
    -

    -

    - - <% @events_by_day.keys.sort.reverse.each do |day| %> -
    - <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%> -
    - - - - - -
    - <%= image_tag(url_to_avatar(e.event_author), :class => "avatar") %> - - - - - - - - - - - <% if e.event_type == "issue" %> - - <% end %> - -
    - - <%= h(e.event_title) if @course.nil? || (e.course != nil && @course.id != e.course.id) %> - - - <% if @canShowRealName %> - <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> - (<%= link_to_user(e.event_author, @canShowRealName) if e.respond_to?(:event_author) %>) - <% else %> - <%= link_to_user(e.event_author) if e.respond_to?(:event_author) %> - <% end %> - <%= l(:label_new_activity) %> - - <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url%> -
    -

    - <%= e.event_description %> -

    -
    - - <%= l :label_activity_time %> - :  - <%= format_activity_day(day) %> - <%= format_time(e.event_datetime, false) %> - - - - <%= link_to l(:label_find_all_comments), issue_path(e.id) %> - - - <%= l(:label_comments_count, :count => e.journals.count) %> - -
    -
    -
    - <% end %> -
    - <% end -%> - <% if (@events_pages.page == @events_pages.last_page) %> -
    - - - - - -
    - <%= image_tag(url_to_avatar(@user), :class => "avatar") %> - - - - - - -
    - <% if @canShowRealName %> - (<%= link_to_user(@user, @canShowRealName) %>) - <% else %> - <%= link_to_user(@user)%> - <% end %> - - <%= l(:label_user_create_project) %> - <%= link_to @course.name %> - ! -
    - <%= l :label_create_time %>: - <%= format_time(@course.created_at) %> -
    -
    -
    - <% end %> -
    - <%else%> -
    - - - - - -
    - <%= image_tag(url_to_avatar(@user), :class => "avatar") %> - - - - - - -
    - <% if @canShowRealName %> - (<%= link_to_user(@user, @canShowRealName) %>) - <% else %> - <%= link_to_user(@user)%> - <% end %> - <%= l(:label_user_create_project) %> - <%= link_to @course.name %> - ! -
    - <%= l :label_create_time %>: - <%= format_time(@course.created_at) %> -
    -
    -
    -<% end %> - - - -<% html_title(l(:label_course_overview)) -%> + <% @events_by_day.keys.sort.reverse.each do |day| %> + <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%> +
    + + <%= image_tag(url_to_avatar(e.event_author), :width => "42", :height => "42") %> + +
    + <%= link_to_user_header(e.event_author,false,:class => 'problem_name c_orange fl') if e.respond_to?(:event_author) %> + <%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %> + <%= l(:label_new_activity) %>: + <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:class => "problem_tit c_dblue fl fb"%> +
    +

    <%= e.event_description %> +
    + <%= l :label_activity_time %> : <%= format_activity_day(day) %><%= format_time(e.event_datetime, false) %> +

    +
    +
    +
    + <% end%> + <% end%> +<% end%> +
    + + <%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %> + +
    + <%= link_to_user_header(@user,false,:class => 'problem_name c_orange fl') %> + <%= link_to_user_header("(#{@user})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName %> + <%= l(:label_user_create_project) %>: + <%= link_to @course.name,course_path(@course),:class => "problem_tit c_dblue fl fb"%> +
    +

    +
    + <%= l :label_create_time %>: : <%= format_time(@course.created_at) %> +

    +
    +
    +
    +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    +
    \ No newline at end of file diff --git a/app/views/courses/unjoin_group.js.erb b/app/views/courses/unjoin_group.js.erb index 7bdefdb9f..e0db2b440 100644 --- a/app/views/courses/unjoin_group.js.erb +++ b/app/views/courses/unjoin_group.js.erb @@ -1,2 +1,2 @@ -$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>"); +$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>"); $("#member_content").html("<%= escape_javascript( render :partial => @render_file, :locals => {:members => @results})%>"); \ No newline at end of file diff --git a/app/views/courses/updategroupname.js.erb b/app/views/courses/updategroupname.js.erb index 8eb4e865c..8dd142557 100644 --- a/app/views/courses/updategroupname.js.erb +++ b/app/views/courses/updategroupname.js.erb @@ -1,4 +1,4 @@ /** * Created by Administrator on 2014/12/3. */ -$("#st_groups").html("<%= escape_javascript( render :partial => 'groups_name', locals: {:course_groups => @course_groups})%>"); \ No newline at end of file +$("#st_groups").html("<%= escape_javascript( render :partial => 'new_groups_name', locals: {:course_groups => @course_groups})%>"); \ No newline at end of file diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index 6b9758fd2..59f1b66fd 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -22,7 +22,7 @@
    - + <%= file_field_tag 'attachments[dummy][file]', :id => '_file', :class => 'file_selector', @@ -41,10 +41,9 @@ :delete_all_files => l(:text_are_you_sure_all) } %> - \ No newline at end of file diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index 030b6cb24..ea499477a 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -2,15 +2,16 @@ <% sufixtypes = @course.contenttypes %> -<%= stylesheet_link_tag 'resource', :media => 'all' %> + - <%= form_tag({:controller => 'courses', :action => 'search'},:id => "course_search_form", :method => :get) do %> - <%= text_field_tag 'name', params[:name], :size => 20, :style => "float:left" %> - - <%= l(:label_search)%> - -
    - - <%#= submit_tag l(:label_search), :class => "ButtonColor m3p10", :name => nil, :style => "float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" %> - <% end %> -
    - - - - - -

    - <%= link_to l(:field_homepage), home_path %> - > - - <%=l(:label_courses_management_platform)%> + +

    + <%= l(:label_user_location) %> : + <%= link_to l(:field_homepage), home_path %> + > + + <%=l(:label_courses_management_platform)%> + + > + <%= link_to @course.name, nil %> +

    +
    + - - - - -<%= render :partial => 'layouts/base_footer' %> -
    + <%= render :partial => 'layouts/new_footer' %> +
    +
    +<%= render :partial => 'layouts/new_feedback' %> -
    - <%= call_hook :view_layouts_base_body_bottom %> - \ No newline at end of file diff --git a/app/views/layouts/base_welcome.html.erb b/app/views/layouts/base_welcome.html.erb new file mode 100644 index 000000000..d04f492ef --- /dev/null +++ b/app/views/layouts/base_welcome.html.erb @@ -0,0 +1,49 @@ + + + + + <%=h html_title %> + + + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_include_tag "jquery.leanModal.min" %> + <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + + +
    +
    +
    + <%=render :partial => 'layouts/base_header'%> +
    +
    + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    + <%=render :partial => 'layouts/base_footer'%> +
    + +
    +
    + + + + +
    +
    +<%= call_hook :view_layouts_base_body_bottom %> + + diff --git a/app/views/layouts/new_base.html.erb b/app/views/layouts/new_base.html.erb new file mode 100644 index 000000000..a270243b6 --- /dev/null +++ b/app/views/layouts/new_base.html.erb @@ -0,0 +1,45 @@ +<% course_model %> + + + + + + <%= h html_title %> + + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + <%= stylesheet_link_tag 'public', 'leftside', 'courses'%> + <%= javascript_include_tag "course","header" %> + + <%= yield :header_tags -%> + + + +
    + <%= render :partial => 'layouts/new_header' %> +
    + +
    + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    +
    + + <%= render :partial => 'layouts/new_footer' %> +
    +
    +<%= render :partial => 'layouts/new_feedback' %> + + +<%= call_hook :view_layouts_base_body_bottom %> + + + \ No newline at end of file diff --git a/app/views/messages/_course_new.html.erb b/app/views/messages/_course_new.html.erb new file mode 100644 index 000000000..ad2db8281 --- /dev/null +++ b/app/views/messages/_course_new.html.erb @@ -0,0 +1,15 @@ +
    +

    <%= l(:label_board_plural) %>

    +
    +
    +

    <%= l(:label_message_new) %>

    + +
    +
    \ No newline at end of file diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index f5c2a4211..ad07a190b 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -1,196 +1,100 @@ - -
    - - - <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> - -
    - <%= watcher_link(@topic, User.current) %> - <%= link_to( - l(:button_quote), - {:action => 'quote', :id => @topic}, - :remote => true, - :method => 'get', - :class => 'icon icon-comment', - :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - l(:button_edit), - {:action => 'edit', :id => @topic}, - :class => 'icon icon-edit' - ) if @message.course_editable_by?(User.current) %> - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => @topic}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'icon icon-del' - ) if @message.course_destroyable_by?(User.current) %> -
    - -
    -
    - <%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %> -
    -

    - <%= link_to @topic.author, user_path(@topic.author) %> -

    -
    -
    -
    - <% if @project %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project),title: @topic.subject.to_s %> - <% elsif @course %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course),title: @topic.subject.to_s %> - <% end %> -
    -
    - <%= textilizable(@topic, :content) %> - <%= link_to_attachments @topic, :author => false %> -
    -
    -
    - <%= authoring @topic.created_on, @topic.author %> -
    -
    - <% if User.current.logged? %> - <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> - <% else %> - <%= link_to l(:button_reply), signin_path %> - <% end %> -
    -
    -
    -
    +
    +

    <%= l(:label_board) %>

    +
    +
    <%= link_to image_tag(url_to_avatar(@topic.author),:width => '46',:height => '46'), user_path(@topic.author) %>
    +
    +

    <%= link_to @topic.subject, course_boards_path(@topic.course),title: @topic.subject.to_s %>

    +
    +

    由<%= link_to_user_header @topic.author,false,:class=> 'problem_name' %> 添加于<%= format_time(@topic.created_on) %>

    +
    + + <%#= watcher_link(@topic, User.current) %> + <%= link_to( + l(:button_edit), + {:action => 'edit', :id => @topic}, + :class => 'talk_edit fr' + ) if @message.course_editable_by?(User.current) %> + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => @topic}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'talk_edit fr' + ) if @message.course_destroyable_by?(User.current) %> +
    +
    <%= textilizable(@topic, :content) %>
    +
    <%= link_to_attachments_course @topic, :author => false %>
    + +
    + <% if User.current.logged? %> + <%= toggle_link l(:button_reply), "reply", :focus => 'message_content',:class => 'talk_edit fr' %> + <% else %> + <%= link_to l(:button_reply), signin_path,:class => 'talk_edit fr' %> + <% end %> + <%= link_to( + l(:button_quote), + {:action => 'quote', :id => @topic}, + :remote => true, + :method => 'get', + :class => 'talk_edit fr', + :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> +
    +
    <% unless @replies.empty? %> -
    -
    -
    -
    -

    - <%= l(:label_reply_plural) %> - (<%= @reply_count %>) -

    <% reply_count = 0 %> <% @replies.each do |message| %> -
    "> - - - - - - - - - - - - - -
    - <%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %> - -
    - <%= link_to( - l(:button_quote), - {:action => 'quote', :id => message}, - :remote => true, - :method => 'get', - :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - #image_tag('edit.png'), - l(:button_edit), - {:action => 'edit', :id => message}, - :title => l(:button_edit) - ) if message.course_editable_by?(User.current) %> - <%= link_to( - #image_tag('delete.png'), - l(:button_delete), - {:action => 'destroy', :id => message}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if message.course_destroyable_by?(User.current) %> -
    -
    - <%= textilizable message,:content,:attachments => message.attachments %> -
    - <%= link_to_attachments message, :author => false %> -
    - <%= authoring message.created_on, message.author %> -
    -
    - +
    "> +
    <%= link_to image_tag(url_to_avatar(message.author), :width => '46',:height => '46'), user_path(message.author) %>
    +
    +
    + <%= link_to_user_header message.author,false,:class => 'c_blue fb fl mb10 ' %> + <%= format_time(message.created_on) %> +
    +

    <%= textilizable message,:content,:attachments => message.attachments %>

    + <%= link_to_attachments_course message, :author => false %> +
    +
    + <%= link_to( + l(:button_quote), + {:action => 'quote', :id => message}, + :remote => true, + :method => 'get', + :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> + <%= link_to( + #image_tag('edit.png'), + l(:button_edit), + {:action => 'edit', :id => message}, + :title => l(:button_edit) + ) if message.course_editable_by?(User.current) %> + <%= link_to( + #image_tag('delete.png'), + l(:button_delete), + {:action => 'destroy', :id => message}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if message.course_destroyable_by?(User.current) %> +
    +
    +
    +
    +
    <% end %> - <% end %> <% if !@topic.locked? && authorize_for_course('messages', 'reply') %> <% end %> - + <% html_title @topic.subject %> + <% end %> +
    +
    - - <%= label_tips %> - -<% if @course && User.current.allowed_to?(:manage_news, @course) %> - <%= link_to(btn_tips, new_course_news_path(@course), + +
    <% if @newss.empty? %>

    @@ -89,67 +45,30 @@

    <% else %> <% @newss.each do |news| %> - - - - - -
    - <%= link_to image_tag(url_to_avatar(news.author), :class => "avatar"), user_path(news.author) %> - - - - - - - - - - - - -
    - - <%= link_to_user(news.author) if news.respond_to?(:author) %> - - - <%= l(:label_project_notice) %> - - - <%= link_to h(news.title), news_path(news) %> - - - <%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @couese) %> - -
    - - <%= textilizable(news, :description) %> - -
    - - <%= l :label_update_time %> - :  - <%= format_time(news.created_on) %> - - - <%= link_to l(:label_project_newother), news_path(news) %> - <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %> -
    -
    +
    + <%= link_to image_tag(url_to_avatar(news.author),:width => 42,:height => 42), user_path(news.author), :class => "problem_pic fl" %> +
    + <%= link_to_user_header(news.author,false,{:class=> 'problem_name c_orange fl'}) if news.respond_to?(:author) %> + <%= l(:label_release_news) %>:<%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %>
    +
    +

    <%= news.description %>
    <%= l(:label_create_time) %> :<%= format_time(news.created_on) %>

    + +
    +
    +
    + <% end %> <% end %>
    -
    - - <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:course_id => @course, :key => User.current.rss_key} %> - <% end %> + <%# other_formats_links do |f| %> + <%#= f.link_to 'Atom', :url => {:course_id => @course, :key => User.current.rss_key} %> + <%# end %> <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> @@ -171,4 +90,13 @@ }); }); }); + $(function(){ + $('.news_description').each(function () { + if($(this).height() >= 38) + { + $('#news_foot_'+$(this).attr('id').replace('news_description_','')).css("display","block"); + } + } + ) + }); diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index 00cbc17de..ed6011e29 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -49,92 +49,89 @@ $("#news-form").submit(); } } + function submitComment() + { + $("#add_comment_form").submit(); + } + function clearMessage() + { + $("#comment_comments").val(""); + } -
    - <%= watcher_link(@news, User.current) %> - <%= link_to(l(:button_edit), - edit_news_path(@news), - :class => 'icon icon-edit', - :accesskey => accesskey(:edit), - :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %> - <%= delete_link news_path(@news) if User.current.allowed_to?(:manage_news, @course) %> +
    +

    <%= l(:label_course_news) %>

    - -

    <%=h @news.title %>

    - <% if authorize_for_course('news', 'edit') %> <% end %> -
    - -
    - <%= textilizable(@news, :description) %> -
    - <%= link_to_attachments @news %> -
    - - <% if @news.commentable? %> -

    - <%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %> -

    - <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> -
    - <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> - <%= wikitoolbar_for 'comment_comments' %> -
    -

    - <%= submit_tag l(:button_add) %> -

    - <% end %> - <% end %> - - <% html_title @news.title -%> +
    + <%= link_to image_tag(url_to_avatar(@news.author),:width => 42,:height => 42), user_path(@news.author), :class => "problem_pic fl" %> +
    +

    <%=h @news.title %>

    + <%#= watcher_link(@news, User.current) %> + <%= link_to(l(:button_edit), + edit_news_path(@news), + :class => 'talk_edit fr', + :accesskey => accesskey(:edit), + :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %> + <%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %> +
    +
    <%= textilizable(@news, :description) %>
    <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    + <%= link_to_attachments_course @news %> + +
    +
    +
    - <% content_for :header_tags do %> - <%= stylesheet_link_tag 'scm' %> - <% end %> + <% if @news.commentable? %> +
    +

    <%= l(:label_comment_add) %>

    + <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %> +
    + <%= text_area 'comment', 'comments', :placeholder=>"最多250个字"%> +
    +

    + <%= l(:label_cancel_with_space) %> + <%= l(:label_comment_with_space) %> - -

    -
    -

    <%= l(:label_comment_plural) %>

    +

    + <% end %> +
    + <% end %> <% comments = @comments.reverse %> <% comments.each do |comment| %> <% next if comment.new_record? %> - - - - - -
    <%= image_tag(url_to_avatar(comment.author), :class => "avatar")%> - - - - - - - - - - - -
    <%= link_to_user(comment.author) if comment.respond_to?(:author) %> <%= l(:label_project_newadd) %><%= l(:label_comment_plural) %>
    - - <%= textilizable(comment.comments) %> - -
    <%= format_time(comment.created_on) %><%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
    +
    +
    <%= link_to image_tag(url_to_avatar(comment.author),:width => 42,:height => 42), user_path(comment.author)%>
    +
    +
    + <%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %><%= format_time(comment.created_on) %> +
    +

    <%= textilizable(comment.comments) %>

    +
    +
    <%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> +
    + +
    +
    +
    <% end if @comments.any? %> -
    + + + + + <% content_for :header_tags do %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + +<% html_title @news.title -%> \ No newline at end of file diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index 8c9bc784a..93040a882 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -1,4 +1,8 @@ +<% + btn_tips = l(:label_news_notice) + label_tips = l(:label_course_news) +%> <% if @project %> <%= labelled_form_for @news, :url => project_news_index_path(@project), :html => {:id => 'news-form', :multipart => true} do |f| %> @@ -7,11 +11,22 @@ <%#= preview_link preview_news_path(:project_id => @project), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> <% end %> <% elsif @course %> - <%= labelled_form_for @news, :url => course_news_index_path(@course), - :html => {:id => 'news-form', :multipart => true} do |f| %> - <%= render :partial => 'news/form', :locals => {:f => f} %> - <%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> - <%#= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %> - <% end %> +
    +

    <%= label_tips %>

    +
    +
    + <%= error_messages_for @news %> +

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

    +
      + <%= labelled_form_for @news, :url => course_news_index_path(@course), + :html => {:id => 'news-form', :multipart => true} do |f| %> + <%= render :partial => 'news/course_form', :locals => {:f => f, :is_new => true} %> + + <% end if @course %> +
    +
    +
    <% end %>
    diff --git a/app/views/poll/_choice_show.html.erb b/app/views/poll/_choice_show.html.erb index d541386d3..408b9d490 100644 --- a/app/views/poll/_choice_show.html.erb +++ b/app/views/poll/_choice_show.html.erb @@ -7,21 +7,21 @@ <%= l(:label_poll_proportion) %> <% poll_question.poll_answers.each do |poll_answer| %> - - <%= poll_answer.answer_text %> - <%= poll_answer.poll_votes.count %> - -
    - -
    - <%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>% - + + <%= poll_answer.answer_text %> + <%= poll_answer.poll_votes.count %> + +
    + +
    + <%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>% + <% end %> - - <%= l(:label_poll_valid_commit) %> - <%= total_answer(poll_question.id) %> -   - + + <%= l(:label_poll_valid_commit) %> + <%= total_answer(poll_question.id) %> +   +
    diff --git a/app/views/poll/_edit_MC.html.erb b/app/views/poll/_edit_MC.html.erb index 19a1e1e89..9209bf61d 100644 --- a/app/views/poll/_edit_MC.html.erb +++ b/app/views/poll/_edit_MC.html.erb @@ -7,7 +7,7 @@ $("#is_necessary_<%=poll_question.id%>").replaceWith("/>"); $("#poll_answers_<%=poll_question.id%>").html("<% poll_question.poll_answers.reorder('answer_position').each do |poll_answer| %>" + "
  • " + - "" + + "" + "" + "" + "" + @@ -29,7 +29,7 @@