Auto Redirect to next quiz
Auto Redirect to next quiz
Hello,
So at the moment we are having multiple quizes in a chained fashion there will be upto 5,000 questions per quiz but each one picks say 10 at random. This is working well, but it's falling short on the page changes, You show a saved success message and then a button which allows going to the chained quiz, which in turn then shows a page which shows another button to start that course.
I've improved it slightly with the following core hack:
CjQuizApi.submitAjaxForm = function(buttonObj, formName, action, triggerBefore, triggerAfter, customData)
{
var button = $(buttonObj);
var form = button.closest(formName).length > 0 ? button.closest(formName) : $(formName);
var url = form.attr('action');
customData = customData ? customData : '';
form.find('input[name="task"]').val(action);
form.ajaxSubmit({
type : 'POST',
url : url + (/?/.test(url) ? '&' : '?') +'format=json',
dataType : 'json',
data : {data: customData},
encode : true,
beforeSerialize : function(jqForm, options)
{
CjQuizApi.refreshEditor();
CjQuizApi.form_submitted = CjQuizApi.executeFunctionByName(triggerBefore, CjQuizApi, action, button, form, null);
return CjQuizApi.form_submitted;
},
success : function(data, status, xhr, jqForm)
{
CjQuizApi.success(triggerAfter, CjQuizApi, action, button, form, data);
/** START MOD **/
chainedRoute = $('#chainedQuizRoute');
if (chainedRoute.length > 0 && data.data.finished == true) {
window.location.href = chainedRoute.val();
}
/** END - MOD **/
},
error : function (xhr, status, error)
{
CjQuizApi.success(triggerAfter, CjQuizApi, action, button, form, xhr.responseJSON);
}
});
};
So I also added in an input which generates the next route, but this makes the whole process better for the user taking the quiz.
It would be even better if the quiz auto-started as they could click cancel.
Would you be able to add such options to the core? This provides a hugely improved workflow.
Many thanks