Skip to content
Snippets Groups Projects
Commit e1545e34 authored by Vladislav Yakovlev's avatar Vladislav Yakovlev
Browse files

Merge branch 'master' into production

* master:
  FIX: sync create subject for discipline without teachers [2]
  FIX: sync create subject for discipline without teachers
  FIX: update subjects.ExternalID
  FEAT: create specializations and groups on students sync
  FIX; mobile layout
parents 4a17dde0 7c475640
Branches
No related merge requests found
...@@ -162,33 +162,36 @@ DROP FUNCTION IF EXISTS CreateGroup// ...@@ -162,33 +162,36 @@ DROP FUNCTION IF EXISTS CreateGroup//
CREATE FUNCTION CreateGroup ( CREATE FUNCTION CreateGroup (
pGradeID INT, pGradeID INT,
pGroupNum INT, pGroupNum INT,
pSpecializationID INT, pSpecName VARCHAR(200) CHARSET utf8,
pGroupName VARCHAR(50) CHARSET utf8, pFacultyID INT,
pYear INT pYear INT
) RETURNS int(11) # group id ) RETURNS int(11) # group id
NO SQL NO SQL
BEGIN BEGIN
DECLARE vGroupID, vFacultyID, vGroupYear, vIsSpecMatch INT DEFAULT -1; DECLARE vGroupID, vSpecId, vGroupYear, vIsSpecMatch INT DEFAULT -1;
DECLARE EXIT HANDLER FOR SQLEXCEPTION RETURN -1; DECLARE EXIT HANDLER FOR SQLEXCEPTION RETURN -1;
SET vFacultyID = (SELECT FacultyID FROM specializations WHERE specializations.ID = pSpecializationID LIMIT 1); # create specialization
INSERT INTO specializations (Name, Abbr, FacultyID) VALUES (pSpecName, NULL, pFacultyID)
ON DUPLICATE KEY UPDATE
specializations.ID = LAST_INSERT_ID(specializations.ID);
SET vSpecId = LAST_INSERT_ID();
# create discipline # create group
INSERT INTO study_groups (GradeID, GroupNum, FacultyID) VALUES (pGradeID, pGroupNum, vFacultyID) INSERT INTO study_groups (GradeID, GroupNum, FacultyID) VALUES (pGradeID, pGroupNum, pFacultyID)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
study_groups.ID = LAST_INSERT_ID(study_groups.ID); study_groups.ID = LAST_INSERT_ID(study_groups.ID);
SET vGroupID = LAST_INSERT_ID(); SET vGroupID = LAST_INSERT_ID();
SELECT groups_years.GroupID, (groups_years.SpecializationID = pSpecializationID AND SELECT groups_years.GroupID, groups_years.SpecializationID = vSpecId
(pGroupName IS NULL OR groups_years.Name <=> pGroupName))
INTO vGroupYear, vIsSpecMatch INTO vGroupYear, vIsSpecMatch
FROM groups_years FROM groups_years
WHERE groups_years.GroupID = vGroupID AND groups_years.Year = pYear WHERE groups_years.GroupID = vGroupID AND groups_years.Year = pYear
LIMIT 1; LIMIT 1;
IF vGroupYear = -1 THEN IF vGroupYear = -1 THEN
INSERT INTO groups_years (GroupID, Year, SpecializationID, Name) INSERT INTO groups_years (GroupID, Year, SpecializationID)
VALUES (vGroupID, pYear, pSpecializationID, pGroupName); VALUES (vGroupID, pYear, vSpecId);
ELSEIF NOT vIsSpecMatch THEN ELSEIF NOT vIsSpecMatch THEN
RETURN -1; RETURN -1;
END IF; END IF;
...@@ -245,7 +248,10 @@ BEGIN ...@@ -245,7 +248,10 @@ BEGIN
# create/get subject (subject name is unique key) # create/get subject (subject name is unique key)
INSERT INTO subjects (Name, Abbr, ExternalID) VALUES (pSubjectName, pSubjectAbbr, pExternalID) INSERT INTO subjects (Name, Abbr, ExternalID) VALUES (pSubjectName, pSubjectAbbr, pExternalID)
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
subjects.ID = LAST_INSERT_ID(subjects.ID); subjects.ID = LAST_INSERT_ID(subjects.ID),
subjects.Name = pSubjectName,
subjects.Abbr = COALESCE(pSubjectAbbr, subjects.Abbr),
subjects.ExternalID = COALESCE(pExternalID, subjects.ExternalID);
SET vSubjectID = LAST_INSERT_ID(); SET vSubjectID = LAST_INSERT_ID();
BEGIN # handler block BEGIN # handler block
...@@ -719,18 +725,12 @@ CREATE FUNCTION CreateStudentEx ( ...@@ -719,18 +725,12 @@ CREATE FUNCTION CreateStudentEx (
) RETURNS int(11) ) RETURNS int(11)
NO SQL NO SQL
BEGIN BEGIN
DECLARE vAccountID, vGradeID, vSpecID, vGroupID, vYear INT DEFAULT -1; DECLARE vGradeID, vGroupID, vYear INT DEFAULT -1;
DECLARE EXIT HANDLER FOR SQLEXCEPTION RETURN -1; DECLARE EXIT HANDLER FOR SQLEXCEPTION RETURN -1;
# get specialization id
INSERT INTO specializations (Name, Abbr, FacultyID) VALUES (pSpecName, NULL, pFacultyID)
ON DUPLICATE KEY UPDATE
specializations.ID = LAST_INSERT_ID(specializations.ID);
SET vSpecID = LAST_INSERT_ID();
SET vYear = COALESCE((SELECT Year FROM semesters WHERE semesters.ID = pSemesterID LIMIT 1), -1); SET vYear = COALESCE((SELECT Year FROM semesters WHERE semesters.ID = pSemesterID LIMIT 1), -1);
SET vGradeID = CreateGrade(pGradeNum, pDegree); SET vGradeID = CreateGrade(pGradeNum, pDegree);
SET vGroupID = CreateGroup(vGradeID, pGroupNum, vSpecID, NULL, vYear); SET vGroupID = CreateGroup(vGradeID, pGroupNum, pSpecName, pFacultyID, vYear);
RETURN CreateStudent(pLastName, pFirstName, pSecondName, vGroupID, pActivationCode, pSemesterID); RETURN CreateStudent(pLastName, pFirstName, pSecondName, vGroupID, pActivationCode, pSemesterID);
END // END //
......
...@@ -238,12 +238,9 @@ input[type="checkbox"] { ...@@ -238,12 +238,9 @@ input[type="checkbox"] {
display: inline; display: inline;
text-align: right; text-align: right;
float: right; float: right;
> div { > * {
display: inline-block; display: inline-block;
margin: 0 5px; margin-left: 10px;
}
a {
margin-left: 5px;
} }
} }
} }
...@@ -342,23 +339,38 @@ input[type="checkbox"] { ...@@ -342,23 +339,38 @@ input[type="checkbox"] {
} }
.semesterLayer { .semesterLayer {
position: relative;
display: inline-block; display: inline-block;
width: auto; width: auto;
.semesterChanger, .semesterSwitcherBtn { text-align: left;
//margin-left: 0px; font-family: @FontFamily;
font-family: @FontFamily; font-size: 1em;
font-size: 1em;
.semesterChanger {
text-align: right;
> * {
position: relative;
display: inline-block;
&:not(:last-child) {
margin-right: 5px;
}
}
} }
.semesterSwitcher { .semesterSwitcher {
display: block; display: block;
padding: 10px; padding: 10px;
overflow: hidden; overflow: hidden;
.modalWindow(auto); .modalWindow(auto);
min-width: 160px;
margin-top: 5px; margin-top: 5px;
background: @ColorBaseWhite; background: @ColorBaseWhite;
border: 1px solid @ColorBaseGrey; border: 1px solid @ColorBaseGrey;
.box-shadow(0 0 5px, @ColorGrey); .box-shadow(0 0 5px, @ColorGrey);
.radius(5px); .radius(5px);
li { li {
margin-bottom: 5px; margin-bottom: 5px;
&:last-child { margin-bottom: 0; } &:last-child { margin-bottom: 0; }
...@@ -371,22 +383,35 @@ input[type="checkbox"] { ...@@ -371,22 +383,35 @@ input[type="checkbox"] {
display: inline-block; display: inline-block;
width: auto; width: auto;
text-align: left; text-align: left;
.recordBookChanger, .recordBookSwitcherBtn { font-family: @FontFamily;
//margin-left: 0px; font-size: 1em;
font-family: @FontFamily;
font-size: 1em; .recordBookChanger {
text-align: right;
> * {
position: relative;
display: inline-block;
&:not(:last-child) {
margin-right: 5px;
}
}
} }
.recordBookSwitcher { .recordBookSwitcher {
display: block; display: block;
padding: 10px; padding: 10px;
overflow: hidden; overflow: hidden;
.modalWindow(auto); .modalWindow(auto);
right: 0; right: 0;
min-width: 160px;
margin-top: 5px; margin-top: 5px;
background: @ColorBaseWhite; background: @ColorBaseWhite;
border: 1px solid @ColorBaseGrey; border: 1px solid @ColorBaseGrey;
.box-shadow(0 0 5px, @ColorGrey); .box-shadow(0 0 5px, @ColorGrey);
.radius(5px); .radius(5px);
li { li {
margin-bottom: 5px; margin-bottom: 5px;
&:last-child { margin-bottom: 0; } &:last-child { margin-bottom: 0; }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
.EventInspectorList { .EventInspectorList {
position: fixed; position: fixed;
z-index: 10000;
height: auto; height: auto;
min-width: 200px; min-width: 200px;
width: 15%; width: 15%;
......
...@@ -111,12 +111,45 @@ ...@@ -111,12 +111,45 @@
.header_wrapper { .header_wrapper {
padding: 9pt 10px; padding: 9pt 10px;
.logotype {
margin-right: 10px;
}
.logotype span, #username { .logotype span, #username {
display: none; display: none;
} }
} }
.semesterLayer {
.semesterChangerTitle {
display: none;
}
}
.recordBookLayer {
.recordBookChangerTitle {
display: none;
}
.recordBookChangerSelection {
width: calc(~"100vw - 235px");
overflow: hidden;
white-space: nowrap;
direction: rtl;
&:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 10px;
height: 100%;
background: linear-gradient(to right, @ColorBaseWhite, fade(@ColorBaseWhite, 0%));
}
}
}
div.window { div.window {
min-width: initial !important; min-width: initial !important;
......
...@@ -164,11 +164,44 @@ h3.blockTitle ...@@ -164,11 +164,44 @@ h3.blockTitle
.header_wrapper { .header_wrapper {
padding: 9pt 10px; padding: 9pt 10px;
.logotype {
margin-right: 10px;
}
.logotype span, #username { .logotype span, #username {
display: none; display: none;
} }
} }
.semesterLayer {
.semesterChangerTitle {
display: none;
}
}
.recordBookLayer {
.recordBookChangerTitle {
display: none;
}
.recordBookChangerSelection {
width: calc(~"100vw - 235px");
overflow: hidden;
white-space: nowrap;
direction: rtl;
&:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 10px;
height: 100%;
background: linear-gradient(to right, @ColorBaseWhite, fade(@ColorBaseWhite, 0%));
}
}
}
div.window { div.window {
min-width: initial !important; min-width: initial !important;
......
...@@ -167,7 +167,14 @@ class Controller_Api_V0_Student extends Controller_Handler_Api { ...@@ -167,7 +167,14 @@ class Controller_Api_V0_Student extends Controller_Handler_Api {
throw new InvalidArgumentException('RecordBook: grade not found'); throw new InvalidArgumentException('RecordBook: grade not found');
} }
$group = Model_Group::find($gradeID, $recordBookData->group, $recordBookData->facultyID); $speciality = $recordBookData->speciality;
if (strpos($speciality, ' - ') == 8) {
$speciality = substr($speciality, 11);
}
$year = Model_Plan::load($recordBookData->planID)->Year;
$group = Model_Group::findOrCreate($gradeID, $recordBookData->group, $speciality, $recordBookData->facultyID, $year);
if (is_null($group)) { if (is_null($group)) {
throw new InvalidArgumentException('RecordBook: group not found'); throw new InvalidArgumentException('RecordBook: group not found');
} }
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
class Controller_Api_V0_StudyPlan extends Controller_Handler_Api { class Controller_Api_V0_StudyPlan extends Controller_Handler_Api {
private function normalizeDisciplinesData($disciplineData, $facultyID) { private function normalizeDisciplinesData($disciplineData, $facultyID) {
if (!isset($disciplineData->subjectID) && isset($disciplineData->externalID)) {
$disciplineData->subjectID = Model_Subject::withExternalID($disciplineData->externalID, $disciplineData->name, '', $facultyID);
}
foreach ($disciplineData->teachers as $teacherData) { foreach ($disciplineData->teachers as $teacherData) {
if (empty($teacherData->hashSnils)) { if (empty($teacherData->hashSnils)) {
Log::instance()->add(Log::WARNING, '{0} {1}: {2}', array( Log::instance()->add(Log::WARNING, '{0} {1}: {2}', array(
...@@ -22,13 +18,7 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api { ...@@ -22,13 +18,7 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api {
} }
if (empty($disciplineData->teacherIDs)) { if (empty($disciplineData->teacherIDs)) {
if (!empty($disciplineData->teachers)) { throw new InvalidArgumentException('Discipline without teachers');
Log::instance()->add(Log::WARNING, '{0} {1}: {2}', array(
'{0}' => 'SYNC_DISCIPLINES',
'{1}' => 'Discipline without teachers',
'{2}' => json_encode($disciplineData),
));
}
} }
switch ($disciplineData->type) { switch ($disciplineData->type) {
...@@ -45,6 +35,10 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api { ...@@ -45,6 +35,10 @@ class Controller_Api_V0_StudyPlan extends Controller_Handler_Api {
throw new InvalidArgumentException('Discipline has bad type'); throw new InvalidArgumentException('Discipline has bad type');
} }
if (!isset($disciplineData->subjectID) && isset($disciplineData->externalID)) {
$disciplineData->subjectID = Model_Subject::withExternalID($disciplineData->externalID, $disciplineData->name, NULL, $facultyID);
}
return $disciplineData; return $disciplineData;
} }
......
...@@ -14,12 +14,14 @@ class Model_Group extends Model ...@@ -14,12 +14,14 @@ class Model_Group extends Model
return $g; return $g;
} }
public static function find($gradeID, $groupNum, $facultyID) { public static function findOrCreate($gradeID, $groupNum, $specialization, $facultyID, $year) {
$sql = 'SELECT `FindGroup`(:gradeID, :groupNum, :facultyID) AS `ID`'; $sql = 'SELECT `CreateGroup`(:gradeID, :groupNum, :specialization, :facultyID, :year) AS `ID`';
$id = DB::query(Database::SELECT, $sql) $id = DB::query(Database::SELECT, $sql)
->param(':gradeID', $gradeID) ->param(':gradeID', $gradeID)
->param(':groupNum', $groupNum) ->param(':groupNum', $groupNum)
->param(':specialization', $specialization)
->param(':facultyID', $facultyID) ->param(':facultyID', $facultyID)
->param(':year', $year)
->execute()->get('ID'); ->execute()->get('ID');
if ($id <= 0) { if ($id <= 0) {
return null; return null;
......
...@@ -48,7 +48,7 @@ class Model_Subject ...@@ -48,7 +48,7 @@ class Model_Subject
return (int) $res->get('Num'); return (int) $res->get('Num');
} }
public static function withExternalID($extID, $name='', $abbr='', $facultyID=null) { public static function withExternalID($extID, $name, $abbr, $facultyID) {
$sql = 'SELECT `Subject_GetByExternalID`(:extID) AS `ID`'; $sql = 'SELECT `Subject_GetByExternalID`(:extID) AS `ID`';
$id = DB::query(Database::SELECT, $sql) $id = DB::query(Database::SELECT, $sql)
->param(':extID', $extID) ->param(':extID', $extID)
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
{% macro SemesterSwitcher(SemesterList) %} {% macro SemesterSwitcher(SemesterList) %}
<a href="#" id="changeSemester" class="semesterChanger" title="Сменить семестр"> <a href="#" id="changeSemester" class="semesterChanger" title="Сменить семестр">
{% set Semester = SemesterList[User.SemesterID] %} {% set Semester = SemesterList[User.SemesterID] %}
Семестр: {{ Rus[Semester.Season] }} {{ Semester.Num == 1 ? Semester.Year : (Semester.Year + 1) }} <span class="semesterChangerTitle">Семестр:</span>
<span class="semesterChangerSelection">{{ Rus[Semester.Season] }} {{ Semester.Num == 1 ? Semester.Year : (Semester.Year + 1) }}</span>
<i class="fa fa-angle-down"></i> <i class="fa fa-angle-down"></i>
</a> </a>
<div class="semesterSwitcherBtn"> <div class="semesterSwitcherBtn">
...@@ -34,7 +35,8 @@ ...@@ -34,7 +35,8 @@
{% macro RecordBookSwitcher(RecordBookList) %} {% macro RecordBookSwitcher(RecordBookList) %}
<a href="#" id="changeRecordBook" class="recordBookChanger" title="Сменить зачетку"> <a href="#" id="changeRecordBook" class="recordBookChanger" title="Сменить зачетку">
{% set RecordBook = RecordBookList[User.RecordBookID] %} {% set RecordBook = RecordBookList[User.RecordBookID] %}
Зачетка: {{ RecordBook.ExternalID }} <span class="recordBookChangerTitle">Зачетка:</span>
<span class="recordBookChangerSelection">{{ RecordBook.ExternalID }}</span>
<i class="fa fa-angle-down"></i> <i class="fa fa-angle-down"></i>
</a> </a>
<div class="recordBookSwitcherBtn"> <div class="recordBookSwitcherBtn">
......
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