diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb index 105cbefbe..1f6dce053 100644 --- a/app/controllers/commons_controller.rb +++ b/app/controllers/commons_controller.rb @@ -45,7 +45,7 @@ class CommonsController < ApplicationController code = case params[:object_type].strip when 'message' - if current_user.course_identity(@object.board.course) >= 5 || @object.author != current_user + if current_user.course_identity(@object.board.course) >= 5 && @object.author != current_user 403 else 200 @@ -53,7 +53,7 @@ class CommonsController < ApplicationController else current_user.admin? ? 200 : 403 end - return normal_status(403, "你没有权限操作!") if code == 403 + return normal_status(code, "你没有权限操作!") if code == 403 end def action(flag) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index f7172021c..0d913a0a1 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -733,14 +733,14 @@ class ShixunsController < ApplicationController private def shixun_params - raise("实训名称不能为空") if params[:name].blank? + raise("实训名称不能为空") if params[:shixun][:name].blank? params.require(:shixun).permit(:name, :trainee, :webssh, :can_copy, :use_scope, :vnc, :test_set_permission, :task_pass, :repo_name, :multi_webssh, :opening_time, :mirror_script_id, :code_hidden, :hide_code, :forbid_copy) end def shixun_info_params - raise("实训描述不能为空") if params[:description].blank? - raise("评测脚本不能为空") if params[:evaluate_script].blank? + raise("实训描述不能为空") if params[:shixun_info][:description].blank? + raise("评测脚本不能为空") if params[:shixun_info][:evaluate_script].blank? params.require(:shixun_info).permit(:description, :evaluate_script) end diff --git a/app/models/challenge.rb b/app/models/challenge.rb index 18b177e1c..e7a382a51 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -52,7 +52,7 @@ class Challenge < ApplicationRecord # 开启挑战 def open_game user_id, shixun - game = self.games.first + game = self.games.where(user_id: user_id).first if game.present? shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : "" else diff --git a/app/services/exercise_user_pdf_service.rb b/app/services/exercise_user_pdf_service.rb index 44ee1e769..ee055ac66 100644 --- a/app/services/exercise_user_pdf_service.rb +++ b/app/services/exercise_user_pdf_service.rb @@ -41,7 +41,7 @@ class ExerciseUserPdfService # #-----正式需删掉 # aa = File.open(Rails.root.join("public/123.html"),"w+") # aa.syswrite(kit.source) - # #正式需删掉------- + # #正式需删掉-------s file = Tempfile.new(filename) kit.to_pdf(file.path) file diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 153ba1514..759a2d2b0 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -94,7 +94,7 @@ <% elsif q.question_type == 2 %>
<% q.exercise_choices.each do |s| %> - + <%= s.choice_text %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index f0eeb0f4c..1cfa57c80 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -39,7 +39,10 @@ p{ margin-bottom: 10px; } .mt8{ - margin-top:8px; + margin-top:7px; +} +.mt10{ + margin-top:10px; } .mbt10{ margin: 10px 0; @@ -109,6 +112,9 @@ p{ white-space: normal; min-height:12px; } +.null-answer p{ + display: inline-block; +} .choose-radio{ display: inline-block; width: 12px; @@ -322,6 +328,12 @@ textarea{ .choice-text p{ margin-bottom:0; } +.mt-2{ + margin-top:-2px; +} +.ex-scores{ + height: auto ; +} diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index bb3723373..bb50f7edf 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -37,14 +37,13 @@ 共<%= @exercise_ques_null_scores %> <% end %> <% if @exercise_ques_main_count > 0 %> - 主观题<%= @exercise_ques_main_count %>题, - 共<%= @exercise_ques_main_scores %> + 主观题<%= @exercise_ques_main_count %>题, + 共<%= @exercise_ques_main_scores %> <% end %> <% if @exercise_ques_shixun_count > 0 %> - 实训题<%= @exercise_ques_shixun_count %>题, - 共<%= @exercise_ques_shixun_scores %> + 实训题<%= @exercise_ques_shixun_count %>题, + 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> <%= @exercise_ques_scores %>分 @@ -56,6 +55,7 @@

+
<% if @ex_obj_array.size > 0 %>
@@ -177,27 +177,30 @@ <% end %>
+
<% if q_type == 0 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -
- - <%= to_markdown(s.choice_text,@request_url) %> +
+ + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> +
<% elsif q_type == 1 %> <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %> -
+
<% if check_answer %> - + <% else %> - + <% end %> - <%= to_markdown(s.choice_text,@request_url) %> + <%= to_markdown(s.choice_text,@request_url) %>
<% end %> +
<% elsif q_type == 2 %>
<% q.exercise_choices.each do |s| %> @@ -212,6 +215,7 @@ <% end %>
+
<% elsif q_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> @@ -220,16 +224,20 @@ <% else %> <% check_answer = "--" %> <% end %> -

+

答案(填空<%= index+1 %>): - <%= to_markdown(check_answer) %> -

+ <%= to_markdown(check_answer,@request_url) %> +
+
<% end %> <% elsif q_type == 4 %> <% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %> -

- <%= to_markdown(check_answer) %> -

+
+
+ <%= to_markdown(check_answer,@request_url) %> +
+
+
<% else %>

@@ -326,6 +334,7 @@

<% end %>
+
<% end %>