EIOS/inc/learn.php

1610 lines
71 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
session_start();
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/class_SYSTEM.php';
$SYSTEMclass = new SYSTEMclass();
if(isset($_GET['page'])){
if($_GET['page']=='tests'){//тесты студента
$msg=array();
if(isset($_POST['save_test'])){
$id_test = (int)$_POST['id_test'];
$ball=0;
//$msg['msg'][]='$_POST:<pre>'.print_r($_POST,1).'</pre>';
if(isset($_POST['quest'])){
foreach($_POST['quest'] as $id_quest => $id_answer){
$text_q='';
$sql = 'SELECT tip,ocenka,text_q FROM '.$ST['dbpf'].'_test_questions WHERE id='.$id_quest.' AND id_tests='.$id_test.' LIMIT 1';
$rez = $DB->QUR_SEL($sql);
if($rez){
$text_q = addslashes($rez[1]['text_q']);
$questocenka = $rez[1]['ocenka'];
if($questocenka==0) $questocenka = 1;
if($rez[1]['tip']==0){//один ответ
$text_a=''; $sball=0;
$sql1 = 'SELECT ocenka,text_a FROM '.$ST['dbpf'].'_test_answers WHERE id_questions='.$id_quest.' AND id='.$id_answer.' LIMIT 1';
$rez1 = $DB->QUR_SEL($sql1);
//$msg['msg'][]='один ответ0:<pre>'.$sql1.print_r($rez1,1).'</pre>';
if($rez1){
if($rez1[1]['ocenka']==0){
$ball++; //$sball=1;
$sball=$questocenka; //27042020-добавил
}
$text_a = $rez1[1]['text_a'];
}
$sql3 = 'INSERT INTO '.$ST['dbpf'].'_test_users_otvet VALUES(0,'.time().','.$id_test.','.$id_quest.','.$id_answer.',"'.$text_q.'","'.addslashes($text_a).'","",'.$sball.','.$_SESSION['user']['id'].')';
$rez3 = $DB->QUR($sql3);
//$msg['msg'][]='один ответ:<pre>'.print_r($rez3,1).'</pre>';
}
if($rez[1]['tip']==1){//множественный ответ
$text_a=''; $sball=0;
//выберем кол-во правильных ответов
$kol_prav=0;
$sql2 = 'SELECT COUNT(id) as kol FROM '.$ST['dbpf'].'_test_answers WHERE id_questions='.$id_quest.' AND ocenka=0';
$rez2 = $DB->QUR_SEL($sql2);
//$msg['msg'][]='множественный ответ0:<pre>'.$sql2.print_r($rez2,1).'</pre>';
//кол-во правильных ответов
if($rez2){ $kol_prav=$rez2[1]['kol']; }
if($kol_prav){//узнаем ответы пользователя
foreach($id_answer as $k => $id_answerm){
$sball=0;
$sql1 = 'SELECT ocenka,text_a FROM '.$ST['dbpf'].'_test_answers WHERE id_questions='.$id_quest.' AND id='.$id_answerm.' LIMIT 1';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
if($rez1[1]['ocenka']==0){//правильный
$ball+=(1/$kol_prav);
//$sball=(1/$kol_prav);
$sball=($questocenka/$kol_prav); //27042020 добавил
}
else{
$ball+=($rez1[1]['ocenka']/$kol_prav);
//$sball=($rez1[1]['ocenka']/$kol_prav);
$sball=-($questocenka/$kol_prav); //27042020 добавил
}
$text_a = $rez1[1]['text_a'];
}
$sql3 = 'INSERT INTO '.$ST['dbpf'].'_test_users_otvet VALUES(0,'.time().','.$id_test.','.$id_quest.','.$id_answerm.',"'.$text_q.'","'.addslashes($text_a).'","",'.$sball.','.$_SESSION['user']['id'].')';
$rez3 = $DB->QUR($sql3);
//$msg['msg'][]='множественный ответ:<pre>'.print_r($rez3,1).'</pre>';
}
}
}
if($rez[1]['tip']==2){//ответ вводится вручную
$text_a=''; $sball=0; $sida = 0;
$sql2 = 'SELECT id,text_a FROM '.$ST['dbpf'].'_test_answers WHERE id_questions='.$id_quest.' AND ocenka=1';
$rez2 = $DB->QUR_SEL($sql2);
if($rez2){
if($rez2[1]['text_a']==$id_answer) { $ball++; $sbal=1; }
$text_a = $rez1[1]['text_a'];
$sida = $rez1[1]['id'];
}
$sql3 = 'INSERT INTO '.$ST['dbpf'].'_test_users_otvet VALUES(0,'.time().','.$id_test.','.$id_quest.','.$sida.',"'.$text_q.'","'.addslashes($text_a).'","'.$id_answer.'",'.$sball.','.$_SESSION['user']['id'].')';
$rez3 = $DB->QUR($sql3);
}
if($rez[1]['tip']==3){//ответ от 1 до оценки
$text_a=''; $sball=0; $sida = 0;
$ball+=$id_answer;
$sball=$id_answer;
$sql3 = 'INSERT INTO '.$ST['dbpf'].'_test_users_otvet VALUES(0,'.time().','.$id_test.','.$id_quest.','.$sida.',"'.$text_q.'","'.$id_answer.'","'.$id_answer.'",'.$sball.','.$_SESSION['user']['id'].')';
$rez3 = $DB->QUR($sql3);
}
}
}
}
$msg['msg'][]='Тест пройден! Результаты вы можете уточнить у преподавателя.';
unset($_GET['des']);
}
$regim = 'tests'; $tests=array();
//$maincontent = '<h2>В ближайшее время появится...</h2>';
//if($_SESSION['user']['id']==2535){
if(!isset($_GET['des'])){//выберем разделы
$sql = 'SELECT * FROM '.$ST['dbpf'].'_test_razdel ORDER BY pos';
$rez = $DB->QUR_SEL($sql);
if($rez){
foreach($rez as $key => $val)if($key){
//нужно сделать отображение только по группам
//$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_test_tests WHERE id_razdel='.$val['id'].' AND status=1 ORDER BY id';
$sql1 = 'SELECT tt.* FROM '.$ST['dbpf'].'_test_tests as tt,'.$ST['dbpf'].'_test_grupps as tg WHERE tt.id_razdel='.$val['id'].' AND tt.status=1 AND tg.id_tests=tt.id AND tg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY tt.id';
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
$tests[$val['id']]['razdel']=$val;
foreach($rez1 as $key1 => $val1)if($key1){
$sql2 = 'SELECT COUNT(id) as kol FROM '.$ST['dbpf'].'_test_questions WHERE id_tests='.$val1['id'].'';
$rez2 = $DB->QUR_SEL($sql2);
if($rez2){
$sql3 = 'SELECT data_c FROM '.$ST['dbpf'].'_test_users_otvet WHERE id_tests='.$val1['id'].' AND id_user='.$_SESSION['user']['id'].'';
$rez3 = $DB->QUR_SEL($sql3);
if($rez3){
$val1['otvet']=1;
$val1['otvet_data']=date('H:i d.m.Y',$rez3[1]['data_c']);
}else{
$val1['otvet']=0;
}
//надо разделить пробный тест и контрольный
if($val1['tests']==1){//пробный есть
$val1['probnyj']=1;
$val1['kontroln']=0;
if($val1['data_testa']!=0){
if($val1['data_testa']<=time()){
$val1['probnyj']=0;
$val1['kontroln']=1;
}
}else{
$val1['kontroln']=-1;
}
}else{//нет пробного
$val1['probnyj']=0;
$val1['kontroln']=0;
if($val1['data_testa']<=time()){
$val1['kontroln']=1;
}
}
//echo '<prE>'.print_r($val,1).''.print_r($val1,1).'</pre>';
$tests[$val['id']]['tests'][]=$val1;
}
}
}
}
}
$smarty->assign('tests',$tests);//'<pre>'.print_r($tests,1).'</pre>'.
}
if(isset($_GET['des'])){//Отобразим тест
$id_test = (int)$_GET['des'];
$test=array();
$regim = 'test';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_test_tests WHERE id='.$id_test.' LIMIT 1';
$rez = $DB->QUR_SEL($sql);
if($rez){
$test = $rez[1];
$testsq = '';
if($test['tests']==1){//тестовый
if($val1['data_testa']!=0){
if($test['data_testa']<=time()){//контрольный
$testsq = '';
}else $testsq = ' AND tests=1';
}else $testsq = ' AND tests=1';
}else{//контрольный
$testsq = '';
}
if($test['random_q']==1){//случайные вопросы
$orderby = ' ORDER BY rand()';
}else{//не случайные вопросы
$orderby = ' ORDER BY pos';
}
$sql1 = 'SELECT * FROM '.$ST['dbpf'].'_test_questions WHERE id_tests='.$id_test.$testsq.' '.$orderby;
$rez1 = $DB->QUR_SEL($sql1);
if($rez1){
$questions=array();
foreach($rez1 as $key1 => $val1)if($key1){
$question=$val1;
if($question['random_a']==1){//случайные ответы
$orderby = ' ORDER BY rand()';
}else{//не случайные ответы
$orderby = ' ORDER BY pos';
}
$sql2 = 'SELECT * FROM '.$ST['dbpf'].'_test_answers WHERE id_questions='.$val1['id'].''.$orderby;
$rez2 = $DB->QUR_SEL($sql2);
if($rez2){
$question['answers']=array();
foreach($rez2 as $key2 => $val2)if($key2){
$question['answers'][]=$val2;
}
}
$questions[]=$question;
}
$test['questions'] = $questions;
}
}
$smarty->assign('test',$test);
}
$smarty->assign('regim',$regim);
$smarty->assign('msg',$msg);
//'<pre>'.print_r($test,1).'</pre>'.'<pre>'.print_r($_POST,1).'</pre>'.
$maincontent = $smarty->fetch('tpl_learn_tests.html');
//}
}
if($_GET['page']=='ocenki'){//оценки
$regim = 'ocenki_view';
if(!isset($_SESSION['user']['student'])) { header('Location: /login/'); exit(); }
$id_student = $_SESSION['user']['student']['id'];
$id_user = $_SESSION['user']['id'];
$ocenki=array();
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_ocenki WHERE id_student='.$id_student.' ORDER BY FIELD(what, "lection","practich","controln"),id_what,type';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_ocenki WHERE id_student='.$id_student.' ORDER BY FIELD(what, "lection","practich","controln"),id_prepod,id_what';
$rez = $DB->QUR_SEL($sql);
//echo '<pre>'.print_r($rez,1).'</pre>';
if($rez){
foreach($rez as $key => $val)if($key){
$save=false;
if($val['what']=='lection'){
if(isset($oc['id'])&&$oc['id']==$val['id_what']){
$oc['oc'][$val['type']] = $val['ocenka'];
$save=true;
}else{
$rez1 = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$val['id_what'].'');
if($rez1){
$oc = $rez1[1];
$oc['type'] = $val['what'];
$oc['oc'][$val['type']] = $val['ocenka'];
}
}
}
if($val['what']=='practich'){
if(isset($oc['id'])&&$oc['id']==$val['id_what']){
$oc['oc'][$val['type']] = $val['ocenka'];
$save=true;
}else{
$rez1 = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_practich WHERE id='.$val['id_what'].'');
if($rez1){
$oc = $rez1[1];
$oc['type'] = $val['what'];
$oc['descrip'] = $rez1[1]['descrip']; //описание материала
$oc['oc'][$val['type']] = $val['ocenka'];
}
}
}
if($val['what']=='controln'){
if(isset($oc['id'])&&$oc['id']==$val['id_what']){
$oc['oc'][$val['type']] = $val['ocenka'];
$save=true;
}else{
$rez1 = $DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_controln WHERE id='.$val['id_what'].'');
if($rez1){
$oc = $rez1[1];
$oc['type'] = $val['what'];
$oc['descrip'] = $rez1[1]['descrip']; //описание материала
$oc['oc'][$val['type']] = $val['ocenka'];
}
}
}
//$oc['save']=$save;
//если нули, то не выводим
if ($oc['oc'][1] == '0') $oc['oc'][1] = '';
if ($oc['oc'][2] == '0') $oc['oc'][2] = '';
if($save) $ocenki[]=$oc;
}
}
//ликвидация задолженностей
$liquidation = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_liquidation WHERE id_student = "'.$id_student.'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
$i = 0;
foreach ($rez as $key => $val) if ($key){
$val['teacher'] = get_user($val['id_teacher']);
switch ($val['control']){
case 1: $val['control'] = 'Экзамен'; break;
case 2: $val['control'] = 'Зачет'; break;
case 3: $val['control'] = 'Курсовая работа'; break;
case 4: $val['control'] = 'Курсовой проект'; break;
case 5: $val['control'] = 'Отчет по практике'; break;
case 6: $val['control'] = 'Зачет с оценкой'; break;
}
switch ($val['type']){
case 1: $val['type'] = 'Досрочная'; break;
case 2: $val['type'] = 'Первичная'; break;
case 3: $val['type'] = 'Повторная'; break;
case 4: $val['type'] = 'С комиссией'; break;
}
switch ($val['iup']){
case 0: $val['iup'] = 'УП'; break;
case 1: $val['iup'] = 'ИУП'; break;
}
$val['date_create'] = date('d.m.Y', $val['date_create']);
$val['date_end'] = date('d.m.Y', $val['date_end']);
$val['date_mark'] = date('d.m.Y', $val['date_mark']);
$i++;
$val['pp'] = $i;
$liquidation[] = $val;
}
}
//echo '<prE>'.print_r($ocenki,1).'</pre>';
$smarty->assign('ocenki',$ocenki);
$smarty->assign('regim',$regim);
$smarty->assign('liquidation',$liquidation);
$maincontent = $smarty->fetch('tpl_learn_ocenki.html');
}
if($_GET['page']=='portfolio'){ //АКТУАЛЬНОЕ ПОРТФОЛИО
$ST['page']['name'] = 'Портфолио студента';
//сохранение портфолио
if (isset($_POST['save_portfolio'])){
/*echo '<br />';
echo '<br />';
echo '<br />';
echo '<br />';
echo '<br />';
echo '<pre>';
print_r($_POST);
echo '</pre>';*/
$about = nl2br(htmlspecialchars($_POST['about']));
$languages = nl2br(htmlspecialchars($_POST['languages']));
$pc = nl2br(htmlspecialchars($_POST['pc']));
$army_is = nl2br(htmlspecialchars($_POST['army_is']));
$family_status = nl2br(htmlspecialchars($_POST['family_status']));
$kind_is = nl2br(htmlspecialchars($_POST['kind_is']));
$com_is = nl2br(htmlspecialchars($_POST['com_is']));
$pereezd_is = nl2br(htmlspecialchars($_POST['pereezd_is']));
$car_category = $_POST['car_category'];
$user = (int) nl2br(htmlspecialchars($_POST['user']));
//отображение данных ПОКАЗАТЬ/СКРЫТЬ
$show_mark = $_POST['show_mark'];
//водительские категории перечисляем через пробел
$category = ' ';
//print_r($car_category);
foreach ($car_category as $key => $val){
//echo $val;
$category .= $val.' ';
}
//INSERT INTO `acs_portfolio` (`id`, `id_user`, `about`, `languages`, `pc`, `army_is`, `family_status`, `kind_is`, `comandirovka_is`, `pereezd_is`, `car_category`, `status`, `date_create`, `date_update`) VALUES (NULL, '0', '123', '123', '123', 'Не служил', 'Холост', 'Нет', 'Не готов', 'Не готов', 'Права отсутствуют', '0', '1', '1');
//удаляем старое портфолио
$sql = 'DELETE FROM '.$ST['dbpf'].'_portfolio WHERE id_user = "'.$user.'" ';
$rez = $DB->QUR($sql);
//вносим новую информацию
$sql = 'INSERT INTO '.$ST['dbpf'].'_portfolio (`id_user`, `about`, `languages`, `pc`, `army_is`, `family_status`, `kind_is`, `comandirovka_is`, `pereezd_is`, `car_category`, `status`, `date_update`, `show_mark_is`) VALUES ("'.$user.'", "'.$about.'", "'.$languages.'", "'.$pc.'", "'.$army_is.'", "'.$family_status.'", "'.$kind_is.'", "'.$com_is.'", "'.$pereezd_is.'", "'.$category.'", "0", "'.date("U").'", "'.$show_mark.'")';
$rez = $DB->QUR($sql);
//echo $about;
}
//берем информацию о портфолио
$id_user = $_SESSION['user']['id'];
$sql = 'SELECT * FROM '.$ST['dbpf'].'_portfolio WHERE id_user = "'.$id_user.'" LIMIT 1';
$rez = $DB->QUR_SEL($sql);
$info_portfolio = $rez[1];
/**/
$smarty->assign('user',$_SESSION['user']);
$smarty->assign('info_portfolio',$info_portfolio);
$maincontent = $smarty->fetch('tpl_learn_portfolio.html');
}
if($_GET['page']=='raspis'){
$ST['page']['name'] = 'Расписание студентов';
//echo '<pre>'.print_r($_SESSION['user'],1).'</pre>';
$sql='SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id='.$_SESSION['user']['student']['id_grupp'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$grname=$rez[1]['sokr'].'-'.$rez[1]['kurs'];
$grnume=$_SESSION['user']['student']['num_grupp'];
//echo 'http://83.234.195.34/raspisnew/export.php?grupp='.$grname.$grnume.'';
$url = 'http://local.mkgtu.ru/raspisnew/export.php?grupp='.urlencode($grname).$grnume.'';
//echo $url;exit();
$raspis=file_get_contents($url);
echo '<!--pre>'.print_r(json_decode($raspis,1),1).'</pre-->';//exit();
//$raspis=file_get_contents('http://83.234.195.34/raspisnew/export.php?grupp=ПИ-11');
if ($raspis!=''){
$raspis=json_decode($raspis);
//echo '<br><prE>'.print_r($raspis,1).'</pre>';
if(isset($raspis->error)) $smarty->assign('message','ответ от сервера: '.$raspis->error[0]);
}
else{
$smarty->assign('message','Не получили данные');
}
//echo $grname.$grnume.'<pre>'; print_r($raspis); echo '</pre>'; //exit();
$smarty->assign('raspis',$raspis);
$grname .= $_SESSION['user']['student']['num_grupp'];
$smarty->assign('grname',$grname);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_raspis.html');
}else{
$smarty->assign('message','Не определили группу');
$smarty->assign('profile',$_SESSION['user']);
$grname .= $_SESSION['user']['student']['num_grupp'];
$smarty->assign('grname',$grname);
$maincontent = $smarty->fetch('tpl_raspis.html');
}
}
if($_GET['page']=='kursov'){
$ST['page']['name'] = 'Курсовые студента';
$lections=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_kursov as c WHERE lg.id_lections=c.id_lection AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY c.data_c DESC,c.data_u DESC, c.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$lections[$i]=$val;
/*$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$val['id_lection'].'');
if($rez1){
$j=0;foreach($rez1 as $key1 => $val1)if($key1){
$val1['data_c']=date('H:i d.m.Y',$val1['data_c']);
$val1['data_u']=date('H:i d.m.Y',$val1['data_u']);
if($_SESSION['user']['student']['status']==0) $val1['file']='-1';
$lections[$i]['le'][$j]=$val1;
$j++;
}
}*/
$i++;
}
}
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_kursov.html');
}
//МОДУЛЬ ДИСЦИПЛИНЫ ПО ВЫБОРУ
if ($_GET['page'] == 'elective'){
$id_user = $_SESSION['user']['id'];
//определяем группу и прочую информацию
$student = get_student($id_user);
$gruppa = get_grupp($student['id_grupp']);
//только студенту
$student_only = get_student_only($id_user);
$message = ''; //блок сообщений
//ВЫБИРАЕМ ДИСЦИПЛИНЫ
if (isset($_POST['changed'])){
$date_create = date("U");
foreach ($_POST['predmet'] as $key => $val){
$sql = 'INSERT INTO '.$ST['dbpf'].'_elective (id_user, id_student, date_create, id_predmet) VALUES ("'.$id_user.'", "'.$student_only['id'].'", "'.$date_create.'", "'.$val.'") ';
$rez = $DB->QUR($sql);
//echo $val.'<br />';
}
//$sql = 'INSERT INTO '.$ST['dbpf'].'_elective (id_user, id_student, date_create, id_predmet) VALUES ("'.$id_user.'", "'.$student['id'].'", "'.$date_create.'", "") ';
/*echo '<pre>';
print_r($_POST);
echo '</pre>';*/
$message = 'Выбор успешно сделан.';
}
//форма обучения
if ($gruppa['fo'] == 'ОФО') $fo = 'очная';
elseif ($gruppa['fo'] == 'ЗФО') $fo = 'заочная';
else $fo = 'очно-заочная';
//смотрим сколько профилей
//если профилей, больше, чем один, то смотрим выбрал ли студент какой-то из них
$profile_obu = '';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_napr_sel WHERE id_stud = "'.$id_user.'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez[0] > 1) {
$id_profile = $rez[1]['id_napr'];
$sql_pr = 'SELECT * FROM '.$ST['dbpf'].'_profile WHERE id_areas = "'.$id_profile.'" ';
$rez_pr = $DB->QUR_SEL($sql_pr);
if ($rez_pr){
$profile_obu = $rez_pr[1]['name'];
}
}
//определяем учебный план
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_plans WHERE forobu = "'.$fo.'" AND shifr1 = "'.$gruppa['specialnost'].'" AND godnap = "'.$gruppa['year_start'].'" LIMIT 1';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_plans WHERE forobu = "'.$fo.'" AND shifr1 = "'.$gruppa['specialnost'].'" AND godnap = "'.$gruppa['year_start'].'" AND propodgo LIKE "%'.$profile_obu.'%"';
$rez = $DB->QUR_SEL($sql);
if ($rez){
$id_plan = $rez[1]['id'];
$plan = $rez;
}else{
$message .= 'Необходимо указать форму обучения, специальность, год начала обучения и профиль обучения';
}
//если профилей несколько и студент ничего не выбрал
$error_change_profile = 0;
if ($rez[0] > 1) if ($profile_obu == '') $error_change_profile = 1;
//определяем курс группы - берем из названия первую цифру
$kurs = courseOfGruppa($student['id_grupp']);
//if($id_plan=='') $message .= 'Необходимо указать форму обучения, специальность, год начала обучения и профиль обучения';
//дисциплины учебного плана - берем блоки/модули
$predmets = array();
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE id_plans = "'.$id_plan.'" AND discid LIKE "%ДВ%" GROUP BY discid';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE kurs = "'.$kurs.'" AND id_plans = "'.$id_plan.'" AND discip LIKE "%по выбору%" GROUP BY discid';
$rez = $DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>'; exit();
//SELECT * FROM acs_iup_shahtplans_stroki WHERE kurs = "" AND id_plans = "" AND discip LIKE "%по выбору%" GROUP BY discid
if ($rez){
foreach ($rez as $key => $val) if ($key){
//теперь определяем какие дисциплины входят в тот или иной учебный блок (модуль)
//блок - это группа предметов, из которых студент выбирает только один определенный, на свое усмотрение
$val['block'] = array();
$sql_in = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE kurs = "'.$kurs.'" AND id_plans = "'.$id_plan.'" AND discid LIKE "%'.$val['discid'].'.%" '; //точка в конце обязательна - перед процентами, это означает, это значит что "спускаемся" в подраздел модуля
$rez_in = $DB->QUR_SEL($sql_in);
if ($rez_in){
foreach ($rez_in as $key_in => $val_in) if ($key_in){
//смотрим, выбирал ли пользователь этот вариант ответа уже
$val_in['sel'] = 0; //по умолчанию = 0 - не выбирал. Если 1 - значит выбирал
$sql_count = 'SELECT * FROM '.$ST['dbpf'].'_elective WHERE id_user = "'.$id_user.'" AND id_predmet = "'.$val_in['id'].'" ';
$rez_count = $DB->QUR_SEL($sql_count);
if ($rez_count) if ($rez_count[0] > 0) $val_in['sel'] = 1;
//смотрим, дисциплина одобрена ли деканатом
$val_in['is_click'] = 0; //по умолчанию = нет
$sql_click = 'SELECT * FROM '.$ST['dbpf'].'_fakultet_elective WHERE id_stroka = "'.$val_in['id'].'" ';
$rez_click = $DB->QUR_SEL($sql_click);
if ($rez_click) if ($rez_click > 0) $val_in['is_click'] = 1; //одобрена деканатом
//
$val['block'][] = $val_in;
}
}
/***
Получается примерно такая структура
1 Дисциплина
1.1 Вариант
1.2 Еще вариант
2 Дисциплина другая
2.1 Вариант
2.2 Другой вариант
...
**/
$predmets[] = $val;
}
}else{
$message .= '<br>Не нашли в учебном плане дисциплину';
}
//echo $sql;
$smarty->assign('message', $message); //контейнер сообщений
$smarty->assign('predmets', $predmets); //информация о дисциплинах учебного плана
$smarty->assign('student', $student); //информация о студенте
$smarty->assign('gruppa', $gruppa); //информация о группе
$smarty->assign('kurs', $kurs); //информация о курсе
$smarty->assign('plan', $plan); //Информация о плане
$smarty->assign('error_change_profile', $error_change_profile); //Ошибка - не выбрана специализация
$maincontent = $smarty->fetch('tpl_learn_elective.html');
}
//СТУДЕНЧЕСКИЕ РАБОТЫ
if($_GET['page']=='studwork'){
$ST['page']['name'] = 'Студ. работы';
//загрузка работы
if (isset($_POST['add_studwork'])){
/*print_r($_POST);
print_r($_FILES);*/
$id_user = (int)$_POST['id_user'];
$type = $_POST['type'];
$name = addslashes($_POST['name']);
$disc = (int)$_POST['disc'];
//берем название дисциплины и семестр, чтобы не утерять информацию при манипуляции с планом
$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE id = "'.$disc.'"';
$rez = $DB->QUR_SEL($sql);
if ($rez) {
$predmet = $rez[1]['discip'];
$sem = $rez[1]['sem'];
}
$file = '';
$rez = $DB->QUR('INSERT INTO '.$ST['dbpf'].'_studwork (`id_user`, `id_plan`, `discip`, `semestr`, `type`, `name`, `file_work`, `otziw_work`, `status`) VALUES ("'.$id_user.'", "'.$disc.'", "'.$predmet.'", "'.$sem.'", "'.$type.'", "'.$name.'", "'.$file.'", "'.$file.'", "на проверке") ');
$id = mysql_insert_id();
//загрузка файла - ОСНОВНАЯ РАБОТА
$uploadfile='';
if(isset($_FILES['file_work'])){
$dir_dest = 'upload/studwork/'.$id.'/';
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = date("U").$_FILES['file_work']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$uploadfile = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['sfile']['tmp_name'], $uploadfile)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file_work']['tmp_name'], $uploadfile)) {
$uploadfile='';
}
}
//загрузка файла - ОТЗЫВ
$uploadfile2='';
if(isset($_FILES['file_otz'])){
$dir_dest = 'upload/studwork/'.$id.'/';
if(!file_exists($dir_dest)) mkdir($dir_dest);
$fil = date("U").$_FILES['file_otz']['name'];
$t = explode('.',$fil); $ext = $t[count($t)-1];
unset($t[count($t)-1]); $fn = implode('.',$t);
$uploadfile2 = $dir_dest . basename(translit($fn).'.'.$ext);
//if (!move_uploaded_file($_FILES['sfile']['tmp_name'], $uploadfile)) {
if (!$SYSTEMclass->sysUPLOAD($_FILES['file_otz']['tmp_name'], $uploadfile2)) {
$uploadfile2='';
}
}
//а теперь указываем файл в базе
$sql = 'UPDATE '.$ST['dbpf'].'_studwork SET file_work = "'.$uploadfile.'", otziw_work = "'.$uploadfile2.'" WHERE id = "'.$id.'" ';
$rez = $DB->QUR($sql);
$msg = 1;
save_logs('Загружена студенческая работа в систему №'.$id);
header("Location: /learn/studwork/".$id."/");
exit;
}
$student_info = get_student($_SESSION['user']['id']);
//подгружаем дисциплины
/*echo '<pre>';
print_r($student_info);
echo '</pre>';*/
//подгружаем форму обучения
switch ($student_info['fo']){
case 'ОФО': $fo = 'очная'; break;
case 'ЗФО': $fo = 'заочная'; break;
case 'ОЗФО': $fo = 'очно-заочная'; break;
}
$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_plans WHERE shifr1 = "'.$student_info['kod_podgotovki'].'" AND godnap = "'.$student_info['year_start'].'" AND forobu = "'.$fo.'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez) $id_plan = $rez[1]['id'];
//echo $id_plan;
//дисциплины
$predmets = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE id_plans = "'.$id_plan.'" AND (discid LIKE "Б2.%" OR discid LIKE "Б3.%" OR krab = 1) ORDER BY sem';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$predmets[] = $val;
}
}
//список уже загруженных работ
$works = array();
$sql = 'SELECT * FROM '.$ST['dbpf'].'_studwork WHERE id_user = "'.$_SESSION['user']['id'].'" ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$works[] = $val;
}
}
/***/
$smarty->assign('works', $works);
$smarty->assign('predmets', $predmets);
$smarty->assign('user', $_SESSION['user']);
$maincontent = $smarty->fetch('tpl_learn_studwork.html');
}
//ОБРАЗОВАТЕЛЬНЫЙ ПРОЦЕСС - ВСЕ ЗАДАНИЯ И ЛЕКЦИИ
if($_GET['page']=='all'){
$ST['page']['name'] = 'Образовательный процесс';
$maincontent = $smarty->fetch('tpl_learn_all.html');
}
//ВЫБОР ПРОФИЛЯ ОБУЧЕНИЯ СТУДЕНТОМ
if ($_GET['page'] == 'profile_change'){
$ST['page']['name'] = 'Выбор профиля обучения';
$id_user = $_SESSION['user']['id']; //пользователь - студент
//студент выбрал профиль обучения
if (isset($_POST['order_profile'])){
$id_napr = $_POST['profile']; //профиль
$date_order = date("U"); //дата подачи заявки
$sql = 'INSERT INTO '.$ST['dbpf'].'_napr_sel (id_stud, id_napr, date_order) VALUES ("'.$id_user.'", "'.$id_napr.'", "'.$date_order.'") ';
$rez = $DB->QUR($sql);
}
//проверяем, заполнил ли он ее до этого
$is_order = 0;
$sql = 'SELECT * FROM '.$ST['dbpf'].'_napr_sel WHERE id_stud = "'.$id_user.'" ';
$rez = $DB->QUR_SEL($sql);
$is_order = $rez[0];
//информация о студенте
$info_student = $_SESSION['user']['student'];
//делаем выборку по направлению профилей специальности
$spec = array();
$sql = 'SELECT ar.*, pr.id as id_profile, pr.* FROM '.$ST['dbpf'].'_areas as ar, '.$ST['dbpf'].'_profile as pr WHERE ar.code LIKE "'.$info_student['kod_podgotovki'][0].$info_student['kod_podgotovki'][1].$info_student['kod_podgotovki'][2].$info_student['kod_podgotovki'][3].$info_student['kod_podgotovki'][4].'%" AND ar.id = pr.id_areas ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$spec[] = $val;
}
}
//echo $info_student['kod_podgotovki'][0].$info_student['kod_podgotovki'][1];
/******/
$smarty->assign('info_student',$info_student);
$smarty->assign('spec',$spec);
$smarty->assign('is_order',$is_order);
$maincontent = $smarty->fetch('tpl_learn_profile_change.html');
}
//РАСПИСАНИЕ ЗАНЯТИЙ В РЕЖИМЕ ВЕБИНАРА
if ($_GET['page'] == 'timetable_web'){
//выводим само расписание
$timetable = '';
$grupp = get_student($_SESSION['user']['id']); //группа студента
$grupp_p = $grupp['sokr'].'-'.$grupp['kurs'];
$date_start = strtotime(date("Y-m-d"));
$sql = 'SELECT * FROM '.$ST['dbpf'].'_timetable_web WHERE day >= "'.$date_start.'" GROUP BY day ';
$rez = $DB->QUR_SEL($sql);
if ($rez){
foreach ($rez as $key => $val) if ($key){
$date = date('d.m.Y', $val['day']);
$timetable .= '<br /><p align="center"><span style="font-family: Times New Roman, serif; font-size: 14pt;">Занятия на <u>'.$date.'</u></span><br></p>';
$sql_couple = 'SELECT timetable.*, us.* FROM '.$ST['dbpf'].'_timetable_web as timetable, '.$ST['dbpf'].'_users as us WHERE timetable.day = "'.$val["day"].'" AND us.id = timetable.id_prepod ORDER BY timetable.couple';
$rez_couple = $DB->QUR_SEL($sql_couple);
$timetable .= '<table border="1" cellspacing="0" cellpadding="0" style="max-width: 95%;" align="center">
<tbody><tr align="center">
<td width="10%" valign="top" style="border:solid windowtext 1.0pt;
mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;background:#EAF1DD;mso-background-themecolor:accent3;
mso-background-themetint:51;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><b><span style="font-size:14.0pt;
font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Время</span></b></p>
</td>
<td width="15%" valign="top" style="border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;background:#EAF1DD;mso-background-themecolor:accent3;
mso-background-themetint:51;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><b><span style="font-size:14.0pt;
font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Группа</span></b></p>
</td>
<td width="30%" valign="top" style="border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;background:#EAF1DD;mso-background-themecolor:accent3;
mso-background-themetint:51;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><b><span style="font-size:14.0pt;
font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Преподаватель</span></b></p>
</td>
<td width="40%" valign="top" style="border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;background:#EAF1DD;mso-background-themecolor:accent3;
mso-background-themetint:51;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><b><span style="font-size:14.0pt;
font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Дисциплина</span></b></p>
</td>
<td width="5%" valign="top" style="border:solid windowtext 1.0pt;
border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:
solid windowtext .5pt;background:#EAF1DD;mso-background-themecolor:accent3;
mso-background-themetint:51;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><b><span style="font-size:14.0pt;
font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">Ссылка</span></b></p>
</td>
</tr>';
foreach ($rez_couple as $kk => $v) if ($kk){
$couple = '';
switch ($v['couple']){
case 1: $couple = '8.00 - 9.30'; break;
case 2: $couple = '9.40 - 11.10'; break;
case 3: $couple = '11.30 - 13.00'; break;
case 4: $couple = '13.10 - 14.40'; break;
case 5: $couple = '15.00 - 16.30'; break;
case 6: $couple = '16.40 - 18.10'; break;
case 7: $couple = '18.20 - 19.50'; break;
case 8: $couple = '20.00 - 21.30'; break;
}
$timetable .= '<tr>
<td valign="top" style="border-top:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><span style="font-size:14.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">'.$couple.'</span></p>
</td>
<td valign="top" style="border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><span style="font-size:14.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">'.$v['groups'].'</span></p>
</td>
<td valign="top" style="border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><span style="font-size:14.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">'.$v['fio'].'</span></p>
</td>
<td valign="top" style="border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><span style="font-size:14.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">'.$v['subject'].'</span></p>
</td>
<td valign="top" style="border-top:none;border-left:
none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;
mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;
mso-border-alt:solid windowtext .5pt;padding:0cm 5.4pt 0cm 5.4pt">
<p style="margin-bottom:0cm;margin-bottom:.0001pt;line-height:
normal"><span style="font-size:14.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;">';
if ($v['link'] != '') if (stripos($v['groups'], $grupp_p) !== false) $timetable .= '<a href="'.$v['link'].'">Перейти</a>';
else $timetable .= '<span class="badge badge-warning">Нет доступа</span>';
else $timetable .= '<span class="badge badge-important">Пока нет</span>';
$timetable .= '</span></p>
</td>
</tr>';
}
$timetable .= '</tbody></table>';
}
}
$smarty->assign('timetable', $timetable);
$maincontent = $smarty->fetch('tpl_learn_timetable_web.html');
}
//элективные дисциплины по физической культуре и спорту
if ($_GET['page'] == 'fk'){
$ST['page']['name'] = 'Элективные дисциплины по физической культуре и спорту';
$page = $_GET["des"];
$errors=array();
//достаем факультет по коду направления подготовки
$kod_podgotovki = $_SESSION['user']['student']['kod_podgotovki'];
$sql_areas = 'SELECT * FROM '.$ST['dbpf'].'_areas WHERE code = "'.$kod_podgotovki.'"';
$rez_areas = $DB->QUR_SEL($sql_areas);
$kafedra = $rez_areas[1]['id_kafedra'];
$sql_kafedres = 'SELECT * FROM '.$ST['dbpf'].'_kafedres WHERE `id` = "'.$kafedra.'"';
$rez_kafedres = $DB->QUR_SEL($sql_kafedres);
$facult = $rez_kafedres[1]['id_facult'];
//достаем элективные дисциплины, доступные для данного курса и факультета
$fk = array();
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_fk_section as sect, '.$ST['dbpf'].'_fk_timetable as timetable WHERE timetable.fakultets LIKE "%'.$facult.'%" AND sect.id = timetable.id_section';
$course = courseOfGruppa($_SESSION['user']['student']['grupp']['id']);
//echo '<pre>'; print_r($_SESSION['user']['student']); echo '</pre>';
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable WHERE fakultets LIKE "%'.$facult.'%" AND `course` = "'.$course['kurs'].'" GROUP BY `id_section`';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable WHERE (
fakultets LIKE "%,'.$facult.',%" OR
fakultets LIKE "%,'.$facult.'" OR
fakultets LIKE "'.$facult.',%" OR
fakultets = "'.$facult.'"
) AND `course` = "'.$course['kurs'].'" GROUP BY `id_section`';
//echo $sql;
$rez = $DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>'; exit();
//SELECT * FROM acs_fk_timetable WHERE (fakultets LIKE "%,5,%" OR fakultets LIKE "%,5" OR fakultets LIKE "5,%") AND `course` = "1" GROUP BY `id_section`
//Array(
// [0] => 9
// [1] => Array( [id] => 1[id_section] => 1[id_teacher] => 142[course] => 1[count] => 27[disability] => 0[fakultets] => 5,8,11,13,14 )
// [2] => Array( [id] => 85 [id_section] => 2 [id_teacher] => 299 [course] => 1 [count] => 26 [disability] => 0 [fakultets] => 5,8,11,13,14 )
// [3] => Array( [id] => 67 [id_section] => 3 [id_teacher] => 304 [course] => 1 [count] => 26 [disability] => 0 [fakultets] => 5,8,11,13,14 )
// [4] => Array( [id] => 143 [id_section] => 4 [id_teacher] => 302 [course] => 1 [count] => 26 [disability] => 0 [fakultets] => 5,8,11,13,14 )
// [5] => Array( [id] => 46 [id_section] => 5 [id_teacher] => 297 [course] => 1 [count] => 27 [disability] => 0 [fakultets] => 5,8,11,13,14 )
// [6] => Array( [id] => 103 [id_section] => 6 [id_teacher] => 306 [course] => 1 [count] => 26 [disability] => 0 [fakultets] => 5,8,11,13,14 )
// [7] => Array( [id] => 28 [id_section] => 8 [id_teacher] => 1107 [course] => 1 [count] => 27 [disability] => 0 [fakultets] => 5,8,11,13,14 )
// [8] => Array( [id] => 145 [id_section] => 10 [id_teacher] => 303 [course] => 1 [count] => 26 [disability] => 0 [fakultets] => 5,8,11,13,14 )
// [9] => Array( [id] => 144 [id_section] => 11 [id_teacher] => 300 [course] => 1 [count] => 26 [disability] => 0 [fakultets] => 5,8,11,13,14 )
//)
if ($rez){
foreach ($rez as $key => $val) if ($key){
$sql_section = 'SELECT * FROM '.$ST['dbpf'].'_fk_section WHERE `id` = "'.$val['id_section'].'"';
$rez_section = $DB->QUR_SEL($sql_section);
$val['name'] = $rez_section[1]['name'];
$val['sokr'] = $rez_section[1]['sokr'];
$val['id'] = $rez_section[1]['id'];
$fk[] = $val;
}
}else{
$errors[]='Не выбрали дисциплины для "'.$facult.'" и курс "'.$course['kurs'].'"';
}
//если выбрана элективная дисциплина
if ($page != ''){
$zapis = array(); //возможные записи
//$sql = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable WHERE fakultets LIKE "%'.$facult.'%" AND course = "'.$course['kurs'].'" AND id_section = "'.$page.'" GROUP BY id_teacher, id_section, course';
$sql = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable WHERE (
fakultets LIKE "%,'.$facult.',%" OR
fakultets LIKE "%,'.$facult.'" OR
fakultets LIKE "'.$facult.',%" OR
fakultets = "'.$facult.'"
) AND course = "'.$course['kurs'].'" AND id_section = "'.$page.'" GROUP BY id_teacher, id_section, course';
$rez = $DB->QUR_SEL($sql);
//echo $sql.'<pre>'.print_r($rez,1).'</pre>'; exit();
//SELECT * FROM acs_fk_timetable WHERE (fakultets LIKE "%,5,%" OR fakultets LIKE "%,5" OR fakultets LIKE "5,%") AND course = "1" AND id_section = "4" GROUP BY id_teacher, id_section, course
//Array( [0] => 1
// [1] => Array( [id] => 143 [id_section] => 4 [id_teacher] => 302 [course] => 1 [count] => 26 [disability] => 0 [fakultets] => 5,8,11,13,14 )
//)
if ($rez){
foreach ($rez as $key => $val) if ($key){
$id_teach = $val['id_teacher'];
$sql_teacher = 'SELECT * FROM '.$ST['dbpf'].'_teachers as teach, '.$ST['dbpf'].'_users as user WHERE teach.id = "'.$id_teach.'" AND teach.id_user = user.id';
$rez_teacher = $DB->QUR_SEL($sql_teacher);
$val['fio'] = $rez_teacher[1]['fio'];
//теперь выводим расписание с этим преподавателем, т.е. в какие дни и в какие пары проводятся занятия
//$sql_timetable = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable as timetable, '.$ST['dbpf'].'_fk_details as details WHERE timetable.fakultets LIKE "%'.$facult.'%" AND timetable.course = "'.$page.'" AND timetable.id = details.id_timetable';
$sql_timetable = 'SELECT * FROM '.$ST['dbpf'].'_fk_timetable as timetable, '.$ST['dbpf'].'_fk_details as details WHERE (
timetable.fakultets LIKE "%,'.$facult.',%" OR
timetable.fakultets LIKE "%,'.$facult.'" OR
timetable.fakultets LIKE "'.$facult.',%" OR
timetable.fakultets = "'.$facult.'"
) AND timetable.course = "'.$course['kurs'].'" AND timetable.id_section = "'.$page.'" AND details.id_timetable = timetable.id AND timetable.id_teacher = "'.$val['id_teacher'].'" ';
$rez_timetable = $DB->QUR_SEL($sql_timetable);
$val['raspis'] = '<ul>';
foreach ($rez_timetable as $key_t => $val_t) if ($key_t){
//заменяем день недели на нормальный
switch ($val_t['day']){
case 1:
$val_t['day'] = 'Понедельник';
break;
case 2:
$val_t['day'] = 'Вторник';
break;
case 3:
$val_t['day'] = 'Среда';
break;
case 4:
$val_t['day'] = 'Четверг';
break;
case 5:
$val_t['day'] = 'Пятница';
break;
case 6:
$val_t['day'] = 'Суббота';
break;
}
//уточняем, в какое время начинается та или иная пара
switch ($val_t['couple']){
case 1:
$val_t['couple'] .= ' пара (8.00 - 9.30)';
break;
case 2:
$val_t['couple'] .= ' пара (9.40 - 11.10)';
break;
case 3:
$val_t['couple'] .= ' пара (11.30 - 13.00)';
break;
case 4:
$val_t['couple'] .= ' пара (13.10 - 14.40)';
break;
case 5:
$val_t['couple'] .= ' пара (15.00 - 16.30)';
break;
case 6:
$val_t['couple'] .= ' пара (16.40 - 18.10)';
break;
case 7:
$val_t['couple'] .= ' пара (18.20 - 19.50)';
break;
}
//print
$val['raspis'] .= '<li><b>'.$val_t['day'].'</b> - '.$val_t['couple'].' </li>';
}
$val['raspis'] .= '</ul>';
/************/
//возможное количество мест для записи
$sql_order = 'SELECT * FROM '.$ST['dbpf'].'_fk_order WHERE id_timetable = "'.$val["id"].'"';
$rez_order = $DB->QUR_SEL($sql_order);
$val['count'] -= $rez_order[0];
//********************************
$zapis[] = $val;
}
}
//выбранная элективная дисциплина
$sql_sect = 'SELECT * FROM '.$ST['dbpf'].'_fk_section WHERE `id` = "'.$page.'"';
$rez_sect = $DB->QUR_SEL($sql_sect);
$section = $rez_sect[1]['name'];
$smarty->assign('section', $section);
$smarty->assign('zapis', $zapis);
}
//проверяем, записан ли студент
$id_user = $_SESSION['user']['id'];
$sql_fk_order = 'SELECT * FROM '.$ST['dbpf'].'_fk_order WHERE `id_student` = "'.$id_user.'"';
$rez_fk_order = $DB->QUR_SEL($sql_fk_order);
$smarty->assign('order_is', $rez_fk_order[0]);
$smarty->assign('order_is_a', $rez_fk_order);
//если студент записан, то выводим название элективной дисциплины, а также ФИО преподавателя
$info_elective = array();
$id_timetable = $rez_fk_order[1]['id_timetable'];
$sql_timetable = 'SELECT tt.*, st.* FROM '.$ST['dbpf'].'_fk_timetable as tt, '.$ST['dbpf'].'_fk_section as st WHERE tt.id = "'.$id_timetable.'" AND tt.id_section = st.id';
$rez_timetable = $DB->QUR_SEL($sql_timetable);
$info_elective['name'] = $rez_timetable[1]['name'];
$sql_details = 'SELECT * FROM '.$ST['dbpf'].'_fk_details WHERE id_timetable = "'.$id_timetable.'"';
$rez_details = $DB->QUR_SEL($sql_details);
//echo $sql_details.'<pre>'.print_r($rez_details,1).'</pre>'; exit();
$info_elective['raspis'] = '';
foreach ($rez_details as $key => $val) if ($key){
switch ($val['day']){
case 1:
$day = 'Понедельник';
break;
case 2:
$day = 'Вторник';
break;
case 3:
$day = 'Среда';
break;
case 4:
$day = 'Четверг';
break;
case 5:
$day = 'Пятница';
break;
case 6:
$day = 'Суббота';
break;
case 7:
$day = 'Воскресенье';
break;
}
$info_elective['raspis'] .= $day.', '.$val['couple'].' пара <br />';
}
$id_teacher = $rez_timetable[1]['id_teacher'];
$sql_teacher = 'SELECT teach.*, us.* FROM '.$ST['dbpf'].'_teachers as teach, '.$ST['dbpf'].'_users as us WHERE us.id = teach.id_user AND teach.id = "'.$id_teacher.'"';
$rez_teacher = $DB->QUR_SEL($sql_teacher);
$info_elective['fio'] = $rez_teacher[1]['fio'];
//***************************************************************************************///
$smarty->assign('kod_podgotovki', $_SESSION['user']['student']['kod_podgotovki']);
$smarty->assign('page', $page);
$smarty->assign('fk', $fk);
$smarty->assign('elective', $info_elective);
$smarty->assign('course', $course);
$smarty->assign('profile', $_SESSION['user']);
$smarty->assign('errors', $errors);
//echo '<pre>'; print_r($fk); echo '</pre>';
$maincontent = $smarty->fetch('tpl_learn_fk.html');
}
//опрос о качестве образовательного процесса
if($_GET['page']=='polls'){
$ST['page']['name'] = 'Опрос о качестве образовательного процесса';
$lections=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_lections as l WHERE lg.id_lections=l.id AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' GROUP BY l.name ORDER BY l.kurs,l.semestr,l.data_c DESC,l.data_u DESC, l.name ';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$val['mfile']=explode('|',$val['file']);
$sql_prepod = 'SELECT * FROM '.$ST['dbpf'].'_teachers WHERE `id` = "'.$val['id_teacher'].'"';
$rez_prepod = $DB->QUR_SEL($sql_prepod);
$id_user = $rez_prepod[1]['id_user'];
$sql_user = 'SELECT * FROM '.$ST['dbpf'].'_users WHERE `id` = "'.$id_user.'"';
$rez_user = $DB->QUR_SEL($sql_user);
$val['fio_pr'] = $rez_user[1]['fio'];
//$val['fio_pr'] = $rez_prepod[1]["id"];
$i++;
$lections[$i]=$val;
}
}
//массив вопросов
$criterias = array(
'1' => 'Предмет имеет практическую пользу (помощь дисциплины в устройстве на работу, актуальность и новизна информации, полученной в ходе изучения предмета)',
'2' => 'Дисциплина способствует развитию мышления (логически рассуждать, думать, принимать решения)',
'3' => 'Дисциплина способствует развитию общекультурного кругозора (культурное и духовное обогащение)',
'4' => 'Имеет место сочетание теоретического материала с практическим (используются примеры по профилю подготовки)',
'5' => 'Преподаватель хорошо объясняет предмет',
'6' => 'Преподаватель сделал предмет интересным',
'7' => 'Преподаватель с энтузиазмом ведёт занятия',
'8' => 'Занятие хорошо структурировано',
'9' => 'Преподаватель вовлекает студентов в участие на занятии',
'10' => 'Критерии, используемые в оценке экзамена / зачёта, были заранее объяснены'
);
$crit=array();
$i=0;
foreach($criterias as $key1 => $val1){
$crit[$i]['id']=$key1;
$crit[$i]['name']=strip_tags($val1);
//if ($id==$key) $crit[$i]['sel']=1; else $crit[$i]['sel']=0;
$i++;
}
$smarty->assign('crit',$crit);
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_learn_polls.html');
}
//практика
if($_GET['page']=='praktika'){
$ST['page']['name'] = 'Практика студента';
$lections=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_praktika as c WHERE lg.id_lections=c.id_lection AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY c.data_c DESC,c.data_u DESC, c.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$lections[$i]=$val;
/*$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$val['id_lection'].'');
if($rez1){
$j=0;foreach($rez1 as $key1 => $val1)if($key1){
$val1['data_c']=date('H:i d.m.Y',$val1['data_c']);
$val1['data_u']=date('H:i d.m.Y',$val1['data_u']);
if($_SESSION['user']['student']['status']==0) $val1['file']='-1';
$lections[$i]['le'][$j]=$val1;
$j++;
}
}*/
$i++;
}
}
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_praktika.html');
}
if($_GET['page']=='practic'){
$ST['page']['name'] = 'Практические работы студента';
$lections=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_practich as c WHERE lg.id_lections=c.id_lection AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY c.data_c DESC,c.data_u DESC, c.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$lections[$i]=$val;
/*$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$val['id_lection'].'');
if($rez1){
$j=0;foreach($rez1 as $key1 => $val1)if($key1){
$val1['data_c']=date('H:i d.m.Y',$val1['data_c']);
$val1['data_u']=date('H:i d.m.Y',$val1['data_u']);
if($_SESSION['user']['student']['status']==0) $val1['file']='-1';
$lections[$i]['le'][$j]=$val1;
$j++;
}
}*/
$i++;
}
}
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_practic.html');
}
if($_GET['page']=='kontrrab'){
$ST['page']['name'] = 'Контрольные работы студента';
$lections=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_controln as c WHERE lg.id_lections=c.id_lection AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY c.data_c DESC,c.data_u DESC, c.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$lections[$i]=$val;
/*
$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$val['id_lection'].'');
if($rez1){
$j=0;foreach($rez1 as $key1 => $val1)if($key1){
$val1['data_c']=date('H:i d.m.Y',$val1['data_c']);
$val1['data_u']=date('H:i d.m.Y',$val1['data_u']);
if($_SESSION['user']['student']['status']==0) $val1['file']='-1';
$lections[$i]['le'][$j]=$val1;
$j++;
}
}
*/
$i++;
}
}
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_kontrrab.html');
}
if($_GET['page']=='sr'){ //задания для самостоятельной работы студента
$ST['page']['name'] = 'Задания для самостоятельной работы студента';
$lections=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_sr as c WHERE lg.id_lections=c.id_lection AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY c.data_c DESC,c.data_u DESC, c.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$lections[$i]=$val;
/*
$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_lections WHERE id='.$val['id_lection'].'');
if($rez1){
$j=0;foreach($rez1 as $key1 => $val1)if($key1){
$val1['data_c']=date('H:i d.m.Y',$val1['data_c']);
$val1['data_u']=date('H:i d.m.Y',$val1['data_u']);
if($_SESSION['user']['student']['status']==0) $val1['file']='-1';
$lections[$i]['le'][$j]=$val1;
$j++;
}
}
*/
$i++;
}
}
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_sr.html');
}
if($_GET['page']=='lection'){
$ST['page']['name'] = 'Лекционные работы студента';
$lections=array();
//$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_lections as l WHERE lg.id_lections=l.id AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY l.kurs,l.semestr,l.data_c DESC,l.data_u DESC, l.name';
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_lections as l WHERE lg.id_lections=l.id AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY l.kurs,l.semestr,l.data_c DESC,l.data_u DESC, l.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
//берем инфу о преподе
$teacher_info = get_teacher_user($val['id_teacher']);
$val['id_user'] = $teacher_info['id'];
$val['fio_prepod'] = $teacher_info['fio'];
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$val['mfile']=explode('|',$val['file']);
$lections[$i]=$val;
/*
$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_practich WHERE id_lection='.$val['id'].'');
if($rez1){
$j=0;
foreach($rez1 as $key1 => $val1)if($key1){
$val1['data_c']=date('H:i d.m.Y',$val1['data_c']);
$val1['data_u']=date('H:i d.m.Y',$val1['data_u']);
if($_SESSION['user']['student']['status']==0) $val1['file']='-1';
$lections[$i]['pr'][$j]=$val1;
$j++;
}
}
$rez1=$DB->QUR_SEL('SELECT * FROM '.$ST['dbpf'].'_controln WHERE id_lection='.$val['id'].'');
if($rez1){
$j=0;
foreach($rez1 as $key1 => $val1)if($key1){
$val1['data_c']=date('H:i d.m.Y',$val1['data_c']);
$val1['data_u']=date('H:i d.m.Y',$val1['data_u']);
if($_SESSION['user']['student']['status']==0) $val1['file']='-1';
$lections[$i]['cr'][$j]=$val1;
$j++;
}
}
*/
$i++;
}
}
/*Здесь реализуем функционал по выбору предметов, которые будет изучать студент*/
$optional_lectures = array();
$sql='SELECT * FROM '.$ST['dbpf'].'_lections_grupp as lg, '.$ST['dbpf'].'_lections as l WHERE lg.id_lections=l.id AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY l.name, l.kurs,l.semestr,l.data_c DESC,l.data_u DESC, l.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$code = '';
$i=0;
foreach($rez as $key => $val) if($key){
if ($i == 0) {
$pr = trim($val['name']);
$code .= $val['id'].',<br />';
$val['code'] = $code;
$optional_lectures[$i] = $val;
} else{
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$val['mfile']=explode('|',$val['file']);
//здесь мы убираем дубли предметов. В качестве айдишника - перечисляем через запятую все ид предмета (только предмет дублируется, но айдишники разные)
$code .= $val['id'].',<br />';
if (trim($val['name']) != $pr){
$val['code'] = $code;
$pr = trim($val['name']);
$code = '';
$optional_lectures[$i] = $val;
}
//$optional_lectures[$i]=$val;
}
//чисто для тестов - потом можно будет удалить
if ($i == 0) $test_one = $pr;
if ($i == 1) $test_two = $pr;
if ($i == 2) $test_three = $pr;
if ($i == 3) $test_four = $pr;
if ($i == 4) $test_five = $pr;
$i++;
}
}
/*END*/
//тестовые переменные
$smarty->assign('test_one', $test_one);
$smarty->assign('test_two', $test_two);
$smarty->assign('test_three', $test_three);
$smarty->assign('test_four', $test_four);
$smarty->assign('test_five', $test_five);
/**/
$smarty->assign('optional_lectures', $optional_lectures);
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_learn.html');
}
if($_GET['page']=='workprogram'){
$ST['page']['name'] = 'Рабочие программы студента';
$lections=array();
$sql='SELECT * FROM '.$ST['dbpf'].'_workprogram_grupp as lg, '.$ST['dbpf'].'_workprogram as l WHERE lg.id_lections=l.id AND lg.id_grupp='.$_SESSION['user']['student']['id_grupp'].' ORDER BY l.data_c DESC,l.data_u DESC, l.name';
$rez=$DB->QUR_SEL($sql);
if($rez){
$i=0; foreach($rez as $key => $val)if($key){
$val['data_c']=date('H:i d.m.Y',$val['data_c']);
$val['data_u']=date('H:i d.m.Y',$val['data_u']);
if($_SESSION['user']['student']['status']==0) $val['file']='-1';
$lections[$i]=$val;
$i++;
}
}
$smarty->assign('lections',$lections);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_workprogram.html');
}
//ЭЛЕКТРОННАЯ ЗАЧЕТКА СТУДЕНТА
if ($_GET['page'] == 'record'){
$ST['page']['name'] = 'Электронная зачетка студента';
$message='';
$uc_plans = array();
//УЧЕБНЫЙ ПЛАН - на данный момент указан фиксированный
$cod_podgotovki = $_SESSION['user']['student']['kod_podgotovki'];
$sql_plan = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_plans WHERE `shifr1` = "'.$cod_podgotovki.'"';
$rez_plan = $DB->QUR_SEL($sql_plan);
$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE `id_plans` = "'.$rez_plan[1]['id'].'" ORDER BY `sem`' ;
$rez = $DB->QUR_SEL($sql);
foreach ($rez as $key => $value) if ($key){
$value["hours"] = 36*$value["zet"];
if ($value["ekz"] == "") $value["control"] = "зачет";
else $value["control"] = "экзамен";
if ($value["zet"] == "") {
$value["zet"] = "-";
$value["hours"] = $value["pr"];
}
$uc_plans[] = $value;
}
$smarty->assign('rez_plan',$rez_plan[1]['id']);
$smarty->assign('uc_plans',$uc_plans);
$maincontent = $smarty->fetch('tpl_learn_record.html');
}
//анкета МОНИТОРИНГ Дистанционного обучения
if ($_GET['page'] == 'anketa_distance'){
$id_user = $_SESSION['user']['id'];
if (isset($_POST['order'])){
$date_create = date("U");
$content = '<span style="font-weight: bold;">1. Оцените Вашу удовлетворенность процессом дистанционного обучения в Майкопском государственном технологическом университете:</span><br />';
$content .= '- '.$_POST['q1'];
$content .= '<br /><br /><span style="font-weight: bold;">2. Какие инструменты электронного и дистанционного обучения были использованы в учебном процессе:</span><br /><ul>';
foreach($_POST['q2'] as $check) {
$content .= '<li>'.$check.'</li>';
}
$content .= '</ul>';
if (strlen($_POST['q2_dop']) > 2) $content .= '<u>Комментарий:</u> '.$_POST['q2_dop'];
$content .= '<br /><br /><span style="font-weight: bold;">3. Как Вы оцениваете работу педагогического состава МГТУ в рамках дистанционного обучения:</span><br />';
$content .= '- '.$_POST['q3'];
if (strlen($_POST['q3_dop']) > 2) $content .= '<br /><u>Комментарий:</u> '.$_POST['q3_dop'];
$content .= '<br /><br /><span style="font-weight: bold;">4. Как Вы оцениваете степень Вашей мотивации к обучению в рамках дистанционного формата по сравнению с традиционным обучением:</span><br />';
$content .= '- '.$_POST['q4'];
$content .= '<br /><br /><span style="font-weight: bold;">5. Какие преимущества дистанционного обучения на данный момент наиболее важны для Вас:</span><br /><ul>';
foreach($_POST['q5'] as $check) {
$content .= '<li>'.$check.'</li>';
}
$content .= '</ul>';
if (strlen($_POST['q5_dop']) > 2) $content .= '<u>Комментарий:</u> '.$_POST['q5_dop'];
$content .= '<br /><br /><span style="font-weight: bold;">6. С какими проблемами дистанционного обучения Вы столкнулись?</span><br /><ul>';
foreach($_POST['q6'] as $check) {
$content .= '<li>'.$check.'</li>';
}
$content .= '</ul>';
if (strlen($_POST['q6_dop']) > 2) $content .= '<u>Комментарий:</u> '.$_POST['q6_dop'];
$content .= '<br /><br /><span style="font-weight: bold;">7. Трудоустроены ли Вы в настоящее время?</span><br />';
$content .= '- '.$_POST['q7'];
if (strlen($_POST['q7_dop']) > 2) $content .= '<br /><u>Комментарий:</u> '.$_POST['q7_dop'];
$content = addslashes($content);
$sql = 'INSERT INTO '.$ST['dbpf'].'_anketes (id_user, date_create, content) VALUES ("'.$id_user.'", "'.$date_create.'", "'.$content.'") ';
$rez = $DB->QUR($sql);
}
//проверяем заполнял ли анкету человек в течение 14 дней
$to_date = date("U");
$isOrder = 0;
$sql = 'SELECT * FROM '.$ST['dbpf'].'_anketes WHERE id_user = "'.$id_user.'" ';
$rez = $DB->QUR_SEL($sql);
foreach ($rez as $key => $val) if ($key){
if (abs($val['date_create'] - $to_date) < 14*24*60*60){
$isOrder = 1;
break;
}
}
$smarty->assign('is',$isOrder);
$maincontent = $smarty->fetch('tpl_learn_anketa_distance.html');
}
if($_GET['page']=='op_docs'){
$ST['page']['name'] = 'Учебные документы студента';
$message='';
$sql='SELECT * FROM '.$ST['dbpf'].'_grupp WHERE id='.$_SESSION['user']['student']['id_grupp'].'';
$rez=$DB->QUR_SEL($sql);
if($rez){
$grname=$rez[1]['sokr'].'-'.$rez[1]['kurs'];
$grnume=$_SESSION['user']['student']['num_grupp'];
$url = 'http://local.mkgtu.ru/calchour_2019/calchour_sht/export.php?step=get_up_by_grupp&grupp='.urlencode($grname).$grnume.'';
$json=json_decode(file_get_contents($url),1);
if(count($json['up'])){
}else {
//$message='Нет учебных планов '.$grname.$grnume.'!';
}
//отдельно выведем ДБНИКУ
$dir_edu = 'tmp/education/';
$filesd=scandir($dir_edu); $files=array(); //
//необходимо искать в учебных программах!!! $_SESSION['user']['student']['kod_podgotovki']
//echo $_SESSION['user']['student']['kod_podgotovki'].'<bR>';
$json['dbnika']=array();
foreach($filesd as $k => $v)if($v!='.'&&$v!='..') {
$t = explode('_',$v);
if($t[0]==$_SESSION['user']['student']['kod_podgotovki']){//нашли файл для направления
//echo $k.' - '.$v.'<br>';
$dbnica = json_decode(file_get_contents($dir_edu.$v),1);
$json['dbnika'][$k]=$dbnica;
}
}
//echo '<pre>'.print_r($json['dbnika'],1).'</pre>';
$smarty->assign('up',$json['up']);
$smarty->assign('dbnika',$json['dbnika']);
if($message) $smarty->assign('message',$message);
}else{
$message='Не определили группу';
$smarty->assign('message',$message);
}
//echo '<pre>'.print_r($json,1).'</pre>';
if(!count($json['dbnika'])) {
$message='для отображения образовательных программ, в профиле студента необходимо указать "Код направления подготовки" - только цифры(c точками), без текста!!!';
$smarty->assign('message',$message);
}
//УЧЕБНЫЙ ПЛАН - на данный момент указан фиксированный
$cod_podgotovki = $_SESSION['user']['student']['kod_podgotovki'];
$sql_plan = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_plans WHERE `shifr1` = "'.$cod_podgotovki.'"';
$rez_plan = $DB->QUR_SEL($sql_plan);
$sql = 'SELECT * FROM '.$ST['dbpf'].'_iup_shahtplans_stroki WHERE `id_plans` = "'.$rez_plan[1]['id'].'" ORDER BY `sem`' ;
$rez = $DB->QUR_SEL($sql);
foreach ($rez as $key => $value) if ($key){
$value["hours"] = 36*$value["zet"];
if ($value["ekz"] == "") $value["control"] = "зачет";
else $value["control"] = "экзамен";
if ($value["zet"] == "") {
$value["zet"] = "-";
$value["hours"] = $value["pr"];
}
$uc_plans[] = $value;
}
//КАЛЕНДАРНЫЙ ГРАФИК
$calGr = '';
//УЧЕБНЫЙ ПЛАН РАЗВЕРНУТЫЙ В ПДФ
$pdf = '';
//$search = "21.03.02";
$search = $_SESSION['user']['student']['kod_podgotovki'];
$url = "http://mkgtu.ru/sveden/education/educationDocs/"; // здесь надо вырезать ссылки (только адреса в href="ТОЛЬКО ЗДЕСЬ")
$furl = file_get_contents($url);
$furl = preg_replace("'<script[^>]*?>.*?</script>'si", "", $furl); // убираем скрипты
preg_match_all("#<a[^>]+>(?!<img).+?</a>#i",$furl,$out);
// вырезает, но целые ссылки, а надо голые адреса, то, что находится в href="!!!!!!!!!!".
for($i=0;$i<count($out[0]);$i++)
if (strpos($out[0][$i], $search) !== false){
//$rez .= $out[0][$i].'<br />';
$place = explode('/sveden', $out[0][$i]);
$pdf .= $place[0].'https://mkgtu.ru/sveden'.$place[1].'<br />';
//$calGr .= $place[0].'https://mkgtu.ru/sveden'.$place[4].'<br />';
}
//---------ПДФ КОНЕЦ--------------
$smarty->assign('rez_plan',$rez_plan[1]['id']);
$smarty->assign('pdf',$pdf);
$smarty->assign('calGr',$calGr);
$smarty->assign('uc_plans',$uc_plans);
$smarty->assign('html',$html);
$smarty->assign('profile',$_SESSION['user']);
$maincontent = $smarty->fetch('tpl_opdocs.html');
}
}
?>