Merge branch 'dev_cxt2' into dev_aliyun

dev_auth
cxt 5 years ago
commit a2bb1ef1a2

@ -605,6 +605,21 @@ class ExercisesController < ApplicationController
end end
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 def my_exercises
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do

@ -572,10 +572,13 @@ class HomeworkCommonsController < ApplicationController
if @homework.homework_type == "practice" 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("缺少answer_open_evaluation参数") if params[:answer_open_evaluation].nil?
tip_exception("缺少work_efficiency参数") if params[:work_efficiency].nil? tip_exception("缺少work_efficiency参数") if params[:work_efficiency].nil?
tip_exception("缺少eff_score参数") if params[:work_efficiency] && params[:eff_score].blank? 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("效率分不能小于等于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("缺少shixun_evaluation参数") if params[:shixun_evaluation].blank?
tip_exception("缺少challenge_settings参数") if params[:challenge_settings].blank? tip_exception("缺少challenge_settings参数") if params[:challenge_settings].blank?
# tip_exception("缺少challenge_id参数") if params[:challenge_settings][:challenge_id].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 # params[:challenge_settings][:challenge_score].length != params[:challenge_settings][:challenge_id].length
current_eff_score = @homework.eff_score current_eff_score = @homework.eff_score
@homework.total_score = params[:total_score]
@homework.work_efficiency = params[:work_efficiency] @homework.work_efficiency = params[:work_efficiency]
@homework.eff_score = params[:work_efficiency] ? params[:eff_score].to_i : 0 @homework.eff_score = params[:work_efficiency] ? params[:eff_score].to_i : 0

@ -534,7 +534,9 @@ class StudentWorksController < ApplicationController
# 作品调分 # 作品调分
def adjust_score def adjust_score
tip_exception("分数不能为空") if params[:score].blank? 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 ActiveRecord::Base.transaction do
begin begin
# 分数不为空的历史评阅都置为失效 # 分数不为空的历史评阅都置为失效

@ -1,8 +1,10 @@
class ExerciseUser < ApplicationRecord class ExerciseUser < ApplicationRecord
# commit_method 0 为默认, 1为学生的手动提交2为倒计时结束后自动提交3为试卷定时截止的自动提交, 4为教师手动的立即截止 # commit_method 0 为默认, 1为学生的手动提交2为倒计时结束后自动提交3为试卷定时截止的自动提交, 4为教师手动的立即截止, 5为老师调分
belongs_to :user belongs_to :user
belongs_to :exercise belongs_to :exercise
has_many :exercise_user_scores, dependent: :destroy
scope :commit_exercise_by_status, lambda { |s| where(commit_status: s) } scope :commit_exercise_by_status, lambda { |s| where(commit_status: s) }
scope :exercise_user_committed, -> {where("commit_status != ?",0) } 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)} scope :current_exercise_user, lambda { |user_id,exercise_id| where(user_id: user_id,exercise_id:exercise_id)}

@ -0,0 +1,5 @@
class ExerciseUserScore < ApplicationRecord
belongs_to :exercise
belongs_to :exercise_user
belongs_to :user
end

@ -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.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, 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_settings @course_groups do |group|
json.group_id group.id json.group_id group.id

@ -86,7 +86,7 @@ if @homework.homework_type == "practice"
json.work_efficiency @homework.work_efficiency json.work_efficiency @homework.work_efficiency
json.student_works @student_works.each do |work| 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.late_penalty work.late_penalty if @homework.allow_late
json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open) json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open)

@ -510,7 +510,7 @@ Rails.application.routes.draw do
post :join_exercise_banks # 加入习题集 post :join_exercise_banks # 加入习题集
post :publish # 立即发布 post :publish # 立即发布
post :end_exercise # 立即截止 post :end_exercise # 立即截止
``
end end
end end
@ -626,6 +626,7 @@ Rails.application.routes.draw do
post :cancel_exercise post :cancel_exercise
get :begin_commit #提交前的弹窗 get :begin_commit #提交前的弹窗
get :publish_groups get :publish_groups
post :adjust_score
end end
resources :exercise_questions,only:[:new,:create,:index] resources :exercise_questions,only:[:new,:create,:index]
end end

@ -0,0 +1,5 @@
class AddTotalScoreToHomeworkCommons < ActiveRecord::Migration[5.2]
def change
add_column :homework_commons, :total_score, :float, default: 100
end
end

@ -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

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ExerciseUserScore, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save