试卷调分

dev_home
cxt 5 years ago
parent 4fe175e2dc
commit 7c9dda492a

@ -614,9 +614,9 @@ class ExercisesController < ApplicationController
exercise_user = @exercise.exercise_users.find_by!(user_id: params[:user_id])
tip_exception("已提交的作品请去评阅页进行调分") if exercise_user.commit_status == 1
if @exercise.subjective_score > 0
tip_exception("主观题成绩不能为空") if params[:subject_score].blank?
tip_exception("主观题成绩不能小于零") if params[:subject_score].to_f < 0
tip_exception("主观题成绩不能大于总分值:#{@exercise.subjective_score}") if params[:subject_score].to_f.round(1) > @exercise.subjective_score.round(1)
tip_exception("主观题成绩不能为空") if params[:subjective_score].blank?
tip_exception("主观题成绩不能小于零") if params[:subjective_score].to_f < 0
tip_exception("主观题成绩不能大于总分值:#{@exercise.subjective_score}") if params[:subjective_score].to_f.round(1) > @exercise.subjective_score.round(1)
end
if @exercise.objective_score > 0
@ -627,7 +627,7 @@ class ExercisesController < ApplicationController
ActiveRecord::Base.transaction do
start_at_time = exercise_user.start_at || Time.now
subjective_score = @exercise.subjective_score > 0 ? params[:subject_score].to_f.round(2) : 0
subjective_score = @exercise.subjective_score > 0 ? params[:subjective_score].to_f.round(2) : 0
objective_score = @exercise.objective_score > 0 ? params[:objective_score].to_f.round(2) : 0
score = subjective_score + objective_score
exercise_user.update_attributes!(start_at: start_at_time, end_at: Time.now, status: 1, commit_status: 1, score: score,

@ -1,15 +1,20 @@
class Weapps::HomesController < Weapps::BaseController
before_action :require_wechat_login!
def show
# banner
@carousels = WeappSettings::Carousel.only_online
# 广告
@advert = WeappSettings::Advert.only_online.first
# 热门实训
@shixuns = Shixun.where(homepage_show: true).includes(:tag_repertoires, :challenges).limit(4)
# 热门实践课程
@subjects = Subject.where(homepage_show: true).includes(:shixuns, :repertoire).limit(4)
# 我的课堂
category = params[:category] && ["manage", "study"].include?(params[:category]) ? params[:category] : (current_user.is_teacher? ? "manage" : "study")
@courses = case category
when 'study' then
current_user.as_student_courses.started
when 'manage' then
current_user.manage_courses
end
end
end

@ -16,25 +16,5 @@ else
json.advert nil
end
json.shixuns do
json.array! @shixuns do |shixun|
json.id shixun.id
json.identifier shixun.identifier
json.name shixun.name
json.status shixun.status
json.power (current_user.shixun_permission(shixun)) # 现在首页只显示已发布的实训
# REDO: 局部缓存
json.tag_name @tag_name_map&.fetch(shixun.id, nil) || shixun.tag_repertoires.first.try(:name)
json.myshixuns_count shixun.myshixuns_count
json.stu_num shixun.myshixuns_count
json.score_info shixun.averge_star
json.challenges_count shixun.challenges_count
#json.exp shixun.all_score
json.level level_to_s(shixun.trainee)
json.pic Util::FileManage.source_disk_file_url(shixun, '_weapp')
end
end
json.subjects do
json.partial! 'subjects/subject', locals: { subjects: @subjects }
end

@ -0,0 +1,6 @@
class AddStickyToCourse < ActiveRecord::Migration[5.2]
def change
add_column :courses, :sticky, :boolean, default: 0
add_column :courses, :sticky_time, :datetime
end
end
Loading…
Cancel
Save