Status
Not open for further replies.

mrklein

Customer
Is there a list/chart of how the various vbQuiz style vars are used to make the various pages?

Our forum has its own custom style set, and we are making some modifications to the quiz layout to mesh better with some tutorials we are linking to the quizes?

For instance, we are trying to add buttons to the Results and Answers & Explanations pages to "Retake Quiz" and "Take Another Quiz", and we're having a hard time finding the right template vars to add to those pages...

Any guidance would be greatly appreciated.
 
It's kind of complex how they go together because of the different question types using different templates for the same type of thing. If you are looking at putting things into the completed quiz area, like when they are viewing their results, that would be most of the templates starting with dbtech_vbquiz_quiz_final_ . The dbtech_vbquiz_quiz_final_results template is the main body of the page and any of the others are for letting sections depending on the quiz type that was taken.
 
Thanks, Dylan, that helps a lot.

Is there a specific "bit" template or "raw" variable available in that "final" template that we could use as a link for "Take this quiz again" and one back to the main quiz page (or is that just using the variable for the quiz file without any query string) ?
 
In the template dbtech_vbquiz_quiz_final_results I have a template hook at the top and bottom of the right side boxes if you want to add another box in there with links.
 
Dylan,

I see these two hooks in the template "":

{vb:raw template_hook.dbtech_vbquiz_result_side_stats_top}
...
{vb:raw template_hook.dbtech_vbquiz_result_side_stats_bottom}


but I cannot find where I can access them. When I create a new plugin, the only things in the list that are close to these names are:

dbtech_vbquiz_quizsimilar_start (DragonByte Tech: vBQuiz (Pro))
dbtech_vbquiz_quiz_results_complete (DragonByte Tech: vBQuiz (Pro))
dbtech_vbquiz_quiz_results_start (DragonByte Tech: vBQuiz (Pro))
dbtech_vbquiz_take_new_quiz_complete (DragonByte Tech: vBQuiz (Pro))

and these don't seem to work when I put a simple debugging statement in the code.

Am I looking in the right place to add code/output for those two hooks?
 
The hooks in the plugin dropdown are file hook locations. To use template hook locations, you have to use them inside of your plugin code.

Brad via Tapatalk
 
Like bszopi said, the plugin needs to attach to a file hook which is different then a template hook. The file hook executes code at a certain location in a php file. The template hook will insert data into a template at a certain location.

What you want to do is try creating a plugin that is on this hook
PHP:
dbtech_vbquiz_quiz_results_complete
This is at the end of the quiz results php page.

Then whatever you want to display, assign it to the variable

PHP:
$template_hook['dbtech_vbquiz_result_side_stats_top'] = $some_data_to_display;
 
template modifications for a "Retake Quiz" button

I created a plugin, and tested both template hooks that Dylan suggested, but I could not get any of the "dbtech_vbquiz_" variables, to populate correctly. For instance, in the following in the string in the plugin:
Code:
    <form class="vbform block" action="{vb:raw vboptions.dbtech_vbquiz_urlpath_text}{vb:raw vboptions.dbtech_vbquiz_filename_text}?do=takequiz" method="post" enctype="multipart/form-data" name="vbform">
        <input type="submit" class="button" value="Retake this quiz" />
	<input type="hidden" name="securitytoken" value="{vb:var bbuserinfo.securitytoken}" />
	<input type="hidden" name="id" id="id" value="{vb:raw quiz_data[quiz_id]}" />
    </form>

the vb variables do not interpolate; instead, they show up in the HTML verbatim.

I tried putting this code directly in the template "dbtech_vbquiz_quiz_final_results", and the variables do interpolate, but when I click on that button, it just takes me back to the vbquiz home page.

Ultimately, I would like access to the quiz just taken, the next quiz in the series, and the previous quiz in the series. I would also like a way to save a URL in the quiz that I could pull into a link so that they could review the lessons before they re-take the quiz. In looking at the database, the only free-form metadata field that looks like it is available for something like that is the "tagging" field.

Keep in mind that only admins will ever create quizzes on our site. They are extremely structured, and relate back to a series of tutorials done as categorized Movable Type blogs. So, I don't mind hacking the mod's templates or even code--I just want to do it safely and efficiently.
 
If you put that straight into the plugin then it wont work. You need to put the actual data in there and not the template variables. So it would be something like

PHP:
$retake = '                        <div class="block smaller">
                            <div id="statistics" class="blockbody floatcontainer">
                                <ul class="blockrow">
                                    <li class="floatcontainer" style="margin-bottom: 10px;">
<form class="vbform block" action="' . $vbulletin->options['dbtech_vbquiz_urlpath_text'] .   $vbulletin->options['dbtech_vbquiz_filename_text'] . '?do=takequiz" method="post" enctype="multipart/form-data" name="vbform">
        <input type="submit" class="button" value="Retake this quiz" />
    <input type="hidden" name="securitytoken" value="' . $vbulletin->userinfo['securitytoken'] . '" />
    <input type="hidden" name="id" id="id" value="' . $taken_complete_data[quiz_id] . '" />
    </form>
                                    </li>
                                </ul>
                            </div>
                        </div>';


$template_hook['dbtech_vbquiz_result_side_stats_bottom'] .= $retake;

That should work
 
Dylan,

Thanks for the help. I got the plugin hook, and the bottom template hook working.

Now, I would like to do something similar on the view answers page, but the hooks listed in the "view_result_answers.php" file aren't showing up in the "Add Plugin" hook drop-down.

I looked in /forums/includes/xml/hooks_dbtech_vbquiz.xml and added the following two lines:

Code:
<hook>dbtech_vbquiz_quiz_results_answers_start</hook>
<hook>dbtech_vbquiz_quiz_results_answers_complete</hook>

and now those two hooks are showing up in the list when I try to add a plugin, but the very same code that you gave above, which worked on the results page, is not working here. I did remember to change "dbtech_vbquiz_result_side_stats_bottom" to "dbtech_vbquiz_view_answer_side_stats_bottom" in the plugin code.

The second plug in code doesn't seem to be running at all. (I put in PHP error_log() in both plugins, and the results plugin wrote to the log, but the answers plugin never fired.)

I would just put the code right in the templates, but now I have a request to show "Previous Quiz" and "Next Quiz" buttons, and I think I will need to adapt some of the database code to look up the previous and next quizzes, by date. I would rather do that in a plugin rather than modifying the action files.

Any idea how to get those hooks working on the answer page?
 
Last edited:
Took me a few to figure it out heh. It's


PHP:
<hook>dbtech_vbquiz_quiz_result_answers_start</hook>
<hook>dbtech_vbquiz_quiz_result_answers_complete</hook>

not

PHP:
<hook>dbtech_vbquiz_quiz_results_answers_start</hook>
<hook>dbtech_vbquiz_quiz_results_answers_complete</hook>
 
Doh! I copied and modified the Result page hooks, and didn't notice that the word "result" was singular in the templates.

Will you put these hooks in the XML file in future releases, so I won't have to remember to modify them after updating?

On a related note, I'm modifying the "main.php" file in the /actions folder with a custom query and new template var to show a list of quizzes under each category. What's the best way to ensure this sticks and doesn't get overwritten by an update of the plugin?



Took me a few to figure it out heh. It's


PHP:
<hook>dbtech_vbquiz_quiz_result_answers_start</hook>
<hook>dbtech_vbquiz_quiz_result_answers_complete</hook>

not

PHP:
<hook>dbtech_vbquiz_quiz_results_answers_start</hook>
<hook>dbtech_vbquiz_quiz_results_answers_complete</hook>
 
Doh! I copied and modified the Result page hooks, and didn't notice that the word "result" was singular in the templates.

Will you put these hooks in the XML file in future releases, so I won't have to remember to modify them after updating?

On a related note, I'm modifying the "main.php" file in the /actions folder with a custom query and new template var to show a list of quizzes under each category. What's the best way to ensure this sticks and doesn't get overwritten by an update of the plugin?

Already put them in the working files :)

There really is no way to keep the changes from being overwritten. You could not overwrite the main.php file but that would usually cause problems since there are likely to be new changes in there. The best way is to do it is just keep a copy of the changes and the location that would get overwritten. If changes are made to the file you want to make sure what you put in there still jives with the existing product anyway.

If you created plugins, I would make sure they aren't associated with the quiz product and they wont get overwritten.
 
Status
Not open for further replies.

Legacy vBQuiz

vBulletin 3.8.x vBulletin 4.x.x
Seller
DragonByte Technologies
Release date
Last update
Total downloads
435
Customer rating
0.00 star(s) 0 ratings
Top