You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
6.9 KiB
151 lines
6.9 KiB
window.load = false;
|
|
window.data = {
|
|
'course': '',
|
|
'teacher': '',
|
|
's_date': '',
|
|
'f_date': '',
|
|
'success': false,
|
|
'expired': false,
|
|
'in_work': false
|
|
};
|
|
window.success = false;
|
|
window.load = false;
|
|
function set_global(point, data) {
|
|
window.data[point]=data;
|
|
if (!window.success){
|
|
if (window.data['course'] && window.data['teacher'] && window.data['s_date'] && window.data['f_date']){
|
|
$('[name=report_go_button]').attr('class', 'btn btn-green');
|
|
window.success = true;
|
|
}
|
|
} else {
|
|
if (!(window.data['course'] && window.data['teacher'] && window.data['s_date'] && window.data['f_date'])){
|
|
$('[name=report_go_button]').attr('class', 'btn btn-green disabled');
|
|
window.success = false;
|
|
}
|
|
}
|
|
}
|
|
function get_teachers(block) {
|
|
var home = $(block);
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/management/reports_api/get_course_teachers/',
|
|
async: true,
|
|
data: {'course': home.attr('course_id')},
|
|
beforeSend: function (data) {
|
|
$('[name=course_choice]').css('border', '0');
|
|
home.css('border-bottom', '3px solid #ff1');
|
|
home.css('border-top', '3px solid #ff1');
|
|
},
|
|
success: function(data){
|
|
if (data['code'] == '1'){
|
|
draw_teachers(data['data']);
|
|
} else {
|
|
console.log(data['response'])
|
|
}
|
|
set_global('course', home.attr('course_id'));
|
|
set_global('teacher', '')
|
|
$('[name=teach_ava_block]').fadeOut('fast');
|
|
}
|
|
});
|
|
}
|
|
|
|
function draw_teachers(data) {
|
|
var home = $('[name="teacher_list"]');
|
|
home.html('');
|
|
for (var i in data){
|
|
home.append('<li class="list-group-item" onclick="get_students(this)" teacher_id="'+data[i]['id']+'" name="teacher_choice" style="clear: both;">' +
|
|
'<img src="'+data[i]['ava']+'" class="img-circle" style="float:left;position:relative;top: -5px;max-width: 30px; max-height: 30px;margin-right: 15px;" reloader_name="avatar"><span>'+data[i]['short_name']+'</span>' +
|
|
'<a href="'+location.protocol + '//'+ location.host+ '/' + data[i]['interactive_key']+'" target="_blank" style="float: right;color: #666;background: #ccc;padding: 0 5px;border-radius: 3px;"><i class="'+data[i]['status']['point']+'" style="color: '+data[i]['status']['color']+';"></i> <i class="glyphicon glyphicon-user"></i></a></li>')
|
|
}
|
|
$('[name=teacher_list_loader]').hide('fast');
|
|
$('[name=teacher_list]').show('slow');
|
|
}
|
|
function get_students(block) {
|
|
var home = $(block);
|
|
$('[name=teacher_choice]').css('border', '0');
|
|
home.css('border', '5px solid #ff1');
|
|
set_global('teacher', home.attr('teacher_id'))
|
|
}
|
|
|
|
function load_process_report() {
|
|
$('[name=error_block]').html('').fadeOut('slow');
|
|
if (window.load){
|
|
$('[name=error_block]').html('Данные по пред идущему запросу еще загружаются').fadeIn('slow');
|
|
} else {
|
|
if (window.success){
|
|
console.log('Хоп');
|
|
get_data();
|
|
$('[name=global_preloader]').fadeIn('slow');
|
|
} else {
|
|
$('[name=error_block]').html('Заполните все необходимые поля').fadeIn('slow');
|
|
}
|
|
}
|
|
}
|
|
|
|
function get_data() {
|
|
$('[name=result_table]').html('').fadeOut('fast');
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/management/reports_api/get_process_report/',
|
|
async: true,
|
|
data: window.data,
|
|
beforeSend: function (data) {
|
|
$('[name="result_students"]').html(' - ');
|
|
$('[name="result_get_hw"]').html(' - ');
|
|
$('[name="result_in_work_hw"]').html(' - ');
|
|
$('[name="result_expired_hw"]').html(' - ');
|
|
$('[name="result_success_hw"]').html(' - ');
|
|
window.load = true;
|
|
},
|
|
success: function(data){
|
|
if (data['code'] == '1'){
|
|
draw_data(data['data']);
|
|
} else {
|
|
console.log(data['response'])
|
|
}
|
|
window.load = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
function draw_data(data) {
|
|
|
|
$('[name=global_preloader]').fadeOut('slow');
|
|
$('[name="result_students"]').html(data['info']['students']);
|
|
$('[name="result_get_hw"]').html(data['info']['get_hw']);
|
|
$('[name="result_in_work_hw"]').html(data['info']['in_work_hw']);
|
|
$('[name="result_expired_hw"]').html(data['info']['expired_hw']);
|
|
$('[name="result_success_hw"]').html(data['info']['success_hw']);
|
|
var n = 0;
|
|
for (var i in data['more']){
|
|
var exp = '';
|
|
if (data['more'][i]['expired']) {
|
|
exp = '<i class="glyphicon glyphicon-ok-sign" style="color: red;"></i>/'+data['more'][i]['expired_time'] + ' часа(-ов)'
|
|
} else {
|
|
exp = '<i class="glyphicon glyphicon-remove-sign" style="color: #ccc;"></i>'
|
|
}
|
|
$('[name=result_table]').append('<tr style="border-bottom: 1px dotted #ccc;">' +
|
|
'<td><a href="'+location.protocol + '//'+ location.host+ '/' + 'admin/journals/homeworkj/'+data['more'][i]['id']+'" target="_blank">'+data['more'][i]['id']+' <i class="glyphicon glyphicon-link"></i></a></td>' +
|
|
'<td><a href="'+location.protocol + '//'+ location.host+ '/admin/courses/homework/'+data['more'][i]['material_id']+'" target="_blank">'+data['more'][i]['material']+' <i class="glyphicon glyphicon-link"></i></a></td>' +
|
|
'<td><a href="'+location.protocol + '//'+ location.host+ '/' + data['more'][i]['student_token']+' " target="_blank">'+data['more'][i]['student']+' <i class="glyphicon glyphicon-link"></i></a></td>' +
|
|
'<td align="left">'+data['more'][i]['s_date']+'</td>' +
|
|
'<td align="left">'+data['more'][i]['f_date']+'</td>' +
|
|
'<td align="left">'+data['more'][i]['status']+'</td>' +
|
|
'<td align="center">'+data['more'][i]['tries']+'</td>' +
|
|
'<td align="right">'+ exp +'</td>' +
|
|
'<td align="right"><a href="'+data['more'][i]['link']+'" target="_blank">Перейти <i class="glyphicon glyphicon-link"></i> </a></td>' +
|
|
'</tr>');
|
|
n += 1;
|
|
}
|
|
$('[name=table_row_count]').html(n);
|
|
$('[name=result_table]').fadeIn('fast');
|
|
}
|
|
$( document.body ).on( "change", "[name=f_date]", function( event ) {
|
|
set_global('f_date', $('[name=f_date]').val().split('.').join('_'));
|
|
console.log('1')
|
|
});
|
|
|
|
$( document.body ).on( "change", "[name=s_date]", function( event ) {
|
|
set_global('s_date', $('[name=s_date]').val().split('.').join('_'));
|
|
console.log('2')
|
|
}); |