Skip to content
Snippets Groups Projects
Rating.php 4.18 KiB
Newer Older
<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Teacher_Rating extends Controller_UserEnvi {
    
    public function action_edit()
    {
        $twig = Twig::factory('teacher/setRate');
        $twig->User = $this->UserInfo;
        $db = new Model_Teacher_Rating;
        
        // Шапка: модули и подмодули
	$discipline = $db->GetMapForDiscipline($this->UserInfo['TeacherID'], $id);
        
        if($discipline->count() == 0)
            throw HTTP_Exception::factory (404, "Дисциплины с ID $id не существует!");
        
	$disciplineHandled = array();
        $maxRate = 0; $i = 0; $module = 0;
        
            if(!isset($disciplineHandled[$i]['SubmodulesCount']))
            {
                $disciplineHandled[$i]['SubmodulesCount'] = 0;
                $disciplineHandled[$i]['MaxRate'] = 0;
            }
            $j = $disciplineHandled[$i]['SubmodulesCount'] += 1;
            $disciplineHandled[$i]['MaxRate'] += (int) $row['MaxRate'];
            $disciplineHandled[$i]['ModuleTitle'] = $row['ModuleName'];
            $disciplineHandled[$i][$j]['Title'] = $row['SubModuleName'];
            $disciplineHandled[$i][$j]['Description'] = $row['SubmoduleDescription'];
            $disciplineHandled[$i][$j]['MaxRate'] = (int) $row['MaxRate'];
            $maxRate += $row['MaxRate'];
        }
        $disciplineHandled['ModulesCount'] = $i;
        $disciplineHandled['MaxRate'] = (int) $maxRate; 
        
        $twig->headerRate = $disciplineHandled;
        
        // Студенты и баллы
        $students = $db->GetStudentsForDiscipline($this->UserInfo['TeacherID'], $id);
        $studentsHandled = array();
                $studentsHandled[$i]['LastName'] = $row['StudentLast'];
                $studentsHandled[$i]['FirstName'] = $row['StudentFirst'];
                $studentsHandled[$i]['SecondName'] = $row['StudentSecond'];
				$studentsHandled[$i]['Grade'] = $row['Grade'];
				$studentsHandled[$i]['GroupNum'] = $row['GroupNum'];
                $rate = $db->getMapForStudent($row['StudentID'], $id);
                $j = 0;
                foreach($rate as $r) {
                        $j += 1;
                        $studentsHandled[$i][$j]['SubmoduleID'] = $r['SubmoduleID'];
                        $studentsHandled[$i][$j]['Rate'] = $r['Rate'];
                }
                $studentsHandled[$i]['RateCount'] = $j;
			}
			else {
				// Мигранты
				$MigrantsCount++;
				$MigrantsHandled[$MigrantsCount]['StudentID'] = $row['StudentID'];
                $MigrantsHandled[$MigrantsCount]['StudentID'] = $row['StudentID'];
                $MigrantsHandled[$MigrantsCount]['LastName'] = $row['StudentLast'];
				$MigrantsHandled[$MigrantsCount]['FirstName'] = $row['StudentFirst'];
				$MigrantsHandled[$MigrantsCount]['SecondName'] = $row['StudentSecond'];
				$MigrantsHandled[$MigrantsCount]['Grade'] = $row['Grade'];
				$MigrantsHandled[$MigrantsCount]['GroupNum'] = $row['GroupNum'];
				$rate = $db->getMapForStudent($row['StudentID'], $id);
                $j = 0;
                foreach($rate as $r) {
                        $j += 1;
                        $MigrantsHandled[$MigrantsCount][$j]['SubmoduleID'] = $r['SubmoduleID'];
                        $MigrantsHandled[$MigrantsCount][$j]['Rate'] = $r['Rate'];
                }
				$MigrantsHandled[$MigrantsCount]['RateCount'] = $j;
			}