From 4519abbce477d934b88aa795eaad657c61ef50e6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 20 Jun 2019 18:50:36 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=AF=95=E8=AE=BE=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8=E5=8F=8C=E9=87=8D=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E7=9A=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/graduation_tasks_controller.rb | 4 ++-- app/models/course.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/graduation_tasks_controller.rb b/app/controllers/graduation_tasks_controller.rb index d95716c9b..435dbd4ed 100644 --- a/app/controllers/graduation_tasks_controller.rb +++ b/app/controllers/graduation_tasks_controller.rb @@ -66,7 +66,7 @@ class GraduationTasksController < ApplicationController @course.teacher_group_user_ids(current_user.id) else course_group_id = @course.course_member(current_user.id).course_group_id - @course.course_members.where(course_group_id: course_group_id).pluck(:user_id) + @course.students.where(course_group_id: course_group_id).pluck(:user_id) end @work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension]) @@ -89,7 +89,7 @@ class GraduationTasksController < ApplicationController # 分班情况 unless params[:course_group].blank? - group_user_ids = @course.course_members.where(course_group_id: params[:course_group]).pluck(:user_id) + group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id) # 有分组只可能是老师身份查看列表 @work_list = @work_list.where(user_id: group_user_ids) end diff --git a/app/models/course.rb b/app/models/course.rb index dd2248d7c..30460b49a 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -139,9 +139,9 @@ class Course < ApplicationRecord def teacher_group_user_ids user_id teachers = teacher_course_groups.where(user_id: user_id) if teachers.exists? - course_members.where(course_group_id: teachers.pluck(:course_group_id)).pluck(:user_id) + students.where(course_group_id: teachers.pluck(:course_group_id)).pluck(:user_id) else - course_members.where(role: 4).pluck(:user_id) + students.pluck(:user_id) end end From 26e6ecba6dc09350e78263d5d3769147421cd5a9 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 20 Jun 2019 18:53:56 +0800 Subject: [PATCH 2/6] fix bug --- app/controllers/exercises_controller.rb | 17 +++++++++-------- app/controllers/polls_controller.rb | 2 +- app/models/course.rb | 2 +- app/models/exercise.rb | 2 +- app/models/poll.rb | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 762c12797..2239f570d 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -436,7 +436,7 @@ class ExercisesController < ApplicationController exercise_status = @exercise.get_exercise_status(current_user.id) - if exercise_status == 1 && (course_group_ids - [0]).count > 0 # 试卷未发布,且老师的分班大于1 ,才可以修改统一设置,否则按试卷默认的来处理 + if exercise_status == 1 && course_group_ids.size > 0 # 试卷未发布,且老师的分班大于1 ,才可以修改统一设置,否则按试卷默认的来处理 unified_setting = params[:unified_setting] else unified_setting = @exercise.unified_setting @@ -450,7 +450,7 @@ class ExercisesController < ApplicationController answer_open = params[:answer_open] ? true : false #答案是否公开 # 统一设置或者分班为0,则更新试卷,并删除试卷分组 - if unified_setting || (course_group_ids.count == 0) + if unified_setting || (course_group_ids.size == 0) params_publish_time = params[:publish_time].blank? ? nil : params[:publish_time].to_time params_end_time = nil if params[:end_time].blank? @@ -798,12 +798,13 @@ class ExercisesController < ApplicationController if exercise_status == 2 #跳过已截止的或未发布的 g_course = params[:group_ids] if g_course.present? - user_course_groups= @course.teacher_course_groups.get_user_groups(current_user.id) - if user_course_groups.present? - teacher_course_group_ids = user_course_groups.pluck(:course_group_id) - else - teacher_course_group_ids = @course.course_groups.pluck(:id) - end + # user_course_groups= @course.teacher_course_groups.get_user_groups(current_user.id) + # if user_course_groups.present? + # teacher_course_group_ids = user_course_groups.pluck(:course_group_id) + # else + # teacher_course_group_ids = @course.course_groups.pluck(:id) + # end + teacher_course_group_ids = @course.charge_group_ids(current_user) if g_course.map(&:to_i).sort == teacher_course_group_ids.sort #开始为统一设置 exercise.exercise_group_settings.destroy_all new_ex_status = set_exercise_status(exercise.publish_time,Time.now) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 38fa973b5..ae93357cc 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -691,7 +691,7 @@ class PollsController < ApplicationController course_group_ids = @course.charge_group_ids(current_user) #当前老师的班级id数组 poll_status = @poll.get_poll_status(current_user.id) - if poll_status == 1 && (course_group_ids - [0]).count > 0 # 问卷未发布,且老师的分班大于1 ,才可以修改统一设置,否则按poll默认的来处理 + if poll_status == 1 && course_group_ids.size > 0 # 问卷未发布,且老师的分班大于1 ,才可以修改统一设置,否则按poll默认的来处理 unified_setting = params[:unified_setting] else unified_setting = @poll.unified_setting diff --git a/app/models/course.rb b/app/models/course.rb index dd2248d7c..dec8c1b50 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -121,7 +121,7 @@ class Course < ApplicationRecord end #当前老师的班级id - def teacher_course_group_ids(user_id) + def teacher_course_ids(user_id) course_teacher_member = teacher_course_groups.get_user_groups(user_id) #获取当前老师的分班 if course_teacher_member.blank? if none_group_count > 0 #有未分班的,则发布到未发布分班 diff --git a/app/models/exercise.rb b/app/models/exercise.rb index e2623c692..b3feec12c 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -66,7 +66,7 @@ class Exercise < ApplicationRecord #当前用户已发布的班级id和试卷分组已发布的班级id的交集 def common_published_ids(user_id) - current_user_groups = course.teacher_course_group_ids(user_id) + current_user_groups = course.teacher_course_ids(user_id) if unified_setting if course.none_group_count > 0 #有未分班的,则发布到未发布分班 un_group_ids = [0] diff --git a/app/models/poll.rb b/app/models/poll.rb index fd9093fcc..b498eda4e 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -62,7 +62,7 @@ class Poll < ApplicationRecord #当前用户已发布的班级id和试卷分组已发布的班级id的交集 def poll_published_ids(user_id) - current_user_groups = course.teacher_course_group_ids(user_id) + current_user_groups = course.teacher_course_ids(user_id) if unified_setting if course.none_group_count > 0 #有未分班的,则发布到未发布 un_group_ids = [0] From 45a0f6cf2c3d42793b01d2bf99467d687c2ac777 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 20 Jun 2019 19:04:05 +0800 Subject: [PATCH 3/6] modify school list apu --- app/controllers/schools_controller.rb | 10 +++++++--- app/views/schools/school_list.json.jbuilder | 1 - .../modules/Courses/coursesPublic/form/SchoolSelect.js | 4 ++-- public/react/src/modules/Courses/new/CoursesNew.js | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 app/views/schools/school_list.json.jbuilder diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb index 1551091aa..11932be42 100644 --- a/app/controllers/schools_controller.rb +++ b/app/controllers/schools_controller.rb @@ -1,8 +1,12 @@ class SchoolsController < ApplicationController + def school_list + schools = School.all + search = params[:search].to_s.strip + if search.present? + schools = schools.where('name Like ?', "%#{search}%") + end - def school_list - q = params[:search] ? params[:search].strip : "" - @schools = School.where("name like ?", "%#{q}%").pluck(:name) + render_ok(school_names: schools.pluck(:name)) end end diff --git a/app/views/schools/school_list.json.jbuilder b/app/views/schools/school_list.json.jbuilder deleted file mode 100644 index 1e2c89897..000000000 --- a/app/views/schools/school_list.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.shools_name @schools \ No newline at end of file diff --git a/public/react/src/modules/Courses/coursesPublic/form/SchoolSelect.js b/public/react/src/modules/Courses/coursesPublic/form/SchoolSelect.js index db62c50b6..e1a9062e3 100644 --- a/public/react/src/modules/Courses/coursesPublic/form/SchoolSelect.js +++ b/public/react/src/modules/Courses/coursesPublic/form/SchoolSelect.js @@ -34,9 +34,9 @@ class SchoolSelect extends Component{ } }) .then((response) => { - if (response.data.shools_name) { + if (response.data.school_names) { if (currentValue === value) { - callback(response.data.shools_name); + callback(response.data.school_names); } } }) diff --git a/public/react/src/modules/Courses/new/CoursesNew.js b/public/react/src/modules/Courses/new/CoursesNew.js index d8fb83974..6c0158f21 100644 --- a/public/react/src/modules/Courses/new/CoursesNew.js +++ b/public/react/src/modules/Courses/new/CoursesNew.js @@ -314,7 +314,7 @@ class CoursesNew extends Component { } }).then((result)=>{ this.setState({ - searchlistscholl:result.data.shools_name, + searchlistscholl:result.data.school_names, scholl:value }) this.props.form.setFieldsValue({ From a1aa51353c3ce9c9f0d76c1743226805767b2093 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 20 Jun 2019 19:44:06 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=AF=BE=E5=A0=82=E6=9D=83=E9=99=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E3=80=81=E4=BD=9C=E4=B8=9A=E5=92=8C=E6=AF=95?= =?UTF-8?q?=E8=AE=BE=E7=9A=84=E7=A7=81=E6=9C=89=E5=8F=82=E6=95=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 6 +++--- app/views/courses/top_banner.json.jbuilder | 4 ++-- app/views/graduation_tasks/index.json.jbuilder | 4 ++-- app/views/graduation_topics/_topics.json.jbuilder | 4 ++-- app/views/homework_commons/index.json.jbuilder | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 65f8f5ff9..2c37285fa 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -274,7 +274,7 @@ class CoursesController < ApplicationController end end - @is_admin = current_user.creator_of_course? @course + @is_admin = @user_course_identity < Course::PROFESSOR @applications= CourseMessage.unhandled_join_course_requests_by_course(@course) @@ -897,8 +897,8 @@ class CoursesController < ApplicationController def top_banner @user = current_user - @is_teacher = @user.teacher_of_course?(@course) - @is_student = @course.course_members.where(user_id: @user.id, role: 4, is_active: 1).present? + @is_teacher = @user_course_identity < Course::STUDENT + @is_student = @user_course_identity == Course::STUDENT @course.increment!(:visits) end diff --git a/app/views/courses/top_banner.json.jbuilder b/app/views/courses/top_banner.json.jbuilder index ddf860709..c0a1ff956 100644 --- a/app/views/courses/top_banner.json.jbuilder +++ b/app/views/courses/top_banner.json.jbuilder @@ -11,7 +11,7 @@ json.course_end @course.is_end json.deadline course_end_date @course.end_date json.educoder_teacher @user.is_teacher? #json.is_student @is_student -json.is_admin @user.creator_of_course?(@course) +json.is_admin @user_course_identity < Course::PROFESSOR json.is_public @course.is_public == 1 json.code_halt @course.invite_code_halt == 1 json.invite_code @course.invite_code_halt == 0 ? @course.generate_invite_code : "" @@ -20,7 +20,7 @@ json.switch_to_teacher switch_teacher_role(@is_student, @course, @user) json.switch_to_assistant switch_assistant_role(@is_student, @course, @user) #json.join_course !@user.member_of_course?(@course) #json.copy_course !@user.member_of_course?(@course) && @user.is_teacher? -json.course_identity @user.course_identity(@course) +json.course_identity @user_course_identity if @course.is_end == 0 json.days_remaining (@course.end_date.to_date - Time.now.to_date).to_i end diff --git a/app/views/graduation_tasks/index.json.jbuilder b/app/views/graduation_tasks/index.json.jbuilder index 157bde672..80780b209 100644 --- a/app/views/graduation_tasks/index.json.jbuilder +++ b/app/views/graduation_tasks/index.json.jbuilder @@ -7,10 +7,10 @@ json.unpublished_count @all_count - @published_count json.task_count @task_count json.tasks @tasks.each do |task| - task_private = @identity > Course::STUDENT && !task.is_public + # task_private = @identity > Course::STUDENT && !task.is_public json.task_id task.id json.name task.name - json.private_icon task_private + json.private_icon !task.is_public json.task_status task.status #6.12 -hs json.status task_curr_status(task, @course)[:status] json.status_time task_curr_status(task, @course)[:time] diff --git a/app/views/graduation_topics/_topics.json.jbuilder b/app/views/graduation_topics/_topics.json.jbuilder index 7a37b666b..271531f85 100644 --- a/app/views/graduation_topics/_topics.json.jbuilder +++ b/app/views/graduation_topics/_topics.json.jbuilder @@ -1,6 +1,6 @@ json.array! topics do |topic| - task_private = course_identity > Course::STUDENT && !topic.is_public - json.private_icon task_private + # task_private = course_identity > Course::STUDENT && !topic.is_public + json.private_icon !topic.is_public json.(topic, :id, :name, :status) json.author topic.teacher.full_name json.user_topic_status topic.user_status(current_user) diff --git a/app/views/homework_commons/index.json.jbuilder b/app/views/homework_commons/index.json.jbuilder index 18e601871..c9074cc2b 100644 --- a/app/views/homework_commons/index.json.jbuilder +++ b/app/views/homework_commons/index.json.jbuilder @@ -12,10 +12,10 @@ json.category_id @category.try(:id) json.category_name @category.try(:name) json.homeworks @homework_commons.each do |homework| - homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public + # homework_private = (@user_course_identity > Course::STUDENT) && !homework.is_public json.homework_id homework.id json.name homework.name - json.private_icon homework_private + json.private_icon !homework.is_public json.status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:status] json.status_time homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time] json.time_status homework_curr_status(homework, @user_course_identity, @course, @member, @member&.teacher_course_groups)[:time_status] From 61f491bdde789056d5cab606300a4b8467126e67 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 20 Jun 2019 19:46:35 +0800 Subject: [PATCH 5/6] fix bug --- app/controllers/exercise_answers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index 68ba83276..c709980f9 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -8,7 +8,7 @@ class ExerciseAnswersController < ApplicationController q_type = @exercise_question.question_type #试卷的类型 choice_id = params[:exercise_choice_id].present? ? params[:exercise_choice_id] : "" answer_text = params[:answer_text].present? ? params[:answer_text] : "" #为字符串 - if q_type < 4 && choice_id.blank? + if q_type < 4 && (q_type != 1) && choice_id.blank? normal_status(-1,"请选择序号") else ea = @exercise_question.exercise_answers.search_answer_users("user_id",current_user.id) #试卷的当前用户的答案 From 010d2f4049ada3e9abeee1f20427c31503a348aa Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 20 Jun 2019 19:52:12 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=80=89=E9=A2=98=E6=8B=92=E7=BB=9D?= =?UTF-8?q?=E5=90=8E=E9=80=89=E9=A2=98=E7=8A=B6=E6=80=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/graduation_topic.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/graduation_topic.rb b/app/models/graduation_topic.rb index 5a2a630e5..294bfa785 100644 --- a/app/models/graduation_topic.rb +++ b/app/models/graduation_topic.rb @@ -50,10 +50,10 @@ class GraduationTopic < ApplicationRecord def student_graduation_topic_status sgt = self.student_graduation_topics status = - if sgt.is_accepting.count == 0 - 2 - elsif sgt.is_refused.count == self.student_graduation_topics.size + if sgt.where(status: [0, 1]).count.zero? 0 + elsif sgt.is_accepting.count.zero? + 2 else 1 end