You are here

class OpignoAnswerForm in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Form/OpignoAnswerForm.php \Drupal\opigno_module\Form\OpignoAnswerForm

Form controller for Answer edit forms.

Hierarchy

Expanded class hierarchy of OpignoAnswerForm

File

src/Form/OpignoAnswerForm.php, line 22

Namespace

Drupal\opigno_module\Form
View source
class OpignoAnswerForm extends ContentEntityForm {

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    /* @var $entity \Drupal\opigno_module\Entity\OpignoAnswer */
    $form = parent::buildForm($form, $form_state);

    // Hide revision_log_message field.
    unset($form['revision_log_message']);
    $entity = $this->entity;
    $activity = $entity
      ->getActivity();

    /** @var \Drupal\opigno_module\Entity\OpignoModule $module */
    $module = $entity
      ->getModule();
    $form['activity'] = [
      '#type' => 'label',
      '#title' => $activity->value,
    ];
    $form['module'] = [
      '#type' => 'label',
      '#title' => $module->value,
    ];

    // Backwards navigation.
    $form['actions']['back'] = [
      '#type' => 'submit',
      '#value' => $this
        ->t('Back'),
      '#submit' => [
        '::backwardsNavigation',
      ],
    ];

    // Check for enabled option.
    // Also check that user already has at least 1 answered activity.
    // Check that user is not on the first activity in the module.
    $activity_link_type = OpignoGroupContext::getActivityLinkType();
    $attempt = $module
      ->getModuleActiveAttempt($this
      ->currentUser(), $activity_link_type);
    if ($attempt !== NULL) {
      $activities = $module
        ->getModuleActivities();
      $first_activity = reset($activities);
      $first_activity = $first_activity !== FALSE ? OpignoActivity::load($first_activity->id) : NULL;
      $current_activity = \Drupal::routeMatch()
        ->getParameter('opigno_activity');
      $has_first_activity = $first_activity !== NULL;
      $has_current_activity = $current_activity !== NULL;
      $is_on_first_activity = $has_first_activity && $has_current_activity && $first_activity
        ->id() === $current_activity
        ->id();

      // Disable back navigation for first content first activity.
      $cid = OpignoGroupContext::getCurrentGroupContentId();
      if ($cid) {
        $content = OpignoGroupManagedContent::load($cid);
        $parents = $content
          ->getParentsLinks();
        if (!$module
          ->getBackwardsNavigation() || empty($parents) && $is_on_first_activity) {
          $form['actions']['back']['#attributes']['disabled'] = TRUE;
        }
      }
    }
    else {
      $form['actions']['back']['#access'] = FALSE;
      $form['actions']['submit']['#access'] = FALSE;
    }

    /* @var $answer_service \Drupal\opigno_module\ActivityAnswerManager */
    $answer_service = \Drupal::service('plugin.manager.activity_answer');
    $answer_activity_type = $activity
      ->getType();
    if ($answer_service
      ->hasDefinition($answer_activity_type)) {
      $answer_instance = $answer_service
        ->createInstance($answer_activity_type);
      $answer_instance
        ->answeringForm($form);
    }

    // Remove 'delete' button.
    unset($form['actions']['delete']);
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    $entity =& $this->entity;
    $activity = $entity
      ->getActivity();
    $module = $entity
      ->getModule();
    $attempt = $module
      ->getModuleActiveAttempt($this
      ->currentUser());
    $moduleHandler = \Drupal::service('module_handler');
    $activities = $module
      ->getModuleActivities();
    if ($attempt !== NULL) {
      $attempt
        ->setLastActivity($activity);
      $entity
        ->setUserModuleStatus($attempt);

      // Check if answer should be evaluated or not.
      // Make it possible to modify answer object before save.

      /* @var $answer_service \Drupal\opigno_module\ActivityAnswerManager */
      $answer_service = \Drupal::service('plugin.manager.activity_answer');
      $answer_activity_type = $activity
        ->getType();
      if ($answer_service
        ->hasDefinition($answer_activity_type)) {
        $answer_instance = $answer_service
          ->createInstance($answer_activity_type);

        // Evaluation status.
        $evaluated_status = $answer_instance
          ->evaluatedOnSave($activity) ? 1 : 0;

        // Answer score.
        if ($activity
          ->hasField('opigno_evaluation_method') && $activity
          ->get('opigno_evaluation_method')->value) {
          $score = 0;
        }
        else {
          $score = $answer_instance
            ->getScore($entity);
        }

        // Calculate score for skills system if activity not included in the current module.
        // Activity type H5P.
        if ($moduleHandler
          ->moduleExists('opigno_skills_system') && $module
          ->getSkillsActive() == 1 && $activity
          ->getType() == 'opigno_h5p') {
          $h5p_score = $form_state
            ->getValue('score');
          $percent_score = $h5p_score / 1.234 - 32.17;
          $score = round($percent_score * 10);
          if ($score < 0) {
            $score = 0;
          }
        }
        $entity
          ->setScore(round($score));
      }

      // Set evaluation status.
      if (isset($evaluated_status)) {
        $entity
          ->setEvaluated($evaluated_status);
      }

      // $entity->save();
      $attempt
        ->save();
    }
    if ($moduleHandler
      ->moduleExists('opigno_skills_system')) {

      // Set skill ID.
      $skill_id = $activity
        ->getSkillId();
      if (!empty($skill_id)) {
        $entity
          ->setSkillId($skill_id);
      }

      // Set skill level.
      $skill_level = $activity
        ->getSkillLevel();
      if (!empty($skill_level)) {
        $entity
          ->setSkillLevel($skill_level);
      }
    }
    $status = parent::save($form, $form_state);
    switch ($status) {
      case SAVED_NEW:
      case SAVED_UPDATED:
        break;
      default:
        \Drupal::messenger()
          ->addMessage($this
          ->t('Saved the %label Answer.', [
          '%label' => $entity
            ->id(),
        ]));
    }
    if ($activity
      ->getType() == 'opigno_scorm') {
      $form_state
        ->set('scorm_answer', $entity);
    }
    $args = [
      'opigno_module' => $module
        ->id(),
    ];
    $current_group = \Drupal::routeMatch()
      ->getParameter('group');
    if ($current_group) {
      $args['group'] = $current_group
        ->id();
    }
    else {
      $args['group'] = OpignoGroupContext::getCurrentGroupId();
    }

    // Query param is used to detect if we go to take page
    // from submitted answer.
    $form_state
      ->setRedirect('opigno_module.take_module', $args, [
      'query' => [
        'continue' => TRUE,
      ],
    ]);

    // Calculate skills statistic.
    if ($moduleHandler
      ->moduleExists('opigno_skills_system') && !empty($skill_level) && !empty($skill_id)) {
      $db_connection = \Drupal::service('database');
      $uid = $this
        ->currentUser()
        ->id();
      $term_storage = \Drupal::entityTypeManager()
        ->getStorage('taxonomy_term');
      $skill_entity = $term_storage
        ->load($skill_id);
      if ($skill_entity != NULL) {
        $minimum_score = $skill_entity
          ->get('field_minimum_score')
          ->getValue()[0]['value'];
        $minimum_answers = $skill_entity
          ->get('field_minimum_count_of_answers')
          ->getValue()[0]['value'];
        $skill_level = $activity
          ->getSkillLevel();

        // Get initial level. This is equal to the count of levels.
        $initial_level = count($skill_entity
          ->get('field_level_names')
          ->getValue());
        $initial_level = $initial_level === 0 ? 1 : $initial_level;

        // Get current user's skills.
        $query = $db_connection
          ->select('opigno_skills_statistic', 'o_s_s');
        $query
          ->fields('o_s_s', [
          'tid',
          'score',
          'progress',
          'stage',
        ]);
        $query
          ->condition('o_s_s.uid', $uid);
        $query
          ->condition('o_s_s.tid', $skill_id);
        $user_skills = $query
          ->execute()
          ->fetchAllAssoc('tid');

        // Get current level of user's skill.
        if (isset($user_skills[$skill_id]) && $user_skills[$skill_id]->stage == $skill_level) {
          $current_stage = $user_skills[$skill_id]->stage;
        }
        elseif (isset($skill_level) || !$module
          ->getSkillsActive()) {
          $current_stage = $skill_level;
        }
        else {
          $current_stage = $initial_level;
        }
        $stage = $current_stage;

        // Get last user's answers on questions for current skill.
        $query = $db_connection
          ->select('opigno_answer_field_data', 'o_a_f_d');
        $query
          ->addExpression('MAX(o_a_f_d.score)', 'score');
        $query
          ->addExpression('MAX(o_a_f_d.changed)', 'changed');
        $query
          ->addExpression('MAX(o_a_f_d.skill_level)', 'skill_level');
        $query
          ->addField('o_a_f_d', 'activity');
        $query
          ->condition('o_a_f_d.user_id', $uid)
          ->condition('o_a_f_d.skills_mode', $skill_id);
        $all_answers = $query
          ->groupBy('o_a_f_d.activity')
          ->orderBy('changed', 'DESC')
          ->execute()
          ->fetchAllAssoc('activity');
        $activity_ids = array_keys($all_answers);

        // Get max score of questions for skill.
        $query = $db_connection
          ->select('opigno_module_relationship', 'o_m_r');
        $query
          ->fields('o_m_r', [
          'child_id',
          'max_score',
        ]);
        $query
          ->condition('o_m_r.parent_id', $module
          ->id());
        $query
          ->condition('o_m_r.parent_vid', $module
          ->getRevisionId());
        $query
          ->condition('o_m_r.child_id', $activity_ids, 'IN');
        $max_scores = $query
          ->execute()
          ->fetchAllAssoc('child_id');

        // Get last user's answers for each level of skill.
        $answers = [];
        $answer_count_for_levels = [];

        // Check the level of skill.
        while ($current_stage > 0) {
          $count_answers_for_stage = 0;
          $avg_score = 0;
          foreach ($all_answers as $key => $answer) {
            if ($answer->skill_level == $current_stage) {
              $answers[$answer->activity] = $answer;
              $count_answers_for_stage++;
              if (!isset($max_scores[$key]->max_score)) {
                $max_scores[$key]->max_score = 10;
              }
              $avg_score += $answer->score / $max_scores[$key]->max_score;
              if ($count_answers_for_stage >= $minimum_answers) {
                $answer_count_for_levels[$current_stage]['access'] = TRUE;
                $avg_score = round($avg_score / $minimum_answers * 100);
                $answer_count_for_levels[$current_stage]['avg_score'] = $avg_score;
                if ($current_stage > $stage) {
                  $stage = $current_stage;
                }
                break;
              }
            }
          }
          $current_stage--;
        }

        // Get average score and current progress of skill.
        $avg_score = 0;
        $current_progress = 0;
        $count_of_levels = $initial_level;

        //      $current_progress = round (count($answers) / $minimum_answers / $count_of_levels * 100);
        foreach ($answers as $key => $answer) {
          if (!isset($max_scores[$key]->max_score)) {
            $max_scores[$key]->max_score = 10;
          }
          $avg_score += $answer->score / $max_scores[$key]->max_score;
        }
        $avg_score = round($avg_score / count($answers) * 100);

        // Update user's skill statistic.
        $keys = [
          'tid' => $skill_id,
          'uid' => $uid,
        ];

        // Check if the user is ready to level-up the skill.
        if (!empty($user_skills) || $minimum_answers == 1) {
          if (!empty($answer_count_for_levels[$stage]) && $answer_count_for_levels[$stage]['access'] == TRUE && $answer_count_for_levels[$stage]['avg_score'] >= $minimum_score) {
            $stage--;
          }
          elseif (isset($user_skills[$skill_id])) {
            $stage = $user_skills[$skill_id]->stage;
          }
        }
        else {
          $stage = $initial_level;
        }

        // Set current progress
        $current_progress = 100 - round($stage / $initial_level * 100);
        $fields = [
          'score' => $avg_score,
          'progress' => $current_progress,
          'stage' => $stage,
        ];
        $query = \Drupal::database()
          ->merge('opigno_skills_statistic')
          ->keys($keys)
          ->fields($fields)
          ->execute();

        // Check if user successfully finished skills tree.
        $target_skill = $module
          ->getTargetSkill();
        $term_storage = \Drupal::entityTypeManager()
          ->getStorage('taxonomy_term');
        $skills_tree = array_reverse($term_storage
          ->loadTree('skills', $target_skill));

        // Get current user's skills.
        $uid = $this
          ->currentUser()
          ->id();
        $query = $db_connection
          ->select('opigno_skills_statistic', 'o_s_s');
        $query
          ->fields('o_s_s', [
          'tid',
          'score',
          'progress',
          'stage',
        ]);
        $query
          ->condition('o_s_s.uid', $uid);
        $user_skills = $query
          ->execute()
          ->fetchAllAssoc('tid');

        // Set default successfully finished this skills tree for user.
        // If the system finds any skill which is not successfully finished then change this variable to FALSE.
        $successfully_finished = TRUE;
        $sum_score = 0;
        foreach ($skills_tree as $key => $skill) {
          $term_storage = \Drupal::entityTypeManager()
            ->getStorage('taxonomy_term');
          $skill_entity = $term_storage
            ->load($skill->tid);
          $minimum_score = $skill_entity
            ->get('field_minimum_score')
            ->getValue()[0]['value'];
          if (!isset($user_skills[$skill->tid])) {
            $successfully_finished = FALSE;
          }
          else {
            $sum_score += $user_skills[$skill->tid]->score;

            // Check if the skill was successfully finished.
            if ($minimum_score > $user_skills[$skill->tid]->score || $user_skills[$skill->tid]->progress < 100) {
              $successfully_finished = FALSE;
            }
          }
        }
        $gid = OpignoGroupContext::getCurrentGroupId();
        $uid = $this
          ->currentUser()
          ->id();
        $steps = LearningPathContent::getAllStepsOnlyModules($gid, $uid);

        // Search for parent.
        $current_step = [];
        foreach ($steps as $step) {
          if ($cid = $step['cid']) {
            $current_step = $step;
            break;
          }
        }
        $activities_from_module = $module
          ->getModuleActivities();
        $count_of_activities = count($activities_from_module);
        $activity_ids = array_keys($activities_from_module);
        $query = $db_connection
          ->select('opigno_answer_field_data', 'o_a_f_d');
        $query
          ->leftJoin('opigno_module_relationship', 'o_m_r', 'o_a_f_d.activity = o_m_r.child_id');
        $query
          ->addExpression('MAX(o_a_f_d.score)', 'score');
        $query
          ->addExpression('MAX(o_a_f_d.changed)', 'changed');
        $query
          ->addExpression('MAX(o_a_f_d.skill_level)', 'skill_level');
        $query
          ->addField('o_a_f_d', 'activity');
        $query
          ->condition('o_a_f_d.user_id', $uid)
          ->condition('o_a_f_d.module', $module
          ->id());
        if (!$module
          ->getModuleSkillsGlobal()) {
          $query
            ->condition('o_a_f_d.activity', $activity_ids, 'IN');
        }
        $query
          ->condition('o_a_f_d.user_module_status', $attempt
          ->id())
          ->condition('o_m_r.max_score', '', '<>')
          ->groupBy('o_a_f_d.activity')
          ->orderBy('changed', 'DESC');
        $answers = $query
          ->execute()
          ->fetchAllAssoc('activity');
        $count_of_answers = count($answers);
        $progress = round($count_of_answers / $count_of_activities * 100);
        $activity_ids = array_keys($answers);
        $sum_score = 0;

        // Get max score of activities.
        if (!empty($activity_ids)) {
          $query = $db_connection
            ->select('opigno_module_relationship', 'o_m_r');
          $query
            ->fields('o_m_r', [
            'child_id',
            'max_score',
          ]);
          $query
            ->condition('o_m_r.parent_id', $module
            ->id());
          $query
            ->condition('o_m_r.parent_vid', $module
            ->getRevisionId());
          $query
            ->condition('o_m_r.child_id', $activity_ids, 'IN');
          $max_scores = $query
            ->execute()
            ->fetchAllAssoc('child_id');
        }
        foreach ($answers as $key => $answer) {
          if (!isset($max_scores[$key]->max_score)) {
            $max_scores[$key]->max_score = 10;
          }
          $sum_score += $answer->score / $max_scores[$key]->max_score;
        }
        $avg_score = $sum_score / $count_of_answers * 100;
        $current_step['best score'] = $avg_score;
        $current_step['current attempt score'] = $avg_score;
        $last_activity_id = end($activities)->id;
        if ($module
          ->getSkillsActive() || $activity
          ->id() == $last_activity_id) {
          if ($successfully_finished == TRUE) {
            $_SESSION['successfully_finished'] = TRUE;
          }
          $attempt
            ->setScore($avg_score);
          $attempt
            ->setMaxScore(100);
          $attempt
            ->save();
        }
      }
    }

    // Send email to the module managers.
    $this
      ->sendEmailToManager($module, $activity, $entity, $current_group);
  }

  /**
   * Send Email to manager.
   */
  public function sendEmailToManager($module, $activity, $answer, $learning_path) {
    if (!$module instanceof OpignoModule || !$activity instanceof OpignoActivity || !$answer instanceof OpignoAnswer || !$learning_path instanceof Group) {
      return;
    }
    $config = \Drupal::config('opigno_learning_path.learning_path_settings');
    $student_activity_notify = $config
      ->get('opigno_learning_path_student_does_activity_notify');
    $student_activity = $config
      ->get('opigno_learning_path_student_does_activity');
    if (!$activity
      ->evaluationMethodManual() || empty($student_activity_notify) || empty($student_activity)) {
      return;
    }

    // Load managers and send email to each.
    $managers = $learning_path
      ->getMembers('learning_path-user_manager');
    $student = \Drupal::currentUser();
    $global_config = \Drupal::config('system.site');
    $options = [
      'absolute' => TRUE,
    ];
    $url = Url::fromRoute('view.opigno_score_modules.opigno_not_evaluated', [], $options);
    $link = Link::fromTextAndUrl(t('link'), $url)
      ->toString();
    foreach ($managers as $manager) {
      $user = $manager
        ->getUser();
      $email = $user
        ->getEmail();
      $lang = $user
        ->getPreferredLangcode();
      $params = [];
      $params['subject'] = t('@sitename Module review', [
        '@sitename' => $global_config
          ->get('name'),
      ]);
      $student_activity = str_replace('[sitename]', $global_config
        ->get('name'), $student_activity);
      $student_activity = str_replace('[user]', $student
        ->getAccountName(), $student_activity);
      $student_activity = str_replace('[manager]', $user
        ->getAccountName(), $student_activity);
      $student_activity = str_replace('[link]', $link, $student_activity);
      $student_activity = str_replace('[module]', $module
        ->getName(), $student_activity);
      $params['message'] = $student_activity;
      \Drupal::service('plugin.manager.mail')
        ->mail('opigno_learning_path', 'opigno_learning_path_managers_notify', $email, $lang, $params);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function backwardsNavigation(array $form, FormStateInterface $form_state) {
    $entity =& $this->entity;
    $module = $entity
      ->getModule();
    $activity = $entity
      ->getActivity();
    $attempt = $module
      ->getModuleActiveAttempt($this
      ->currentUser());
    $activities = $module
      ->getModuleActivities();
    if (key($activities) != $activity
      ->id()) {

      // Set last activity only if current activity is not first.
      $attempt
        ->setLastActivity($activity);
      $attempt
        ->save();
    }
    $args = [
      'opigno_module' => $module
        ->id(),
    ];
    $current_group = \Drupal::routeMatch()
      ->getParameter('group');
    if ($current_group) {
      $args['group'] = $current_group
        ->id();
    }

    // Query param is used to detect if we used backwards navigation button.
    $form_state
      ->setRedirect('opigno_module.take_module', $args, [
      'query' => [
        'backwards' => TRUE,
      ],
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function backToTraining(array $form, FormStateInterface $form_state) {
    $group = \Drupal::routeMatch()
      ->getParameter('group');
    $form_state
      ->setRedirect('entity.group.canonical', [
      'group' => $group
        ->id(),
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentEntityForm::$entity protected property The entity being used by this form. Overrides EntityForm::$entity 9
ContentEntityForm::$entityRepository protected property The entity repository service.
ContentEntityForm::$entityTypeBundleInfo protected property The entity type bundle info service.
ContentEntityForm::$time protected property The time service.
ContentEntityForm::addRevisionableFormFields protected function Add revision form fields if the entity enabled the UI.
ContentEntityForm::buildEntity public function Builds an updated entity object based upon the submitted form values. Overrides EntityForm::buildEntity 3
ContentEntityForm::copyFormValuesToEntity protected function Copies top-level form values to entity properties Overrides EntityForm::copyFormValuesToEntity
ContentEntityForm::create public static function Instantiates a new instance of this class. Overrides FormBase::create 9
ContentEntityForm::flagViolations protected function Flags violations for the current form. 4
ContentEntityForm::form public function Gets the actual form array to be built. Overrides EntityForm::form 13
ContentEntityForm::getBundleEntity protected function Returns the bundle entity of the entity, or NULL if there is none.
ContentEntityForm::getEditedFieldNames protected function Gets the names of all fields edited in the form. 4
ContentEntityForm::getFormDisplay public function Gets the form display. Overrides ContentEntityFormInterface::getFormDisplay
ContentEntityForm::getFormLangcode public function Gets the code identifying the active form language. Overrides ContentEntityFormInterface::getFormLangcode
ContentEntityForm::getNewRevisionDefault protected function Should new revisions created on default.
ContentEntityForm::init protected function Initializes the form state and the entity before the first form build. Overrides EntityForm::init 1
ContentEntityForm::initFormLangcodes protected function Initializes form language code values.
ContentEntityForm::isDefaultFormLangcode public function Checks whether the current form language matches the entity one. Overrides ContentEntityFormInterface::isDefaultFormLangcode
ContentEntityForm::prepareEntity protected function Prepares the entity object before the form is built first. Overrides EntityForm::prepareEntity 1
ContentEntityForm::setFormDisplay public function Sets the form display. Overrides ContentEntityFormInterface::setFormDisplay
ContentEntityForm::showRevisionUi protected function Checks whether the revision form fields should be added to the form.
ContentEntityForm::submitForm public function This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state… Overrides EntityForm::submitForm 3
ContentEntityForm::updateChangedTime public function Updates the changed time of the entity.
ContentEntityForm::updateFormLangcode public function Updates the form language to reflect any change to the entity language.
ContentEntityForm::validateForm public function Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level… Overrides FormBase::validateForm 3
ContentEntityForm::__construct public function Constructs a ContentEntityForm object. 9
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityForm::$entityTypeManager protected property The entity type manager. 3
EntityForm::$moduleHandler protected property The module handler service.
EntityForm::$operation protected property The name of the current operation.
EntityForm::$privateEntityManager private property The entity manager.
EntityForm::actions protected function Returns an array of supported actions for the current entity form. 29
EntityForm::actionsElement protected function Returns the action form element for the current entity form.
EntityForm::afterBuild public function Form element #after_build callback: Updates the entity with submitted data.
EntityForm::getBaseFormId public function Returns a string identifying the base form. Overrides BaseFormIdInterface::getBaseFormId 5
EntityForm::getEntity public function Gets the form entity. Overrides EntityFormInterface::getEntity
EntityForm::getEntityFromRouteMatch public function Determines which entity will be used by this form from a RouteMatch object. Overrides EntityFormInterface::getEntityFromRouteMatch 1
EntityForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId 10
EntityForm::getOperation public function Gets the operation identifying the form. Overrides EntityFormInterface::getOperation
EntityForm::prepareInvokeAll protected function Invokes the specified prepare hook variant.
EntityForm::processForm public function Process callback: assigns weights and hides extra fields.
EntityForm::setEntity public function Sets the form entity. Overrides EntityFormInterface::setEntity
EntityForm::setEntityManager public function Sets the entity manager for this form. Overrides EntityFormInterface::setEntityManager
EntityForm::setEntityTypeManager public function Sets the entity type manager for this form. Overrides EntityFormInterface::setEntityTypeManager
EntityForm::setModuleHandler public function Sets the module handler for this form. Overrides EntityFormInterface::setModuleHandler
EntityForm::setOperation public function Sets the operation for this form. Overrides EntityFormInterface::setOperation
EntityForm::__get public function
EntityForm::__set public function
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
OpignoAnswerForm::backToTraining public function
OpignoAnswerForm::backwardsNavigation public function
OpignoAnswerForm::buildForm public function Form constructor. Overrides EntityForm::buildForm
OpignoAnswerForm::save public function Form submission handler for the 'save' action. Overrides EntityForm::save
OpignoAnswerForm::sendEmailToManager public function Send Email to manager.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.