Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: twig tags for feedback modals #364

Conversation

bartlomiejmarszal
Copy link
Contributor

Provide twig oriented feedback blocks rendering

Copy link
Contributor

@bugalot bugalot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my perspective, and not change the behavior of QTI-SDK, in case you simply wish to use Twig instead of the regular PHP template oriented notation (<?php if: ?> and co.), is to augment the MarkupPostRenderer::render() method to make it Twig capable. It shoudln't be a big deal.

This would cover all the scenarios, using Twig, or the current implementation.

@@ -638,6 +643,10 @@ protected function processNode($base = ''): void
$this->includeChoiceComponent($component, $rendering);
}

if ($this->mustTwigFeedbackComponent($component) === true) {
$this->twigFeedbackComponent($component, $rendering);
Copy link

@pribi pribi Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to clear up the naming a bit. If I understand it correctly:

Does this mean if twig feedback component must be used? I propose to rename to:
if ($this->mustUseTwigFeedbackComponent($component) === true) { ... }

and set twig feedback component:
$this->setTwigFeedbackComponent($component, $rendering);

@bartlomiejmarszal
Copy link
Contributor Author

From my perspective, and not change the behavior of QTI-SDK, in case you simply wish to use Twig instead of the regular PHP template oriented notation (<?php if: ?> and co.), is to augment the MarkupPostRenderer::render() method to make it Twig capable. It shoudln't be a big deal.

This would cover all the scenarios, using Twig, or the current implementation.

Hey! Thank you for your comment. For me, it is not clear the reason behind using two different renderers. I saw a way how I could generate <!-- qtism-if --!> notation. The result of this is following:

<!-- qtism-if (($qtismState['PASS_CATEGORY_SCORED_RENDERING'] !== null && ($qtismState['PASS_CATEGORY_SCORED_RENDERING'] instanceof qtism\\common\\datatypes\\QtiIdentifier && $qtismState['PASS_CATEGORY_SCORED_RENDERING']->equals(new qtism\\common\\datatypes\\QtiIdentifier('not_passed')) || $qtismState['PASS_CATEGORY_SCORED_RENDERING'] instanceof qtism\\runtime\\common\\Container && $qtismState['PASS_CATEGORY_SCORED_RENDERING']->contains(new qtism\\common\\datatypes\\QtiIdentifier('not_passed'))))): -->

This should be replaced in MarkupPostRenderer with twig as a new feature. I saw this process should be done by regexp operations. But I do not understand this approach. Why do I need to complicate this like that? Why I can't just generate the correct markup when required (based on FeedbackShowHidePolicy)?

@bartlomiejmarszal bartlomiejmarszal marked this pull request as ready for review September 11, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants