diff --git a/app/controllers/exercise_answers_controller.rb b/app/controllers/exercise_answers_controller.rb index e5d67b2d7..b1e23071b 100644 --- a/app/controllers/exercise_answers_controller.rb +++ b/app/controllers/exercise_answers_controller.rb @@ -14,19 +14,15 @@ class ExerciseAnswersController < ApplicationController else ea = @exercise_question.exercise_answers.search_answer_users("user_id",current_user.id) #试卷的当前用户的答案 if q_type == Exercise::SINGLE || q_type == Exercise::JUDGMENT #选择题(单选)/判断题 - ea_choice = ea.search_exercise_answer("exercise_choice_id",choice_id).first - answer_option = { + if ea.exists? + ea.first.update_attribute(:exercise_choice_id,choice_id ) + else + answer_option = { :user_id => current_user.id, :exercise_question_id => @exercise_question.id, :exercise_choice_id => choice_id, :answer_text => "" - } - if ea_choice.present? #如果当前用户的答案存在,再次点击,即为删除 - ea_choice.destroy - else - if @exercise_question.exercise_standard_answers.count <= 1 #单选题的时候 - ea.first.destroy if ea.present? - end + } ex_a = ExerciseAnswer.new(answer_option) ex_a.save! end diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index 4003ffb94..130e7f4b8 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -344,7 +344,7 @@ module TidingDecorator end def resubmit_student_work_content - I18n.t(locale_format) % container&.homework_common.try(:name) + I18n.t(locale_format) % parent_container.try(:name) end def student_works_score_content diff --git a/app/services/subject_search_service.rb b/app/services/subject_search_service.rb index 2366cecc2..f69c56c88 100644 --- a/app/services/subject_search_service.rb +++ b/app/services/subject_search_service.rb @@ -12,7 +12,7 @@ class SubjectSearchService < ApplicationService type = params[:type] || "all" if type == "mine" - @subjects = User.current.shixuns.visible.unhidden + @subjects = User.current.subjects.visible.unhidden else @subjects = Subject.visible.unhidden end diff --git a/app/views/shixun_lists/index.json.jbuilder b/app/views/shixun_lists/index.json.jbuilder index 79ce4b09c..08baeabf9 100644 --- a/app/views/shixun_lists/index.json.jbuilder +++ b/app/views/shixun_lists/index.json.jbuilder @@ -11,12 +11,12 @@ json.shixun_list do atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/ highlights[:description]&.first&.sub!(reg, '') - highlights[:description]&.map{|des| des.gsub!(atta_reg, '')} + highlights[:description]&.map{|des| des.gsub(atta_reg, '')} highlights[:content]&.first&.sub!(reg, '') - highlights[:content]&.map{|des| des.gsub!(atta_reg, '')} + highlights[:content]&.map{|des| des.gsub(atta_reg, '')} json.title highlights.delete(:name)&.join('...') || obj.searchable_title - json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '') + json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.gsub(atta_reg, '') json.content highlights json.level level_to_s(obj.trainee) diff --git a/app/views/subject_lists/index.json.jbuilder b/app/views/subject_lists/index.json.jbuilder index 6992deb1f..63ee6dcbc 100644 --- a/app/views/subject_lists/index.json.jbuilder +++ b/app/views/subject_lists/index.json.jbuilder @@ -7,15 +7,15 @@ json.subject_list do # 去除开头标点符号 reg = /^[,。?:;‘’!“”—……、]/ # 附件的替换 - atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/ + atta_reg = /!\[.*\]\(\/api\/attachments\/\d+\)/ highlights[:description]&.first&.sub!(reg, '') - highlights[:description]&.map{|des| des.gsub!(atta_reg, '')} + highlights[:description]&.map{|des| des.gsub(atta_reg, '')} highlights[:content]&.first&.sub!(reg, '') - highlights[:content]&.map{|des| des.gsub!(atta_reg, '')} + highlights[:content]&.map{|des| des.gsub(atta_reg, '')} json.title highlights.delete(:name)&.join('...') || obj.searchable_title - json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '') + json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.gsub(atta_reg, '') json.content highlights end diff --git a/public/react/src/modules/message/js/MessagSub.js b/public/react/src/modules/message/js/MessagSub.js index 88613513c..f92ea71c4 100644 --- a/public/react/src/modules/message/js/MessagSub.js +++ b/public/react/src/modules/message/js/MessagSub.js @@ -488,10 +488,24 @@ class MessagSub extends Component { case "SubjectStartCourse": return window.open(`/paths/${item.container_id}`); case "ResubmitStudentWork": - return window.open(`/courses/${item.belong_container_id}/graduation_tasks/${item.container_id}/appraise`); + if (item.homework_type === "normal") { + //普通作业 + return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}/${item.container_id}/appraise`); + } + if (item.homework_type === "group") { + //分组作业 + return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}/${item.container_id}/appraise`); + } case "AdjustScore": //belong_container_id course的id - return window.open(`/courses/${item.belong_container_id}/graduation_tasks/${item.parent_container_id}`); + if (item.homework_type === "normal") { + //普通作业 + return window.open(`/courses/${item.belong_container_id}/common_homeworks/${item.parent_container_id}`); + } + if (item.homework_type === "group") { + //分组作业 + return window.open(`/courses/${item.belong_container_id}/group_homeworks/${item.parent_container_id}`); + } default : return }