public function LearningPathManagerController::updateItemMinScore in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Controller/LearningPathManagerController.php \Drupal\opigno_learning_path\Controller\LearningPathManagerController::updateItemMinScore()
Method called when an item success score is set or not.
1 string reference to 'LearningPathManagerController::updateItemMinScore'
File
- src/
Controller/ LearningPathManagerController.php, line 190
Class
- LearningPathManagerController
- Controller for all the actions of the Learning Path manager app.
Namespace
Drupal\opigno_learning_path\ControllerCode
public function updateItemMinScore(Group $group, Request $request) {
// Ensure all data are okay.
$datas = json_decode($request
->getContent());
if (empty($datas->cid)) {
return new JsonResponse(NULL, Response::HTTP_BAD_REQUEST);
}
$cid = $datas->cid;
$success_score_min = empty($datas->successScoreMin) ? 0 : $datas->successScoreMin;
// Update the item.
$content = LPManagedContent::load($cid);
$content
->setSuccessScoreMin($success_score_min);
$content
->save();
// Return the JSON response.
return new JsonResponse(NULL, Response::HTTP_OK);
}