protected function ImportTrainingForm::setMaxScore in Opigno module 3.x
Same name and namespace in other branches
- 8 src/Form/ImportTrainingForm.php \Drupal\opigno_module\Form\ImportTrainingForm::setMaxScore()
Build Array of settings to create entity.
Parameters
OpignoActivity $activity: OpignoActivity entity.
OpignoModule $module: OpignoModule entity.
array $activity_content: List of values from imported file.
File
- src/
Form/ ImportTrainingForm.php, line 586
Class
- ImportTrainingForm
- Import Course form.
Namespace
Drupal\opigno_module\FormCode
protected function setMaxScore($activity, $module, $activity_content) {
// Set max score.
if (!empty($activity_content['max_score'])) {
$db_connection = \Drupal::service('database');
unset($activity_content['max_score']['omr_id']);
$max_score = $activity_content['max_score'];
$max_score['parent_id'] = $module
->id();
$max_score['child_id'] = $activity
->id();
$max_score['parent_vid'] = $module
->get('vid')
->getValue()[0]['value'];
$max_score['child_vid'] = $activity
->get('vid')
->getValue()[0]['value'];
try {
$db_connection
->insert('opigno_module_relationship')
->fields($max_score)
->execute();
} catch (\Exception $e) {
\Drupal::logger('opigno_groups_migration')
->error($e
->getMessage());
}
}
}