function opigno_quiz_app_node_update in Opigno Quiz App 7
Implements hook_node_update().
File
- ./
opigno_quiz_app.module, line 360 - Module file. Defines module hooks.
Code
function opigno_quiz_app_node_update($node) {
if ($node->type == 'quiz' && !empty($node->nid) && !empty($node->og_group_ref)) {
$original_node = $node->original;
// adds the weight for new courses
foreach ($node->og_group_ref as $lang => $items) {
foreach ($items as $item) {
// Set a default weight of 0.
if (!opigno_quiz_app_is_in_entity_reference($item['target_id'], $original_node->og_group_ref)) {
opigno_quiz_app_set_course_quiz_weight($item['target_id'], $node->nid);
}
}
}
// removes the weight from courses that were removed
foreach ($original_node->og_group_ref as $lang => $items) {
foreach ($items as $item) {
// Set a default weight of 0.
if (!opigno_quiz_app_is_in_entity_reference($item['target_id'], $node->og_group_ref)) {
opigno_quiz_app_delete_course_quiz_weight($item['target_id'], $node->nid);
}
}
}
}
}