function AdvisingScreen::draw_progress_boxes
Search API
7.x AdvisingScreen.php | AdvisingScreen::draw_progress_boxes() |
6.x AdvisingScreen.php | AdvisingScreen::draw_progress_boxes() |
This function calls drawPieChart to construct the student's 3 progress pie charts.
Return value
string
1 call to AdvisingScreen::draw_progress_boxes()
- AdvisingScreen::display_screen in classes/
AdvisingScreen.php - This function generates the HTML to display the screen. Should be used in conjunction with output_to_browser()
File
- classes/
AdvisingScreen.php, line 1889
Class
Code
function draw_progress_boxes()
{
global $user;
// Draw the boxes for student progress (where
// the pie charts go!)
$rtn = "";
if (!$this->db) {
$this->db = get_global_database_handler();
}
$bool_charts_are_hidden = FALSE;
// have we already calculated this degree's data?
if (@$this->degree_plan->bool_calculated_progess_hours != TRUE)
{
// Only bother to get the types calculations needed for the piecharts
// Get the requested piecharts from our config...
$types = array();
$temp = variable_get_for_school("pie_chart_config", "c ~ Core Requirements\nm ~ Major Requirements\ndegree ~ Degree Progress", $this->student->school_id);
$lines = explode("\n", $temp);
foreach ($lines as $line) {
if (trim($line) == "") {
continue;
}
$temp = explode("~", $line);
$requirement_type = trim($temp [0]);
$types [$requirement_type] = trim($temp [1]);
}
$this->degree_plan->calculate_progress_hours(FALSE, $types);
$this->degree_plan->calculate_progress_quality_points(FALSE, $types);
}
// Create a "theme" array for later use.
$pie_chart_theme_array = array();
$pie_chart_theme_array ["screen"] = $this;
$pie_chart_theme_array ["student"] = $this->student;
$pie_chart_theme_array ["degree_plan"] = $this->degree_plan;
// Get the requested piecharts from our config...
$temp = variable_get_for_school("pie_chart_config", "c ~ Core Requirements\nm ~ Major Requirements\ndegree ~ Degree Progress", $this->student->school_id);
$config_lines = explode("\n", $temp);
// Go through each of the degrees we have piecharts for
foreach ($this->degree_plan->gpa_calculations as $degree_id => $val) {
$dp = new DegreePlan();
$dp->degree_id = $degree_id;
if ($degree_id > 0) {
$dp->load_descriptive_data();
$d_title = $dp->get_title2(FALSE, TRUE);
$d_code = fp_get_machine_readable($dp->major_code);
}
else {
// Degree_id == 0, so this is the "overall" degree.
$d_title = t("Overall Progress");
$d_code = "PIE_OVERALL_PROGRESS";
}
// Add to our theme array.
$pie_chart_theme_array ["degree_rows"][$degree_id] = array(
"degree_id" => $degree_id,
"row_label" => $d_title,
"row_classes" => "",
"degree_plan" => $dp,
"degree_major_code_machine" => $d_code,
"bool_display" => TRUE,
);
foreach ($config_lines as $line) {
if (trim($line) == "") {
continue;
}
$temp = explode("~", $line);
$requirement_type = trim($temp [0]);
$label = trim($temp [1]);
$unfinished_col = @trim($temp [2]);
$progress_col = @trim($temp [3]);
if ($unfinished_col == "") {
$unfinished_col = "660000";
}
if ($progress_col == "") {
$progress_col = "FFCC33";
}
// Okay, let's see if this degreeplan even has any data on this requirement type.
$total_hours = $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["total_hours"] * 1;
$fulfilled_hours = $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["fulfilled_hours"] * 1;
$qpts = $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["qpts"] * 1;
if (floatval($total_hours) == 0) {
continue; // no hours for this requirement type!
}
// Setting to display GPA
$gpa = $extra_gpa = "";
if (variable_get_for_school("pie_chart_gpa", "no", $this->student->school_id) == "yes") {
if ($this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["qpts_hours"] > 0) {
$gpa = fp_truncate_decimals($qpts / $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["qpts_hours"], 3);
}
if ($gpa) {
$extra_gpa = "<div class='view-extra-gpa ' style='text-align: right; color: gray;'>GPA: $gpa</div>";
}
}
// If we are here, then there is indeed enough data to create a piechart!
// Generate the pie chart and add to our array, for later display.
$html = $this->draw_pie_chart_box($label, $fulfilled_hours, $total_hours, "", $unfinished_col, $progress_col, $extra_gpa);
$hide_pie_html = "$label: $fulfilled_hours / $total_hours";
// Will only display if we've set it above.
if ($gpa) {
$hide_pie_html .= " ($gpa)";
}
$pie_chart_html_array [] = array(
"pie" => $html,
"hide_pie" => $hide_pie_html,
);
// Add to our theme array
$pie_chart_theme_array ["degree_rows"][$degree_id]["data"][$requirement_type] = array(
"full_html" => $html,
"hide_pie_html" => $hide_pie_html,
"requirement_type" => $requirement_type,
"label" => $label,
"unfinished_col" => $unfinished_col,
"progress_col" => $progress_col,
"total_hours" => $total_hours,
"fulfilled_hours" => $fulfilled_hours,
"qpts" => $qpts,
"bool_display" => TRUE,
"pie_classes" => '',
);
} // foreach $line (for piechart by type)
} //foreach $degree_id
//////////////////
// Send the pie_chart_theme_array to a hook for possible extra processing.
invoke_hook("theme_pie_charts", array(&$pie_chart_theme_array));
//////////////////
$prcount = 0;
$total_rows = count($pie_chart_theme_array ["degree_rows"]);
$degree_classes = fp_get_degree_classifications();
// Now, cycle through all of the 'rows' of degrees we need to draw.
foreach ($pie_chart_theme_array ["degree_rows"] as $degree_id => $details) {
if ($details ["bool_display"] === FALSE) {
continue; // hide the entire row
}
// We also want to denote if this is part of a "combined" degree or not.
$extra_pie_trtd_class = "";
if ($this->degree_plan->is_combined_dynamic_degree_plan) {
$extra_pie_trtd_class .= "pie-combined-dynamic-degree-plan";
}
else {
$extra_pie_trtd_class .= "pie-single-degree-plan";
}
$degree_class = @$details ['degree_plan']->degree_class;
if ($degree_class == "") {
$degree_class = "NOT_SET";
}
$degree_level_num = intval(@$degree_classes ['machine_name_to_level_num'][$degree_class]);
$rtn .= "<tr class='pie-degree-row pie-degree-row-$degree_id pie-degree-row-class-$degree_class pie-total-rows-$total_rows pie-degree-row-degree-level-num-$degree_level_num pie-row-count-$prcount {$details ['row_classes']}'><td colspan='2' class='$extra_pie_trtd_class'>
<div class='pie-row-label'>{$details ["row_label"]}</div>";
$td_width = "";
if (@count($pie_chart_html_array) > 0) {
$td_width = round(100 / count($pie_chart_html_array));
}
if (!isset($user->settings ["hide_charts"])) {
$user->settings ["hide_charts"] = "";
}
if ($this->bool_force_pie_charts || ($user->settings ["hide_charts"] != "hide" && $this->bool_blank == FALSE))
{ // Display the pie charts
$bool_charts_are_hidden = FALSE;
$rtn .= "
<div style='margin-bottom: 10px;' class='pies-wrapper'>
<table class='pie-chart-table' width='100%' cellspacing='0' cellpadding='0' border='0'>
<tr>
";
$c = 0;
if (@isset($pie_chart_theme_array ['degree_rows'][$degree_id]["data"])) {
foreach ($pie_chart_theme_array ['degree_rows'][$degree_id]["data"] as $requirement_type => $val) {
$html = $val ["full_html"];
if (@$val ["bool_display"] === FALSE) {
continue; // this particular chart shouldn't be shown.
}
$style = @($c == count($pie_chart_html_array) - 1) ? "" : "padding-right:5px;";
$rtn .= "<td width='$td_width%' style='$style' class='td_full_pie td_full_pie_$requirement_type " . @$val ["pie_classes"] . "'>
" . $html . "
</td>";
$c++;
}
}
$rtn .= " </table>";
$rtn .= "</div>"; // class pies-wrapper
}
else {
// Hide the charts!
$bool_charts_are_hidden = TRUE;
$rtn .= "
<table border='0' width='100%' class='pie-chart-table-hide-charts' cellpadding='0' cellspacing='0' >
<tr class='pie-hidden-charts-label-row'>
<td colspan='10' class='' align='center' height='20'>
" . fp_render_section_title(t("Progress"), 'hidden-pie-charts-section') . "
</td>
</tr>
<tr class='pie-hidden-charts-row'>";
$c = 0;
if (isset($pie_chart_theme_array ['degree_rows'][$degree_id]["data"])) {
foreach ($pie_chart_theme_array ['degree_rows'][$degree_id]["data"] as $requirement_type => $val) {
$html = $val ["hide_pie_html"];
if ($val ["bool_display"] === FALSE) {
continue; // this particular chart shouldn't be shown.
}
$rtn .= "<td width='$td_width%' align='center' class='td_hidden_pie td_hidden_pie_$requirement_type {$val ["pie_classes"]} '>
" . $html . "
</td>";
$c++;
}
}
$rtn .= "
</tr>
</table>";
}
$rtn .= "</td></tr>";
$prcount++;
} // foreach degree_rows
return $rtn;
}