function quiz_ddlines_install in Quiz 7.4
Same name and namespace in other branches
- 8.4 question_types/quiz_ddlines/quiz_ddlines.install \quiz_ddlines_install()
Implements hook_install().
File
- question_types/
quiz_ddlines/ quiz_ddlines.install, line 15 - Sponsored by: Senter for IKT i utdanningen Code: paalj
Code
function quiz_ddlines_install() {
// Add body field to multichoice node
quiz_question_add_body_field('quiz_ddlines');
cache_clear_all('autoload:', 'cache');
// At this point quiz core has created the ddlines node type.
// Now it's time to add the image field to the node:
if (!field_info_field('field_image')) {
$field = array(
'field_name' => 'field_image',
'type' => 'image',
);
field_create_field($field);
}
$instance = field_info_instance('node', 'field_image', 'quiz_ddlines');
if (empty($instance)) {
$help_text = t("<p>Start by uploading a background image. The image is movable within the canvas.<br/> \n \t\t\t\tThe next step is to add the alternatives, by clicking in the canvas. \n \t\t\t\tEach alternative consists of a circular hotspot, a label, and a connecting line. You need \n \t\t\t\tto double click the rectangular label to add the text, and move the hotspot to the correct\n \t\t\t\tposition. When selecting a label, a popup-window is displayed, which gives you the following\n \t\t\t\talternatives:\n \t\t\t\t<ul>\n \t\t\t\t\t<li>Set the alternative's feedback (only possible if feedback is enabled)</li>\n \t\t\t\t\t<li>Set the color of each alternative</li>\n \t\t\t\t\t<li>Delete the alternative</li>\n \t\t\t\t</ul> \t\t\t\t\n \t\t\t\t</p>");
$instance = array(
'field_name' => 'field_image',
'entity_type' => 'node',
'bundle' => 'quiz_ddlines',
'label' => 'Background image',
'description' => $help_text,
'required' => TRUE,
'settings' => array(
'no_ui' => TRUE,
),
'widget' => array(
'settings' => array(
'preview_image_style' => 'quiz_ddlines',
'no_ui' => TRUE,
),
),
);
field_create_instance($instance);
}
}