ajax_quiz.admin.inc in Quiz 6.6
File
includes/ajax_quiz/ajax_quiz.admin.inc
View source
<?php
function ajax_quiz_instruction($node) {
if (isset($_REQUEST['ajax_load_example']) && $_REQUEST['ajax_load_example']) {
_ajax_quiz_get_questions($node);
}
else {
drupal_add_js(drupal_get_path('module', 'ajax_quiz') . '/ajax_quiz.js');
$output = '<div class="ajax-quiz-wrapper">';
$output .= '<div class="ajax-quiz-description">' . $node->body . '</div>';
$output .= '<div class="ajax-quiz-start">' . l(t('Start'), $_GET['q'], array(
'attributes' => array(
'class' => 'ajax-load-example',
),
)) . '</div>';
$output .= '</div>';
return $output;
}
}
function _ajax_quiz_get_questions($node) {
$output = '';
foreach (drupal_get_messages() as $type) {
foreach ($type as $message) {
$output .= '<script type="text/javascript"> alert("' . "{$type} : {$message}" . '"); </script>';
}
}
$output .= node_view($node, FALSE, TRUE);
$result = array(
'content' => $output,
'__callbacks' => array(
'Drupal.AjaxLoadExample.formCallback',
),
);
drupal_alter('ajax_data', $result, 'ajax_load_example', 'node_view');
drupal_json($result);
}