diff --git a/app/controllers/competitions/competitions_controller.rb b/app/controllers/competitions/competitions_controller.rb index 1a80dc7e6..31ed4367d 100644 --- a/app/controllers/competitions/competitions_controller.rb +++ b/app/controllers/competitions/competitions_controller.rb @@ -22,7 +22,7 @@ class Competitions::CompetitionsController < Competitions::BaseController @count = competitions.count competitions = competitions.order(published_at: :desc, online_time: :desc) - @competitions = paginate(competitions.includes(sponsor_schools: :school, current_stage_section: :competition_stage)) + @competitions = paginate(competitions.includes(:competition_mode_setting, sponsor_schools: :school, current_stage_section: :competition_stage)) ids = @competitions.map(&:id) @member_count_map = TeamMember.where(competition_id: ids).group(:competition_id).count diff --git a/app/controllers/competitions/prizes_controller.rb b/app/controllers/competitions/prizes_controller.rb index aab1df9a1..116548de7 100644 --- a/app/controllers/competitions/prizes_controller.rb +++ b/app/controllers/competitions/prizes_controller.rb @@ -5,7 +5,10 @@ class Competitions::PrizesController < Competitions::BaseController self_prizes = current_competition.competition_prize_users.where(user_id: current_user.id).includes(:competition_team) @leader = self_prizes.any?(&:leader?) # 是否为队长 - @bank_account = self_prizes.find(&:leader?).extra if @leader + if @leader + @bank_account = self_prizes.find(&:leader?).extra + @bank_account_editable = self_prizes.select(&:leader?).all?(&:pending?) + end @self_prizes = self_prizes.select(&:certificate_exist?) # 个人证书quit @team_prizes = self_prizes.map(&:competition_team).uniq.select(&:certificate_exists?) # 团队证书 diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 3b6273465..7c0c40cfc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -253,14 +253,14 @@ class CoursesController < ApplicationController group_ids = params[:group_ids].is_a?(Array) ? params[:group_ids] : params[:group_ids].split(",") if params[:group_ids] all_members = course_act_scores @course, group_ids @course_members = all_members[0 .. 9] - if @user_course_identity == Course::STUDENT - user_ids = all_members.map(&:user_id) - rank = user_ids.index(current_user.id).to_i + 1 - if rank > 10 - current_member = all_members.select{|member| member.user_id == current_user.id} - @course_members << current_member - end - end + # if @user_course_identity == Course::STUDENT + # user_ids = all_members.map(&:user_id) + # rank = user_ids.index(current_user.id).to_i + 1 + # if rank > 10 + # current_member = all_members.select{|member| member.user_id == current_user.id}.first + # @course_members << current_member if current_member.present? + # end + # end end def join_excellent_course @@ -1266,7 +1266,7 @@ class CoursesController < ApplicationController @all_members = @course.students search = params[:search] ? "#{params[:search].strip}" : "" #用户名或学生学号id搜索 group_id = params[:group_id] #分班的班级id - @all_members = @all_members.where(course_group_id: group_id) unless group_id.blank? + @all_members = @all_members.where(course_group_id: group_id.map(&:to_i)) unless group_id.blank? unless search.blank? @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{search}%","%#{search}%") end diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index bd5a41123..a6464a151 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -605,6 +605,21 @@ class ExercisesController < ApplicationController end end + # 对未提交的用户进行调分 + def adjust_score + exercise_user = @exercise.exercise_users.find_by!(user_id: params[:user_id]) + tip_exception("已提交的作品请去评阅页进行调分") if exercise_user.commit_status == 1 + tip_exception("分数不能为空") if params[:score].blank? + tip_exception("分数不能超过0-#{@exercise.question_scores}") if params[:score].to_f < 0 || params[:score].to_f.round(1) > @exercise.question_scores.round(1) + + ActiveRecord::Base.transaction do + start_at_time = exercise_user.start_at || Time.now + exercise_user.update_attributes!(start_at: start_at_time, end_at: Time.now, status: 1, commit_status: 1, score: params[:score].to_f.round(2), commit_method: 5) + ExerciseUserScore.create!(exercise_id: @exercise.id, exercise_user_id: exercise_user.id, score: params[:score], comment: params[:comment]) + normal_status("操作成功") + end + end + #我的题库 def my_exercises ActiveRecord::Base.transaction do diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 5d27de7b8..6d627df33 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -125,7 +125,7 @@ class HomeworkCommonsController < ApplicationController # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 if @work&.work_status.to_i > 0 && (@homework.work_public || @homework.score_open) && ((!@homework.anonymous_comment && @homework.end_or_late) || (@homework_detail_manual.comment_status > 4 && @homework.end_or_late)) - @student_works = student_works.where("user_id != #{@work.user_id}") + @student_works = student_works.where("student_works.user_id != #{@work.user_id}") # 匿评、申诉阶段只能看到分配给自己的匿评作品 elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 && @homework_detail_manual.comment_status <= 4 @@ -572,10 +572,13 @@ class HomeworkCommonsController < ApplicationController if @homework.homework_type == "practice" # 实训作业的评分设置 + tip_exception("总分值不能为空") if params[:total_score].blank? + tip_exception("总分值不能小于0") if params[:total_score].to_i < 0 tip_exception("缺少answer_open_evaluation参数") if params[:answer_open_evaluation].nil? tip_exception("缺少work_efficiency参数") if params[:work_efficiency].nil? tip_exception("缺少eff_score参数") if params[:work_efficiency] && params[:eff_score].blank? tip_exception("效率分不能小于等于0") if params[:eff_score] && params[:eff_score].to_i <= 0 + tip_exception("效率分不能大于总分值") if params[:eff_score] && params[:eff_score].to_i > params[:total_score].to_i tip_exception("缺少shixun_evaluation参数") if params[:shixun_evaluation].blank? tip_exception("缺少challenge_settings参数") if params[:challenge_settings].blank? # tip_exception("缺少challenge_id参数") if params[:challenge_settings][:challenge_id].blank? @@ -584,6 +587,7 @@ class HomeworkCommonsController < ApplicationController # params[:challenge_settings][:challenge_score].length != params[:challenge_settings][:challenge_id].length current_eff_score = @homework.eff_score + @homework.total_score = params[:total_score] @homework.work_efficiency = params[:work_efficiency] @homework.eff_score = params[:work_efficiency] ? params[:eff_score].to_i : 0 diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index b7a6953a5..c45bca268 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -534,7 +534,9 @@ class StudentWorksController < ApplicationController # 作品调分 def adjust_score tip_exception("分数不能为空") if params[:score].blank? - tip_exception("分数不能超过0-100") if params[:score].to_f < 0 || params[:score].to_f > 100 + tip_exception("分数不能超过0-100") if @homework.homework_type != "practice" && (params[:score].to_f < 0 || params[:score].to_f.round(1) > 100.round(1)) + tip_exception("已提交的作品请去评阅页进行调分") if @homework.homework_type == "practice" && @work.work_status > 0 + tip_exception("分数不能超过总分值#{@homework.total_score}") if @homework.homework_type == "practice" && (params[:score].to_f < 0 || params[:score].to_f.round(1) > @homework.total_score.round(1)) ActiveRecord::Base.transaction do begin # 分数不为空的历史评阅都置为失效 diff --git a/app/forms/users/apply_authentication_form.rb b/app/forms/users/apply_authentication_form.rb index 2b984fcaa..e9bd1b793 100644 --- a/app/forms/users/apply_authentication_form.rb +++ b/app/forms/users/apply_authentication_form.rb @@ -1,7 +1,7 @@ class Users::ApplyAuthenticationForm include ActiveModel::Model - attr_accessor :name, :id_number, :upload_image + attr_accessor :name, :id_number, :gender, :upload_image validates :name, presence: true validate :validate_ID_number diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 4de15b20f..a28668c6b 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -63,6 +63,8 @@ module CoursesHelper "/courses/#{course.id}/boards/#{course_board.id}" when "course_group" "/courses/#{course.id}/course_groups" + when "statistics" + "/courses/#{course.id}/statistics" end end diff --git a/app/models/competition.rb b/app/models/competition.rb index 8613e974a..fa1267025 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -49,6 +49,12 @@ class Competition < ApplicationRecord end end + # 报名数 + def team_member_count + course = competition_mode_setting&.course if mode == 2 + course ? course.students.count : team_members.count + end + def sponsor_schools_name sponsor_schools.map{|sponsor| sponsor.school.name} end diff --git a/app/models/exercise_user.rb b/app/models/exercise_user.rb index 0f2e8456e..fb2034998 100644 --- a/app/models/exercise_user.rb +++ b/app/models/exercise_user.rb @@ -1,8 +1,10 @@ class ExerciseUser < ApplicationRecord - # commit_method 0 为默认, 1为学生的手动提交,2为倒计时结束后自动提交,3为试卷定时截止的自动提交, 4为教师手动的立即截止 + # commit_method 0 为默认, 1为学生的手动提交,2为倒计时结束后自动提交,3为试卷定时截止的自动提交, 4为教师手动的立即截止, 5为老师调分 belongs_to :user belongs_to :exercise + has_many :exercise_user_scores, dependent: :destroy + scope :commit_exercise_by_status, lambda { |s| where(commit_status: s) } scope :exercise_user_committed, -> {where("commit_status != ?",0) } scope :current_exercise_user, lambda { |user_id,exercise_id| where(user_id: user_id,exercise_id:exercise_id)} diff --git a/app/models/exercise_user_score.rb b/app/models/exercise_user_score.rb new file mode 100644 index 000000000..d022b0b31 --- /dev/null +++ b/app/models/exercise_user_score.rb @@ -0,0 +1,5 @@ +class ExerciseUserScore < ApplicationRecord + belongs_to :exercise + belongs_to :exercise_user + belongs_to :user +end diff --git a/app/views/competitions/competitions/common_header.json.jbuilder b/app/views/competitions/competitions/common_header.json.jbuilder index a869d920b..0d0f3f4ca 100644 --- a/app/views/competitions/competitions/common_header.json.jbuilder +++ b/app/views/competitions/competitions/common_header.json.jbuilder @@ -1,6 +1,6 @@ json.extract! @competition, :id, :name, :sub_title, :identifier, :bonus, :mode json.visits_count @competition.visits -member_count = @competition.team_members.count +member_count = @competition.team_member_count json.member_count member_count.zero? ? 268 : member_count json.start_time @competition.start_time&.strftime("%Y-%m-%d") diff --git a/app/views/competitions/competitions/index.json.jbuilder b/app/views/competitions/competitions/index.json.jbuilder index c01f0aa59..b7a3f20e0 100644 --- a/app/views/competitions/competitions/index.json.jbuilder +++ b/app/views/competitions/competitions/index.json.jbuilder @@ -5,7 +5,8 @@ json.competitions do json.competition_status competition.competition_status json.visits_count competition.visits - member_count = @member_count_map&.fetch(competition.id, 0) || competition.team_members.count + course = competition.competition_mode_setting&.course if competition.mode == 2 + member_count = course ? course.students.count : (@member_count_map&.fetch(competition.id, 0) || competition.team_members.count) json.member_count member_count.zero? ? 268 : member_count json.image url_to_avatar(competition) diff --git a/app/views/competitions/prizes/show.json.jbuilder b/app/views/competitions/prizes/show.json.jbuilder index 5bd4a5ae6..c8de20430 100644 --- a/app/views/competitions/prizes/show.json.jbuilder +++ b/app/views/competitions/prizes/show.json.jbuilder @@ -1,6 +1,9 @@ json.leader @leader -json.bank_account @bank_account if @leader +if @leader + json.bank_account @bank_account + json.bank_account_editable @bank_account_editable +end json.personal_certifications do json.array! @self_prizes do |prize_user| diff --git a/app/views/courses/act_score.json.jbuilder b/app/views/courses/act_score.json.jbuilder index 394497635..ed6929b13 100644 --- a/app/views/courses/act_score.json.jbuilder +++ b/app/views/courses/act_score.json.jbuilder @@ -1,7 +1,7 @@ json.course_members @course_members.each do |member| user = member.user - json.user_login user.login - json.user_name user.real_name + json.user_login user&.login + json.user_name user&.real_name # json.course_group member.course_group_name json.total_score member.score end \ No newline at end of file diff --git a/app/views/homework_commons/settings.json.jbuilder b/app/views/homework_commons/settings.json.jbuilder index 52e3f1cdf..cf36c6165 100644 --- a/app/views/homework_commons/settings.json.jbuilder +++ b/app/views/homework_commons/settings.json.jbuilder @@ -5,7 +5,7 @@ json.partial! "homework_btn_check", locals: {identity: @user_course_identity, ho json.partial! "student_btn_check", locals: {identity: @user_course_identity, homework: @homework, work: @work} json.(@homework, :unified_setting, :publish_time, :end_time, :late_penalty, :allow_late, :late_time, :work_public, - :score_open, :answer_public) + :score_open, :answer_public, :total_score) json.group_settings @course_groups do |group| json.group_id group.id diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 24d1f354a..3807d5b99 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -86,7 +86,7 @@ if @homework.homework_type == "practice" json.work_efficiency @homework.work_efficiency json.student_works @student_works.each do |work| - json.(work, :id, :work_status, :update_time, :ultimate_score) + json.(work, :id, :work_status, :update_time, :ultimate_score, :myshixun_id) json.late_penalty work.late_penalty if @homework.allow_late json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open) diff --git a/config/routes.rb b/config/routes.rb index 65dd90cc2..3cf18fe75 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -510,7 +510,7 @@ Rails.application.routes.draw do post :join_exercise_banks # 加入习题集 post :publish # 立即发布 post :end_exercise # 立即截止 - +`` end end @@ -626,6 +626,7 @@ Rails.application.routes.draw do post :cancel_exercise get :begin_commit #提交前的弹窗 get :publish_groups + post :adjust_score end resources :exercise_questions,only:[:new,:create,:index] end diff --git a/db/migrate/20191029084344_add_total_score_to_homework_commons.rb b/db/migrate/20191029084344_add_total_score_to_homework_commons.rb new file mode 100644 index 000000000..1fefdde34 --- /dev/null +++ b/db/migrate/20191029084344_add_total_score_to_homework_commons.rb @@ -0,0 +1,5 @@ +class AddTotalScoreToHomeworkCommons < ActiveRecord::Migration[5.2] + def change + add_column :homework_commons, :total_score, :float, default: 100 + end +end diff --git a/db/migrate/20191030062150_create_exercise_user_scores.rb b/db/migrate/20191030062150_create_exercise_user_scores.rb new file mode 100644 index 000000000..911a8a3a5 --- /dev/null +++ b/db/migrate/20191030062150_create_exercise_user_scores.rb @@ -0,0 +1,13 @@ +class CreateExerciseUserScores < ActiveRecord::Migration[5.2] + def change + create_table :exercise_user_scores do |t| + t.references :exercise, index: true + t.references :exercise_user, index: true + t.float :score + t.text :comment + t.references :user, index: true + + t.timestamps + end + end +end diff --git a/public/react/src/modules/competition/RegistrationSearch.js b/public/react/src/modules/competition/RegistrationSearch.js index 02d4fa861..a1f0b9ac3 100644 --- a/public/react/src/modules/competition/RegistrationSearch.js +++ b/public/react/src/modules/competition/RegistrationSearch.js @@ -54,11 +54,11 @@ class RegistrationSearch extends React.Component { />

战队总数: - {item.type != "statistics" ?

  • this.showsandians(e,key,item.category_url,1,item.id,item.type)} className={this.props.mainurl===item.category_url&&this.props.location.pathname===item.category_url?"liactive":"clearfix active"} onMouseLeave={(e)=>this.hidesandian(e,key)} onMouseEnter={(e)=>this.showsandian(e,key)}> this.showsandians(e,key,item.category_url,1,item.id,item.type)} className={ item.second_category===undefined?"fl ml20 pd0":item.second_category.length===0?"fl ml20 pd0":this.state.sandiantypes===key?"fl ml20 pd0 ebebeb":"fl ml20 pd0"}> { @@ -1051,7 +1050,7 @@ class Coursesleftnav extends Component{ :""} -
  • : ""} + {/*下拉列表*/} @@ -1154,8 +1153,8 @@ class Coursesleftnav extends Component{ return(
    {/**/} - - {item.type != "statistics" ? + +
  • this.setnavid(e,key,item.id,item.type,item.category_url)} onMouseEnter={(e)=>this.showsandian(e,key)} title={item.name.length<7?"":item.name} @@ -1172,14 +1171,15 @@ class Coursesleftnav extends Component{ item.type==="poll"?: item.type==="attachment"?: item.type==="board"?: - item.type==="course_group"?:"" + item.type==="course_group"?: + item.type==="statistics"?:"" } this.selectnavid(e,key,item.id,item.type,item.category_url)}>{item.name} {item.task_count===0?"":item.task_count} -
  • : ""} +
    + }> + 复制邀请码 + + } {isStudent && addToDir(record)} style={''}>加入分班} onGoDetail(record)} style={''}>查看 diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index 76e5d28f8..f9cea2da2 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -870,7 +870,7 @@ class CoursesNew extends Component { "shixun_homework", "common_homework", "group_homework", "exercise", "attachment", "course_group", ], })( - + 公告栏 实训作业 普通作业 @@ -881,6 +881,7 @@ class CoursesNew extends Component { 资源 讨论 分班 + 统计 )} diff --git a/public/react/src/modules/courses/new/Goldsubject.js b/public/react/src/modules/courses/new/Goldsubject.js index 35a83ed94..f04bf1f4b 100644 --- a/public/react/src/modules/courses/new/Goldsubject.js +++ b/public/react/src/modules/courses/new/Goldsubject.js @@ -992,7 +992,7 @@ class Goldsubject extends Component { "announcement","online_learning","shixun_homework","common_homework", ], })( - + 公告栏 在线学习 实训作业 @@ -1002,6 +1002,7 @@ class Goldsubject extends Component { 资源 讨论 分班 + 统计 )} diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js index f0ed674c0..e6c84d4ce 100644 --- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js +++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js @@ -704,6 +704,7 @@ class Trainingjobsetting extends Component { shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, + total_score:this.state.CalculateMax } } else { // //非统一配置 @@ -734,6 +735,8 @@ class Trainingjobsetting extends Component { shixun_evaluation: this.state.proportion === "均分比例" ? 0 : this.state.proportion === "经验值比例" ? 1 : this.state.proportion === "自定义分值" ? 2 : 0, challenge_settings: array, score_open: this.state.publicwork, + total_score:this.state.CalculateMax + } } diff --git a/public/react/src/modules/courses/statistics/Statistics.js b/public/react/src/modules/courses/statistics/Statistics.js index 5564215ec..0166000cf 100644 --- a/public/react/src/modules/courses/statistics/Statistics.js +++ b/public/react/src/modules/courses/statistics/Statistics.js @@ -281,14 +281,39 @@ class Statistics extends Component{ }, ]; + + let shixun_homeworktype=false; + let common_homeworktype=false; + let group_homeworktype=false; + let graduationtype=false; + let exercisetype=false; let course_grouptype=false; if(this.props&&this.props.course_modules!=undefined){ {this.props&&this.props.course_modules.map((item,key)=>{ if(item.type==="course_group"){ course_grouptype=true } + + if(item.type==="shixun_homework"){ + shixun_homeworktype=true + } + if(item.type==="common_homework"){ + common_homeworktype=true + } + if(item.type==="group_homework"){ + group_homeworktype=true + } if(item.type==="graduation"){ + graduationtype=true + } + + if(item.type==="exercise"){ + exercisetype=true + } + })} } + + if(course_grouptype===false){ columns.some((item,key)=> { if (item.title === "分班") { @@ -298,25 +323,66 @@ class Statistics extends Component{ } ) } + + if(shixun_homeworktype===false){ + columns.some((item,key)=> { + if (item.title === "实训作业") { + columns.splice(key, 1) + return true + } + } + ) + } + + if(common_homeworktype===false){ + columns.some((item,key)=> { + if (item.title === "普通作业") { + columns.splice(key, 1) + return true + } + } + ) + } + + if(group_homeworktype===false){ + columns.some((item,key)=> { + if (item.title === "分组作业") { + columns.splice(key, 1) + return true + } + } + ) + } + + if(graduationtype===false){ + columns.some((item,key)=> { + if (item.title === "毕设任务") { + columns.splice(key, 1) + return true + } + } + ) + } + + if(exercisetype===false){ + columns.some((item,key)=> { + if (item.title === "试卷") { + columns.splice(key, 1) + return true + } + } + ) + } + // console.log(this.props.isAdmin) - // "user_login": "p94602358", - // "user_name": "卿前程", - // "course_group": "电气工程1805", // 分班 - // "common_score": 0.0, // 普通作业 - // "group_score": 0.0, // 分组作业 - // "practice_score": 747.1000061035156, // 实训作业 - // "exercise_score": 0.0, // 试卷成绩 - // "graduation_score": 0.0, // 毕设成绩 - // "total_score": 747.1000061035156, // 总成绩 - // "rank": 1 // 排名,学生身份才传 const operations = - this.getwork_scoredata(1,group_idss,'desc')} - /> + />} this.derivefun(`/courses/${this.props.match.params.coursesId}/export_member_scores_excel.xlsx`)}>导出 ; return( diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index eaf3204f2..64d413f88 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -606,7 +606,14 @@ submittojoinclass=(value)=>{ ) } //头部获取是否已经登录了 - getUser=(url)=>{ + getUser=(url,type)=>{ + + if(type==="projects"){ + if(!this.props.user&&this.props.user.email){ + this.openNotification("请先绑定邮箱,谢谢"); + return + } + } // console.log("点击了503") // console.log(url); let{user} =this.state; @@ -1254,7 +1261,7 @@ submittojoinclass=(value)=>{ {this.props.Headertop===undefined?"":
  • this.getUser("/paths/new")} >新建实践课程
  • } -
  • this.getUser("/projects/new")} target="_blank">新建开发项目
  • +
  • this.getUser("/projects/new","projects")} target="_blank">新建开发项目