diff --git a/db/postgresql/functions.sql b/db/postgresql/functions.sql
index 82e88e97247e6ae4eb2a99bf0bd976c9c0b1df52..596aa5c3999798904d27d2a0fb37d1428017da61 100644
--- a/db/postgresql/functions.sql
+++ b/db/postgresql/functions.sql
@@ -1,4 +1,8 @@
- DROP TRIGGER IF EXISTS  tr_i_submodule ON submodules CASCADE; 
+-- noinspection LossyEncodingForFile
+
+-- noinspection LossyEncodingForFile
+
+DROP TRIGGER IF EXISTS  tr_i_submodule ON submodules CASCADE;
 
  DROP TRIGGER IF EXISTS  tr_u_submodule ON submodules CASCADE; 
 
@@ -5437,15 +5441,15 @@ begin
 --	:pactivationcode 	-- put the pactivationcode parameter value instead of 'pactivationcode' (varchar)
 --);
 
-      vAccountID := CreateAccount(pActivationCode, GetUserRole('teacher'));
+      vAccountID := CreateAccount(pLastName, pFirstName, pSecondName, pActivationCode, GetUserRole('teacher'));
    -- add new teacher
-    INSERT INTO teachers (AccountID, LastName, FirstName, SecondName, JobPositionID, DepartmentID) VALUES
-        (vAccountID, pLastName, pFirstName, pSecondName, pJobPositionID, pDepartmentID) returning vID;
+    INSERT INTO teachers (AccountID, JobPositionID, FacultyID) VALUES
+        (vAccountID, pJobPositionID, pDepartmentID) returning ID into vID;
     RETURN vID;
-  EXCEPTION 
-  when others then
-  RETURN -1;
-   
+  --EXCEPTION
+  --when others then
+  --RETURN -1;
+
 END;
 $function$;
 
diff --git a/~dev_rating/application/classes/Controller/Api/V0/Teacher.php b/~dev_rating/application/classes/Controller/Api/V0/Teacher.php
index adeb5794db333c100b7c597fa6deef72db99fbc6..bdae3ac154c659bad557620e6a8b6828afcab9ac 100644
--- a/~dev_rating/application/classes/Controller/Api/V0/Teacher.php
+++ b/~dev_rating/application/classes/Controller/Api/V0/Teacher.php
@@ -76,8 +76,11 @@ class Controller_Api_V0_Teacher extends Controller_Handler_Api {
             $teacher = $teacher->inila($teacherData->inila);
         }
         $teacher = $teacher->create();
-
-        return (int)$teacher->ID;
+        if (isset($teacher->ActivationCode)) {
+            return [(int)$teacher->ID, $teacher->ActivationCode];
+        } else {
+            return (int)$teacher->ID;
+        }
     }
 
     private function updateTeacher($teacherData) {
diff --git a/~dev_rating/application/classes/Model/Teacher.php b/~dev_rating/application/classes/Model/Teacher.php
index 492bc123fda9a54c8b9f6d368f8fa6168d19c20e..efeb763a1644ea986afb1281b160545f501ad6dc 100644
--- a/~dev_rating/application/classes/Model/Teacher.php
+++ b/~dev_rating/application/classes/Model/Teacher.php
@@ -71,6 +71,9 @@ class Model_Teacher extends Model_Container
                 ->parameters($this->data)
                 ->execute()->get('ID');
         } else {
+            if (!isset($this->data["DepID"])) {
+                $this->DepID = $this->data['FacultyID'];
+            }
             $sql = 'SELECT * FROM Teacher_Create(LastName, FirstName, SecondName, JobPositionID, DepID, 
                                                 ActivationCode) AS "ID"';