function theme_multichoice_generate_title in Quiz 6.2
Same name and namespace in other branches
- 5.2 multichoice.module \theme_multichoice_generate_title()
- 6.6 question_types/multichoice/multichoice.module \theme_multichoice_generate_title()
- 6.3 question_types/multichoice/multichoice.module \theme_multichoice_generate_title()
- 6.5 question_types/multichoice/multichoice.module \theme_multichoice_generate_title()
Create a decent question title based on taxonomy and question body.
This is themeable so others can create their own titles without too much trouble: 1. Pick the first taxonomy term from the first vocabulary. 2. Append a numeric sequence. 3. Append the first 50 chars of question body, or less, depending on where the word breaks are.
Parameters
$node: The question node to generate a title for.
Return value
A title string.
1 theme call to theme_multichoice_generate_title()
- multichoice_submit in ./
multichoice.module - Implementation of hook_submit().
File
- ./
multichoice.module, line 1093 - Multiple choice question type for the Quiz module.
Code
function theme_multichoice_generate_title($node) {
$title = '';
// Get the first taxonomy term if available.
$taxonomy = $node->taxonomy;
while (is_array($taxonomy)) {
$taxonomy = current($taxonomy);
}
if (!empty($taxonomy)) {
$taxonomy = taxonomy_get_term($taxonomy);
$title .= $taxonomy->name . ' - ';
}
// Append a numeric sequence.
$qnum = variable_get('multichoice_qnum', 0);
$title .= $qnum++ . ' - ';
variable_set('multichoice_qnum', $qnum);
// Strip tags from question body and shorten to 50 or less chars.
$shortstring = trim(substr(strip_tags($node->body), 0, 50));
if (FALSE !== ($breakpoint = strrpos($shortstring, ' '))) {
$shortstring = substr($shortstring, 0, $breakpoint);
}
return $title . $shortstring;
}