function stats_report_major_counts

6.x stats.module stats_report_major_counts()
4.x stats.module stats_report_major_counts()
5.x stats.module stats_report_major_counts()

This report shows how many students are in each major.

Return value

unknown

File

modules/stats/stats.module, line 401
This module displays statistics and reports for FlightPath

Code

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>";


  $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
            WHERE major_code = '?'
            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;
}