From 029aac355491a4ee5a44823ea0cc55875719dab4 Mon Sep 17 00:00:00 2001 From: jasder Date: Mon, 1 Jul 2019 11:35:27 +0800 Subject: [PATCH 1/7] FIX delete message permission --- app/controllers/messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index bad54b88e..f684b27f3 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -128,7 +128,7 @@ class MessagesController < ApplicationController def destroy begin - return normal_status(403, "您没有权限进行该操作") unless @message.author == current_user || current_user.teacher_of_course?(@message.board.course) + return normal_status(403, "您没有权限进行该操作") if current_user.course_identity(@message.board.course) >= 5 || @message.author != current_user @message.destroy! rescue Exception => e uid_logger_error(e.message) From 4a257c29603b67ab17d2d59f66b6ba2ce580e172 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:24:00 +0800 Subject: [PATCH 2/7] fix bug --- .../exercise_export/blank_exercise.html.erb | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 9ee1d40f7..f281a55a0 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -83,30 +83,28 @@
<% if q.question_type == 0 %> - <% q.exercise_choices.each_with_index do |s,index| %> -

- - <%= convert_to_char((index+1).to_s)%> - <%= to_markdown(s.choice_text) %> -

+ <% q.exercise_choices.each do |s| %> +
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q.question_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> -

- - <%= convert_to_char((index+1).to_s)%> - <%= to_markdown(s.choice_text) %> -

+ <% q.exercise_choices.each do |s| %> +
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q.question_type == 2 %> -

- <% q.exercise_choices.each_with_index do |s,index| %> - - - <%= to_markdown(s.choice_text) %> +

+ <% q.exercise_choices.each do |s| %> + + + <%= to_markdown(s.choice_text) %> <% end %> -

+
<% elsif q.question_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> From 8f3be9a7f6e42c8e3678df80eb6b0f660b748d4c Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:37:13 +0800 Subject: [PATCH 3/7] fix bug --- .../exercise_export/blank_exercise.html.erb | 16 ++++++---------- .../exercise_export/exercise_export.css | 6 ++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index f281a55a0..b253d86b9 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -68,17 +68,13 @@ (<%= q&.question_score %>分)
- 电脑的电路图 - udasker_picture - <% q_markdown = to_markdown(q.question_title) %> <% if q.question_type == 5 %> - <% q_markdown_name = to_markdown(q.shixun_name) %> - <%= q_markdown_name %> + <%= to_markdown(q.shixun_name) %>
- <%= q_markdown %> + <%= to_markdown(q.question_title) %>
<% else %> - <%= q_markdown %> + <%= to_markdown(q.question_title) %> <% end %>
@@ -86,14 +82,14 @@ <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> @@ -101,7 +97,7 @@ <% q.exercise_choices.each do |s| %> - <%= to_markdown(s.choice_text) %> + <%= to_markdown(s.choice_text) %> <% end %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 9190e9251..bbe523972 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -309,6 +309,12 @@ textarea{ clear:both; zoom:1; } +.line-20{ + line-height: 20px; +} +.line-20 P{ + margin-bottom:0; +} From 0922155a1cdd9a603bd59b193506b2537c165896 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:50:01 +0800 Subject: [PATCH 4/7] fix bug --- app/helpers/application_helper.rb | 4 +--- .../exercise_export/blank_exercise.html.erb | 15 +++++++-------- app/templates/exercise_export/exercise_export.css | 4 +++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd5a8b233..c49e5e775 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -349,9 +349,7 @@ module ApplicationHelper } markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,options) m_t = markdown.render(text) - ss = m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t - Rails.logger.info("############_____________ss________________##################{ss}") - ss + m_t&.include?("src=\"") ? m_t&.gsub("src=\"","src=\"#{request_url}") : m_t end end diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index b253d86b9..5727d0f62 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -44,7 +44,6 @@ 实训题<%= @exercise_ques_shixun_count %>题, 共<%= @exercise_ques_shixun_scores %> <% end %> - <% if @exercise_ques_count > 0 %> <%= @exercise_ques_scores %>分 @@ -59,7 +58,7 @@
<% @exercise_questions.each do |q| %>
-
+
<%= q.question_number %>、 @@ -80,15 +79,15 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
- +
+ <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
- +
+ <%= to_markdown(s.choice_text) %>
<% end %> @@ -96,8 +95,8 @@
<% q.exercise_choices.each do |s| %> - - <%= to_markdown(s.choice_text) %> + + <%= s.choice_text %> <% end %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index bbe523972..140db58ef 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -315,6 +315,8 @@ textarea{ .line-20 P{ margin-bottom:0; } - +.v-middle{ + vertical-align: middle; +} From b69d705ed77f4f81f78b32d323a03f05d5ca5aef Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:52:42 +0800 Subject: [PATCH 5/7] Fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 8 ++++---- app/templates/exercise_export/exercise_export.css | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 5727d0f62..aed7acdcd 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -80,15 +80,15 @@ <% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 140db58ef..3efda43bb 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -309,8 +309,8 @@ textarea{ clear:both; zoom:1; } -.line-20{ - line-height: 20px; +.line-24{ + line-height: 24px; } .line-20 P{ margin-bottom:0; From e365005af14682e96f3bc080ac32ab1c733f1438 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 12:55:04 +0800 Subject: [PATCH 6/7] fix bug --- app/templates/exercise_export/blank_exercise.html.erb | 4 ++-- app/templates/exercise_export/exercise_export.css | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index aed7acdcd..99b8e6683 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -79,14 +79,14 @@
<% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %> -
+
<%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %> -
+
<%= to_markdown(s.choice_text) %>
diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 3efda43bb..53dc5b3c8 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -312,11 +312,9 @@ textarea{ .line-24{ line-height: 24px; } -.line-20 P{ +.line-24 p{ margin-bottom:0; } -.v-middle{ - vertical-align: middle; -} + From 81950469b4c33cdd8e139a8ac26a4717c7c87f6b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Mon, 1 Jul 2019 13:15:13 +0800 Subject: [PATCH 7/7] fix bug --- .../exercise_export/blank_exercise.html.erb | 8 ++-- .../exercise_export/exercise_export.css | 10 +++++ .../exercise_export/exercise_user.html.erb | 40 +++++++++---------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 99b8e6683..7e7c14977 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -80,15 +80,15 @@ <% if q.question_type == 0 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 1 %> <% q.exercise_choices.each do |s| %>
- - <%= to_markdown(s.choice_text) %> + + <%= to_markdown(s.choice_text) %>
<% end %> <% elsif q.question_type == 2 %> diff --git a/app/templates/exercise_export/exercise_export.css b/app/templates/exercise_export/exercise_export.css index 53dc5b3c8..a72b26782 100644 --- a/app/templates/exercise_export/exercise_export.css +++ b/app/templates/exercise_export/exercise_export.css @@ -44,6 +44,9 @@ p{ .mbt10{ margin: 10px 0; } +.mt5{ + margin-top:5px; +} .pull-right{ float:right; } @@ -82,9 +85,15 @@ p{ .ml20{ margin-left:20px; } +.ml10{ + margin-left:10px; +} .mr3{ margin-right:3px; } +.mr8{ + margin-right:8px; +} .mr15{ margin-right:15px; } @@ -318,3 +327,4 @@ textarea{ + diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 5770c5921..1679692b3 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -167,41 +167,39 @@ <% end %>
- <% q_title = q.question_title&.html_safe %> - <% if q_type == 5 %> - <% q_name = q.shixun_name&.html_safe %> - <%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %> + <% if q.question_type == 5 %> + <%= to_markdown(q.shixun_name) %>
- <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= to_markdown(q.question_title) %>
<% else %> - <%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %> + <%= to_markdown(q.question_title) %> <% end %>
<% if q_type == 0 %> - <% q.exercise_choices.each_with_index do |s,index| %> + <% q.exercise_choices.each do |s| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %> -

- - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -

+
+ + <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q_type == 1 %> - <% q.exercise_choices.each_with_index do |s,index| %> + <% 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 %> - <%= convert_to_char((index+1).to_s)%><%= s.choice_text%> -

+ <%= to_markdown(s.choice_text) %> +
<% end %> <% elsif q_type == 2 %> -

+

<% q.exercise_choices.each do |s| %> <% if user_answer.present? && (s.id == user_answer.first.exercise_choice_id) %> <% check_answer = 'choose-answer' %> @@ -213,7 +211,7 @@ <%= s.choice_text %> <% end %> -

+
<% elsif q_type == 3 %> <% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %> <% st_counts.each_with_index do |s,index| %> @@ -224,13 +222,13 @@ <% end %>

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

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

- <%= check_answer&.html_safe %> + <%= to_markdown(check_answer) %>

<% else %>