> Add a readonly service property to a form.
Cannot reproduce an issue here. I've modified web/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php, to have readonly properties in the constructor:
public function __construct(
protected readonly string $root,
protected readonly string $sitePath,
protected readonly EntityTypeManagerInterface $entityTypeManager,
protected readonly ModuleInstallerInterface $moduleInstaller,
protected readonly UserNameValidator $userNameValidator,
protected readonly bool $superUserAccessPolicy,
) {}
After flushing the cache, I could update the form at /admin/config/system/site-information without issues or errors in my logs. I could also prove that \Drupal\Core\DependencyInjection\DependencySerializationTrait was involved, since \Drupal\Core\Form\FormBase uses the trait.
Also I do not see, where services our modified via DependencySerializationTrait. The injected services are readonly by intent.
For me (and obviously others) the current solution is good enough. Let's not over engineer and wait 9 years more. I pledge for RTBC.
I agree with vitaliyb98. "You ruined my project and there is a module, which works better" is no message a maintainer can work with and help in any way.
Looks good. I've approved it. Thanks.
Yes, it was the local command. The parameter for the database (sqllite) and the base url were wrong.
I ended up with this command on my DDEV setup:
ddev exec SIMPLETEST_DB=sqlite://localhost/db.sqlite SIMPLETEST_BASE_URL=https://d11-pbt.ddev.site vendor/bin/phpunit -c web/core/phpunit.xml.dist web/modules/custom/permissions_by_term/tests --filter VocabularyResetPermissionsTest
The tests did pass. However, there are a couple of deprecation messages, which should be cleaned up some time.
Vitaly, could you please create a new patch release, since you merged a couple of MRs already?
Still no patch release. Guys, can you finally create a new patch release, please? We are experiencing this issue on any site and the Stage File Proxy is widespread.
This is a duplicate of https://www.drupal.org/project/stage_file_proxy/issues/3520313 🐛 Deprecated function: str_ends_with() Active
The code review was successful. 👍 I left an optional improvement inside of the MR.
Thanks, now PHPUnit is not complaining about missing dependencies.
However, now all the tests are failing:
➜ d11-pbt ddev exec SIMPLETEST_DB=mysql://db:db@db/db SIMPLETEST_BASE_URL=https://drupal.ddev.site vendor/bin/phpunit -c web/core/phpunit.xml.dist web/modules/custom/permissions_by_term/tests
HTML output directory sites/simpletest/browser_output is not a writable directory.PHPUnit 11.5.36 by Sebastian Bergmann and contributors.
Runtime: PHP 8.3.23
Configuration: /var/www/html/web/core/phpunit.xml.distFFFFFFFDDDDDDDDDDDDDDDDDDDDDDD 30 / 30 (100%)
Time: 00:25.901, Memory: 8.00 MB
There were 7 failures:
1) Drupal\Tests\permissions_by_term\Functional\NodeBatchTest::testBatchOnTermEditForm with data set "0" (50, true)
User ylbdyjxw successfully logged in.
Failed asserting that false is true./var/www/html/web/core/tests/Drupal/Tests/UiHelperTrait.php:186
/var/www/html/web/modules/custom/permissions_by_term/tests/src/Functional/NodeBatchTest.php:712) Drupal\Tests\permissions_by_term\Functional\NodeBatchTest::testBatchOnTermEditForm with data set "1" (5, false)
User tawfeax4 successfully logged in.
Failed asserting that false is true./var/www/html/web/core/tests/Drupal/Tests/UiHelperTrait.php:186
/var/www/html/web/modules/custom/permissions_by_term/tests/src/Functional/NodeBatchTest.php:713) Drupal\Tests\permissions_by_term\Functional\NodeBatchTest::testBatchOnUserEditForm with data set "0" (50, true)
User n7k8v63i successfully logged in.
Failed asserting that false is true./var/www/html/web/core/tests/Drupal/Tests/UiHelperTrait.php:186
/var/www/html/web/modules/custom/permissions_by_term/tests/src/Functional/NodeBatchTest.php:964) Drupal\Tests\permissions_by_term\Functional\NodeBatchTest::testBatchOnUserEditForm with data set "1" (5, false)
User qyc7drvo successfully logged in.
Failed asserting that false is true.
Since I do get the error "HTML output directory sites/simpletest/browser_output is not a writable directory.", I was also creating this directory and set it to chmod -R 777.
Now I do get this error:
7) Drupal\Tests\permissions_by_term\Functional\VocabularyResetPermissionsTest::testKeepOnlyOneVocab
Error: Class "Behat\Mink\Driver\BrowserKitDriver" not found/var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php:285
/var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php:197
/var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php:348
/var/www/html/web/modules/custom/permissions_by_term/tests/src/Functional/VocabularyResetPermissionsTest.php:68
Is the require-dev section of your composer.json file similar?
"require-dev": {
"behat/mink": "^1.12",
"mikey179/vfsstream": "^1.6",
"phpspec/prophecy-phpunit": "^2.4",
"phpunit/phpunit": "^11.0",
"symfony/phpunit-bridge": "^7.3"
}
Tried to run it like this:
ddev exec SIMPLETEST_DB=mysql://db:db@db/db SIMPLETEST_BASE_URL=https://drupal.ddev.site vendor/bin/phpunit -c web/core/phpunit.xml.dist web/modules/custom/permissions_by_term/tests
I have tried to this command, but I do still get this error:
➜ permissions_by_term git:(3408309-remains-access-control) ddev exec SIMPLETEST_DB=mysql://db:db@db/db SIMPLETEST_BASE_URL=https://drupal.ddev.site vendor/bin/phpunit -c web/core/phpunit.xml.dist web/modules/custom/permissions_by_term/tests
HTML output directory sites/simpletest/browser_output is not a writable directory.PHP Warning: Class "Drupal\TestTools\PhpUnitCompatibility\PhpUnit12\TestCompatibilityTrait" not found in /var/www/html/web/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php on line 12
Warning: Class "Drupal\TestTools\PhpUnitCompatibility\PhpUnit12\TestCompatibilityTrait" not found in /var/www/html/web/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php on line 12
PHP Fatal error: During class fetch: Uncaught RuntimeException: The autoloader expected class "Drupal\Tests\PhpUnitCompatibilityTrait" to be defined in file "/var/www/html/web/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php". The file was found but the class was not in it, the class name or namespace probably has a typo. in /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:360
Stack trace:
Which PHPUnit version are you using? Please check like this: composer show | grep phpunit. Which Drupal version are you using?
@vitaly98: I could successfully test this. Thanks!
I slightly modified the form, for not showing the status message above the setting. It looked a bit awkward. The warning is now in the standard help text below the setting checkbox.
I tried to run the unit tests locally. Including web/modules/custom/permissions_by_term/tests/src/Functional/VocabularyResetPermissionsTest.php
Therefor I run the tests from a basic Drupal 11 project with DDEV and the PHPUnit config file from Drupal core (and the PbTs config in doubt):
bin/phpunit -c web/core/phpunit.xml.dist web/modules/custom/permissions_by_term/tests
I got the following error:
HTML output directory sites/simpletest/browser_output is not a writable directory.
PHP Warning: Class "Drupal\TestTools\PhpUnitCompatibility\PhpUnit12\TestCompatibilityTrait" not found in /var/www/html/web/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php on line 12
Warning: Class "Drupal\TestTools\PhpUnitCompatibility\PhpUnit12\TestCompatibilityTrait" not found in /var/www/html/web/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php on line 12
PHP Fatal error: During class fetch: Uncaught RuntimeException: The autoloader expected class "Drupal\Tests\PhpUnitCompatibilityTrait" to be defined in file "/var/www/html/web/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php". The file was found but the class was not in it, the class name or namespace probably has a typo. in /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:360
Stack trace:
#0 /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php(317): Symfony\Component\ErrorHandler\DebugClassLoader->checkClass()
#1 /var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php(53): Symfony\Component\ErrorHandler\DebugClassLoader->loadClass()
#2 /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php(306): include('...')
#3 /var/www/html/web/modules/custom/permissions_by_term/tests/src/Functional/NodeBatchTest.php(16): Symfony\Component\ErrorHandler\DebugClassLoader->loadClass()
#4 /var/www/html/vendor/phpunit/phpunit/src/Runner/TestSuiteLoader.php(116): require_once('...')
#5 /var/www/html/vendor/phpunit/phpunit/src/Runner/TestSuiteLoader.php(49): PHPUnit\Runner\TestSuiteLoader->loadSuiteClassFile()
#6 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(237): PHPUnit\Runner\TestSuiteLoader->load()
#7 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(258): PHPUnit\Framework\TestSuite->addTestFile()
#8 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php(113): PHPUnit\Framework\TestSuite->addTestFiles()
#9 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php(58): PHPUnit\TextUI\Configuration\TestSuiteBuilder->testSuiteFromPath()
#10 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Application.php(389): PHPUnit\TextUI\Configuration\TestSuiteBuilder->build()
#11 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Application.php(196): PHPUnit\TextUI\Application->buildTestSuite()
#12 /var/www/html/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run()
#13 /var/www/html/bin/phpunit(122): include('...')
#14 {main} in /var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php on line 53Fatal error: During class fetch: Uncaught RuntimeException: The autoloader expected class "Drupal\Tests\PhpUnitCompatibilityTrait" to be defined in file "/var/www/html/web/core/tests/Drupal/Tests/PhpUnitCompatibilityTrait.php". The file was found but the class was not in it, the class name or namespace probably has a typo. in /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php:360
Stack trace:
#0 /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php(317): Symfony\Component\ErrorHandler\DebugClassLoader->checkClass()
#1 /var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php(53): Symfony\Component\ErrorHandler\DebugClassLoader->loadClass()
#2 /var/www/html/vendor/symfony/error-handler/DebugClassLoader.php(306): include('...')
#3 /var/www/html/web/modules/custom/permissions_by_term/tests/src/Functional/NodeBatchTest.php(16): Symfony\Component\ErrorHandler\DebugClassLoader->loadClass()
#4 /var/www/html/vendor/phpunit/phpunit/src/Runner/TestSuiteLoader.php(116): require_once('...')
#5 /var/www/html/vendor/phpunit/phpunit/src/Runner/TestSuiteLoader.php(49): PHPUnit\Runner\TestSuiteLoader->loadSuiteClassFile()
#6 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(237): PHPUnit\Runner\TestSuiteLoader->load()
#7 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(258): PHPUnit\Framework\TestSuite->addTestFile()
#8 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php(113): PHPUnit\Framework\TestSuite->addTestFiles()
#9 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php(58): PHPUnit\TextUI\Configuration\TestSuiteBuilder->testSuiteFromPath()
#10 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Application.php(389): PHPUnit\TextUI\Configuration\TestSuiteBuilder->build()
#11 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Application.php(196): PHPUnit\TextUI\Application->buildTestSuite()
#12 /var/www/html/vendor/phpunit/phpunit/phpunit(104): PHPUnit\TextUI\Application->run()
#13 /var/www/html/bin/phpunit(122): include('...')
#14 {main} in /var/www/html/web/core/tests/Drupal/Tests/BrowserTestBase.php on line 53
I made the following directory existing and writeable: web/sites/simpletest/browser_output
This are my installed phpunit packages:
➜ d11-pbt d composer show | grep phpunit
phpspec/prophecy-phpunit 2.4.0 Integrating the Prophecy m...
phpunit/php-code-coverage 12.3.7 Library that provides coll...
phpunit/php-file-iterator 6.0.0 FilterIterator implementat...
phpunit/php-invoker 6.0.0 Invoke callables with a ti...
phpunit/php-text-template 5.0.0 Simple template engine.
phpunit/php-timer 8.0.0 Utility class for timing
phpunit/phpunit 12.3.8 The PHP Unit Testing frame...
symfony/phpunit-bridge 7.3.3 Provides utilities for PHP...
➜ d11-pbt
jepster_ → made their first commit to this issue’s fork.
I do not understand the issue here. The permissions are tied to the users UID. After the user changes his user password, the uid stays the same. Please describe the issue more verbose.
jepster_ → created an issue.
@poker10 Thanks for your hint and the links to the docs. I have updated the doc comment for core/lib/Drupal/Core/Mail/MailManager.php, too.
@poker I do not like this issue becoming another never ending story with endless re-openings for 1 line of comment in a class method. Could you please open a new issue for the other class, so we can merge this here? You could provide a MR in your new issue, so this comes on track.
Looks good to me. Good job ivnish. Thanks!
This is only a status message. We are discussing this as a community since 9 years. This proves that we are super pedantic and lacking project management skills. Please merge this change finally.
Thanks. Applied the MR and released in version 3.1.39: https://www.drupal.org/project/permissions_by_term/releases/3.1.39 →
I've seen, that I must install any question type module first. This info would be very helpful on the "add quiz question type" page. Otherwise this page is quite confusing.
jepster_ → created an issue.
Released in 3.1.38: https://www.drupal.org/project/permissions_by_term/releases/3.1.38 →
Thanks! Can you create a MR for this?
Later this did not help and the following helped me in my projects composer.json file:
"autoload": {
"psr-4": {
"Geocoder\\": "vendor/willdurand/geocoder"
}
}
jepster_ → created an issue.
Thanks, I reviewed the edit and applied it.
Well, I am not in a migration case here. :) I am transliterating filenames. Files which have been transliterated are good to know for us. Also it would be good to have redirects for such filename transliterations, so search engines won't stumble into 404 http errors.
You must not add additional brackets to the if-case. That's redundant. Also you should write the constants in uppercase. NULL instead of null, to match the Drupal coding standards: https://www.drupal.org/docs/develop/standards/php/php-coding-standards#s... →
The null check can be shortened just to !
Something like this should work:
if (!$this->requestStack->getCurrentRequest()->query->get('url'))
I am really wondering, why you are getting this error. Since Drupal cannot determine any url here. The controller acts in webbrowser and there you have always a url. It looks like not reproducable and tied to any individual issue on your website. :-/
Could you please add the credit for jepster to me? This is the wrong account.
This was my talk:
> By default, I would leave the current behaviour: log errors only, it might be the edge case thus not expecting so many logs, and actually it's something that we should be aware of.
The migrate core module f.e. offers db tables, which are showing the migrated files. Separate from the log. Such a table would be helpful, too. E.g. "files_transliteration_message".
> as it's only meant to be executed with a Drush command
I would not limit it to Drush only. That would remove the possibility of automate the files transliteration process. Please mind update and deploy hooks: https://www.drupal.org/project/transliterate_existing_files/issues/3539028 ✨ Provide a class method for update and deploy hooks Active
peter majmesku → created an issue.
> If we are using the dblog module and not an external logging service, this could flood the watchdog table
We are already logging the errors. This could flood the watchdog table, too. So maybe a config for both?
> A first lightweight way to do it would be to use Settings
Yes, this would be useful.
See my MR and the patch. Please review.
peter majmesku → created an issue.
peter majmesku → created an issue.
The MR resolves the issue for me. Thanks.
Can anyone please create an new release with this patch?
> We don't need to repeat the full $to docs, but we should at least say it has the same format as that parameter. Thanks!
I've added this information. Please review. Thanks!
This is not really a fix, but it works as a workaround, at least:
"autoload": {
"files": [
"vendor/willdurand/geocoder/Provider/Provider.php",
"vendor/willdurand/geocoder/Provider/AbstractProvider.php"
]
}
This is not really a fix, but it works as a workaround, at least:
"autoload": {
"files": [
"vendor/willdurand/geocoder/Provider/Provider.php",
"vendor/willdurand/geocoder/Provider/AbstractProvider.php"
]
}
> surprised phpcs didn't pick up the test sentences not having a full stop
I've corrected this.
The tests are failing in the pipeline randomly. I've restarted them a couple of times and sometimes PHPUnit for functional JavaScript is failing with an unknown error, then Nightwatch is failing etc. There are no frontend changes, in relation with JavaScript. My feature branch contains the latest changes from 11.x. Can anyone help?
> Believe the IS should be updated with screenshots for proposed UI changes that will probably need UX sign off.
Where do we need UI changes? The UI is coming from the ECA module and automatically processed from the EmailAction.php.
See my changes in the MR. Please review.
peter majmesku → created an issue.
> @peter majmesku fyi you shouldn't RTBC your own stuff.
Well, I RTBC'd your change.
> summary is missing the steps to reproduce section
Done.
> pipeline appears to have issues,
Solved.
Thanks!
Applied the suggestion. Thanks.
Updated the method attribute signature comment with a more accurate description. Please review my MR.
peter majmesku → created an issue. See original summary → .
Added a test which proves the functionality. See my latest commit. If you remove my changes in Resource.php
if ($thumbnail_width && $thumbnail_height) {
then this error will appear
InvalidArgumentException: The thumbnail dimensions must be numbers greater than zero.
But the variables $thumbnail_width and $thumbnail_height can be passed into the constructor as NULL.
So I consider the change a improvement.
peter majmesku → created an issue.
I am working on a Drupal 10 to Drupal 10 migration. All the examples here did not help. Looks like they are related to Drupal 7.
My solution was an own migrate process plugin. You can find it here: https://git.drupalcode.org/project/sites_migrator/-/blob/1.0.x/src/Plugi...
The plugin must be implemented into the process like this:
field_paragraphs:
plugin: paragraphs_sub_process
source: field_paragraphs
migration:
- wg_paragraph_media_text
process:
target_id: '0'
target_revision_id: '1'
I hope this example helps somebody.
Should be done, when the sites module code is on d.o ( https://www.drupal.org/project/sites → ).
peter majmesku → made their first commit to this issue’s fork.
I've double checked the form id like that:
/**
* Implements hook_form_alter().
*/
function nice_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
dump($form_id);
}
The dumped form id is:
tfa_base_overview
Then I've tried to change the FormDecorator attribute value:
#[FormDecorator('tfa_base_overview_alter')]
final class TfaBaseOverviewFormDecorator extends FormDecoratorBase implements ContainerFactoryPluginInterface {
Unfortunately the form does not get applied.
I need to implement this:
/**
* {@inheritdoc}
*/
public function applies(): bool {
return TRUE;
}
Form ID is "tfa_base_overview". I want that the form decorator decorates the form. It does not. If this can be somehow resolved with the applies method, that would be fine. I do not know how to implement that. If I add this method to the generated class, then the decorator is applied for any form.
/**
* {@inheritdoc}
*/
public function applies(): bool {
return TRUE;
}
The code looks good and is the common way to generate Drush commands in Drupal. Checked other Drush generate commands and it looks like the proper way to do it.
I tried to do the same what I already have with the Drush generate command. The form decorator does not get applied. The following code was the generated result:
declare(strict_types=1);
namespace Drupal\ulf_tfa\FormDecorator;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\form_decorator\Attribute\FormDecorator;
use Drupal\form_decorator\FormDecoratdorBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* My form decorator.
*/
#[FormDecorator('tfa_base_overview')]
final class TfaBaseOverviewFormDecorator extends FormDecoratorBase implements ContainerFactoryPluginInterface {
/**
* The constructor.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
private readonly AccountProxyInterface $currentUser,
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): self {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('current_user'),
);
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, ...$args) {
$form = $this->inner->buildForm($form, $form_state, ...$args);
$form['disable_tfa'] = [
'#type' => 'checkbox',
'#title' => $this->t('Woohoo Disable Two-Factor Authentication'),
'#description' => $this->t('By disabling two-factor authentication for your account, you won\'t be asked for two-factor authentication setup anymore. If you would like to re-enable it, you can do so in your user account settings.'),
'#weight' => -10,
'#default_value' => FALSE,
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$this->inner->validateForm($form, $form_state);
// Validate your magic
}
}
Can you implement the
applies()
method for the generated class, too? That way the form decorator would be applied on the given form. That would be awesome. :)
peter majmesku → created an issue.
Is this something that can be reproduced via the sites group form? Please provide a more verbose instruction for the reproduction steps.
Currently the PHPUnit and code qa tools are failing. Looks like they've been ignored since a longer time.
The summary appears to be missing the steps that trigger the issue
Also would need a test case to show how this is a problem.
Updated the summary. hth
The MR is created. Please review.
See: https://www.drupal.org/project/drupal/issues/3525305 🐛 Check thumbnail width and height before using it Active
peter majmesku → created an issue.
peter majmesku → created an issue.
I have noticed, that I must open the following url as anonymous user (quiz id is "1"):
peter majmesku → created an issue.
I was able to do it like this:
$a = Paragraph::create([
'type' => 'multichoice',
'multichoice_correct' => 1,
'multichoice_answer' => 'Alternative A',
'multichoice_feedback_chosen' => 'You chose A',
'multichoice_feedback_not_chosen' => 'You did not choose A',
'multichoice_score_chosen' => 1,
'multichoice_score_not_chosen' => 0,
]);
$a->save();
$b = Paragraph::create([
'type' => 'multichoice',
'multichoice_answer' => 'Alternative B',
'multichoice_feedback_chosen' => 'You chose B',
'multichoice_feedback_not_chosen' => 'You did not choose B',
'multichoice_score_chosen' => -1,
'multichoice_score_not_chosen' => 0,
]);
$b->save();
$c = Paragraph::create([
'type' => 'multichoice',
'multichoice_answer' => 'Alternative C',
'multichoice_feedback_chosen' => 'You chose C',
'multichoice_feedback_not_chosen' => 'You did not choose C',
'multichoice_score_chosen' => -1,
'multichoice_score_not_chosen' => 0,
]);
$c->save();
$question = QuizQuestion::create([
'title' => 'MCQ 1 Title',
'type' => 'multichoice',
'choice_multi' => 0,
'choice_random' => 0,
'choice_boolean' => 0,
'body' => 'MCQ 1 body text',
]);
$question->get('alternatives')->appendItem($a);
$question->get('alternatives')->appendItem($b);
$question->get('alternatives')->appendItem($c);
$question->save();
Found code examples in the automated tests. See quiz/modules/quiz_multichoice/tests/src/Functional/QuizMultichoiceTestCase.php
Please notice: I would like to create a multiple-choice question programmatically.
peter majmesku → created an issue.
I've extended the patch, so the 'cmi.suspend_data' will be stored. This seems to work. Please review.
I've tested this patch and I cannot confirm that it works. If I set a Xdebug debugger breakpoint in
\Drupal\opigno_scorm\Controller\OpignoScormController::scormCommit()
then I do not see any "cmi.suspend_data" dataset there. So the current course status is not visible. See attached screenshot. Have you figured out, how the course status (completed pages, answered questions etc.) are stored?
peter majmesku → created an issue.