diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 82f92c2d1..af501fdf9 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -41,6 +41,10 @@ class AccountController < ApplicationController render :layout => 'static_base' end + def about_us + render :layout => 'static_base' + end + # Log out current user and redirect to welcome page def logout if User.current.anonymous? diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index c10f8bc84..4088d4156 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -19,7 +19,7 @@ class CommentsController < ApplicationController default_search_scope :news include ApplicationHelper model_object News - before_filter :find_model_object + before_filter :find_model_object before_filter :find_project_from_association before_filter :authorize @@ -34,24 +34,31 @@ class CommentsController < ApplicationController ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT end - # 与我相关动态的记录add start - if( @comment.id && @news.course ) - if(@news.author_id != User.current.id) - notify = ActivityNotify.new() - notify.activity_container_id = @news.course.id - notify.activity_container_type = 'Course' - notify.activity_id = @comment.id - notify.activity_type = 'Comment' - notify.notify_to = @news.author_id - notify.is_read = 0 - notify.save() - end - end - # 与我相关动态的记录add end + # # 锟斤拷锟斤拷锟斤拷囟锟教拷募锟铰糰dd start + # if( @comment.id && @news.course ) + # if(@news.author_id != User.current.id) + # notify = ActivityNotify.new() + # notify.activity_container_id = @news.course.id + # notify.activity_container_type = 'Course' + # notify.activity_id = @comment.id + # notify.activity_type = 'Comment' + # notify.notify_to = @news.author_id + # notify.is_read = 0 + # notify.save() + # end + # end + # # 锟斤拷锟斤拷锟斤拷囟锟教拷募锟铰糰dd end flash[:notice] = l(:label_comment_added) end - redirect_to news_url(@news) + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + else + redirect_to news_url(@news) + end end def destroy @@ -69,6 +76,6 @@ class CommentsController < ApplicationController @comment = nil @news end - - + + end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 87c1e288b..2e9925916 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -115,23 +115,16 @@ class HomeworkCommonController < ApplicationController end end - # uri = URI('http://test.gitlab.trustie.net/api/questions.json') - # req = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'}) - # req.body = question.to_json - # res = Net::HTTP.start(uri.hostname, uri.port) do |http| - # http.request(req) + # uri = URI('http://192.168.80.21:8080/api/questions.json') + # body = question.to_json + # res = Net::HTTP.new(uri.host, uri.port).start do |client| + # request = Net::HTTP::Post.new(uri.path) + # request.body = body + # request["Content-Type"] = "application/json" + # client.request(request) # end - - uri = URI('http://192.168.80.21:8080/api/questions.json') - body = question.to_json - res = Net::HTTP.new(uri.host, uri.port).start do |client| - request = Net::HTTP::Post.new(uri.path) - request.body = body - request["Content-Type"] = "application/json" - client.request(request) - end - result = JSON.parse(res.body) - homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 + # result = JSON.parse(res.body) + # homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 homework.homework_detail_programing = homework_detail_programing else @@ -254,15 +247,15 @@ class HomeworkCommonController < ApplicationController question[:input] << test.input question[:output] << test.output end - uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json") - body = question.to_json - res = Net::HTTP.new(uri.host, uri.port).start do |client| - request = Net::HTTP::Put.new(uri.path) - request.body = body - request["Content-Type"] = "application/json" - client.request(request) - end - result = JSON.parse(res.body) + # uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json") + # body = question.to_json + # res = Net::HTTP.new(uri.host, uri.port).start do |client| + # request = Net::HTTP::Put.new(uri.path) + # request.body = body + # request["Content-Type"] = "application/json" + # client.request(request) + # end + # result = JSON.parse(res.body) end @homework.save_attachments(params[:attachments]) @@ -406,4 +399,4 @@ class HomeworkCommonController < ApplicationController student_works += student_works student_works[index + 1 .. index + n] end -end \ No newline at end of file +end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 67fec1b71..b3624b14d 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,11 +20,11 @@ class IssuesController < ApplicationController default_search_scope :issues before_filter :authorize1, :only => [:show] - before_filter :find_issue, :only => [:show, :edit, :update] + before_filter :find_issue, :only => [:show, :edit, :update,:add_journal] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index] + before_filter :authorize, :except => [:index,:add_journal] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -66,14 +66,14 @@ class IssuesController < ApplicationController if @query.valid? case params[:format] - when 'csv', 'pdf' - @limit = 10#Setting.issues_export_limit.to_i - when 'atom' - @limit = 10#Setting.feeds_limit.to_i - when 'xml', 'json' - @offset, @limit = api_offset_and_limit({:limit => 10}) - else - @limit = 10#per_page_option + when 'csv', 'pdf' + @limit = 10#Setting.issues_export_limit.to_i + when 'atom' + @limit = 10#Setting.feeds_limit.to_i + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 10}) + else + @limit = 10#per_page_option end @assign_to_id = params[:assigned_to_id] @author_id = params[:author_id] @@ -84,9 +84,9 @@ class IssuesController < ApplicationController @issue_pages = Paginator.new @issue_count, @limit, params['page'] @offset ||= @issue_pages.offset @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], - :order => sort_clause, - :offset => @offset, - :limit => @limit) + :order => sort_clause, + :offset => @offset, + :limit => @limit) @issue_count_by_group = @query.issue_count_by_group respond_to do |format| format.js @@ -145,16 +145,16 @@ class IssuesController < ApplicationController @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq respond_to do |format|`` - format.html { - retrieve_previous_and_next_issue_ids - render :template => 'issues/show', :layout => @project_base_tag#by young - } - format.api - format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } - format.pdf { - pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") - } + format.html { + retrieve_previous_and_next_issue_ids + render :template => 'issues/show', :layout => @project_base_tag#by young + } + format.api + format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } + format.pdf { + pdf = issue_to_pdf(@issue, :journals => @journals) + send_data(pdf, :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") + } end end @@ -324,8 +324,8 @@ class IssuesController < ApplicationController issue.reload if @copy issue = issue.copy({}, - :attachments => params[:copy_attachments].present?, - :subtasks => params[:copy_subtasks].present? + :attachments => params[:copy_attachments].present?, + :subtasks => params[:copy_subtasks].present? ) end journal = issue.init_journal(User.current, params[:notes]) @@ -355,21 +355,21 @@ class IssuesController < ApplicationController @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f if @hours > 0 case params[:todo] - when 'destroy' - # nothing to do - when 'nullify' - TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) - when 'reassign' - reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) - if reassign_to.nil? - flash.now[:error] = l(:error_issue_not_found_in_project) - return + when 'destroy' + # nothing to do + when 'nullify' + TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) + end else - TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) - end - else - # display the destroy form if it's a user request - return unless api_request? + # display the destroy form if it's a user request + return unless api_request? end end @issues.each do |issue| @@ -385,6 +385,18 @@ class IssuesController < ApplicationController end end + def add_journal + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + end + private def find_project @@ -425,14 +437,14 @@ class IssuesController < ApplicationController issue_attributes = params[:issue] if issue_attributes && params[:conflict_resolution] case params[:conflict_resolution] - when 'overwrite' - issue_attributes = issue_attributes.dup - issue_attributes.delete(:lock_version) - when 'add_notes' - issue_attributes = issue_attributes.slice(:notes) - when 'cancel' - redirect_to issue_url(@issue) - return false + when 'overwrite' + issue_attributes = issue_attributes.dup + issue_attributes.delete(:lock_version) + when 'add_notes' + issue_attributes = issue_attributes.slice(:notes) + when 'cancel' + redirect_to issue_url(@issue) + return false end end @issue.safe_attributes = issue_attributes diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index a242587fb..965aacab0 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -177,6 +177,7 @@ class MessagesController < ApplicationController @reply.board = @board @reply.safe_attributes = params[:reply] @reply.content = @quote + @reply.content + @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject] @topic.children << @reply #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? @@ -185,41 +186,18 @@ class MessagesController < ApplicationController update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE end - # 涓庢垜鐩稿叧鍔ㄦ佺殑璁板綍add start - if(@board && @board.course) #椤圭洰鐨勫厛涓嶇 - notifyto_arr = {} - notifyto_arr[@topic.author_id] = @topic.author_id - if( params[:parent_topic] != nil && params[:parent_topic] != '') - parent_topic = Message.find(params[:parent_topic]) - notifyto_arr[parent_topic.author_id] = parent_topic.author_id - end - notifyto_arr.each do |k,user_id| - if(user_id != User.current.id) - notify = ActivityNotify.new() - if(@board.course) - notify.activity_container_id = @board.course_id - notify.activity_container_type = 'Course' - else - notify.activity_container_id = @board.project_id - notify.activity_container_type = 'Project' - end - notify.activity_id = @reply.id - notify.activity_type = 'Message' - notify.notify_to = user_id - notify.is_read = 0 - notify.save() - end - end - end - # 涓庢垜鐩稿叧鍔ㄦ佺殑璁板綍add end - call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) attachments = Attachment.attach_files(@reply, params[:attachments]) render_attachment_warning_if_needed(@reply) else #render file: 'messages#show', layout: 'base_courses' end - if params[:is_board] + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + elsif params[:is_board] if @project redirect_to project_boards_path(@project) elsif @course diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 1af832b79..7726ab3da 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,13 +3,45 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list] protect_from_forgery :except => :set_program_score + ### + def program_test + resultObj = {status: 0, results: [], error_msg: '', time: Time.now} + student_work = find_or_save_student_work + unless student_work + resultObj[:status] = 100 + else + if @homework.homework_type == 2 && @homework.homework_detail_programing + result = test_realtime(student_work, params[:src]) + logger.debug result + resultObj[:status] = result["status"] + resultObj[:results] = result["results"] + resultObj[:error_msg] = result["error_msg"] + results = result["results"] + if result["status"].to_i == -2 #缂栬瘧閿欒 + results = [result["error_msg"]] + end + student_work_test = student_work.student_work_tests.build(status: result["status"], results: results, + src: params[:src]) + unless student_work.save + resultObj[:status] = 200 + else + resultObj[:status] = result["status"].to_i + resultObj[:time] = student_work_test.created_at.to_s(:db) + resultObj[:index] = student_work.student_work_tests.count + end + + end + end + render :json => resultObj + end + def index #璁剧疆浣滀笟瀵瑰簲鐨刦orge_messages琛ㄧ殑viewed瀛楁 query_student_work = @homework.course_messages @@ -102,20 +134,16 @@ class StudentWorkController < ApplicationController end def new - student_work = @homework.student_works.where("user_id = ?",User.current.id).first - if student_work.nil? - @stundet_work = StudentWork.new - respond_to do |format| - format.html - end - else - render_403 + @student_work = @homework.student_works.where("user_id = ?",User.current.id).first + if @student_work.nil? + @student_work = StudentWork.new end end def create if params[:student_work] - stundet_work = StudentWork.new + stundet_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id] + stundet_work ||= StudentWork.new stundet_work.name = params[:student_work][:name] stundet_work.description = params[:student_work][:description] stundet_work.project_id = params[:student_work][:project_id] @@ -128,23 +156,9 @@ class StudentWorkController < ApplicationController stundet_work.late_penalty = 0 end render_attachment_warning_if_needed(stundet_work) - if stundet_work.save if @homework.homework_type == 2 && @homework.homework_detail_programing #缂栫▼浣滀笟锛屽鐢熸彁浜や綔鍝佸悗璁$畻绯荤粺寰楀垎 - url = "http://192.168.80.21:8080/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json" - solutions = { - student_work_id:stundet_work.id, - src:Base64.encode64(stundet_work.description), - language:@homework.homework_detail_programing.language - } - uri = URI(url) - body = solutions.to_json - res = Net::HTTP.new(uri.host, uri.port).start do |client| - request = Net::HTTP::Post.new(uri.path) - request.body = body - request["Content-Type"] = "application/json" - client.request(request) - end + end respond_to do |format| format.html { @@ -584,4 +598,44 @@ class StudentWorkController < ApplicationController book.write xls_report xls_report.string end + + def find_or_save_student_work + student_work = @homework.student_works.where(user_id: User.current.id).first + if student_work.nil? + @homework.student_works.build( + name: params[:title], + description: params[:src], + user_id: User.current.id + ) + unless @homework.save + else + student_work = @homework.student_works.where(user_id: User.current.id).first + end + end + student_work + end + + + def test_realtime(student_work, src) + url = "#{Redmine::Configuration['judge_server']}api/realtime_test.json" + + factor = [] + @homework.homework_tests.each do |test| + factor << {input: test.input, output: test.output} + end + solutions = { + src:src, + language:@homework.homework_detail_programing.language, + factor: factor + } + uri = URI(url) + body = solutions.to_json + res = Net::HTTP.new(uri.host, uri.port).start do |client| + request = Net::HTTP::Post.new(uri.path) + request.body = body + request["Content-Type"] = "application/json" + client.request(request) + end + JSON.parse(res.body) + end end \ No newline at end of file diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 882f88e41..1fac6737b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -41,12 +41,12 @@ class UsersController < ApplicationController before_filter :can_show_course, :only => [:user_courses,:user_homeworks] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, - :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, - :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, - :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, - :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, - :user_import_homeworks,:user_search_homeworks,:user_import_resource] + :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, + :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, + :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, + :user_import_homeworks,:user_search_homeworks,:user_import_resource] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -218,7 +218,7 @@ class UsersController < ApplicationController end # end - ##added by fq +##added by fq def watch_bids # cond = 'bids.reward_type <> 1' # @bids = Bid.watched_by(@user).where('reward_type = ?', 1) # added by huang @@ -281,7 +281,7 @@ class UsersController < ApplicationController unless User.current.admin? if !@user.active? || (@user != User.current && @memberships.empty? && events.empty?) render_404 - return + return end end @@ -342,6 +342,24 @@ class UsersController < ApplicationController end end + def new_user_commit_homework + @user = User.current + @homework = HomeworkCommon.find(params[:homework_id]) + @student_work = @homework.student_works.where(user_id: User.current.id).first + if @student_work.nil? + @student_work = StudentWork.new + end + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + end + + def user_commit_homework + flash[:notice] = l(:notice_successful_create) + redirect_to user_homeworks_user_path(User.current) + end + def user_new_homework if params[:homework_common] homework = HomeworkCommon.new @@ -349,7 +367,7 @@ class UsersController < ApplicationController homework.description = params[:homework_common][:description] homework.end_time = params[:homework_common][:end_time] || Time.now homework.publish_time = Time.now - homework.homework_type = 1 + homework.homework_type = params[:homework_type].to_i || 1 homework.late_penalty = 2 homework.user_id = User.current.id homework.course_id = params[:course_id] @@ -358,17 +376,36 @@ class UsersController < ApplicationController render_attachment_warning_if_needed(homework) #鍖胯瘎浣滀笟鐩稿叧灞炴 - homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 - homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = Time.now - homework_detail_manual.evaluation_end = Time.now - homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 - homework_detail_manual.absence_penalty = 2 - homework.homework_detail_manual = homework_detail_manual + if homework.homework_type == 1 + homework_detail_manual = HomeworkDetailManual.new + homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_manual.comment_status = 1 + homework_detail_manual.evaluation_start = Time.now + homework_detail_manual.evaluation_end = Time.now + homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 + homework_detail_manual.absence_penalty = 2 + homework.homework_detail_manual = homework_detail_manual + else + homework_detail_programing = HomeworkDetailPrograming.new + homework.homework_detail_programing = homework_detail_programing + homework_detail_programing.ta_proportion = params[:ta_proportion] || 0.6 + homework_detail_programing.language = params[:program][:language].to_i + + inputs = params[:program][:input] + if Array === inputs + inputs.each_with_index do |val, i| + homework.homework_tests << HomeworkTest.new( + input: val, + output: params[:program][:output][i] + ) + end + end + + end if homework.save homework_detail_manual.save if homework_detail_manual + homework_detail_programing.save if homework_detail_programing redirect_to user_homeworks_user_path(User.current.id) end end @@ -376,9 +413,102 @@ class UsersController < ApplicationController #鐢ㄦ埛浠庤祫婧愬簱瀵煎叆璧勬簮鍒颁綔涓 def user_import_resource - user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 + @user = User.current + user_course_ids = @user.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") + @type = params[:type] + @homework_id = params[:homework_id] + @limit = 7 + @is_remote = true + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @attachments = paginateHelper @attachments,7 + respond_to do |format| + format.js + end + end + + #寮曞叆璧勬簮鍒楄〃鏍规嵁绫诲瀷杩囨护 + def user_resource_type + if User.current.id.to_i != params[:id].to_i + render_403 + return + end + if(params[:type].blank? || params[:type] == "1") #鍏ㄩ儴 + user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") + elsif params[:type] == "2" #璇剧▼璧勬簮 + user_course_ids = User.current.courses.map { |c| c.id} + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) ").order("created_on desc") + elsif params[:type] == "3" #椤圭洰璧勬簮 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") + elsif params[:type] == "4" #闄勪欢 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + elsif params[:type] == "5" #鐢ㄦ埛璧勬簮 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") + end + @type = params[:type] + @limit = 7 + @is_remote = true + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @attachments = paginateHelper @attachments,7 + respond_to do |format| + format.js + end + end + + + #寮曞叆璧勬簮鍒楄〃鏍规嵁鍏抽敭璇嶈繃婊 + def user_ref_resource_search + search = params[:search].to_s.strip.downcase + if(params[:type].blank? || params[:type] == "1") #鍏ㄩ儴 + user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 鍙栦氦闆嗗苟鏌ヨ + @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") + elsif params[:type] == "2" #璇剧▼璧勬簮 + user_course_ids = User.current.courses.map { |c| c.id} + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") + elsif params[:type] == "3" #椤圭洰璧勬簮 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") + elsif params[:type] == "4" #闄勪欢 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + elsif params[:type] == "5" #鐢ㄦ埛璧勬簮 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + end + @type = params[:type] + @limit = 7 + @is_remote = true + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @attachments = paginateHelper @attachments,7 + respond_to do |format| + format.js + end + end + + #灏嗚祫婧愭壒閲忓紩鍏 + def import_resources_to_homework + @attachments = [] + unless params[:checkbox1].nil? || params[:checkbox1].blank? + params[:checkbox1].each do |id| + atta = Attachment.find(id) + att_copy = atta.copy + att_copy.container_id = nil + att_copy.container_type = nil + att_copy.copy_from = atta.id + att_copy.save + @attachments << att_copy + end + end respond_to do |format| format.js end @@ -440,16 +570,16 @@ class UsersController < ApplicationController sort_update %w(login firstname lastname mail admin created_on last_login_on) case params[:format] - when 'xml', 'json' - @offset, @limit = api_offset_and_limit({:limit => 15}) - else - @limit = 15 + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 15}) + else + @limit = 15 end # retrieve all users # 鍏堝唴杩炰竴涓媠tatuses 淇濊瘉鎺掑簭涔嬪悗鏁伴噺涓鑷 scope = User.visible. - joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") + joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id") # unknow scope = scope.in_group(params[:group_id]) if params[:group_id].present? @@ -460,29 +590,29 @@ class UsersController < ApplicationController # users classify case params[:user_sort_type] - when '0' - # 鍒涘缓鏃堕棿鎺掑簭 - @s_type = 0 - @users = scope.reorder('users.created_on DESC') - when '1' - # 娲昏穬搴︽帓搴, 灏辨槸鎵璋撶殑寰楀垎鎯呭喌 - @s_type = 1 - @users = scope. - joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). - reorder('option_numbers.total_score DESC') - when '2' - # 绮変笣鏁版帓搴 - @s_type = 2 - @users = scope. - #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). - reorder('user_statuses.watchers_count DESC') + when '0' + # 鍒涘缓鏃堕棿鎺掑簭 + @s_type = 0 + @users = scope.reorder('users.created_on DESC') + when '1' + # 娲昏穬搴︽帓搴, 灏辨槸鎵璋撶殑寰楀垎鎯呭喌 + @s_type = 1 + @users = scope. + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') + when '2' + # 绮変笣鏁版帓搴 + @s_type = 2 + @users = scope. + #joins("INNER JOIN user_statuses ON users.id = user_statuses.user_id"). + reorder('user_statuses.watchers_count DESC') - else - # 榛樿娲昏穬搴︽帓搴 - @s_type = 1 - @users = scope. - joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). - reorder('option_numbers.total_score DESC') + else + # 榛樿娲昏穬搴︽帓搴 + @s_type = 1 + @users = scope. + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') end # limit and offset @@ -502,20 +632,20 @@ class UsersController < ApplicationController sort_init 'login', 'asc' sort_update %w(login firstname lastname mail admin created_on last_login_on) (redirect_to user_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? - case params[:format] + case params[:format] when 'xml', 'json' @offset, @limit = api_offset_and_limit({:limit => 15}) else @limit = 15#per_page_option - end - # - #@status = params[:status] || 1 - #has = { - # "show_changesets" => true - #} - # scope = User.logged.status(@status) - # @search_by = params[:search_by] ? params[:search_by][:id] : 0 - # scope = scope.like(params[:name],@search_by) if params[:name].present? + end + # + #@status = params[:status] || 1 + #has = { + # "show_changesets" => true + #} + # scope = User.logged.status(@status) + # @search_by = params[:search_by] ? params[:search_by][:id] : 0 + # scope = scope.like(params[:name],@search_by) if params[:name].present? @search_by = params[:search_by] ? params[:search_by] : 0 us = UsersService.new @@ -548,13 +678,13 @@ class UsersController < ApplicationController def user_courses4show @page = params[:page].to_i + 1 @courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) - end + end #鏄剧ず鏇村鐢ㄦ埛椤圭洰 def user_projects4show @page = params[:page].to_i + 1 @projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5) - end + end def user_course_activities lastid = nil @@ -631,9 +761,7 @@ class UsersController < ApplicationController end def show - @page = params[:page] ? params[:page].to_i + 1 : 0 - user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" course_types = "('Message','News','HomeworkCommon','poll')" @@ -654,7 +782,7 @@ class UsersController < ApplicationController @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) else @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) - end + end else @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) end @@ -672,124 +800,124 @@ class UsersController < ApplicationController # Author lizanle # Description type 1 :鎵鏈夊姩鎬佸寘鎷垜鍏虫敞鐨勪汉 type 2:鎴戠殑鍔ㄦ type 3:鍏充簬鎴戠殑鍥炲 case params[:type] - when "1" - if @user == User.current - activity = Activity.where('user_id = ?', User.current.id).order('id desc') - @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all - @state = 1 - end - when "2" - message = [] - if @user == User.current - message = JournalsForMessage.reference_message(@user.id) - message += Journal.reference_message(@user.id) - end - @activity_count = message.size - @info_pages = Paginator.new @activity_count, pre_count, params['page'] - messages = message.sort {|x,y| y.created_on <=> x.created_on } - @message = messages[@info_pages.offset, @info_pages.per_page] - @state = 2 - else - # Time 2015-02-04 10:50:49 - # Author lizanle - # Description 鎵鏈夊姩鎬 - where_condition = nil; - # where_condition = "act_type <> 'JournalsForMessage'" - user_ids = [] - if @user == User.current - watcher = User.watched_by(@user) - watcher.push(User.current) - user_ids = watcher.map{|x| x.id} - else - user_ids << @user.id - end - activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc') - - permission = !User.current.admin? - if permission - #Issue - act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id} - project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) - end - ids = [] - ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} - - #HomeworkCommon - act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} - course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: course_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + when "1" + if @user == User.current + activity = Activity.where('user_id = ?', User.current.id).order('id desc') + @activity_count = activity.count + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all + @state = 1 end - ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id} - - #Journal - act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} - project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) + when "2" + message = [] + if @user == User.current + message = JournalsForMessage.reference_message(@user.id) + message += Journal.reference_message(@user.id) end - ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} - - #News - act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} - project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) + @activity_count = message.size + @info_pages = Paginator.new @activity_count, pre_count, params['page'] + messages = message.sort {|x,y| y.created_on <=> x.created_on } + @message = messages[@info_pages.offset, @info_pages.per_page] + @state = 2 + else + # Time 2015-02-04 10:50:49 + # Author lizanle + # Description 鎵鏈夊姩鎬 + where_condition = nil; + # where_condition = "act_type <> 'JournalsForMessage'" + user_ids = [] + if @user == User.current + watcher = User.watched_by(@user) + watcher.push(User.current) + user_ids = watcher.map{|x| x.id} + else + user_ids << @user.id end - ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id} + activity = Activity.where(where_condition).where(user_id: user_ids).order('id desc') + + permission = !User.current.admin? + if permission + #Issue + act_ids = activity.where(act_type: 'Issue').select('act_id').map{|x| x.act_id} + project_ids = Issue.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids = [] + ids << Issue.where(id: act_ids, project_id: p_ids).map{|x| x.id} + + #HomeworkCommon + act_ids = activity.where(act_type: 'HomeworkCommon').select('act_id').map{|x| x.act_id} + course_ids = HomeworkCommon.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: course_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << HomeworkCommon.where(id: act_ids, course_id: c_ids).map{|x| x.id} + + #Journal + act_ids = activity.where(act_type: 'Journal').select('act_id').map{|x| x.act_id} + project_ids = Journal.where(id:act_ids, journalized_type: 'Project').select('distinct journalized_id').map{|x| x.journalized_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Journal.where(id: act_ids, journalized_id: p_ids, journalized_type: 'Project').map{|x| x.id} + + #News + act_ids = activity.where(act_type: 'News').select('act_id').map{|x| x.act_id} + project_ids = News.where(id: act_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << News.where(id: act_ids, project_id: p_ids).map{|x| x.id} - project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: project_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) - end - ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id} - - #Message - act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id} - board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id} - project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id} - p_ids = [] - Project.where(id: project_ids).each do |x| - p_ids << x.id unless x.visible?(User.current) - end - ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id} + project_ids = News.where(id: act_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << News.where(id: act_ids, course_id: p_ids).map{|x| x.id} + + #Message + act_ids = activity.where(act_type: 'Message').select('act_id').map{|x| x.act_id} + board_ids = Message.where(id: act_ids).select('distinct board_id').map{|x| x.board_id} + project_ids = Board.where(id: board_ids).select('distinct project_id').map{|x| x.project_id} + p_ids = [] + Project.where(id: project_ids).each do |x| + p_ids << x.id unless x.visible?(User.current) + end + ids << Message.where(id: act_ids, board_id: p_ids).map{|x| x.id} - project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id} - c_ids = [] - Course.where(id: project_ids).each do |x| - c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) - end - ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id} + project_ids = Board.where(id: board_ids).select('distinct course_id').map{|x| x.course_id} + c_ids = [] + Course.where(id: project_ids).each do |x| + c_ids << x.id unless x.is_public !=0 && User.current.member_of_course?(x) + end + ids << Message.where(id: act_ids, board_id: c_ids).map{|x| x.id} - logger.debug "filter ids #{ids}" + logger.debug "filter ids #{ids}" - activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty? - end + activity = activity.where('act_id not in (?)', ids.flatten ).order('id desc') unless ids.flatten.empty? + end - # activity = activity.reject { |e| - # e.act.nil? || - # (!User.current.admin? && !e.act.nil? - # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || - # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || - # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || - # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || - # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) - # } - # + # activity = activity.reject { |e| + # e.act.nil? || + # (!User.current.admin? && !e.act.nil? + # (((e.act_type == "Issue") && !e.act.project.visible?(User.current)) || + # (e.act_type == "Bid" && !e.act.courses.first.nil? && e.act.courses.first.is_public == 0 && !User.current.member_of_course?(e.act.courses.first)) || + # (e.act_type == "Journal" && e.act.respond_to?("Project") && !e.act.project.visible?(User.current)) || + # (e.act_type == "News" && ((!e.act.project.nil? && !e.act.project.visible?(User.current)) || (!e.act.course.nil? && e.act.course.is_public == 0 && !User.current.member_of_course?(e.act.course)))) || + # (e.act_type == "Message" && !e.act.board.nil? && ((!e.act.board.project.nil? && !e.act.board.project.visible?(User.current)) || (!e.act.board.course.nil? && e.act.board.course.is_public == 0 && !User.current.member_of_course?(e.act.board.course)))))) + # } + # - @activity_count = activity.count - @activity_pages = Paginator.new @activity_count, pre_count, params['page'] - @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) - @state = 0 + @activity_count = activity.count + @activity_pages = Paginator.new @activity_count, pre_count, params['page'] + @activity = activity.slice(@activity_pages.offset,@activity_pages.per_page) + @state = 0 end if params[:user].present? @@ -817,7 +945,7 @@ class UsersController < ApplicationController if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) # redirect_to home_path render_404 - return + return end end @@ -849,7 +977,7 @@ class UsersController < ApplicationController unless User.current.admin? if !@user.active? render_404 - return + return end end @@ -907,7 +1035,7 @@ class UsersController < ApplicationController unless @user.id.nil? #鍚庡彴娉ㄥ唽鐨勭敤鎴烽粯璁ゆ潈闄愪负鐢锋у紑鍙戝憳 ue = UserExtensions.create(:identity => 3, - :gender => 0, + :gender => 0, :user_id => @user.id) ue.save end @@ -977,8 +1105,8 @@ class UsersController < ApplicationController @user = User.find(params[:id]) #@user.save_attachments(params[:attachments],User.current) # Container_type涓篜rincipal - Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) - if(params[:type].nil? || params[:type] == "1") #鍏ㄩ儴 + Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) + if(params[:type].blank?|| params[:type] == "1") #鍏ㄩ儴 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -1033,14 +1161,14 @@ class UsersController < ApplicationController # 鍒犻櫎鐢ㄦ埛璧勬簮锛屽垎涓烘壒閲忓垹闄 鍜 鍗曚釜鍒犻櫎锛屽彧鑳藉垹闄よ嚜宸变笂浼犵殑璧勬簮 def user_resource_delete if params[:resource_id].present? - Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) + Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) elsif params[:checkbox1].present? - params[:checkbox1].each do |id| - Attachment.where("author_id = #{User.current.id}").delete(id) + params[:checkbox1].each do |id| + Attachment.where("author_id = #{User.current.id}").delete(id) end end - if(params[:type].nil? || params[:type] == "1") #鍏ㄩ儴 + if(params[:type].blank? || params[:type] == "1") #鍏ㄩ儴 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -1087,17 +1215,17 @@ class UsersController < ApplicationController @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] @attachments = paginateHelper @attachments,25 - respond_to do |format| - format.js - end + respond_to do |format| + format.js + end end #鏍规嵁id鎴栬呭悕绉版悳绱㈡暀甯堟垨鑰呭姪鏁欎负褰撳墠鐢ㄦ埛鐨勮绋 def search_user_course @user = User.current if !params[:search].nil? - @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") - .select { |course| @user.allowed_to?(:as_teacher,course)} + @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") + .select { |course| @user.allowed_to?(:as_teacher,course)} else @course = @user.courses .select { |course| @user.allowed_to?(:as_teacher,course)} @@ -1129,28 +1257,28 @@ class UsersController < ApplicationController # 灏嗚祫婧愬彂閫佸埌瀵瑰簲鐨勮绋,鍒嗕负鍙戦佸崟涓紝鎴栬呮壒閲忓彂閫 def add_exist_file_to_course @flag = true - if params[:send_id].present? + if params[:send_id].present? send_id = params[:send_id] ori = Attachment.find_by_id(send_id) course_ids = params[:course_ids] if course_ids.nil? @flag = false end - unless course_ids.nil? - course_ids.each do |id| - next if ori.blank? - attach_copied_obj = ori.copy - attach_copied_obj.tag_list.add(ori.tag_list) # tag鍏宠仈 - attach_copied_obj.container = Course.find(id) - attach_copied_obj.created_on = Time.now - attach_copied_obj.author_id = User.current.id - if attach_copied_obj.attachtype == nil - attach_copied_obj.attachtype = 4 - end - attach_copied_obj.save - @save_message = attach_copied_obj.errors.full_messages - end + unless course_ids.nil? + course_ids.each do |id| + next if ori.blank? + attach_copied_obj = ori.copy + attach_copied_obj.tag_list.add(ori.tag_list) # tag鍏宠仈 + attach_copied_obj.container = Course.find(id) + attach_copied_obj.created_on = Time.now + attach_copied_obj.author_id = User.current.id + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + attach_copied_obj.save + @save_message = attach_copied_obj.errors.full_messages end + end elsif params[:send_ids].present? send_ids = params[:send_ids].split(" ") course_ids = params[:course_ids] @@ -1177,8 +1305,20 @@ class UsersController < ApplicationController end end else - @flag = false + @flag = false end + user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") + @type = params[:type] + @limit = 25 + @user = User.current + @is_remote = true + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @attachments = paginateHelper @attachments,25 respond_to do |format| format.js end @@ -1235,7 +1375,18 @@ class UsersController < ApplicationController else @flag=true end - + user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") + @type = params[:type] + @limit = 25 + @user = User.current + @is_remote = true + @atta_count = @attachments.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @attachments = paginateHelper @attachments,25 respond_to do |format| format.js end @@ -1243,15 +1394,15 @@ class UsersController < ApplicationController # 璧勬簮棰勮 def resource_preview - preview_id = params[:resource_id] - @file = Attachment.find(preview_id) - @preview_able = false; - if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)} - @preview_able = true; - end - respond_to do |format| - format.js - end + preview_id = params[:resource_id] + @file = Attachment.find(preview_id) + @preview_able = false; + if %w(pdf pptx doc docx xls xlsx).any?{|x| @file.filename.downcase.end_with?(x)} + @preview_able = true; + end + respond_to do |format| + format.js + end end # 閲嶅懡鍚嶈祫婧 @@ -1291,7 +1442,7 @@ class UsersController < ApplicationController def destroy_membership @membership = Member.find(params[:membership_id]) if @membership.deletable? - @membership.destroy + @membership.destroy end respond_to do |format| format.html { redirect_to edit_user_url(@user, :tab => 'memberships') } @@ -1306,31 +1457,31 @@ class UsersController < ApplicationController @obj_flag = params[:tag_for_save][:object_flag] case @obj_flag - when '1' then - @obj = User.find_by_id(@obj_id) - when '2' then - @obj = Project.find_by_id(@obj_id) - when '3' then - @obj = Issue.find_by_id(@obj_id) - when '4' then - # @obj = Bid.find_by_id(@obj_id) - when '5' then - @obj = Forum.find_by_id(@obj_id) - when '6' - @obj = Attachment.find_by_id(@obj_id) - when '7' then - @obj = Contest.find_by_id(@obj_id) - when '8' - @obj = OpenSourceProject.find_by_id(@obj_id) - when '9' - @obj = Course.find_by_id(@obj_id) - else - @obj = nil + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + # @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) + else + @obj = nil end unless @obj.nil? @obj.tag_list.add(@tags.split(",")) else - return + return end if @obj.save logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" @@ -1421,9 +1572,9 @@ class UsersController < ApplicationController def update_extensions(user_extensions) user_extensions = params[:user_extensions] unless user_extensions.nil? - user_extensions = UserExtensions.find_by_id(user_extensions.user_id) + user_extensions = UserExtensions.find_by_id(user_extensions.user_id) - # user_extensions. + # user_extensions. end end @@ -1450,7 +1601,7 @@ class UsersController < ApplicationController render_403 return end - if(params[:type].nil? || params[:type] == "1") #鍏ㄩ儴 + if(params[:type].blank? || params[:type] == "1") #鍏ㄩ儴 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #鎴戠殑璧勬簮搴撶殑璇濓紝閭d箞搴旇鏄垜涓婁紶鐨勬墍鏈夎祫婧 鍔犱笂 鎴戝姞鍏ョ殑璇剧▼鐨勬墍鏈夎祫婧 @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -1514,9 +1665,9 @@ class UsersController < ApplicationController else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #濡傛灉璇剧▼绉佹湁璧勬簮锛岄偅涔堣鐪嬭繖涓祫婧愮殑璇剧▼鏄笉鏄湪 杩欎釜user鐨勬墍鏈夋垜鍙鐨勮绋嬩腑 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + - " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ - " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + - " and (filename like '%#{search}%') ").order("created_on desc") + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ + " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + + " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "2" #璇剧▼璧勬簮 if User.current.id.to_i == params[:id].to_i @@ -1525,7 +1676,7 @@ class UsersController < ApplicationController else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #濡傛灉璇剧▼绉佹湁璧勬簮锛岄偅涔堣鐪嬭繖涓祫婧愮殑璇剧▼鏄笉鏄湪 杩欎釜user鐨勬墍鏈夋垜鍙鐨勮绋嬩腑 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "3" #椤圭洰璧勬簮 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 76f36b34d..ad9322cbc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2338,7 +2338,7 @@ module ApplicationHelper #鏍规嵁浼犲叆浣滀笟纭畾鏄剧ず涓虹紪杈戜綔鍝佽繕鏄柊寤轰綔鍝,鎴栬呮樉绀轰綔鍝佹暟閲 def user_for_homework_common homework,is_teacher if is_teacher #鑰佸笀鏄剧ず浣滃搧鏁伴噺 - link_to "鎻愪氦锛#{homework.student_works.count}锛",student_work_index_path(:homework => homework.id),:class => "c_blue" + link_to "鎻愪氦(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else #瀛︾敓鏄剧ず鎻愪氦浣滃搧銆佷慨鏀逛綔鍝佺瓑鎸夐挳 work = cur_user_works_for_homework homework if work.nil? diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 0eee08b6b..1a0b9ca0d 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -116,7 +116,7 @@ module JournalsHelper end end #content << content_tag('div', links.join(' ').html_safe, :class => 'contextual', :style => 'margin-top:-25px;') unless links.empty? - content << textilizable(journal, :notes) + content << textAreailizable(journal, :notes) css_classes = "wiki" css_classes << " editable" if editable content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes ,:style => "width:510px") diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index e7ab001da..269630ec3 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -71,7 +71,7 @@ module UsersHelper def user_settings_tabs tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general}, {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural} - ] + ] if Group.all.any? tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural} end @@ -83,7 +83,7 @@ module UsersHelper def get_users_by_tag(tag_name) User.tagged_with(tag_name).order('updated_on desc') end - + # added by fq # - + # TODO: 寰呭垹 # def show_activity(state) # content = ''.html_safe @@ -114,19 +114,19 @@ module UsersHelper # end # content_tag('div', content, :class => "pagination") # end - + #TODO: 寰呭垹 def watch_projects(state) content = ''.html_safe case state - when 0 - s = content_tag('span', l(:label_project_take), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) - when 1 - s = content_tag('span', l(:label_has_watched_project), :class => "current-page") - content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) - content << content_tag('li', s, :class => "current-page") + when 0 + s = content_tag('span', l(:label_project_take), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1})) + when 1 + s = content_tag('span', l(:label_has_watched_project), :class => "current-page") + content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'})) + content << content_tag('li', s, :class => "current-page") end content_tag('div', content, :class => "pagination") end @@ -134,59 +134,59 @@ module UsersHelper def user_course(state) content = ''.html_safe if @user != User.current - if @user.user_extensions.identity == 0 + if @user.user_extensions.identity == 0 case state - when 0 - s = content_tag('span', '浠栨墽鏁欑殑璇剧▼', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('浠栧彂甯冪殑浣滀笟', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '浠栧彂甯冪殑浣滀笟', :class => "current-page") - content << content_tag('li', link_to('浠栨墽鏁欑殑璇剧▼', {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', '浠栨墽鏁欑殑璇剧▼', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('浠栧彂甯冪殑浣滀笟', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '浠栧彂甯冪殑浣滀笟', :class => "current-page") + content << content_tag('li', link_to('浠栨墽鏁欑殑璇剧▼', {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end - else + else case state - when 0 - s = content_tag('span', '浠栫殑璇剧▼', :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('浠栫殑浣滀笟', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '浠栫殑浣滀笟', :class => "current-page") - content << content_tag('li', link_to('浠栫殑璇剧▼', {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', '浠栫殑璇剧▼', :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('浠栫殑浣滀笟', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '浠栫殑浣滀笟', :class => "current-page") + content << content_tag('li', link_to('浠栫殑璇剧▼', {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end end else - if @user.user_extensions.identity == 0 + if @user.user_extensions.identity == 0 case state - when 0 - s = content_tag('span', l(:label_teaching_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', l(:label_release_homework), :class => "current-page") - content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', l(:label_teaching_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', l(:label_release_homework), :class => "current-page") + content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end - else + else case state - when 0 - s = content_tag('span', l(:label_my_course), :class => "current-page") - content << content_tag('li', s) - content << content_tag('li', link_to('鎴戠殑浣滀笟', {:controller => 'users', :action => 'user_courses', :type => 1})) - content_tag('div', content, :class => "pagination") - when 1 - s = content_tag('span', '鎴戠殑浣滀笟', :class => "current-page") - content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) - content << content_tag('li', s, :class => "current-page") - content_tag('div', content, :class => "pagination") + when 0 + s = content_tag('span', l(:label_my_course), :class => "current-page") + content << content_tag('li', s) + content << content_tag('li', link_to('鎴戠殑浣滀笟', {:controller => 'users', :action => 'user_courses', :type => 1})) + content_tag('div', content, :class => "pagination") + when 1 + s = content_tag('span', '鎴戠殑浣滀笟', :class => "current-page") + content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0})) + content << content_tag('li', s, :class => "current-page") + content_tag('div', content, :class => "pagination") end end end @@ -196,42 +196,42 @@ module UsersHelper def sort_user(state, project_type) content = ''.html_safe case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") ) + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") ) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ))) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs") - end - + end + def sort_user_enterprise(state, project_type) content = ''.html_safe case state - when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") - when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) - when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) - content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + when 0 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + when 1 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type))) end content = content_tag('ul', content) content_tag('div', content, :class => "tabs_enterprise") - end + end def gender_avatar_uri user img_uri = '/images/sidebar/female.png' @@ -256,7 +256,7 @@ module UsersHelper # people_ids += (members_to_user_ids(tmp)) unless tmp.nil? # end # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin? - + false end @@ -290,7 +290,7 @@ module UsersHelper membership.collect { |e| memberships.push(e) } - ## 鍒ゆ柇璇剧▼鏄惁杩囨湡 [闇灏佽] + ## 鍒ゆ柇璇剧▼鏄惁杩囨湡 [闇灏佽] memberships_doing = [] memberships_done = [] memberships.map { |e| @@ -544,9 +544,13 @@ module UsersHelper #鑾峰彇鎸囧畾鐢ㄦ埛浣滀负鑰佸笀鐨勮绋 def get_as_teacher_courses user type = [] + option = [] + option << "璇烽夋嫨鍙戝竷浣滀笟鐨勮绋" + option << -1 + type << option user.courses.select{|c| user.allowed_to?(:as_teacher,c)}.each do |course| option = [] - option << course.name + option << course.name+"锛"+course.time.to_s+course.term+"锛" option << course.id type << option end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 217c7d770..1c066495f 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -56,4 +56,6 @@ class HomeworkCommon < ActiveRecord::Base Mailer.run.homework_added(self) end + delegate :language_name, :to => :homework_detail_programing + end diff --git a/app/models/homework_detail_programing.rb b/app/models/homework_detail_programing.rb index 4c7134806..e5938d091 100644 --- a/app/models/homework_detail_programing.rb +++ b/app/models/homework_detail_programing.rb @@ -2,4 +2,8 @@ class HomeworkDetailPrograming < ActiveRecord::Base attr_accessible :language, :standard_code, :homework_common_id belongs_to :homework_common + + def language_name + %W(c c++).at(self.language.to_i - 1) + end end diff --git a/app/models/homework_test.rb b/app/models/homework_test.rb index df2848194..b4d8a4262 100644 --- a/app/models/homework_test.rb +++ b/app/models/homework_test.rb @@ -2,5 +2,4 @@ class HomeworkTest < ActiveRecord::Base attr_accessible :input, :output, :homework_common_id,:result,:error_msg belongs_to :homework_common - has_many :student_work_test end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index b95c11c11..6e39c954a 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -7,7 +7,7 @@ class StudentWork < ActiveRecord::Base has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project - has_many :student_work_test + has_many :student_work_tests, order: 'id desc' before_destroy :delete_praise diff --git a/app/models/student_work_test.rb b/app/models/student_work_test.rb index 413528b82..96aa1d6c3 100644 --- a/app/models/student_work_test.rb +++ b/app/models/student_work_test.rb @@ -1,12 +1,12 @@ # encoding: utf-8 class StudentWorkTest < ActiveRecord::Base - attr_accessible :student_work_id, :homework_test_id, :result, :error_msg - - belongs_to :homework_test + attr_accessible :student_work_id, :results, :status, :src belongs_to :student_work + serialize :results, Array + def status_to_s - case self.result.to_i + case self.status.to_i when -1 '缂栬瘧鍑洪敊' when -2 @@ -33,10 +33,11 @@ class StudentWorkTest < ActiveRecord::Base end def test_score - if self.result.to_i == 0 + if self.status.to_i == 0 format("%.1f",100.0 / self.student_work.homework_common.homework_tests.count) else 0 end end + end diff --git a/app/views/account/about_us.html.erb b/app/views/account/about_us.html.erb new file mode 100644 index 000000000..2d21783ce --- /dev/null +++ b/app/views/account/about_us.html.erb @@ -0,0 +1,50 @@ +<%= stylesheet_link_tag 'new_user'%> +
+

鍏充簬鎴戜滑

+
+

+ Trustie鏄竴涓潰鍚戦珮鏍″垱鏂板疄璺电殑鍦ㄧ嚎鍗忎綔绀惧尯锛屾槸鍦ㄤ腑鍥介珮鏍℃帹琛屽ぇ瑙勬ā寮鏀惧湪绾跨爺绌讹紙Massive Open Online Research, MOORE锛夌殑鏀拺骞冲彴锛屼篃绠绉癟rustie骞冲彴銆傝佸笀銆佸鐢熷拰绉戠爺浜哄憳鍙互鍦ㄦ寮灞曞悇绉嶅湪绾垮崗鍚屽涔犮佸崗鍚屼綔涓氥佸崗鍚屽紑鍙戠瓑娲诲姩銆 +

+

+ MOORE鏄浗闃茬瀛︽妧鏈ぇ瀛︽潹瀛﹀啗闄㈠+鎻愬嚭鐨勪竴涓潰鍚戦珮鏍$鐮旀暀瀛︽椿鍔ㄧ殑鏂板瀷鍒涙柊瀹炶返姒傚康锛屼负鍏ㄩ潰鏀寔楂樻牎浜烘墠鍩瑰吇鍜岀瀛︾爺绌舵彁渚涗簡涓绉嶆柊鎬濊矾銆侻OORE鏄澶ц妯″湪绾垮紑鏀捐绋嬶紙Massive Open Online Course, MOOC锛夌殑鎷撳睍锛屾槸璇惧爞鏁欏涓庡垱鏂板疄璺垫繁搴︾粨鍚堢殑鍏ㄦ柊妯″紡锛屽彲浠ョ湅浣淢OOC2.0銆 +

+

+ 2005骞村紑濮嬶紝Trustie鐮斿埗鍥㈤槦鍥寸粫缃戠粶鏃朵唬鐨勮蒋浠跺紑鍙戞晥鐜囧拰璐ㄩ噺杩欎竴鏍稿績闂灞曞紑鐮旂┒锛岀粡杩囧崄骞寸殑纾ㄧ牶涓庢敾鍏筹紝閫愭鎻ず鍑轰互澶т紬鍖栧崗鍚屽紑鍙戙佸紑鏀惧紡璧勬簮鍏变韩銆佹寔缁у彲淇¤瘎浼颁负鏍稿績鐨勪簰鑱旂綉澶ц妯″崗鍚屾満鐞嗭紝鎻愬嚭浜嗗叏鏂扮殑杞欢寮鍙戠兢浣撳寲鏂规硶銆2008骞磋捣锛岀爺鍒跺洟闃熷紑濮嬫帰绱㈠浣曞皢杩欑鍗忓悓鏈虹悊寮曞叆杞欢浜烘墠鍩瑰吇銆侻OORE姒傚康鐨勬彁鍑轰负鐮斿埗鍥㈤槦鐨勪汉鎵嶅煿鍏诲疄璺垫彁渚涗簡鏂扮殑鍙戝睍鏂瑰悜鍜屽簲鐢ㄦā寮忥紝浣縏rustie鎶鏈拰宸ュ叿鑳藉鏇寸洿鎺ャ佹洿鏈夋晥鍦颁笌楂樻牎浜烘墠鍩瑰吇瀵规帴锛屽舰鎴愪簡浠婂ぉ宸茶澶ч噺甯堢敓鎺ュ彈鐨勫湪绾夸汉鎵嶅煿鍏诲钩鍙般 +

+

+ 鐮斿埗鍥㈤槦璁や负MOORE鐨勫垱鏂颁汉鎵嶅煿鍏绘ā寮忥紙濡傚浘1宸﹀浘锛夋槸灏嗕簰鑱旂綉澶ц妯″崗鍚屾満鐞嗕笌楂樻牎鍒涙柊瀹炶返娲诲姩鐩哥粨鍚堢殑鍏ㄦ柊浜烘墠鍩瑰吇鏂规硶鍜屾ā寮忥紝鐮斿埗鍥㈤槦骞跺熀浜庢湰骞冲彴鐨勬灦鏋勫舰鎴愪簡瀵筂OORE鏍稿績鏈虹悊鐨勪笁鏂归潰璁よ瘑锛堝鍥1鍙冲浘锛夈 +

+
+ +

鍥1 鍩轰簬MOORE鐨勫垱鏂颁汉鎵嶅煿鍏绘ā寮忎笌鏍稿績鏈虹悊

+
+

+ 鐩墠锛孴rustie骞冲彴宸茬粡鍒濇灞曠幇鍑哄ぇ瑙勬ā寮鏀惧湪绾跨爺绌剁殑鐢熸佺郴缁熻摑鍥撅紝鍏舵牳蹇冩槸鍦ㄧ嚎鏁欏瀹炶返骞冲彴鍜屽湪绾垮崗鍚岀爺绌跺钩鍙帮紝濡傚浘2銆俆rustie鍦ㄧ嚎鏁欏瀹炶返骞冲彴鏄敮鎸佹暀甯堝拰瀛︾敓鍥寸粫璇惧爞瀛︿範寮灞曞疄璺电殑骞冲彴锛堝鍥2锛夛紝Trustie鍦ㄧ嚎鍗忓悓鐮旂┒骞冲彴鏄敮鎸佸紑鍙戝皬缁勫洿缁曞疄璺典换鍔℃垨鐮旂┒宸ヤ綔寮灞曞垎甯冨紡鍗忎綔鐨勫钩鍙帮紙濡傚浘2锛夈備袱涓牳蹇冨钩鍙颁负涓鍚"鏂版墜"澶у鐢熸垚闀夸负鍏锋湁涓瀹氬垱鏂拌兘鍔涚殑"鍒涘"鎻愪緵浜嗕粠瀛︿範鍒扮爺绌剁殑涓涓笎杩涘紡鎴愰暱鐜锛堝鍥2锛夈 +

+

+ 鐗瑰埆鏄紝鏍规嵁甯堢敓鐨勫疄闄呴渶瑕侊紝Trustie骞冲彴鎻愪緵浜嗙鏈夋ā寮忓拰鍏紑妯″紡锛屾敮鎸侀拡瀵规湭鍏紑鎴愭灉瀹炴柦鏈夋晥鐭ヨ瘑浜ф潈淇濇姢涓哄墠鎻愮殑浜ゆ祦鍒嗕韩锛堝鍥2锛夈傞殢鐫瓒婃潵瓒婂鐨勯珮鏍°佽绋嬪拰鐮旂┒灏忕粍鐨勫姞鍏ワ紝MOORE鍒涙柊瀹炶返妯″紡鐨勭敓鎬佹晥鐩婂皢涓嶆柇鏄剧幇鍑烘潵銆 +

+
+ +

鍥2 鍩轰簬MOORE鐨勬敮鎾戝钩鍙板拰鐢熸佺郴缁

+
+

+ 鐮斿埗鍥㈤槦鐗瑰埆鎰熻阿楂樻牎鑰佸笀鍜屽鐢熺殑绉瀬鍙嶉銆佹棤绉佸垱鎰忋傚钩鍙扮殑寰堝瀹炵敤渚挎嵎鐨勫姛鑳介兘鏄佸笀浠Н鏋佸弬涓庡拰璁捐鐨勭粨鏋滐紝姹囪仛浜嗗ぇ閲忓笀鐢熺殑瀹濊吹璐$尞锛屾槸鐮斿埗鍥㈤槦鍜岀敤鎴风兢浣撳叡鍚屾垚闀跨殑缁撴灉銆 +

+

+ Trustie骞冲彴鐨勫熀鏈濊矾鏄皢寮婧愭ā寮忎笌涓浗楂樻牎浜烘墠鍩瑰吇娲诲姩鐩哥粨鍚堬紝浣嗗叾鏈川涓婃槸涓绉峅2O锛圤nline To Offline锛夌殑鍒涙柊浜烘墠鍩瑰吇妯″紡锛屽彧鏈夊湪浠ヤ笅涓や釜鏂归潰鍚屾鎺ㄨ繘锛屾墠鑳藉湪鎸佺画瑙e喅瀹為檯闇姹傜殑杩囩▼涓揩閫熷彂灞曪細
+     锛1锛夋瀯寤哄疄璺靛钩鍙帮紝婵娲诲垱鏂拌兘鍔涳細鎴愪负鏀寔涓嶅悓瑙勬ā鐨勫洟闃熻繘琛屽崗鍚岀爺绌跺拰鍗忓悓寮鍙戠殑瀹炶返骞冲彴锛屾敮鎸佸悇绫诲彲鍏紑鐨勮绋嬪疄楠屼换鍔°佹暀鐮斿绉戠爺浠诲姟鐨勫湪绾垮崗鍚岋紝鑳藉鏈夋晥鎻愬崌鍜岃瘎浼板鐢熺殑鍒涙柊鑳藉姏銆佸崗浣滆兘鍔涘拰瀹炶返鑳藉姏銆
+     锛2锛夊紩鍏ュ紑婧愮悊蹇碉紝褰㈡垚鍒涘鏂囧寲锛氬皢浜掕仈缃戝紑婧愯蒋浠惰繍鍔ㄤ腑鐨勮嚜鐢便佸绛夈佸叡浜佸垱鏂扮殑鐞嗗康寮曞叆楂樻牎锛屼娇"鑷富鍒涙剰骞朵翰鑷姩鎵嬪疄鐜板垱鎰"鐨勫垱瀹㈢簿绁炴繁鍏ヤ汉鎵嶅煿鍏绘椿鍔紝鍦ㄥ鐢熺兢浣撲腑褰㈡垚澶ц儐鍒涙剰銆佸ぇ鑳嗗疄璺电殑鍒涙柊鏂囧寲銆 +

+

+ 鐮斿埗鍥㈤槦璁や负锛孴rustie骞冲彴鏄竴绉"浜掕仈缃+"鎬濈淮鍦ㄩ珮鏍℃暀鑲查鍩熺殑澶у瀷鎺㈢储鎬у疄璺点備綔涓轰竴绉嶄簰鑱旂綉搴旂敤锛孴rustie骞冲彴鑷韩鐨勫紑鍙戜篃閲囧彇浜嗕簰鑱旂綉妯″紡锛歍rustie鐮斿埗鍥㈤槦閲囩敤浜"缃戞瀯鍖栬蒋浠跺紑鍙戞ā寮"锛屽潥鎸"姣忓懆涓鏇"鐨勫揩閫熶笂绾裤佸揩閫熶綋楠屾ā寮忥紝浠ユ渶澶х▼搴︿笂璐磋繎鐢ㄦ埛瀹為檯闇姹傛彁鍗囥傛杩庨珮鏍″笀鐢熶竴鍚屾姇韬垱鏂板疄璺碉紝鍏卞悓瑙佽瘉MOORE鍒涙柊鐢熸佺殑鏃╂棩褰㈡垚銆 +

+
+ + + +
+ + + + diff --git a/app/views/account/lost_password.html.erb b/app/views/account/lost_password.html.erb index 0e4ddd1ff..5bf93fd14 100644 --- a/app/views/account/lost_password.html.erb +++ b/app/views/account/lost_password.html.erb @@ -1,6 +1,6 @@ <%= stylesheet_link_tag 'new_user'%> -
+

蹇樿瀵嗙爜

@@ -9,7 +9,7 @@ <%= text_field_tag 'mail', nil, :size => 40, :placeholder => '璇疯緭鍏ユ敞鍐岄偖绠',:class=>'NomalInput mb20'%> <% if flash[:error] %> -

<%= flash[:error]%>

+

<%= flash[:error]%>

<% elsif flash[:notice] %>

<%= flash[:notice]%>

diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index b8bbf3d63..f117acd7f 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -37,7 +37,7 @@ <% @topics.each do |topic| %>
<%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> -
+
<% author = topic.author.to_s %>
<%= link_to User.current.member_of_course?(@board.course) ? "#{topic.author.show_name}(#{topic.author.login})" : "#{topic.author}" , user_path(topic.author), @@ -48,7 +48,7 @@

  <%= h(topic.subject) %>

<% if topic.course_editable_by?(User.current) %> - <%= l(:button_edit) %> <% end %> @@ -120,7 +120,7 @@ <%= l(:label_activity_time)%>锛  <%= format_time topic.created_on %>
- <%= l(:button_reply) %> + <%= l(:button_reply) %>
@@ -171,7 +171,7 @@

- <%= format_time(message.created_on) %> + <%= format_time(message.created_on) %> <%= link_to( l(:button_delete), @@ -179,13 +179,13 @@ :method => :post, :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete), - :class => ' c_dblue fr f14' + :class => ' linkBlue fr f12' ) if message.course_destroyable_by?(User.current) %> <%= link_to( l(:button_reply), 'javascript:;', :nhname =>'showbtn_child_reply', - :class => ' c_dblue fr f14', + :class => ' linkBlue fr f12', :style => 'margin-right: 10px;', 'data-topic-id' =>message.id, :title => l(:button_reply)) if !topic.locked? && authorize_for('messages', 'reply') %> diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb new file mode 100644 index 000000000..dd3c3dfb2 --- /dev/null +++ b/app/views/comments/create.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); + +init_KindEditor_data('<%= @user_activity_id%>'); diff --git a/app/views/courses/search.html.erb b/app/views/courses/search.html.erb index c19f9821a..e7f344df2 100644 --- a/app/views/courses/search.html.erb +++ b/app/views/courses/search.html.erb @@ -20,12 +20,12 @@ <% end %> <% end %> - + diff --git a/app/views/homework_common/_new_homework_detail_manual_form.html.erb b/app/views/homework_common/_new_homework_detail_manual_form.html.erb new file mode 100644 index 000000000..7fb728ad0 --- /dev/null +++ b/app/views/homework_common/_new_homework_detail_manual_form.html.erb @@ -0,0 +1,74 @@ +
+
+
+
鍙戝竷浣滀笟
+
+
+
+ +
+
+ 瀵煎叆浣滀笟 + +
+ +
+
+
+
+ <% if edit_mode %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %> + <% else %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= f.kindeditor :description,:editor_id => 'homework_description_editor' %> + <% end %> +
+
+ +
+ + + + +
+ 鍙戝竷 + <%= link_to '鍙栨秷',homework_common_index_path(:course => @course.id),:class => 'fr mr10 mt3'%> +
+
+
+
+ +
+ + + diff --git a/app/views/homework_common/new.html.erb b/app/views/homework_common/new.html.erb index 6fc0fff0e..f5fb595e1 100644 --- a/app/views/homework_common/new.html.erb +++ b/app/views/homework_common/new.html.erb @@ -1,17 +1,16 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<% content_for :header_tags do %> + <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> + <%= javascript_include_tag 'homework','baiduTemplate' %> +<% end %> + <%= error_messages_for 'homework_common' %> -
-

- <%= l(:label_course_homework_new)%> -

-
+
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %> <%= hidden_field_tag "course",@course.id%> - <%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> - 鎻愪氦 - <%#= link_to "涓婁竴姝", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%> - <%= link_to '鍙栨秷',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%> + <%= render :partial => 'homework_common/new_homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %> <% end%>
+ +
diff --git a/app/views/homework_common/next_step.html.erb b/app/views/homework_common/next_step.html.erb index e84d0f87a..7ed852fea 100644 --- a/app/views/homework_common/next_step.html.erb +++ b/app/views/homework_common/next_step.html.erb @@ -1,4 +1,4 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> <%= error_messages_for 'homework_common' %>

diff --git a/app/views/issues/add_journal.js.erb b/app/views/issues/add_journal.js.erb new file mode 100644 index 000000000..efa5750c2 --- /dev/null +++ b/app/views/issues/add_journal.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); + +init_KindEditor_data(<%= @user_activity_id%>); \ No newline at end of file diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 720ff3e8f..d6368b4a0 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -1,9 +1,9 @@ -
鎴鏃堕棿锛<%= format_date(activity.end_time) %>

-
+
浣滀笟鎻忚堪锛<%= activity.description.html_safe %>
- - +
+
+ <% count=0 %> +
鍥炲( + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> <% end %> + <%= count %> + )
+
<%#=format_date(activity.updated_on)%>
+ <%if count > 2 %> + + <% end %> +
+ +
+
+ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +

+
+ 鍙栨秷 + 鍙戦 + <% end%>
+
+ + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> +
+
    + <% activity.children.reorder("created_on desc").each do |reply|%> + <% replies_all_i=replies_all_i+1 %> +
  • +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => "45", :height => "45"), user_path(reply.author_id), :alt => "鐢ㄦ埛澶村儚" %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_date(reply.created_on) %> +
    +
    + <%= reply.content.html_safe %> +
    +
    +
    +
  • + <% end %> +
+
+ <% end %> +
+
diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index 78478aee4..7edc19681 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -1,4 +1,4 @@ -
+
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "鐢ㄦ埛澶村儚" %> @@ -18,56 +18,50 @@
鍙戝竷鏃堕棿锛<%= format_date(activity.created_on) %>
-
閫氱煡鎻忚堪锛<%= activity.description.html_safe %>
- -
- <% count=activity.comments_count %> -
鍥炲锛<%= count %>锛
+ <% count=activity.comments.count %> +
+ 鍥炲锛<%= count %>锛 +
<%#= format_date(activity.updated_on) %>
<%if count>2 %> - + <% end %> -
- <%#= render :partial => 'course_news_reply',:locals => { :contest => @contest, :journals => @jour, :state => false}%> - <% replies_all_i = 0 %> - <% unless activity.comments.empty? %> -
+ <% if count > 0 %> +
    <% activity.comments.reorder("created_on desc").each do |comment| %> - <% replies_all_i=replies_all_i+1 %> -
  • + <% replies_all_i = replies_all_i + 1 %> +
  • <%= link_to image_tag(url_to_avatar(comment.author), :width => "45", :height => "45"), user_path(comment.author_id), :alt => "鐢ㄦ埛澶村儚" %>
    @@ -79,9 +73,6 @@ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_date(comment.created_on) %> - <%#= link_to_if_authorized_course l(:button_delete), {:controller => 'comments', :action => 'destroy', :id => activity, :comment_id => comment}, - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %> -
<%= comment.comments.html_safe %>
@@ -90,6 +81,6 @@ <% end %>
- <% end %> + <% end %>
\ No newline at end of file diff --git a/app/views/users/_course_poll.html.erb b/app/views/users/_course_poll.html.erb index a6f21a97f..15e549ad8 100644 --- a/app/views/users/_course_poll.html.erb +++ b/app/views/users/_course_poll.html.erb @@ -28,8 +28,8 @@
鍙戝竷鏃堕棿锛<%= format_date(activity.published_at) %>
-
闂嵎鎻忚堪锛<%=activity.polls_description.html_safe.to_s%>
- diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index b41b9f28f..ab49fd9d6 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -1,22 +1,25 @@ <% if attachments.nil? || attachments.empty? %> + + + <% else %> <% attachments.each do |attach| %> -
    -
  • - -
  • -
  • - - <%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename), - :title => attach.filename,:class=>'resourcesBlack'%> -
  • -
  • <%= number_to_human_size(attach.filesize) %>
  • -
  • <%= get_resource_type(attach.container_type)%>
  • -
  • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
  • -
  • <%= attach.author_id %>
  • -
  • <%= format_date(attach.created_on) %>
  • -
  • <%= attach.id %>
  • -
- <% end %> +
    +
  • + +
  • +
  • + + <%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename), + :title => attach.filename,:class=>'resourcesBlack'%> +
  • +
  • <%= number_to_human_size(attach.filesize) %>
  • +
  • <%= get_resource_type(attach.container_type)%>
  • +
  • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
  • +
  • <%= attach.author_id %>
  • +
  • <%= format_date(attach.created_on) %>
  • +
  • <%= attach.id %>
  • +
+ <% end %> <% end %> diff --git a/app/views/users/_show_user_resource.html.erb b/app/views/users/_show_user_resource.html.erb index a27a51d65..a3c82d995 100644 --- a/app/views/users/_show_user_resource.html.erb +++ b/app/views/users/_show_user_resource.html.erb @@ -1,26 +1,67 @@ -
+ +
-
璧勬簮搴
+
寮曠敤璧勬簮搴撹祫婧
+
+
+ +
+ + <%= form_tag(user_ref_resource_search_user_path(user),:method => 'get',:remote=>'true',:class=>'referenceSearchBox') do%> + + + <% end %> + +
+
+
+
+
    +
  • +
  • 璧勬簮鍚嶇О
  • +
  • 澶у皬
  • +
  • 绫诲埆
  • +
  • 涓婁紶鑰
  • +
  • 涓婁紶鏃堕棿
  • +
+
+ <%= form_tag(import_resources_to_homework_user_path(user),:method => 'post',:remote=>'true') do %> + +
+ <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
-
-
- - -
+
    + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true%> +
+
+ - <%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %> -
- <%= render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks}%> -
-
-
- 纭畾 -
-
- 鍙栨秷 -
-
- <% end%>
-
\ No newline at end of file + <% end %> + diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index b43d0d54e..2eba84efa 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -1,51 +1,21 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> + <% user_activities.each do |user_activity| - unless user_activities.nil? %> + if user_activities %> <% act= user_activity.act unless user_activity.act_type == "ProjectCreateInfo" %> <% case user_activity.container_type.to_s %> @@ -65,41 +39,26 @@ <% if act %> <% case user_activity.act_type.to_s %> <% when 'HomeworkCommon' %> - <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity =>user_activity} %> + <%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'News' %> - <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity =>user_activity} %> + <%= render :partial => 'course_news', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'Message'%> - <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Course'%> - <%#= render :partial => 'course_create', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Attachment' %> - <%#= render :partial => 'course_attachment', :locals => {:activity => act, :user_activity => user_activity} %> - <%# when 'JournalsForMessage' %> - <%#= render :partial => 'course_journalsformessage', :locals => {:activity => act, :user_activity => user_activity} %> + <%= render :partial => 'course_message', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'Poll' %> - <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity => user_activity} %> + <%= render :partial => 'course_poll', :locals => {:activity => act, :user_activity_id => user_activity.id} %> <% end %> <% end %> <% when 'Project' %> <% if act %> <% case user_activity.act_type.to_s %> <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity =>user_activity} %> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% when 'Message' %> - <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Journal' %> - <%#= render :partial => 'project_journal', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'News' %> - <%#= render :partial => 'project_news', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Document' %> - <%#= render :partial => 'project_document', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'Attachment' %> - <%#= render :partial => 'project_attachment', :locals => {:activity => act,:user_activity =>user_activity} %> - <%# when 'ProjectCreateInfo' %> - <%#= render :partial => 'project_create', :locals => {:activity => act,:user_activity =>user_activity} %> + <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% end %> <% end %> <% end %> <% end %> <% end %> - \ No newline at end of file + +<%= link_to "鐐瑰嚮灞曞紑鏇村",user_activities_path(@user.id,:type => type),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index 1613b144e..00d80dd22 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -46,8 +46,9 @@
+ 涓婁紶闄勪欢 - <%#= link_to "璧勬簮搴", user_import_resource_user_path(User.current.id),:class => "FilesBtn fl mr15 mt3",:remote => true%> + <%= link_to "璧勬簮搴",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mr15 mt3",:remote => true%>
<% content_for :header_tags do %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 8340306e0..4a38e630b 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -1,7 +1,11 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor" %> +<% content_for :header_tags do %> + <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> + <%= javascript_include_tag 'homework','baiduTemplate' %> +<% end %> +
- +

@@ -9,36 +13,75 @@
<%= link_to "瀵煎叆浣滀笟", user_import_homeworks_user_path(User.current.id),:class => "BlueCirBtn fl mr10",:remote => true%>
- + <%= calendar_for('homework_end_time')%>
+ -
\ No newline at end of file +
+ + diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index faa09ef70..fc6e723f2 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -53,4 +53,5 @@
<% end%> - \ No newline at end of file + +<%= link_to "鍔犺浇鏇村",user_homeworks_user_path(User.current.id),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> \ No newline at end of file diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb index 08737f5ca..c61790c40 100644 --- a/app/views/users/add_exist_file_to_course.js.erb +++ b/app/views/users/add_exist_file_to_course.js.erb @@ -1,4 +1,9 @@ <% if @flag == true%> +$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); +$("#res_all_count").html(<%= @atta_count%>); closePopUp(); <% else%> <% end %> \ No newline at end of file diff --git a/app/views/users/add_exist_file_to_project.js.erb b/app/views/users/add_exist_file_to_project.js.erb index 08737f5ca..c61790c40 100644 --- a/app/views/users/add_exist_file_to_project.js.erb +++ b/app/views/users/add_exist_file_to_project.js.erb @@ -1,4 +1,9 @@ <% if @flag == true%> +$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#res_count").html(0); +$("#checkboxAll").attr('checked',false); +$("#res_all_count").html(<%= @atta_count%>); closePopUp(); <% else%> <% end %> \ No newline at end of file diff --git a/app/views/users/import_resources_to_homework.js.erb b/app/views/users/import_resources_to_homework.js.erb new file mode 100644 index 000000000..b77590095 --- /dev/null +++ b/app/views/users/import_resources_to_homework.js.erb @@ -0,0 +1,16 @@ +<% unless @attachments.empty?%> + <% @attachments.each_with_index do |attachment, i| %> + $("#attachments_fields").append( + ''+ + '<%= 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 %> + hideModal(); +<% end %> \ No newline at end of file diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb new file mode 100644 index 000000000..a150c39ba --- /dev/null +++ b/app/views/users/new_user_commit_homework.html.erb @@ -0,0 +1,117 @@ +<% content_for :header_tags do %> + <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> + <%= javascript_include_tag 'homework','baiduTemplate' %> +<% end %> + + + + + +
+
+
+
鎻愪氦浣滃搧
+
+
+
+
<%= @homework.name %>
鎴鏃堕棿锛<%= @homework.end_time %> +
+ <%= @homework.user.show_name %> +

<%= @homework.description %>
+杈撳叆 2 1 1 4 4 2 3 6 5
+杈撳嚭 15
+

+
+

娉細杩熶氦鎵2鍒嗭紝缂鸿瘎涓涓綔鍝佹墸2

+
+
+ <%= form_for(@student_work, + :html => { :multipart => true }, + :url => {:controller => 'users', + :action => 'user_commit_homework', + :student_work_id => @student_work.id, + :homework => @homework.id + }, + :method => :post) do |f|%> + +
+ 璇蜂娇鐢 <%= @homework.language_name %> 璇█缂栧啓 +
+
+ <%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"璇锋鎷綘鐨勪唬鐮佺殑鍔熻兘" %> +
+
+ <%= f.text_area :description, id: 'program-src', class:" W700 H150", placeholder:"璇疯创鍏ヤ綘鐨勪唬鐮", rows: 10 %> +
+ + <% end %> +
+
+
+ <% @student_work.student_work_tests.each_with_index do |test, index| %> +
+

绗<%= @student_work.student_work_tests.count - index%>娆℃祴璇

<%= test.created_at.to_s(:db) %> +
+
+ <% if test.status.to_i == -2 %> +
<%= test.results.first %>
+ <% else %> +
+
    + <% test.results.each_with_index do |x, i| %> +
  • 娴嬭瘯<%=i+1%> + <% if x["status"].to_i != 0 %> + 娴嬭瘯閿欒锛 + 鎮ㄧ殑杈撳嚭锛 + <%=x["result"]%> + 姝g‘杈撳嚭锛 + <%=x["output"]%> +
    +
  • + <% else %> + 娴嬭瘯姝g‘锛 +
    + + <% end %> + <% end %> +
+
+ <% end %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 74ca48595..fe916331f 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,19 +1,3 @@ - -
@@ -55,4 +39,4 @@
-<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0} %> \ No newline at end of file +<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type} %> \ No newline at end of file diff --git a/app/views/users/show.js.erb b/app/views/users/show.js.erb index 0ce84cf0e..bf7443f8c 100644 --- a/app/views/users/show.js.erb +++ b/app/views/users/show.js.erb @@ -1,4 +1,4 @@ -$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page} )%>"); +$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type} )%>"); <% if @user_activities.count < 10%> -$(window).off("scroll", scrollHandler); +$("#show_more_activities").hide(); <% end%> diff --git a/app/views/users/user_commit_homework.html.erb b/app/views/users/user_commit_homework.html.erb new file mode 100644 index 000000000..a7416cf40 --- /dev/null +++ b/app/views/users/user_commit_homework.html.erb @@ -0,0 +1,114 @@ + + + + + + +
+
+
+
鎻愪氦浣滃搧
+
+
+
+
<%= @homework.name %>
鎴鏃堕棿锛<%= @homework.end_time %> +
+ <%= @homework.user.show_name %> +

<%= @homework.description %>
+杈撳叆 2 1 1 4 4 2 3 6 5
+杈撳嚭 15
+

+
+

娉細杩熶氦鎵2鍒嗭紝缂鸿瘎涓涓綔鍝佹墸2

+
+
+ <%= form_for(@student_work, + :html => { :multipart => true }, + :url => {:controller => 'student_work', + :action => 'create', + :student_work_id => @student_work.id, + :homework => @homework.id + }, + :method => :post) do |f|%> + +
+ 璇蜂娇鐢 <%= @homework.language_name %> 璇█缂栧啓 +
+
+ <%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"璇锋鎷綘鐨勪唬鐮佺殑鍔熻兘" %> +
+
+ <%= f.text_area :description, id: 'program-src', class:" W700 H150", placeholder:"璇疯创鍏ヤ綘鐨勪唬鐮", rows: 10 %> +
+ + <% end %> +
+
+
+ <% @student_work.student_work_tests.each_with_index do |test, index| %> +
+

绗<%= @student_work.student_work_tests.count - index%>娆℃祴璇

<%= test.created_at.to_s(:db) %> +
+
+ <% if test.status.to_i == -2 %> +
<%= test.results.first %>
+ <% else %> +
+
    + <% test.results.each_with_index do |x, i| %> +
  • 娴嬭瘯<%=i+1%> + <% if x["status"].to_i != 0 %> + 娴嬭瘯閿欒锛 + 鎮ㄧ殑杈撳嚭锛 + <%=x["result"]%> + 姝g‘杈撳嚭锛 + <%=x["output"]%> +
    +
  • + <% else %> + 娴嬭瘯姝g‘锛 +
    + + <% end %> + <% end %> +
+
+ <% end %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 74e4df4f0..a935af2f5 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -1,35 +1,26 @@ +
+
+
浣滀笟
+
+
+
<% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> -
-
-
鍙戝竷浣滀笟
-
-
-
-
<% homework = HomeworkCommon.new %> <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %> @@ -38,14 +29,6 @@
<% end%>
- -<%else%> -
-
-
浣滀笟
-
-
-
<% end%> <%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0} %> diff --git a/app/views/users/user_import_resource.js.erb b/app/views/users/user_import_resource.js.erb index ce70d68ad..dc3682d30 100644 --- a/app/views/users/user_import_resource.js.erb +++ b/app/views/users/user_import_resource.js.erb @@ -1,7 +1,8 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_homeworks') %>'); -showModal('ajax-modal', '580px'); -$('#ajax-modal').css('height','300px').css("width","580px"); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_resource',:locals => {:user => @user,:homework_id=>@homework_id}) %>'); +showModal('ajax-modal', '730px'); +$('#ajax-modal').css('height','500px').css("width","730px"); $('#ajax-modal').siblings().remove(); -$('#ajax-modal').before("" + -""); -$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed"); \ No newline at end of file +$('#ajax-modal').before("
" + +"
"); +$('#ajax-modal').parent().css("top","").css("left","").css("position","fixed").css("padding-left","16px").css("padding-bottom","16px").css("padding-right","16px"); +$('#ajax-modal').parent().addClass("popbox").addClass("referenceResourcesPopup"); \ No newline at end of file diff --git a/app/views/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index 556069a1f..c8196c90f 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -1,11 +1,6 @@ - - - - - - - +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor","user" %> -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"user" %> - - - -
@@ -38,8 +23,8 @@

- 鍙栨秷 - 鐣欒█ + 鍙栨秷 + 鐣欒█ <% end%>
diff --git a/app/views/users/user_ref_resource_search.js.erb b/app/views/users/user_ref_resource_search.js.erb new file mode 100644 index 000000000..52f54bee4 --- /dev/null +++ b/app/views/users/user_ref_resource_search.js.erb @@ -0,0 +1,2 @@ +$("#user_ref_resources").html('<%= escape_javascript(render :partial => 'resources_list',:locals=>{:attachments => @attachments})%>'); +$("#resource_ref_pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 2ecda7758..c0049db88 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -4,9 +4,9 @@ <%= stylesheet_link_tag 'leftside' %> <%= javascript_include_tag 'attachments'%> - - - + + + diff --git a/app/views/users/user_resource_type.js.erb b/app/views/users/user_resource_type.js.erb new file mode 100644 index 000000000..52f54bee4 --- /dev/null +++ b/app/views/users/user_resource_type.js.erb @@ -0,0 +1,2 @@ +$("#user_ref_resources").html('<%= escape_javascript(render :partial => 'resources_list',:locals=>{:attachments => @attachments})%>'); +$("#resource_ref_pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file diff --git a/app/views/users/user_select_homework.js.erb b/app/views/users/user_select_homework.js.erb index 945da4c9a..a18fdacc8 100644 --- a/app/views/users/user_select_homework.js.erb +++ b/app/views/users/user_select_homework.js.erb @@ -5,3 +5,4 @@ $("#homework_end_time").val("<%= @homework.end_time%>"); $("#course_id").val("<%= @homework.course_id%>"); $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => @homework })%>"); homework_description_editor.html("<%= escape_javascript(@homework.description.html_safe)%>"); +$("#homework_editor").show(); diff --git a/config/configuration.yml b/config/configuration.yml index ef204a31e..af68515eb 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -199,9 +199,12 @@ default: repository_root_path: '/tmp/htdocs' + judge_server: 'http://judge.trustie.net/' + # specific configuration options for production environment # that overrides the default ones production: + judge_server: 'http://192.168.80.21:8080/' repository_root_path: '/home/pdl/redmine-2.3.2-0/apache2/htdocs' cookie_domain: ".trustie.net" rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 48502f014..4a6ddce4e 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2075,7 +2075,8 @@ zh: label_contact_us: 鑱旂郴鎴戜滑 label_recruitment_information: 鎷涜仒淇℃伅 label_surpport_group: 甯姪涓績 - label_forums: 璁哄潧鍙嶉 + #label_forums: 璁哄潧鍙嶉 + label_forums: 璐村惂浜ゆ祦 label_language: 璇█ label_license: 婀業CP澶09019772 diff --git a/config/routes.rb b/config/routes.rb index 8451b7365..8454a1c47 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -120,6 +120,7 @@ RedmineApp::Application.routes.draw do get 'absence_penalty_list' get 'evaluation_list' post 'set_program_score' + post 'program_test' end end @@ -171,7 +172,7 @@ RedmineApp::Application.routes.draw do resources :contests, only: [:index] do resources :contestnotifications do # get 'preview', on: :collection - resources :notificationcomments + resources :notificationcomments end collection do @@ -232,7 +233,7 @@ RedmineApp::Application.routes.draw do end end end - + resources :shares @@ -263,6 +264,7 @@ RedmineApp::Application.routes.draw do match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post] match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post] match 'agreement',:to => 'account#agreement',:as => 'agreement',:via=>[:get] + match 'about_us',:to=>'account#about_us',:as=>'about_us',:via=>[:get] match 'account/register', :via => [:get, :post], :as => 'register' match 'account/lost_password', :via => [:get, :post], :as => 'lost_password' match 'account/activate', :via => :get @@ -309,8 +311,11 @@ RedmineApp::Application.routes.draw do collection do match "tag_saveEx" , :via => [:get, :post] post "user_new_homework" + get 'new_user_commit_homework' + post "user_commit_homework" post 'user_select_homework' end + member do match 'user_projects_index', :to => 'users#user_projects_index', :via => :get match 'user_projects', :to => 'users#user_projects', :via => :get @@ -365,7 +370,10 @@ RedmineApp::Application.routes.draw do get 'resource_preview' post 'rename_resource' get 'search_user_project' - # end + get 'user_resource_type' + get 'user_ref_resource_search' + post 'import_resources_to_homework' + # end end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" @@ -479,7 +487,7 @@ RedmineApp::Application.routes.draw do collection do match "getattachtype" , :via => [:get, :post] match "search_project",:via => [:post,:get] - #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] + #match 'getattachtype/:attachtype', :to => 'files#getattachtype', :via => [:get, :post] end end @@ -509,7 +517,7 @@ RedmineApp::Application.routes.draw do resources :repositories, :except => [:index, :show] do member do get 'newrepo', :via => [:get, :post] - # get 'create', :via=>[:get, :post] + # get 'create', :via=>[:get, :post] end end match 'wiki/index', :via => :get @@ -540,6 +548,9 @@ RedmineApp::Application.routes.draw do match 'bulk_edit', :via => [:get, :post] post 'bulk_update' end + member do + post 'add_journal' + end resources :time_entries, :controller => 'timelog' do collection do get 'report' @@ -596,8 +607,8 @@ RedmineApp::Application.routes.draw do :controller => 'repositories', :format => false, :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ } get 'projects/:id/repository/statistics', :to => 'repositories#stats' @@ -614,8 +625,8 @@ RedmineApp::Application.routes.draw do :controller => 'repositories', :format => false, :constraints => { - :action => /(browse|show|entry|raw|annotate|diff)/, - :rev => /[a-z0-9\.\-_]+/ + :action => /(browse|show|entry|raw|annotate|diff)/, + :rev => /[a-z0-9\.\-_]+/ } get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', :controller => 'repositories', @@ -718,7 +729,7 @@ RedmineApp::Application.routes.draw do get 'test_connection', :as => 'try_connection' end collection do - get 'autocomplete_for_new_user' + get 'autocomplete_for_new_user' end end @@ -780,7 +791,7 @@ RedmineApp::Application.routes.draw do collection do match 'chang_read_flag', :via => :get end - end + end end # end of resources :courses match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback' diff --git a/db/migrate/20150828011415_change_student_work_tests.rb b/db/migrate/20150828011415_change_student_work_tests.rb new file mode 100644 index 000000000..7d4459ab6 --- /dev/null +++ b/db/migrate/20150828011415_change_student_work_tests.rb @@ -0,0 +1,13 @@ +class ChangeStudentWorkTests < ActiveRecord::Migration + + def change + change_table :student_work_tests do |t| + t.remove :error_msg + t.remove :result + t.remove :homework_test_id + t.integer :status, default: 9 + t.text :results + end + end + +end diff --git a/db/migrate/20150828155329_add_src_to_student_work_tests.rb b/db/migrate/20150828155329_add_src_to_student_work_tests.rb new file mode 100644 index 000000000..89bd80882 --- /dev/null +++ b/db/migrate/20150828155329_add_src_to_student_work_tests.rb @@ -0,0 +1,5 @@ +class AddSrcToStudentWorkTests < ActiveRecord::Migration + def change + add_column :student_work_tests, :src, :text + end +end diff --git a/public/images/aboutus_01.jpg b/public/images/aboutus_01.jpg new file mode 100644 index 000000000..e53085610 Binary files /dev/null and b/public/images/aboutus_01.jpg differ diff --git a/public/images/aboutus_02.jpg b/public/images/aboutus_02.jpg new file mode 100644 index 000000000..acc6f8e84 Binary files /dev/null and b/public/images/aboutus_02.jpg differ diff --git a/public/images/homepage_icon.png b/public/images/homepage_icon.png index 4478af070..d39624a2e 100644 Binary files a/public/images/homepage_icon.png and b/public/images/homepage_icon.png differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js index ce5a960cf..8e5e38ee4 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -99,13 +99,13 @@ function initFilters(){ $('#filters-table td.field input[type=checkbox]').each(function(){ toggleFilter($(this).val()); }); - $('#filters-table td.field input[type=checkbox]').live('click',function(){ + $('#filters-table td.field input[type=checkbox]').on('click',function(){ toggleFilter($(this).val()); }); - $('#filters-table .toggle-multiselect').live('click',function(){ + $('#filters-table .toggle-multiselect').on('click',function(){ toggleMultiSelect($(this).siblings('select')); }); - $('#filters-table input[type=text]').live('keypress', function(e){ + $('#filters-table input[type=text]').on('keypress', function(e){ if (e.keyCode == 13) submit_query_form("query_form"); }); } diff --git a/public/javascripts/baiduTemplate.js b/public/javascripts/baiduTemplate.js new file mode 100644 index 000000000..2f05969e3 --- /dev/null +++ b/public/javascripts/baiduTemplate.js @@ -0,0 +1,216 @@ +/** + * baiduTemplate绠鍗曞ソ鐢ㄧ殑Javascript妯℃澘寮曟搸 1.0.6 鐗堟湰 + * http://baidufe.github.com/BaiduTemplate + * 寮婧愬崗璁細BSD License + * 娴忚鍣ㄧ幆澧冨崰鐢ㄥ懡鍚嶇┖闂 baidu.template 锛宯odejs鐜鐩存帴瀹夎 npm install baidutemplate + * @param str{String} dom缁撶偣ID锛屾垨鑰呮ā鏉縮tring + * @param data{Object} 闇瑕佹覆鏌撶殑json瀵硅薄锛屽彲浠ヤ负绌恒傚綋data涓簕}鏃讹紝浠嶇劧杩斿洖html銆 + * @return 濡傛灉鏃燿ata锛岀洿鎺ヨ繑鍥炵紪璇戝悗鐨勫嚱鏁帮紱濡傛灉鏈塪ata锛岃繑鍥瀐tml銆 + * @author wangxiao + * @email 1988wangxiao@gmail.com +*/ + +;(function(window){ + + //鍙栧緱娴忚鍣ㄧ幆澧冪殑baidu鍛藉悕绌洪棿锛岄潪娴忚鍣ㄧ幆澧冪鍚坈ommonjs瑙勮寖exports鍑哄幓 + //淇鍦╪odejs鐜涓嬶紝閲囩敤baidu.template鍙橀噺鍚 + var baidu = typeof module === 'undefined' ? (window.baidu = window.baidu || {}) : module.exports; + + //妯℃澘鍑芥暟锛堟斁缃簬baidu.template鍛藉悕绌洪棿涓嬶級 + baidu.template = function(str, data){ + + //妫鏌ユ槸鍚︽湁璇d鐨勫厓绱犲瓨鍦紝濡傛灉鏈夊厓绱犲垯鑾峰彇鍏冪礌鐨刬nnerHTML/value锛屽惁鍒欒涓哄瓧绗︿覆涓烘ā鏉 + var fn = (function(){ + + //鍒ゆ柇濡傛灉娌℃湁document锛屽垯涓洪潪娴忚鍣ㄧ幆澧 + if(!window.document){ + return bt._compile(str); + }; + + //HTML5瑙勫畾ID鍙互鐢变换浣曚笉鍖呭惈绌烘牸瀛楃鐨勫瓧绗︿覆缁勬垚 + var element = document.getElementById(str); + if (element) { + + //鍙栧埌瀵瑰簲id鐨刣om锛岀紦瀛樺叾缂栬瘧鍚庣殑HTML妯℃澘鍑芥暟 + if (bt.cache[str]) { + return bt.cache[str]; + }; + + //textarea鎴杋nput鍒欏彇value锛屽叾瀹冩儏鍐靛彇innerHTML + var html = /^(textarea|input)$/i.test(element.nodeName) ? element.value : element.innerHTML; + return bt._compile(html); + + }else{ + + //鏄ā鏉垮瓧绗︿覆锛屽垯鐢熸垚涓涓嚱鏁 + //濡傛灉鐩存帴浼犲叆瀛楃涓蹭綔涓烘ā鏉匡紝鍒欏彲鑳藉彉鍖栬繃澶氾紝鍥犳涓嶈冭檻缂撳瓨 + return bt._compile(str); + }; + + })(); + + //鏈夋暟鎹垯杩斿洖HTML瀛楃涓诧紝娌℃湁鏁版嵁鍒欒繑鍥炲嚱鏁 鏀寔data={}鐨勬儏鍐 + var result = bt._isObject(data) ? fn( data ) : fn; + fn = null; + + return result; + }; + + //鍙栧緱鍛藉悕绌洪棿 baidu.template + var bt = baidu.template; + + //鏍囪褰撳墠鐗堟湰 + bt.versions = bt.versions || []; + bt.versions.push('1.0.6'); + + //缂撳瓨 灏嗗搴攊d妯℃澘鐢熸垚鐨勫嚱鏁扮紦瀛樹笅鏉ャ + bt.cache = {}; + + //鑷畾涔夊垎闅旂锛屽彲浠ュ惈鏈夋鍒欎腑鐨勫瓧绗︼紝鍙互鏄疕TML娉ㄩ噴寮澶 + bt.LEFT_DELIMITER = bt.LEFT_DELIMITER||'<%'; + bt.RIGHT_DELIMITER = bt.RIGHT_DELIMITER||'%>'; + + //鑷畾涔夐粯璁ゆ槸鍚﹁浆涔夛紝榛樿涓洪粯璁よ嚜鍔ㄨ浆涔 + bt.ESCAPE = true; + + //HTML杞箟 + bt._encodeHTML = function (source) { + return String(source) + .replace(/&/g,'&') + .replace(//g,'>') + .replace(/\\/g,'\') + .replace(/"/g,'"') + .replace(/'/g,'''); + }; + + //杞箟褰卞搷姝e垯鐨勫瓧绗 + bt._encodeReg = function (source) { + return String(source).replace(/([.*+?^=!:${}()|[\]/\\])/g,'\\$1'); + }; + + //杞箟UI UI鍙橀噺浣跨敤鍦℉TML椤甸潰鏍囩onclick绛変簨浠跺嚱鏁板弬鏁颁腑 + bt._encodeEventHTML = function (source) { + return String(source) + .replace(/&/g,'&') + .replace(//g,'>') + .replace(/"/g,'"') + .replace(/'/g,''') + .replace(/\\\\/g,'\\') + .replace(/\\\//g,'\/') + .replace(/\\n/g,'\n') + .replace(/\\r/g,'\r'); + }; + + //灏嗗瓧绗︿覆鎷兼帴鐢熸垚鍑芥暟锛屽嵆缂栬瘧杩囩▼(compile) + bt._compile = function(str){ + var funBody = "var _template_fun_array=[];\nvar fn=(function(__data__){\nvar _template_varName='';\nfor(name in __data__){\n_template_varName+=('var '+name+'=__data__[\"'+name+'\"];');\n};\neval(_template_varName);\n_template_fun_array.push('"+bt._analysisStr(str)+"');\n_template_varName=null;\n})(_template_object);\nfn = null;\nreturn _template_fun_array.join('');\n"; + return new Function("_template_object",funBody); + }; + + //鍒ゆ柇鏄惁鏄疧bject绫诲瀷 + bt._isObject = function (source) { + return 'function' === typeof source || !!(source && 'object' === typeof source); + }; + + //瑙f瀽妯℃澘瀛楃涓 + bt._analysisStr = function(str){ + + //鍙栧緱鍒嗛殧绗 + var _left_ = bt.LEFT_DELIMITER; + var _right_ = bt.RIGHT_DELIMITER; + + //瀵瑰垎闅旂杩涜杞箟锛屾敮鎸佹鍒欎腑鐨勫厓瀛楃锛屽彲浠ユ槸HTML娉ㄩ噴 + var _left = bt._encodeReg(_left_); + var _right = bt._encodeReg(_right_); + + str = String(str) + + //鍘绘帀鍒嗛殧绗︿腑js娉ㄩ噴 + .replace(new RegExp("("+_left+"[^"+_right+"]*)//.*\n","g"), "$1") + + //鍘绘帀娉ㄩ噴鍐呭 <%* 杩欓噷鍙互浠绘剰鐨勬敞閲 *%> + //榛樿鏀寔HTML娉ㄩ噴锛屽皢HTML娉ㄩ噴鍖归厤鎺夌殑鍘熷洜鏄敤鎴锋湁鍙兘鐢 鏉ュ仛鍒嗗壊绗 + .replace(new RegExp("", "g"),"") + .replace(new RegExp(_left+"\\*.*?\\*"+_right, "g"),"") + + //鎶婃墍鏈夋崲琛屽幓鎺 \r鍥炶溅绗 \t鍒惰〃绗 \n鎹㈣绗 + .replace(new RegExp("[\\r\\t\\n]","g"), "") + + //鐢ㄦ潵澶勭悊闈炲垎闅旂鍐呴儴鐨勫唴瀹逛腑鍚湁 鏂滄潬 \ 鍗曞紩鍙 鈥 锛屽鐞嗗姙娉曚负HTML杞箟 + .replace(new RegExp(_left+"(?:(?!"+_right+")[\\s\\S])*"+_right+"|((?:(?!"+_left+")[\\s\\S])+)","g"),function (item, $1) { + var str = ''; + if($1){ + + //灏 鏂滄潬 鍗曞紩 HTML杞箟 + str = $1.replace(/\\/g,"\").replace(/'/g,'''); + while(/<[^<]*?'[^<]*?>/g.test(str)){ + + //灏嗘爣绛惧唴鐨勫崟寮曞彿杞箟涓篭r 缁撳悎鏈鍚庝竴姝ワ紝鏇挎崲涓篭' + str = str.replace(/(<[^<]*?)'([^<]*?>)/g,'$1\r$2') + }; + }else{ + str = item; + } + return str ; + }); + + + str = str + //瀹氫箟鍙橀噺锛屽鏋滄病鏈夊垎鍙凤紝闇瑕佸閿 <%var val='test'%> + .replace(new RegExp("("+_left+"[\\s]*?var[\\s]*?.*?[\\s]*?[^;])[\\s]*?"+_right,"g"),"$1;"+_right_) + + //瀵瑰彉閲忓悗闈㈢殑鍒嗗彿鍋氬閿(鍖呮嫭杞箟妯″紡 濡<%:h=value%>) <%=value;%> 鎺掗櫎鎺夊嚱鏁扮殑鎯呭喌 <%fun1();%> 鎺掗櫎瀹氫箟鍙橀噺鎯呭喌 <%var val='test';%> + .replace(new RegExp("("+_left+":?[hvu]?[\\s]*?=[\\s]*?[^;|"+_right+"]*?);[\\s]*?"+_right,"g"),"$1"+_right_) + + //鎸夌収 <% 鍒嗗壊涓轰竴涓釜鏁扮粍锛屽啀鐢 \t 鍜屽湪涓璧凤紝鐩稿綋浜庡皢 <% 鏇挎崲涓 \t + //灏嗘ā鏉挎寜鐓<%鍒嗕负涓娈典竴娈电殑锛屽啀鍦ㄦ瘡娈电殑缁撳熬鍔犲叆 \t,鍗崇敤 \t 灏嗘瘡涓ā鏉跨墖娈靛墠闈㈠垎闅斿紑 + .split(_left_).join("\t"); + + //鏀寔鐢ㄦ埛閰嶇疆榛樿鏄惁鑷姩杞箟 + if(bt.ESCAPE){ + str = str + + //鎵惧埌 \t=浠绘剰涓涓瓧绗%> 鏇挎崲涓 鈥橈紝浠绘剰瀛楃,' + //鍗虫浛鎹㈢畝鍗曞彉閲 \t=data%> 鏇挎崲涓 ',data,' + //榛樿HTML杞箟 涔熸敮鎸丠TML杞箟鍐欐硶<%:h=value%> + .replace(new RegExp("\\t=(.*?)"+_right,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'"); + }else{ + str = str + + //榛樿涓嶈浆涔塇TML杞箟 + .replace(new RegExp("\\t=(.*?)"+_right,"g"),"',typeof($1) === 'undefined'?'':$1,'"); + }; + + str = str + + //鏀寔HTML杞箟鍐欐硶<%:h=value%> + .replace(new RegExp("\\t:h=(.*?)"+_right,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'") + + //鏀寔涓嶈浆涔夊啓娉 <%:=value%>鍜<%-value%> + .replace(new RegExp("\\t(?::=|-)(.*?)"+_right,"g"),"',typeof($1)==='undefined'?'':$1,'") + + //鏀寔url杞箟 <%:u=value%> + .replace(new RegExp("\\t:u=(.*?)"+_right,"g"),"',typeof($1)==='undefined'?'':encodeURIComponent($1),'") + + //鏀寔UI 鍙橀噺浣跨敤鍦℉TML椤甸潰鏍囩onclick绛変簨浠跺嚱鏁板弬鏁颁腑 <%:v=value%> + .replace(new RegExp("\\t:v=(.*?)"+_right,"g"),"',typeof($1)==='undefined'?'':baidu.template._encodeEventHTML($1),'") + + //灏嗗瓧绗︿覆鎸夌収 \t 鍒嗘垚涓烘暟缁勶紝鍦ㄧ敤'); 灏嗗叾鍚堝苟锛屽嵆鏇挎崲鎺夌粨灏剧殑 \t 涓 '); + //鍦╥f锛宖or绛夎鍙ュ墠闈㈠姞涓 '); 锛屽舰鎴 ');if ');for 鐨勫舰寮 + .split("\t").join("');") + + //灏 %> 鏇挎崲涓篲template_fun_array.push(' + //鍗冲幓鎺夌粨灏剧锛岀敓鎴愬嚱鏁颁腑鐨刾ush鏂规硶 + //濡傦細if(list.length=5){%>

',list[4],'

');} + //浼氳鏇挎崲涓 if(list.length=5){_template_fun_array.push('

',list[4],'

');} + .split(_right_).join("_template_fun_array.push('") + + //灏 \r 鏇挎崲涓 \ + .split("\r").join("\\'"); + + return str; + }; + +})(window); diff --git a/public/javascripts/homework.js b/public/javascripts/homework.js new file mode 100644 index 000000000..67bfd59c3 --- /dev/null +++ b/public/javascripts/homework.js @@ -0,0 +1,133 @@ +$(function(){ +//鎻愪氦浣滀笟 + + var bt=baidu.template; + bt.LEFT_DELIMITER=''; + + var tested = false; + var valid_form = function() { + var src = $('#program-src').val(); + var title = $('#program-title').val(); + + if (!src) { + alert('璇疯緭鍏ユ纭殑浠g爜'); + return false; + } + if (!title) { + alert('璇疯緭鍏ユ爣棰'); + return false; + } + return true; + } + + var test_program = function(cb){ + var homework_id = $('#test-program-btn').attr('data-homework-id'); + var student_work_id = $('#test-program-btn').attr('data-student-work-id'); + var src = $('#program-src').val(); + var title = $('#program-title').val(); + + if(!valid_form()){ + return; + } + + $.post( + '/student_work/program_test', + {homework: homework_id, student_work_id: student_work_id, src: src, title: title}, + function(data,status){ + tested = true; + console.log(data); + + if (typeof cb == 'function') {cb(); return;} + + + var html=bt('t:result-list',data); + $('.ProResult').prepend(html); + + if (data.status==0) { + var r=confirm("绛旈姝g‘锛屾槸鍚︾珛鍒绘彁浜?"); + if (r) { + $(".HomeWorkCon form").submit(); + } + } + } + ); + }; + + $('#test-program-btn').on('click', test_program); + + + $('#commit-program-work-btn').on('click', function(){ + if(!valid_form()){ + return; + } + if($('.ProResult .ProResultTop').length<=0){ + var r=confirm("娴嬭瘯鍚庢墠鑳芥彁浜わ紝鏄惁绔嬪埢娴嬭瘯?"); + if (r) { + test_program(); + } + return; + } + + if (!tested) { + test_program(function(){ + $(".HomeWorkCon form").submit(); + }); + return; + } + + $(".HomeWorkCon form").submit(); + }); + + $('form.edit_student_work').on('keydown', '#program-src', function(){ + tested = false; + }); + + +//鍙戝竷浣滀笟 + var isProgramHomework = function(){ + return !$(".advanced_option").is(":hidden"); + } + + var submit_comm_homework = function(id){ + var valid = true; + if (isProgramHomework()) { + $.each($('.advanced_option textarea.InputBox'), function(i, val){ + if ($(val).val().length<=0) { + $(val).focus(); + valid = false; + return false; + } + }); + if (valid) { + $('input[name=homework_type]').val(2); + }; + } + if (valid) { + submit_homework(id); + } + } + window.submit_comm_homework = submit_comm_homework; + + var datepickerOptions={dateFormat:'yy-mm-dd',firstDay:0,showWeek:true,showOtherMonths:true,selectOtherMonths:true}; + + $('input.date-input').datepicker(datepickerOptions); + + $('a.pic_date').on('click', function(){ + $(this).parent().prev().first().focus(); + }) + + + $('a.DropBtn').on('click', function(){ + $(".advanced_option").toggle(); + }); + + $(".HomeWork").on('click', 'a.icon_add', function(){ + var html = bt('t:test-answer-list', null); + $(this).parent('.mt10').after(html); + + }); + $(".HomeWork").on('click', 'a.icon_remove', function(){ + $(this).parent('.mt10').remove(); + }); +}); \ No newline at end of file diff --git a/public/javascripts/init_KindEditor.js b/public/javascripts/init_KindEditor.js new file mode 100644 index 000000000..fc02146bb --- /dev/null +++ b/public/javascripts/init_KindEditor.js @@ -0,0 +1,100 @@ +function init_editor(params){ + var editor = params.kindutil.create(params.textarea, { + resizeType : 1,minWidth:"1px",width:"100%",height:"80px", + items:['emoticons'], + afterChange:function(){//鎸夐敭浜嬩欢 + nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); + }, + afterCreate:function(){ + var toolbar = $("div[class='ke-toolbar']",params.div_form); + $(".ke-outline>.ke-toolbar-icon",toolbar).append('琛ㄦ儏'); + params.toolbar_container.append(toolbar); + } + }).loadPlugin('paste'); + return editor; +} + +function nh_check_field(params){ + var result=true; + if(params.content!=undefined){ + if(params.content.isEmpty()){ + result=false; + } + if(params.content.html()!=params.textarea.html() || params.issubmit==true){ + params.textarea.html(params.content.html()); + params.content.sync(); + if(params.content.isEmpty()){ + params.contentmsg.html('鍐呭涓嶈兘涓虹┖'); + params.contentmsg.css({color:'#ff0000'}); + }else{ + params.contentmsg.html('濉啓姝g‘'); + params.contentmsg.css({color:'#008000'}); + } + params.contentmsg.show(); + } + } + return result; +} +function init_form(params){ + params.form.submit(function(){ + var flag = false; + if(params.form.attr('data-remote') != undefined ){ + flag = true + } + var is_checked = nh_check_field({ + issubmit:true, + content:params.editor, + contentmsg:params.contentmsg, + textarea:params.textarea + }); + if(is_checked){ + if(flag){ + return true; + }else{ + $(this)[0].submit(); + return false; + } + } + return false; + }); +} +function nh_reset_form(params){ + params.form[0].reset(); + params.textarea.empty(); + if(params.editor != undefined){ + params.editor.html(params.textarea.html()); + } + params.contentmsg.hide(); +} + +function init_KindEditor_data(id){ + KindEditor.ready(function (K) { + $("div[nhname='new_message_" + id + "']").each(function () { + var params = {}; + params.kindutil = K; + params.div_form = $(this); + params.form = $("form", params.div_form); + if (params.form == undefined || params.form.length == 0) { + return; + } + params.textarea = $("textarea[nhname='new_message_textarea_" + id + "']", params.div_form); + params.contentmsg = $("p[nhname='contentmsg_" + id + "']", params.div_form); + params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form); + params.cancel_btn = $("#new_message_cancel_btn_" + id); + params.submit_btn = $("#new_message_submit_btn_" + id); + + if (params.textarea.data('init') == undefined) { + params.editor = init_editor(params); + init_form(params); + params.cancel_btn.click(function () { + nh_reset_form(params); + }); + params.submit_btn.click(function () { + params.form.submit(); + }); + params.textarea.data('init', 1); + $(this).show(); + } + }); + }); +} \ No newline at end of file diff --git a/public/javascripts/jQuery.autoMail.js b/public/javascripts/jQuery.autoMail.js index 1750914fd..bf3519561 100644 --- a/public/javascripts/jQuery.autoMail.js +++ b/public/javascripts/jQuery.autoMail.js @@ -131,13 +131,13 @@ }); //榧犳爣缁忚繃鍒楄〃椤逛簨浠 //榧犳爣缁忚繃 - $(".mailHover").live("mouseover", function(){ + $(".mailHover").on("mouseover", function(){ index = Number($(this).attr("id").split("_")[1]); liveValue = $("#mailList_"+index).text(); x.children("." + cf).removeClass(cf).addClass(cl); $(this).addClass(cf).removeClass(cl); }); - $(".mailHover").live("click", function(){ + $(".mailHover").on("click", function(){ $("#mail").val($(this).html()); }); diff --git a/public/javascripts/jquery.colorbox-min.js b/public/javascripts/jquery.colorbox-min.js index 46c33f314..fbd95fd34 100644 --- a/public/javascripts/jquery.colorbox-min.js +++ b/public/javascripts/jquery.colorbox-min.js @@ -4,4 +4,4 @@ (c) 2014 Jack Moore - http://www.jacklmoore.com/colorbox license: http://www.opensource.org/licenses/mit-license.php */ -(function(t,e,i){function n(i,n,o){var r=e.createElement(i);return n&&(r.id=Z+n),o&&(r.style.cssText=o),t(r)}function o(){return i.innerHeight?i.innerHeight:t(i).height()}function r(e,i){i!==Object(i)&&(i={}),this.cache={},this.el=e,this.value=function(e){var n;return void 0===this.cache[e]&&(n=t(this.el).attr("data-cbox-"+e),void 0!==n?this.cache[e]=n:void 0!==i[e]?this.cache[e]=i[e]:void 0!==X[e]&&(this.cache[e]=X[e])),this.cache[e]},this.get=function(e){var i=this.value(e);return t.isFunction(i)?i.call(this.el,this):i}}function h(t){var e=W.length,i=(z+t)%e;return 0>i?e+i:i}function a(t,e){return Math.round((/%/.test(t)?("x"===e?E.width():o())/100:1)*parseInt(t,10))}function s(t,e){return t.get("photo")||t.get("photoRegex").test(e)}function l(t,e){return t.get("retinaUrl")&&i.devicePixelRatio>1?e.replace(t.get("photoRegex"),t.get("retinaSuffix")):e}function d(t){"contains"in y[0]&&!y[0].contains(t.target)&&t.target!==v[0]&&(t.stopPropagation(),y.focus())}function c(t){c.str!==t&&(y.add(v).removeClass(c.str).addClass(t),c.str=t)}function g(e){z=0,e&&e!==!1&&"nofollow"!==e?(W=t("."+te).filter(function(){var i=t.data(this,Y),n=new r(this,i);return n.get("rel")===e}),z=W.index(_.el),-1===z&&(W=W.add(_.el),z=W.length-1)):W=t(_.el)}function u(i){t(e).trigger(i),ae.triggerHandler(i)}function f(i){var o;if(!G){if(o=t(i).data(Y),_=new r(i,o),g(_.get("rel")),!$){$=q=!0,c(_.get("className")),y.css({visibility:"hidden",display:"block",opacity:""}),L=n(se,"LoadedContent","width:0; height:0; overflow:hidden; visibility:hidden"),b.css({width:"",height:""}).append(L),D=T.height()+k.height()+b.outerHeight(!0)-b.height(),j=C.width()+H.width()+b.outerWidth(!0)-b.width(),A=L.outerHeight(!0),N=L.outerWidth(!0);var h=a(_.get("initialWidth"),"x"),s=a(_.get("initialHeight"),"y"),l=_.get("maxWidth"),f=_.get("maxHeight");_.w=(l!==!1?Math.min(h,a(l,"x")):h)-N-j,_.h=(f!==!1?Math.min(s,a(f,"y")):s)-A-D,L.css({width:"",height:_.h}),J.position(),u(ee),_.get("onOpen"),O.add(I).hide(),y.focus(),_.get("trapFocus")&&e.addEventListener&&(e.addEventListener("focus",d,!0),ae.one(re,function(){e.removeEventListener("focus",d,!0)})),_.get("returnFocus")&&ae.one(re,function(){t(_.el).focus()})}v.css({opacity:parseFloat(_.get("opacity"))||"",cursor:_.get("overlayClose")?"pointer":"",visibility:"visible"}).show(),_.get("closeButton")?B.html(_.get("close")).appendTo(b):B.appendTo("
"),w()}}function p(){!y&&e.body&&(V=!1,E=t(i),y=n(se).attr({id:Y,"class":t.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),v=n(se,"Overlay").hide(),S=t([n(se,"LoadingOverlay")[0],n(se,"LoadingGraphic")[0]]),x=n(se,"Wrapper"),b=n(se,"Content").append(I=n(se,"Title"),R=n(se,"Current"),P=t('