Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
jasder 5 years ago
commit 8f359dd9a1

@ -150,9 +150,8 @@ class ChallengesController < ApplicationController
def index
uid_logger("identifier: #{params}")
# 通过调试发现 这里includes(:games)性能会慢10倍
current_myshixun = @shixun.current_myshixun(current_user.id)
@challenges = @shixun.challenges.includes(:games).where("games.user_id" => (current_myshixun ? current_user.id : nil))
@challenges = Challenge.fields_for_list.where(shixun_id: @shixun.id)
@editable = @shixun.status == 0 # before_action有判断权限如果没发布则肯定是管理人员
@user = current_user

@ -776,7 +776,7 @@ class CoursesController < ApplicationController
name = attachment.disk_filename
if name.split(".").last == "xls"
begin
attachment_folder = Rails.configuration.educoder['attachment_folder']
attachment_folder = edu_setting('attachment_folder')
full_path = "#{attachment_folder}/#{path}/#{name}"
xls = Roo::Spreadsheet.open(full_path, extension: :xls)
worksheet = xls.sheet(0)

@ -1333,8 +1333,8 @@ class ExercisesController < ApplicationController
#导出空白试卷
def export_exercise
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
@request_url = request.base_url
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
filename = "#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf"
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets

@ -12,7 +12,7 @@ class HomeworkCommonsController < ApplicationController
:code_review_detail, :show_comment, :settings, :works_list, :update_settings,
:reference_answer, :publish_groups, :end_groups, :alter_name, :update_explanation]
before_action :user_course_identity
before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer]
before_action :homework_publish, only: [:show, :works_list, :code_review_results, :show_comment, :settings, :reference_answer, :update_student_score]
before_action :teacher_allowed, only: [:new, :edit, :create, :update, :shixuns, :subjects, :create_shixun_homework,
:publish_homework, :end_homework, :set_public, :choose_category, :move_to_category,
:choose_category, :create_subject_homework, :multi_destroy, :group_list, :homework_code_repeat,
@ -237,6 +237,7 @@ class HomeworkCommonsController < ApplicationController
end
def update_score
tip_exception("作业还未发布,暂不能计算成绩") if @homework.publish_time.nil? || @homework.publish_time > Time.now
begin
if @homework.unified_setting
student_works = @homework.student_works

@ -179,6 +179,16 @@ class ShixunsController < ApplicationController
ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => @new_shixun.id)
end
# 同步配置
@shixun.shixun_service_configs.each do |config|
ShixunServiceConfig.create!(:shixun_id => @new_shixun.id,
:cpu_limit => config.cpu_limit,
:lower_cpu_limit => config.lower_cpu_limit,
:memory_limit => config.memory_limit,
:request_limit => config.request_limit,
:mirror_repository_id => config.mirror_repository_id)
end
# fork版本库
logger.info("###########fork_repo_path: ######{@repo_path}")
project_fork(@new_shixun, @repo_path, current_user.login)

@ -17,6 +17,7 @@ class ZipsController < ApplicationController
end
def export_exercises
@request_url = request.base_url
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
file_name = filename_for_content_disposition(exercises.filename)
@ -41,7 +42,6 @@ class ZipsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
@request_url = request.base_url
group_id = params[:exercise_group_id]
if @exercise.blank?
normal_status(-1,"试卷不存在")

@ -334,9 +334,8 @@ module ApplicationHelper
raw arr.join('')
end
def to_markdown(text)
request_url = request.base_url
# 导出pdf时转化markdown为html
def to_markdown(text,origin_url)
return nil if text.blank?
options = {
:autolink => true,
@ -349,9 +348,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=\"#{origin_url}") : m_t
end
end

@ -3,7 +3,7 @@ class ExerciseUserPdfService
include ApplicationHelper
include StudentWorksHelper
attr_reader :exercise, :ex_user
attr_reader :exercise, :ex_user, :request_url
def initialize(exercise, ex_user,request_url)
@exercise = exercise

@ -1,9 +1,9 @@
class ExportExercisesService
include ExercisesHelper
include StudentWorksHelper
attr_reader :exercise, :ex_users
attr_reader :exercise, :ex_users, :request_url
def initialize(exercise, ex_users,request_url)
def initialize(exercise, ex_users, request_url)
@exercise = exercise
@ex_users = ex_users
@request_url = request_url

@ -44,7 +44,6 @@
<span class="mr15">实训题<span class="mlr5"><%= @exercise_ques_shixun_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_shixun_scores %></span>分</span>
<% end %>
<% if @exercise_ques_count > 0 %>
<span class="pull-right">
共<span class="text-orange mlr5"><%= @exercise_ques_scores %></span>分
@ -59,7 +58,7 @@
<div class="mbt10">
<% @exercise_questions.each do |q| %>
<div class="bdc">
<div class="pbt10">
<div class="pbt5">
<div class="pbt5">
<span class="mr5 text-blue"><%= q.question_number %>、</span>
<span class="text-blue">
@ -68,45 +67,39 @@
<span class="text-gray mlr5">(<%= q&.question_score %>分)</span>
</div>
<div class="pbt5">
<img src="http://47.96.87.25:48080/api/attachments/368984" alt="电脑的电路图" title="电脑的电路图">
<img class="myavatar avatar-48" alt="udasker_picture" src="http://images.udask.cn/uploaders/user/picture/2/2_udasker.jpg?v=1556452947">
<% q_markdown = to_markdown(q.question_title) %>
<% if q.question_type == 5 %>
<% q_markdown_name = to_markdown(q.shixun_name) %>
<span class="ques-title" ><%= q_markdown_name %></span>
<span class="ques-title" ><%= to_markdown(q.shixun_name,@request_url) %></span>
<div class="mt8 text-gray">
<span><%= q_markdown %></span>
<span><%= to_markdown(q.question_title,@request_url) %></span>
</div>
<% else %>
<span class="ques-title"><%= q_markdown %></span>
<span class="ques-title"><%= to_markdown(q.question_title,@request_url) %></span>
<% end %>
</div>
<div class="pbt5">
<% if q.question_type == 0 %>
<% q.exercise_choices.each_with_index do |s,index| %>
<p class="pbt5">
<span class="choose-radio"></span>
<span class="mr15"><%= convert_to_char((index+1).to_s)%></span>
<span class="inline-block"><%= to_markdown(s.choice_text) %></span>
</p>
<% q.exercise_choices.each do |s| %>
<div class="pbt5 clearfix main-choice">
<span class="choose-radio pull-left mt8"></span>
<span class="inline-block pull-left choice-text ml10"><%= to_markdown(s.choice_text,@request_url) %></span>
</div>
<% end %>
<% elsif q.question_type == 1 %>
<% q.exercise_choices.each_with_index do |s,index| %>
<p class="pbt5">
<span class="choose-checkbox"></span>
<span class="mr20"><%= convert_to_char((index+1).to_s)%></span>
<span class="inline-block"><%= to_markdown(s.choice_text) %></span>
</p>
<% q.exercise_choices.each do |s| %>
<div class="pbt5 clearfix main-choice">
<span class="choose-checkbox pull-left mt8"></span>
<span class="inline-block pull-left choice-text ml10"><%= to_markdown(s.choice_text,@request_url) %></span>
</div>
<% end %>
<% elsif q.question_type == 2 %>
<p class="pbt5">
<% q.exercise_choices.each_with_index do |s,index| %>
<span class="mr15">
<span class="choose-radio"></span>
<span class="mlr5 inline-block"><%= to_markdown(s.choice_text) %></span>
<div class="pbt5 clearfix">
<% q.exercise_choices.each do |s| %>
<span class="mr15 clearfix">
<span class="choose-radio "></span>
<span class="mlr5 inline-block"><%= s.choice_text %></span>
</span>
<% end %>
</p>
</div>
<% elsif q.question_type == 3 %>
<% st_counts = q.exercise_standard_answers.pluck(:exercise_choice_id).uniq %>
<% st_counts.each_with_index do |s,index| %>

@ -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;
}
@ -248,7 +257,7 @@ table{
text-align:center;
}
table, tr, td, th, tbody, thead, tfoot,textarea{
table, tr, td, th, tbody, thead, tfoot,textarea,.main-choice{
page-break-inside: avoid;
}
table th{
@ -310,5 +319,10 @@ textarea{
zoom:1;
}
.choice-text p{
margin-bottom:0;
}

@ -167,41 +167,39 @@
<% end %>
</div>
<div class="pbt5">
<% q_title = q.question_title&.html_safe %>
<% if q_type == 5 %>
<% q_name = q.shixun_name&.html_safe %>
<span class="ques-title"><%= q_name&.include?("src=\"") ? q_name&.gsub("src=\"","src=\"#{@request_url}") : q_name %></span>
<% if q.question_type == 5 %>
<span class="ques-title" ><%= to_markdown(q.shixun_name,@request_url) %></span>
<div class="mt8 text-gray">
<span><%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %></span>
<span><%= to_markdown(q.question_title,@request_url) %></span>
</div>
<% else %>
<span class="ques-title"><%= q_title&.include?("src=\"") ? q_title&.gsub("src=\"","src=\"#{@request_url}") : q_title %></span>
<span class="ques-title"><%= to_markdown(q.question_title,@request_url) %></span>
<% end %>
</div>
</div>
<div class="pbt5">
<% 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" : '' %>
<p class="pbt5">
<span class="choose-radio <%= check_answer %>"></span>
<span class="mr15"><%= convert_to_char((index+1).to_s)%></span><%= s.choice_text%>
</p>
<div class="pbt5 clearfix main-choice">
<span class="choose-radio <%= check_answer %> pull-left mt8"></span>
<span class="inline-block pull-left ml10 choice-text"><%= to_markdown(s.choice_text,@request_url) %></span>
</div>
<% 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 %>
<p class="pbt5">
<div class="pbt5 clearfix main-choice">
<% if check_answer %>
<span class="choose-checkbox choose-answer-multi" ></span>
<span class="choose-checkbox choose-answer-multi mt8" ></span>
<% else %>
<span class="choose-checkbox"></span>
<span class="choose-checkbox pull-left mt8"></span>
<% end %>
<span class="mr15"><%= convert_to_char((index+1).to_s)%></span><%= s.choice_text%>
</p>
<span class="inline-block pull-left choice-text ml10"><%= to_markdown(s.choice_text,@request_url) %></span>
</div>
<% end %>
<% elsif q_type == 2 %>
<p class="pbt5">
<div class="pbt5 clearfix">
<% 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 @@
<span class="mlr5"><%= s.choice_text %></span>
</span>
<% end %>
</p>
</div>
<% 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 %>
<p class="pbt10 flex-nowrap">
<span class="pull-left line-34">答案(填空<%= index+1 %></span>
<span class="null-answer"><%= check_answer&.html_safe %></span>
<span class="null-answer"><%= to_markdown(check_answer) %></span>
</p>
<% end %>
<% elsif q_type == 4 %>
<% check_answer = (user_answer.present? ? user_answer.first.answer_text : '--') %>
<p class="flex-nowrap">
<span class="null-answer main-height"><%= check_answer&.html_safe %></span>
<span class="null-answer main-height"><%= to_markdown(check_answer) %></span>
</p>
<% else %>
<div class="mbt10">
@ -337,7 +335,7 @@
<div class="bdc">
<div class="pbt10">
<div class="inline-block pull-left">
<span><img src="/images/avatars/User/<%= ques_user.id %>" class="avatar-32"/></span>
<span><img src="<%= @request_url %>/images/avatars/User/<%= ques_user.id %>" class="avatar-32"/></span>
</div>
<div class="ml38">
<p class="mb10"><span class="pr"><%= ques_user.real_name %></span><span class="plr15 text-gray"><%= ques_comment.first.updated_at.strftime('%Y-%m-%d %H:%M') %></span></p>

@ -1,6 +1,6 @@
# 导航栏公共数据
json.partial! "challenges/top_common_data", shixun_identifier: @shixun.identifier
json.(@challenge, :id, :subject, :task_pass, :difficulty, :score)
json.(@challenge, :id, :subject, :task_pass, :difficulty, :score, :exec_time)
json.tags @challenge.challenge_tags.map(&:name)

@ -22,7 +22,7 @@ json.shixun do
json.hide_code @shixun.hide_code # 隐藏代码窗口
json.code_hidden @shixun.code_hidden # 代码目录隐藏
json.vnc @shixun.vnc
json.exec_time @shixun.exec_time
#json.exec_time @shixun.exec_time
json.webssh @shixun.webssh
json.multi_webssh @shixun.multi_webssh
json.use_scope @shixun.use_scope

Loading…
Cancel
Save