dev_aliyun_beta
杨树明 5 years ago
commit 0a08539f42

@ -1,14 +1,22 @@
$(document).on('turbolinks:load', function() {
var $modal = $('.modal.admin-message-modal');
var $submitBtn = $modal.find('.submit-btn');
if ($modal.length > 0) {
$modal.on('hide.bs.modal', function(){
$modal.find('.modal-body').html('');
$submitBtn.unbind();
});
}
});
function showMessageModal(html) {
function showMessageModal(html, callback) {
var $modal = $('.modal.admin-message-modal');
var $submitBtn = $modal.find('.submit-btn');
$submitBtn.unbind();
if(callback !== undefined && typeof callback === 'function'){
$submitBtn.on('click', callback);
}
$modal.find('.modal-body').html(html);
$modal.modal('show');
}

@ -0,0 +1,78 @@
$(document).on('turbolinks:load', function() {
var $modal = $('.modal.admin-import-course-member-modal');
if ($modal.length > 0) {
var $form = $modal.find('form.admin-import-course-member-form');
var resetFileInputFunc = function(file){
file.after(file.clone().val(""));
file.remove();
}
$modal.on('show.bs.modal', function(){
$modal.find('.file-names').html('选择文件');
$modal.find('.upload-file-input').trigger('click');
});
$modal.on('hide.bs.modal', function(){
resetFileInputFunc($modal.find('.upload-file-input'));
});
$modal.on('change', '.upload-file-input', function(e){
var file = $(this)[0].files[0];
$modal.find('.file-names').html(file ? file.name : '请选择文件');
})
var importFormValid = function(){
if($form.find('input[name="file"]').val() == undefined || $form.find('input[name="file"]').val().length == 0){
$form.find('.error').html('请选择文件');
return false;
}
return true;
};
var buildResultMessage = function(data){
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败"+ data.fail.length + "条</div>";
if(data.fail.length > 0){
messageHtml += '<table class="table"><thead class="thead-light"><tr><th>数据</th><th>失败原因</th></tr></thead><tbody>';
data.fail.forEach(function(item){
messageHtml += '<tr><td>' + item.data + '</td><td>' + item.message + '</td></tr>';
});
messageHtml += '</tbody></table>'
}
return messageHtml;
}
$modal.on('click', '.submit-btn', function(){
$form.find('.error').html('');
if (importFormValid()) {
$('body').mLoading({ text: '正在导入...' });
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/import_course_members',
data: new FormData($form[0]),
processData: false,
contentType: false,
success: function(data){
$('body').mLoading('destroy');
$modal.modal('hide');
showMessageModal(buildResultMessage(data), function(){
window.location.reload();
});
},
error: function(res){
$('body').mLoading('destroy');
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
}
});
}
});

@ -122,14 +122,18 @@ $(document).on('turbolinks:load', function(){
// 导入学生
var $importUserModal = $('.modal.admin-import-user-modal');
var $importUserForm = $importUserModal.find('form.admin-import-user-form')
var resetFileInputFunc = function(file){
file.after(file.clone().val(""));
file.remove();
}
$importUserModal.on('show.bs.modal', function(){
resetFileInputFunc($importUserModal.find('.upload-file-input'));
$importUserModal.find('.file-names').html('选择文件');
$importUserModal.find('.upload-file-input').trigger('click');
});
$importUserModal.find('.upload-file-input').on('change', function(e){
$importUserModal.on('change', '.upload-file-input', function(e){
var file = $(this)[0].files[0];
$importUserModal.find('.file-names').html(file ? file.name : '请选择文件');
})
@ -175,7 +179,9 @@ $(document).on('turbolinks:load', function(){
$('body').mLoading('destroy');
$importUserModal.modal('hide');
showMessageModal(buildResultMessage(data));
showMessageModal(buildResultMessage(data), function(){
window.location.reload();
});
},
error: function(res){
$('body').mLoading('destroy');

@ -212,7 +212,7 @@ class CoursesController < ApplicationController
@course.update_attributes!(course_params.merge(extra_params))
@course.update_course_modules(params[:course_module_types])
Rails.logger.info("###############course_update_end")
normal_status(0, "成功")
rescue => e
uid_logger_error(e.message)
@ -1484,8 +1484,10 @@ class CoursesController < ApplicationController
shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"]
# 更新实训作业成绩
shixun_homeworks.includes(:homework_challenge_settings, :published_settings, :homework_commons_shixun).each do |homework|
homework.update_homework_work_score
unless course.is_end
shixun_homeworks.includes(:homework_challenge_settings, :published_settings, :homework_commons_shixun).each do |homework|
homework.update_homework_work_score
end
end
shixun_homeworks = shixun_homeworks&.includes(score_student_works: :user)

@ -916,7 +916,8 @@ class GamesController < ApplicationController
# 更新关卡状态和一些学习进度
def update_game_parameter game
game.update_attribute(:status, 0) if game.status == 1
game.update_attributes(status: 0, open_time: Time.now) if game.status == 3
# 第一次进入关卡更新时间
game.update_attributes(status: 0, open_time: Time.now) if game.open_time.blank? || game.status == 3
# 开启实训更新myshixuns的时间方便跟踪用于的学习进度。
game.myshixun.update_column(:updated_at, Time.now)
end

@ -601,7 +601,7 @@ class ShixunsController < ApplicationController
challenges.each_with_index do |challenge, index|
status = (index == 0 ? 0 : 3)
game_identifier = generate_identifier(Game, 12)
worker.add(base_attr.merge(challenge_id: challenge.id, status: status, open_time: Time.now,
worker.add(base_attr.merge(challenge_id: challenge.id, status: status,
identifier: game_identifier, modify_time: challenge.modify_time))
end
end

@ -0,0 +1,30 @@
<div class="modal fade admin-import-course-member-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">导入课堂成员</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form class="admin-import-course-member-form" enctype="multipart/form-data">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">文件</span>
</div>
<div class="custom-file">
<input type="file" name="file" id="import-course-member-input" class="upload-file-input" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<label class="custom-file-label file-names" for="import-course-member-input">选择文件</label>
</div>
</div>
<div class="error text-danger"></div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary submit-btn">确认</button>
</div>
</div>
</div>
</div>

@ -11,7 +11,7 @@
保存成功
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">确认</button>
<button type="button" class="btn btn-primary submit-btn" data-dismiss="modal">确认</button>
</div>
</div>
</div>

@ -28,6 +28,7 @@
<% end %>
<%= javascript_void_link '导入用户', class: 'btn btn-secondary btn-sm', data: { toggle: 'modal', target: '.admin-import-user-modal'} %>
<%= javascript_void_link '导入课堂成员', class: 'btn btn-secondary btn-sm ml-2', data: { toggle: 'modal', target: '.admin-import-course-member-modal'} %>
</div>
<div class="box users-list-container">
@ -35,4 +36,7 @@
</div>
<%= render partial: 'admins/users/shared/reward_grade_modal' %>
<%= render partial: 'admins/users/shared/import_user_modal' %>
<%= render partial: 'admins/users/shared/import_user_modal' %>
<!-- TODO: move to course list page -->
<%= render partial: 'admins/courses/shared/import_course_member_modal' %>

@ -14,8 +14,8 @@
<span class="input-group-text">文件</span>
</div>
<div class="custom-file">
<input type="file" name="file" class="upload-file-input" id="upload-file-input" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<label class="custom-file-label file-names" for="upload-file-input">选择文件</label>
<input type="file" name="file" class="upload-file-input" id="import-user-input" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<label class="custom-file-label file-names" for="import-user-input">选择文件</label>
</div>
</div>
<div class="error text-danger"></div>

@ -20,6 +20,7 @@ if @course
json.group_info @course.teacher_group(@user.id) if @course_identity < Course::STUDENT
end
json.first_category_url module_url(@course.none_hidden_course_modules.first, @course)
json.course_is_end @course.is_end
end
if params[:school]

Binary file not shown.

@ -646,7 +646,7 @@ render(){
{/*<span className="color-grey-9 ml3 mr3">&gt;</span>*/}
{/*</WordsBtn>*/}
<span>{`${current_user ? current_user.username : ''} ${ this.isEdit ? '编辑' : '提交'}作品` }</span>
<span>{`${current_user ? current_user.real_name : ''} ${ this.isEdit ? '编辑' : '提交'}作品` }</span>
</p>
<div style={{ width:'100%',height:'75px'}} >

@ -2499,8 +2499,8 @@ class Listofworksstudentone extends Component {
// console.log(data);
// console.log(datas);
// console.log(this.props.isAdmin());
console.log("学生老师列表");
let course_is_end = this.props.current_user&&this.props.current_user.course_is_end;
return (
this.props.isAdmin() === true ?
(
@ -2641,7 +2641,7 @@ class Listofworksstudentone extends Component {
<ul className="clearfix" style={{padding: '20px 15px 10px 20px'}}>
<li className="clearfix ">
<span className="fl mr10 color-grey-6 ">计算成绩时间{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')}</span>
<span>
{course_is_end===true?<span>
{teacherdata&&teacherdata.publish_immediately===false&&computeTimetype===true?
(this.props.isNotMember()===false?<div className={"computeTime font-13"} onClick={this.setComputeTimet}>
计算成绩
@ -2651,7 +2651,7 @@ class Listofworksstudentone extends Component {
计算成绩
</div>:"")
}
</span>
</span>:""}
<div className="fr mr5 search-newysl" style={{marginBottom: '1px'}}>
<Search
@ -2946,7 +2946,7 @@ class Listofworksstudentone extends Component {
<div className="fr">
<span className="fl mr10 color-grey-6 ">计算成绩时间{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')}</span>
{teacherdata&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{ course_is_end===true?"":teacherdata&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{computeTimetype===true?
(this.props.isNotMember()===false?
<div className={"computeTime font-13"} onClick={this.setComputeTime}>
@ -3156,7 +3156,7 @@ class Listofworksstudentone extends Component {
<div className="fr">
<span className="fl mr10 color-grey-6 ">计算成绩时间{teacherdata&&teacherdata.calculation_time==null?"--": moment(teacherdata&&teacherdata.calculation_time).format('YYYY-MM-DD HH:mm')}</span>
{teacherdata&&teacherdata.task_operation&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{ course_is_end===true?"":teacherdata&&teacherdata.task_operation&&teacherdata.task_operation[0]==="开启挑战"?"":<span>
{computeTimetype===true?
(this.props.isNotMember()===false?<div className={"computeTime font-13"} onClick={this.setComputeTime}>
计算成绩

@ -561,7 +561,8 @@ export default class TPMevaluation extends Component {
if(type==="sr"){
newevaluationlist[key].input=e.target.value
}else if(type==="yq"){
newevaluationlist[key].output=e.target.value
// 统一转成\r\n
newevaluationlist[key].output= e.target.value ? e.target.value.replace(/\r?\n/g, "\r\n") : e.target.value
}
this.setevaluationlist(newevaluationlist);
}

Loading…
Cancel
Save