function stats_test
Search API
5.x stats.module | stats_test() |
Lets me run a test...
File
- modules/
stats/ stats.module, line 239 - This module displays statistics and reports for FlightPath
Code
function stats_test() {
$cwid = "17690589";
$major_code = "AGRB";
$catalog_year = 2011;
$db = get_global_database_handler();
// For later, let's get our requirement types from the pie chart config...
$requirement_types = array();
// Get the requested piecharts from our config...
$temp = variable_get("pie_chart_config", "c ~ Core Requirements\nm ~ Major Requirements\ndegree ~ Degree Progress");
$lines = explode("\n", $temp);
foreach ($lines as $line) {
if (trim($line) == "") {
continue;
}
$temp = explode("~", $line);
$requirement_type = trim($temp [0]);
$label = trim($temp [1]);
$requirement_types [$requirement_type] = $label;
}
//advise_init_advising_variables();
// Load them up fully and calculate their percentages
$student = new Student($cwid, $db);
$degree_id = $db->get_degree_id($major_code, $catalog_year);
if ($degree_id) {
///////////////////
// Fully build up a FlightPath screen in memory, as if the student
// were looking at this on a web page....
//$degree_plan = new DegreePlan($degree_id);
$degree_plan = new DegreePlan($degree_id, $db, false, $student->array_significant_courses);
$student->load_student_substitutions();
$student->load_unassignments();
$student->list_courses_taken->sort_alphabetical_order();
$student->list_courses_taken->sort_most_recent_first();
$fp = new FlightPath($student, $degree_plan);
$screen = new AdvisingScreen("", $fp);
$screen->view = "year";
$fp->flag_outdated_substitutions();
$fp->assign_courses_to_semesters(); // bare degree plan. not groups.
$fp->assign_courses_to_groups();
$screen->build_screen_elements();
////////////////
// Okay, perform the percentage calculations...
$degree_plan->calculate_progress_hours();
$degree_plan->calculate_progress_quality_points();
foreach ($requirement_types as $requirement_type => $label) {
// Okay, let's see if this degreeplan even has any data on this requirement type.
$total_hours = $degree_plan->gpa_calculations [$requirement_type]["total_hours"] * 1;
$fulfilled_hours = $degree_plan->gpa_calculations [$requirement_type]["fulfilled_hours"] * 1;
$qpts_hours = $degree_plan->gpa_calculations [$requirement_type]["qpts_hours"] * 1;
$qpts = $degree_plan->gpa_calculations [$requirement_type]["qpts"] * 1;
$gpa = $percent = 0;
if ($qpts_hours > 0) {
$gpa = fp_truncate_decimals($qpts / $qpts_hours, 3);
}
if ($total_hours > 0) {
$percent = round(($fulfilled_hours / $total_hours) * 100);
}
$batch ["csv"] .= "$fulfilled_hours, $total_hours, $percent, $gpa, ";
}
}
fpm($degree_plan->gpa_calculations ["degree"]);
}