Exemplo n.º 1
0
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
}
    } 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) {
        if ($key == $USER->id) {
            //Bold the current student
            $html .= "<tr><td><b>" . studentidToLMS_Name($key) . "</b></td>";
        } else {
            $html .= "<tr><td>" . studentidToLMS_Name($key) . "</td>";
        }
        $html .= "<td style='text-align:center;'>" . $member . "</td>";
        $html .= "<td style='text-align:center;'''>" . round($member / $total_hours * 100, 2) . "</td>";
        $distribution = MemberWorkloadDistribution($member, $equal_hours);
        if (!empty($distribution)) {
            //If distribution occus, display variance and icon.
            $html .= "<td style='text-align:center;color:crimson;'>" . MemberWorkloadDistribution($member, $equal_hours) . "  <img src='pix\\alert_icon.png'' width='12px' height='12px'/></td>";
        } else {
            $html .= "<td></td>";
        }
        $html .= "</tr>";
    }
    $html .= "<td><u>Total</u></td><td style='text-align:center;'>" . $total_hours . "</td><td style='text-align:center;'>" . round($total_hours / $total_hours * 100, 2) . "</td><td></td></tr>";
    $html .= "</table>";
} else {
    //else, no tasks are created, display generic message.
    $html = "There are currently no tasks created. Please create a task and view workload distribution again.";
}
$content = $html;
//$content = format_text($content, $project->contentformat, $formatoptions);
echo $OUTPUT->box($content, "generalbox center clearfix");
add_to_log($course->id, 'project', 'workload dist', 'workload_distribution.php?id=' . $cmid, $p);
    //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) {
        if ($key == $USER->id) {
            //Bold the current student
            $html .= "<tr><td><b>" . studentidToLMS_Name($key) . "</b></td>";
        } else {
            $html .= "<tr><td>" . studentidToLMS_Name($key) . "</td>";
        }
        $html .= "<td style='text-align:center;'>" . $member . "</td>";
        $html .= "<td style='text-align:center;'>" . round($member / $total_hours * 100, 2) . "</td>";
        $wl = MemberWorkloadDistribution($member, $equal_hours);
        if (isset($wl)) {
            //If distribution occus, display variance and icon.
            $html .= "<td style='text-align:center;color:crimson;'>" . $wl . "  <img src='pix/alert_icon.png' width='12px' height='12px'/></td>";
        } else {
            $html .= "<td></td>";
        }
        $html .= "</tr>";
    }
    $html .= "<td><u>Total</u></td><td style='text-align:center;'>" . $total_hours . "</td><td style='text-align:center;'>" . round($total_hours / $total_hours * 100, 2) . "</td><td></td></tr>";
    $html .= "</table>";
} else {
    //else, no tasks are created, display generic message.
    $html = "There are currently no tasks created. Please create a task and view workload distribution again.";
}
$content = $html;