Scoring methodology plugins configuration is not loaded

Created on 24 January 2024, 11 months ago
Updated 26 April 2024, 8 months ago

Problem/Motivation

With current version of module we have an issue to see a stored configuration for WebformScore plugins (calculation rules in Webform element).

Steps to reproduce

Create one of provided Webform Score elements, set a scoring methodology in section Quiz answer and save element. Open element settings again and scoring methodology should be empty.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia tomasbarej

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @tomasbarej
  • πŸ‡ΈπŸ‡°Slovakia tomasbarej

    I was able to fix the behaviour, but I'm not so confident about the resolution because I don't really get how it might actually work before.

    There is an initialisation of a plugin in QuizTrait.php with a method createWebformScorePlugin:

    $plugin = $this->createWebformScorePlugin($this->configuration, $score_methodology_option);
    

    First argument of the method should be an element where settings of the plugin should be loaded from element property #webform_score_plugin_configuration

      protected function createWebformScorePlugin(array $element, $plugin_id = NULL) {
        if (!$plugin_id) {
          $plugin_id = $this->getElementProperty($element, 'webform_score_plugin');
        }
    
        return $this->webformScoreManager->createInstance($plugin_id, $this->getElementProperty($element, 'webform_score_plugin_configuration'));
      }
    

    It doesn't make sense to me to pass a $this->configuration array when there are not (or should not be) an element property.

    It starts working when I pass an actual element props the method expects in form or an $element array like this:

            $element = [
              '#webform_score_plugin' => $score_methodology_option,
              '#webform_score_plugin_configuration' => $current_plugin_config,
            ];
            $plugin = $this->createWebformScorePlugin($element, $score_methodology_option);
    

    What I'm not sure are the two more occurrences of plugin initialisation $plugin = $this->createWebformScorePlugin($this->configuration, $score_methodology_option); in methods validateConfigurationForm and submitConfigurationForm and wondering if it actually might validate or submit the values. In order to save config we need patch posted in issue https://www.drupal.org/project/webform_score/issues/2913371 πŸ› The score configuration is not saved Needs review

  • Status changed to Needs review 11 months ago
  • πŸ‡¦πŸ‡ΊAustralia nigelcunningham Geelong

    Thanks for opening this issue. I've just pushed some work that I've done over the last few days - as you rightly pointed out, more was needed than just fixing the arguments. I'll credit your work on this when I get up to closing the issue. In the meantime, if you'd like to try the current dev branch, it will hopefully fix issues for you.

Production build 0.71.5 2024