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

dev_course
jingquan huang 6 years ago
commit e474a8d139

@ -126,6 +126,13 @@ class ApplicationController < ActionController::Base
end
end
# 课堂教师、课堂管理员、超级管理员的权限(不包含助教)
def teacher_or_admin_allowed
unless current_user.course_identity(@course) < Course::ASSISTANT_PROFESSOR
normal_status(403, "")
end
end
def require_admin
normal_status(403, "") unless User.current.admin?
end

@ -2,7 +2,7 @@ class CourseGroupsController < ApplicationController
before_action :require_login
before_action :set_group, except: [:create]
before_action :find_course, only: [:create]
before_action :teacher_allowed
before_action :teacher_or_admin_allowed
def create
tip_exception("分班名称不能为空") if params[:name].blank?

@ -25,11 +25,11 @@ class CoursesController < ApplicationController
before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate,
:transfer_to_course_group, :delete_from_course,
:search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher]
before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :join_graduation_group,
:set_course_group, :change_course_admin, :change_course_teacher,
:delete_course_teacher, :teacher_application_review, :create_group_by_importing_file]
before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin,
:set_course_group, :delete_course_teacher, :teacher_application_review,
:create_group_by_importing_file]
before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group,
:export_member_scores_excel, :course_group_list]
:change_course_teacher, :export_member_scores_excel, :course_group_list]
before_action :validate_course_name, only: [:create, :update]
before_action :find_board, only: :board_list
before_action :validate_page_size, only: :mine

@ -480,7 +480,7 @@ class ExerciseQuestionsController < ApplicationController
ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分
if @exercise_question.question_type == 3 #当为填空题,更新问题的总分,
ex_answer_old = ex_answers.score_reviewed.pluck(:score).sum #每一关的得分总和
each_right_score = (@c_score / ex_answers.count.to_f).round(1) #调分后,平均每关的分数
each_right_score = (@c_score / ex_answers.count.to_f) #调分后,平均每关的分数
new_obj_score = ex_obj_score - ex_answer_old + @c_score
total_scores = new_obj_score + ex_subj_score
ex_scores = {
@ -615,7 +615,7 @@ class ExerciseQuestionsController < ApplicationController
normal_status(-1,"题目不允许为空!") if (params[:question_title].blank? && params[:question_type].to_i !=5 ) #除了实训题,其余题目必需有题干
normal_status(-1,"问题类型不允许为空!" ) if params[:question_type].blank?
normal_status(-1,"分值不允许为空!" ) if params[:question_score].blank? && params[:question_scores].blank? #分值的数组或参数必需存在一个
if params[:question_score].present? && params[:question_score].to_f.round(1) <= 0.0 #问题类型存在,则分值不能为空,且必需大于0
if params[:question_score].present? && params[:question_score].to_f <= 0.0 #问题类型存在,则分值不能为空,且必需大于0
normal_status(-1,"分值必需大于0")
elsif (params[:question_score].present? && params[:question_score].to_f.round(1) > 100.0) || (params[:question_scores].present? && (params[:question_scores].map{|a| a.to_f.round(1)}.max > 100.0))
normal_status(-1,"分值不能超过100分")
@ -677,7 +677,7 @@ class ExerciseQuestionsController < ApplicationController
end
def check_adjust_score
@c_score = params[:score].to_f.round(1) #调分后的分数
@c_score = params[:score].to_f #调分后的分数
@user_id = params[:user_id]
@exercise_current_user = @exercise.exercise_users.exercise_commit_users(@user_id).first #当前试卷用户的答案内容
if @exercise_current_user.blank?

@ -200,10 +200,15 @@ class HomeworkCommonsController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
else
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
{table_columns: @work_head_cells,task_users: @work_cells_column}
if @work_excel.present?
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
{table_columns: @work_head_cells,task_users: @work_cells_column}
else
normal_status(-1,"暂无提交的学生!")
end
end
}
format.zip{

@ -21,6 +21,7 @@ class ZipsController < ApplicationController
file_name = filename_for_content_disposition(exercises.filename)
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
rescue Exception => e
normal_status(-1, e.message)
end
@ -39,7 +40,7 @@ class ZipsController < ApplicationController
def get_exercise
ActiveRecord::Base.transaction do
begin
@exercise = Exercise.find_by(id:params[:exercise_id])
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
group_id = params[:exercise_group_id]
if @exercise.blank?
normal_status(-1,"试卷不存在")

@ -14,12 +14,14 @@ module UserDecorator
# 关注数
def follow_count
User.watched_by(id).count
Watcher.where(user_id: id, watchable_type: %w(Principal User)).count
# User.watched_by(id).count
end
# 粉丝数
def fan_count
watchers.count
Watcher.where(watchable_type: %w(Principal User), watchable_id: id).count
# watchers.count
end
# 是否绑定邮箱

@ -246,15 +246,18 @@ module CoursesHelper
def left_group_info course
group_info = []
course.course_groups.each do |course_group|
group_info << {category_id: course_group.id, category_name: course_group.name, position: course_group.position,
category_count: course_group.course_members_count, category_type: false,
second_category_url: "/courses/#{@course.id}/course_groups/#{course_group.id}"}
if course.course_groups_count > 0
course.course_groups.each do |course_group|
group_info << {category_id: course_group.id, category_name: course_group.name, position: course_group.position,
category_count: course_group.course_members_count, category_type: false,
second_category_url: "/courses/#{@course.id}/course_groups/#{course_group.id}"}
end
none_group_count = course.students.where(course_group_id: 0).size
group_info << {category_id: 0, category_name: "未分班", position: course.course_groups.pluck(:position).max.to_i + 1,
category_count: none_group_count, category_type: false,
second_category_url: "/courses/#{@course.id}/course_groups/0"}
end
none_group_count = course.students.where(course_group_id: 0).size
group_info << {category_id: 0, category_name: "未分班", position: course.course_groups.pluck(:position).max.to_i + 1,
category_count: none_group_count, category_type: false,
second_category_url: "/courses/#{@course.id}/course_groups/0"}
group_info
end
end

@ -245,7 +245,7 @@ module ExportHelper
else
user_course = "--"
end
user_obj_score = e_user.objective_score < 0.0 ? 0.0 : e_user.subjective_score.round(1).to_s
user_obj_score = e_user.objective_score < 0.0 ? 0.0 : e_user.objective_score.round(1).to_s
user_suj_score = e_user.subjective_score < 0.0 ? 0.0 : e_user.subjective_score.round(1).to_s
user_score = e_user.score.present? ? e_user.score.round(1).to_s : 0.0
if e_user.commit_status.present? && e_user.commit_status == 1

@ -41,7 +41,6 @@ class ExerciseUserPdfService
# aa = File.open(Rails.root.join("public/123.html"),"w+")
# aa.syswrite(kit.source)
#正式需删掉-------
file = Tempfile.new(filename)
kit.to_pdf(file.path)
file

@ -13,13 +13,13 @@
</div>
<div class="plr15">
<p class="text-gray">
<%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description).html_safe %>
<%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description)&.html_safe %>
</p>
</div>
</div>
<div class="mbt20 bgc">
<div class="ex-scores pd10 text-gray fs13">
<div class="inline-block pull-left">
<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>
@ -44,10 +44,16 @@
<span class="mr15">实训题<span class="mlr5"><%= @exercise_ques_shixun_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_shixun_scores %></span>分</span>
<% end %>
</div>
<div style="text-align:right;word-break:keep-all;">合计<span class="text-blue mlr5"><%= @exercise_ques_count %></span>题,
共<span class="text-orange mlr5"><%= @exercise_ques_scores %></span>分
</div>
<% 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="text-blue mlr5"><%= @exercise_ques_count %></span>题
</span>
<% end %>
</p>
</div>
</div>
<div class="mbt10">
@ -63,12 +69,12 @@
</div>
<div class="pbt5">
<% if q.question_type == 5 %>
<span class="ques-title"><%= q.shixun_name.present? ? q.shixun_name.html_safe : "" %></span>
<span class="ques-title"><%= q.shixun_name.present? ? q.shixun_name&.html_safe : "" %></span>
<div class="mt8 text-gray">
<span><%= q.question_title.present? ? q.question_title.html_safe : "" %></span>
<span><%= q.question_title.present? ? q.question_title&.html_safe : "" %></span>
</div>
<% else %>
<span class="ques-title"><%= q.question_title.present? ? q.question_title.html_safe : "" %></span>
<span class="ques-title"><%= q.question_title.present? ? q.question_title&.html_safe : "" %></span>
<% end %>
</div>
<div class="pbt5">

@ -1,5 +1,7 @@
body{
font-size:14px;}
font-size:14px;
font-family: "微软雅黑","宋体";
}
p{
margin:0;
}
@ -229,7 +231,7 @@ p{
position: absolute;
display: inline-block;
bottom: 9px;
left: 3px;
left: 1px;
}
.circle-right:after{
color:#fff;
@ -303,6 +305,10 @@ textarea{
background-color:#eee;
line-height:2;
}
.clearfix{
clear:both;
zoom:1;
}

@ -13,13 +13,13 @@
</div>
<div class="plr15">
<p class="text-gray">
<%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description).html_safe %>
<%= @exercise.try(:exercise_description).nil? ? "" : @exercise.try(:exercise_description)&.html_safe %>
</p>
</div>
</div>
<div class="mbt20 bgc">
<div class="ex-scores pd10 text-gray fs13">
<div class="inline-block pull-left">
<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>
@ -44,11 +44,16 @@
<span class="mr15">实训题<span class="mlr5"><%= @exercise_ques_shixun_count %></span>题,
共<span class="mlr5"><%= @exercise_ques_shixun_scores %></span>分</span>
<% end %>
</div>
<div style="text-align:right;word-break:keep-all;">
合计<span class="text-blue mlr5"><%= @exercise_ques_count %></span>题,
共<span class="text-orange mlr5"><%= @exercise_ques_scores %></span>分
</div>
<% 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="text-blue mlr5"><%= @exercise_ques_count %></span>题
</span>
<% end %>
</p>
</div>
</div>
<div class="mbt10">
@ -59,7 +64,7 @@
<span class="mlr5"><span class="line-line bg-green"></span>正确</span>
<span class="mlr5"><span class="line-line bg-red"></span>错误</span>
<span class="mlr5"><span class="line-line bg-orange"></span>部分得分</span>
<span class="pull-right">总分:<span class="text-orange"><%= @exercise_user.score %>分</span></span>
<span class="pull-right">总分:<span class="text-orange"><%= @exercise_user&.score %>分</span></span>
</p>
</div>
<div class="pbt5">
@ -162,14 +167,14 @@
</div>
<div class="pbt5">
<% if q_type == 5 %>
<span class="ques-title"><%= q.shixun_name.html_safe %></span>
<span class="ques-title"><%= q.shixun_name&.html_safe %></span>
<div class="mt8 text-gray">
<span><%= q.question_title.html_safe %></span>
<span><%= q.question_title&.html_safe %></span>
</div>
<% elsif q_type == 4 %>
<span class="ques-title"><%= q.question_title.html_safe %></span>
<span class="ques-title"><%= q.question_title&.html_safe %></span>
<% else %>
<span class="ques-title"><%= q.question_title.html_safe %></span>
<span class="ques-title"><%= q.question_title&.html_safe %></span>
<% end %>
</div>
</div>
@ -218,13 +223,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"><%= check_answer&.html_safe %></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"><%= check_answer&.html_safe %></span>
</p>
<% else %>
<div class="mbt10">

@ -96,7 +96,8 @@ Rails.application.configure do
config.active_record.belongs_to_required_by_default = false
# config.cache_store = :file_store, "#{Rails.root }/files/cache_store/"
config.cache_store = :redis_store, 'redis://r-bp122bd1b710f274.redis.rds.aliyuncs.com:6379/0/cache', { expires_in: 90.minutes }
#config.cache_store = :redis_store, 'redis://r-bp122bd1b710f274.redis.rds.aliyuncs.com:6379/0/cache', { expires_in: 90.minutes }
config.cache_store = :redis_store, 'redis://10.9.72.102:6379/0/cache', { expires_in: 90.minutes }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {

@ -1,11 +1,14 @@
PDFKit.configure do |config|
config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf'
# config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || 'wkhtmltopdf'
config.wkhtmltopdf = ENV["WKHTMLTOPDF_EXEC"] || '/usr/bin/wkhtmltopdf'
config.default_options = {
encoding: "UTF-8",
page_size: 'A4',
print_media_type: true,
dpi: 300,
debug_javascript: true,
javascript_delay: 500,
# quiet: false
stop_slow_scripts:false,
no_stop_slow_scripts: true
}

Loading…
Cancel
Save