diff --git a/Gemfile b/Gemfile index 0125e9d60..38364b556 100644 --- a/Gemfile +++ b/Gemfile @@ -44,7 +44,9 @@ group :development do gem 'grape-swagger' gem 'better_errors', '~> 1.1.0' gem 'rack-mini-profiler', '~> 0.9.3' - gem 'win32console' + if RUBY_PLATFORM =~ /w32/ + gem 'win32console' + end end group :development, :test do 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..8fa90ea46 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,8 +1,10 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise,:show_student_result] - before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, + :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise, + :show_student_result,:student_exercise_list] + before_filter :find_course, :only => [:index,:new,:create] include ExerciseHelper def index @@ -18,16 +20,16 @@ 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") + exercises = @course.exercises.where("exercise_status <> 1").order("created_at asc") end @exercises = paginateHelper exercises,20 #分页 respond_to do |format| @@ -48,47 +50,32 @@ 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?) - render_403 - return - end exercise_end = @exercise.end_time > Time.now if @exercise.time == -1 @can_edit_excercise = exercise_end else - @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin? + @can_edit_excercise = !has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end end - @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first - # 学生点击的时候即创建关联,自动保存 - #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) - - # 已提交问卷的用户不能再访问该界面 -=begin - if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) - respond_to do |format| - format.html {render :layout => 'base_courses'} - end - else -=end - if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) + unless @is_teacher + @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first + if @exercise_user.nil? eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first end - # @percent = get_percent(@exercise,User.current) - exercise_questions = @exercise.exercise_questions - @exercise_questions = paginateHelper exercise_questions,5 #分页 score = calculate_student_score(@exercise, User.current) - eu = get_exercise_user(@exercise.id, User.current.id) - eu.update_attributes(:score => score) - respond_to do |format| - format.html {render :layout => 'base_courses'} - end + @exercise_user.update_attributes(:score => score) + end + # @percent = get_percent(@exercise,User.current) + @exercise_questions = @exercise.exercise_questions + respond_to do |format| + format.html {render :layout => 'base_courses'} + end #end end @@ -369,8 +356,20 @@ class ExerciseController < ApplicationController end def student_exercise_list +=begin + if @exercise.end_time <= Time.now + @course.student.each do |student| + if ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,@exercise.id).empty? + ExerciseUser.create(:user_id => student.student_id, :exercise_id => @exercise.id, :start_at => @exercise.end_time, :status => true,:score=>0) + end + + s_score = calculate_student_score(@exercise, student.student) + exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", student.student_id, @exercise.id).first + exercise_user.update_attributes(:score => s_score) + end + end +=end @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? - @exercise = Exercise.find params[:id] @all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc") @exercise_count = @exercise.exercise_users.where('score is not NULL').count if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time <= Time.now) @@ -537,12 +536,9 @@ class ExerciseController < ApplicationController # @score = 100 if @uncomplete_question.count < 1 # 查看是否有已提交记录 - eu = get_exercise_user(@exercise.id, User.current.id) - eu.user_id = User.current.id - eu.exercise_id = @exercise.id - eu.score = @score - if eu.save - #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') + cur_exercise_user.score = @score + if cur_exercise_user.save + #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') @status = 0 #提交成功 else @status = 2 #未知错误 @@ -550,6 +546,7 @@ class ExerciseController < ApplicationController else @status = 1 #有未做得必答题 end + @save = params[:save].to_i if params[:save] respond_to do |format| format.js end @@ -560,11 +557,11 @@ class ExerciseController < ApplicationController def show_student_result @user = User.find params[:user_id] @can_edit_excercise = false - @exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first @exercise_questions = @exercise.exercise_questions score = calculate_student_score(@exercise, @user) eu = get_exercise_user(@exercise.id, @user.id) eu.update_attributes(:score => score) + @exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first respond_to do |format| format.html {render :layout => 'base_courses'} end @@ -582,15 +579,15 @@ class ExerciseController < ApplicationController standard_answer = get_user_standard_answer(question, user) unless answer.empty? # 问答题有多个答案 - if question.question_type == 3 + if question.question_type == 3 && !standard_answer.empty? if standard_answer.include?(answer.first.answer_text) score1 = score1+ question.question_score unless question.question_score.nil? end - elsif question.question_type == 1 + elsif question.question_type == 1 && !standard_answer.nil? if answer.first.exercise_choice.choice_position == standard_answer.exercise_choice_id score2 = score2 + question.question_score unless question.question_score.nil? end - else + elsif question.question_type == 2 && !standard_answer.nil? arr = get_mulscore(question, user) if arr.to_i == standard_answer.exercise_choice_id score3 = score3 + question.question_score unless question.question_score.nil? diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b15be4896..328446fbb 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -186,7 +186,7 @@ class FilesController < ApplicationController @order = "" @is_remote = false if params[:project_id] - @isproject = true + @container_type = 0 if params[:sort] params[:sort].split(",").each do |sort_type| @@ -246,7 +246,7 @@ class FilesController < ApplicationController format.js end elsif params[:course_id] - @isproject = false + @container_type = 1 if params[:sort] params[:sort].split(",").each do |sort_type| @@ -297,6 +297,13 @@ class FilesController < ApplicationController @tag_list = attachment_tag_list @all_attachments 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 end @@ -421,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/issues_controller.rb b/app/controllers/issues_controller.rb index edf055370..7cdc838e2 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -142,6 +142,13 @@ class IssuesController < ApplicationController @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq + #id name email + #1. issues list persons + #2. project persons + @at_persons = @journals.map(&:user) + @issue.project.users + @at_persons = @at_persons.uniq{|u| u.id}.delete_if{|u| u.id == User.current.id} + @at_persons = nil + respond_to do |format|`` format.html { retrieve_previous_and_next_issue_ids diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index c53dcbed5..0883b3799 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -85,7 +85,7 @@ class MyController < ApplicationController flash[:notice] = l(:notice_mail_notification_updated) redirect_to my_account_url else - redirect_to signin_url + redirect_to signin_url end end @@ -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] @@ -223,7 +223,7 @@ class MyController < ApplicationController end flash.now[:error] = l(:notice_account_old_wrong_password) end - render :template => 'my/account',:layout=>'base_users_new' + render :template => 'my/account',:layout=>'new_base_user' end # Create a new feeds key 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/projects_controller.rb b/app/controllers/projects_controller.rb index 200bd4d69..ab2cfa2ba 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -30,7 +30,7 @@ class ProjectsController < ApplicationController before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project] before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] - before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] + before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar] before_filter :file, :statistics #:watcherlist # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 # before_filter :memberAccess, only: :member @@ -697,7 +697,11 @@ class ProjectsController < ApplicationController flash[:error] = l(:error_can_not_archive_project) end end - redirect_to admin_projects_url(:status => params[:status]) + if params[:type] == "project" + redirect_to user_path(User.current) + else + redirect_to admin_projects_url(:status => params[:status]) + end end def unarchive diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 77868c689..b79adda2d 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 @@ -207,6 +270,9 @@ class StudentWorkController < ApplicationController user_activity.updated_at = Time.now user_activity.save end + course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"new",:course_message_id=>student_work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录 + course_message.save + @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first respond_to do |format| format.js @@ -236,10 +302,11 @@ class StudentWorkController < ApplicationController @submit_result = true @work.name = params[:student_work][:name] @work.description = params[:student_work][:description] - @work.project_id = params[:student_work][:project] @work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@work) if @work.save + course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"edit",:course_message_id=>@work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录 + course_message.save =begin respond_to do |format| format.html { @@ -276,6 +343,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 +367,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 +643,90 @@ 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}") + @commit_student_ids = @homework.student_work_projects.map{|student| student.user_id} + @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 @@ -737,7 +923,7 @@ class StudentWorkController < ApplicationController #成绩计算 def set_final_score homework,student_work if homework && homework.homework_detail_manual - if homework.homework_type == 1 #匿评作业 + if homework.homework_type != 2 #匿评作业 if homework.teacher_priority == 1 #教师优先 if student_work.teacher_score student_work.final_score = student_work.teacher_score 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..5a9563b73 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1934,6 +1934,8 @@ module ApplicationHelper candown = true elsif attachment.container.class.to_s=="StudentWork" candown = true + elsif attachment.container.class.to_s=="BlogComment" + candown = true elsif attachment.container.class.to_s == "User" candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id) elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses @@ -2435,10 +2437,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 => "开启匿评后不可修改作品" @@ -2446,7 +2457,7 @@ module ApplicationHelper link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "匿评已结束" elsif homework.homework_type == 2 && 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' - elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") + elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id link_to "修改作品(#{homework.student_works.count})", edit_student_work_path(work.id),:class => 'c_blue' else link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "作业截止后不可修改作品" @@ -2459,6 +2470,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 +2503,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={}) @@ -2619,4 +2661,38 @@ int main(int argc, char** argv){ true end end + + def import_ke(default_opt={}) + opt = {enable_at: true, prettify: false, init_activity: false}.merge default_opt + ss = '' + if opt[:enable_at] + ss = '" + end + + ss += javascript_include_tag("/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg') + if opt[:enable_at] + ss += javascript_include_tag('/assets/kindeditor/at/jquery.caret.min.js', '/assets/kindeditor/at/jquery.atwho.js', '/assets/kindeditor/at/config.js') + ss += stylesheet_link_tag("/assets/kindeditor/at/jquery.atwho.css") + end + + if opt[:prettify] + ss += javascript_include_tag 'prettify' + ss += stylesheet_link_tag 'prettify' + end + + if opt[:init_activity] + ss += javascript_include_tag "init_activity_KindEditor" + end + + ss.html_safe + end + end 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/course_message.rb b/app/models/course_message.rb index 11b0165c5..79d27f3c5 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -1,5 +1,5 @@ class CourseMessage < ActiveRecord::Base - # status说明: status在课程不同的类型,区分不同的功能 + # status说明: status在课程不同的类型,区分不同的功能 status = 9 作品的提交记录 # HomeworkCommon:status: # nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败 attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status @@ -19,7 +19,7 @@ class CourseMessage < ActiveRecord::Base def add_user_message #unless self.course_message_type == 'JoinCourseRequest' - if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? + if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil? && self.status != 9 self.message_alls << MessageAll.new(:user_id => self.user_id) 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/journals_for_message.rb b/app/models/journals_for_message.rb index ec6390408..396133c7a 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -267,7 +267,7 @@ class JournalsForMessage < ActiveRecord::Base # 课程成员得分(英雄榜) def act_as_student_score - unless self.user.allowed_to?(:as_teacher, self.jour) + if !self.user.allowed_to?(:as_teacher, self.jour) && self.jour_type == "Course" course_member_score(self.jour_id, self.user_id, "JournalForMessage") end end diff --git a/app/models/memo.rb b/app/models/memo.rb index 7c4fbdcf1..ee9f4c8db 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,36 @@ 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 , + analysis: { + char_filter: { + and_filter: { + type: "mapping", + mappings: [ "&=> and "] + } + }, + analyzer: { + my_analyzer: { + type: 'custom', + tokenizer: 'standard', + filter: ['classic'], + char_filter: ['html_strip'] + } + } + } + } do + mappings dynamic: 'false' do + indexes :subject, analyzer: 'smartcn',index_options: 'offsets'#, char_filter: 'html_strip' + indexes :content, analyzer:'my_analyzer',index_options: 'offsets',search_analyzer: 'smartcn' + 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 +79,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 +89,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 +265,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..144f3859f 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 @@ -45,7 +46,7 @@ class StudentWork < ActiveRecord::Base #成绩计算 def set_final_score homework,student_work if homework && homework.homework_detail_manual - if homework.homework_type == 1 #匿评作业 + if homework.homework_type != 2 #匿评作业 if homework.teacher_priority == 1 #教师优先 if student_work.teacher_score student_work.final_score = student_work.teacher_score 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..0c8d65481 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)}, @@ -409,10 +410,14 @@ class User < Principal else name = lastname+firstname end - name = name.empty? || name.nil? ? login : name - name + name.empty? || name.nil? ? login : name end ## end + + def get_at_show_name + name = show_name + name = "#{name} #{self.login}" if name != self.login + end #added by nie def count_new_journal_reply diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 8b39c39ab..8df42fb41 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -228,7 +228,7 @@ class UsersService end course_list end - + #修改密码 def change_password params @current_user = User.find(params[:current_user_id]) diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index f87741dd9..e4d053d49 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -1,4 +1,6 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false) %> +<% end %>

<%=l(:label_system_message)%>


diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb index cfbe68085..02a613e6e 100644 --- a/app/views/attachments/destroy.js.erb +++ b/app/views/attachments/destroy.js.erb @@ -1,8 +1,7 @@ <% if @is_destroy%> $("#attachment_<%= @attachment.id%>").remove(); - if(document.getElementById("uploadReviseBox")) { - $("#uploadReviseBox").removeClass('disable_link'); - $("#choose_revise_attach").attr("onclick","_file.click();"); + if(document.getElementById("revise_attachment_div_<%= @attachment.id%>")) { + $("#revise_attachment_div_<%= @attachment.id%>").remove(); } <%else%> var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>'); diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb index 554702d97..9fb8cbc59 100644 --- a/app/views/bids/edit.html.erb +++ b/app/views/bids/edit.html.erb @@ -1,5 +1,7 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'prettify','/assets/kindeditor/pasteimg' %> -<%= stylesheet_link_tag 'prettify'%> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: true) %> +<% end %> + <%= labelled_form_for @bid,:html => { :multipart => true } do |f| %> <%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}",:f=>f,:edit_mode => true} %> <% end %> diff --git a/app/views/blog_comments/_edit.html.erb b/app/views/blog_comments/_edit.html.erb index 375c948d4..c7065ece4 100644 --- a/app/views/blog_comments/_edit.html.erb +++ b/app/views/blog_comments/_edit.html.erb @@ -1,9 +1,13 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false) %> + <%= javascript_include_tag 'blog' %> +<% end %> +
- +

diff --git a/app/views/blog_comments/_new.html.erb b/app/views/blog_comments/_new.html.erb index 48f152c4e..e336c7d01 100644 --- a/app/views/blog_comments/_new.html.erb +++ b/app/views/blog_comments/_new.html.erb @@ -1,9 +1,12 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'blog' %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false) %> + <%= javascript_include_tag 'blog' %> +<% end %>
- +

-
<% if @subPage_title == l(:label_student_list)%> <%= render :partial => 'course_student', :locals => {:members => @members} %> <% else%> <%= render :partial => 'course_teacher', :locals => {:members => @members} %> <% end%> + diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 650127aef..634f26495 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -89,7 +89,7 @@ <% end %> <% if @course.is_delete == 1 %> -
<%=link_to "恢复该课程", renew_course_path(@course) %>
+
<%=link_to "恢复该课程", renew_course_path(@course) %>
<% else %>
<%=link_to "删除该课程", course_path(@course), :method => :delete, :confirm=>"确认要删除该课程吗?" %> diff --git a/app/views/courses/syllabus.html.erb b/app/views/courses/syllabus.html.erb index bb3421cba..f4b8ce8a4 100644 --- a/app/views/courses/syllabus.html.erb +++ b/app/views/courses/syllabus.html.erb @@ -1,9 +1,14 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <%= javascript_include_tag 'blog' %> +<% end %> + -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> +<% end %> +
<% reply_allow = JournalsForMessage.create_by_user? User.current %>

<%= l(:label_user_response) %>

diff --git a/app/views/projects/settings/_new_edit.html.erb b/app/views/projects/settings/_new_edit.html.erb index b38871a60..1d204a52b 100644 --- a/app/views/projects/settings/_new_edit.html.erb +++ b/app/views/projects/settings/_new_edit.html.erb @@ -26,4 +26,13 @@ 保存 <% end %> +<% if User.current.member_of?(@project) && Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") %> +
+ + <%= link_to(l(:button_delete_project), { :controller => 'projects', :action => 'archive', :id => @project, :status => params[:status], :type =>"project" }, + :data => {:confirm => l(:text_are_you_sure)}, :method => :post) unless @project.archived? %> + <%#=link_to "删除该课程", course_path(@course), :method => :delete, :confirm=>"确认要删除该课程吗?" %> + (友情提示:删除该项目后如果您想恢复该项目,请联系系统管理员!) +
+<% end %>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index aaa740d24..e7616a020 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -53,7 +53,7 @@ - <%=link_to"全部提交次数", {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> + <%=link_to"提交明细", {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %>
diff --git a/app/views/student_work/_choose_group_member.html.erb b/app/views/student_work/_choose_group_member.html.erb new file mode 100644 index 000000000..1ec8ed0fa --- /dev/null +++ b/app/views/student_work/_choose_group_member.html.erb @@ -0,0 +1,96 @@ +
+
+
请添加小组成员
+
+
+
+
+
+ +
+
+
    +
    +
      +
    • <%=User.current.show_name %> + <% unless User.current.user_extensions.student_id == "" %> + (<%=User.current.user_extensions.student_id %>) + <% end %> +
    • +
    +
    + + +
    +
    + \ No newline at end of file diff --git a/app/views/student_work/_evaluation_title.html.erb b/app/views/student_work/_evaluation_title.html.erb index cfd9632c2..7398dbee1 100644 --- a/app/views/student_work/_evaluation_title.html.erb +++ b/app/views/student_work/_evaluation_title.html.erb @@ -1,8 +1,12 @@
    • 作品名称 - 姓名 - 学号 + <% if @homework.homework_type != 3 %> + 姓名 + 学号 + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> + 关联项目 + <% end %>
    • diff --git a/app/views/student_work/_evaluation_un_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb index 4ed0a538a..66b96431e 100644 --- a/app/views/student_work/_evaluation_un_title.html.erb +++ b/app/views/student_work/_evaluation_un_title.html.erb @@ -1,8 +1,12 @@
      • - 作品名称 - 姓名 - 学号 + 作品名称 + <% if @homework.homework_type != 3 %> + 姓名 + 学号 + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> + 关联项目 + <% end %>
      • diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb index 2a0962244..641405fe4 100644 --- a/app/views/student_work/_evaluation_un_work.html.erb +++ b/app/views/student_work/_evaluation_un_work.html.erb @@ -13,14 +13,22 @@
  • -
      -
    • - <%= student_work.user.show_name%> -
    • -
    • - <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> -
    • -
    + <% if @homework.homework_type != 3 %> +
      +
    • + <%= student_work.user.show_name%> +
    • +
    • + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> +
    • +
    + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
      +
    • + <%= student_work.project.name %> +
    • +
    + <% end %>
  • diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index e336b0282..db680cbec 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -1,46 +1,67 @@
      - <% is_my_work = student_work.user == User.current%> + <% if @homework.homework_type != 3 %> + <% is_my_work = student_work.user == User.current%> + <% else %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% is_my_work = pro && pro.student_work_id == student_work.id%> + <% end %>
      • <% if is_my_work%>
      • <%= image_tag(url_to_avatar(student_work.user),width:"40", height: "40") %>
      • -
      • +
      • <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
        <%= link_to student_work_name, student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%>
      • -
          -
        • - <%= student_work.user.show_name%> -
        • -
        • - <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> -
        • -
        + <% if @homework.homework_type != 3 %> +
          +
        • + <%= student_work.user.show_name%> +
        • +
        • + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> +
        • +
        + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
          +
        • + <%= student_work.project.name %> +
        • +
        + <% end %>
      • <% else%>
      • <%= image_tag(url_to_avatar(""),width:"40", height: "40") %>
      • -
      • +
      • <%= link_to "匿名的作品", student_work_path(student_work),:remote => true,:title => student_work_name, :class => "linkGrey f14 StudentName break_word width285"%>
      • -
          -
        • - 匿名 -
        • -
        • - -- -
        • -
        + <% if @homework.homework_type != 3 %> +
          +
        • + 匿名 +
        • +
        • + -- +
        • +
        + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
          +
        • + 匿名 +
        • +
        + <% end %>
      • <% end%> diff --git a/app/views/student_work/_new_student_work_alert.html.erb b/app/views/student_work/_new_student_work_alert.html.erb index 8e0c8a954..42a891d60 100644 --- a/app/views/student_work/_new_student_work_alert.html.erb +++ b/app/views/student_work/_new_student_work_alert.html.erb @@ -2,7 +2,11 @@

        当前作业 - 已开启匿评 + <% if @homework.homework_detail_manual.comment_status == 2 %> + 已开启匿评 + <% elsif @homework.homework_detail_manual.comment_status == 3 %> + 已关闭匿评 + <% end %> 您提交作品后将 不会收到任何匿评作品, 您的作品也 diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb new file mode 100644 index 000000000..43f59c9c9 --- /dev/null +++ b/app/views/student_work/_relate_project.html.erb @@ -0,0 +1,58 @@ +

        + 关联项目 + + <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:homework=>@homework.id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course,:course_activity =>@course_activity),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %> + +
        + +
          +

          + + +
          + <% end %> +
          + \ No newline at end of file diff --git a/app/views/student_work/_revise_attachment.html.erb b/app/views/student_work/_revise_attachment.html.erb index 968a4853b..4d85b1813 100644 --- a/app/views/student_work/_revise_attachment.html.erb +++ b/app/views/student_work/_revise_attachment.html.erb @@ -4,7 +4,7 @@
          追加修订附件
          -
          +
          追加附件: <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 2} %> 追加时间:<%=format_time revise_attachment.created_on.to_s %>  (<%=revise_attachment_status @homework,revise_attachment %>) @@ -15,7 +15,7 @@ 追加修订附件
          <% if revise_attachment %> -
          +
          追加附件: <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 1} %> 追加时间:<%=format_time revise_attachment.created_on.to_s %> diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 993b0f2aa..f92614e10 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -1,5 +1,12 @@
          + <% is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin? %> + <% if @homework.homework_type != 3 %> + <% is_my_work = work.user == User.current%> + <% else %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% is_my_work = pro && pro.student_work_id == work.id%> + <% end %>
          • 上交时间: @@ -15,7 +22,7 @@ <%= link_to "",edit_student_work_path(work),:class => "pic_edit",:title => "修改"%>
          • <% end%> - <% if @homework.homework_detail_manual.comment_status == 3 && work.user != User.current%> + <% if @homework.homework_detail_manual.comment_status == 3 && !is_my_work %>
          • <%= render :partial => 'student_work_praise' %> @@ -25,11 +32,29 @@ - <% if work.project%> -
          • - 关联项目: - <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + <% if @homework.homework_type == 3 && work.student_work_projects && (@homework.homework_detail_manual.comment_status != 2 || is_my_work || is_teacher ) %> +
            +
          • + 参与人员: + <%= link_to(work.user.show_name+"(组长)", user_path(work.user.id), :class => "linkBlue" )%> + <% members = work.student_work_projects.where("is_leader = 0") %> + <% members.each do |member| if !members.empty? %> + 、<%=link_to((User.find member.user_id).show_name, user_path(member.user.id), :class => "linkBlue" ) %> + <% end %> + <% end %>
          • + <% if @homework.homework_detail_group.base_on_project == 1 %> +
          • + 关联项目: + <% if work.project.is_public || User.current.member_of?(work.project) || User.current.admin? %> + <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + <% else %> + <%=work.project.name %> + <% end %> + <%#= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + (综合评分:<%=work.project.project_score.score.to_i %>) +
          • + <% end %> <% end%>
          • @@ -52,7 +77,7 @@
          • - <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current)%> + <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && !is_my_work)%>
            <%= render :partial => 'add_score',:locals => {:work => work,:score => score}%> diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index e9b056c84..5598092e9 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -40,12 +40,17 @@ <% end%>
            - <% if student_work.user == User.current && !@is_evaluation %> + <% if @homework.homework_type != 3 && student_work.user == User.current && !@is_evaluation %> <% if @homework.homework_type == 2%> <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> <% else %> <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> <% end %> + <% elsif @homework.homework_type == 3 %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% if pro && pro.student_work_id == student_work.id && !@is_evaluation %> + <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% end %> <% end %>
            diff --git a/app/views/student_work/cancel_relate_project.js.erb b/app/views/student_work/cancel_relate_project.js.erb new file mode 100644 index 000000000..3aa853a00 --- /dev/null +++ b/app/views/student_work/cancel_relate_project.js.erb @@ -0,0 +1,7 @@ +<% if @user_activity_id != -1 %> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else%> +$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); +init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index d506b5542..bfdf8c316 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -48,7 +48,7 @@
            - <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @work, :has_program=>false} %> + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @work, :has_program=>false,:has_group=>false} %>
            diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index ee0dd7e9b..c3a61d4c8 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -34,6 +34,44 @@ ) } } + // 添加组成员 + function show_group_member() { + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/choose_group_member',:locals => {:homework=>@homework}) %>'); + showModal('ajax-modal', '528px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("addMemberCP"); + } + // 关联项目 + function show_project() { + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/relate_project',:locals => {:homework=>@homework}) %>'); + showModal('ajax-modal', '320px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("groupPopUp"); + } + // 作品校验 + function popupRegex(){ + if(regexStudentWorkName()&®exStudentWorkDescription()) + { + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { + $('#ajax-modal').html("

            作品信息完整性校验中,请稍等...

            "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); + } + } else { + $('#ajax-modal').html("

            作品信息完整性校验中,请稍等...

            "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); + } + } + } +
            @@ -78,7 +116,11 @@ 提示:作品名称和描述中不要出现真实的姓名信息
            - + <% if @homework.homework_type == 3 %> + + + <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> + <% end %>
            <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请简洁的概括作品的功能或特性", :onkeyup => "regexStudentWorkName();" %>
            @@ -95,20 +137,29 @@
            - <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %> + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false} %> +
            +
            +
            +
            - -
            + <% if @homework.homework_type == 3 %> + + <% end %> -
            - <%= select_tag :project_id, options_for_select(user_projects_option, @student_work.project_id), {:class => "InputBox W680 fl"} %> + + +
            提交 @@ -118,16 +169,4 @@
            <% end%>
            -
            - \ No newline at end of file +
            \ No newline at end of file diff --git a/app/views/student_work/new_student_work_project.js.erb b/app/views/student_work/new_student_work_project.js.erb new file mode 100644 index 000000000..51df45f13 --- /dev/null +++ b/app/views/student_work/new_student_work_project.js.erb @@ -0,0 +1,5 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/relate_project') %>'); +showModal('ajax-modal', '320px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("groupPopUp"); \ No newline at end of file diff --git a/app/views/student_work/retry_work.js.erb b/app/views/student_work/retry_work.js.erb index c5fca76d4..c6f354875 100644 --- a/app/views/student_work/retry_work.js.erb +++ b/app/views/student_work/retry_work.js.erb @@ -1,2 +1,2 @@ hideModal('#popbox02'); -$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false})%>"); \ No newline at end of file +$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false})%>"); \ No newline at end of file diff --git a/app/views/student_work/search_course_students.js.erb b/app/views/student_work/search_course_students.js.erb new file mode 100644 index 000000000..1cea9f27e --- /dev/null +++ b/app/views/student_work/search_course_students.js.erb @@ -0,0 +1,37 @@ +$("#all_students_list").empty(); +<% @users.each do |user|%> + var link = "
          • <%=user.show_name %>"; + <% unless user.user_extensions.student_id == "" %> + link += "(<%=user.user_extensions.student_id %>)"; + <% end %> + link += "
          • "; + $("#all_students_list").append(link); + + var str = ""; + var lists = $("#choose_students_list li"); + if(lists.length > 0) { + for(var i=0; i + if (str.indexOf(<%=user.id.to_s %>) < 0) { + $("#student_<%=user.id %>").one("click",function choose_student() { + var li = "
          • + li += " onclick='delete_student(<%=user.id %>);'"; + <% end %> + li += ">" + $("#student_<%=user.id %>").html()+"
          • "; + $("#choose_students_list").append(li); + }); + } + <% else %> + if (str.indexOf(<%=user.id.to_s %>) < 0) { + $("#student_<%=user.id %>").attr("title","该学生已加入其它分组"); + } + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/search_user_projects.js.erb b/app/views/student_work/search_user_projects.js.erb new file mode 100644 index 000000000..7751821a5 --- /dev/null +++ b/app/views/student_work/search_user_projects.js.erb @@ -0,0 +1,9 @@ +<% if @first == 1 && @project_ids.empty? %> + $("#no_search_result").show(); +<% else %> + $("#search_project_list").html(""); + <% @project_ids.each do |project|%> + link = "
          • "; + $("#search_project_list").append(link ); + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/student_work_project.js.erb b/app/views/student_work/student_work_project.js.erb new file mode 100644 index 000000000..405dccca4 --- /dev/null +++ b/app/views/student_work/student_work_project.js.erb @@ -0,0 +1,8 @@ +hideModal("#popbox02"); +<% if @user_activity_id != -1 %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else%> + $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); + init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 309b8b95a..a3aa5d5b1 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -44,7 +44,27 @@ 教师评阅中 <% end%> <% end%> +
            + <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1%> + 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! + <% elsif activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 0%> + 系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合! + <% end %>
            + <% if activity.homework_type == 3 && !is_teacher && activity.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(activity.course)%> + <% projects = cur_user_projects_for_homework activity %> + <% works = cur_user_works_for_homework activity %> + <% if works.nil? && projects.nil? %> +
            + <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => activity.id,:is_in_course=>-1,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' %> + <%#= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %> +
            + <% elsif works.nil? %> +
            + <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => activity.id,:is_in_course=>-1,:user_activity_id=>user_activity_id,:course_activity=>course_activity), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %> +
            + <% end %> + <% end %>
            <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> <%= user_for_homework_common activity,is_teacher %> @@ -77,6 +97,26 @@ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %>
            + <% if activity.homework_type == 3 && !activity.student_work_projects.empty? && activity.homework_detail_group.base_on_project == 1 %> +
            +
            + + 已关联项目: +
            + <% activity.student_work_projects.where("is_leader = 1").each do |pro| %> +
            + <% project = Project.find pro.project_id %> + <% if project.is_public || User.current.member_of?(project) || User.current.admin?%> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> + <% else %> + <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> + <% end %> +

            <%=project.project_score.score.to_i %>

            +
            + <% end %> +
            + <% end %> +
            <% if is_teacher%> <% comment_status = activity.homework_detail_manual.comment_status %>
            diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 669953afa..4f1d3a5d8 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -1,4 +1,7 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor" %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> +<% end %> + -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> +<% end %> +
            <% reply_allow = JournalsForMessage.create_by_user? User.current %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 640f98b1f..9f7b90ee4 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -45,12 +45,12 @@
          • <% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %> - <%= link_to "作业题目:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id), + <%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> <% else %> - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> @@ -103,7 +103,7 @@ user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %> ">发布的作业:
          • - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> @@ -142,7 +142,7 @@ ">启动了作业匿评:
          • - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
          • @@ -173,19 +173,25 @@ <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">关闭了作业匿评:
          • - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))"%>
          • <%= time_tag(ma.created_at).html_safe %>
          @@ -202,7 +208,7 @@ ">启动作业匿评失败
        • - <%= link_to "作业题目:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + <%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}", :onmouseover => "message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
        • @@ -213,7 +219,6 @@

        • <%= time_tag(ma.created_at).html_safe %>
        + <% end %> <% end %> - + <% if ma.forge_message_type == "RemoveFromProject" %> + <% unless ma.project.nil? %>
    • <%= time_tag(ma.created_at).html_safe %>
    • + <% end %> <% end %> <% if ma.forge_message_type == "ProjectInvite" %> diff --git a/app/views/users/search_user_course.js.erb b/app/views/users/search_user_course.js.erb index 60ddd6d9c..2a0c98cad 100644 --- a/app/views/users/search_user_course.js.erb +++ b/app/views/users/search_user_course.js.erb @@ -15,4 +15,6 @@ $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); $('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup"); -$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); \ No newline at end of file +$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); +var val = $("#search_course_input").val(); +$("#search_course_input").val("").focus().val(val); diff --git a/app/views/users/search_user_project.js.erb b/app/views/users/search_user_project.js.erb index 26a0f265c..f38d9edc8 100644 --- a/app/views/users/search_user_project.js.erb +++ b/app/views/users/search_user_project.js.erb @@ -12,3 +12,6 @@ $('#ajax-modal').before(" '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/users/user_newfeedback.html.erb b/app/views/users/user_newfeedback.html.erb index 4962ea8f4..30ba54b28 100644 --- a/app/views/users/user_newfeedback.html.erb +++ b/app/views/users/user_newfeedback.html.erb @@ -1,4 +1,8 @@ -<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor","user" %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <%= javascript_include_tag "user" %> +<% end %> +