function student_priority_display_priority_calculations_page
Search API
7.x student_priority.module | student_priority_display_priority_calculations_page() |
6.x student_priority.module | student_priority_display_priority_calculations_page() |
Displays the calculations used to get the priority values. Can be displayed in either the dialog or stand-alone.
File
- modules/
student_priority/ student_priority.module, line 38
Code
function student_priority_display_priority_calculations_page() {
global $current_student_id, $user;
$student_id = $current_student_id;
$rtn = "";
fp_add_css(fp_get_module_path('student_profile') . '/css/style.css');
fp_add_js(fp_get_module_path('advise') . '/js/advise.js');
fp_set_title('');
$rtn .= "";
if ($_GET ['window_mode'] == 'popup') {
$rtn .= "<a class='tests-expand-link' href='javascript:parent.window.location=\"" . fp_url("student-profile/priority-calculations", "current_student_id=$current_student_id") . "\"; void(0);'><i class='fa fa-expand'></i> " . t("View full page") . "</a>";
}
$rtn .= "<p>" . t("This system is able to make calculations as to the student's \"Academic Priority\", or, how at-risk the
student is of experiencing significant difficulties.") . "</p>";
$rtn .= "<h3>" . t("Current Academic Priority:") . "</h3>";
$rtn .= "<!--current-academic-priority-->";
$rtn .= "<h3>" . t("Calculations:") . "</h3>";
$rtn .= "<div>" . t("The following calculations were used to determine the student's current Academic Priority. The score value increases their priority average.") . "</div>";
$rtn .= "
<table border='1' style='max-width: 600px;' class='calc-tests-table'>
<tr>
<th width='70%'>Test</th>
<th width='15%'>Result</th>
<th width='15%'>Score</th>
</tr>";
// Get student calculations
$calcs = student_priority_get_calculations_for_student($student_id, TRUE);
foreach ($calcs ['calc_test_results'] as $machine_name => $details) {
$result = $result_label = $details ['result'];
if (isset($details ['result_label'])) {
$result_label = $details ['result_label'];
}
$score = $details ['score'];
$extra = isset($details ['extra']) ? trim($details ['extra']) : '';
$test_title = $calcs ['calc_tests'][$machine_name]['title'];
$test_description = @$calcs ['calc_tests'][$machine_name]['description'];
$more_content = "";
$more_toggle = "";
if ($extra != "") {
// click to toggle div
$rnd = md5(mt_rand(0, 9999) . mt_rand(99, 99999) . microtime());
$more_toggle = "<a href='javascript:void(0);' onclick='jQuery(\"#test-extra-$rnd\").toggle();' class='test-more-toggle' title='Click for more details'><i class='fa fa-ellipsis-h'></i></a>";
$more_content = "<div id='test-extra-$rnd' class='test-extra' style='display:none;'>
$extra
</div>";
}
$bgcolor = 'white';
if (is_numeric($score)) {
if ($score > 0) {
$bgcolor = '#fff4f4';
}
$score = (strlen("$score") == 1) ? number_format($score, 1) : $score; // force at least X num of decimals
}
$rtn .= "<tr>
<td style='background-color: $bgcolor; color: black;'>$more_toggle$test_title$more_content</td>
<td style='background-color: $bgcolor;'>$result_label</td>
<td style='background-color: $bgcolor;'>$score</td>
</tr>";
} // foreach priority_tests
$rtn .= "</table>";
$total_score = $calcs ['total'];
$count = $calcs ['count'];
$avg = $calcs ['avg'];
$percent = $calcs ['percent'];
$max_possible = $calcs ['max_possible'];
// TODO: these might be controlled by setting one day
$academic_priority_desc = array(
"high" => t("High"),
"medium" => t("Medium"),
"normal" => t("Normal"),
);
$rtn .= "<p><b>Totals:</b> $total_score score / $max_possible max = <b>" . $percent . "</b>%.
</p>
<p>
<b>" . t("Percent Scoring:") . "</b>
<br><span class='profile-priority-bar priority-normal'>" . $academic_priority_desc ['normal'] . "</span> 0 to 30
<br><span class='profile-priority-bar priority-medium'>" . $academic_priority_desc ['medium'] . "</span> 31 to 70
<br><span class='profile-priority-bar priority-high'>" . $academic_priority_desc ['high'] . "</span> 71 to 100
</p>
";
// Update the "academic priority" field at the top of the page, based on ranges.
$academic_priority = student_priority_get_student_academic_priority_label($percent);
$machine = $academic_priority ['machine'];
$label = $academic_priority ['label'];
$priority_html = "<span class='profile-priority-bar priority-$machine'>" . $label . "</span>";
$rtn = str_replace("<!--current-academic-priority-->", $priority_html, $rtn);
// Let's set our breadcrumbs
$db = get_global_database_handler();
$crumbs = array();
$crumbs [] = array(
'text' => 'Students',
'path' => 'student-search',
);
$crumbs [] = array(
'text' => $db->get_student_name($current_student_id) . " ($current_student_id)",
'path' => 'student-profile',
'query' => "current_student_id=$current_student_id",
);
$crumbs [] = array(
'text' => t("Student Profile"),
'path' => 'student-profile',
'query' => "current_student_id=$current_student_id",
);
fp_set_breadcrumbs($crumbs);
return $rtn;
}