Fixed study group matching leader/helper calculations
This commit is contained in:
@@ -1502,12 +1502,12 @@ function _booking_leader_helper_email_summary($node) {
|
|||||||
" INNER JOIN {booking_person} p on m.booking_node_id = p.nid " .
|
" INNER JOIN {booking_person} p on m.booking_node_id = p.nid " .
|
||||||
" WHERE booking_eventid = :eid " .
|
" WHERE booking_eventid = :eid " .
|
||||||
" AND booking_studygroup_id = :group AND booking_studygroup_role = :role AND booking_session_id = :session",
|
" AND booking_studygroup_id = :group AND booking_studygroup_role = :role AND booking_session_id = :session",
|
||||||
array(':eid' => $event->eid, ':group' => $i, ':role' => $otherrole_id, ':session' => $node->$sessionid,
|
array(':eid' => $event->eid, ':group' => $studygroup->sid, ':role' => $otherrole_id, ':session' => $node->$sessionid,
|
||||||
));
|
));
|
||||||
$otherperson = $otherperson_query->fetchAll();
|
$otherperson = $otherperson_query->fetchAll();
|
||||||
|
|
||||||
watchdog('booking', "<pre>Other person for studygroup !group and role !role result:\n@info</pre>",
|
watchdog('booking', "<pre>Other person for studygroup !group and role !role result:\n@info</pre>",
|
||||||
array('!group' => $i, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true)));
|
array('!group' => $studygroup->sid, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true)));
|
||||||
|
|
||||||
foreach ($otherperson as $other)
|
foreach ($otherperson as $other)
|
||||||
{
|
{
|
||||||
@@ -1517,7 +1517,7 @@ function _booking_leader_helper_email_summary($node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rows[] = t('!role for !descrip (section !id). Your !otherrole is !other. You can contact them on !phone or !email.',
|
$rows[] = t('!role for !descrip (section !id). Your !otherrole is !other. You can contact them on !phone or !email.',
|
||||||
array('!role' => $role, '!id' => $studygroups[$i]->sid, '!descrip' => $studygroups[$i]->booking_studygroup_descrip,
|
array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip,
|
||||||
'!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
|
'!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@@ -28,16 +28,30 @@ function booking_studygroups_leaders_calculate() {
|
|||||||
$calculation_messages[] = t('Processing eligible Leader/helper with id !id and age !age',
|
$calculation_messages[] = t('Processing eligible Leader/helper with id !id and age !age',
|
||||||
array('!id' => $person->nid, '!age' => $age)
|
array('!id' => $person->nid, '!age' => $age)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
foreach ($groups as $studygroup)
|
||||||
|
{
|
||||||
|
//watchdog('booking_debug', "<pre>Study Group Element\n@info</pre>", array('@info' => print_r( $studygroup, true)));
|
||||||
|
if ($age >= 22 && $studygroup->leader_nid == 0)
|
||||||
|
{
|
||||||
|
$studygroup->leader_nid = $person->nid;
|
||||||
|
$calculation_messages[] = t("Study Group Assignment as leader for nid !nid to group !descrip at session id !sid",
|
||||||
|
array('!nid' => $person->nid, '!descrip' => $studygroup->booking_studygroup_descrip, '!sid' => $studygroup->session_id, '@info' => print_r( $studygroup, true)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
elseif ($age < 22 && $studygroup->helper_nid == 0)
|
||||||
|
{
|
||||||
|
$studygroup->helper_nid = $person->nid;
|
||||||
|
$calculation_messages[] = t("Study Group Assignment as helper for nid !nid to group !descrip at session id !sid",
|
||||||
|
array('!nid' => $person->nid, '!descrip' => $studygroup->booking_studygroup_descrip, '!sid' => $studygroup->session_id, '@info' => print_r( $studygroup, true)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if someone is 22 or over, they're a leader
|
//if someone is 22 or over, they're a leader
|
||||||
if ($age >= 22)
|
//$next_group_index = $groups[_booking_get_next_studygroup('leader_nid', $groups)];
|
||||||
{
|
|
||||||
$next_group_index = $groups[_booking_get_next_studygroup('leader_nid', $groups)];
|
//$groups[$next_group_index]->leader_nid = $person->nid;
|
||||||
$calculation_messages[] = t('Assigning id !id to study group !group as a leader',
|
|
||||||
array('!id' => $person->nid, '!group' => $next_group_index)
|
|
||||||
);
|
|
||||||
$groups[$next_group_index]->leader_nid = $person->nid;
|
|
||||||
}
|
|
||||||
//if someone is under 22, they're a helper
|
//if someone is under 22, they're a helper
|
||||||
|
|
||||||
//left over people become a reserve leader
|
//left over people become a reserve leader
|
||||||
@@ -152,7 +166,7 @@ function _booking_studygroups_retrieve_groups() {
|
|||||||
$new_group = clone $group;
|
$new_group = clone $group;
|
||||||
|
|
||||||
$new_group->session_id = $i;
|
$new_group->session_id = $i;
|
||||||
$new_group->leader_nid = -1;
|
$new_group->leader_nid = 0;
|
||||||
$new_group->helper_nid = 0;
|
$new_group->helper_nid = 0;
|
||||||
$new_group->reserve_nid = 0;
|
$new_group->reserve_nid = 0;
|
||||||
$new_group->processed = 0;
|
$new_group->processed = 0;
|
||||||
@@ -161,7 +175,7 @@ function _booking_studygroups_retrieve_groups() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdog('booking', "<pre>Study Group Sessions:\n@info</pre>", array('@info' => print_r( $groups, true)));
|
//watchdog('booking', "<pre>Study Group Sessions:\n@info</pre>", array('@info' => print_r( $groups, true)));
|
||||||
return $groups;
|
return $groups;
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user