diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e5d9fc495..73bd07954 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -399,7 +399,7 @@ class ExercisesController < ApplicationController choice_random = params[:choice_random] ? true : false score_open = params[:score_open] ? true : false #分数是否公开 answer_open = params[:answer_open] ? true : false #答案是否公开 - assistant_auth = params[:assistant_auth] ? true : false # 助教权限 + assistant_auth = params[:assistant_auth] # 助教权限 # 统一设置或者分班为0,则更新试卷,并删除试卷分组 if unified_setting || (course_group_ids.size == 0) @@ -532,7 +532,8 @@ class ExercisesController < ApplicationController :answer_open => answer_open, :exercise_status => exercise_status, :publish_time => p_time, - :end_time => e_time + :end_time => e_time, + :assistant_auth => assistant_auth } @exercise.update!(exercise_params) if @exercise.exercise_status == Exercise::PUBLISHED @@ -773,10 +774,11 @@ class ExercisesController < ApplicationController ex_group_setting = exercise.exercise_group_settings old_exercise_groups = ex_group_setting.find_in_exercise_group("course_group_id", g_course) #试卷的分组设置 left_course_groups = teacher_course_group_ids - g_course + all_left_groups = all_course_group_ids - g_course left_exercise_groups = ex_group_setting.find_in_exercise_group("course_group_id", left_course_groups) if left_exercise_groups.blank? && exercise.unified_setting - if left_course_groups.size > 0 #开始为统一设置,但是立即截止为分班。则创建没有立即截止的班级的exercise_group_setting - left_course_groups.each do |g| + if all_left_groups.size > 0 #开始为统一设置,但是立即截止为分班。则创建没有立即截止的班级的exercise_group_setting + all_left_groups.each do |g| ex_group_options = { :exercise_id => exercise.id, :course_group_id => g, diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 0e3771e61..faea30242 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -359,6 +359,9 @@ class HomeworkCommonsController < ApplicationController def new tip_exception("type参数有误") if params[:type].blank? || ![1, 3].include?(params[:type].to_i) @homework_type = params[:type].to_i + module_type = params[:type].to_i == 1 ? "common_homework" : "group_homework" + @main_category = @course.course_modules.find_by(module_type: module_type) + @category = @main_category.course_second_categories.find_by(id: params[:category]) if params[:category].present? end def create @@ -376,6 +379,11 @@ class HomeworkCommonsController < ApplicationController @homework.user_id = current_user.id @homework.course_id = @course.id + if params[:category].present? + category = @course.course_second_categories.find_by(id: params[:category]) + @homework.course_second_category_id = category&.id.to_i + end + homework_detail_manual = HomeworkDetailManual.new @homework.homework_detail_manual = homework_detail_manual homework_detail_manual.te_proportion = 0.7 @@ -404,7 +412,12 @@ class HomeworkCommonsController < ApplicationController end def edit - + if @homework.course_second_category_id == 0 + module_type = @homework.homework_type == "normal" ? "common_homework" : "group_homework" + @main_category = @course.course_modules.find_by(module_type: module_type) + else + @category = @homework.course_second_category + end end def update diff --git a/app/controllers/question_banks_controller.rb b/app/controllers/question_banks_controller.rb index bcb88ad85..af6305a64 100644 --- a/app/controllers/question_banks_controller.rb +++ b/app/controllers/question_banks_controller.rb @@ -212,6 +212,11 @@ class QuestionBanksController < ApplicationController homework_type: homework.homework_type, course_id: course.id, homework_bank_id: homework.id, reference_answer: homework.reference_answer) + if params[:category].present? + category = course.course_second_categories.find_by(id: params[:category]) + new_homework.course_second_category_id = category&.id.to_i + end + # 作业的基本设置复制 new_homework.homework_detail_manual = HomeworkDetailManual.new new_homework_detail_manual = new_homework.homework_detail_manual diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index a6a919981..58a420581 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -69,17 +69,18 @@ class HomeworkCommon < ApplicationRecord # 作业对应的子目录/父目录名称 def category_info - case self.homework_type - when 'normal' - {category_id: course.common_course_modules.first.try(:id), category_name: course.common_course_modules.first.try(:module_name), main: 1} - when 'group' - {category_id: course.group_course_modules.first.try(:id), category_name: course.group_course_modules.first.try(:module_name), main: 1} - when 'practice' - if self.course_second_category.present? - {category_id: self.course_second_category.try(:id), category_name: self.course_second_category.try(:name), main: 0} - else - {category_id: course.shixun_course_modules.take.try(:id), category_name: course.shixun_course_modules.take.try(:module_name), main: 1} - end + if self.course_second_category.present? + {category_id: self.course_second_category.try(:id), category_name: self.course_second_category.try(:name), main: 0} + else + course_module = case homework_type + when 'normal' + course.common_course_modules.take + when 'group' + course.group_course_modules.take + when 'practice' + course.shixun_course_modules.take + end + {category_id: course_module.try(:id), category_name: course_module.try(:module_name), main: 1} end end diff --git a/app/views/exercises/exercise_setting.json.jbuilder b/app/views/exercises/exercise_setting.json.jbuilder index 25c6fa588..84cd31c55 100644 --- a/app/views/exercises/exercise_setting.json.jbuilder +++ b/app/views/exercises/exercise_setting.json.jbuilder @@ -1,7 +1,7 @@ json.exercise do json.extract! @exercise, :id,:exercise_name, :exercise_status,:time,:publish_time, :end_time,:score_open,:answer_open,:question_random,:choice_random, - :unified_setting,:show_statistic + :unified_setting,:show_statistic,:assistant_auth json.course_id @course.id json.published_count @exercise_publish_count json.unpublish_count @exercise_unpublish_count diff --git a/app/views/files/index.json.jbuilder b/app/views/files/index.json.jbuilder index 0002cf299..e7805c0d8 100644 --- a/app/views/files/index.json.jbuilder +++ b/app/views/files/index.json.jbuilder @@ -14,6 +14,7 @@ json.data do json.partial! "users/user_simple", user: attachment.author end # json.partial! "files/course_groups", attachment_group_settings: attachment.attachment_group_settings + json.category_id attachment.course_second_category_id if @course_second_category_id.to_i == 0 json.category_name attachment.course_second_category&.name end diff --git a/app/views/homework_commons/edit.json.jbuilder b/app/views/homework_commons/edit.json.jbuilder index 49dc11dd8..d2eb865ac 100644 --- a/app/views/homework_commons/edit.json.jbuilder +++ b/app/views/homework_commons/edit.json.jbuilder @@ -1,6 +1,16 @@ json.course_id @course.id json.course_name @course.name -json.category @homework.category_info +# json.category @homework.category_info + +json.category do + if @category.present? + json.category_id @category.id + json.category_name @category.name + else + json.category_id @main_category&.id + json.category_name @main_category&.module_name + end +end json.(@homework, :id, :name, :description, :reference_answer) diff --git a/app/views/homework_commons/new.json.jbuilder b/app/views/homework_commons/new.json.jbuilder index 82a5d78fa..9a703d40f 100644 --- a/app/views/homework_commons/new.json.jbuilder +++ b/app/views/homework_commons/new.json.jbuilder @@ -1,3 +1,11 @@ json.course_id @course.id json.course_name @course.name -json.category @course.category_info(@homework_type == 1 ? "common_homework" : "group_homework") \ No newline at end of file +json.category do + if @category.present? + json.category_id @category.id + json.category_name @category.name + else + json.category_id @main_category&.id + json.category_name @main_category&.module_name + end +end \ No newline at end of file diff --git a/db/migrate/20200311092049_add_index_user_id_challenge_id_for_games.rb b/db/migrate/20200311092049_add_index_user_id_challenge_id_for_games.rb new file mode 100644 index 000000000..c9fab49d4 --- /dev/null +++ b/db/migrate/20200311092049_add_index_user_id_challenge_id_for_games.rb @@ -0,0 +1,9 @@ +class AddIndexUserIdChallengeIdForGames < ActiveRecord::Migration[5.2] + def change + delete_games = Game.where.not(myshixun_id: Myshixun.all).reorder(nil) + puts "delete_games: #{delete_games.pluck(:id)}" + delete_games.destroy_all + + add_index :games, [:user_id, :challenge_id], unique: true + end +end diff --git a/public/react/src/college/College.js b/public/react/src/college/College.js index 15b0e82f8..bc8f2a3a2 100644 --- a/public/react/src/college/College.js +++ b/public/react/src/college/College.js @@ -907,7 +907,7 @@ class College extends Component {
公开设置
+属性设置
@@ -790,7 +874,7 @@ class Exercisesetting extends Component{ (选中,则在试卷截止时间之后,已提交答题的学生可以查看试卷题目的答案,否则不能查看)
-+
+