function opigno_simple_ui_update_quiz_labels in Opigno 7
Update the quiz fields and settings and name them "Lesson".
2 calls to opigno_simple_ui_update_quiz_labels()
- opigno_simple_ui_install in modules/
simple_ui/ opigno_simple_ui.install - Implements hook_install().
- opigno_simple_ui_modules_enabled in modules/
simple_ui/ opigno_simple_ui.module - Implements hook_modules_enabled().
File
- modules/
simple_ui/ includes/ opigno_simple_ui.quiz.inc, line 135 - Quiz specific enhancements.
Code
function opigno_simple_ui_update_quiz_labels() {
variable_set('quiz_name', t("Lesson"));
$instance = field_info_instance('node', 'quiz_weight', 'quiz');
if (!empty($instance)) {
$instance['label'] = "Lesson weight";
field_update_instance($instance);
}
$instance = field_info_instance('node', 'quiz_type', 'quiz');
if (!empty($instance)) {
$instance['label'] = "Lesson type";
$instance['description'] = "Sets the type of this lesson. Can be <em>theory</em> (not shown in results by default), <em>quiz</em> (always shown in results) and <em>mix</em>.";
field_update_instance($instance);
}
$instance = field_info_instance('node', 'body', 'quiz');
if (!empty($instance)) {
$instance['label'] = "Introduction";
field_update_instance($instance);
}
foreach (array(
'long_answer' => array(
'body' => -1,
'og_group_ref' => 1,
),
'matching' => array(
'body' => -5,
'og_group_ref' => 1,
),
'multichoice' => array(
'body' => -5,
'og_group_ref' => 1,
),
'quizfileupload' => array(
'body' => -4,
),
'quiz_ddlines' => array(
'body' => -4,
),
'quiz_directions' => array(
'body' => -4,
),
'scale' => array(
'body' => -4,
),
'short_answer' => array(
'body' => -5,
),
'truefalse' => array(
'body' => -5,
),
) as $type => $fields) {
foreach ($fields as $field => $weight) {
$instance = field_read_instance('node', $field, $type);
if (!empty($instance)) {
$instance['widget']['weight'] = $weight;
field_update_instance($instance);
}
}
}
$settings = variable_get('field_bundle_settings_node__multichoice', NULL);
if ($settings) {
$settings['extra_fields']['form']['title']['weight'] = -10;
variable_set('field_bundle_settings_node__multichoice', $settings);
}
/*
array('long-answer', 'quizfileupload', 'quiz-directions');
foreach (array_keys(_quiz_question_get_implementations()) as $type) {
$instance = field_read_instance('node', 'body', $type);
if (!empty($instance)) {
$instance['widget']['weight'] = -6;
field_update_instance($instance);
}
}
*/
$instance = field_info_instance('node', 'course_required_quiz_ref', OPIGNO_COURSE_BUNDLE);
if (!empty($instance)) {
$instance['label'] = "Lesson required for the course validation";
field_update_instance($instance);
}
}