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/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) #试卷的当前用户的答案 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]