public function OpignoModuleScoreLink::render in Opigno module 8
Same name and namespace in other branches
- 3.x src/Plugin/views/field/OpignoModuleScoreLink.php \Drupal\opigno_module\Plugin\views\field\OpignoModuleScoreLink::render()
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides FieldPluginBase::render
File
- src/
Plugin/ views/ field/ OpignoModuleScoreLink.php, line 36
Class
- OpignoModuleScoreLink
- A handler to provide a field that is completely custom by the administrator.
Namespace
Drupal\opigno_module\Plugin\views\fieldCode
public function render(ResultRow $values) {
/** @var \Drupal\opigno_module\Entity\OpignoActivity $activities */
$activities = $values->_relationship_entities["module"]
->getModuleActivities();
$activities = array_column((array) $activities, 'type');
$manually_scored_activities = [
'opigno_file_upload',
'opigno_long_answer',
];
$correct_activity = !empty(array_intersect($manually_scored_activities, $activities));
$parameters = [
'opigno_module' => $values->opigno_module_field_data_user_module_status_id,
'user_module_status' => $values->id,
];
return $correct_activity ? Link::fromTextAndUrl($this
->t('Score'), Url::fromRoute('opigno_module.module_result_form', $parameters))
->toString() : '';
}