public function LearningPathContentController::updateActivity in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathContentController.php \Drupal\opigno_learning_path\Controller\LearningPathContentController::updateActivity()
This method is called on learning path load.
It will update an existing activity relation.
1 string reference to 'LearningPathContentController::updateActivity'
File
- src/
Controller/ LearningPathContentController.php, line 546
Class
- LearningPathContentController
- Controller for all the actions of the Learning Path content.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function updateActivity(OpignoModule $opigno_module, Request $request) {
// First, check the params.
$datas = json_decode($request
->getContent());
if (empty($datas->omr_id) || !isset($datas->max_score)) {
return new JsonResponse(NULL, Response::HTTP_BAD_REQUEST);
}
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$merge_query = $db_connection
->merge('opigno_module_relationship')
->keys([
'omr_id' => $datas->omr_id,
])
->fields([
'max_score' => $datas->max_score,
])
->execute();
return new JsonResponse(NULL, Response::HTTP_OK);
}