EIOS/rabprog/workDiscip.php

75 lines
3.5 KiB
PHP
Raw Normal View History

2023-12-28 15:39:22 +03:00
<?php
exit();//НЕ ДОДЕЛАНО, отображает дисциплины у которых разный json
//Берем каждый план из него каждую дисциплину и проверяем наличие kontr_rab
include_once 'config.php';
include_once 'inc/class_ShahtPlans.php';
$SHAHT = new class_ShahtPlans();
$sql = 'SELECT fs.id, fs.file FROM acs_fshp_file as f, acs_fshp_files as fs WHERE f.god_nach_podgot=2023 GROUP BY fs.id ORDER BY fs.id DESC';
$rez = $DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>';
if(!$rez['err']&&$rez['kol']) {
foreach ($rez['rez'] as $key => $val) {
$id_file = $val['id'];
echo $val['id'].':'.$val['file'].'<hr>';
//Проверим есть ли файл обработки для плана
$file_tmp = 'tmp/shahtplans/planizfile_'.$val['id'].'.json';
if(file_exists($file_tmp)){
$arr = json_decode(file_get_contents($file_tmp),1);
//echo '<pre>'.print_r($arr,1).'</pre>';
//[Б1.О.01] => Array(
// [ezfo_ze] => 4 [schitatVplane] => + [index] => Б1.О.01 [name] => История России
// [ekzamen] => 2 [zachet] => 1 [zachetsocenk] => 0 [kp] => 0 [kr] => 0
// [kafcod] => 51 [kafname] => Управления и таможенного дела
// [json] => {\"1\":{\"1\":{\"ze\":\"2\",\"lekcii\":\"20\",\"pr\":10,\"srp\":\"0.25\",\"sr\":\"41.75\"},\"2\":{\"ze\":\"2\",\"lekcii\":\"18\",\"pr\":10,\"sr\":\"17\",\"krat\":\"0.35\",\"kontrol\":\"26.65\"}}}
// [kontrol] => 0
// [json1] => Array (
// [1] => Array (
// [1] => Array ( [ze] => 2 [lekcii] => 20 [pr] => 10 [srp] => 0.25 [sr] => 41.75 )
// [2] => Array ( [ze] => 2 [lekcii] => 18 [pr] => 10 [sr] => 17 [krat] => 0.35 [kontrol] => 26.65)
// )
// )
//)
foreach ($arr as $index => $data) {
$data['id_file'] = $id_file;
$check1 = check_discip($data);
if($check1['err']==1){
echo $data['index'].' '.$data['name'].$check1['msg'].'<br>';
}else{
//echo $check1['msg'];
}
}
}else{
echo 'нет файла '.$file_tmp.' - обработаем и надо второй раз обновить!<br>';
$plans = $SHAHT->parse_file_bezDB($id_file,'');
//echo '<pre>'.print_r($plans,1).'</pre>';
//exit();
}
}
}
/**
* Проверка JSON дисциплины
* @param $param
* @return array|mixed
*/
function check_discip($param){
GLOBAL $DB; $out=array();
$sql = 'SELECT id,json FROM acs_fshp_uchebplans WHERE id_file='.$param['id_file'].' AND index1="'.$param['index'].'" AND name="'.$param['name'].'"';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']) {
$discip = $rez['rez'][0];
if($discip['json']!=json_encode($param['json1'],JSON_UNESCAPED_UNICODE)){
$out['err'] = 1;
$out['msg'] = '<table><tr>';
$out['msg'] .= '<td valign="top"><pre>'.print_r(json_decode($discip['json'],1),1).'</pre></td>';
$out['msg'] .= '<td valign="top"><pre>'.print_r($param['json1'],1).'</pre></td>';
$out['msg'] .= '</tr></table>';
//$out['json'] = json_decode($discip['json'],1);
}else{
$out['err'] = 0;
$out['msg'] = $discip['json'].'<br>'.$param['json'].'<br>';
}
}
return $out;
}