function quiz_question_revision_actions_form in Quiz 7.5
Same name and namespace in other branches
- 8.6 question_types/quiz_question/quiz_question.pages.inc \quiz_question_revision_actions_form()
- 8.5 question_types/quiz_question/quiz_question.pages.inc \quiz_question_revision_actions_form()
- 7.6 question_types/quiz_question/quiz_question.pages.inc \quiz_question_revision_actions_form()
Create the form for the revision actions page.
Form for deciding what to do with the quizzes a question is member of when the question is revised.
_state
Parameters
array $form:
stdClass $question_node:
Return value
array An renderable FAPI array.
1 string reference to 'quiz_question_revision_actions_form'
- quiz_question_menu in question_types/
quiz_question/ quiz_question.module - Implements hook_menu().
File
- question_types/
quiz_question/ quiz_question.pages.inc, line 21 - User page callbacks for the quiz_question module.
Code
function quiz_question_revision_actions_form($form, $form_state, $question_node) {
$efq = new EntityFieldQuery();
// Find relationships that contain not the current version of this question.
$result = $efq
->entityCondition('entity_type', 'quiz_question_relationship')
->propertyCondition('child_nid', $question_node->nid)
->execute();
$relationships = entity_load('quiz_question_relationship', array_keys($result['quiz_question_relationship']));
$affected = array();
foreach ($relationships as $relationship) {
$affected[$relationship->parent_nid] = $relationship->parent_nid;
}
$text = t('You have created a new revision of a question that belongs to %num quizzes. Choose what you want to do with the different quizzes.', array(
'%num' => count($affected),
));
$form['intro'] = array(
'#markup' => $text,
);
$form['question_node'] = array(
'#type' => 'value',
'#value' => $question_node,
);
$form['quizzes'] = array();
// Create a form element for each quiz.
foreach ($relationships as $relationship) {
$quiz = node_load($relationship->parent_nid);
if (node_access('update', $quiz)) {
$answered = quiz_has_been_answered($quiz);
$options = array();
if (user_access('manual quiz revisioning')) {
$options['update'] = t('Update (no revision)');
}
$options['revise'] = t('Create new revision');
$options['nothing'] = t('Do nothing');
$form['quizzes']['#tree'] = TRUE;
$form['quizzes'][$quiz->nid]['revise'] = array(
'#type' => 'radios',
'#title' => check_plain($quiz->title) . ' - ' . ($answered ? t('answered') : t('unanswered')) . ', ' . ($quiz->status ? t('published') : t('unpublished')),
'#options' => $options,
'#default_value' => $answered ? 'nothing' : 'update',
);
$form['quizzes'][$quiz->nid]['status'] = array(
'#type' => 'checkbox',
'#title' => $quiz->status ? t('Leave published') : t('Publish'),
'#default_value' => $quiz->status,
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
// Help texts.
$form['update_expl'] = array(
'#type' => 'item',
'#title' => t('Update'),
'#description' => t('Replace the old revision of the question with the new revision. This may affect reporting. It is the default when the most recent Quiz revision has not been answered.'),
);
$form['revise_expl'] = array(
'#type' => 'item',
'#title' => t('Create new revision'),
'#description' => t('If the current revision of a Quiz has been answered, you should make a new revision to ensure that existing answer statistics and reports remain correct.') . '<br/>' . t('If the new revision of the question only corrects spelling errors, you do not need to create a new revision of the Quiz.'),
);
$form['nothing_expl'] = array(
'#type' => 'item',
'#title' => t('Do nothing'),
'#description' => t('The quiz will not be revised, and will still use the old revision of the question.'),
);
return $form;
}