WS: mod_feedback_process_page, form validation?

WS: mod_feedback_process_page, form validation?

by Markku Lahtinen -
Number of replies: 3
Hi fellow Moodlers,

I have succeeded in creating users, enrolling them to courses containing feedback activity modules and those enrolled users are able to complete the feedback forms, all this through the WS API.  Everything seems to work as advertised, that is really cool 🙂

Unfortunately I have somewhat limited understanding of the inner workings of Moodle code base. In particular, currently I do not understand the following:

Can I do form validation of feedback forms through API?

It seems that mod_feedback_process_page returns warnings array, but in my case it is always empty for whatever reason.

    Array 
        (
        [jumpto] => int        
        [completed] => int        
        [completionpagecontents] => string        
        [siteaftersubmit] => string        
        [warnings] =>
            Array 
                (
                [0] =>
                    Array 
                        (
                        [item] => string                        
                        [itemid] => int                        
                        [warningcode] => string                        
                        [message] => string                        
                        )
                )        
        )
Should I use something else than mod_feedback_launch_feedback  and mod_feedback_process_page in order to get the feedback form validation info through the API and show the possible errors on the form?

Any ideas or pointers to relevant info are appreciated.


Average of ratings: -
In reply to Markku Lahtinen

Re: WS: mod_feedback_process_page, form validation?

by Markku Lahtinen -
Sorry for the missing background info, I am on Moodle 4.3 (Build: 20231009)
In reply to Markku Lahtinen

Re: WS: mod_feedback_process_page, form validation?

by Hammad Ali -

To obtain feedback form validation information through the API and display potential errors on the form, you should check the 'warnings' array returned by mod_feedback_process_page. If it's consistently empty, there may be a different issue.

Ensure that your feedback form is configured correctly and that the fields match the expected structure. If you're not getting the expected warnings, you might want to inspect the form setup, input data, or any custom validation logic you have. ReceiptifySpotify

Consider using additional debugging methods, such as printing the input data and checking the form configuration to identify the root cause of the issue. If problems persist, consulting the Moodle API documentation or seeking support from the Moodle community might provide more insights or solutions specific to your case.


In reply to Hammad Ali

Re: WS: mod_feedback_process_page, form validation?

by Markku Lahtinen -
Many thanks for your insights, I'll have a look at this in the near future. Good to know that  the 'warnings' array  is the way to go : )
BR: Markku