You are here

public function OpignoGroupManagerController::updateItemMinScore in Opigno group manager 8

Same name and namespace in other branches
  1. 3.x src/Controller/OpignoGroupManagerController.php \Drupal\opigno_group_manager\Controller\OpignoGroupManagerController::updateItemMinScore()

Method called when an item success score is set or not.

1 string reference to 'OpignoGroupManagerController::updateItemMinScore'
opigno_group_manager.routing.yml in ./opigno_group_manager.routing.yml
opigno_group_manager.routing.yml

File

src/Controller/OpignoGroupManagerController.php, line 362

Class

OpignoGroupManagerController
Controller for all the actions of the Opigno group manager app.

Namespace

Drupal\opigno_group_manager\Controller

Code

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 = OpignoGroupManagedContent::load($cid);
  $content
    ->setSuccessScoreMin($success_score_min);
  $content
    ->save();

  // Return the JSON response.
  return new JsonResponse(NULL, Response::HTTP_OK);
}