Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

courseware
杨树明 5 years ago
commit 558738ec01

@ -40,11 +40,11 @@ class CoursesController < ApplicationController
:add_teacher, :export_couser_info, :export_member_act_score,
:update_informs, :new_informs, :delete_informs, :switch_to_student, :move_to_category]
before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin,
:set_course_group, :create_group_by_importing_file,
:update_task_position, :tasks_list]
:set_course_group, :create_group_by_importing_file]
before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group,
:change_course_teacher, :course_group_list, :change_member_role,:inform_up, :inform_down,
:teacher_application_review, :apply_teachers, :delete_course_teacher]
:teacher_application_review, :apply_teachers, :delete_course_teacher,
:update_task_position, :tasks_list]
before_action :validate_course_name, only: [:create, :update]
before_action :find_board, only: :board_list
before_action :validate_page_size, only: :mine

@ -1201,7 +1201,7 @@ class ExercisesController < ApplicationController
# 分页
@page = params[:page] || 1
@limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
@exercise_users_list = @exercise_users_list.preload(:exercise_user_scores, user: :user_extension).page(@page).per(@limit)
else
@exercise_users_list = []

@ -19,10 +19,10 @@ class HomeworkCommonsController < ApplicationController
:publish_homework, :end_homework, :set_public, :choose_category, :move_to_category,
:choose_category, :create_subject_homework, :multi_destroy, :group_list, :homework_code_repeat,
:code_review_results, :code_review_detail, :update_explanation, :update_settings,
:add_to_homework_bank, :publish_groups, :end_groups, :batch_comment]
:add_to_homework_bank, :publish_groups, :end_groups, :batch_comment, :alter_name]
before_action :require_id_params, only: [:set_public, :multi_destroy, :publish_homework, :end_homework, :move_to_category,
:add_to_homework_bank]
before_action :course_manager, only: [:alter_name]
# before_action :course_manager, only: [:alter_name]
def index
tip_exception("type参数有误") if params[:type] && ![1, 3, 4].include?(params[:type].to_i)

@ -688,7 +688,7 @@ module ExercisesHelper
end
#获取用户的相关信息
def exercise_use_info(ex_user,user_status,exercise)
def exercise_use_info(ex_user,user_status,exercise,subject_question_ids)
course = exercise.course
current_user_group_id = ""
current_user_group_name = ""
@ -712,7 +712,13 @@ module ExercisesHelper
course_group = course.course_groups.by_group_ids(current_user_group_id)
current_user_group_name = course_group.first.name if course_group.present?
end
teacher_review = ex_user.subjective_score < 0.0 ? false : true
exercise_answer_ids = ex_user.user.exercise_answers.where(exercise_question_id: subject_question_ids).pluck(:id)
if ex_user.subjective_score > 0.0 || ex_user.exercise_user_scores.size > 0 || ExerciseAnswerComment.where(exercise_answer_id: exercise_answer_ids).exists?
teacher_review = true
else
teacher_review = false
end
if (user_status == 0 && commit_status == 1) || (user_status == 1 && ex_user_exercise_status == 3 && commit_status == 1) #老师都可以看,学生,需在试卷已提交,且已截止的情况下看
ex_object_score = ex_user.objective_score <= 0.0 ? 0 : ex_user.objective_score.round(1).to_s
ex_subject_score = ex_user.subjective_score < 0.0 ? nil : (ex_user.subjective_score > 0.0 ? ex_user.subjective_score.round(1).to_s : 0)

@ -38,6 +38,10 @@ class Exercise < ApplicationRecord
DEADLINE = 3 #已截止
ENDED = 4 #课堂已结束
def subject_question_ids
exercise_questions.where(question_type: [4]).pluck(:id)
end
def question_scores
exercise_questions.pluck(:question_score).sum
end

@ -2,6 +2,9 @@
<% add_admin_breadcrumb('概览', admins_path) %>
<% end %>
<% content_for(:head) do %>
<meta name="turbolinks-cache-control" content="no-cache">
<% end %>
<div class="header bg-gradient-primary pb-8 pt-md-8">
<div class="container-fluid">
<div class="header-body">

@ -1,4 +1,4 @@
ex_user_info = exercise_use_info(exercise_user,user_status,exercise)
ex_user_info = exercise_use_info(exercise_user,user_status,exercise,question_ids)
json.user_id ex_user_info[:user_id]
json.user_name ex_user_info[:user_name]

@ -47,7 +47,8 @@ if @exercise_users_list.present?
json.array! @exercise_users_list.each do |exercise_user|
json.partial! "exercises/exercise_user",locals: {exercise_user:exercise_user, subjective_type:@subjective_type,
user_status:@exercise_current_user_status, exercise:@exercise,
question_ids: @exercise.exercise_questions.pluck(:id)}
question_ids: @exercise.exercise_questions.pluck(:id),
subject_question_ids: @exercise.subject_question_ids}
end
end
else

@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
<%= yield :head %>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

@ -39,7 +39,7 @@ if @shixun
json.challenge_id challenge.id
challenge_score = @homework.challenge_score challenge.id
json.game_score_full challenge_score
json.game_score @work.work_challenge_score game, challenge_score, challenge.id
json.game_score number_with_precision (@work.work_challenge_score game, challenge_score, challenge.id), precision: 1
challenge_comment = @work.shixun_work_comments.find_by(challenge_id: challenge.id)
json.challenge_comment challenge_comment&.comment
json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil

Loading…
Cancel
Save