diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 43918ed10..36a48f2a3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -103,11 +103,10 @@ class StudentWorkController < ApplicationController if result["status"].to_i != -2 #result["results"].first['output'] = result["results"].first['output'].gsub(" ","□") #result["results"].first['result'] = result["results"].first['result'].gsub(" ","□") + space_replace_1(result["results"].first['output']) + space_replace_1(result["results"].first['result']) end - space_replace_1(result["results"].first['output']) - space_replace_1(result["results"].first['result']) - logger.debug result #-1 默认值 0全部正确并结束 2 超时 -2 编译错误 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index efe968d3b..2d1402ed5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1820,9 +1820,38 @@ class UsersController < ApplicationController else @flag = false end + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_project_ids = User.current.projects.map {|p| p.id} user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','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") + if(params[:type].blank? || params[:type] == "1") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end + elsif params[:type] == "6" # 公共资源 + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end + end @type = params[:type] @limit = 25 @path = user_resource_user_path(User.current, :type => @type) @@ -1932,9 +1961,39 @@ class UsersController < ApplicationController else @flag=true end + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_project_ids = User.current.projects.map {|p| p.id} user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','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") + if(params[:type].blank? || params[:type] == "1") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end + elsif params[:type] == "6" # 公共资源 + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end + end + @status = params[:status] @type = params[:type] @limit = 25 @path = user_resource_user_path(User.current, :type => @type) @@ -2031,9 +2090,38 @@ class UsersController < ApplicationController else @flag=true end + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + user_project_ids = User.current.projects.map {|p| p.id} user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','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") + if(params[:type].blank? || params[:type] == "1") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end + elsif params[:type] == "6" # 公共资源 + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end + end @type = params[:type] @limit = 25 @path = user_resource_user_path(User.current, :type => @type) diff --git a/app/views/users/_course_file_form.html.erb b/app/views/users/_course_file_form.html.erb index a1317c1f8..1c10cdbeb 100644 --- a/app/views/users/_course_file_form.html.erb +++ b/app/views/users/_course_file_form.html.erb @@ -1,4 +1,5 @@ -<%= form_tag add_exist_file_to_course_user_path(user, :type => defined? type ? "6" : type ),:remote=>true,:id=>'course_list_form' do %> + +<%= form_tag add_exist_file_to_course_user_path(user, :type => defined?(type) ? type : "6" ),:remote=>true,:id=>'course_list_form' do %>