It would be very useful to be able to add a role if a user successfully passes a quiz. If this should be handled in another way I apologize.

Comments

cmillet1’s picture

I second this request. The purpose my my quiz is to make sure a user has gained some skill or knowledge before they can access a certain portion of the site.

Optionally, the ability to execute some code on successful completion would definitely do the trick as well.

cmillet1’s picture

My apologies. It looks like you are able to execute php as I described above.

westwesterson’s picture

glad you found the answer to your problem :-)

cmillet1’s picture

Seems I spoke too soon. I'm having problems getting my code to execute (2.0 beta 2), even though I've set the input type to parse PHP. But that's outside the scope of this issue.. It would still be nice to have the functionality described by the original submitter though.

westwesterson’s picture

If someone were to implement the workflow-ng api for quiz i'd be happy to commit it ;)

cmillet1’s picture

Any suggestions as to why my code is not executing? Has anyone had problems with this version of the Quiz module? It seems like I've done everything obvious (such as setting the input type to PHP), is there something else I might be missing?

Any help would be most appreciated. Thanks!

westwesterson’s picture

Version: 6.x-2.x-dev » 5.x-2.x-dev

changing to current version for 5.x-2.x development

cmillet1’s picture

Thanks! This is working now with Beta 3.

For those who are interested, the code I'm using for "Summary text if passed.: " to add a new role to a user when the pass a quiz is:

global $user;

$rid = 6;
$role_name = 'passedquiz';

$roles = $user->roles + array($rid => $role_name);
user_save($user, array('roles' => $roles));

patcon’s picture

If I understand correctly, the equivalent of the "Summary text is passed" field no longer allows input format for be chosen, so PHP isn't possible anymore, correct? Anyone have a work-around?

Thanks!

mbutcher’s picture

Issue tags: +actions, +hook_quiz_end, +roles

A patch for input format handling would be welcome.

The way to handle it in Quiz 3 is with an action associated with the trigger that fires at the end of a quiz. We are also thinking of adding some additional hooks so that modules could link in and do something when a quiz is done.

Unfortunately, though, I don't have a good suggestion for Quiz 2.

duaelfr’s picture

Component: Code » Code - Import/Export
Status: Active » Closed (won't fix)

This version of Quiz is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.