diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6387a97a4..cbf2c30bb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -418,6 +418,8 @@ class ApplicationController < ActionController::Base @project = Project.find(params[:project_id]) elsif params[:course_id] @course = Course.find(params[:course_id]) + elsif params[:org_subfield_id] + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) end rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 37182dbcf..d371ed4cb 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -240,6 +240,8 @@ class AttachmentsController < ApplicationController format.html { redirect_to_referer_or respond_path(@attachment.container) } elsif !@attachment.container.nil? && @attachment.container.is_a?(PhoneAppVersion) format.html { redirect_to_referer_or mobile_version_path } + elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgSubfield) + format.html {redirect_to_referer_or org_subfield_files_path(@attachment.container)} else if @project.nil? format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index a99ab32ec..2a75d0580 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -18,13 +18,13 @@ class ExerciseController < ApplicationController end_exercises.each do |exercise| exercise.update_column('exercise_status', 3) end - if @course.is_public == 0 && !User.current.member_of_course?(@course) + if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) render_403 return end remove_invalid_exercise(@course) @is_teacher = User.current.allowed_to?(:as_teacher,@course) - if @is_teacher + if @is_teacher || User.current.admin? exercises = @course.exercises.order("created_at asc") else exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc") @@ -48,13 +48,13 @@ class ExerciseController < ApplicationController end_exercises.each do |exercise| exercise.update_column('exercise_status', 3) end - unless User.current.member_of_course?(@course) + unless User.current.member_of_course?(@course) || User.current.admin? render_403 return end @exercise = Exercise.find params[:id] @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? - if @exercise.exercise_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) + if @exercise.exercise_status != 2 && (!(User.current.allowed_to?(:as_teacher,@course) || User.current.admin?)) render_403 return end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c894680a6..328446fbb 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -299,6 +299,10 @@ class FilesController < ApplicationController render :layout => 'base_courses' elsif params[:org_subfield_id] @container_type = 2 + @organization = Organization.find(params[:organization_id]) + @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] + show_attachments @containers + render :layout => 'base_org' # @subfield = params[:org_subfield_id] end @@ -424,8 +428,39 @@ class FilesController < ApplicationController redirect_to course_files_url(@course) } end - end + elsif @org_subfield + @addTag=false + # if params[:in_org_subfield_toolbar] + # @in_org_subfield_toolbar = params[:in_org_subfield_toolbar] + # end + attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type]) + # if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + # Mailer.run.attachments_added(attachments[:files]) + # end + + # TODO: 临时用 nyan + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)] #modify by Long Jun + # @containers += @org_subfield.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + show_attachments @containers + + @attachtype = 0 + @contenttype = 0 + + respond_to do |format| + format.js + format.html { + redirect_to org_subfield_files_url(@org_subfield) + } + end + end end end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 67499655f..a8d6dfe8f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -126,14 +126,33 @@ class HomeworkCommonController < ApplicationController if @homework_detail_manual.comment_status == 1 student_works = @homework.student_works if student_works && student_works.size >= 2 - student_works.each_with_index do |work, index| - user = work.user - n = @homework_detail_manual.evaluation_num - n = n < student_works.size ? n : student_works.size - 1 - assigned_homeworks = get_assigned_homeworks(student_works, n, index) - assigned_homeworks.each do |h| - student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) - student_works_evaluation_distributions.save + if @homework.homework_type == 3 + student_work_projects = @homework.student_work_projects.where("student_work_id is not null") + student_work_projects.each_with_index do |pro_work, pro_index| + n = @homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + work_index = -1 + student_works.each_with_index do |stu_work, stu_index| + if stu_work.id.to_i == pro_work.student_work_id.to_i + work_index = stu_index + end + end + assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) + student_works_evaluation_distributions.save + end + end + else + student_works.each_with_index do |work, index| + user = work.user + n = @homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + assigned_homeworks = get_assigned_homeworks(student_works, n, index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) + student_works_evaluation_distributions.save + end end end @homework_detail_manual.update_column('comment_status', 2) @@ -143,7 +162,8 @@ class HomeworkCommonController < ApplicationController Mailer.send_mail_anonymous_comment_open(@homework).deliver else @statue = 2 - end + + end else @statue = 3 end @@ -277,6 +297,7 @@ class HomeworkCommonController < ApplicationController @homework = HomeworkCommon.find params[:id] @homework_detail_manual = @homework.homework_detail_manual @homework_detail_programing = @homework.homework_detail_programing + @homework_detail_group = @homework.homework_detail_group @course = @homework.course rescue render_404 diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 977a77569..0883b3799 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -129,7 +129,7 @@ class MyController < ApplicationController @user.safe_attributes = params[:user] @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') - @user.login = params[:login] + #@user.login = params[:login] unless @user.user_extensions.nil? if @user.user_extensions.identity == 2 @user.firstname = params[:enterprise_name] diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 00b88fdaa..1dc7885fe 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -17,4 +17,8 @@ class OrgSubfieldsController < ApplicationController @organization = Organization.find(@subfield.organization_id) @subfield.update_attributes(:name => params[:name]) end + + def show + + end end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 77868c689..f79646ade 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,7 +3,7 @@ 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, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] @@ -95,12 +95,27 @@ class StudentWorkController < ApplicationController @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name @show_all = true elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 - my_work = @homework.student_works.where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.where(:id => pro.student_work_id) + else + my_work = @homework.student_works.where(:user_id => User.current.id) + end @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end if my_work.empty? @stundet_works = [] else @@ -116,12 +131,27 @@ class StudentWorkController < ApplicationController @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name @show_all = true elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 - my_work = @homework.student_works.where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.where(:id => pro.student_work_id) + else + my_work = @homework.student_works.where(:user_id => User.current.id) + end @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end if my_work.empty? @stundet_works = [] else @@ -190,6 +220,10 @@ class StudentWorkController < ApplicationController student_work.user_id = User.current.id student_work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(student_work) + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + @student_work_project = @homework.student_work_projects.where("user_id = #{User.current.id}").first + student_work.project_id = @student_work_project.project_id + end #提交作品时,计算是否迟交 if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") student_work.late_penalty = @homework.late_penalty @@ -197,6 +231,35 @@ class StudentWorkController < ApplicationController student_work.late_penalty = 0 end if student_work.save + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + @student_work_project.student_work_id = student_work.id + @student_work_project.save + members = params[:group_member_ids].split(',') + for i in 1 .. members.count-1 + stu_project = StudentWorkProject.new + stu_project.homework_common_id = @homework.id + stu_project.student_work_id = student_work.id + stu_project.project_id = @student_work_project.project_id + stu_project.user_id = members[i].to_i + stu_project.is_leader = 0 + stu_project.save + end + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + members = params[:group_member_ids].split(',') + for i in 0 .. members.count-1 + stu_project = StudentWorkProject.new + stu_project.homework_common_id = @homework.id + stu_project.student_work_id = student_work.id + stu_project.project_id = -1 + stu_project.user_id = members[i].to_i + if i == 0 + stu_project.is_leader = 1 + else + stu_project.is_leader = 0 + end + stu_project.save + end + end course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first if course_activity course_activity.updated_at = Time.now @@ -276,6 +339,18 @@ class StudentWorkController < ApplicationController def destroy if @work.destroy + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + pros = @work.student_work_projects.where("is_leader = 0") + pros.each do |pro| + pro.destroy + end + project = @work.student_work_projects.where("is_leader = 1").first + project.update_attributes(:student_work_id => nil) + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + @work.student_work_projects.each do |pro2| + pro2.destroy + end + end respond_to do |format| format.html { redirect_to student_work_index_url(:homework => @homework.id) @@ -288,12 +363,36 @@ class StudentWorkController < ApplicationController @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first if @work @work.destroy + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + pros = @work.student_work_projects.where("is_leader = 0") + pros.each do |pro| + pro.destroy + end + project = @work.student_work_projects.where("is_leader = 1").first + project.update_attributes(:student_work_id => nil) + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + @work.student_work_projects.each do |pro2| + pro2.destroy + end + end end redirect_to user_homeworks_user_path(User.current.id) end def retry_work if @work.destroy + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + pros = @work.student_work_projects.where("is_leader = 0") + pros.each do |pro| + pro.destroy + end + project = @work.student_work_projects.where("is_leader = 1").first + project.update_attributes(:student_work_id => nil) + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + @work.student_work_projects.each do |pro2| + pro2.destroy + end + end @student_work = StudentWork.new respond_to do |format| format.js @@ -540,7 +639,89 @@ class StudentWorkController < ApplicationController end end + def new_student_work_project + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + + #创建作业的关联项目 + def student_work_project + @project = StudentWorkProject.new + @project.homework_common_id = @homework.id + @project.project_id = (Project.find params[:projectName].to_i).id + @project.user_id = User.current.id + @project.is_leader = 1 + if @project.save + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + + end + + #查找学生创建的项目列表 + def search_user_projects + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + @project_ids = Project.where("user_id = #{User.current.id} and name like '#{condition}'") + @first = params[:first].to_i + respond_to do |format| + format.js + end + end + + #查找课程的学生 + def search_course_students + name = "" + unless params[:name].nil? + name = params[:name] + end + all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")" + all_students = User.where("id in #{all_student_ids}") + @users = searchstudent_by_name all_students,name + respond_to do |format| + format.js + end + end + + def cancel_relate_project + relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first + if relate_pro.destroy + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + end + private + def searchstudent_by_name users, name + mems = [] + if name != "" + name = name.to_s.downcase + users.each do |m| + username = m.lastname.to_s.downcase + m.firstname.to_s.downcase + if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name)) + mems << m + end + end + else + mems = users + end + mems + end + def hsd_committed_work?(user, homework) sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first sw.nil? ? result = false : result = true diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 834009d71..b6d336547 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -551,12 +551,21 @@ class UsersController < ApplicationController ) end end + end + #分组作业 + if homework.homework_type == 3 + homework_detail_group = HomeworkDetailGroup.new + homework.homework_detail_group = homework_detail_group + homework_detail_group.min_num = params[:min_num].to_i + homework_detail_group.max_num = params[:max_num].to_i + homework_detail_group.base_on_project = params[:base_on_project].to_i end if homework.save homework_detail_manual.save if homework_detail_manual homework_detail_programing.save if homework_detail_programing + homework_detail_group.save if homework_detail_group if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => homework.course_id) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 815a44839..1508fc871 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -161,7 +161,7 @@ class WelcomeController < ApplicationController query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename'] + fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -173,10 +173,12 @@ class WelcomeController < ApplicationController lastname: {}, name:{}, description:{}, - filename:{} + filename:{}, + subject:{}, + content:{} } } - },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results + },[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results when 'user' @users = User.search(@name).page(params[:page] || 1).per(20) when 'project' @@ -185,6 +187,8 @@ class WelcomeController < ApplicationController @courses = Course.search(@name).page(params[:page] || 1).per(20).results when 'attachment' @attachments = Attachment.search(@name).page(params[:page] || 1).per(20).results + when 'memo' + @memos = Memo.search(@name).page(params[:page] || 1).per(20).results else @alls = Elasticsearch::Model.search({ query: { @@ -192,7 +196,7 @@ class WelcomeController < ApplicationController query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename'] + fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -204,10 +208,12 @@ class WelcomeController < ApplicationController lastname: {}, name:{}, description:{}, - filename:{} + filename:{}, + subject:{}, + content:{} } } - },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results + },[User,Course,Attachment,Project,Memo] ).page(params[:page] || 1).per(20).results end @@ -216,13 +222,14 @@ class WelcomeController < ApplicationController @course_count = Course.search(@name).results.total @attach_count = Attachment.search(@name).results.total @project_count = Project.search(@name).results.total + @memo_count = Memo.search(@name).results.total @total_count = Elasticsearch::Model.search({ query: { multi_match: { query: @name, type:"most_fields", operator: "or", - fields: ['login', 'firstname','lastname','name','description^0.5','filename'] + fields: ['login', 'firstname','lastname','name','description^0.5','filename','subject','content^0.5'] } }, highlight: { @@ -234,10 +241,12 @@ class WelcomeController < ApplicationController lastname: {}, name:{}, description:{}, - filename:{} + filename:{}, + subject:{}, + content:{} } } - },[User,Course,Attachment,Project] ).results.total + },[User,Course,Attachment,Project,Memo] ).results.total # search_type = params[:search_type].to_sym unless search_condition.blank? # search_by = params[:search_by] # diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 46a20dd4c..8f4679c67 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2435,10 +2435,19 @@ module ApplicationHelper link_to "作品(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else #学生显示提交作品、修改作品等按钮 work = cur_user_works_for_homework homework + project = cur_user_projects_for_homework homework if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") - link_to "提交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' + if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 + link_to "提交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品' + else + link_to "提交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' + end elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") - link_to "补交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_red' + if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 + link_to "补交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品' + else + link_to "补交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_red' + end else if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前 link_to "作品匿评", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品" @@ -2459,6 +2468,24 @@ module ApplicationHelper end + def relate_project homework,is_teacher,is_in_course,user_activity_id,course_activity + if User.current.member_of_course?(homework.course) + if is_teacher + #link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + else + projects = cur_user_projects_for_homework homework + works = cur_user_works_for_homework homework + if works.nil? && projects.nil? + link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' + elsif works.nil? + link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' + else + #link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + end + end + end + end + def student_anonymous_comment homework if homework.homework_detail_manual case homework.homework_detail_manual.comment_status @@ -2474,7 +2501,20 @@ module ApplicationHelper #获取当前用户在指定作业下提交的作业的集合 def cur_user_works_for_homework homework - homework.student_works.where("user_id = ?",User.current).first + work = homework.student_works.where("user_id = ?",User.current).first + if homework.homework_type == 3 + pro = homework.student_work_projects.where("user_id = #{User.current.id}").first + if pro.nil? || pro.student_work_id == "" || pro.student_work_id.nil? + work = nil + else + work = StudentWork.find pro.student_work_id + end + end + work + end + #获取当前用户在指定作业下关联的项目的集合 + def cur_user_projects_for_homework homework + homework.student_work_projects.where("user_id = ?",User.current).first end def file_preview_tag(file, html_options={}) diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 9a1765ddc..cf9cbcc32 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -113,7 +113,8 @@ module FilesHelper if attachment.is_public? || (attachment.container_type == "Project" && User.current.member_of?(attachment.project)) || (attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)))|| - attachment.author_id == User.current.id + attachment.author_id == User.current.id || + attachment.container_type == "OrgSubfield" result << attachment end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 999cefdaa..ad5655b02 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -22,6 +22,7 @@ class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'" + belongs_to :org_subfield, foreign_key: 'container_id', conditions: "attachements.container_type = 'OrgSubfield'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" @@ -46,7 +47,7 @@ class Attachment < ActiveRecord::Base settings index: { number_of_shards: 5 } do mappings dynamic: 'false' do indexes :filename, analyzer: 'smartcn',index_options: 'offsets' - indexes :downloads, analyzer: 'smartcn',index_options: 'offsets' + indexes :downloads, index:"not_analyzed",index_options: 'offsets' end end diff --git a/app/models/course.rb b/app/models/course.rb index ee26d1d54..0194a2a9d 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -16,7 +16,7 @@ class Course < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' - indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets',type:"date" + indexes :updated_at, index:"not_analyzed",type:"date" end end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 8d421a98f..0ad667bd1 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -9,6 +9,8 @@ class HomeworkCommon < ActiveRecord::Base belongs_to :user has_one :homework_detail_manual, :dependent => :destroy has_one :homework_detail_programing, :dependent => :destroy + has_one :homework_detail_group, :dependent => :destroy + has_many :student_work_projects, :dependent => :destroy has_many :homework_tests, :dependent => :destroy has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 @@ -74,6 +76,10 @@ class HomeworkCommon < ActiveRecord::Base self.homework_type == 2 && self.homework_detail_programing end + def is_group_homework? + self.homework_type == 3 && self.homework_detail_group + end + ###添加回复 def self.add_homework_jour(user, notes, id , options = {}) homework = HomeworkCommon.find(id) diff --git a/app/models/homework_detail_group.rb b/app/models/homework_detail_group.rb new file mode 100644 index 000000000..0a9cb5fe2 --- /dev/null +++ b/app/models/homework_detail_group.rb @@ -0,0 +1,4 @@ +class HomeworkDetailGroup < ActiveRecord::Base + belongs_to :homework_common + attr_accessible :base_on_project, :homework_common_id, :max_num, :min_num +end diff --git a/app/models/memo.rb b/app/models/memo.rb index 7c4fbdcf1..2ead1cbb6 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -1,7 +1,9 @@ +require 'elasticsearch/model' class Memo < ActiveRecord::Base include Redmine::SafeAttributes include UserScoreHelper include ApplicationHelper + include Elasticsearch::Model belongs_to :forum has_many_kindeditor_assets :assets, :dependent => :destroy belongs_to :author, :class_name => "User", :foreign_key => 'author_id' @@ -12,6 +14,18 @@ class Memo < ActiveRecord::Base validates_length_of :content, maximum: 30000 validate :cannot_reply_to_locked_topic, :on => :create + + #elasticsearch kaminari init + Kaminari::Hooks.init + Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari + settings index: { number_of_shards: 5 } do + mappings dynamic: 'false' do + indexes :subject, analyzer: 'smartcn',index_options: 'offsets' + indexes :content, analyzer: 'smartcn',index_options: 'offsets' + indexes :updated_at,index:"not_analyzed" ,type:'date' + end + end + acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC" acts_as_attachable has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj @@ -47,9 +61,9 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message - # after_update :update_memos_forum - after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分 + after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message,:create_memo_ealasticsearch_index + after_update :update_memo_ealasticsearch_index + after_destroy :reset_counters!,:delete_kindeditor_assets,:delete_memo_ealasticsearch_index#,:down_user_score -- 公共区发帖暂不计入得分, # after_create :send_notification # after_save :plusParentAndForum # after_destroy :minusParentAndForum @@ -57,6 +71,36 @@ class Memo < ActiveRecord::Base # scope :visible, lambda { |*args| # includes(:forum => ).where() # } + scope :indexable,lambda { + where('parent_id is null') + } + + def self.search(query) + __elasticsearch__.search( + { + query: { + multi_match: { + query: query, + type:"most_fields", + operator: "or", + fields: ['subject','content^0.5'] + } + }, + sort: { + _score:{order: "desc" }, + updated_at:{order: "desc" } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + subject: {}, + content: {} + } + } + } + ) + end def send_mail Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') @@ -203,6 +247,22 @@ class Memo < ActiveRecord::Base # Author lizanle # Description 从硬盘上删除资源 def delete_kindeditor_assets - delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO + delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO + end + + def create_memo_ealasticsearch_index + if self.parent_id.nil? + self.__elasticsearch__.index_document + end + end + def update_memo_ealasticsearch_index + if self.parent_id.nil? + self.__elasticsearch__.update_document + end + end + def delete_memo_ealasticsearch_index + if self.parent_id.nil? + self.__elasticsearch__.delete_document + end end end diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index efe9699c3..f95bb3eba 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -1,4 +1,9 @@ class OrgSubfield < ActiveRecord::Base belongs_to :organization, :foreign_key => :organization_id has_many :org_document_comments, :dependent => :destroy + has_many :files + acts_as_attachable + + def project + end end \ No newline at end of file diff --git a/app/models/project.rb b/app/models/project.rb index ff546e098..cd4036810 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -39,10 +39,11 @@ class Project < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' - indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets', type:'date' + indexes :updated_on, index:"not_analyzed", type:'date' end end + has_many :student_work_projects,:dependent => :destroy has_many :student_works has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" @@ -86,6 +87,7 @@ class Project < ActiveRecord::Base # end #ADDED BY NIE + has_one :project_score, :dependent => :destroy has_many :project_infos, :dependent => :destroy has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 884f4a089..c6e2a6584 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -4,6 +4,7 @@ class StudentWork < ActiveRecord::Base belongs_to :homework_common belongs_to :user + has_many :student_work_projects has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project diff --git a/app/models/student_work_project.rb b/app/models/student_work_project.rb new file mode 100644 index 000000000..676071817 --- /dev/null +++ b/app/models/student_work_project.rb @@ -0,0 +1,7 @@ +class StudentWorkProject < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :homework_common + belongs_to :student_work + belongs_to :project + belongs_to :user +end diff --git a/app/models/user.rb b/app/models/user.rb index b9d9de029..6e6d58f86 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,7 +35,7 @@ class User < Principal indexes :login, analyzer: 'smartcn',index_options: 'offsets' indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' indexes :lastname, analyzer: 'smartcn',index_options: 'offsets' - indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets',type: 'date' + indexes :last_login_on, index:"not_analyzed",type: 'date' end end @@ -107,6 +107,7 @@ class User < Principal has_many :student_works, :dependent => :destroy has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy + has_many :student_work_projects, :dependent => :destroy #end has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index 25cc7f68a..a9d399511 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -20,6 +20,25 @@ :lebel_file_uploding => l(:lebel_file_uploding), :delete_all_files => l(:text_are_you_sure_all) } %> +<% elsif @project %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => ie8? ? '': 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :lebel_file_uploding => l(:lebel_file_uploding), + :delete_all_files => l(:text_are_you_sure_all) + } %> <% else %> <%= file_field_tag 'attachments[dummy][file]', :id => '_file', diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb new file mode 100644 index 000000000..a8aa13458 --- /dev/null +++ b/app/views/files/_org_subfield_list.html.erb @@ -0,0 +1,56 @@ +<% delete_allowed = User.current.admin? %> +
+

共有 <%= all_attachments.count%> 个资源

+

+ <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% else %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>  /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% end %> +

+
+
+ + + + +
+ +
+ <% org_subfield_attachments.each do |file| %> + <% if 1 %> +
+
+ <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <% if User.current.logged? %> + <%= file_preview_tag(file, class: 'f_l re_open', style:'text-align: center;') %> + <% end %> +
+
+
+

文件大小:<%= number_to_human_size(file.filesize) %>

+ <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @org_subfield.id && file.container_type == "OrgSubfield"%> +

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+
+
+ + + + + +
+
+ <% end %> + <% end %> +
+ +
diff --git a/app/views/files/_subfield_files.html.erb b/app/views/files/_subfield_files.html.erb new file mode 100644 index 000000000..ea408c7a6 --- /dev/null +++ b/app/views/files/_subfield_files.html.erb @@ -0,0 +1,97 @@ +<%= stylesheet_link_tag 'courses' %> + + +
+
+
+ <%= form_tag( search_org_subfield_files_path(@org_subfield), method: 'get',:class => "re_search f_l",:remote=>true) do %> + <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> + <%= submit_tag "栏目内搜索", :class => "re_schbtn b_lblue",:name => "inorg_subfield",:id => "inorg_subfield", :onmouseover => "presscss('inorg_subfield')",:onmouseout =>"buttoncss()" %> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + <% end %> + <%# if is_org_subfield_teacher(User.current,@org_subfield) || (@org_subfield.publish_resource==1 && User.current.member_of_org_subfield?(@org_subfield) ) %> + +

+ 上传: + 课件 |  + 软件 |  + 媒体 |  + 代码 |  + 论文 |  + 其他 +

+ <%# end %> +
+
+ +
+ <%= render :partial => 'org_subfield_list',:locals => {org_subfield: @org_subfield,all_attachments: @all_attachments,sort:@sort,order:@order,org_subfield_attachments:@obj_attachments} %> +
+ +
+
+<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_subfield_files_list.html.erb b/app/views/files/_subfield_files_list.html.erb new file mode 100644 index 000000000..d762743ad --- /dev/null +++ b/app/views/files/_subfield_files_list.html.erb @@ -0,0 +1,55 @@ +<% delete_allowed = User.current.admin? %> +
+

共有 <%= all_attachments.count%> 个资源

+

+ <% if order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% else %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>  /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 + <% end %> +

+
+
+ +
+ <%= render :partial => "files/tag_yun", :locals => {:tag_list => @tag_list,:course => course,:tag_name => @tag_name}%> +
+
+ +
+ <% curse_attachments.each do |file| %> + <% if file.is_public? || User.current.admin? %> +
+
+ <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> +
+
+
+

文件大小:<%= number_to_human_size(file.filesize) %>

+ <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @org_subfield.id && file.container_type == "OrgSubfield"%> +

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+
+
+
+ + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> +
+
+
+ <% else %> +
<%= file.filename %>是私有资源
+ <% end %> + <% end %> +
+ +
diff --git a/app/views/files/_upload_subfield_file.html.erb b/app/views/files/_upload_subfield_file.html.erb new file mode 100644 index 000000000..c3ca72ecd --- /dev/null +++ b/app/views/files/_upload_subfield_file.html.erb @@ -0,0 +1,31 @@ + +
+
+

<%= l(:label_upload_files)%>

+
+ <%= error_messages_for 'attachment' %> + + + <%= form_tag(org_subfield_files_path(org_subfield), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + + + + <%= render :partial => 'files/attachement_list',:locals => {:org_subfield => org_subfield} %> +
+ <%= l(:button_cancel)%> + <%= l(:button_confirm)%> + <% end %> +
+ +
+ <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ + \ No newline at end of file diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 9de7aa042..4d8bb26ca 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -52,6 +52,17 @@ $('#upload_file_div').slideToggle('slow'); setTimeout( function(){div.remove();},3000) <% end %> <%end%> + <% elsif @org_subfield %> + hideModal(); + $("#resource_list").html('<%= j(render partial: "subfield_files" ,locals: {org_subfield: @org_subfield}) %>'); +// $("#courses_files_count_info").html("<%#= @all_attachments.count%>"); +// $("#courses_files_count_nav").html("(<%#= @all_attachments.count%>)") + // 添加文件上传成功提示, + <% unless params[:attachments].nil? %> + var div = $('
文件上传成功!
'); + $("#org_subfield_list").prepend(div); + setTimeout( function(){div.remove();},3000) + <% end %> <% end %> <% end %> $(document).ready(img_thumbnails); diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 3dad88868..dff20a20b 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,8 +1,10 @@
- <% if @isproject %> + <% if @container_type == 0 %> <%= render :partial => 'project_file_new', locals: {project: @project} %> - <% else %> + <% elsif @container_type == 1 %> <%= render :partial => 'course_file', locals: {course: @course} %> + <% elsif @container_type == 2 %> + <%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %> <% end %>
diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 3b3877228..010bc8ec9 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -4,7 +4,7 @@ $("#homework_publish_time").val(""); $("#homework_end_time").val(""); $("#course_id").val($("#option_select").val()); - $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true })%>"); + $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true})%>"); homework_description_editor.html(""); $("#homework_editor").toggle(); } diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index dc9ee10b6..94f62638e 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -30,7 +30,7 @@
  •   
  • diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index e336b0282..58f611b55 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -1,6 +1,11 @@