Say I have limited a user to submit "1" submission every "15 Minutes".

Is there a way (token most probably) to alert the user that he still need to wait for lets say 5 Min 36 Sec to submit again the webform.

Remain time

Thank you,

Comments

C.E.A created an issue. See original summary.

jrockowitz’s picture

I think we are going to run into caching issues with a token like this one but I am open to trying to set it up.

jrockowitz’s picture

The calculation is probably {last completed} - {interval} = {remaining}

The token syntax could be something like [webform-submission:interval:user:wait].

c.e.a’s picture

I think we are going to run into caching issues with a token like this one but I am open to trying to set it up.

The best bet here is to display an informational message for the user for two reasons and let them take care about the caching issue:

  1. Inform him about the existing of such token like: You may use [webform-submission:interval:user:wait] to display the remaining time for the next submission.
  2. Please note you may encounter caching issue if you are using any caching system.

The token syntax could be something like [webform-submission:interval:user:wait]

It will be usefull if you can divide the tokens into something like:

  • [webform-submission:interval:user:wait]
  • [webform-submission:interval:user:wait:minutes]
  • [webform-submission:interval:user:wait:seconds]

Another solution but it is more complicated:

Add the interval time to a countdown timer element to be updated using Ajax.

  • jrockowitz committed c581d4a on 3049534-limit-wait
    Issue #3049534 by C.E.A: Add a token for "Per user submission limit...
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new15.64 KB

Please review the attached patch.

For now, I think just displaying the wait time and second should be okay. Drupal's date diff format does not support returning only minutes.

  • jrockowitz committed 29a9341 on 3049534-limit-wait
    Issue #3049534 by C.E.A: Add a token for "Per user submission limit...
jrockowitz’s picture

StatusFileSize
new16.19 KB

This patch adds a max cache age to the bubbleable metadata.

c.e.a’s picture

Patch #8 returned:

$ patch -p1 < 3049534-9.patch
patching file src/Utility/WebformDateHelper.php
patching file src/WebformSubmissionForm.php
patching file tests/modules/webform_test/config/install/webform.webform.test_form_limit_wait.yml
patching file webform.tokens.inc
Hunk #1 FAILED at 8.
Hunk #2 succeeded at 96 (offset -1 lines).
Hunk #3 succeeded at 112 (offset -1 lines).
Hunk #4 succeeded at 128 (offset -1 lines).
Hunk #5 succeeded at 144 (offset -1 lines).
Hunk #6 succeeded at 504 (offset -1 lines).
Hunk #7 succeeded at 520 (offset -1 lines).
Hunk #8 succeeded at 536 (offset -1 lines).
Hunk #9 succeeded at 552 (offset -1 lines).
Hunk #10 succeeded at 901 (offset -10 lines).
1 out of 10 hunks FAILED -- saving rejects to file webform.tokens.inc.rej
jrockowitz’s picture

Please apply the patch to the latest dev release or check out the 3049534-limit-wait branch.

  • jrockowitz committed 62dbf91 on 3049534-limit-wait
    Issue #3049534 by jrockowitz, C.E.A: Add a token for "Per user...
jrockowitz’s picture

StatusFileSize
new16.13 KB

The attached patch has minor spacing tweaks and should apply to the latest dev release without any problems.

  • jrockowitz committed d72c518 on 3049534-limit-wait
    Issue #3049534 by jrockowitz, C.E.A: Add a token for "Per user...
jrockowitz’s picture

StatusFileSize
new25.05 KB

The attached patch includes test coverage.

c.e.a’s picture

I am very very sorry about the delay, I totally forget about this feature request... now I am back again!

I have tested #14 and it is working as expected.

However, when the webform is closed from further submission until the countdown reaches the end, an informational message will appear to the user: This webform is closed. Only submission administrators are allowed to access this webform and create new submissions.

Only if you can remove this informational message, because it will confuse the users...

Thank you,

jrockowitz’s picture

Status: Needs review » Postponed (maintainer needs more info)

Can you please post an example webform?

c.e.a’s picture

Ok... I am sorry, my bad!

the informational message is shown only for admin users and not for other roles.

So everything is working as expected!

Thank you,

jrockowitz’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community
c.e.a’s picture

Status: Reviewed & tested by the community » Active
c.e.a’s picture

Status: Active » Reviewed & tested by the community

Changing the status at the same time!

  • jrockowitz committed 1a8d96f on 8.x-5.x
    Issue #3049534 by jrockowitz, C.E.A: Add a token for "Per user...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • jrockowitz committed 866815b on 8.x-5.x
    Issue #3049534 by jrockowitz, C.E.A: Add a token for "Per user...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.