Skip to content
Snippets Groups Projects
Commit 228ec3c2 authored by xamgore's avatar xamgore
Browse files

Code formatting

parent 6fdfa590
Branches
Tags
No related merge requests found
......@@ -2,169 +2,120 @@
class Controller_Handler_FileCreator extends Controller_Handler
{
public function before() {
$this->setAccessLevel(self::ACCESS_USER);
parent::before();
}
// Таблица баллов (со страницы оценивания) [dev version]
public function action_GenerateExcelRatingTable()
{
// TODO CHECK!!!
public function action_GenerateExcelRatingTable() {
$xls = new PHPExcel();
$xls = new PHPExcel();
// Устанавливаем индекс активного листа
$xls->setActiveSheetIndex(0);
// Устанавливаем индекс активного листа
$xls->setActiveSheetIndex(0);
// Получаем активный лист
$sheet = $xls->getActiveSheet();
// Получаем активный лист
$sheet = $xls->getActiveSheet();
// Шапка таблицы: структура УКД (модули и мероприятия)
$structure = Model_Map::getMapForDiscipline($this->post['disciplineID']);
// Шапка таблицы: структура УКД (модули и мероприятия)
$structure = Model_Map::getMapForDiscipline($this->post['disciplineID']);
$id = -1;
$count = 0;
$maxRate = 0;
$structureHandled = array();
$structureHandled = array();
$maxRate = 0; $i = 0; $module = 0;
foreach ($structure as $row) {
if ($row['ModuleID'] != $id) {
$id = $row['ModuleID'];
$module =& $structureHandled[$count++];
foreach($structure as $row)
{
if($row['ModuleID'] != $module)
{
$i++;
$module = $row['ModuleID'];
}
if(!isset($structureHandled[$i]['SubmodulesCount']))
{
$structureHandled[$i]['SubmodulesCount'] = 0;
$structureHandled[$i]['MaxRate'] = 0;
}
$j = $structureHandled[$i]['SubmodulesCount'] += 1;
$structureHandled[$i]['MaxRate'] += (int) $row['MaxRate'];
$structureHandled[$i]['ModuleTitle'] = $row['ModuleName'];
$structureHandled[$i]['ModuleType'] = $row['ModuleType'];
$structureHandled[$i][$j]['SubmoduleID'] = $row['SubmoduleID'];
$structureHandled[$i][$j]['Title'] = $row['SubModuleName'];
$structureHandled[$i][$j]['MaxRate'] = (int) $row['MaxRate'];
$maxRate += $row['MaxRate'];
$module = array(
'MaxRate' => 0,
'SubmodulesCount' => 0,
'ModuleTitle' => $row['ModuleName'],
'ModuleType' => $row['ModuleType'],
);
}
$structureHandled['ModulesCount'] = $i;
$structureHandled['MaxRate'] = (int) $maxRate;
$sheet->setCellValueByColumnAndRow(
0, // Столбец. Индексация с 0
1, // Строка. Индексация с 1
'Модуль'
);
$module['SubmodulesCount']++;
$sheet->setCellValueByColumnAndRow(
0,
2,
'Мероприятие'
$module[] = array(
'SubmoduleID' => $row['SubmoduleID'],
'Title' => $row['SubModuleName'],
'MaxRate' => (int)$row['MaxRate'],
);
$sheet->setCellValueByColumnAndRow(
0,
3,
'Макс. балл'
);
$maxRate += $row['MaxRate'];
$module['MaxRate'] += (int)$row['MaxRate'];
}
$SubmodulesCount = 0;
// Модули
for ($k = 1, $pointer = 1; $k <= $structureHandled['ModulesCount']; $k++)
{
$sheet->mergeCellsByColumnAndRow($pointer, 1, $pointer + $structureHandled[$k]['SubmodulesCount'] - 1, 1);
$structureHandled['ModulesCount'] = $count;
$structureHandled['MaxRate'] = (int)$maxRate;
$sheet->setCellValueByColumnAndRow(
$pointer,
1,
$structureHandled[$k]['ModuleTitle']
);
$sheet->setCellValueByColumnAndRow(0, 1, 'Модуль');
$sheet->setCellValueByColumnAndRow(0, 2, 'Мероприятие');
$sheet->setCellValueByColumnAndRow(0, 3, 'Макс. балл');
// Мероприятия
for ($l = 1; $l <= $structureHandled[$k]['SubmodulesCount']; $l++)
{
$sheet->setCellValueByColumnAndRow(
$pointer + $l - 1,
2,
$structureHandled[$k][$l]['Title']
);
$sheet->setCellValueByColumnAndRow(
$pointer + $l - 1,
3,
$structureHandled[$k][$l]['MaxRate']
);
$SubmodulesCount++;
}
$submodulesCount = 0;
// Модули
for ($k = 0, $pointer = 1; $k <= $structureHandled['ModulesCount']; $k++) {
$sheet->mergeCellsByColumnAndRow($pointer, 1, $pointer + $structureHandled[$k]['SubmodulesCount'] - 1, 1);
$sheet->setCellValueByColumnAndRow($pointer, 1, $structureHandled[$k]['ModuleTitle']);
$pointer = $structureHandled[$k]['SubmodulesCount'] + 1;
// Мероприятия
for ($l = 0; $l <= $structureHandled[$k]['SubmodulesCount']; $l++) {
$sheet->setCellValueByColumnAndRow($pointer + $l, 2, $structureHandled[$k][$l]['Title']);
$sheet->setCellValueByColumnAndRow($pointer + $l, 3, $structureHandled[$k][$l]['MaxRate']);
$submodulesCount++;
}
$sheet->setCellValueByColumnAndRow(
$SubmodulesCount + 1,
1,
'Итог'
);
$pointer = $structureHandled[$k]['SubmodulesCount'] + 1;
}
$sheet->mergeCellsByColumnAndRow( $SubmodulesCount + 1, 1, $SubmodulesCount + 1, 3 );
$sheet->setCellValueByColumnAndRow($submodulesCount + 1, 1, 'Итог');
$sheet->mergeCellsByColumnAndRow($submodulesCount + 1, 1, $submodulesCount + 1, 3);
// Студенты и их баллы
// Студенты и их баллы
$students = Model_Rating::GetStudentsForRating($this->post['disciplineID']);
$students = Model_Rating::GetStudentsForRating($this->post['disciplineID']);
$i = 0;
$curGroup = 0;
$rateSum = 0;
$i_s = 0; $curGroup = 0; $rateSum = 0;
foreach ($students as $row) {
if ($curGroup !== $row['GroupID']) {
$curGroup = $row['GroupID'];
foreach($students as $row) {
if ($curGroup !== $row['GroupID']) {
$curGroup = $row['GroupID'];
$i_s++;
$sheet->mergeCellsByColumnAndRow( 0, 3 + $i_s, $SubmodulesCount + 1, 3 + $i_s );
$sheet->setCellValueByColumnAndRow(
0,
3 + $i_s,
$row['GroupNum']." группа"
);
}
// Студенты
$i_s++;
$rateSum += $row['Rate'];
$sheet->setCellValueByColumnAndRow(
0,
3 + $i_s,
$row['Last'].' '.$row['First'].' '.$row['Second']
);
$i++;
$sheet->mergeCellsByColumnAndRow(0, 3 + $i, $submodulesCount + 1, 3 + $i);
$sheet->setCellValueByColumnAndRow(0, 3 + $i, $row['GroupNum'] . ' группа');
}
// Баллы студента
$rate = Model_Rating::getMapForStudent($row['ID'], $this->post['disciplineID']);
$i_r = 0;
foreach($rate as $r) {
$i_r++;
$sheet->setCellValueByColumnAndRow(
$i_r,
3 + $i_s,
$r['Rate']
);
}
// Студенты
$i++;
$rateSum += $row['Rate'];
$sheet->setCellValueByColumnAndRow(0, 3 + $i, $row['Last'] . ' ' . $row['First'] . ' ' . $row['Second']);
// Баллы студента
$rate = Model_Rating::getMapForStudent($row['ID'], $this->post['disciplineID']);
$i_r = 0;
foreach ($rate as $r) {
$i_r++;
$sheet->setCellValueByColumnAndRow($i_r, 3 + $i, $r['Rate']);
}
$sheet->setCellValueByColumnAndRow(
$SubmodulesCount + 1, // Столбец. Индексация с 0
3 + $i_s,
$rateSum
);
$sheet->setCellValueByColumnAndRow($submodulesCount + 1, 3 + $i, $rateSum);
}
}
$this->GetHeaders();
$this->GetHeaders();
// Выводим содержимое файла
$objWriter = new PHPExcel_Writer_Excel5($xls);
$objWriter->save('php://output');
// Выводим содержимое файла
$objWriter = new PHPExcel_Writer_Excel5($xls);
$objWriter->save('php://output');
}
// Ведомость
......
......@@ -1099,8 +1099,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/**
* Set a cell value by using numeric cell coordinates
*
* @param string $pColumn Numeric column coordinate of the cell (A = 0)
* @param string $pRow Numeric row coordinate of the cell
* @param string $pColumn Numeric column coordinate of the cell (>= 0)
* @param string $pRow Numeric row coordinate of the cell (>= 1)
* @param mixed $pValue Value of the cell
* @param bool $returnCell Return the worksheet (false, default) or the cell (true)
* @return PHPExcel_Worksheet|PHPExcel_Cell Depending on the last parameter being specified
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment