stats.module
Search API
- 7.x modules/stats/stats.module
- 6.x modules/stats/stats.module
- 4.x modules/stats/stats.module
- 5.x modules/stats/stats.module
This module displays statistics and reports for FlightPath
File
modules/stats/stats.moduleView source
- <?php
-
- /**
- * @file
- * This module displays statistics and reports for FlightPath
- *
- * @return unknown
- */
-
-
-
-
- /**
- * Implementation of hook_menu
- *
- * @return unknown
- */
- function stats_menu() {
- $items = array();
-
- $items["admin-tools/stats"] = array(
- "title" => "Usage Stats & Reports",
- "page_callback" => "stats_display_main",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "menu_icon" => fp_theme_location() . "/images/popup.gif",
- "target" => "_blank",
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- );
-
-
- $items["stats/reports/access"] = array(
- "title" => "Access Stats",
- "description" => "See recent access within the system. This can be useful to see if anyone is currently using the system.",
- "page_callback" => "stats_report_access_stats",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "bool_print" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Main menu",
- "path" => "admin-tools/stats",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- "weight" => 100,
- );
-
-
- $items["stats/reports/major-counts"] = array(
- "title" => "Major Counts",
- "description" => "Displays the number of students within each major or major/concentration.",
- "page_callback" => "stats_report_major_counts",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "bool_print" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Main menu",
- "path" => "admin-tools/stats",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- "weight" => 150,
- );
-
-
-
- /**
- *
- * Removing due to lack of use, and incompatibility with FP5
- *
- *
- $items["stats/reports/selected-degree-options"] = array(
- "title" => "Selected Degree Options",
- "description" => "This report will display information about which degree options students/advisors are selecting for particular majors
- (ex: General Studies)",
- "page_callback" => "stats_report_selected_degree_options",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "bool_print" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Main menu",
- "path" => "admin-tools/stats",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- "weight" => 200,
- );
- */
-
-
-
-
-
- $items["stats/reports/advisor-use"] = array(
- "title" => "Advisor Use",
- "description" => "How many students an advisor has advised over a specified time range.",
- "page_callback" => "stats_report_advisor_use",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "bool_print" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Main menu",
- "path" => "admin-tools/stats",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- "weight" => 250,
- );
-
- $system_name = variable_get("system_name", "FlightPath");
-
- $items["stats/reports/student-course-list"] = array(
- "title" => "Student Course List",
- "description" => "List courses a student has taken, which $system_name is aware of.",
- "page_callback" => "stats_report_student_course_list",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "bool_print" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Main menu",
- "path" => "admin-tools/stats",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- "weight" => 300,
- );
-
-
-
-
- $items["stats/reports/flightpath-use-summary"] = array(
- "title" => "$system_name Use Summary",
- "description" => "A detailed report on how $system_name is being used over a specified time range.",
- "page_callback" => "stats_report_flightpath_use_summary",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "bool_print" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Main menu",
- "path" => "admin-tools/stats",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- "weight" => 350,
- );
-
-
-
-
-
- $items["stats/reports/course-use-summary"] = array(
- "title" => "Course Use Summary",
- "description" => "A report of everywhere a particular course is used in $system_name (groups or degrees).",
- "page_callback" => "stats_report_course_use_summary",
- "access_arguments" => array("can_access_stats"),
- "page_settings" => array(
- "page_show_title" => TRUE,
- "bool_print" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Main menu",
- "path" => "admin-tools/stats",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- "weight" => 450,
- );
-
-
-
-
-
- // Lets the user download a CSV file stored in the batch_queue table, with a batch_id.
- $items["stats/download-csv-from-batch/%"] = array(
- "page_callback" => "stats_download_csv_from_batch",
- "page_arguments" => array(2),
- "access_arguments" => array("can_access_stats"),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
-
-
- return $items;
- }
-
-
-
- /**
- * Lets the user download a CSV file from a completed batch.
- *
- * There are no permissions on this, except the can_access_stats permission.
- *
- * @param unknown_type $batch_id
- */
- function stats_download_csv_from_batch($batch_id) {
-
- $filename = fp_get_machine_readable(strtolower($_REQUEST["filename"]));
-
- $batch = batch_get($batch_id);
-
- // Give it to the browser...
- header('Content-type: text/csv');
- header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
- print $batch["csv"];
-
- die;
-
- }
-
-
-
- /**
- * Lets me run a test...
- *
- */
- 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"]);
-
-
- }
-
-
-
-
-
-
-
-
- /**
- * Implementation of hook_perm().
- * Expects to return an array of permissions recognized by
- * this module.
- *
- * Ex: $a = array(
- * "deCanDoSomething" => array (
- * "title" => "Can Do Something",
- * "description" => "Allow the user to do something."
- * )
- * );
- *
- */
- function stats_perm() {
-
- $perms = array (
- "can_access_stats" => array(
- "title" => t("Can access/view stats"),
- "description" => t("This allows the user to access the stats module, letting them run
- reports on usage."),
- ),
- );
-
- return $perms;
-
- }
-
-
-
-
- /**
- * Return the HTML for a pulldown containing the catalog years available for selection.
- *
- * @param unknown_type $selected
- * @param unknown_type $display_submit
- */
- function stats_draw_catalog_year_pulldown($selected = "", $display_submit = FALSE) {
-
- $rtn = "";
-
-
- $rtn .= "
- <table border='0'>
-
- <td valign='middle'>
-
- <select name='catalog_year' id='catalog_year'><option value=''>
- " . t("Please select a catalog year") . "</option>
- <option value=''>-----------------------------------</option>";
-
-
- $current_catalog_year = variable_get("current_catalog_year", "");
-
- if ($selected == "") $selected = $current_catalog_year;
-
- $res = db_query("SELECT DISTINCT (catalog_year) FROM degrees
- WHERE exclude = '0'
- ORDER BY catalog_year DESC");
- while ($cur = db_fetch_array($res)) {
- $sel = ($cur["catalog_year"] == $selected) ? "selected=selected" : "";
- $rtn .= "<option value='{$cur["catalog_year"]}' $sel>{$cur["catalog_year"]}-" . ($cur["catalog_year"] + 1) . "</option>";
- }
-
- $rtn .= " </select> </td>";
- if ($display_submit == true)
- {
- $rtn .= "<td valign='middle'><input type='submit' value='" . t("Select") . "'></td>";
- }
-
- $rtn .= "</table>";
-
- return $rtn;
-
- }
-
-
-
- /**
- * This report will display everywhere a particular course is used in FlightPath (groups and degrees)
- *
- */
- function stats_report_course_use_summary() {
- $rtn = "";
-
- $draft = "";
- $use_draft = FALSE;
-
- $subject_id = trim(@$_GET["subject_id"]);
- $course_num = trim(@$_GET["course_num"]);
- $draft_check = @$_GET["draft"];
- if ($draft_check == "checked") {
- $draft = "draft_";
- $use_draft = TRUE;
- }
-
- $rtn .= "<form action='" . fp_url("stats/reports/course-use-summary") . "' method='GET' >";
- $rtn .= "Please enter a course's subject ID and course number to search:<br>
- <input type='text' name='subject_id' placeholder='subject ID' size='10' value='$subject_id'>
- <input type='text' name='course_num' placeholder='course num' size='10' value='$course_num'>
- <input type='checkbox' name='draft' value='checked' $draft_check>Check draft tables?
- <input type='submit' value='Search'>
- <br><b>Note:</b> This may take up to a minute to run, please be patient.";
-
- $rtn .= "</form>";
-
- if ($subject_id && $course_num) {
- $rtn .= "<hr>";
- // First, look up this course's ID.
- $db = get_global_database_handler();
- $course_id = $db->get_course_id($subject_id, $course_num);
-
- if ($course_id) {
- $rtn .= "<h2>Course $subject_id $course_num (id is $course_id)</h2>";
-
- // Groups
- $rtn .= "<div><b>Groups:</b></div>
- <table border='1'>
- <tr>
- <th>ID</th>
- <th>Name</th>
- <th>Title</th>
- <th>Year</th>
-
- </tr>";
- $res = db_query("SELECT * FROM {$draft}group_requirements WHERE course_id = ?
- order by `id`", $course_id);
- while ($cur = db_fetch_array($res)) {
- $group_id = $cur["group_id"];
- $group = new Group($group_id, $db, -1, false, $use_draft);
- if (!$group->title) {
- // This is possibly a child group. Look for its parent.
- $res2 = db_query("SELECT * FROM {$draft}group_requirements WHERE child_group_id = ?", $group_id);
- $cur2 = db_fetch_array($res2);
- if ($cur2["group_id"] != "") {
- $group_id = $cur2["group_id"];
- $group = new Group($group_id, $db, -1, false, $use_draft);
- }
- }
- $rtn .= "<tr>
- <td>$group_id</td>
- <td>$group->group_name</td>
- <td>$group->title</td>
- <td>$group->catalog_year</td>
- </tr>";
- }
- $rtn .= "</table>";
-
- // Now, look for degrees...
-
- $rtn .= "<br><br><br>
- <b>Degrees:</b>
- <table border='1'>
- <tr>
- <th>ID</th>
- <th>Title</th>
- <th>MAJR</th>
- <th>Track</th>
- <th>Sem</th>
- <th>Year</th>
- </tr>";
-
- $res = db_query("SELECT * FROM {$draft}degree_requirements WHERE course_id = ? ORDER BY `id`", $course_id);
- while ($cur = db_fetch_array($res)) {
- $degree_id = $cur["degree_id"];
- $degree = new DegreePlan($degree_id, $db, TRUE, FALSE, $use_draft);
-
- $rtn .= "<tr>
- <td>$degree_id</td>
- <td>$degree->title</td>
- <td>$degree->major_code</td>
- <td>$degree->track_code</td>
- <td>" . $cur["semester_num"] . "</td>
- <td>$degree->catalog_year</td>
- </tr>";
- }
-
-
-
- $rtn .= '</table>';
-
- } // if course_id
- else {
- $rtn .= "<div>Course could not be found. Check spelling.";
- }
-
- }
-
-
-
-
-
- return $rtn;
-
- }
-
-
-
-
-
-
- /**
- * This report will show which degree options are being selected for degrees which offer options.
- *
- * @return unknown
- */
- function z__stats_report_selected_degree_options() {
- $rtn = "";
-
-
- // What major have they selected?
- $major = trim(@$_GET["major"]);
-
- $rtn .= "<form action='" . fp_url("stats/reports/selected-degree-options") . "' method='GET' >";
- $rtn .= stats_draw_majors_pulldown($major, TRUE, TRUE, t("Please select a major with degree options"));
- $rtn .= "</form>";
-
- $db = get_global_database_handler();
-
- if ($major != "")
- {
- $count_in_major = 0;
- $degree_option_count = array();
-
- $sql = "SELECT * FROM students a, student_degrees b
- WHERE substring_index(major_code, '|', 1) = '?'
- AND rank_code IN %RANKIN%
- AND a.cwid = b.student_id
- %EXTRA_STUDENTSEARCH_CONDITIONS%
- GROUP BY a.cwid";
-
-
- $rank_in = "( '" . join("', '", csv_to_array($GLOBALS["fp_system_settings"]["allowed_student_ranks"])) . "' )";
- $sql = str_replace("%RANKIN%", $rank_in, $sql);
- $sql = str_replace("%EXTRA_STUDENTSEARCH_CONDITIONS%", @$GLOBALS["fp_system_settings"]["extra_student_search_conditions"], $sql);
-
- $result = db_query($sql, $major);
-
- while($cur = db_fetch_array($result))
- {
- extract($cur, 3, "db");
- $count_in_major++;
-
- $track = "";
- // Does this student have a track (degree option) specified?
- //$student_settings = $db->get_student_settings($db_cwid);
-
- $student_major_codes = $db->get_student_majors_from_db($db_cwid);
- // Look through all the major codes for this student, and see if any
- // have a |_ in them. If they do, that means they are a track.
- foreach ($student_major_codes as $mc) {
- if (strstr($mc, $major . "|_")) {
- $track = $mc; // Yes, so this is a track for this major.
-
- // Init if not already...
- if (!isset($degree_option_count[$track])) {
- $degree_option_count[$track] = 0;
- }
-
- $degree_option_count[$track]++;
-
- }
- }
-
-
-
- // No track found. Add that one, too.
- if ($track == "")
- {
- $track = t("None selected");
- // Init if not already...
- if (!isset($degree_option_count[$track])) {
- $degree_option_count[$track] = 0;
- }
-
- $degree_option_count[$track]++;
-
- }
-
-
-
-
-
- } // while db_fetch_array
-
- arsort($degree_option_count);
-
-
-
- $rtn .= "<table border='1'>
- <tr>
- <th>" . t("Degree Option") . "</th>
- <th>" . t("Count") . "</th>
- <th>" . t("Description") . "</th>
- </tr>";
-
- foreach($degree_option_count as $d_option => $value)
- {
- //$desc = get_track_title($major,$d_option);
- // figure out the title of the track...
- $temp = explode("-", $db_catalog_year);
- $cy = $temp[0];
- $degree_id = $db->get_degree_id($d_option, $cy);
-
- $dp = new DegreePlan();
- $dp->degree_id = $degree_id;
- $dp->load_descriptive_data();
- $desc = $dp->get_title2(TRUE, TRUE);
-
-
- $rtn .= "<tr><td valign='top'>
- $d_option
- </td>
- <td valign='top'>
- $value
- </td>
- <td valign='top'>
- $desc
- </td>
-
- </tr>";
- }
-
- $rtn .= "</table>" . t("Total number of students:") . " $count_in_major.";
-
- }
-
-
-
- return $rtn;
- }
-
-
-
-
- /**
- * Display a major selection pulldown, used by other reports.
- *
- * If bool_only_majors_with_tracks == TRUE, then we will only display the majors which
- * have tracks associated with them.
- *
- * If bool_exclude_tracks == TRUE, then we will skip over any major_code with a "_" in it,
- * meaning, this code describes a track and not the base major.
- *
- * If bool_only_current_catalog_year == TRUE, then only degrees from the current catalog year
- * will be displayed.
- *
- */
- function stats_draw_majors_pulldown($smajor = "", $display_submit = FALSE, $bool_only_majors_with_tracks = FALSE, $label = "Please select a major", $bool_exclude_tracks = FALSE, $bool_only_current_catalog_year = TRUE, $bool_return_options_array = FALSE)
- {
-
- $rtn = "";
- $db = get_global_database_handler();
- $major_array = array();
-
- $options_array = array();
-
-
- $current_catalog_year = variable_get("current_catalog_year", "");
-
- $m_a_count = 0;
- if ($bool_only_current_catalog_year) {
- $query = "SELECT * FROM degrees
- WHERE catalog_year = '?'
- AND `exclude`='0'
- ORDER BY `title` ";
- $result = db_query($query, $current_catalog_year);
- }
- else { // current catalog year not important.
- $query = "SELECT * FROM degrees
- WHERE `exclude`='0'
- GROUP BY major_code
- ORDER BY `title` ";
- $result = db_query($query);
- }
- while ($cur_row = $db->db_fetch_array($result)) {
- $major = trim($cur_row["major_code"]);
-
- if ($bool_exclude_tracks && strpos($major, "_")) {
- continue;
- }
-
- if ($bool_only_majors_with_tracks && !$db->get_degree_tracks($major, $current_catalog_year))
- { // only get majors that also have tracks!
- continue;
- }
-
- $description = trim($cur_row["title"]);
- $type = trim($cur_row["degree_type"]);
- $major_array[$m_a_count]["description"] = $description;
- $major_array[$m_a_count]["major"] = $major;
- $major_array[$m_a_count]["type"] = $type;
-
- $m_a_count++;
-
-
- }
-
-
- $rtn .= "
- <table border='0'>
-
- <td valign='middle'>
-
- <select name='major' id='major'>
- <option value=''>" . $label . "</option>
- <option value=''>-----------------------------------</option>";
-
- for ($t = 0; $t < $m_a_count; $t++)
- {
- $sel = "";
- if ($major_array[$t]["major"] == $smajor && $smajor != "")
- {
- $sel = "selected";
- }
- $hyph = "-";
- if ($major_array[$t]["type"] == "" || $major_array[$t]["type"] == "NA")
- {
- $hyph = "";
- $major_array[$t]["type"] = "";
- }
-
- $rtn .= "<option value='" . $major_array[$t]["major"] . "' $sel>(" . $major_array[$t]["major"] . ")
- " . $major_array[$t]["description"] . " $hyph " . $major_array[$t]["type"] . "
- </option>";
-
- $options_array[$major_array[$t]["major"]] = "(" . $major_array[$t]["major"] . ") " . $major_array[$t]["description"] . " $hyph " . $major_array[$t]["type"];
-
-
- }
-
-
- $rtn .= " </select> </td>";
- if ($display_submit == true)
- {
- $rtn .= "<td valign='middle'><input type='submit' value='" . t("Select") . "'></td>";
- }
-
- $rtn .= "</table>";
-
- if ($bool_return_options_array) return $options_array;
-
-
-
- return $rtn;
-
- }
-
-
-
-
-
-
- /**
- * Draws a simple form for entering a student's CWID, used by other reports.
- *
- * @param unknown_type $path
- * @param unknown_type $student_cwid
- * @return unknown
- */
- function stats_draw_student_cwid_form($path, $student_cwid = "") {
- $rtn = "";
-
- $rtn .= "<form action='" . fp_url($path) . "' method='GET' >
- " . t("Enter a student's CWID to see their courses") . "
- <br>
- <input type='textfield' value='$student_cwid' name='student_cwid'>
- <br>
- <input type='submit' value='" . t("Submit") . "'>
- </form> <hr>
- ";
-
-
- return $rtn;
- }
-
-
-
- /**
- * This report shows how many students are in each major.
- *
- * @return unknown
- */
- function stats_report_major_counts() {
- $rtn = "";
-
-
-
- $rtn .= "<table border='1'>
- <tr>
- <th>" . t("Major") . "</th>
- <th>" . t("Count") . "</th>
- <th colspan='2'>" . t("Description") . "</th>
- </tr>";
-
- $total = 0;
-
- $result = db_query("SELECT * FROM degrees
- GROUP BY major_code
- ORDER BY title, major_code ");
- while ($cur = db_fetch_array($result)) {
- $count = 0;
- $major_code = $cur["major_code"];
- $title = $cur["title"];
- $degree_type = $cur["degree_type"];
-
- // If this is a degree option, skip it, as we do not expect
- // the students table to record degree option choices.
- if (strstr($major_code, "|_")) continue;
-
- // Find out how many students have this major.
-
- $sql = "SELECT count(cwid) AS count FROM students a, student_degrees b
- WHERE b.major_code = ?
- AND a.cwid = b.student_id
- AND rank_code IN %RANKIN%
- %EXTRA_STUDENTSEARCH_CONDITIONS% ";
-
- $rank_in = "( '" . join("', '", csv_to_array(@$GLOBALS["fp_system_settings"]["allowed_student_ranks"])) . "' )";
- $sql = str_replace("%RANKIN%", $rank_in, $sql);
- $sql = str_replace("%EXTRA_STUDENTSEARCH_CONDITIONS%", @$GLOBALS["fp_system_settings"]["extra_student_search_conditions"], $sql);
-
- $res2 = db_query($sql, $major_code);
- $cur2 = db_fetch_array($res2);
-
- if (is_numeric($cur2["count"])) {
- $total += $cur2["count"];
- }
- $res_array[$major_code]["count"] = $cur2["count"] * 1;
- $res_array[$major_code]["desc"] = $title;
- $res_array[$major_code]["type"] = $degree_type;
-
- }
-
-
- foreach($res_array as $major => $value) {
-
- $rtn .= "<tr>
- <td valign='top' class='tenpt'>$major</td>
- <td valign='top' class='tenpt'>{$value["count"]}</td>
- <td valign='top' class='tenpt'>{$value["type"]}</td>
- <td valign='top' class='tenpt'>{$value["desc"]}</td>
- </tr>";
- }
-
- $rtn .= "</table>
- " . t("Total student records:") . " $total.";
-
-
-
-
- return $rtn;
- }
-
-
-
- /**
- * This report shows common usages in FlightPath by all users.
- *
- * This is a helpful report for determining which functionality is most popular
- * in FlightPath
- *
- * @return unknown
- */
- function stats_report_flightpath_use_summary() {
- $rtn = "";
-
- $start_date = trim(addslashes(@$_REQUEST["start_date"]));
- $end_date = trim(addslashes(@$_REQUEST["end_date"]));
-
- $rtn .= stats_draw_date_range_form("stats/reports/flightpath-use-summary", $start_date, $end_date);
-
- if ($start_date == "" || $end_date == "") {
- return $rtn;
- }
- $start_date .= " 00:00:00"; // make it start at midnight of the startDate.
- $end_date .= " 23:59:59"; // make it go through to midnight of the endDate.
- // Okay, now we get our various counts....
-
- // Logins...
- $u_student = stats_get_log_count("login","",true,$start_date,$end_date,true);
- $t_student = stats_get_log_count("login","",false,$start_date,$end_date,true);
- $u_staff = stats_get_log_count("login","",true,$start_date,$end_date,false);
- $t_staff = stats_get_log_count("login","",false,$start_date,$end_date,false);
- $rtn .= "<b>System Logins</b>
- <blockquote>
- Unique student logins: $u_student<br>
- Total student logins: $t_student<br>
- ------- <br>
- Unique faculty/staff logins: $u_staff<br>
- Total faculty/staff logins: $t_staff
- </blockquote>
- ";
-
- // Advisings...
- $regular_advisings = stats_get_log_count("save_adv_active","",false,$start_date,$end_date,false);
- $wi_advisings = stats_get_log_count("save_adv_active_whatif","",false,$start_date,$end_date,false);
- $total_advisings = $regular_advisings + $wi_advisings;
- $rtn .= "<b>Advisings</b>
- <blockquote>
- Total student advisings: $total_advisings <br>
- ------- <br>
- Regular advisings: $regular_advisings<br>
- What If advisings: $wi_advisings
- </blockquote>
- ";
-
- // Comments...
- $total = stats_get_log_count("save_comment","",false,$start_date,$end_date,false);
- $unique = stats_get_log_count("save_comment","",true,$start_date,$end_date,false);
- $rtn .= "<b>Comments</b>
- <blockquote>
- Total comments saved: $total <br>
- ------- <br>
- Unique faculty/staff commentors: $unique
- </blockquote>
- ";
-
- // Course search...
- $u_student = stats_get_log_count("course_search","",true,$start_date,$end_date,true);
- $um_student = stats_get_log_count("course_search","",true,$start_date,$end_date,true,true);
- $t_student = stats_get_log_count("course_search","",false,$start_date,$end_date,true);
- $tm_student = stats_get_log_count("course_search","",false,$start_date,$end_date,true, true);
-
- $u_staff = stats_get_log_count("course_search","",true,$start_date,$end_date,false);
- $t_staff = stats_get_log_count("course_search","",false,$start_date,$end_date,false);
- $tm_staff = stats_get_log_count("course_search","",false,$start_date,$end_date,false, true);
- $rtn .= "<b>Course Search</b>
- <blockquote>
- Unique student users: $u_student <span class='s-mobile'>($um_student mobile)</span><br>
- Total student uses: $t_student <span class='s-mobile'>($tm_student mobile)</span><br>
- ------- <br>
- Unique faculty/staff users: $u_staff<br>
- Total faculty/staff (and anonymous) uses: $t_staff <span class='s-mobile'>($tm_staff mobile)</span>
- </blockquote>
- ";
-
-
- // Degree search...
- $u_student = stats_get_log_count("blank_degrees","",true,$start_date,$end_date,true);
- $um_student = stats_get_log_count("blank_degrees","",true,$start_date,$end_date,true,true);
- $t_student = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,true);
- $tm_student = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,true, true);
- $u_staff = stats_get_log_count("blank_degrees","",true,$start_date,$end_date,false);
- $t_staff = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,false);
- $tm_staff = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,false, true);
- $rtn .= "<b>Degree Search (blank degrees)</b>
- <blockquote>
- Unique student users: $u_student <span class='s-mobile'>($um_student mobile)</span><br>
- Total student uses: $t_student <span class='s-mobile'>($tm_student mobile)</span><br>
- ------- <br>
- Unique faculty/staff users: $u_staff<br>
- Total faculty/staff (and anonymous) uses: $t_staff <span class='s-mobile'>($tm_staff mobile)</span>
- </blockquote>
- ";
-
-
- // View preferences
- $t_student_y = stats_get_log_count("view_by_year","",false,$start_date,$end_date,true);
- $tm_student_y = stats_get_log_count("view_by_year","",false,$start_date,$end_date,true, true);
- $u_student_y = stats_get_log_count("view_by_year","",true,$start_date,$end_date,true);
- $um_student_y = stats_get_log_count("view_by_year","",true,$start_date,$end_date,true, true);
-
- $t_staff_y = stats_get_log_count("view_by_year","",false,$start_date,$end_date,false);
-
- $t_student_t = stats_get_log_count("view_by_type","",false,$start_date,$end_date,true);
- $tm_student_t = stats_get_log_count("view_by_type","",false,$start_date,$end_date,true, true);
- $u_student_t = stats_get_log_count("view_by_type","",true,$start_date,$end_date,true);
- $um_student_t = stats_get_log_count("view_by_type","",true,$start_date,$end_date,true, true);
-
-
- $t_staff_t = stats_get_log_count("view_by_type","",false,$start_date,$end_date,false);
- $rtn .= "<b>View Preferences</b>
- <blockquote>
- Unique student view-by-year: $u_student_y <span class='s-mobile'>($um_student_y mobile)</span><br>
- Total student view-by-year: $t_student_y <span class='s-mobile'>($tm_student_y mobile)</span><br>
- Total faculty/staff view-by-year: $t_staff_y<br>
- ------- <br>
- Unqiue student view-by-type: $u_student_t <span class='s-mobile'>($um_student_t mobile)</span><br>
- Total student view-by-type: $t_student_t <span class='s-mobile'>($tm_student_t mobile)</span><br>
- Total faculty/staff view-by-type: $t_staff_t<br>
- </blockquote>
- ";
-
- // Substitutions
- $t_staff = stats_get_log_count("save_substitution","",false,$start_date,$end_date,false);
- $u_staff = stats_get_log_count("save_substitution","",true,$start_date,$end_date,false);
- $rtn .= "<b>Substitutions</b>
- <blockquote>
- Unique substitutors: $u_staff<br>
- Total substitutions: $t_staff<br>
- </blockquote>
- ";
-
- return $rtn;
- }
-
-
-
-
- /**
- * Used by the use_summary report. This function will simply return log counts
- * for the specified parameters in the watchdog table.
- *
- * @param unknown_type $action
- * @param unknown_type $action_array
- * @param unknown_type $bool_distinct
- * @param unknown_type $start_date
- * @param unknown_type $end_date
- * @param unknown_type $bool_students
- * @param unknown_type $bool_mobile_only
- * @return unknown
- */
- function stats_get_log_count($action = "", $action_array = "", $bool_distinct = false, $start_date, $end_date, $bool_students = true, $bool_mobile_only = false)
- {
-
- $action_line = " `type` = '$action' ";
- if (is_array($action_array) && count($action_array) > 1)
- {
- $action_line = "";
- $action_line .= "( ";
- foreach($action_array as $action)
- {
- $action_line .= " `type`='$action' OR";
- }
- $action_line = substr($action_line, 0, -2);
- $action_line .= ") ";
- }
-
- $count = "count(wid)";
- if ($bool_distinct)
- {
- $count = "count(distinct `user_id`)";
- }
-
- $user_type = "";
- if ($bool_students)
- {
- $user_type = " `is_student` = '1' ";
- } else {
- $user_type = " `is_faculty` = '1' ";
- }
-
- if ($bool_mobile_only) {
- $action_line .= " AND is_mobile = '1' ";
- }
-
- $start_ts = strtotime($start_date);
- $end_ts = strtotime($end_date);
-
- $res = db_query("SELECT $count AS count FROM watchdog
- WHERE
- `timestamp` > '$start_ts' AND `timestamp` < '$end_ts'
- AND $user_type
- AND
- $action_line
- ");
- $cur = db_fetch_array($res);
- return $cur["count"] * 1;
-
-
- }
-
-
-
-
-
- /**
- * Displays the HTML for the date range form used by several reports.
- * $path is what is the form's ACTION sending to.
- */
- function stats_draw_date_range_form($path, $start_date = "", $end_date = "") {
- $rtn = "";
-
- $rtn .= "<form action='" . fp_url($path) . "' method='GET' >
- " . t("Enter dates in the format YYYY-MM-DD (ex: 2012-01-01)") . "
- <br>
- " . t("Start date:") . " <input type='text' name='start_date' value='$start_date' id='start_date'>
-
- " . t("End date:") . " <input type='text' name='end_date' value='$end_date' id='end_date'>
-
- <input type='submit' value='" . t("Submit") . "'>
- </form> <hr>
- <script type='text/javascript'>
- $(function() {
- $('#start_date').datepicker({ dateFormat: 'yy-mm-dd'});
- $('#end_date').datepicker({ dateFormat: 'yy-mm-dd'});
- });
- </script>";
-
-
- return $rtn;
- }
-
-
- /**
- * This report shows which advisors are using FlightPath most often.
- *
- *
- * @return unknown
- */
- function stats_report_advisor_use() {
- $rtn = "";
-
- $start_date = trim(addslashes(@$_REQUEST["start_date"]));
- $end_date = trim(addslashes(@$_REQUEST["end_date"]));
-
- $rtn .= stats_draw_date_range_form("stats/reports/advisor-use", $start_date, $end_date);
-
- if ($start_date == "" || $end_date == "") {
- return $rtn;
- }
-
- $start_date .= " 00:00:00"; // make it start at midnight of the startDate.
- $end_date .= " 23:59:59"; // make it go through to midnight of the endDate.
-
- $start_ts = strtotime($start_date);
- $end_ts = strtotime($end_date);
-
- // Now, what we're doing here is we want the names of the advisors,
- // and how many advisings they actually completed for each,
- // as well as which college or department they belong to. They need
- // to be sorted by college/department.
- $f_array = array();
- $s_array = array();
-
- $result = db_query("SELECT * FROM watchdog a, faculty b, users c
- WHERE
- a.timestamp > '?' AND a.timestamp < '?'
- AND
- (a.type = 'save_adv_active' OR a.type = 'save_adv_active_whatif')
- AND a.cwid = b.cwid
- AND a.cwid = c.cwid
- AND c.is_faculty = 1
- ORDER BY b.department ", $start_ts, $end_ts);
-
- while($cur = db_fetch_array($result)) {
- $faculty_id = trim($cur["cwid"]);
-
- if (!isset($f_array[$faculty_id])) $f_array[$faculty_id] = 0;
-
- $f_array[$faculty_id] = intval($f_array[$faculty_id]); // make it a number.
- $f_array[$faculty_id]++;
-
- $s_array[$faculty_id]["dept_name"] = ucwords(strtolower(trim($cur["department"])));
- $s_array[$faculty_id]["college_name"] = ucwords(strtolower(trim($cur["college"])));
- $s_array[$faculty_id]["name"] = ucwords(strtolower(trim($cur["f_name"]) . " " . trim($cur["l_name"])));
-
-
-
- }
-
-
-
- // Sort based on who has advised the most...
- //arsort($f_array);
-
- $start_date = trim(addslashes($_REQUEST["start_date"]));
- $end_date = trim(addslashes($_REQUEST["end_date"]));
-
- // Now, output the results...
- $rtn .= "
- <table border='1' width='650'>
- <tr>
- <th>" . t("Name") . "</th>
- <th>" . t("Dept") . "</th>
- <th>#</th>
- </tr>";
- foreach($f_array as $faculty_id => $value)
- {
- $name = $s_array[$faculty_id]["name"];
- $college_name = $s_array[$faculty_id]["college_name"];
- $dept_name = $s_array[$faculty_id]["dept_name"];
-
- $rtn .= "<tr>
- <td valign='top'>$name</td>
- <td valign='top'>$dept_name</td>
- <td valign='top' align='center'>$value</td>
- </tr>
-
- ";
- }
- $rtn .= "</table>";
-
-
-
- return $rtn;
- }
-
-
-
- /**
- * This report shows recent activity in FlightPath. It can also be used to see
- * if anyone is "online" in that they would have activity less than 5 minutes old.
- *
- * @return unknown
- */
- function stats_report_access_stats() {
- $rtn = "";
-
-
- $min = trim(addslashes(@$_REQUEST["min"]));
- if ($min == "")
- {
- $min = "20";
- }
-
-
- $rtn .= "
- <form action='" . fp_url("stats/reports/access") . "' method='GET'>
- " . t("Activity over the last") . "
- <input type='text' name='min' value='$min' size='2'>
- ";
-
-
-
- $rtn .= t("minutes") . ": <input type='submit' value='->'>
- </form>
- " . t("Unique students in time frame") . ": <!--STUDENTS-->. " . t("Unique faculty/staff in time frame") . ": <!--STAFF--> <br>";
-
- $rtn .= "<table border='1' width='700'>
- <tr>
- <th>" . t("User") . "</th>
- <th>" . t("UID") . "</th>
- <th>" . t("CWID") . "</th>
- <th>" . t("Name") . "</th>
- <th>" . t("Type") . "</th>
- <th>" . t("Action") . "</th>
- <th>" . t("Extra") . "</th>
- <th>" . t("Time") . "</th>
- </tr>";
-
- $cwid_array = array();
- $student_actions = $staff_actions = 0;
-
- $interval = time() - ($min * 60);
-
- $res = db_query("SELECT * FROM watchdog
- WHERE `timestamp` > '?'
- ORDER BY `timestamp` DESC ", $interval);
- while ($cur = db_fetch_array($res)) {
- extract ($cur, 3, "db");
-
- $account = fp_load_user($db_user_id);
-
- $bgcol = "white";
- if ($account->is_student) {
- $bgcol = "lightblue";
- }
- else if ($account->is_faculty){
- $bgcol = "pink";
- }
-
- $minago = round((time() - $db_timestamp) / 60, 0);
-
- $extra_data = trim(substr($db_extra_data, 0, 18));
- if (strlen($extra_data) < strlen($db_extra_data))
- {
- $extra_data .= "...";
- }
-
- $pretty_date = format_date($db_timestamp);
-
- $user_type = "";
- if ($account->is_student) {
- $user_type .= "<div>" . t("student") . "</div>";
- }
- if ($account->is_faculty) {
- $user_type .= "<div>" . t("faculty") . "</div>";
- }
-
- $rtn .= "<tr style='background-color:$bgcol'>
- <td valign='top' class='tenpt'>$account->name</td>
- <td valign='top' class='tenpt'>$account->cwid</td>
- <td valign='top' class='tenpt'>$account->id</td>
- <td valign='top' class='tenpt'>$account->f_name $account->l_name</td>
- <td valign='top' class='tenpt'>$user_type</td>
- <td valign='top' class='tenpt'>$db_type</td>
- <td valign='top' class='tenpt'>" . t($db_message, unserialize($db_variables)) . "</td>
- <td valign='top' class='tenpt'>$minago " . t("min ago") . " <font size='1'>$pretty_date</font></td>
- </tr>";
-
- // Let's increase our counters, if this is a new CWID.
- if (!in_array($db_user_id, $cwid_array)) {
- $cwid_array[] = $db_user_id;
- if ($account->is_student) {
- $student_actions++;
- } else if ($account->is_faculty) {
- $staff_actions++;
- }
- }
-
-
- }
-
- // Add in our student and staff action counts
- $rtn = str_replace("<!--STUDENTS-->",$student_actions,$rtn);
- $rtn = str_replace("<!--STAFF-->",$staff_actions,$rtn);
-
-
- $rtn .= "</table>";
-
-
- return $rtn;
- }
-
-
- /**
- * This report shows a list of all of a student's courses which FlightPath is aware of.
- *
- * @return unknown
- */
- function stats_report_student_course_list() {
-
- $rtn = "";
-
- $student_cwid = trim(addslashes(@$_REQUEST["student_cwid"]));
- $student_pidm = 0;
- $rtn .= stats_draw_student_cwid_form("stats/reports/student-course-list", $student_cwid);
-
- if ($student_cwid == "") {
- return $rtn;
- }
-
- // If we have the banner_integration module installed, then get the pidm from banner too
- if (function_exists("banner_integration_get_pidm_for_cwid")) {
- $student_pidm = banner_integration_get_pidm_for_cwid($student_cwid);
- }
- $student_name = fp_get_student_name($student_cwid);
- $student = new Student($student_cwid);
-
-
- $rtn .= "
-
- <style>
- .zebra-even {
- background-color: white;
- }
- .zebra-odd {
- background-color: #ddd;
- }
- </style>
-
- <h2>$student_name ($student_cwid)
- ";
- if ($student_pidm > 0) {
- $rtn .= "<br>PIDM: $student_pidm";
- }
- $rtn .= "</h2>
- <table border='0' cellspacing='0' cellpadding='6'>
- <tr>
- <th>Subject</th>
- <th>Number</th>
- <th>Grade</th>
- <th>Hours</th>
- <th>Term</th>
- <th>Transfer?</th>
- </tr>";
-
-
- // So that we can sort our list of courses, we will add them to
- // 2 arrays, one for local courses, one for transfer.
- $local_array = array();
- $transfer_array = array();
-
- $pol = "even";
-
- $local_hours = 0;
- $transfer_hours = 0;
-
-
-
- while($student->list_courses_taken->has_more()) {
- $course = $student->list_courses_taken->get_next();
-
- $subjectID = $course->subject_id;
- $courseNum = $course->course_num;
- $grade = $course->grade;
- $hours = $course->get_hours_awarded();
-
- $rnd = mt_rand(0,9999);
-
- if (is_object($course->course_transfer)) {
- $subjectID = $course->course_transfer->subject_id;
- $courseNum = $course->course_transfer->course_num;
- $grade = $course->course_transfer->grade;
- $hours = $course->course_transfer->get_hours_awarded();
-
- $transfer_hours += $hours;
-
- }
- else {
- // local course
- $local_hours += $hours;
- }
-
- $html_line = "
- <td>$subjectID</td>
- <td>$courseNum</td>
- <td>$grade</td>
- <td>$hours</td>
- <td>$course->term_id</td>
- <td>" . (($course->bool_transfer) ? "T" : "") . "</td>
- ";
-
- if ($course->bool_transfer) {
- // The $rnd makes sure this is unique, in case a course is showing as repeated in the same term.
- $transfer_array["$course->term_id~$subjectID~$courseNum~$rnd"] = $html_line;
- }
- else {
- // The $rnd makes sure this is unique, in case a course is showing as repeated in the same term.
- $local_array["$course->term_id~$subjectID~$courseNum~$rnd"] = $html_line;
- }
-
-
- }
-
-
- // Okay, now let's sort our arrays and display them.
- ksort($transfer_array);
- ksort($local_array);
-
- foreach($local_array as $line) {
- $rtn .= "<tr class='zebra-$pol'>$line</tr>";
- $pol = ($pol == "even")?"odd":"even";
- }
-
- foreach($transfer_array as $line) {
- $rtn .= "<tr class='zebra-$pol'>$line</tr>";
- $pol = ($pol == "even")?"odd":"even";
- }
-
-
-
- $rtn .= "</table>
- <hr>
- ";
-
- $rtn .= "<p>" . count($local_array) . " local courses, with $local_hours hours.</p>";
- $rtn .= "<p>" . count($transfer_array) . " transfer courses, with $transfer_hours hours.</p>";
-
-
-
- return $rtn;
-
-
- }
-
-
-
- /**
- * Main menu screen for this module.
- *
- * We will simply display the "menu block" for "stats/reports". That is,
- * any path that begins with stats/reports will show up here.
- *
- * You can create a report in your custom module, and as long as the url begins
- * with stats/reports, and the menu item is of type "MENU_TYPE_NORMAL_ITEM"
- * it will appear on this page. Set the weight to be > 1000 to appear below this list,
- * set weight < 100 to appear above.
-
- *
- * @return unknown
- */
- function stats_display_main() {
- $rtn = "";
-
-
-
- $rtn .= "<div class='stats-main-menu' style='font-size:1.2em;'>";
- $rtn .= fp_render_menu_block("System Reports", "stats/reports");
- $rtn .= "</div>";
-
- // If we have other reports which have been exposed using the hook_stats_additional_menublocks function,
- // display them here.
-
- $reports = invoke_hook('stats_additional_menublocks');
- if ($reports) {
- foreach ($reports as $module_name => $temp) {
- $rtn .= "<div class='stats-main-menu stats-additional-menublocks' style='font-size:1.2em;'>";
- foreach($reports[$module_name] as $title => $menu_block_path) {
- $rtn .= fp_render_menu_block($title, $menu_block_path);
- }
- $rtn .= "</div>";
- }
- }
-
-
-
-
-
- return $rtn;
- }
Functions
Name | Description |
---|---|
stats_display_main | Main menu screen for this module. |
stats_download_csv_from_batch | Lets the user download a CSV file from a completed batch. |
stats_draw_catalog_year_pulldown | Return the HTML for a pulldown containing the catalog years available for selection. |
stats_draw_date_range_form | Displays the HTML for the date range form used by several reports. $path is what is the form's ACTION sending to. |
stats_draw_majors_pulldown | Display a major selection pulldown, used by other reports. |
stats_draw_student_cwid_form | Draws a simple form for entering a student's CWID, used by other reports. |
stats_get_log_count | Used by the use_summary report. This function will simply return log counts for the specified parameters in the watchdog table. |
stats_menu | Implementation of hook_menu |
stats_perm | Implementation of hook_perm(). Expects to return an array of permissions recognized by this module. |
stats_report_access_stats | This report shows recent activity in FlightPath. It can also be used to see if anyone is "online" in that they would have activity less than 5 minutes old. |
stats_report_advisor_use | This report shows which advisors are using FlightPath most often. |
stats_report_course_use_summary | This report will display everywhere a particular course is used in FlightPath (groups and degrees) |
stats_report_flightpath_use_summary | This report shows common usages in FlightPath by all users. |
stats_report_major_counts | This report shows how many students are in each major. |
stats_report_student_course_list | This report shows a list of all of a student's courses which FlightPath is aware of. |
stats_test | Lets me run a test... |
z__stats_report_selected_degree_options | This report will show which degree options are being selected for degrees which offer options. |