function AlertWorkloadDistribution($group) { global $DB; $course = $DB->get_record('groups', array('id' => $group), 'courseid')->courseid; $member_rank = RankMembersTasksDistribution($group); //Get the total number of hours based on each student $total_hours = array_sum($member_rank); $equal_hours = $total_hours / count($member_rank); if ($total_hours == 0) { return; } foreach ($member_rank as $key => $member) { $workload = MemberWorkloadDistribution($member, $equal_hours); if (!empty($workload)) { add_to_log($course, 'project', 'alert', 'workload dist: ' . $group); return true; break; } //end if } //end foreach }
require_course_login($course, true, $cm); $context = context_module::instance($cm->id); require_capability('mod/project:view', $context); $PAGE->set_url('/mod/project/workload_distribution.php', array('id' => $cm->id)); $PAGE->set_title($course->shortname . ': ' . $project->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($project); $options = empty($project->displayoptions) ? array() : unserialize($project->displayoptions); /// Check to see if groups are being used here $groupmode = groups_get_activity_groupmode($cm); $currentgroup = groups_get_activity_group($cm, true); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string('Workload Distribution'), 2); echo $OUTPUT->heading(format_string(getGroupName($currentgroup)), 4); //$html = "<img src='pix\\".$history_summary->method.".png' width='16px' heigh='16px' /> ".userdate($history_summary->date)."<br /><br />"; $member_rank = RankMembersTasksDistribution($currentgroup); //echo AlertMembersTasksDistribution($member_rank); arsort($member_rank); //Order the Rank by number of hours //Get the total number of hours based on each student $total_hours = array_sum($member_rank); if ($total_hours > 0) { $equal_hours = $total_hours / count($member_rank); $html = "Individual Recommended Hours: " . round($equal_hours, 2) . " Hours<br /><br />"; //If large variance occurs, display column for table if (AlertWorkloadDistribution($currentgroup)) { $html .= "<table style='border:1px solid black;'><tr style='background-color:lightgrey;'><th>Member</th><th>Assigned Hours</th><th>% of Workload</th><th>Variance</th></tr>"; } else { $html .= "<table style='border:1px solid black;'><tr style='background-color:lightgrey;'><th>Member</th><th>Assigned Hours</th><th>% of Workload</th><th></th></tr>"; } foreach ($member_rank as $key => $member) {
require_course_login($course, true, $cm); $context = context_module::instance($cm->id); require_capability('mod/project:view', $context); $PAGE->set_url('/mod/project/workload_distribution.php', array('id' => $cm->id)); $PAGE->set_title($course->shortname . ': ' . $project->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($project); $options = empty($project->displayoptions) ? array() : unserialize($project->displayoptions); /// Check to see if groups are being used here $groupmode = groups_get_activity_groupmode($cm); $currentgroup = groups_get_activity_group($cm, true); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string('Workload Distribution'), 2); echo $OUTPUT->heading(format_string(getGroupName($currentgroup)), 4); //$html = "<img src='pix\\".$history_summary->method.".png' width='16px' heigh='16px' /> ".userdate($history_summary->date)."<br /><br />"; $member_rank = RankMembersTasksDistribution($currentgroup, $project->id); //echo AlertMembersTasksDistribution($member_rank); arsort($member_rank); //Order the Rank by number of hours //Get the total number of hours based on each student $total_hours = array_sum($member_rank); if ($total_hours > 0) { $equal_hours = $total_hours / count($member_rank); $html = "Individual Recommended Hours: " . round($equal_hours, 2) . " Hours<br /><br />"; //If large variance occurs, display column for table if (AlertWorkloadDistribution($currentgroup, $project->id)) { $html .= "<table style='border:1px solid black;'><tr style='background-color:lightgrey;'><th>Member</th><th>Assigned Hours</th><th>% of Workload</th><th>Variance</th></tr>"; } else { $html .= "<table style='border:1px solid black;'><tr style='background-color:lightgrey;'><th>Member</th><th>Assigned Hours</th><th>% of Workload</th><th></th></tr>"; } foreach ($member_rank as $key => $member) {