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

Fixes #38: incorrect response from server

Server had been returning number of affected rows minus one: either 0, or -1. This value is converted to bool (res == 0), and js displayed an error.
parent ef886950
Branches
Tags
No related merge requests found
......@@ -1457,7 +1457,7 @@ BEGIN
modules.Type = 'regular' AND
NOT InternalIsMapLocked(modules.DisciplineID)
LIMIT 1;
RETURN ROW_COUNT()-1;
RETURN ROW_COUNT();
END //
......
......@@ -99,9 +99,9 @@ class Controller_Handler_Map extends Controller_Handler
}
public function action_ChangeModuleName() {
$failed = Model_Map::changeModuleName($this->user->TeacherID, $_POST['ModuleID'], $_POST['ModuleName']);
Model_Map::changeModuleName($this->user->TeacherID, $_POST['ModuleID'], $_POST['ModuleName']);
$response['success'] = !$failed;
$response['success'] = true;
$this->response->body(json_encode($response));
}
......
......@@ -47,14 +47,22 @@ class Model_Map extends Model
->execute()->get('Num');
}
/**
* @param $teacherID
* @param $moduleID
* @param $name
* @return boolean true, if name was changed
*/
public static function changeModuleName($teacherID, $moduleID, $name) {
$sql = "SELECT `ChangeModuleName`(:teacher, :module, :name) AS `Num`";
return DB::query(Database::SELECT, $sql)
$result = DB::query(Database::SELECT, $sql)
->parameters([
':teacher' => $teacherID,
':module' => $moduleID,
':name' => $name,
])->execute()->get('Num');
])->execute();
return (bool) $result->get('Num');
}
public static function addSubmodule($teacherID, $moduleID, $typeControl, $maxRate = 0, $title = '', $description = '') {
......
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