dev_forum
SylorHuang 6 years ago
parent 5d3cb93b35
commit e178f32db5

@ -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 = "#{@exercise.user.real_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

@ -49,12 +49,12 @@ class ZipsController < ApplicationController
@course = @exercise.course
default_ex_users = @exercise.all_exercise_users(current_user.id).exercise_user_committed
@ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
@ex_users = default_ex_users.limit 2 #仅导出已提交的,截止后则是全部为提交的。
#可以分班选择
if group_id.present?
exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数
user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq
@ex_users = @ex_users.where(user_id: user_ids)
@ex_users = @ex_users.where(user_id: user_ids).limit 2
end
default_ex_users_size = @ex_users.size

@ -15,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,37 +17,34 @@
</p>
</div>
</div>
<div class="mbt20 bgc">
<div class="mbt20 bgc width100">
<div class="ex-scores pd10 text-gray fs13">
<p class="clearfix width100 inline-block">
<span class="pull-left">
<% if @exercise_single_ques_count > 0 %>
<p class="clearfix">
<% 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>
<% end %>
<% if @exercise_double_ques_count > 0 %>
<% if @exercise_double_ques_count > 0 %>
<span class="mr15">多选题<span class="mlr5"><%= @exercise_double_ques_count %></span>题,
共<span class="mlr5"><%= @exercise_double_ques_scores %></span>分</span>
<% end %>
<% if @exercise_ques_judge_count > 0 %>
<% if @exercise_ques_judge_count > 0 %>
<span class="mr15">判断题<span class="mlr5"><%= @exercise_ques_judge_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_judge_scores %></span>分</span>
<% end %>
<% if @exercise_ques_null_count > 0 %>
<% if @exercise_ques_null_count > 0 %>
<span class="mr15">填空题<span class="mlr5"><%= @exercise_ques_null_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_null_scores %></span>分</span>
<% end %>
<% if @exercise_ques_main_count > 0 %>
<% 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>
<% end %>
<% if @exercise_ques_shixun_count > 0 %>
<% 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>
<% end %>
</span>
<span class="pull-right">
<% if @exercise_ques_count > 0 %>
<span class="mr15">
合计<span class="text-blue mlr5"><%= @exercise_ques_count %></span>题

@ -337,8 +337,8 @@ textarea{
width:100%;
}
.ex-scores{
width:100%;
display:inline-block;
/*width:100%;*/
/*display:inline-block;*/
word-break: break-all;
}

@ -19,33 +19,31 @@
</div>
<div class="mbt20 bgc width100">
<div class="ex-scores pd10 text-gray fs13">
<p class="clearfix width100 inline-block">
<span class="pull-left">
<% if @exercise_single_ques_count > 0 %>
<p class="clearfix">
<% 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>
<% end %>
<% if @exercise_double_ques_count > 0 %>
<% if @exercise_double_ques_count > 0 %>
<span class="mr15">多选题<span class="mlr5"><%= @exercise_double_ques_count %></span>题,
共<span class="mlr5"><%= @exercise_double_ques_scores %></span>分</span>
<% end %>
<% if @exercise_ques_judge_count > 0 %>
<% if @exercise_ques_judge_count > 0 %>
<span class="mr15">判断题<span class="mlr5"><%= @exercise_ques_judge_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_judge_scores %></span>分</span>
<% end %>
<% if @exercise_ques_null_count > 0 %>
<% if @exercise_ques_null_count > 0 %>
<span class="mr15">填空题<span class="mlr5"><%= @exercise_ques_null_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_null_scores %></span>分</span>
<% end %>
<% if @exercise_ques_main_count > 0 %>
<% 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>
<% end %>
<% if @exercise_ques_shixun_count > 0 %>
<% 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>
<% end %>
</span>
<span class="pull-right">
<% if @exercise_ques_count > 0 %>
<span class="mr15">

Loading…
Cancel
Save