function z__stats_report_selected_degree_options

7.x stats.module z__stats_report_selected_degree_options()
6.x stats.module z__stats_report_selected_degree_options()
5.x stats.module z__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 482
This module displays statistics and reports for FlightPath

Code

function z__stats_report_selected_degree_options() {
  $rtn = "";


  // What major have they selected?
  $major = fp_trim((string) @$_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(variable_get("allowed_student_ranks", ''))) . "' )";
    $sql = str_replace("%RANKIN%", $rank_in, $sql);
    $sql = str_replace("%EXTRA_STUDENTSEARCH_CONDITIONS%", variable_get("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;
}