/**
  * Получить модули и ИР дисциплины.
  * Возвращает массив модулей, в каждом из которых присутствует список его ИР.
  * Первый модуль в списке - не модуль а обёртка над списком ИР самой дисциплины, его отличает type=='dis'
  * @param int $id
  * @return array [ [type,sort <module.*>, irs=>[ir.*] ] ]
  */
 public static function getDisIr($id)
 {
     $pack0 = array('type' => 'dis', 'sort' => 0, 'id' => $id);
     $pack0['irs'] = RPIrro::getIr($id, 'dis');
     $modules = RPIrro::modules($id);
     $mids = RPU::reshape($modules, false, 'id');
     $mirs = RPIrro::getIr($mids, 'mod');
     foreach ($modules as $k => $mod) {
         $modules[$k]['type'] = 'module';
         $modules[$k]['irs'] = RPU::filterBy($mirs, array('p' => $mod['id']));
     }
     $modules[] = $pack0;
     return RPU::matrixSort($modules, 'sort');
 }
Exemple #2
0
    if ($row['ws'] == $row['we']) {
        $unvis[$i]['week'] = $row['ws'] . ' неделя';
    } else {
        $unvis[$i]['week'] = $row['ws'] . ' - ' . $row['we'] . ' недели';
    }
}
//Взять взыскания студента
$sanction = RPIrro::getSanction($gr['id']);
$textzamech = array('1' => "Замечание", "2" => "Выговор");
foreach ($sanction as $i => $row) {
    $sanction[$i]['data'] = RPU::convDtP($row['data']);
    $sanction[$i]['type'] = $textzamech[$row['id_type']];
}
//Взять направление и профиль
$MsSQL = RPDB::connect();
$result = $MsSQL->prepare("select np.name np,op.name op from np,op,bup,tup,tup_gr where op.id_np=np.id AND bup.id_op=op.id AND tup.id_bup=bup.id AND tup_gr.id=tup.id AND tup_gr.gr=?");
if (!$result->execute(array($gr['id']))) {
    throw new Exception('Ошибка при нахождении НП и ОП');
}
if (!($studinf = $result->fetch(PDO::FETCH_ASSOC))) {
    throw new Exception('Ошибка при нахождении НП и ОП');
}
//============================
$arResult['dis'] = $dis;
$arResult['dolg'] = $dolg;
$arResult['sem'] = RPU::absSemForUP($gr['year'], $set);
$arResult['napr'] = $studinf['np'];
$arResult['prof'] = $studinf['op'];
$arResult['unvis'] = RPU::filterBy($unvis, array('numst' => $numst));
$arResult['sanction'] = RPU::filterBy($sanction, array('numst' => $numst));
$arResult['irs_km'] = $irs_km;
$numst = RPU::reshape($myPost, 'numst', 'numst');
$id_km = RPU::reshape($myPost, 'id_km', 'id_km');
$MsSQL = RPDB::connect();
//Получаем существующие баллы в БД для измененных КМ и студентов
$result = $MsSQL->prepare('select * from st_ball where id_km IN (' . RPU::plas($id_km) . ') and numst IN (' . RPU::plas($numst) . ')');
if (!$result->execute(array_merge($id_km, $numst))) {
    throw new Exception("Ошибка получения баллов");
}
$balls = $result->fetchAll(PDO::FETCH_ASSOC);
foreach ($myPost as $val) {
    // Убрано после новости о том, что можно удалять балл
    //if($val['ball']==='') continue;
    if ($val['ball'] === 'н') {
        $val['ball'] = -1;
    }
    $b = RPU::filterBy($balls, array('id_km' => $val['id_km'], 'numst' => $val['numst']));
    if (!empty($b)) {
        if ($b['ball'] === $val['ball']) {
            continue;
        }
        $where = $val;
        unset($where['ball']);
        if ($val['ball'] === '') {
            if (!RPDB::delete('st_ball', $where)) {
                throw new Exception("Ошибка удаления бала");
            }
        } else {
            if (!RPDB::update('st_ball', array('ball' => $val['ball']), $where)) {
                throw new Exception("Ошибка обновления баллов");
            }
        }
        if ($k['bonus'] != 1) {
            $pr1km['min'][$k['id']] = $k['min_ball'];
            $pr1km['max'][$k['id']] = $k['max_ball'];
        }
        $b = RPU::filterBy($ball[$link], array('id_km' => $k['id'], 'numst' => $numst));
        $b = end(RPU::reshape($b, false, array('ball')));
        $body[$i]['un'][] = $u[$k['week']];
        if ($b['ball'] == '-1') {
            $b['ball'] = 'н';
        }
        $pr1 += (double) $b['ball'];
        $b['id_km'] = $k['id'];
        $b['numst'] = $numst;
        $body[$i]['km'][$k['id']] = $b;
    }
    $grade = end(RPU::filterBy($dis['grades'], array('numst' => $numst)));
    $body[$i]['sum'] = $grade['b'];
    $body[$i]['pr1'] = $pr1;
    $body[$i++]['oc'] = $grade['o'];
}
$arResult['print']['pr1']['max'] = array_sum($pr1km['max']);
$arResult['print']['pr1']['min'] = array_sum($pr1km['min']);
$arResult['print']['body'] = $body;
$arResult['print']['form'] = $dis['itog_name'];
$arResult['print']['pr'] = $pr;
$arResult['print']['week'] = $set['week'];
$arResult['print']['id_tup_d'] = $link;
$arResult['print']['unvisit'] = $unvisit;
$arResult['print']['no_show'] = $no_show;
$APPLICATION->SetTitle("Журнал группы " . $gr['name'] . " по дисциплине" . $inTitle . ": " . $dis['name'] . $help);
$this->IncludeComponentTemplate();
<?php

if (!RPRole::getPermitOne('journal_edit')) {
    RPH::errorPage("Ошибка доступа");
}
$myPost = json_decode(file_get_contents('php://input'), true);
$link = $_GET['id_tup_d'];
$MsSQL = RPDB::connect();
//Получаем существующие баллы в БД для измененных студентов
$result = $MsSQL->prepare('select * from started where id_tup_d = ? and numst IN (' . RPU::plas(array_keys($myPost)) . ')');
if (!$result->execute(array_merge(array($link), array_keys($myPost)))) {
    throw new Exception("Ошибка получения приступил/не приступил");
}
$pr = $result->fetchAll(PDO::FETCH_ASSOC);
foreach ($myPost as $numst => $flag) {
    $b = RPU::filterBy($pr, array('numst' => $numst));
    if (!empty($b)) {
        //Обновить
        if ($flag === $b['flag']) {
            continue;
        }
        $where = array('id_tup_d' => $link, 'numst' => $numst);
        if (!RPDB::update('started', array('flag' => $flag), $where)) {
            throw new Exception("Ошибка обновления присупил/не приступил");
        }
    } else {
        //Вставить
        $field = array('id_tup_d' => $link, 'numst' => $numst, 'flag' => $flag);
        if (!RPDB::insert('started', $field)) {
            throw new Exception("Ошибка добавления присупил/не приступил");
        }