Skip to content
Snippets Groups Projects
Commit 87831813 authored by Sivaji Ganesh Jojodae's avatar Sivaji Ganesh Jojodae
Browse files

patch #443482 fixed by sivaji: hook_cron to remove incomplete quiz results

parent 8e7c6874
No related branches found
No related tags found
No related merge requests found
......@@ -551,7 +551,13 @@ function quiz_admin_settings() {
'#description' => t('Filter the actions dropdown by a specific type.'),
);
$form['quiz_remove_partial_quiz_record'] = array(
'#type' => 'select',
'#title' => t('Remove Incomplete Quiz Records (older than)'),
'#options' => quiz_remove_partial_quiz_record_value(),
'#description' => t('Number of days that you like to keep the incomplete quiz records'),
);
$form['quiz_look_feel'] = array(
'#type' => 'fieldset',
'#title' => t('Look and Feel Settings'),
......@@ -785,4 +791,15 @@ function theme_question_selection_table($form) {
$table = theme('table', $headers, $rows, array('id' => 'questions-order-' . $table_counter));
return $table . drupal_render($form);
}
\ No newline at end of file
function quiz_remove_partial_quiz_record_value() {
$list = array();
$list[0] = t('Never');
for ($i=1; $i<31; $i++) {
$list[$i*86400] = $i. ' ' . t('Day(s)');
}
for ($i=35; $i<125; $i+=5) {
$list[$i*86400] = $i . ' ' . t('Day(s)');
}
return $list;
}
......@@ -192,7 +192,7 @@ function quiz_menu() {
$items['admin/quiz/%/view'] = array(
'title' => t('View @quiz', array('@quiz' => QUIZ_NAME)),
'page callback' => 'quiz_admin',
'page arguments' => array(2),
'page arguments' => array(2),
'access arguments' => array('administer quiz'),
'type' => MENU_CALLBACK,
'file' => 'quiz.admin.inc',
......@@ -2556,3 +2556,14 @@ function quiz_action_options($type = 'all') {
return $options[$type];
}
}
/*
* Implementation of hook_cron()
*/
function quiz_cron() {
$rm_time = variable_get('quiz_remove_partial_quiz_record','0');
if ($rm_time) { // $time = 0 for never
db_query('DELETE FROM {quiz_node_results} WHERE !time_end AND (%d - time_start) > %d', time(), $rm_time);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment