class OpignoModule in Opigno module 8
Same name and namespace in other branches
- 3.x src/Entity/OpignoModule.php \Drupal\opigno_module\Entity\OpignoModule
Defines the Module entity.
Plugin annotation
@ContentEntityType(
id = "opigno_module",
label = @Translation("Module"),
handlers = {
"view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
"list_builder" = "Drupal\opigno_module\OpignoModuleListBuilder",
"views_data" = "Drupal\opigno_module\Entity\OpignoModuleViewsData",
"form" = {
"default" = "Drupal\opigno_module\Form\OpignoModuleForm",
"add" = "Drupal\opigno_module\Form\OpignoModuleForm",
"edit" = "Drupal\opigno_module\Form\OpignoModuleForm",
"delete" = "Drupal\opigno_module\Form\OpignoModuleDeleteForm",
},
"access" = "Drupal\opigno_module\OpignoModuleAccessControlHandler",
"route_provider" = {
"html" = "Drupal\opigno_module\OpignoModuleHtmlRouteProvider",
},
},
base_table = "opigno_module",
data_table = "opigno_module_field_data",
revision_table = "opigno_module_revision",
revision_data_table = "opigno_module_field_revision",
translatable = TRUE,
show_revision_ui = TRUE,
admin_permission = "administer module entities",
entity_keys = {
"id" = "id",
"revision" = "vid",
"label" = "name",
"uuid" = "uuid",
"uid" = "uid",
"langcode" = "langcode",
"status" = "status",
},
links = {
"canonical" = "/module/{opigno_module}",
"add-form" = "/admin/structure/opigno_module/add",
"edit-form" = "/admin/structure/opigno_module/{opigno_module}/edit",
"delete-form" = "/admin/structure/opigno_module/{opigno_module}/delete",
"collection" = "/admin/structure/opigno_module",
},
field_ui_base_route = "opigno_module.settings"
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
- class \Drupal\Core\Entity\RevisionableContentEntityBase implements RevisionLogInterface uses RevisionLogEntityTrait
- class \Drupal\opigno_module\Entity\OpignoModule implements OpignoModuleInterface uses EntityChangedTrait
- class \Drupal\Core\Entity\RevisionableContentEntityBase implements RevisionLogInterface uses RevisionLogEntityTrait
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
Expanded class hierarchy of OpignoModule
11 files declare their use of OpignoModule
- ContentTypeModule.php in src/
Plugin/ OpignoGroupManagerContentType/ ContentTypeModule.php - ImportCourseForm.php in src/
Form/ ImportCourseForm.php - ImportModuleForm.php in src/
Form/ ImportModuleForm.php - ImportTrainingForm.php in src/
Form/ ImportTrainingForm.php - LearningPathController.php in src/
Controller/ LearningPathController.php
File
- src/
Entity/ OpignoModule.php, line 70
Namespace
Drupal\opigno_module\EntityView source
class OpignoModule extends RevisionableContentEntityBase implements OpignoModuleInterface {
use EntityChangedTrait;
/**
* Static cache of user attempts.
*/
protected $userAttempts = [];
/**
* Static cache of user active attempt.
*/
protected $userActiveAttempt = [];
/**
* Static cache of user training active attempt.
*
* @var mixed
*/
protected $userTrainingActiveAttempt = [];
/**
* Static cache of activities.
*/
protected $activities = [];
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += [
'uid' => \Drupal::currentUser()
->id(),
];
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this
->get('name')->value;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this
->set('name', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public function getCreatedTime() {
return $this
->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this
->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getOwner() {
return $this
->get('uid')->entity;
}
/**
* {@inheritdoc}
*/
public function getOwnerId() {
return $this
->get('uid')->target_id;
}
/**
* {@inheritdoc}
*/
public function setOwnerId($uid) {
$this
->set('uid', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this
->set('uid', $account
->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function isPublished() {
return (bool) $this
->getEntityKey('status');
}
/**
* {@inheritdoc}
*/
public function setPublished($published) {
$this
->set('status', $published ? TRUE : FALSE);
return $this;
}
/**
* Get Module Randomization setting.
*/
public function getRandomization() {
return $this
->get('randomization')->value;
}
/**
* Get Module Backwards navigation setting.
*/
public function getBackwardsNavigation() {
return (bool) $this
->get('backwards_navigation')->value;
}
/**
* Get Allow resume setting.
*/
public function getAllowResume() {
return (bool) $this
->get('allow_resume')->value;
}
/**
* Get random activities count.
*/
public function getRandomActivitiesCount() {
return $this
->get('random_activities')->value;
}
/**
* Set random activities count.
*/
public function setRandomActivitiesCount($value) {
$this
->set('random_activities', $value);
return $this;
}
/**
* Get random activity score.
*/
public function getRandomActivityScore() {
return $this
->get('random_activity_score')->value;
}
/**
* Get skills activity of module.
*/
public function getSkillsActive() {
return $this
->get('skills_active')->value;
}
/**
* Get skills activity of module.
*/
public function getModuleSkillsGlobal() {
return $this
->get('module_global')->value;
}
/**
* Get target skill of module.
*/
public function getTargetSkill() {
return $this
->get('skill_target')->value;
}
/**
* Set random activities count.
*/
public function setRandomActivityScore($value) {
$this
->set('random_activity_score', $value);
return $this;
}
/**
* Get image entity.
*/
public function getModuleImage() {
$media = $this
->get('module_media_image')->entity;
if ($media) {
return $media
->get('field_media_image')->entity;
}
else {
return NULL;
}
}
/**
* Get hide results setting.
*/
public function getHideResults($answer = NULL) : bool {
// Show results for admins.
$account = \Drupal::currentUser();
if ($account
->hasPermission('view module results')) {
return FALSE;
}
$result = (bool) $this
->get('hide_results')->value;
if (!$answer instanceof OpignoAnswer) {
return $result;
}
// Load group.
// Check if user has role 'student manager' in a learning_path.
$user_module_status = $answer
->getUserModuleStatus();
if ($user_module_status instanceof UserModuleStatus && $user_module_status
->hasField('learning_path') && !empty($group = $user_module_status
->get('learning_path')->target_id) && LearningPathAccess::memberHasRole('user_manager', $account, $group)) {
return FALSE;
}
// Return selected value for others.
return $result;
}
/**
* Get feedback results options.
*/
public function getResultsOptions() {
/* @var $connection \Drupal\Core\Database\Connection */
$connection = \Drupal::service('database');
$select_query = $connection
->select('opigno_module_result_options', 'omro')
->fields('omro')
->condition('module_id', $this
->id())
->condition('module_vid', $this
->getRevisionId());
$options = $select_query
->execute()
->fetchAll();
return $options;
}
/**
* Insert feedback results options.
*/
public function insertResultsOptions(FormStateInterface $form_state) {
/* @var $connection \Drupal\Core\Database\Connection */
$connection = \Drupal::service('database');
$insert_query = $connection
->insert('opigno_module_result_options')
->fields([
'module_id',
'module_vid',
'option_name',
'option_summary',
'option_summary_format',
'option_start',
'option_end',
]);
$form_values = $form_state
->getValues();
foreach ($form_values['results_options'] as $option) {
if (!empty($option['option_name'])) {
if (is_array($option['option_summary'])) {
$option['option_summary_format'] = $option['option_summary']['format'];
$option['option_summary'] = $option['option_summary']['value'];
}
$insert_query
->values([
'module_id' => $this
->id(),
'module_vid' => $this
->getRevisionId(),
'option_name' => $option['option_name'],
'option_summary' => $option['option_summary'],
'option_summary_format' => $option['option_summary_format'],
'option_start' => $option['option_start'],
'option_end' => $option['option_end'],
]);
}
}
$insert_query
->execute();
}
/**
* Update feedback results options.
*/
public function updateResultsOptions(FormStateInterface $form_state) {
/* @var $connection \Drupal\Core\Database\Connection */
$connection = \Drupal::service('database');
// Remove existing options.
$connection
->delete('opigno_module_result_options')
->condition('module_id', $this
->id())
->condition('module_vid', $this
->getRevisionId())
->execute();
// Insert options.
$this
->insertResultsOptions($form_state);
}
/**
* Checks module availability.
*/
public function checkModuleAvailability() {
$availability = [
'open' => TRUE,
'message' => '',
];
$module_availability = 0;
$group_id = OpignoGroupContext::getCurrentGroupId();
$lp_module_availability = LPModuleAvailability::loadByProperties([
'group_id' => $group_id,
'entity_id' => $this
->id(),
]);
if ($lp_module_availability) {
$lp_module_availability = current($lp_module_availability);
$module_availability = $lp_module_availability
->getAvailability();
}
if ($module_availability) {
$open_date = $lp_module_availability
->getOpenDate();
$close_date = $lp_module_availability
->getCloseDate();
if ($open_date && $close_date) {
$quiz_open = \Drupal::time()
->getRequestTime() >= $open_date;
$quiz_closed = \Drupal::time()
->getRequestTime() >= $close_date;
}
if (isset($quiz_open) && isset($quiz_closed)) {
if (!$quiz_open || $quiz_closed) {
$message = '';
// Load Config.
$config = \Drupal::config('opigno_module.settings');
if ($quiz_closed) {
$message = $config
->get('availability_closed_message');
}
elseif (!$quiz_open) {
$message = $config
->get('availability_unavailable_message');
}
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$message = \Drupal::token()
->replace($message, [
'opigno_module' => $this,
]);
}
$availability = [
'open' => FALSE,
'message' => $message,
];
}
}
}
return $availability;
}
/**
* Get loaded statuses for specified user.
*/
public function getModuleAttempts(AccountInterface $user, $range = NULL, $latest_cert_date = NULL, $finished = FALSE) {
$key = $this
->id() . '_' . $user
->id();
$key_base = $key;
if (isset($range)) {
$key .= '_' . $range;
}
if (array_key_exists($key, $this->userAttempts)) {
return $this->userAttempts[$key];
}
$status_storage = static::entityTypeManager()
->getStorage('user_module_status');
$query = $status_storage
->getQuery();
$query
->condition('module', $this
->id())
->condition('user_id', $user
->id());
if ($finished) {
$query
->condition('finished', 0, '>');
}
if ($latest_cert_date) {
$query
->condition('started', $latest_cert_date, '>=');
}
$status_ids = $query
->execute();
if ($status_ids) {
$status_entities = $status_storage
->loadMultiple($status_ids);
$this->userAttempts[$key_base] = $status_entities;
// Figure out the 'last' and 'best' scores in PHP to avoid running three
// queries for potentially the same entity.
$max_id = max(array_keys($status_ids));
$this->userAttempts[$key_base . '_last'] = [
$max_id => $status_entities[$max_id],
];
$max_score = 0;
$best_entity = FALSE;
foreach ($status_entities as $entity) {
if ($entity
->getScore() >= $max_score) {
$max_score = $entity
->getScore();
$best_entity = $entity;
}
}
if (!$best_entity) {
$this->userAttempts[$key_base . '_best'] = [];
}
else {
$this->userAttempts[$key_base . '_best'] = [
$best_entity
->id() => $best_entity,
];
}
}
else {
$this->userAttempts[$key_base . '_best'] = [];
$this->userAttempts[$key_base . '_last'] = [];
}
return isset($this->userAttempts[$key]) ? $this->userAttempts[$key] : [];
}
/**
* Get entity if user didn't finish module.
*
* @param \Drupal\Core\Session\AccountInterface $user
* User entity object.
*
* @return \Drupal\Core\Entity\EntityInterface|null
* Entity interface.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function getModuleActiveAttempt(AccountInterface $user, $activity_link_type = NULL) {
$key = $this
->id() . '_' . $user
->id();
if ($activity_link_type == 'flow') {
// Used Opigno flow type of activity answer link.
if (array_key_exists($key, $this->userActiveAttempt)) {
return $this->userActiveAttempt[$key];
}
OpignoGroupContext::removeActivityLinkType();
}
else {
// Used activity answer manual/direct link.
if (array_key_exists($key, $this->userActiveAttempt) && !empty($this->userActiveAttempt[$key])) {
return $this->userActiveAttempt[$key];
}
elseif (!empty($this->userAttempts[$key . '_last'])) {
$last_attempt = reset($this->userAttempts[$key . '_last']);
$this->userActiveAttempt[$key] = $last_attempt;
return $last_attempt;
}
}
$status_storage = static::entityTypeManager()
->getStorage('user_module_status');
$query = $status_storage
->getQuery();
$module_statuses = $query
->condition('module', $this
->id())
->condition('user_id', $user
->id())
->condition('finished', 0)
->range(0, 1)
->execute();
$this->userActiveAttempt[$key] = !empty($module_statuses) ? $status_storage
->load(key($module_statuses)) : NULL;
return $this->userActiveAttempt[$key];
}
/**
* Get module attempt if user didn't finish training.
*
* @param \Drupal\user\Entity\User $user
* User entity.
* @return numeric
* Best score result.
*/
public function getBestScore(User $user) {
// For each attempt, check the score and save the best one.
$user_attempts = $this
->getModuleAttempts($user, 'best');
$best_score = 0;
/* @var \Drupal\opigno_module\Entity\UserModuleStatus $user_attempt */
foreach ($user_attempts as $user_attempt) {
// Get the scores.
$actual_score = $user_attempt
->getAttemptScore();
// Save the best score.
if ($actual_score > $best_score) {
$best_score = $actual_score;
}
}
return $best_score;
}
/**
* Implements opigno_module_get_user_module_score().
*
* @param \Drupal\Core\Session\AccountInterface $account
* User account object.
* @param int $latest_cert_date
* The last date when was attempt.
*
* @return int
* Score in percents depends of OpignoModule keep_results option.
*/
function getUserScore(AccountInterface $account, $latest_cert_date = NULL) {
$which_score_keep = $this
->getKeepResultsOption();
$attempts = $this
->getModuleAttempts($account, 'last', $latest_cert_date);
if (!$attempts) {
return 0;
}
/* @var \Drupal\opigno_module\Entity\UserModuleStatus $last_attempt */
$last_attempt = end($attempts);
$score = 0;
switch ($which_score_keep) {
// The newest score always saved in last attempt.
case 'newest':
$score = (int) $last_attempt
->getScore();
break;
// For these options get best score.
case 'best':
case 'all':
$score = (int) $last_attempt
->calculateBestScore($latest_cert_date);
break;
}
// Clamp score.
$score = max(0, $score);
$score = min(100, $score);
return $score;
}
/**
* Get training attempt if user didn't finish training.
*
* @param \Drupal\Core\Session\AccountInterface $user
* User entity object.
* @param \Drupal\group\Entity\Group $group
* Group object.
*
* @return \Drupal\Core\Entity\EntityInterface|null
* Entity interface.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function getTrainingActiveAttempt(AccountInterface $user, Group $group) {
$key = $group
->id() . '_' . $user
->id();
if (array_key_exists($key, $this->userTrainingActiveAttempt)) {
return $this->userTrainingActiveAttempt[$key];
}
$status_storage = static::entityTypeManager()
->getStorage('user_lp_status');
$query = $status_storage
->getQuery();
$training_statuses = $query
->condition('gid', $group
->id())
->condition('uid', $user
->id())
->condition('finished', 0)
->range(0, 1)
->execute();
$this->userTrainingActiveAttempt[$key] = !empty($training_statuses) ? $status_storage
->load(key($training_statuses)) : NULL;
return $this->userTrainingActiveAttempt[$key];
}
/**
* Get activities related to specific module.
*/
public function getModuleActivities($full = FALSE) {
if (empty($this->activities)) {
/* @todo join table with activity revisions */
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$query = $db_connection
->select('opigno_activity', 'oa');
$query
->fields('oafd', [
'id',
'vid',
'type',
'name',
'usage_activity',
'skills_list',
'skill_level',
]);
$query
->fields('omr', [
'activity_status',
'weight',
'max_score',
'auto_update_max_score',
'omr_id',
'omr_pid',
'child_id',
'child_vid',
]);
$query
->addJoin('inner', 'opigno_activity_field_data', 'oafd', 'oa.id = oafd.id');
$query
->addJoin('inner', 'opigno_module_relationship', 'omr', 'oa.id = omr.child_id');
$query
->condition('oafd.status', 1);
$query
->condition('omr.parent_id', $this
->id());
if ($this
->getRevisionId()) {
$query
->condition('omr.parent_vid', $this
->getRevisionId());
}
$query
->condition('omr_pid', NULL, 'IS');
$query
->orderBy('omr.weight');
$query
->orderBy('omr.omr_id');
$result = $query
->execute();
foreach ($result as $activity) {
$this->activities[$activity->id] = $activity;
}
}
// Load entities if full was requested.
if ($full && !empty($this->activities)) {
$activity_ids = [];
foreach ($this->activities as $activity) {
$activity_ids[$activity->id] = $activity->id;
}
return OpignoActivity::loadMultiple($activity_ids);
}
return $this->activities;
}
/**
* Get activities related to specific skills.
*/
public function getSuitableActivities($current_skills) {
if (empty($current_skills)) {
return [
0 => 0,
];
}
$activities = [];
/* @var $db_connection \Drupal\Core\Database\Connection */
$db_connection = \Drupal::service('database');
$query = $db_connection
->select('opigno_activity', 'oa');
$query
->fields('oafd', [
'id',
'vid',
'type',
'name',
'usage_activity',
'skills_list',
'skill_level',
]);
$query
->addJoin('inner', 'opigno_activity_field_data', 'oafd', 'oa.id = oafd.id');
$query
->condition('oafd.status', 1);
$query
->condition('oafd.skills_list', $current_skills, 'IN');
$query
->condition('oafd.usage_activity', 'global');
$result = $query
->execute();
foreach ($result as $activity) {
$activities[$activity->id] = $activity;
}
return $activities;
}
/**
* Get answers of the specific user within specified attempt.
*
* @param \Drupal\Core\Session\AccountInterface $user
* User account.
* @param \Drupal\opigno_module\Entity\UserModuleStatusInterface $attempt
* User module attempt object.
*
* @return array|\Drupal\Core\Entity\EntityInterface|null
* User answers objects.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function userAnswers(AccountInterface $user, UserModuleStatusInterface $attempt) {
$answers_storage = static::entityTypeManager()
->getStorage('opigno_answer');
$query = $answers_storage
->getQuery();
$answers = $query
->condition('module', $this
->id())
->condition('user_id', $user
->id())
->condition('user_module_status', $attempt
->id())
->execute();
return !empty($answers) ? $answers_storage
->loadMultiple($answers) : [];
}
/**
* Returns random activity.
*/
public function getRandomActivity(UserModuleStatusInterface $attempt) {
// Need to get activity that was not answered yet in this attempt.
// Take all the activities.
$activities = $this
->getModuleActivities();
$activities_storage = static::entityTypeManager()
->getStorage('opigno_activity');
$randomization = $this
->getRandomization();
$random_count = $this
->getRandomActivitiesCount();
$answered_random = 0;
// Take answers within attempt.
$user_answers = $this
->userAnswers(\Drupal::currentUser(), $attempt);
if (!empty($user_answers)) {
foreach ($user_answers as $answer) {
$answer_activity = $answer
->getActivity();
// Unset answered activity if answer already exist.
if (isset($activities[$answer_activity
->id()])) {
if ($randomization == 2) {
$answered_random++;
}
unset($activities[$answer_activity
->id()]);
}
}
}
if ($randomization == 2) {
$assigned_random = $activities;
$activities = [];
if (!empty($assigned_random) && $random_count > $answered_random) {
$required_random = $random_count - $answered_random;
$random_activities = array_rand($assigned_random, $required_random);
if (is_array($random_activities)) {
foreach ($random_activities as $random_activity) {
$activities[$random_activity] = $assigned_random[$random_activity];
}
}
else {
$activities[$random_activities] = $assigned_random[$random_activities];
}
}
}
return !empty($activities) ? $activities_storage
->load(array_rand($activities, 1)) : FALSE;
}
/**
* Get option to know which result need to be saved on Database.
*
* @return string
* Return string "best", "newest" or "all"
*/
public function getKeepResultsOption() {
$keep_results_options = [
0 => 'best',
1 => 'newest',
2 => 'all',
];
$option = $this
->get('keep_results')->value;
return $keep_results_options[$option];
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the Module entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the Module entity.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setRequired(TRUE)
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue(NULL)
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['module_media_image'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Image'))
->setDescription(t('Set here a module image'))
->setRevisionable(TRUE)
->setTranslatable(FALSE)
->setRequired(FALSE)
->setSetting('target_type', 'media')
->setSetting('handler', 'default')
->setSetting('handler_settings', [
'target_bundles' => [
'image',
],
])
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'media_thumbnail',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_browser_entity_reference',
'weight' => 26,
'settings' => [
'entity_browser' => 'media_entity_browser_groups',
'field_widget_display' => 'rendered_entity',
'field_widget_remove' => TRUE,
'open' => TRUE,
'selection_mode' => 'selection_append',
'field_widget_display_settings' => [
'view_mode' => 'image_only',
],
'field_widget_edit' => FALSE,
'field_widget_replace' => FALSE,
'third_party_settings' => [
'type' => 'entity_browser_entity_reference',
],
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['description'] = BaseFieldDefinition::create('text_long')
->setLabel(t('Description'))
->setDefaultValue('')
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setRequired(FALSE)
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
])
->setDisplayOptions('form', [
'type' => 'text_long',
'weight' => 3,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Module is published.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Authored on'))
->setDescription(t('The time that the Module was created.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'timestamp',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'datetime_timestamp',
'weight' => 10,
])
->setDisplayConfigurable('form', TRUE);
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the Module was last edited.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE);
$fields['random_activity_score'] = BaseFieldDefinition::create('integer')
->setLabel(t('Random activity score'))
->setDescription(t('Score per each random activity.'))
->setRevisionable(TRUE)
->setDefaultValue(1);
$fields['allow_resume'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Allow resume'))
->setDescription(t('Allow users to leave this Module incomplete and then resume it from where they left off.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => 1,
]);
$fields['backwards_navigation'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Backwards navigation'))
->setDescription(t('Allow users to go back and revisit activities already answered.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => 2,
]);
$randomization_options = [
0 => t('No randomization'),
1 => t('Random order'),
2 => t('Random activities'),
];
$randomization_description = t("<strong>Random order</strong> - all questions display in random order") . '<br/>' . t("<strong>Random activities</strong> - specific number of activities are drawn randomly from this module's pool of questions");
$fields['randomization'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Randomize activities'))
->setDescription($randomization_description)
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setSetting('allowed_values', $randomization_options)
->setDefaultValue(0)
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'options_buttons',
'weight' => 3,
]);
$fields['random_activities'] = BaseFieldDefinition::create('integer')
->setLabel(t('Number of random activities'))
->setDescription(t('The number of activities to be randomly selected each time someone takes this module.'))
->setRevisionable(TRUE)
->setDefaultValue(1)
->setDisplayOptions('form', [
'type' => 'options_buttons',
'weight' => 4,
]);
$takes_options = [
t('Unlimited'),
];
for ($i = 1; $i < 10; $i++) {
$takes_options[$i] = $i;
}
$fields['takes'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Allowed number of attempts'))
->setDescription(t('The number of times a user is allowed to take this Module. <strong>Anonymous users are only allowed to take Module that allow an unlimited number of attempts.</strong>'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setSetting('allowed_values', $takes_options)
->setDefaultValue(0)
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'options_buttons',
'weight' => 4,
]);
$fields['show_attempt_stats'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Display allowed number of attempts'))
->setDescription(t('Display the allowed number of attempts on the starting page for this Module.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => 5,
]);
$keep_results_options = [
0 => t('The best'),
1 => t('The newest'),
2 => t('All'),
];
$fields['keep_results'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Store results'))
->setDescription(t('These results should be stored for each user.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setSetting('allowed_values', $keep_results_options)
->setDefaultValue(2)
->setRequired(TRUE)
->setDisplayOptions('form', [
'type' => 'options_buttons',
'weight' => 6,
]);
$fields['hide_results'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Do not display results at the end of the module'))
->setDescription(t('If you check this option, the correct answers won’t be displayed to the users at the end of the module.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(FALSE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => 2,
]);
$fields['badge_active'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Activate badge system for this module'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(FALSE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => 1,
]);
$fields['badge_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 1,
]);
$fields['badge_description'] = BaseFieldDefinition::create('string_long')
->setLabel(t('Badge description'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setRequired(FALSE)
->setDefaultValue('')
->setDisplayOptions('form', [
'type' => 'string_textarea',
'weight' => 2,
'settings' => [
'rows' => 3,
],
]);
$options = [
'finished' => 'Finished',
'success' => 'Success',
];
$fields['badge_criteria'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Badge criteria'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue('finished')
->setSetting('allowed_values', $options)
->setDisplayOptions('form', [
'type' => 'options_buttons',
'weight' => 3,
]);
$fields['badge_media_image'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Badge image'))
->setRevisionable(TRUE)
->setTranslatable(FALSE)
->setSetting('target_type', 'media')
->setSetting('handler', 'default')
->setSetting('handler_settings', [
'target_bundles' => [
'image_png',
],
])
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'media_thumbnail',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_browser_entity_reference',
'weight' => 4,
'settings' => [
'entity_browser' => 'media_entity_browser_badge_images',
'field_widget_display' => 'rendered_entity',
'field_widget_remove' => TRUE,
'open' => TRUE,
'selection_mode' => 'selection_append',
'field_widget_display_settings' => [
'view_mode' => 'image_only',
],
'field_widget_edit' => FALSE,
'field_widget_replace' => FALSE,
'third_party_settings' => [
'type' => 'entity_browser_entity_reference',
],
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['skills_active'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Activate skills system for this module'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(FALSE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => 1,
]);
$term_storage = \Drupal::entityTypeManager()
->getStorage('taxonomy_term');
$target_skills = $term_storage
->loadTree('skills', 0, 1);
$options = [];
foreach ($target_skills as $row) {
$options[$row->tid] = $row->name;
}
$fields['skill_target'] = BaseFieldDefinition::create('list_string')
->setLabel(t('Target skill'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setSetting('allowed_values', $options)
->setDisplayOptions('form', [
'type' => 'options_select',
'weight' => 3,
]);
$fields['module_global'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Use all suitable activities from Opigno system'))
->setDescription(t('If checked then Opigno system will load all suitable activities from other trainings and not assigned activities.'))
->setRevisionable(TRUE)
->setTranslatable(TRUE)
->setDefaultValue(FALSE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => 4,
]);
return $fields;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
ContentEntityBase:: |
protected | property | Language code identifying the entity active language. | |
ContentEntityBase:: |
protected | property | Local cache for the default language code. | |
ContentEntityBase:: |
protected | property | The default langcode entity key. | |
ContentEntityBase:: |
protected | property | Whether the revision translation affected flag has been enforced. | |
ContentEntityBase:: |
protected | property | Holds untranslatable entity keys such as the ID, bundle, and revision ID. | |
ContentEntityBase:: |
protected | property | Local cache for field definitions. | |
ContentEntityBase:: |
protected | property | The array of fields, each being an instance of FieldItemListInterface. | |
ContentEntityBase:: |
protected static | property | Local cache for fields to skip from the checking for translation changes. | |
ContentEntityBase:: |
protected | property | Indicates whether this is the default revision. | |
ContentEntityBase:: |
protected | property | The language entity key. | |
ContentEntityBase:: |
protected | property | Local cache for the available language objects. | |
ContentEntityBase:: |
protected | property | The loaded revision ID before the new revision was set. | |
ContentEntityBase:: |
protected | property | Boolean indicating whether a new revision should be created on save. | |
ContentEntityBase:: |
protected | property | The revision translation affected entity key. | |
ContentEntityBase:: |
protected | property | Holds translatable entity keys such as the label. | |
ContentEntityBase:: |
protected | property | A flag indicating whether a translation object is being initialized. | |
ContentEntityBase:: |
protected | property | An array of entity translation metadata. | |
ContentEntityBase:: |
protected | property | Whether entity validation was performed. | |
ContentEntityBase:: |
protected | property | Whether entity validation is required before saving the entity. | |
ContentEntityBase:: |
protected | property | The plain data values of the contained fields. | |
ContentEntityBase:: |
public | function |
Checks data value access. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Adds a new translation to the translatable object. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
public static | function |
Provides field definitions for a specific bundle. Overrides FieldableEntityInterface:: |
4 |
ContentEntityBase:: |
protected | function | Clear entity translation object cache to remove stale references. | |
ContentEntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Gets a field item list. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets the value of the given entity key, if defined. | 1 |
ContentEntityBase:: |
public | function |
Gets the definition of a contained field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all field item lists. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Returns an array of field names to skip in ::hasTranslationChanges. | 1 |
ContentEntityBase:: |
public | function | ||
ContentEntityBase:: |
protected | function | ||
ContentEntityBase:: |
public | function |
Gets the loaded Revision ID of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the revision identifier of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets a translated field. | |
ContentEntityBase:: |
public | function |
Gets a translation of the data. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the languages the data is translated to. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation status. Overrides TranslationStatusInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translatable object referring to the original language. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks there is a translation for the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the identifier. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Instantiates a translation object for an existing translation. | |
ContentEntityBase:: |
public | function |
Checks if this entity is the default revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is the default one. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if this entity is the latest revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether a new revision should be created on save. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is new. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation support status. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the label of the entity. Overrides EntityBase:: |
2 |
ContentEntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Reacts to changes to a field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Acts on a created entity before hooks are invoked. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase:: |
5 |
ContentEntityBase:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides EntityBase:: |
5 |
ContentEntityBase:: |
public | function |
Acts on a revision before it gets saved. Overrides RevisionableInterface:: |
2 |
ContentEntityBase:: |
public | function |
Gets a list of entities referenced by this entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Removes the translation identified by the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets a field value. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Populates the local cache for the default language code. | |
ContentEntityBase:: |
public | function |
Enforces an entity to be saved as a new revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Updates language for already instantiated fields. | |
ContentEntityBase:: |
public | function |
Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Updates the original values with the interim changes. | |
ContentEntityBase:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Validates the currently set values. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Magic method: Implements a deep clone. | |
ContentEntityBase:: |
public | function |
Constructs an Entity object. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for getting object properties. | |
ContentEntityBase:: |
public | function | Implements the magic method for isset(). | |
ContentEntityBase:: |
public | function | Implements the magic method for setting object properties. | |
ContentEntityBase:: |
public | function |
Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for unset(). | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: traitSleep | 1 |
DependencySerializationTrait:: |
public | function | 2 | |
EntityBase:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
EntityBase:: |
protected | property | The entity type. | |
EntityBase:: |
protected | property | A typed data object wrapping this entity. | |
EntityBase:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Deletes an entity permanently. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Enforces an entity to be new. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets the entity manager. | |
EntityBase:: |
protected | function | Gets the entity type bundle info service. | |
EntityBase:: |
protected | function | Gets the entity type manager. | |
EntityBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the entity type definition. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the ID of the type of the entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | The list cache tags to invalidate for this entity. | |
EntityBase:: |
public | function |
Gets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets a typed data object for this entity object. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Indicates if a link template exists for a given key. Overrides EntityInterface:: |
|
EntityBase:: |
protected static | function | Invalidates an entity's cache tags upon delete. | 1 |
EntityBase:: |
protected | function | Invalidates an entity's cache tags upon save. | 1 |
EntityBase:: |
public | function |
Determines whether the entity is new. Overrides EntityInterface:: |
2 |
EntityBase:: |
protected | function | Gets the language manager. | |
EntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array link templates. | 1 |
EntityBase:: |
public static | function |
Loads an entity. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Loads one or more entities. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface:: |
16 |
EntityBase:: |
public static | function |
Acts on loaded entities. Overrides EntityInterface:: |
2 |
EntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public | function |
Saves an entity permanently. Overrides EntityInterface:: |
3 |
EntityBase:: |
public | function |
Sets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array of placeholders for this entity. | 2 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
EntityChangedTrait:: |
public | function | Gets the timestamp of the last entity change for the current translation. | |
EntityChangedTrait:: |
public | function | Returns the timestamp of the last entity change across all translations. | |
EntityChangedTrait:: |
public | function | Sets the timestamp of the last entity change for the current translation. | |
EntityChangesDetectionTrait:: |
protected | function | Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck | |
OpignoModule:: |
protected | property | Static cache of activities. | |
OpignoModule:: |
protected | property | Static cache of user active attempt. | |
OpignoModule:: |
protected | property | Static cache of user attempts. | |
OpignoModule:: |
protected | property | Static cache of user training active attempt. | |
OpignoModule:: |
public static | function |
Provides base field definitions for an entity type. Overrides RevisionableContentEntityBase:: |
|
OpignoModule:: |
public | function | Checks module availability. | |
OpignoModule:: |
public | function | Get Allow resume setting. | |
OpignoModule:: |
public | function | Get Module Backwards navigation setting. | |
OpignoModule:: |
public | function | Get module attempt if user didn't finish training. | |
OpignoModule:: |
public | function |
Gets the Module creation timestamp. Overrides OpignoModuleInterface:: |
|
OpignoModule:: |
public | function | Get hide results setting. | |
OpignoModule:: |
public | function | Get option to know which result need to be saved on Database. | |
OpignoModule:: |
public | function | Get entity if user didn't finish module. | |
OpignoModule:: |
public | function | Get activities related to specific module. | |
OpignoModule:: |
public | function | Get loaded statuses for specified user. | |
OpignoModule:: |
public | function | Get image entity. | |
OpignoModule:: |
public | function | Get skills activity of module. | |
OpignoModule:: |
public | function |
Gets the Module name. Overrides OpignoModuleInterface:: |
|
OpignoModule:: |
public | function |
Returns the entity owner's user entity. Overrides EntityOwnerInterface:: |
|
OpignoModule:: |
public | function |
Returns the entity owner's user ID. Overrides EntityOwnerInterface:: |
|
OpignoModule:: |
public | function | Get random activities count. | |
OpignoModule:: |
public | function | Returns random activity. | |
OpignoModule:: |
public | function | Get random activity score. | |
OpignoModule:: |
public | function | Get Module Randomization setting. | |
OpignoModule:: |
public | function | Get feedback results options. | |
OpignoModule:: |
public | function | Get skills activity of module. | |
OpignoModule:: |
public | function | Get activities related to specific skills. | |
OpignoModule:: |
public | function | Get target skill of module. | |
OpignoModule:: |
public | function | Get training attempt if user didn't finish training. | |
OpignoModule:: |
function | Implements opigno_module_get_user_module_score(). | ||
OpignoModule:: |
public | function | Insert feedback results options. | |
OpignoModule:: |
public | function |
Returns the Module published status indicator. Overrides OpignoModuleInterface:: |
|
OpignoModule:: |
public static | function |
Changes the values of an entity before it is created. Overrides EntityBase:: |
|
OpignoModule:: |
public | function |
Sets the Module creation timestamp. Overrides OpignoModuleInterface:: |
|
OpignoModule:: |
public | function |
Sets the Module name. Overrides OpignoModuleInterface:: |
|
OpignoModule:: |
public | function |
Sets the entity owner's user entity. Overrides EntityOwnerInterface:: |
|
OpignoModule:: |
public | function |
Sets the entity owner's user ID. Overrides EntityOwnerInterface:: |
|
OpignoModule:: |
public | function |
Sets the published status of a Module. Overrides OpignoModuleInterface:: |
|
OpignoModule:: |
public | function | Set random activities count. | |
OpignoModule:: |
public | function | Set random activities count. | |
OpignoModule:: |
public | function | Update feedback results options. | |
OpignoModule:: |
public | function | Get answers of the specific user within specified attempt. | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionCreationTime(). | 1 |
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionLogMessage(). | 1 |
RevisionLogEntityTrait:: |
protected static | function | Gets the name of a revision metadata field. | |
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionUser(). | 1 |
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::getRevisionUserId(). | 1 |
RevisionLogEntityTrait:: |
public static | function | Provides revision-related base field definitions for an entity type. | |
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionCreationTime(). | 1 |
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionLogMessage(). | 1 |
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionUser(). | 1 |
RevisionLogEntityTrait:: |
public | function | Implements \Drupal\Core\Entity\RevisionLogInterface::setRevisionUserId(). | 1 |
SynchronizableEntityTrait:: |
protected | property | Whether this entity is being created, updated or deleted through a synchronization process. | |
SynchronizableEntityTrait:: |
public | function | ||
SynchronizableEntityTrait:: |
public | function | ||
TranslationStatusInterface:: |
constant | Status code identifying a newly created translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying an existing translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying a removed translation. |