EIOS/rabprog/prakt_comp.php

71 lines
2.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Вспомогательный файл для связывания дисциплин с компетенциями
*/
exit();
include_once 'config.php';
$sql = 'SELECT id,file FROM acs_fshp_files WHERE id<91';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
foreach($rez['rez'] as $key => $val){
$id_file = $val['id'];
$pi = pathinfo($val['file']);
//$pi['filename']//1_3295_200501_PB_OFO_2022plx
//echo '<pre>'.print_r($pi,1).'</pre>';
$file = 'upload/shaht_xlsx/'.$pi['filename'].'_comp.json';
echo $file.'<hr>';
if (file_exists($file)){
$array = json_decode(file_get_contents($file),1);
//echo '<pre>'.print_r($array,1).'</pre>';
foreach($array as $kod => $v)if(isset($v['discips'])&&count($v['discips'])){
$index = $v['index'];
$id_co = get_comp($index,$id_file);
if($id_co) {
foreach ($v['discips'] as $k1 => $disc) {
$id_up = get_up($disc['shifr'], $disc['discip'], $id_file);
$id_upco = get_upcomp($id_up,$id_co);
if(!$id_upco && $id_up) {
echo '$id_file=' . $id_file . '; $index=' . $index . '; shifr=' . $disc['shifr'] . '; discip=' . $disc['discip'] . '; ';
echo '$id_co=' . $id_co . '; $id_up=' . $id_up . '; <br>';
$sql = 'INSERT INTO acs_fshp_uchebplans_compet VALUES(0,'.$id_up.','.$id_co.')';
$rez = $DB->QUR($sql);
}
}
}
}
}
//exit();
}
}
function get_upcomp($id_up,$id_compet){
GLOBAL $DB;
$id=0;
$sql = 'SELECT id FROM acs_fshp_uchebplans_compet WHERE id_uchebplans="'.$id_up.'" AND id_compet='.$id_compet;
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id = $rez['rez'][0]['id'];
}
return $id;
}
function get_up($index,$name,$id_file){
GLOBAL $DB;
$id=0;
$sql = 'SELECT id FROM acs_fshp_uchebplans WHERE index1="'.$index.'" AND name="'.$name.'" AND id_file='.$id_file.'';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id = $rez['rez'][0]['id'];
}
return $id;
}
function get_comp($index,$id_file){
GLOBAL $DB;
$id=0;
$sql = 'SELECT id FROM acs_fshp_compet WHERE `index`="'.$index.'" AND id_file='.$id_file; //echo $sql.'<br>';
$rez = $DB->QUR_SEL($sql);
if(!$rez['err']&&$rez['kol']){
$id = $rez['rez'][0]['id'];
}
return $id;
}