Commit 02b99b14 authored by Sandeep Tanwar's avatar Sandeep Tanwar Committed by Nigel Cunningham
Browse files

Issue #3180585 by sanju1092101: Quiz Answers Fields Change to Element Options Ajax issue

parent fa3e3074
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -149,8 +149,21 @@ trait QuizTrait {
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::validateConfigurationForm($form, $form_state);

    // Fixing issue for scoring methodology form not getting created.
    if (empty($form_state->getValue('webform_score_plugin'))) {
      if (array_key_exists('maximum', $this->webformScoreManager->pluginOptionsCompatibleWith($this->getAnswerDataTypeId()))) {
        $score_methodology_option = 'maximum';
      }
      else {
        $score_methodology_option = array_key_first($this->webformScoreManager->pluginOptionsCompatibleWith($this->getAnswerDataTypeId()));
      }
    }
    else {
      $score_methodology_option = $form_state->getValue('webform_score_plugin');
    }

    try {
      $plugin = $this->createWebformScorePlugin($this->configuration, $form_state->getValue('webform_score_plugin'));
      $plugin = $this->createWebformScorePlugin($this->configuration, $score_methodology_option);

      if ($plugin instanceof PluginFormInterface) {
        $sub_form_state = SubformState::createForSubform($form['properties']['webform_score']['webform_score_plugin_configuration'], $form, $form_state->getCompleteFormState());