diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7f1383bc..c1c25151 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -132,6 +132,15 @@ class ApplicationController < ActionController::Base end end + DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) + # 随机生成字符 + def generates_identifier(container, num) + code = DCODES.sample(num).join + while container.exists?(identifier: code) do + code = DCODES.sample(num).join + end + code + end def ec_public_auth major_school unless User.current.admin? || major_school.template_major || major_school.school.users.where(:id => User.current.id).count > 0 || diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 960030c9..fff508a8 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -31,9 +31,9 @@ class CollegesController < ApplicationController end def verification_school_identifier - school = School.where(:identifier => params[:identifier]).first - status = school.present? ? 1 : 0 - render :json => {status: status} + schools = School.where(identifier: params[:identifier]) + schools = schools.where('id != ?', params[:school_id]) if params[:school_id].present? + render :json => { status: schools.exists? ? 1 : 0 } end def online_school diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 421e5da3..e87c7297 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -2394,9 +2394,10 @@ class CoursesController < ApplicationController sheet1[4,0] = "排名" sheet1[4,1] = "学生姓名" sheet1[4,2] = "昵称" - sheet1[4,3] = "学号" - sheet1[4,4] = "分班" - current_col = 4 + sheet1[4,3] = "邮箱" + sheet1[4,4] = "学号" + sheet1[4,5] = "分班" + current_col = 5 homeworks.where(:homework_type => 4).each do |homework| sheet1[4,current_col+=1] = "#{homework.name}" end @@ -2428,6 +2429,7 @@ class CoursesController < ApplicationController sheet1[count_row,column]= i+1 sheet1[count_row,column+=1] = member.user.show_real_name sheet1[count_row,column+=1] = member.user.login + sheet1[count_row,column+=1] = member.user.mail sheet1[count_row,column+=1] = member.user.user_extensions.student_id sheet1[count_row,column+=1] = member.course_group_id == 0 ? "暂无" : member.course_group.name # current_col = 5 diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 5b03010d..e404c5ee 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -30,9 +30,9 @@ class HomeworkCommonController < ApplicationController @homework_type = params[:homework_type].to_i @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) if @search - @homework_commons = @course.homework_commons.where(:homework_type => @homework_type).where("homework_commons.name like '%#{@search}%'").includes(:homework_detail_manual, :homework_group_settings, :student_works) + @homework_commons = @course.homework_commons.where(:homework_type => @homework_type).where("homework_commons.name like '%#{@search}%'") else - @homework_commons = @course.homework_commons.where(:homework_type => @homework_type).includes(:homework_detail_manual, :homework_group_settings, :student_works) + @homework_commons = @course.homework_commons.where(:homework_type => @homework_type) end if @is_teacher @homework_commons = @homework_commons @@ -72,6 +72,9 @@ class HomeworkCommonController < ApplicationController @is_new = params[:is_new] @homeworks = paginateHelper @homework_commons,15 + + @homeworks = @homework_type == 4 ? @homeworks.includes(:homework_detail_manual, :homework_group_settings, [homework_commons_shixuns: :shixun]) : + @homeworks.includes(:homework_detail_manual, :homework_group_settings) #设置at已读 =begin ids = @homeworks.inject([]) do |ids, homework| diff --git a/app/controllers/managements/schools_controller.rb b/app/controllers/managements/schools_controller.rb index f27e00ae..a5c789ff 100644 --- a/app/controllers/managements/schools_controller.rb +++ b/app/controllers/managements/schools_controller.rb @@ -4,8 +4,8 @@ class Managements::SchoolsController < Managements::BaseController def statistics @sub_type = 1 - params[:sort_by] = :teacher_count if params[:sort_by].blank? - params[:sort_direction] = :desc if params[:sort_direction].blank? + params[:sort_by] = params[:sort_by].presence || :teacher_count + params[:sort_direction] = params[:sort_direction].presence || :desc service = Management::SchoolReportService.new(params) @obj_count, @schools = service.call @@ -20,8 +20,8 @@ class Managements::SchoolsController < Managements::BaseController def data_grow @sub_type = 2 params[:data_type] ||= 'grow' - params[:sort_by] = :teacher_increase_count if params[:sort_by].blank? - params[:sort_direction] = :desc if params[:sort_direction].blank? + params[:sort_by] = params[:sort_by].presence || :teacher_increase_count + params[:sort_direction] = params[:sort_direction].presence || :desc service = Management::SchoolDataGrowService.new(params) @grow_summary = service.grow_summary @@ -31,7 +31,7 @@ class Managements::SchoolsController < Managements::BaseController end def data_contrast - params[:contrast_column] = :teacher_increase_count if params[:contrast_column].blank? + params[:contrast_column] = params[:contrast_column].presence || :teacher_increase_count params[:sort_direction] ||= :desc params[:sort_by] = :percentage diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index b4e5b0b4..769481b0 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -851,6 +851,15 @@ class ManagementsController < ApplicationController @front_js = eva.front_js end + def evaluate_simple + page = params[:page] + @recodes = EvaluateRecord.where("created_at > ?", Time.now - 1.days).reorder("consume_time desc") + @recodes_count = @recodes.size + @record_pages = Paginator.new @recodes_count, 20, page || 1 + @offset ||= @record_pages.offset + @recodes = paginateHelper @recodes, 20 + end + # 评测时间列表 def evaluate_records shixun_tomcat = Redmine::Configuration['shixun_tomcat'] @@ -866,7 +875,7 @@ class ManagementsController < ApplicationController keyword = params[:keyword] limit = 20 - if search + if search.present? if "u_name" == keyword @evaluate_recods = EvaluateRecord.joins("join users u on evaluate_records.user_id = u.id").where("concat(u.lastname, u.firstname) like '%#{search}%'") # @evaluate_recods = EvaluateRecord.where(user_id: User.where("concat(lastname, firstname) like '%#{search}%'").pluck(:id)) @@ -875,7 +884,12 @@ class ManagementsController < ApplicationController # @evaluate_recods = EvaluateRecord.where(user_id: UserExtensions.where(school_id: School.where("name like '%#{search}%'").pluck(:id)).pluck(:user_id)) end else - @evaluate_recods = EvaluateRecord.where("0=0") + @evaluate_recods = EvaluateRecord.where(nil) + end + + if params[:beginTime].present? + endTime = params[:endTime].present? ? params[:endTime] : Time.now + @evaluate_recods = @evaluate_recods.where("created_at >= ? and created_at <= ?", params[:beginTime], endTime) end @evaluate_recods_count = @evaluate_recods.count @@ -1504,7 +1518,7 @@ end if search.blank? @schools = School.where("0=0") else - @schools = School.where("name like '%#{search}%'") + @schools = School.where("name like ?", "%#{search}%") end if params[:index] == '8' @schools = @schools.reorder("created_at #{@sx_order}") @@ -4194,7 +4208,7 @@ end sheet1 = book.create_worksheet :name => "course" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue - sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间","创建时间"]) + sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","评测次数", "私有","状态","创建者单位","创建者","动态时间","创建时间"]) count_row = 1 courses.each do |course| school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name @@ -4206,12 +4220,13 @@ end sheet1[count_row,4] = course.homework_commons.where(:homework_type => 1).count sheet1[count_row,5] = course.homework_commons.where(:homework_type => 4).count sheet1[count_row,6] = course.exercises.count - sheet1[count_row,7] = course.is_public.to_i == 1 ? '否' : '是' - sheet1[count_row,8] = course.is_end ? "已结束" : "正在进行" - sheet1[count_row,9] = school - sheet1[count_row,10] = teacher_name - sheet1[count_row,11] = format_time(course.updatetime) - sheet1[count_row,12] = format_time(course.created_at) + sheet1[count_row,7] = course.evaluate_count + sheet1[count_row,8] = course.is_public.to_i == 1 ? '否' : '是' + sheet1[count_row,9] = course.is_end ? "已结束" : "正在进行" + sheet1[count_row,10] = school + sheet1[count_row,11] = teacher_name + sheet1[count_row,12] = format_time(course.updatetime) + sheet1[count_row,13] = format_time(course.created_at) count_row += 1 end book.write xls_report diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 09626c31..6316446e 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -467,7 +467,7 @@ class MyshixunsController < ApplicationController # taskId 即返回的game id # 返回结果:params [:stauts] 0 表示运行结果成功,其它则失败 - # compile_success 1 表示成功; 0表示失败 + # compile_success 1 表示成功; 0表示编译失败; -1 表示创建pod失败; -2 表示克隆代码失败 # msg 错误信息 # output 为测试用户编译输出结果 # myshixun:status 1为完成实训 @@ -475,7 +475,7 @@ class MyshixunsController < ApplicationController # resubmit 1:表示已通关后重新评测;0:表示非重新评测 # retry_status 0:初始值;1:重新评测失败;2:重新评测成功 # tpiRepoPath 中间层图片的workspace路径 - # params[:jsonTestDetails] = '{"buildID":"19284","compileSuccess":"1", + # params[:jsonTestDetails] = '{"buildID":"19284","compileSuccess":"1","createPodStatus": "1", "downloadStatus": "1", # "msg":[{"caseId":"1","expectedOutput":"MSAyIDMNCg","input":"MiAzIDE","output":"MSAyIDMNCg","passed":"1"}, # {"caseId":"2","expectedOutput":"LTMgMSA2DQo","input":"LTMgNiAx","output":"LTMgMSA2DQo","passed":"1"}, # {"caseId":"3","expectedOutput":"LTcgLTUgLTMNCg","input":"LTcgLTMgLTU","output":"LTcgLTUgLTMNCg","passed":"1"}], @@ -497,7 +497,19 @@ class MyshixunsController < ApplicationController resubmit = jsonTestDetails['resubmit'] outPut = tran_base64_decode64(jsonTestDetails['outPut']) jenkins_testsets = jsonTestDetails['msg'] - compile_success = jsonTestDetails['compileSuccess'] + compile_success = jsonTestDetails['compileSuccess'] + # # 创建pod的状态 0 失败 1 成功 + # create_pod_status = jsonTestDetails['createPodStatus'] + # # 克隆代码的装填 0 失败 1 成功 + # clone_code_status = jsonTestDetails['downloadStatus'] + # # 1表示编译成功;0 表示运行异常; -1 表示克隆代码失败; -2 表示创建pod失败 + # compile_success = if clone_code_status == "0" + # -1 + # elsif create_pod_status == "0" + # -2 + # else + # jsonTestDetails['compileSuccess'] + # end # message = Base64.decode64(params[:msg]) unless params[:msg].blank? logger.info(outPut) game = Game.find(game_id) @@ -523,7 +535,7 @@ class MyshixunsController < ApplicationController end logger.info("#############status: #{status}") logger.info("#############resubmit: #{resubmit}") - record = EvaluateRecord.where(:game_id => game_id).first + record = EvaluateRecord.where(:identifier => params[:sec_key]).first logger.info("training_task_status start#3**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") # status:0表示评测成功 diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index df1fdcd6..8885353c 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -586,9 +586,9 @@ class StudentWorkController < ApplicationController if @stundet_works.size != 0 if @order == "student_id" - @stundet_works = @stundet_works.includes(:user => {:user_extensions => []}, :project => {}, :student_works_scores => {}).order("user_extensions.student_id #{@b_sort}") + @stundet_works = @stundet_works.includes(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}") else - @stundet_works = @stundet_works.includes(:user => {:user_extensions => []}, :project => {}, :student_works_scores => {}).order("#{@order} #{@b_sort}") + @stundet_works = @stundet_works.order("#{@order} #{@b_sort}") end end @@ -615,6 +615,16 @@ class StudentWorkController < ApplicationController _index @stundet_works = paginateHelper @stundet_works, @limit + if @stundet_works.size != 0 + @stundet_works = if @homework.homework_type == 1 + @stundet_works.includes(:student_works_scores, [user: :user_extensions]) + elsif @homework.homework_type == 3 + @stundet_works.includes(:student_works_scores, [project: :project_score], [user: :user_extensions]) + elsif @homework.homework_type == 4 + @stundet_works.includes(:student_works_scores, [myshixun: :games], [user: :user_extensions]) + end + @members = @course.members.where(user_id: @stundet_works.pluck(:user_id)).select([:user_id, :course_group_id]) + end respond_to do |format| format.js format.html { render :layout => 'base_edu'} diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ade22d4e..01a08d95 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -191,7 +191,7 @@ module ApplicationHelper # 分班 def member_group_name members, user_id - member = members.where(:user_id => user_id).first + member = members.find_by_user_id(user_id) group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name end @@ -269,12 +269,12 @@ module ApplicationHelper end # 实训作品列表的提交状态 - def list_work_status work, homework, member + def list_work_status work, homework, course_group_id if work.work_status == 0 str = "未提交" else if work.compelete_status == 0 - setting_time = homework_group_setting homework, member.try(:course_group_id) + setting_time = homework_group_setting homework, course_group_id end_time = setting_time.end_time.present? ? setting_time.end_time : homework.end_time if end_time > Time.now || (homework.allow_late && !homework.course.is_end) str = "正在提交" @@ -1317,11 +1317,11 @@ module ApplicationHelper def had_commit_studentwork_count homework_common member = homework_common.course.members.where(:user_id => User.current.id).first student_works = homework_common.student_works - if member.present? && member.teacher_course_groups.count > 0 + if member.present? && member.teacher_course_groups.size > 0 group_students = homework_common.course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) student_works = student_works.where(:user_id => group_students) end - student_works.where("work_status !=?", 0).count + student_works.where("work_status !=?", 0).size end # 实训作业的有效作品数 @@ -1357,11 +1357,11 @@ module ApplicationHelper def had_uncommit_studentwork_count homework_common member = homework_common.course.members.where(:user_id => User.current.id).first student_works = homework_common.student_works - if member.present? && member.teacher_course_groups.count > 0 + if member.present? && member.teacher_course_groups.size > 0 group_students = homework_common.course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) student_works = student_works.where(:user_id => group_students) end - student_works.where("work_status =?", 0).count + student_works.where("work_status =?", 0).size end # 未评阅 @@ -1369,12 +1369,12 @@ module ApplicationHelper #count = StudentWorksScore.find_by_sql("SELECT count(distinct student_work_id) as count FROM student_works_scores sws, student_works sw, homework_commons hc where hc.id =#{homework_common.id} and sw.homework_common_id=hc.id and sw.is_delete = 0 and sws.student_work_id = sw.id and sws.user_id=#{User.current.id};").first.try(:count).to_i member = homework_common.course.members.where(:user_id => User.current.id).first student_works = homework_common.student_works - if member.present? && member.teacher_course_groups.count > 0 + if member.present? && member.teacher_course_groups.size > 0 group_students = homework_common.course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) student_works = student_works.where(:user_id => group_students) end - has_comment = StudentWorksScore.where(:student_work_id => student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).count - student_count = student_works.count + has_comment = StudentWorksScore.where(:student_work_id => student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).size + student_count = student_works.size return student_count - has_comment end @@ -6568,7 +6568,7 @@ def update_shixun_work_status homework else setting = homework.homework_group_settings.where("publish_time < '#{Time.now}'") if setting.blank? - student_works = student_works.where("0=1") + student_works = student_works.none else users = homework.course.members.where(:course_group_id => setting.map(&:course_group_id)) student_works = student_works.where(:user_id => users.map(&:user_id)) @@ -6578,7 +6578,7 @@ def update_shixun_work_status homework myshixuns = Myshixun.where(:shixun_id => shixun.id, :user_id => student_works.map(&:user_id)) myshixuns.each do |myshixun| work = student_works.where(:user_id => myshixun.user_id).first - member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{work.user_id}").first + member = homework.course.members.find_by(:user_id => work.user_id) setting_time = homework_group_setting homework, member.try(:course_group_id) games = myshixun.games.where(:challenge_id => challeng_ids) myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil @@ -7220,8 +7220,8 @@ def search_work_member works,name select_works = works else name = name.downcase - select_works = works.select{ |work| work.user.user_extensions[:student_id].to_s.downcase.include?(name) || (work.user[:lastname].to_s.downcase + work.user[:firstname].to_s.downcase).include?(name) - } + select_works = works.joins(user: :user_extensions).where("concat(lastname, firstname) like ? + or student_id like ?", "%#{name}%", "%#{name}%") end select_works end diff --git a/app/models/course.rb b/app/models/course.rb index 843d846d..c6c6d3df 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -500,6 +500,15 @@ class Course < ActiveRecord::Base end end + # 课堂实训作业的评测次数 + def evaluate_count + course_user_ids = self.members.map(&:user_id) + shixun_ids = self.homework_commons.joins(:homework_commons_shixuns).where(homework_type: 4).pluck(:shixun_id) + return 0 if shixun_ids.blank? + Game.joins(:challenge).where(challenges: {shixun_id: shixun_ids}, games: {user_id: course_user_ids}).sum(:evaluate_count) + end + + #课程动态公共表记录 def act_as_course_activity self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id) diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index abe09e08..af466de3 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -150,7 +150,7 @@ class HomeworkCommon < ActiveRecord::Base # 作业的实训 def shixun - Shixun.find(self.homework_commons_shixuns.try(:shixun_id)) + homework_commons_shixuns.shixun end # 作业实训过关的数目 diff --git a/app/models/output.rb b/app/models/output.rb index 8f1547cf..aec0889d 100644 --- a/app/models/output.rb +++ b/app/models/output.rb @@ -1,7 +1,7 @@ class Output < ActiveRecord::Base # attr_accessible :title, :body # actual_output 编程题:实际输出, 选择题: 用户提交的答案(如: 014 对应用户选择为A B E) - # compile_success 1 表示程序未报错,有正常输出, 0.表示程序抛异常了,报错! + # compile_success 1 表示程序未报错,有正常输出, 0.表示程序抛异常了,报错! -1 表示克隆代码失败; -2 表示创建pod失败 default_scope :order => 'query_index desc' belongs_to :game #belongs_to :challenge_choose diff --git a/app/services/games_service.rb b/app/services/games_service.rb index 8b5e486d..91645e84 100644 --- a/app/services/games_service.rb +++ b/app/services/games_service.rb @@ -347,10 +347,12 @@ class GamesService rev = params[:rev] ? params[:rev] : "master" content_modified = 0 ActiveRecord::Base.transaction do + sec_key = generates_identifier(EvaluateRecord, 10) # params[:evaluate] 实训评测时更新必须给的参数,需要依据该参数做性能统计,其它类型的更新可以跳过 # 自动保存的时候evaluate为0;点评测的时候为1 if params[:evaluate] == 1 - record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun.id, :game_id => @game.id) + record = EvaluateRecord.create!(:user_id => current_user.id, :shixun_id => @myshixun.shixun.id, + :game_id => @game.id, :identifier => sec_key) Rails.logger.warn("##game is is #{@game.id}, record id is #{record.id}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") # @myshixun.student_works.update_all(:update_time => Time.now) if !@myshixun.student_works.blank? student_work_time = format("%.3f", (Time.now.to_f - record.created_at.to_f)).to_f @@ -385,7 +387,7 @@ class GamesService if content != last_content && code_file.blank? raise("update file failed") else - return {:success => "success", :resubmit => resubmit ,:content_modified => content_modified} + return {:success => "success", :resubmit => resubmit ,:content_modified => content_modified, sec_key: record.identifier} end end rescue Exception => e @@ -546,7 +548,7 @@ class GamesService :testCases => "#{testCases}", :resubmit => "#{resubmit}", :times => params[:first].to_i, :podType => shixun.webssh, :containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}", :tpmScript => "#{tpmScript}", :timeLimit => "#{shixun.exec_time}", :content_modified => content_modified, :persistenceName => shixun.identifier, - :isPublished => (shixun.status < 2 ? 0 : 1)} + :isPublished => (shixun.status < 2 ? 0 : 1), :sec_key => params[:sec_key]} # 评测有文件输出的需要特殊传字段 path:表示文件存储的位置 params['file'] = Base64.urlsafe_encode64({:path => "#{game_challenge.picture_path}"}.to_json) if game_challenge.picture_path.present? @@ -569,7 +571,8 @@ class GamesService # ----单测模式end return {:result => "success", :resubmit => resubmit, :ableToCreate => res['ableToCreate'], :waitNum => res['waitNum'], - :waitingTime => res['waitingTime'], :position => game_challenge.position, :port => res['port'], :had_done => game.had_done } + :waitingTime => res['waitingTime'], :position => game_challenge.position, :port => res['port'], + :had_done => game.had_done} rescue Exception => e Rails.logger.error("评测出错,详情:" + e.message) return {:result => 'fail', :contents =>"实训云平台繁忙(繁忙等级:502),请稍后刷新并重试", :position => game_challenge.position, :had_done => game.had_done} @@ -878,7 +881,7 @@ class GamesService mirror_name = shixun.mirror_name # 轮询结束,更新评测耗时 - e_record = EvaluateRecord.where(:game_id => game.id).first + e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first if game_status == 0 || game_status == 2 if e_record front_js = format("%.3f", (Time.now.to_f - e_record.try(:updated_at).to_f)).to_f diff --git a/app/views/attachments/_form_attachments.html.erb b/app/views/attachments/_form_attachments.html.erb index e1d6b3b5..58ae4aa0 100644 --- a/app/views/attachments/_form_attachments.html.erb +++ b/app/views/attachments/_form_attachments.html.erb @@ -49,8 +49,9 @@ <%= javascript_include_tag 'attachments' %> +
+
+

耗时详情

+ +
+
+
    +
  1. 总耗时:<%= @consume_time %>
  2. +
  3. 作品更新:<%= @student_work %>
  4. +
  5. 文件更新:<%= @file_update %>
  6. +
  7. 中间层总耗时:<%= @brige %>
  8. +
  9. pull代码:<%= @git_pull %>
  10. +
  11. pod启动:<%= @create_pod %>
  12. +
  13. pod执行:<%= @pod_execute %>
  14. +
  15. 中间层回传:<%= @return_back %>--(中间层出结果传Educoder)
  16. +
  17. 前端轮询:<%= @front_js %>--(局部数据查询,Js轮询)
  18. +
  19. 回调结果存储:<%= @test_cases %>
  20. +
+
+
+<% end %> + +<% if @recodes.present? %> +
+ + + + + + + + + + + + + + + + + + + + + <% @recodes.each_with_index do |record, index| %> + + + + + + + + + + + + + + + + <% end %> + +
序号总耗时作品更新文件更新中间层总耗时pull代码pod启动pod执行中间层回传前端轮询回调结果存储创建时间实训名称
<%= index %><%= record.consume_time %><%= record.student_work %><%= record.file_update %><%= record.brige %><%= record.git_pull %><%= record.create_pod %><%= record.pod_execute %><%= record.return_back %><%= record.front_js %><%= record.test_cases %><%= format_time record.created_at %><%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %>
+
+
+
    + <%= pagination_links_full @record_pages, @recodes_count, :per_page_links => false, :remote => false, :flag => true, :is_new => true %> +
+
+
+
+ +
+<% end %> diff --git a/app/views/managements/schools/_data_grow_list.html.erb b/app/views/managements/schools/_data_grow_list.html.erb index 6d42c8b0..27a1ccf3 100644 --- a/app/views/managements/schools/_data_grow_list.html.erb +++ b/app/views/managements/schools/_data_grow_list.html.erb @@ -3,7 +3,8 @@ <% if params[:grow_begin_date].present? %> <%= params[:grow_date_input] %> <% else %> - 昨日至今日, + <%= (Time.current - 5.hour).beginning_of_day.ago(1.days).strftime('%Y-%m-%d') %> 05:00至 + <%= (Time.current - 5.hour).beginning_of_day.strftime('%Y-%m-%d') %> 05:00, <% end %> 新增教师<%= @grow_summary.teacher_increase_count || 0 %>人, 新增学生<%= @grow_summary.student_increase_count || 0 %>人, diff --git a/app/views/managements/upload_logo.html.erb b/app/views/managements/upload_logo.html.erb index 5da56c47..487f3eba 100644 --- a/app/views/managements/upload_logo.html.erb +++ b/app/views/managements/upload_logo.html.erb @@ -130,7 +130,10 @@ if($("#unit_head_route").val().trim() !=""){ $.ajax({ url: "<%= verification_school_identifier_colleges_path %>", - data: {identifier: $("#unit_head_route").val().trim()}, + data: { + school_id: <%= @school.id %>, + identifier: $("#unit_head_route").val().trim() + }, async:false, success: function (data) { if(data.status == 0){ diff --git a/app/views/student_work/_evaluation_un_common_title.html.erb b/app/views/student_work/_evaluation_un_common_title.html.erb index 93b1dd1d..20c85456 100644 --- a/app/views/student_work/_evaluation_un_common_title.html.erb +++ b/app/views/student_work/_evaluation_un_common_title.html.erb @@ -28,7 +28,8 @@ <%= student_work.user.show_real_name %> - <% group_name = new_member_group_name @course.id, student_work.user_id %> + <% group_id = @members.select{|m|m.user_id==student_work.user_id}.first.try(:course_group_id) %> + <% group_name = group_id.to_i == 0 ? '未分班' : @course.course_groups.find_by_id(group_id).name %> <%= group_name %> diff --git a/app/views/student_work/_evaluation_un_group_title.html.erb b/app/views/student_work/_evaluation_un_group_title.html.erb index 0d2842c6..9bc44e9b 100644 --- a/app/views/student_work/_evaluation_un_group_title.html.erb +++ b/app/views/student_work/_evaluation_un_group_title.html.erb @@ -33,7 +33,8 @@ <%= student_work.user.show_real_name %> - <% group_name = member_group_name @homework.course.members, student_work.user_id %> + <% group_id = @members.select{|m|m.user_id==student_work.user_id}.first.try(:course_group_id) %> + <% group_name = group_id.to_i == 0 ? '未分班' : @course.course_groups.find_by_id(group_id).name %> <%= group_name %> diff --git a/app/views/student_work/_evaluation_un_shixun_title.html.erb b/app/views/student_work/_evaluation_un_shixun_title.html.erb index 1666939e..d732fcf7 100644 --- a/app/views/student_work/_evaluation_un_shixun_title.html.erb +++ b/app/views/student_work/_evaluation_un_shixun_title.html.erb @@ -25,8 +25,8 @@ <%= student_work.user.show_real_name %> - <% member = Member.find_by_sql("select course_group_id from members where course_id = #{@homework.course_id} and user_id = #{student_work.user_id}").first %> - <% group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name %> + <% group_id = @members.select{|m|m.user_id==student_work.user_id}.first.try(:course_group_id) %> + <% group_name = group_id.to_i == 0 ? '未分班' : @course.course_groups.find_by_id(group_id).name %> <%= group_name %> @@ -35,7 +35,7 @@ <%= student_id %> - <% status = list_work_status student_work, @homework, member %> + <% status = list_work_status student_work, @homework, group_id %> <%= status %> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index d4352309..99384dfc 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -101,16 +101,16 @@ <% end %> <%= link_to "导出成绩", student_work_index_path(:homework => @homework.id, :order => @order, :sort => @b_sort, :name => @name, :group => @group, :comment => @comment, :status => @status, :format => 'xls'), :class => 'fr mt3 ml15 white-btn orange-btn', :id => "export_student_work" %> - <% if @homework.homework_detail_manual.try(:comment_status) == 0 || @homework.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %> + <% if @homework.homework_detail_manual.try(:comment_status) == 0 || @homework.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").size > 0 %> <%= link_to '立即发布', publish_notice_homework_common_path(@homework), :remote => true, :class => "white-btn orange-btn fr ml15 mt3" %> <% end %> - <% if (@homework.homework_detail_manual.try(:comment_status) == 1 && @homework.end_time > Time.now) || @homework.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %> + <% if (@homework.homework_detail_manual.try(:comment_status) == 1 && @homework.end_time > Time.now) || @homework.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").size > 0 %> <%= link_to '立即截止', end_notice_homework_common_path(@homework), :remote => true, :class => "white-btn orange-btn fr ml15 mt3" %> <% end %> <% if @homework.publish_time.present? && @homework.publish_time < Time.now && @homework.end_time > Time.now && (@homework.homework_type == 1 || @homework.homework_type == 3) %> 撤销发布 <% end %> - <% if @homework.homework_type == 4 && @homework.publish_time.present? && @homework.publish_time < Time.now && @homework.homework_group_reviews.count == 0 %> + <% if @homework.homework_type == 4 && @homework.publish_time.present? && @homework.publish_time < Time.now && @homework.homework_group_reviews.size == 0 %> 代码查重 <% end %> @@ -186,7 +186,7 @@ 不限 - <% has_comment = StudentWorksScore.where(:student_work_id => student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).count %> + <% has_comment = StudentWorksScore.where(:student_work_id => student_works.map(&:id), :reviewer_role => [1, 2]).group_by(&:student_work_id).size %> > > @@ -207,6 +207,7 @@ > +
  • 分班情况: @@ -214,7 +215,7 @@ 不限

    - <% groups.each do |group| %> + <% groups.includes(:members).each do |group| %> > @@ -264,7 +265,7 @@ <% my_work = cur_user_works_for_homework @homework %> <% if @homework.homework_detail_manual.comment_status == 3 %> <% unless my_work.nil? %> - <% if my_work.user.student_works_evaluation_distributions.where(:student_work_id => @homework.student_works.map(&:id)).count != 0 %> + <% if my_work.user.student_works_evaluation_distributions.where(:student_work_id => @homework.student_works.map(&:id)).size != 0 %> 你在匿评开启之前提交了作品,你的作品正在匿评中 <% else %> 你在匿评开启之后才提交作品,你的作品没有参与匿评 @@ -287,8 +288,8 @@ <% end %>

    - <%= @homework.student_works.where("work_status != 0").count %> 已交 - <%= @homework.course.student.count - @homework.student_works.where("work_status != 0").size %> + <%= @homework.student_works.where("work_status != 0").size %> 已交 + <%= @homework.course.student.size - @homework.student_works.where("work_status != 0").size %> 未交 <% if @homework.homework_detail_manual %> <% if @homework.homework_detail_manual.comment_status == 1 %> diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 5f521117..d5a9e1e7 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -37,7 +37,7 @@ <% if comment_status == 0 || activity.homework_group_settings.where("publish_time is null or publish_time > '#{Time.now}'").count > 0 %>

  • <%= link_to '立即发布', publish_notice_homework_common_path(activity), :remote => true %>
  • <% end %> - <% if (comment_status == 1 && activity.end_time > Time.now) || activity.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %> + <% if (comment_status == 1 && activity.end_time && activity.end_time > Time.now) || activity.homework_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
  • <%= link_to '立即截止', end_notice_homework_common_path(activity), :remote => true %>
  • <% end %>
  • <%= link_to "导出成绩", student_work_index_path(:homework => activity, :format => 'xls'), :id => "export_student_work" %>
  • diff --git a/config/routes.rb b/config/routes.rb index d02c1e4e..e4dfe08d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -523,6 +523,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 resources :managements do collection do + get 'evaluate_simple' get 'hidden_course' match 'training_2018',:via=>[:get,:post] get 'update_pay_status' diff --git a/db/migrate/20190524005242_add_identifier_to_evaluate_records.rb b/db/migrate/20190524005242_add_identifier_to_evaluate_records.rb new file mode 100644 index 00000000..7fe00179 --- /dev/null +++ b/db/migrate/20190524005242_add_identifier_to_evaluate_records.rb @@ -0,0 +1,8 @@ +class AddIdentifierToEvaluateRecords < ActiveRecord::Migration + def change + add_column :evaluate_records, :identifier, :string + add_index :evaluate_records, :identifier, unique: true + remove_index :evaluate_records, :name => :game + remove_index :evaluate_records, :name => :index_evaluate_records_on_user_id + end +end