function stats_report_selected_degree_options

4.x stats.module stats_report_selected_degree_options()

This report will show which degree options are being selected for degrees which offer options.

Return value

unknown

File

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

Code

function stats_report_selected_degree_options() {
  $rtn = "";


  // What major have they selected?
  $major = trim($_GET ["major"]);

  $rtn .= "<form action='" . fp_url("stats/selected-degree-options") . "' method='GET' >";
  $rtn .= stats_draw_majors_with_options_pulldown($major, true);
  $rtn .= "</form>";

  $db = get_global_database_handler();

  if ($major != "") 
   {
    $count_in_major = 0;
    $degree_option_count = array();

    $sql = "SELECT * FROM students
            WHERE substring_index(major_code, '|', 1) = '?'
            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);

    $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);

      if ($student_settings ["major_code"] == $major) 
       {
        $track = $student_settings ["track_code"];
      }

      if ($track == "") 
       {
        $track = t("None selected");
      }

      // Init if not already...
      $degree_option_count [$track] = $degree_option_count [$track] * 1;

      $degree_option_count [$track];
    }

    ++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($major . "|_" . $d_option, $cy);

      $dp = new DegreePlan();
      $dp->degree_id = $degree_id;
      $dp->load_descriptive_data();
      $desc = $dp->track_title;


      $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 results:") . " $count_in_major.";

  }



  return $rtn;
}