Account created on 14 August 2018, about 6 years ago
#

Recent comments

I didn't mean to assign it to myself, nor do I know how I ended up doing that. I was mostly answering my own question for future reference, in case someone else was struggling with the same issue. I indeed have solved my own problem and no longer need any help.

After playing with it a lot more, it turns out that it is accomplished with set field value.

  1. Create the term with Entity: Create New setting the type to Taxonomy term: MyVocabulary and the Entity label: what I want the term to be. Create a token, ie. new-child
  2. Entity: Set Field Value: Field name: parent. Just the word 'parent'. No brackets or new-child:parent:tid or anything. Literally just the word 'parent'. Field Value: the TID of the parent. I used a token by loading the parent term first, then grabbing the TID that way.
  3. Eventually save the new term, using Set Field Value or Save entity

Oh really?! Dang.
Here is what I have so far (I haven't gotten anything more accomplished since I posted last):
1. My new event pulls the quiz taker uid, the quiz score, and the max score from the database and makes tokens (if that makes a difference in the condition/action)
2. It pulls the quiz name based on the quiz ID from another database table based on a join. This makes a token, too.

I would like to be able to make two conditions:
1. Select the quiz name from a drop down (I do have a working dropdown)
2. Select a passing percentage (I do have percentages as 10's (100, 90, 80, etc) in a working dropdown)

Then if both conditions pass, execute the next action. It doesn't really matter to me if this is done with the flow arrow or an action rectangle, just that the two conditions can be executed together.

Drupal 9: Yes, I'm using Drupal 9, but that is because both H5P and A11Y (accessibility) are both stuck on 9 for the time being. If they move to 10 before January, I'll do the same, otherwise, I'll have to wait until June (academic semesters). Everything else is luxury modules, but not the quizzes and font for dyslexic readers.

I was using the Compare Two Scalar values as a starting point. I'll put some more work in this weekend coming and post my struggles/successes with getting the condition and/or action to work correctly.

Thanks for everything! When it's all working correctly (at least for Drupal 9), I'll happily give you the whole lot. I'm not too sad I had to write another event since it makes new, usable tokens that are not provided by H5P, it was just a learning adventure.

Okay, after another day of attacking it, it does seem that because the H5P module's event specifically calls use Symfony\Component\EventDispatcher\Event and not use Drupal\Component\EventDispatcher\Event;, the ECA event throws an error where it says: InvalidArgumentException: Passed $event parameter is not of an expected event object type, Drupal\h5p\Event\FinishedEvent given in Drupal\eca\Processor->execute() (line 107 of /web/modules/contrib/eca/src/Processor.php).. I could fix the error by either changing the H5P module's event to be of the Drupal type, or the Processor.php to read like I had above, but neither is the best way. So instead, I managed to write a new event that reacts to the H5P event (which also creates some handy tokens) and has use Drupal\Component\EventDispatcher\Event; along with a separate event subscriber, then have ECA respond to the new event instead of directly to the H5P created event, and everything seems to be working fine now. At least on the event side. The Condition part is still a mystery to me, but I'll keep plugging away on it. I can get a condition inside the event, like you mention in the video about 3/4 of the way through, but not as a separate condition. I can probably get away with it being a part of the event, but since there will be many H5P quizzes in the end and each will have a different action (mostly changing roles or adding points to a user integer field), I need the condition to work either as part of the event or as part of a condition.

I'm not developing in a repository, but I could. Like in GitHub? I have no problem sharing what I create after this much work.

Thanks! With the video and drush (and a fair amount of help), I got the event working. However, it took quite a bit and I could only get it to work if I changed line 106 in Processor.php (from the ECA module) to:

if (!(($event instanceof Event) || ($event instanceof \Symfony\Component\EventDispatcher\Event)) && !($event instanceof ContractsEvent)) {
    throw new \InvalidArgumentException(sprintf('Passed $event parameter is not of an expected event object type, %s given', get_class($event)));
}

Even though H5P does indeed create an event and I was able to write other Event Subscribers, the explicit call to \Symfony\Component ... was the only way I could get it to work. Up next is tackling a Condition. I can get a Configuration form to work if I make it part of the event, but not part of the configuration. My best guess is I'm not creating the evaluation function correctly. I did use the drush gen to get the condition directory/file, but now I'm a bit lost. I'll keep plugging away, I just thought I'd post an update about the event.

Do you have such an ECA event plugin in your custom code?

I do not. I don't think I knew that was the path I needed to take, but now I do.

(hours later) ...

I've spent a good part of today trying to emulate the other plugins (like User Events) and oh dang, is it not working. Is there any chance you have a Plugin skeleton? I've tried to look at the documentation and copy what I'm seeing, but it's throwing PHP errors at me.

TypeError: Drupal\h5p_eca\EventSubscriber\H5PFinishedSubscriber::__construct(): Argument #1 ($ecaTriggerEvent) must be of type Drupal\h5p_eca\EventSubscriber\Drupal\eca\Processor, Drupal\eca\Processor given, called in /web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in Drupal\h5p_eca\EventSubscriber\H5PFinishedSubscriber->__construct() (line 17 of /web/modules/custom/h5p_eca/src/EventSubscriber/H5PFinishedSubscriber.php)

Production build 0.71.5 2024