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

dev_forum
cxt 5 years ago
commit 65f98fab79

@ -9,17 +9,17 @@ module GitHelper
# 版本库文件内容,带转码
def git_fle_content(repo_path, path)
begin
logger.info("git file content: repo_path is #{repo_path}, path is #{path}")
Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}")
content = GitService.file_content(repo_path: repo_path, path: path)
logger.info("git file content: content is #{content}")
Rails.logger.info("git file content: content is #{content}")
decode_content = nil
if content.present?
content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass
content = Base64.decode64(content)
cd = CharDet.detect(content)
logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
decode_content =
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8

@ -1335,7 +1335,7 @@ class ExercisesController < ApplicationController
def export_exercise
@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"
filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d_%H%M')}.pdf"
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
end

@ -734,6 +734,6 @@ module ExercisesHelper
#实训题学生代码的行数
def content_line(content)
content.split(/\r?\n/).length
content.split(/\r?\n/).length + 1
end
end

@ -2,6 +2,7 @@ class ExerciseUserPdfService
include ExercisesHelper
include ApplicationHelper
include StudentWorksHelper
include GitHelper
attr_reader :exercise, :ex_user, :request_url
@ -14,8 +15,8 @@ class ExerciseUserPdfService
end
def filename
user_course = @course.course_members.find_by(user_id:@ex_user_user.id).course_group_name
exercise_user_name = user_course + "_" + exercise.exercise_name + "_" + @ex_user_user.real_name
user_course = @course.course_members.find_by(user_id:@ex_user_user.id)&.course_group_name
exercise_user_name = "#{@ex_user_user.real_name}_#{user_course.present? ? user_course : "未分班"}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M')}"
"#{exercise_user_name.strip}.pdf"
end

@ -10,7 +10,7 @@ class ExportExercisesService
end
def filename
exercise_export_name = exercise.user.real_name + "_" + exercise.exercise_name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
exercise_export_name = "#{exercise.user.real_name}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M')}"
"#{exercise_export_name.strip}.zip"
end

@ -17,9 +17,9 @@
</p>
</div>
</div>
<div class="mbt20 bgc">
<div class="mbt20 bgc width100">
<div class="ex-scores pd10 text-gray fs13">
<p class="clearfix">
<p class="clearfix inline-block width100">
<% if @exercise_single_ques_count > 0 %>
<span class="mr15">单选题<span class="mlr5"><%= @exercise_single_ques_count %></span>题,
共<span class="mlr5"><%= @exercise_single_ques_scores %></span>分</span>
@ -44,17 +44,20 @@
<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>分
</span>
<span class="mr15 pull-right">
<span class="pull-right">
<% if @exercise_ques_count > 0 %>
<span class="mr15">
合计<span class="text-blue mlr5"><%= @exercise_ques_count %></span>题
</span>
<span>
共<span class="text-orange mlr5"><%= @exercise_ques_scores %></span>分
</span>
<% end %>
</span>
</p>
</div>
</div>
<div class="clearfix"></div>
<div class="mbt10">
<% @exercise_questions.each do |q| %>
<div class="bdc">

@ -2,6 +2,7 @@ body{
font-size:14px;
font-family: "微软雅黑","宋体";
}
p{
margin:0;
}
@ -319,6 +320,7 @@ textarea{
border:none;
background-color:#eee;
line-height:2;
}
.clearfix{
clear:both;
@ -331,10 +333,18 @@ textarea{
.mt-2{
margin-top:-2px;
}
.width100{
width:100%;
}
.ex-scores{
height: auto ;
/*width:100%;*/
/*display:inline-block;*/
word-break: break-all;
line-height:2;
}

@ -17,9 +17,9 @@
</p>
</div>
</div>
<div class="mbt20 bgc">
<div class="mbt20 bgc width100">
<div class="ex-scores pd10 text-gray fs13">
<p class="clearfix">
<p class="clearfix inline-block width100">
<% if @exercise_single_ques_count > 0 %>
<span class="mr15">单选题<span class="mlr5"><%= @exercise_single_ques_count %></span>题,
共<span class="mlr5"><%= @exercise_single_ques_scores %></span>分</span>
@ -37,21 +37,23 @@
共<span class="mlr5"><%= @exercise_ques_null_scores %></span>分</span>
<% end %>
<% if @exercise_ques_main_count > 0 %>
<span class="mr15">主观题<span class="mlr5"><%= @exercise_ques_main_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_main_scores %></span>分</span>
<span class="mr15">主观题<span class="mlr5"><%= @exercise_ques_main_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_main_scores %></span>分</span>
<% end %>
<% if @exercise_ques_shixun_count > 0 %>
<span class="mr15">实训题<span class="mlr5"><%= @exercise_ques_shixun_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_shixun_scores %></span>分</span>
<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>分
</span>
<span class="mr15 pull-right">
<span class="pull-right">
<% if @exercise_ques_count > 0 %>
<span class="mr15">
合计<span class="text-blue mlr5"><%= @exercise_ques_count %></span>题
</span>
<span>
共<span class="text-orange mlr5"><%= @exercise_ques_scores %></span>分
</span>
<% end %>
</span>
</p>
</div>
</div>
@ -316,20 +318,24 @@
</tbody>
</table>
<% end %>
<% if game.try(:lastest_code).present? && game.challenge.st == 0 %>
<% con_rows = content_line(game.lastest_code) %>
<div class="mbt20">
<p class="bgc" >
<% if game.try(:lastest_code).blank? %>
<% cha_path = challenge_path(game.challenge&.path) %>
<% latest_code = git_fle_content(game.myshixun.repo_path,cha_path) %>
<% else %>
<% latest_code = game.try(:lastest_code) %>
<% end %>
<% con_rows = content_line(latest_code) %>
<div class="mbt20">
<p class="bgc" >
<span class="pd10" style="display:inherit;">
<span class="fl">最近通过的代码</span>
<span class="pull-right"><%= game.challenge.path %></span>
<span class="pull-right"><%= game.challenge&.path %></span>
</span>
</p>
<div class="bg-e pd10">
<textarea class="" id="content_show_<%= game.id %>" name="content" rows="<%= con_rows %>"><%= game.lastest_code %></textarea>
</div>
</p>
<div class="bg-e pd10">
<textarea class="" id="content_show_<%= game.id %>" name="content" rows="<%= con_rows %>">><%= latest_code %></textarea>
</div>
<% end %>
</div>
</div>
</div>
<% end %>

Loading…
Cancel
Save