stats.module

  1. 6.x modules/stats/stats.module
  2. 4.x modules/stats/stats.module
  3. 5.x modules/stats/stats.module

This module displays statistics and reports for FlightPath

File

modules/stats/stats.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * This module displays statistics and reports for FlightPath
  5. *
  6. * @return unknown
  7. */
  8. /**
  9. * Implementation of hook_menu
  10. *
  11. * @return unknown
  12. */
  13. function stats_menu() {
  14. $items = array();
  15. $items["stats"] = array(
  16. "title" => "Analytics & Reports",
  17. "page_callback" => "stats_display_main",
  18. "access_arguments" => array("can_access_stats"),
  19. "page_settings" => array(
  20. "page_show_title" => TRUE,
  21. ),
  22. "type" => MENU_TYPE_NORMAL_ITEM,
  23. );
  24. $items["stats/select-school"] = array(
  25. "title" => "Select School",
  26. "page_callback" => "fp_render_form",
  27. "page_arguments" => array("stats_select_school_form"),
  28. "access_arguments" => array("can_access_stats"),
  29. "page_settings" => array(
  30. "page_show_title" => TRUE,
  31. "bool_print" => FALSE,
  32. "menu_links" => array(
  33. 0 => array(
  34. "text" => t("Analytics"),
  35. "path" => "stats",
  36. ),
  37. ),
  38. ),
  39. "type" => MENU_TYPE_CALLBACK,
  40. );
  41. $items["stats/reports/access"] = array(
  42. "title" => "Access Stats",
  43. "description" => "See recent access within the system. This can be useful to see if anyone is currently using the system.",
  44. "page_callback" => "stats_report_access_stats",
  45. "access_arguments" => array("can_access_stats"),
  46. "page_settings" => array(
  47. "page_show_title" => TRUE,
  48. "menu_links" => array(
  49. 0 => array(
  50. "text" => t("Analytics"),
  51. "path" => "stats",
  52. ),
  53. ),
  54. ),
  55. "type" => MENU_TYPE_NORMAL_ITEM,
  56. "weight" => 100,
  57. );
  58. $items["stats/reports/major-counts"] = array(
  59. "title" => "Major Counts",
  60. "description" => "Displays the number of students within each major or major/concentration.",
  61. "page_callback" => "stats_report_major_counts",
  62. "access_arguments" => array("can_access_stats"),
  63. "page_settings" => array(
  64. "page_show_title" => TRUE,
  65. "menu_links" => array(
  66. 0 => array(
  67. "text" => t("Analytics"),
  68. "path" => "stats",
  69. ),
  70. ),
  71. ),
  72. "type" => MENU_TYPE_NORMAL_ITEM,
  73. "weight" => 150,
  74. );
  75. $items["stats/reports/major-students-progress"] = array(
  76. "title" => "Major Students Progress",
  77. "description" => "Students in a major, and their progress percentages in that major.",
  78. "page_callback" => "fp_render_form",
  79. "page_arguments" => array("stats_report_major_students_progress_form"),
  80. "access_arguments" => array("can_access_stats"),
  81. "page_settings" => array(
  82. "bool_print" => FALSE,
  83. "menu_links" => array(
  84. 0 => array(
  85. "text" => t("Analytics"),
  86. "path" => "stats",
  87. ),
  88. ),
  89. ),
  90. "type" => MENU_TYPE_NORMAL_ITEM,
  91. "weight" => 170,
  92. "file" => menu_get_module_path("stats") . "/reports.major-students-progress.inc",
  93. );
  94. $items["stats/reports/advisor-use"] = array(
  95. "title" => "Advisor Use",
  96. "description" => "How many students an advisor has advised over a specified time range.",
  97. "page_callback" => "stats_report_advisor_use",
  98. "access_arguments" => array("can_access_stats"),
  99. "page_settings" => array(
  100. "page_show_title" => TRUE,
  101. "bool_print" => FALSE,
  102. "menu_links" => array(
  103. 0 => array(
  104. "text" => t("Analytics"),
  105. "path" => "stats",
  106. ),
  107. ),
  108. ),
  109. "type" => MENU_TYPE_NORMAL_ITEM,
  110. "weight" => 250,
  111. );
  112. $system_name = variable_get("system_name", "FlightPath");
  113. $items["stats/reports/student-course-list"] = array(
  114. "title" => "Student Course List",
  115. "description" => "List courses a student has taken, which $system_name is aware of.",
  116. "page_callback" => "stats_report_student_course_list",
  117. "access_arguments" => array("can_access_stats"),
  118. "page_settings" => array(
  119. "page_show_title" => TRUE,
  120. "menu_links" => array(
  121. 0 => array(
  122. "text" => t("Analytics"),
  123. "path" => "stats",
  124. ),
  125. ),
  126. ),
  127. "type" => MENU_TYPE_NORMAL_ITEM,
  128. "weight" => 300,
  129. );
  130. $items["stats/reports/flightpath-use-summary"] = array(
  131. "title" => "$system_name Use Summary",
  132. "description" => "A detailed report on how $system_name is being used over a specified time range.",
  133. "page_callback" => "stats_report_flightpath_use_summary",
  134. "access_arguments" => array("can_access_stats"),
  135. "page_settings" => array(
  136. "page_show_title" => TRUE,
  137. "menu_links" => array(
  138. 0 => array(
  139. "text" => t("Analytics"),
  140. "path" => "stats",
  141. ),
  142. ),
  143. ),
  144. "type" => MENU_TYPE_NORMAL_ITEM,
  145. "weight" => 350,
  146. );
  147. $items["stats/reports/course-use-summary"] = array(
  148. "title" => "Course Use Summary",
  149. "description" => "A report of everywhere a particular course is used in $system_name (groups or degrees).",
  150. "page_callback" => "stats_report_course_use_summary",
  151. "access_arguments" => array("can_access_stats"),
  152. "page_settings" => array(
  153. "page_show_title" => TRUE,
  154. "menu_links" => array(
  155. 0 => array(
  156. "text" => t("Analytics"),
  157. "path" => "stats",
  158. ),
  159. ),
  160. ),
  161. "type" => MENU_TYPE_NORMAL_ITEM,
  162. "weight" => 450,
  163. );
  164. // Lets the user download a CSV file stored in the batch_queue table, with a batch_id.
  165. $items["stats/download-csv-from-batch/%"] = array(
  166. "page_callback" => "stats_download_csv_from_batch",
  167. "page_arguments" => array(2),
  168. "access_arguments" => array("can_access_stats"),
  169. "type" => MENU_TYPE_CALLBACK,
  170. );
  171. return $items;
  172. }
  173. /**
  174. * Lets the user download a CSV file from a completed batch.
  175. *
  176. * There are no permissions on this, except the can_access_stats permission.
  177. *
  178. * @param unknown_type $batch_id
  179. */
  180. function stats_download_csv_from_batch($batch_id) {
  181. $filename = fp_get_machine_readable(strtolower($_REQUEST["filename"]));
  182. $batch = batch_get($batch_id);
  183. watchdog('stats', "download_csv_from_batch batch_id:$batch_id, filename:$filename.csv", array());
  184. // Give it to the browser...
  185. header('Content-type: text/csv');
  186. header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
  187. print $batch["csv"];
  188. die;
  189. }
  190. /**
  191. * Implementation of hook_perm().
  192. * Expects to return an array of permissions recognized by
  193. * this module.
  194. *
  195. * Ex: $a = array(
  196. * "deCanDoSomething" => array (
  197. * "title" => "Can Do Something",
  198. * "description" => "Allow the user to do something."
  199. * )
  200. * );
  201. *
  202. */
  203. function stats_perm() {
  204. $perms = array (
  205. "can_access_stats" => array(
  206. "title" => t("Access/view stats & analytics"),
  207. "description" => t("This allows the user to access the stats module, letting them run
  208. reports on usage."),
  209. ),
  210. );
  211. return $perms;
  212. }
  213. /**
  214. * Return the HTML for a pulldown containing the catalog years available for selection.
  215. *
  216. * @param unknown_type $selected
  217. * @param unknown_type $display_submit
  218. */
  219. function stats_draw_catalog_year_pulldown($selected = "", $display_submit = FALSE) {
  220. $rtn = "";
  221. $rtn .= "
  222. <table border='0'>
  223. <td valign='middle'>
  224. <select name='catalog_year' id='catalog_year'><option value=''>
  225. " . t("Please select a catalog year") . "</option>
  226. <option value=''>-----------------------------------</option>";
  227. $current_catalog_year = variable_get("current_catalog_year", ""); // TODO: school_id?
  228. if ($selected == "") $selected = $current_catalog_year;
  229. $res = db_query("SELECT DISTINCT (catalog_year) FROM degrees
  230. WHERE exclude = '0'
  231. ORDER BY catalog_year DESC");
  232. while ($cur = db_fetch_array($res)) {
  233. $sel = ($cur["catalog_year"] == $selected) ? "selected=selected" : "";
  234. $rtn .= "<option value='{$cur["catalog_year"]}' $sel>{$cur["catalog_year"]}-" . ($cur["catalog_year"] + 1) . "</option>";
  235. }
  236. $rtn .= " </select> </td>";
  237. if ($display_submit == true)
  238. {
  239. $rtn .= "<td valign='middle'><input type='submit' value='" . t("Select") . "'></td>";
  240. }
  241. $rtn .= "</table>";
  242. return $rtn;
  243. }
  244. /**
  245. * This report will display everywhere a particular course is used in FlightPath (groups and degrees)
  246. *
  247. */
  248. function stats_report_course_use_summary() {
  249. $rtn = "";
  250. $draft = "";
  251. $use_draft = FALSE;
  252. $subject_id = trim(@$_GET["subject_id"]);
  253. $course_num = trim(@$_GET["course_num"]);
  254. $school_id = intval(@$_GET["school_id"]);
  255. $draft_check = @$_GET["draft"];
  256. if ($draft_check == "checked") {
  257. $draft = "draft_";
  258. $use_draft = TRUE;
  259. }
  260. $rtn .= "<form action='" . fp_url("stats/reports/course-use-summary") . "' method='GET' >";
  261. $rtn .= "Please enter a course's subject ID and course number to search:<br>";
  262. if (module_enabled("schools")) {
  263. $options = schools_get_schools_for_fapi();
  264. $rtn .= "<select name='school_id'>";
  265. foreach ($options as $k => $v) {
  266. $sel = "";
  267. if (intval($k) === $school_id) $sel = "selected";
  268. $rtn .= "<option value='$k' $sel>" . t("School: ") . $v . "</option>";
  269. }
  270. $rtn .= "</select> &nbsp; ";
  271. }
  272. $rtn .= "
  273. <input type='text' name='subject_id' placeholder='Subject ID' size='10' value='$subject_id'> &nbsp;
  274. <input type='text' name='course_num' placeholder='Course Num' size='10' value='$course_num'> &nbsp;
  275. <input type='checkbox' name='draft' value='checked' $draft_check>Check draft tables? &nbsp;
  276. <input type='submit' value='Search'>
  277. <br><b>Note:</b> This may take up to a minute to run, please be patient.";
  278. $rtn .= "</form>";
  279. if ($subject_id && $course_num) {
  280. $rtn .= "<hr>";
  281. // First, look up this course's ID.
  282. $db = get_global_database_handler();
  283. $course_id = $db->get_course_id($subject_id, $course_num, '', $use_draft, $school_id);
  284. if ($course_id) {
  285. $rtn .= "<h2>Course $subject_id $course_num (id is $course_id)</h2>";
  286. // Groups
  287. $rtn .= "<div><b>Groups:</b></div>
  288. <table border='1'>
  289. <tr>
  290. <th>ID</th>
  291. <th>Name</th>
  292. <th>Title</th>
  293. <th>Year</th>
  294. </tr>";
  295. $res = db_query("SELECT * FROM {$draft}group_requirements WHERE course_id = ?
  296. order by `id`", $course_id);
  297. while ($cur = db_fetch_array($res)) {
  298. $group_id = $cur["group_id"];
  299. $group = new Group($group_id, $db, -1, false, $use_draft);
  300. if (!$group->title) {
  301. // This is possibly a child group. Look for its parent.
  302. $res2 = db_query("SELECT * FROM {$draft}group_requirements WHERE child_group_id = ?", $group_id);
  303. $cur2 = db_fetch_array($res2);
  304. if ($cur2["group_id"] != "") {
  305. $group_id = $cur2["group_id"];
  306. $group = new Group($group_id, $db, -1, false, $use_draft);
  307. }
  308. }
  309. $rtn .= "<tr>
  310. <td>$group_id</td>
  311. <td>$group->group_name</td>
  312. <td>$group->title</td>
  313. <td>$group->catalog_year</td>
  314. </tr>";
  315. }
  316. $rtn .= "</table>";
  317. // Now, look for degrees...
  318. $rtn .= "<br><br><br>
  319. <b>Degrees:</b>
  320. <table border='1'>
  321. <tr>
  322. <th>ID</th>
  323. <th>Title</th>
  324. <th>MAJR</th>
  325. <th>Track</th>
  326. <th>Sem</th>
  327. <th>Year</th>
  328. </tr>";
  329. $res = db_query("SELECT * FROM {$draft}degree_requirements WHERE course_id = ? ORDER BY `id`", $course_id);
  330. while ($cur = db_fetch_array($res)) {
  331. $degree_id = $cur["degree_id"];
  332. $degree = new DegreePlan($degree_id, $db, TRUE, FALSE, $use_draft);
  333. $rtn .= "<tr>
  334. <td>$degree_id</td>
  335. <td>$degree->title</td>
  336. <td>$degree->major_code</td>
  337. <td>$degree->track_code</td>
  338. <td>" . $cur["semester_num"] . "</td>
  339. <td>$degree->catalog_year</td>
  340. </tr>";
  341. }
  342. $rtn .= '</table>';
  343. } // if course_id
  344. else {
  345. $rtn .= "<div>Course could not be found. Check spelling.";
  346. }
  347. }
  348. watchdog('stats', "report_course_use_summary subject_id:$subject_id, course_num:$course_num, school_id:$school_id, draft_check:$draft_check", array());
  349. return $rtn;
  350. }
  351. /**
  352. * This report will show which degree options are being selected for degrees which offer options.
  353. *
  354. * @return unknown
  355. */
  356. function z__stats_report_selected_degree_options() {
  357. $rtn = "";
  358. // What major have they selected?
  359. $major = trim(@$_GET["major"]);
  360. $rtn .= "<form action='" . fp_url("stats/reports/selected-degree-options") . "' method='GET' >";
  361. $rtn .= stats_draw_majors_pulldown($major, TRUE, TRUE, t("Please select a major with degree options"));
  362. $rtn .= "</form>";
  363. $db = get_global_database_handler();
  364. if ($major != "")
  365. {
  366. $count_in_major = 0;
  367. $degree_option_count = array();
  368. $sql = "SELECT * FROM students a, student_degrees b
  369. WHERE substring_index(major_code, '|', 1) = '?'
  370. AND rank_code IN %RANKIN%
  371. AND a.cwid = b.student_id
  372. %EXTRA_STUDENTSEARCH_CONDITIONS%
  373. GROUP BY a.cwid";
  374. $rank_in = "( '" . join("', '", csv_to_array(variable_get("allowed_student_ranks",''))) . "' )";
  375. $sql = str_replace("%RANKIN%", $rank_in, $sql);
  376. $sql = str_replace("%EXTRA_STUDENTSEARCH_CONDITIONS%", variable_get("extra_student_search_conditions",''), $sql);
  377. $result = db_query($sql, $major);
  378. while($cur = db_fetch_array($result))
  379. {
  380. extract($cur, 3, "db");
  381. $count_in_major++;
  382. $track = "";
  383. // Does this student have a track (degree option) specified?
  384. //$student_settings = $db->get_student_settings($db_cwid);
  385. $student_major_codes = $db->get_student_majors_from_db($db_cwid);
  386. // Look through all the major codes for this student, and see if any
  387. // have a |_ in them. If they do, that means they are a track.
  388. foreach ($student_major_codes as $mc) {
  389. if (strstr($mc, $major . "|_")) {
  390. $track = $mc; // Yes, so this is a track for this major.
  391. // Init if not already...
  392. if (!isset($degree_option_count[$track])) {
  393. $degree_option_count[$track] = 0;
  394. }
  395. $degree_option_count[$track]++;
  396. }
  397. }
  398. // No track found. Add that one, too.
  399. if ($track == "")
  400. {
  401. $track = t("None selected");
  402. // Init if not already...
  403. if (!isset($degree_option_count[$track])) {
  404. $degree_option_count[$track] = 0;
  405. }
  406. $degree_option_count[$track]++;
  407. }
  408. } // while db_fetch_array
  409. arsort($degree_option_count);
  410. $rtn .= "<table border='1'>
  411. <tr>
  412. <th>" . t("Degree Option") . "</th>
  413. <th>" . t("Count") . "</th>
  414. <th>" . t("Description") . "</th>
  415. </tr>";
  416. foreach($degree_option_count as $d_option => $value)
  417. {
  418. //$desc = get_track_title($major,$d_option);
  419. // figure out the title of the track...
  420. $temp = explode("-", $db_catalog_year);
  421. $cy = $temp[0];
  422. $degree_id = $db->get_degree_id($d_option, $cy);
  423. $dp = new DegreePlan();
  424. $dp->degree_id = $degree_id;
  425. $dp->load_descriptive_data();
  426. $desc = $dp->get_title2(TRUE, TRUE);
  427. $rtn .= "<tr><td valign='top'>
  428. $d_option
  429. </td>
  430. <td valign='top'>
  431. $value
  432. </td>
  433. <td valign='top'>
  434. $desc
  435. </td>
  436. </tr>";
  437. }
  438. $rtn .= "</table>" . t("Total number of students:") . " $count_in_major.";
  439. }
  440. return $rtn;
  441. }
  442. /**
  443. * Display a major selection pulldown, used by other reports.
  444. *
  445. * If bool_only_majors_with_tracks == TRUE, then we will only display the majors which
  446. * have tracks associated with them.
  447. *
  448. * If bool_exclude_tracks == TRUE, then we will skip over any major_code with a "_" in it,
  449. * meaning, this code describes a track and not the base major.
  450. *
  451. * If bool_only_current_catalog_year == TRUE, then only degrees from the current catalog year
  452. * will be displayed.
  453. *
  454. */
  455. 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, $school_id = 0)
  456. {
  457. $rtn = "";
  458. $db = get_global_database_handler();
  459. $major_array = array();
  460. $options_array = array();
  461. $current_catalog_year = variable_get_for_school("current_catalog_year", "", $school_id);
  462. $m_a_count = 0;
  463. if ($bool_only_current_catalog_year) {
  464. $query = "SELECT * FROM degrees
  465. WHERE catalog_year = ?
  466. AND school_id = ?
  467. AND `exclude`='0'
  468. ORDER BY major_code ";
  469. $result = db_query($query, $current_catalog_year, $school_id);
  470. }
  471. else { // current catalog year not important.
  472. $query = "SELECT * FROM degrees
  473. WHERE `exclude`='0'
  474. AND school_id = ?
  475. GROUP BY major_code
  476. ORDER BY major_code ";
  477. $result = db_query($query, $school_id);
  478. }
  479. while ($cur_row = $db->db_fetch_array($result)) {
  480. $major = trim($cur_row["major_code"]);
  481. if ($bool_exclude_tracks && strpos($major, "_")) {
  482. continue;
  483. }
  484. if ($bool_only_majors_with_tracks && !$db->get_degree_tracks($major, $current_catalog_year))
  485. { // only get majors that also have tracks!
  486. continue;
  487. }
  488. $description = trim($cur_row["title"]);
  489. $type = trim($cur_row["degree_type"]);
  490. $school_id = intval($cur_row['school_id']);
  491. $major_array[$m_a_count]["description"] = $description;
  492. $major_array[$m_a_count]["major"] = $major;
  493. $major_array[$m_a_count]["type"] = $type;
  494. $major_array[$m_a_count]["school_id"] = $school_id;
  495. if (module_enabled("schools")) {
  496. $major_array[$m_a_count]["school_name"] = t("School: ") . schools_get_school_name_for_id($school_id);
  497. }
  498. $m_a_count++;
  499. }
  500. $rtn .= "
  501. <table border='0'>
  502. <td valign='middle'>
  503. <select name='major' id='major'>
  504. <option value=''>" . $label . "</option>
  505. <option value=''>-----------------------------------</option>";
  506. for ($t = 0; $t < $m_a_count; $t++)
  507. {
  508. $sel = "";
  509. if ($major_array[$t]["major"] == $smajor && $smajor != "")
  510. {
  511. $sel = "selected";
  512. }
  513. $hyph = "-";
  514. if ($major_array[$t]["type"] == "" || $major_array[$t]["type"] == "NA")
  515. {
  516. $hyph = "";
  517. $major_array[$t]["type"] = "";
  518. }
  519. $rtn .= "<option value='" . $major_array[$t]["major"] . "' $sel>(" . $major_array[$t]["major"] . ")
  520. " . $major_array[$t]["description"] . " $hyph " . $major_array[$t]["type"] . "
  521. </option>";
  522. if (module_enabled("schools")) {
  523. // Create an options array multi-dimentional, organized by school name.
  524. $options_array[$major_array[$t]["school_name"]][$major_array[$t]["major"]] = "(" . $major_array[$t]["major"] . ") " . $major_array[$t]["description"] . " $hyph " . $major_array[$t]["type"];
  525. }
  526. else {
  527. // Just create a "flat" options array
  528. $options_array[$major_array[$t]["major"]] = "(" . $major_array[$t]["major"] . ") " . $major_array[$t]["description"] . " $hyph " . $major_array[$t]["type"];
  529. }
  530. }
  531. $rtn .= " </select> </td>";
  532. if ($display_submit == true)
  533. {
  534. $rtn .= "<td valign='middle'><input type='submit' value='" . t("Select") . "'></td>";
  535. }
  536. $rtn .= "</table>";
  537. if ($bool_return_options_array) return $options_array;
  538. return $rtn;
  539. }
  540. /**
  541. * Draws a simple form for entering a student's CWID, used by other reports.
  542. *
  543. * @param unknown_type $path
  544. * @param unknown_type $student_cwid
  545. * @return unknown
  546. */
  547. function z__stats_draw_student_cwid_form($path, $student_cwid = "") {
  548. $rtn = "";
  549. $rtn .= "<form action='" . fp_url($path) . "' method='GET' >
  550. " . t("Enter a student's CWID to see their courses") . "
  551. <br>
  552. <span class='form-element element-type-textfield'>
  553. <input type='textfield' value='$student_cwid' name='student_cwid'>
  554. </span>
  555. <span class='buttons form-element element-type-submit'>
  556. <input type='submit' value='" . t("Submit") . "'>
  557. </span>
  558. </form> <hr>
  559. ";
  560. return $rtn;
  561. }
  562. function stats_select_school_form() {
  563. $form = array();
  564. if (isset($_REQUEST['title'])) {
  565. fp_set_title(strip_tags($_REQUEST['title']));
  566. }
  567. $redirect_path = $_REQUEST['redirect'];
  568. $options = schools_get_schools_for_fapi();
  569. $form['school_id'] = array(
  570. 'type' => 'select',
  571. 'label' => t("Please select a school:"),
  572. 'options' => $options,
  573. 'hide_please_select' => TRUE,
  574. );
  575. $form['select_school'] = array(
  576. 'type' => 'hidden',
  577. 'value' => 'yes',
  578. );
  579. $form['redirect'] = array(
  580. 'type' => 'hidden',
  581. 'value' => base64_encode($redirect_path),
  582. );
  583. $form['submit_btn'] = array(
  584. 'type' => 'submit',
  585. 'value' => t("Continue"),
  586. );
  587. // change breadcrumbs based on REQUEST
  588. if (isset($_REQUEST['crumbs'])) {
  589. $crumbs = unserialize(base64_decode($_REQUEST['crumbs']));
  590. fp_set_breadcrumbs($crumbs);
  591. }
  592. return $form;
  593. }
  594. function stats_select_school_form_submit($form, $form_state) {
  595. // We are simply trying to select the school. Return to the form with our selection.
  596. $school_id = intval($form_state['values']['school_id']);
  597. $redirect_path = base64_decode($form_state['values']['redirect']);
  598. fp_goto($redirect_path, 'school_id=' . $school_id);
  599. return;
  600. }
  601. /**
  602. * This report shows how many students are in each major.
  603. *
  604. * @return unknown
  605. */
  606. function stats_report_major_counts() {
  607. $rtn = "";
  608. $rtn .= "<p>" . t("This report shows number of students in each major or concentration, as defined in FlightPath.") . "</p>";
  609. $rtn .= "<table border='1'>
  610. <tr>";
  611. if (module_enabled('schools')) {
  612. $rtn .= "<th>" . t("School") . "</th>";
  613. }
  614. $rtn .= "
  615. <th>" . t("Major") . "</th>
  616. <th>" . t("Count") . "</th>
  617. <th colspan='2'>" . t("Description") . "</th>
  618. </tr>";
  619. $total = 0;
  620. $result = db_query("SELECT * FROM degrees
  621. GROUP BY major_code
  622. ORDER BY school_id, major_code, title ");
  623. while ($cur = db_fetch_array($result)) {
  624. $count = 0;
  625. $major_code = $cur["major_code"];
  626. $title = $cur["title"];
  627. $degree_type = $cur["degree_type"];
  628. $school_id = intval($cur['school_id']);
  629. $school_code = "#$school_id";
  630. if ($school_id === 0) $school_code = "-";
  631. if (module_enabled("schools")) {
  632. $school_code = schools_get_school_code_for_id($school_id);
  633. }
  634. // Find out how many students have this major code.
  635. $sql = "SELECT count(cwid) AS count FROM students a, student_degrees b
  636. WHERE b.major_code = ?
  637. AND a.cwid = b.student_id
  638. AND rank_code IN %RANKIN%
  639. %EXTRA_STUDENTSEARCH_CONDITIONS% ";
  640. $rank_in = "( '" . join("', '", csv_to_array(variable_get("allowed_student_ranks", "FR,SO,JR,SR"))) . "' )";
  641. $sql = str_replace("%RANKIN%", $rank_in, $sql);
  642. $sql = str_replace("%EXTRA_STUDENTSEARCH_CONDITIONS%", variable_get("extra_student_search_conditions",""), $sql);
  643. $res2 = db_query($sql, $major_code);
  644. $cur2 = db_fetch_array($res2);
  645. if (is_numeric($cur2["count"])) {
  646. $total += $cur2["count"];
  647. }
  648. $res_array[$major_code]["count"] = $cur2["count"] * 1;
  649. $res_array[$major_code]["desc"] = $title;
  650. $res_array[$major_code]["type"] = $degree_type;
  651. $res_array[$major_code]["school_code"] = $school_code;
  652. }
  653. foreach($res_array as $major => $value) {
  654. $rtn .= "<tr>";
  655. if (module_enabled('schools')) {
  656. $rtn .= "<td valign='top' class='tenpt'>{$value["school_code"]}</td>";
  657. }
  658. $rtn .= "
  659. <td valign='top' class='tenpt'>$major</td>
  660. <td valign='top' class='tenpt'>{$value["count"]}</td>
  661. <td valign='top' class='tenpt'>{$value["type"]}</td>
  662. <td valign='top' class='tenpt'>{$value["desc"]}</td>
  663. </tr>";
  664. }
  665. $rtn .= "</table>
  666. " . t("Total student records:") . " $total.";
  667. watchdog('stats', "report_major_counts", array());
  668. return $rtn;
  669. }
  670. /**
  671. * This report shows common usages in FlightPath by all users.
  672. *
  673. * This is a helpful report for determining which functionality is most popular
  674. * in FlightPath
  675. *
  676. * @return unknown
  677. */
  678. function stats_report_flightpath_use_summary() {
  679. $rtn = "";
  680. $start_date = @$_REQUEST["start_date"];
  681. $end_date = @$_REQUEST["end_date"];
  682. $rtn .= stats_draw_date_range_form("stats/reports/flightpath-use-summary", $start_date, $end_date);
  683. if ($start_date == "" || $end_date == "") {
  684. return $rtn;
  685. }
  686. $start_date .= " 00:00:00"; // make it start at midnight of the startDate.
  687. $end_date .= " 23:59:59"; // make it go through to midnight of the endDate.
  688. // Okay, now we get our various counts....
  689. // Logins...
  690. $u_student = stats_get_log_count("login","",true,$start_date,$end_date,true);
  691. $t_student = stats_get_log_count("login","",false,$start_date,$end_date,true);
  692. $u_staff = stats_get_log_count("login","",true,$start_date,$end_date,false);
  693. $t_staff = stats_get_log_count("login","",false,$start_date,$end_date,false);
  694. $rtn .= "<b>System Logins</b>
  695. <blockquote>
  696. Unique student logins: $u_student<br>
  697. Total student logins: $t_student<br>
  698. ------- <br>
  699. Unique faculty/staff logins: $u_staff<br>
  700. Total faculty/staff logins: $t_staff
  701. </blockquote>
  702. ";
  703. // Advisings...
  704. $regular_advisings = stats_get_log_count("save_adv_active","",false,$start_date,$end_date,false);
  705. $wi_advisings = stats_get_log_count("save_adv_active_whatif","",false,$start_date,$end_date,false);
  706. $total_advisings = $regular_advisings + $wi_advisings;
  707. $rtn .= "<b>Advisings</b>
  708. <blockquote>
  709. Total student advisings: $total_advisings <br>
  710. ------- <br>
  711. Regular advisings: $regular_advisings<br>
  712. What If advisings: $wi_advisings
  713. </blockquote>
  714. ";
  715. // Comments...
  716. $total = stats_get_log_count("save_comment","",false,$start_date,$end_date,false);
  717. $unique = stats_get_log_count("save_comment","",true,$start_date,$end_date,false);
  718. $rtn .= "<b>Comments</b>
  719. <blockquote>
  720. Total comments saved: $total <br>
  721. ------- <br>
  722. Unique faculty/staff commentors: $unique
  723. </blockquote>
  724. ";
  725. // Course search...
  726. $u_student = stats_get_log_count("course_search","",true,$start_date,$end_date,true);
  727. $um_student = stats_get_log_count("course_search","",true,$start_date,$end_date,true,true);
  728. $t_student = stats_get_log_count("course_search","",false,$start_date,$end_date,true);
  729. $tm_student = stats_get_log_count("course_search","",false,$start_date,$end_date,true, true);
  730. $u_staff = stats_get_log_count("course_search","",true,$start_date,$end_date,false);
  731. $t_staff = stats_get_log_count("course_search","",false,$start_date,$end_date,false);
  732. $tm_staff = stats_get_log_count("course_search","",false,$start_date,$end_date,false, true);
  733. $rtn .= "<b>Course Search</b>
  734. <blockquote>
  735. Unique student users: $u_student <span class='s-mobile'>($um_student mobile)</span><br>
  736. Total student uses: $t_student <span class='s-mobile'>($tm_student mobile)</span><br>
  737. ------- <br>
  738. Unique faculty/staff users: $u_staff<br>
  739. Total faculty/staff (and anonymous) uses: $t_staff <span class='s-mobile'>($tm_staff mobile)</span>
  740. </blockquote>
  741. ";
  742. // Degree search...
  743. $u_student = stats_get_log_count("blank_degrees","",true,$start_date,$end_date,true);
  744. $um_student = stats_get_log_count("blank_degrees","",true,$start_date,$end_date,true,true);
  745. $t_student = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,true);
  746. $tm_student = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,true, true);
  747. $u_staff = stats_get_log_count("blank_degrees","",true,$start_date,$end_date,false);
  748. $t_staff = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,false);
  749. $tm_staff = stats_get_log_count("blank_degrees","",false,$start_date,$end_date,false, true);
  750. $rtn .= "<b>Degree Search (blank degrees)</b>
  751. <blockquote>
  752. Unique student users: $u_student <span class='s-mobile'>($um_student mobile)</span><br>
  753. Total student uses: $t_student <span class='s-mobile'>($tm_student mobile)</span><br>
  754. ------- <br>
  755. Unique faculty/staff users: $u_staff<br>
  756. Total faculty/staff (and anonymous) uses: $t_staff <span class='s-mobile'>($tm_staff mobile)</span>
  757. </blockquote>
  758. ";
  759. // View preferences
  760. $t_student_y = stats_get_log_count("view_by_year","",false,$start_date,$end_date,true);
  761. $tm_student_y = stats_get_log_count("view_by_year","",false,$start_date,$end_date,true, true);
  762. $u_student_y = stats_get_log_count("view_by_year","",true,$start_date,$end_date,true);
  763. $um_student_y = stats_get_log_count("view_by_year","",true,$start_date,$end_date,true, true);
  764. $t_staff_y = stats_get_log_count("view_by_year","",false,$start_date,$end_date,false);
  765. $t_student_t = stats_get_log_count("view_by_type","",false,$start_date,$end_date,true);
  766. $tm_student_t = stats_get_log_count("view_by_type","",false,$start_date,$end_date,true, true);
  767. $u_student_t = stats_get_log_count("view_by_type","",true,$start_date,$end_date,true);
  768. $um_student_t = stats_get_log_count("view_by_type","",true,$start_date,$end_date,true, true);
  769. $t_staff_t = stats_get_log_count("view_by_type","",false,$start_date,$end_date,false);
  770. $rtn .= "<b>View Preferences</b>
  771. <blockquote>
  772. Unique student view-by-year: $u_student_y <span class='s-mobile'>($um_student_y mobile)</span><br>
  773. Total student view-by-year: $t_student_y <span class='s-mobile'>($tm_student_y mobile)</span><br>
  774. Total faculty/staff view-by-year: $t_staff_y<br>
  775. ------- <br>
  776. Unqiue student view-by-type: $u_student_t <span class='s-mobile'>($um_student_t mobile)</span><br>
  777. Total student view-by-type: $t_student_t <span class='s-mobile'>($tm_student_t mobile)</span><br>
  778. Total faculty/staff view-by-type: $t_staff_t<br>
  779. </blockquote>
  780. ";
  781. // Substitutions
  782. $t_staff = stats_get_log_count("save_substitution","",false,$start_date,$end_date,false);
  783. $u_staff = stats_get_log_count("save_substitution","",true,$start_date,$end_date,false);
  784. $rtn .= "<b>Substitutions</b>
  785. <blockquote>
  786. Unique substitutors: $u_staff<br>
  787. Total substitutions: $t_staff<br>
  788. </blockquote>
  789. ";
  790. watchdog('stats', "report_flightpath_use_summary start_date:$start_date, end_date:$end_date", array());
  791. return $rtn;
  792. }
  793. /**
  794. * Used by the use_summary report. This function will simply return log counts
  795. * for the specified parameters in the watchdog table.
  796. *
  797. * @param unknown_type $action
  798. * @param unknown_type $action_array
  799. * @param unknown_type $bool_distinct
  800. * @param unknown_type $start_date
  801. * @param unknown_type $end_date
  802. * @param unknown_type $bool_students
  803. * @param unknown_type $bool_mobile_only
  804. * @return unknown
  805. */
  806. function stats_get_log_count($action = "", $action_array = "", $bool_distinct = false, $start_date = '', $end_date = '', $bool_students = true, $bool_mobile_only = false)
  807. {
  808. $action_line = " `type` = '$action' ";
  809. if (is_array($action_array) && count($action_array) > 1)
  810. {
  811. $action_line = "";
  812. $action_line .= "( ";
  813. foreach($action_array as $action)
  814. {
  815. $action_line .= " `type`='$action' OR";
  816. }
  817. $action_line = substr($action_line, 0, -2);
  818. $action_line .= ") ";
  819. }
  820. $count = "count(wid)";
  821. if ($bool_distinct)
  822. {
  823. $count = "count(distinct `user_id`)";
  824. }
  825. $user_type = "";
  826. if ($bool_students)
  827. {
  828. $user_type = " `is_student` = '1' ";
  829. } else {
  830. $user_type = " `is_faculty` = '1' ";
  831. }
  832. if ($bool_mobile_only) {
  833. $action_line .= " AND is_mobile = '1' ";
  834. }
  835. $start_ts = strtotime($start_date);
  836. $end_ts = strtotime($end_date);
  837. $res = db_query("SELECT $count AS count FROM watchdog
  838. WHERE
  839. `timestamp` > '$start_ts' AND `timestamp` < '$end_ts'
  840. AND $user_type
  841. AND
  842. $action_line
  843. ");
  844. $cur = db_fetch_array($res);
  845. return $cur["count"] * 1;
  846. }
  847. /**
  848. * Displays the HTML for the date range form used by several reports.
  849. * $path is what is the form's ACTION sending to.
  850. *
  851. * start and end date expected in YYYY-MM-DD format
  852. *
  853. */
  854. function stats_draw_date_range_form($path, $start_date = "", $end_date = "") {
  855. $rtn = "";
  856. $rtn .= "<form action='" . fp_url($path) . "' method='GET' >
  857. " . t("Select a date range to begin:") . "
  858. <br>
  859. " . t("Start date:") . "
  860. <span class='form-element element-type-date element-size-smaller'>
  861. <input type='date' name='start_date' value='$start_date' id='start_date'>
  862. </span>
  863. &nbsp; &nbsp;
  864. " . t("End date:") . "
  865. <span class='form-element element-type-date'>
  866. <input type='date' name='end_date' value='$end_date' id='end_date'>
  867. </span>
  868. &nbsp; &nbsp;
  869. <span class='buttons form-element element-type-submit'>
  870. <input type='submit' value='" . t("Submit") . "'>
  871. </span>
  872. </form> <hr>
  873. ";
  874. return $rtn;
  875. }
  876. /**
  877. * This report shows which advisors are using FlightPath most often.
  878. *
  879. *
  880. * @return unknown
  881. */
  882. function stats_report_advisor_use() {
  883. $rtn = "";
  884. $start_date = trim(addslashes(@$_REQUEST["start_date"]));
  885. $end_date = trim(addslashes(@$_REQUEST["end_date"]));
  886. $rtn .= stats_draw_date_range_form("stats/reports/advisor-use", $start_date, $end_date);
  887. if ($start_date == "" || $end_date == "") {
  888. return $rtn;
  889. }
  890. $start_date .= " 00:00:00"; // make it start at midnight of the startDate.
  891. $end_date .= " 23:59:59"; // make it go through to midnight of the endDate.
  892. $start_ts = strtotime($start_date);
  893. $end_ts = strtotime($end_date);
  894. // Now, what we're doing here is we want the names of the advisors,
  895. // and how many advisings they actually completed for each,
  896. // as well as which college or department they belong to. They need
  897. // to be sorted by college/department.
  898. $f_array = array();
  899. $s_array = array();
  900. $result = db_query("SELECT * FROM watchdog a, faculty b, users c
  901. WHERE
  902. a.timestamp > '?' AND a.timestamp < '?'
  903. AND
  904. (a.type = 'save_adv_active' OR a.type = 'save_adv_active_whatif')
  905. AND a.cwid = b.cwid
  906. AND a.cwid = c.cwid
  907. AND c.is_faculty = 1
  908. ORDER BY b.department_code ", $start_ts, $end_ts);
  909. while($cur = db_fetch_array($result)) {
  910. $faculty_id = trim($cur["cwid"]);
  911. $school_id = intval($cur['school_id']);
  912. $departments = fp_get_departments($school_id);
  913. if (!isset($f_array[$faculty_id])) $f_array[$faculty_id] = 0;
  914. $dept_name = @$departments[$cur['department_code']];
  915. if (!$dept_name) $dept_name = $cur['department_code'];
  916. $f_array[$faculty_id] = intval($f_array[$faculty_id]); // make it a number.
  917. $f_array[$faculty_id]++;
  918. $s_array[$faculty_id]["dept_name"] = $dept_name;
  919. $s_array[$faculty_id]["college_name"] = ucwords(strtolower(trim($cur["college"])));
  920. $s_array[$faculty_id]["school_id"] = $school_id;
  921. $s_array[$faculty_id]["name"] = ucwords(strtolower(trim($cur["f_name"]) . " " . trim($cur["l_name"])));
  922. }
  923. // Sort based on who has advised the most...
  924. //arsort($f_array);
  925. $start_date = trim(addslashes($_REQUEST["start_date"]));
  926. $end_date = trim(addslashes($_REQUEST["end_date"]));
  927. // Now, output the results...
  928. $rtn .= "
  929. <table border='1' width='650'>
  930. <tr>";
  931. if (module_enabled('schools')) {
  932. $rtn .= "<th>" . t("School") . "</th>";
  933. }
  934. $rtn .= "
  935. <th>" . t("Name") . "</th>
  936. <th>" . t("Dept") . "</th>
  937. <th>#</th>
  938. </tr>";
  939. foreach($f_array as $faculty_id => $value)
  940. {
  941. $name = $s_array[$faculty_id]["name"];
  942. $college_name = $s_array[$faculty_id]["college_name"];
  943. $dept_name = $s_array[$faculty_id]["dept_name"];
  944. $school_id = $s_array[$faculty_id]["school_id"];
  945. $rtn .= "<tr>";
  946. if (module_enabled('schools')) {
  947. $rtn .= "<td valign='top'>" . schools_get_school_name_for_id($school_id) . "</td>";
  948. }
  949. $rtn .= "
  950. <td valign='top'>$name</td>
  951. <td valign='top'>$dept_name</td>
  952. <td valign='top' align='center'>$value</td>
  953. </tr>
  954. ";
  955. }
  956. $rtn .= "</table>";
  957. return $rtn;
  958. }
  959. /**
  960. * This report shows recent activity in FlightPath. It can also be used to see
  961. * if anyone is "online" in that they would have activity less than 5 minutes old.
  962. *
  963. * @return unknown
  964. */
  965. function stats_report_access_stats() {
  966. $rtn = "";
  967. fp_add_css(fp_get_module_path("admin") . '/css/admin.css');
  968. $min = intval(@$_REQUEST["min"]);
  969. if ($min < 1 || $min > 2000)
  970. {
  971. $min = "20";
  972. }
  973. $rtn .= "
  974. <form action='" . fp_url("stats/reports/access") . "' method='GET'>
  975. " . t("Activity over the last") . "
  976. <input type='text' name='min' value='$min' size='2'>
  977. ";
  978. $rtn .= t("minutes") . ": <input type='submit' value='&gt;'>
  979. </form>
  980. " . t("Unique students in time frame") . ": <!--STUDENTS-->. " . t("Unique faculty/staff in time frame") . ": <!--STAFF--> <br>";
  981. $rtn .= "<hr>
  982. <table class='watchdog-table' cellspacing='0' cellpadding='4'>
  983. <tr>
  984. <th>" . t("ID") . "</th>
  985. <th>" . t("User") . "</th>
  986. <th>" . t("User Type") . "</th>
  987. <th>" . t("Action") . "</th>
  988. <th>" . t("Msg") . "</th>
  989. <th>" . t("Time") . "</th>
  990. </tr>";
  991. $cwid_array = array();
  992. $student_actions = $staff_actions = 0;
  993. $interval = time() - ($min * 60);
  994. $pol = "";
  995. $res = db_query("SELECT * FROM watchdog
  996. WHERE `timestamp` > ?
  997. ORDER BY `timestamp` DESC
  998. ", $interval);
  999. while ($cur = db_fetch_array($res)) {
  1000. extract ($cur, 3, "db");
  1001. $wid = $cur['wid'];
  1002. $account = fp_load_user($db_user_id);
  1003. $pol = ($pol == "even") ? "odd" : "even";
  1004. $minago = round((time() - $db_timestamp) / 60, 0);
  1005. $vars = @unserialize($db_variables);
  1006. if (!$vars) $vars = '';
  1007. $message = strip_tags(t($db_message, $vars));
  1008. if (strlen($message) > 100) {
  1009. $message = trim(substr($message, 0, 100)) . "...";
  1010. }
  1011. $pretty_date = format_date(convert_time($db_timestamp));
  1012. $user_type = "";
  1013. if ($account->is_student) {
  1014. $user_type .= "<span>" . t("Student") . "</span>";
  1015. }
  1016. if ($account->is_faculty) {
  1017. $user_type .= "<span style='background-color: lightyellow;'>" . t("Faculty") . "</span>";
  1018. }
  1019. $rtn .= "<tr class='row-$pol'>
  1020. <td valign='top'>" . l($wid, "admin/config/watchdog/$wid") . "</td>
  1021. <td valign='top'>$account->name</td>
  1022. <td valign='top'>$user_type</td>
  1023. <td valign='top'>$db_type</td>
  1024. <td valign='top'>$message</td>
  1025. <td valign='top'>$minago " . t("min ago") . " &nbsp; <em>($pretty_date)</em></td>
  1026. </tr>";
  1027. // Let's increase our counters, if this is a new CWID.
  1028. if (!in_array($db_user_id, $cwid_array)) {
  1029. $cwid_array[] = $db_user_id;
  1030. if ($account->is_student) {
  1031. $student_actions++;
  1032. } else if ($account->is_faculty) {
  1033. $staff_actions++;
  1034. }
  1035. }
  1036. }
  1037. // Add in our student and staff action counts
  1038. $rtn = str_replace("<!--STUDENTS-->",$student_actions,$rtn);
  1039. $rtn = str_replace("<!--STAFF-->",$staff_actions,$rtn);
  1040. $rtn .= "</table>";
  1041. return $rtn;
  1042. }
  1043. /**
  1044. * This report shows a list of all of a student's courses which FlightPath is aware of.
  1045. *
  1046. * @return unknown
  1047. */
  1048. function stats_report_student_course_list() {
  1049. $rtn = "";
  1050. $student_cwid = trim(addslashes(@$_REQUEST["student_cwid"]));
  1051. $student_pidm = 0;
  1052. //$rtn .= stats_draw_student_cwid_form("stats/reports/student-course-list", $student_cwid);
  1053. $rtn .= "<form action='" . fp_url("stats/reports/student-course-list") . "' method='GET' >
  1054. " . t("Enter a student's CWID to see their courses:") . "
  1055. <br>
  1056. <span class='form-element element-type-textfield'>
  1057. <input type='textfield' value='$student_cwid' name='student_cwid'>
  1058. </span>
  1059. <span class='buttons form-element element-type-submit'>
  1060. <input type='submit' value='" . t("Submit") . "'>
  1061. </span>
  1062. </form> <hr>";
  1063. if ($student_cwid == "") {
  1064. return $rtn;
  1065. }
  1066. // If we have the banner_integration module installed, then get the pidm from banner too
  1067. if (function_exists("banner_integration_get_pidm_for_cwid")) {
  1068. $student_pidm = intval(banner_integration_get_pidm_for_cwid($student_cwid));
  1069. }
  1070. $student_name = fp_get_student_name($student_cwid);
  1071. $student = new Student($student_cwid);
  1072. $school_id = db_get_school_id_for_student_id($student_cwid);
  1073. $school_name = "";
  1074. if (module_enabled("schools")) {
  1075. $school_name = schools_get_school_name_for_id($school_id);
  1076. }
  1077. $rtn .= "
  1078. <style>
  1079. .zebra-even {
  1080. background-color: white;
  1081. }
  1082. .zebra-odd {
  1083. background-color: #eee;
  1084. }
  1085. </style>
  1086. <h2>$student_name ($student_cwid)
  1087. ";
  1088. if ($student_pidm > 0) {
  1089. $rtn .= "<br>PIDM: $student_pidm";
  1090. }
  1091. if ($school_name) {
  1092. $rtn .= "<br>" . t("School:") . "<em>$school_name</em>";
  1093. }
  1094. $rtn .= "</h2>
  1095. <table border='0' cellspacing='0' cellpadding='6'>
  1096. <tr>
  1097. <th>Subject</th>
  1098. <th>Number</th>
  1099. <th>Grade</th>
  1100. <th>Hours</th>
  1101. <th>Term</th>
  1102. <th>Transfer?</th>
  1103. </tr>";
  1104. // So that we can sort our list of courses, we will add them to
  1105. // 2 arrays, one for local courses, one for transfer.
  1106. $local_array = array();
  1107. $transfer_array = array();
  1108. $pol = "even";
  1109. $local_hours = 0;
  1110. $transfer_hours = 0;
  1111. while($student->list_courses_taken->has_more()) {
  1112. $course = $student->list_courses_taken->get_next();
  1113. $subjectID = $course->subject_id;
  1114. $courseNum = $course->course_num;
  1115. $grade = $course->grade;
  1116. $hours = $course->get_hours_awarded();
  1117. $rnd = mt_rand(0,9999);
  1118. if (is_object($course->course_transfer)) {
  1119. $subjectID = $course->course_transfer->subject_id;
  1120. $courseNum = $course->course_transfer->course_num;
  1121. $grade = $course->course_transfer->grade;
  1122. $hours = $course->course_transfer->get_hours_awarded();
  1123. $transfer_hours += $hours;
  1124. }
  1125. else {
  1126. // local course
  1127. $local_hours += $hours;
  1128. }
  1129. $html_line = "
  1130. <td>$subjectID</td>
  1131. <td>$courseNum</td>
  1132. <td>$grade</td>
  1133. <td>$hours</td>
  1134. <td>$course->term_id</td>
  1135. <td>" . (($course->bool_transfer) ? "T" : "") . "</td>
  1136. ";
  1137. if ($course->bool_transfer) {
  1138. // The $rnd makes sure this is unique, in case a course is showing as repeated in the same term.
  1139. $transfer_array["$course->term_id~$subjectID~$courseNum~$rnd"] = $html_line;
  1140. }
  1141. else {
  1142. // The $rnd makes sure this is unique, in case a course is showing as repeated in the same term.
  1143. $local_array["$course->term_id~$subjectID~$courseNum~$rnd"] = $html_line;
  1144. }
  1145. }
  1146. // Okay, now let's sort our arrays and display them.
  1147. ksort($transfer_array);
  1148. ksort($local_array);
  1149. foreach($local_array as $line) {
  1150. $rtn .= "<tr class='zebra-$pol'>$line</tr>";
  1151. $pol = ($pol == "even")?"odd":"even";
  1152. }
  1153. foreach($transfer_array as $line) {
  1154. $rtn .= "<tr class='zebra-$pol'>$line</tr>";
  1155. $pol = ($pol == "even")?"odd":"even";
  1156. }
  1157. $rtn .= "</table>
  1158. <hr>
  1159. ";
  1160. $rtn .= "<p>" . count($local_array) . " local courses, with $local_hours hours.</p>";
  1161. $rtn .= "<p>" . count($transfer_array) . " transfer courses, with $transfer_hours hours.</p>";
  1162. watchdog('stats', "report_student_course_list student_id:$student_cwid, school_id:$school_id, student_name:$student_name", array());
  1163. return $rtn;
  1164. }
  1165. /**
  1166. * Main menu screen for this module.
  1167. *
  1168. * We will simply display the "menu block" for "stats/reports". That is,
  1169. * any path that begins with stats/reports will show up here.
  1170. *
  1171. * You can create a report in your custom module, and as long as the url begins
  1172. * with stats/reports, and the menu item is of type "MENU_TYPE_NORMAL_ITEM"
  1173. * it will appear on this page. Set the weight to be > 1000 to appear below this list,
  1174. * set weight < 100 to appear above.
  1175. *
  1176. * @return unknown
  1177. */
  1178. function stats_display_main() {
  1179. $rtn = "";
  1180. $rtn .= "<div class='stats-main-menu'>";
  1181. $rtn .= fp_render_menu_block("System Reports", "stats/reports");
  1182. $rtn .= "</div>";
  1183. // If we have other reports which have been exposed using the hook_stats_additional_menublocks function,
  1184. // display them here.
  1185. $reports = invoke_hook('stats_additional_menublocks');
  1186. if ($reports) {
  1187. foreach ($reports as $module_name => $temp) {
  1188. $extraclass = "";
  1189. $extraclass .= "stats-menublock-path-" . strtolower(fp_get_machine_readable(current($reports[$module_name])));
  1190. $rtn .= "<div class='stats-main-menu stats-additional-menublocks $extraclass'>";
  1191. foreach($reports[$module_name] as $title => $menu_block_path) {
  1192. $rtn .= fp_render_menu_block($title, $menu_block_path);
  1193. }
  1194. $rtn .= "</div>";
  1195. }
  1196. }
  1197. return $rtn;
  1198. }

Functions

Namesort descending 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_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_select_school_form
stats_select_school_form_submit
z__stats_draw_student_cwid_form Draws a simple form for entering a student's CWID, used by other reports.
z__stats_report_selected_degree_options This report will show which degree options are being selected for degrees which offer options.