Merge branches 'dev_Ysm' and 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_Ysm

dev_aliyun_beta
杨树明 6 years ago
commit 037c0bdf17

@ -34,7 +34,7 @@ $(document).on('turbolinks:load', function() {
$.get('/colleges/' + schoolId + '/shixun_chart_data', function(data){
$statisticBody.find('.shixun-chart-loading').hide();
if (data.data.length > 0) {
$shixunChart.css('height', '400px').css('width', '400px');
$shixunChart.css('height', '400px').css('width', '100%');
initShixunChart(data.names, data.data);
} else {
$statisticBody.find('.shixun-chart-empty').show();
@ -146,7 +146,7 @@ $(document).on('turbolinks:load', function() {
$.get('/colleges/' + schoolId + '/student_hot_evaluations', function(data){
$statisticBody.find('.hot-chart-loading').hide();
if (data.names.length > 0) {
$statisticBody.find('.hot-chart').css('height', '400px').css('width', '400px');
$statisticBody.find('.hot-chart').css('height', '400px').css('width', '100%');
initHotEvaluating(data.names.reverse(), data.values.reverse());
} else {
$statisticBody.find('.hot-chart-empty').show();

@ -1085,11 +1085,15 @@ class CoursesController < ApplicationController
# 导出课堂信息
def export_couser_info
set_export_cookies
course_info_to_xlsx @course
filename_ = "#{current_user.real_name}_#{@course.name}_课堂信息_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{format_sheet_name filename_.strip}",template: "courses/export_course_info.xlsx.axlsx",
locals: {course_info: @course_info}
if params[:export].present? && params[:export]
normal_status(0,"正在下载中")
else
set_export_cookies
course_info_to_xlsx @course
filename_ = "#{current_user.real_name}_#{@course.name}_课堂信息_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{format_sheet_name filename_.strip}",template: "courses/export_course_info.xlsx.axlsx",
locals: {course_info: @course_info}
end
end
# 导出活跃度

@ -372,7 +372,7 @@ class ExerciseBankQuestionsController < ApplicationController
private
def bank_admin
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin?
end
def get_exercise

@ -17,9 +17,9 @@ class ExerciseBanksController < ApplicationController
end
def update
tip_exception("试卷标题不能为空!") if params[:exercise_name].blank?
tip_exception("标题不能为空!") if params[:exercise_name].blank?
@bank.update_attributes!(name: params[:exercise_name], description: params[:exercise_description])
normal_status(0,"试卷更新成功")
normal_status(0,"更新成功")
end
def choose_shixun
@ -58,11 +58,12 @@ class ExerciseBanksController < ApplicationController
def find_bank
@bank = ExerciseBank.find_by!(id: params[:id])
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? ||
(current_user.certification_teacher? && @bank.is_public)
end
def bank_admin
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin?
end
#判断实训是否已选择

@ -280,11 +280,12 @@ class ExerciseQuestionsController < ApplicationController
if null_choice_text_count >= ex_answer_pre_count
new_add_choice = null_choice_text_count_array - ex_answer_pre_count_array
ex_answer_pre_count_array.each do |n|
standard_option = {
:exercise_question_id => @exercise_question.id,
:exercise_choice_id => null_choice_id,
:answer_text => null_choice_text[n-1]
@hash_symbol_null_ = {
:exercise_question_id => @exercise_question.id,
:exercise_choice_id => null_choice_id,
:answer_text => null_choice_text[n - 1]
}
standard_option = @hash_symbol_null_
ex_answer_pre[n-1].update(standard_option)
end
if new_add_choice.count > 0 #表示有新增的

@ -23,11 +23,12 @@ class GtopicBanksController < ApplicationController
def find_bank
@bank = GtopicBank.find_by!(id: params[:id])
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? ||
(current_user.certification_teacher? && @bank.is_public)
end
def bank_admin
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin?
end
def gtopic_bank_params

@ -39,11 +39,12 @@ class HomeworkBanksController < ApplicationController
def find_bank
@bank = HomeworkBank.find_by!(id: params[:id])
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? ||
(current_user.certification_teacher? && @bank.is_public)
end
def bank_admin
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin?
end
def bank_params

@ -0,0 +1,157 @@
class PollBankQuestionsController < ApplicationController
before_action :require_login, :check_auth #用户需登陆
before_action :get_poll, only:[:create] #获取试卷
before_action :get_poll_question, except: [:create] #获取试卷的问题及试卷
before_action :bank_admin #是否为老师
before_action :validates_params, only: [:create, :update] #传入参数的验证
def create
ActiveRecord::Base.transaction do
begin
poll_options = {
:question_title => params[:question_title],
:question_type => params[:question_type],
:is_necessary => params[:is_necessary].to_i,
:question_number => @poll.exercise_bank_questions.count + 1,
:max_choices => params[:max_choices] || nil,
:min_choices => params[:min_choices] || nil
}
@poll_question = @poll.exercise_bank_questions.new(poll_options)
if params[:insert_id].present? #插入问题时那么从插入的这个id以后的question_num都将要+1
insert_poll = @poll.exercise_bank_questions.find_by(id: params[:insert_id])
if insert_poll.present? #如果该问题存在的话,意思是如果是第一题,那么就不存在插入
ques_num = insert_poll.question_number.to_i
@poll_question.question_number = ques_num + 1 #更新了问题的位置
@poll.exercise_bank_questions.insert_question_ex(ques_num).update_all("question_number = question_number + 1")
end
end
if @poll_question.save!
if params[:question_type] != 3
p_answer = params[:question_answers]
p_other_answer = params[:question_other_answer]
# 新增选择题答案选择的选项
(1..p_answer.count).each do |i|
answer = p_answer[i-1] # 传入的答案的内容
question_option = {
:choice_position => i,
:choice_text => answer
}
poll_answers = @poll_question.exercise_bank_choices.new question_option
poll_answers.save
end
# 新增答案的其他选项
if p_other_answer
question_option = {
:choice_position => p_answer.count + 1,
:choice_text => ''
}
poll_answers = @poll_question.exercise_bank_choices.new question_option
poll_answers.save
end
end
end
normal_status("创建成功")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("问卷的问题创建失败!")
raise ActiveRecord::Rollback
end
end
end
def update
ActiveRecord::Base.transaction do
begin
if @poll_question.question_type < 3 #当为单选题或多选题时
p_answer = params[:question_answers]
p_other_answer = params[:question_other_answer]
p_answer_count = p_answer.count
@poll_question.exercise_bank_choices.each do |an|
if (p_answer_count < @poll_current_answers) && (p_answer_count..@poll_current_answers).to_a.include?(an.choice_position)
an.destroy
end
end
(1..p_answer_count).each do |i|
answer = @poll_question.exercise_bank_choices.find_by_custom("choice_position",i).first
if answer # 判断该位置的answer是否存在存在则更新.不存在则跳到下一步
answer.choice_text = p_answer[i-1]
answer.choice_position = i
answer.save
else
answer_options = {
:choice_position => i,
:choice_text => p_answer[i-1]
}
@poll_question.exercise_bank_choices.new answer_options
end
end
if p_other_answer #判断答案的其他选项是否存在
other_answer = @poll_question.exercise_bank_choices.find_by_custom("choice_text","").first
if other_answer.blank?
question_option = {
:choice_position => p_answer_count + 1,
:choice_text => ''
}
@poll_question.exercise_bank_choices.new question_option
else
other_answer.choice_position = p_answer_count + 1
other_answer.save
end
end
end
@poll_question.update_attributes(poll_questions_params)
normal_status("问卷更新成功")
rescue Exception => e
uid_logger_error(e.message)
tip_exception("更新失败")
raise ActiveRecord::Rollback
end
end
end
private
def bank_admin
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin?
end
def get_poll
@poll = ExerciseBank.find_by!(id: params[:exercise_bank_id])
end
def get_poll_question
@poll_question = ExerciseBankQuestion.find_by!(id: params[:id])
@poll = @poll_question.exercise_bank
end
def poll_questions_params
params.require(:poll_question).permit(:question_title,:question_type,:is_necessary,:question_number,:max_choices,:min_choices)
end
def validates_params
normal_status(-1, "问题标题不能为空!") if params[:question_title].blank?
normal_status(-1, "是否要求必答的值不能为空!") if params[:is_necessary].blank?
normal_status(-1, "问题类型不能为空!") if params[:question_type].blank?
if params[:min_choices].present? && params[:max_choices].present? && (params[:min_choices].to_i > params[:max_choices].to_i)
normal_status(-1, "最小可选不能大于最大可选!")
elsif params[:question_answers].present? && (params[:max_choices].to_i > params[:question_answers].count)
normal_status(-1, "选择题的最大可选项不能大于答案数!")
elsif [1,3].include?(params[:question_type]) && (params[:max_choices].to_i > 0 || params[:min_choices].to_i > 0)
normal_status(-1, "单选题或主观题不能有最大或最小选择数!")
elsif params[:question_type] == 3 && (params[:question_answers] || params[:question_other_answer])
normal_status(-1, "主观问题不需要可选答案!")
elsif params[:question_type] != 3
if params[:question_answers].present? && params[:question_answers].include?("")
normal_status(-1, "选择题不能有空值!")
elsif params[:question_other_answer].present? && params[:question_other_answer].length > 0
normal_status(-1, "其他选项不能有值!")
elsif params[:question_type] == 1 && params[:question_answers].count < 2
normal_status(-1, "单选题选项不能小于2")
elsif params[:question_type] == 2 && params[:question_answers].count < 3
normal_status(-1, "多选题选项不能小于3")
end
end
end
end

@ -25,11 +25,12 @@ class TaskBanksController < ApplicationController
def find_bank
@bank = GtaskBank.find_by!(id: params[:id])
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin? ||
(current_user.certification_teacher? && @bank.is_public)
end
def bank_admin
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
tip_exception(403, "无权限") unless @bank.user_id == current_user.id || current_user.admin?
end
def gtask_bank_params

@ -14,7 +14,13 @@
<td class="member-container">
<%= render partial: 'admins/departments/shared/member_users', locals: { department: department } %>
</td>
<td><%= link_to department.identifier.to_s, '#', target: '_blank' %></td>
<td>
<% if department.identifier.present? %>
<%= link_to department.identifier.to_s, statistics_college_path(department.identifier), target: '_blank' %>
<% else %>
--
<% end %>
</td>
<td><%= department.host_count %></td>
<td><%= department.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
<td class="action-container">

@ -17,10 +17,10 @@
<% if @courses.present? %>
<% @courses.each do |course| %>
<tr>
<td class="text-left"><a href="/courses/<%= course.id %>/students" target="_blank" class="task-hide pl20 edu-txt-left" style="max-width: 220px"><%= course.name %></a></td>
<td class="text-left"><a href="/courses/<%= course.id %>/students" target="_blank" class="d-inline-block text-truncate" style="max-width: 220px"><%= course.name %></a></td>
<% teacher_names = course.teacher_users.map(&:real_name).join('、') %>
<td class="text-left">
<span class="d-inline-block text-truncate" style="max-width: 220px" data-toggle="tooltip" title="<%= teacher_names %>">
<span class="d-inline-block text-truncate" style="max-width: 150px" data-toggle="tooltip" title="<%= teacher_names %>">
<%= teacher_names || '--' %>
</span>
</td>

@ -104,8 +104,8 @@
<th>排名</th>
<th>姓名</th>
<th>管理课堂</th>
<th>已发布实训作业</th>
<th>未发布实训作业</th>
<th width="15%">已发布实训作业</th>
<th width="15%">未发布实训作业</th>
<th>学生数</th>
<th>完成率</th>
<th>发布实训</th>

@ -663,6 +663,8 @@ Rails.application.routes.draw do
end
end
resources :poll_bank_questions
resources :attachments
resources :schools do

File diff suppressed because one or more lines are too long

@ -129134,7 +129134,7 @@ $(document).on('turbolinks:load', function() {
$.get('/colleges/' + schoolId + '/shixun_chart_data', function(data){
$statisticBody.find('.shixun-chart-loading').hide();
if (data.data.length > 0) {
$shixunChart.css('height', '400px').css('width', '400px');
$shixunChart.css('height', '400px').css('width', '100%');
initShixunChart(data.names, data.data);
} else {
$statisticBody.find('.shixun-chart-empty').show();
@ -129246,7 +129246,7 @@ $(document).on('turbolinks:load', function() {
$.get('/colleges/' + schoolId + '/student_hot_evaluations', function(data){
$statisticBody.find('.hot-chart-loading').hide();
if (data.names.length > 0) {
$statisticBody.find('.hot-chart').css('height', '400px').css('width', '400px');
$statisticBody.find('.hot-chart').css('height', '400px').css('width', '100%');
initHotEvaluating(data.names.reverse(), data.values.reverse());
} else {
$statisticBody.find('.hot-chart-empty').show();

@ -109199,7 +109199,7 @@ $(document).on('turbolinks:load', function() {
$.get('/colleges/' + schoolId + '/shixun_chart_data', function(data){
$statisticBody.find('.shixun-chart-loading').hide();
if (data.data.length > 0) {
$shixunChart.css('height', '400px').css('width', '400px');
$shixunChart.css('height', '400px').css('width', '100%');
initShixunChart(data.names, data.data);
} else {
$statisticBody.find('.shixun-chart-empty').show();
@ -109311,7 +109311,7 @@ $(document).on('turbolinks:load', function() {
$.get('/colleges/' + schoolId + '/student_hot_evaluations', function(data){
$statisticBody.find('.hot-chart-loading').hide();
if (data.names.length > 0) {
$statisticBody.find('.hot-chart').css('height', '400px').css('width', '400px');
$statisticBody.find('.hot-chart').css('height', '400px').css('width', '100%');
initHotEvaluating(data.names.reverse(), data.values.reverse());
} else {
$statisticBody.find('.hot-chart-empty').show();

@ -128,7 +128,8 @@ class studentsList extends Component{
}
/// 确认是否下载
confirmysl(url){
axios.get(url).then((response) => {
// this.props.showGlobalLoading('正在生成文件,请稍后...')
axios.get(url + 'export=true').then((response) => {
if(response === undefined){
return
}

@ -81,7 +81,7 @@ export function TPMIndexHOC(WrappedComponent) {
isRender: false,
AccountProfiletype: false,
slowDownloading: false
globalLoading: false
}
}
@ -137,7 +137,7 @@ export function TPMIndexHOC(WrappedComponent) {
keyupListener = (e) => {
if (e.key === "Escape") {
this.setState({ slowDownloading: false })
this.setState({ globalLoading: false })
}
}
componentWillUnmount() {
@ -378,20 +378,27 @@ export function TPMIndexHOC(WrappedComponent) {
type===true?window.open(url):window.location.href=url;
}
slowDownload = (url, tip) => {
this._slowDownloadTip = tip || '正在生成文件,请稍后...';
this.setState({ slowDownloading: true })
this._gLoadingTip = tip || '正在生成文件,请稍后...';
this.setState({ globalLoading: true })
const fileUrl = url;
downloadFile({
url: fileUrl,
successCallback: (url) => {
this.setState({ slowDownloading: false })
this.setState({ globalLoading: false })
console.log('successCallback')
},
failCallback: (responseHtml, url) => {
this.setState({ slowDownloading: false })
this.setState({ globalLoading: false })
console.log('failCallback')
}
})
}
showGlobalLoading = (tip) => {
this._gLoadingTip = tip || '加载中,请稍后...';
this.setState({ globalLoading: true })
}
hideGlobalLoading = () => {
this.setState({ globalLoading: false })
}
render() {
let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state;
@ -418,7 +425,10 @@ export function TPMIndexHOC(WrappedComponent) {
DownloadFileA:(title,url)=>this.DownloadFileA(title,url),
DownloadOpenPdf:(type,url)=>this.DownloadOpenPdf(type,url),
slowDownload: this.slowDownload
slowDownload: this.slowDownload,
showGlobalLoading: this.showGlobalLoading,
hideGlobalLoading: this.hideGlobalLoading,
}
return (
<div className="indexHOC">
@ -456,7 +466,7 @@ export function TPMIndexHOC(WrappedComponent) {
}
.globalSpin {
max-height: 700px !important;
}
.indexHOC > .ant-spin-nested-loading {
background: #000;
@ -471,9 +481,9 @@ export function TPMIndexHOC(WrappedComponent) {
}
`
}</style>
<Spin spinning={this.state.slowDownloading} delay={0} className="globalSpin"
<Spin spinning={this.state.globalLoading} delay={0} className="globalSpin"
size="large"
tip= {this._slowDownloadTip || "加载中..."}
tip= {this._gLoadingTip || "加载中..."}
>
<NewHeader {...this.state} {...this.props}></NewHeader>

Loading…
Cancel
Save