Newer
Older
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Controller_Api_V0_FinalReport extends Controller_Handler_Api
{
/**
* @api {get} api/v0/final-report Get final form data for export into 1C
* @apiName Get final report
* @apiGroup Final report
* @apiVersion 0.1.0
* @apiParam {String} token Api key
* @apiParam {Int} year Год (четырехзначное число)
* @apiParam {Int} num Номер семестра (1-2)
* @apiParam {String} plan Код справочника из 1С:Университет соответствующий учебному плану
* @apiParam {String} discipline Код справочника из 1С:Университет соответствующий учебной дисциплине
* @apiParam {Int} groupnum Номер группы
* @apiParam {Int} gradenum Id курса (gradeID)
* @apiParam {Int} study_form Номер формы обучения (1-3)
* @apiParam {Int} faculty Id факультета (facultyID)
* @apiDescription This method returns all grades for particular student group,
* study plan, discipline, semester, study form and faculty.
* @apiExample {curl} Example usage:
* curl -i http://grade/~dev_rating/api/v0/final-report?token=osw839hfgh9a23hgfh92hasff232f2oasf&year=2018&num=1&plan=000130973&discipline=000026162&groupnum=1&gradenum=6&study_form=1&faculty=1
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* {
* "response": {
* "000130973": {
* "000026162": {
* "type": "exam",
* "students": {
* "ММ-18-0263": {
* "semester": 60,
* "exam": [
* 40,
* null,
* null
* ],
* "extra": [
* null,
* null
* ]
* },
* "ММ-18-0265": {
* "semester": 56,
* "exam": [
* 39,
* null,
* null
* ],
* "extra": [
* null,
* null
* }
* }
* }
* }
* }
* }
*
*/
public function action_get_index()
{
try {
// Получаем год и номер семестра из query запроса
$year = $this->request->query('year');
$num = $this->request->query('num');
$plan = $this->request->query('plan');
$discipline = $this->request->query('discipline');
$groupnum = $this->request->query('groupnum');
$gradenum = $this->request->query('gradenum');
$groupid = $this->request->query('groupid');
$faculty = $this->request->query('faculty');
$study_form = $this->request->query('study_form');
$emulate = $this->request->query('emulate');
if (isset($discipline) and !isset($groupnum)) {
$finalReport = Model_FinalReport::getBySemesterYearNumDiscipline($year, $num, $discipline);
} elseif (!isset($discipline)) {
$finalReport = Model_FinalReport::getBySemesterYearNumPlan($year, $num, $plan);
$finalReport = Model_FinalReport::getBySemesterYearNumDisciplineGroup($year, $num, $discipline, $groupnum, $groupid, $gradenum, $faculty, $study_form);
$response = [];
/** @var Model_FinalReportItem $row */
foreach ($finalReport as $row) {
$response[$row->PlanExternalID][$row->SubjectExternalID]['type'] = $row->ExamType;
$response[$row->PlanExternalID][$row->SubjectExternalID]['students'][$row->RecordBookExternalID] = [
'semester' => $row->SemesterRate,
'exam' => [$row->ExamRate, $row->Exam2Rate, $row->Exam3Rate],
'extra' => [$row->ExtraRate, $row->Extra2Rate],
if (!isset($emulate) and isset($groupnum)) {
//$groupID = Model_Group::find($gradenum, $groupnum, $study_form, $faculty);
Model_Logs::logFormExport($this->user->ID, $discipline, $groupid, $this->user["SemesterID"]);
Anton Bagliy
committed
// TODO: удалить лишние учебные планы от академиков правильным способом!
array_splice($response, 1);
} catch (Exception $e) {
$this->badRequestError($e->getMessage());
}