function stats_report_student_course_list

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

This report shows a list of all of a student's courses which FlightPath is aware of.

Return value

unknown

File

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

Code

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

  $rtn .= "<form action='" . fp_url("stats/reports/student-course-list") . "' method='GET' >
            " . t("Enter a student's CWID to see their courses:") . "
            <br>
            <span class='form-element element-type-textfield'>
              <input type='textfield' value='$student_cwid' name='student_cwid'>
            </span>
            
            <span class='buttons form-element element-type-submit'>
              <input type='submit' value='" . t("Submit") . "'>
            </span>
          </form> <hr>";


  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 = intval(banner_integration_get_pidm_for_cwid($student_cwid));
  }
  $student_name = fp_get_student_name($student_cwid);
  $student = new Student($student_cwid);

  $school_id = db_get_school_id_for_student_id($student_cwid);
  $school_name = "";
  if (module_enabled("schools")) {
    $school_name = schools_get_school_name_for_id($school_id);
  }


  $rtn .= "
  
  <style>
    .zebra-even {
      background-color: white;
    }
    .zebra-odd {
      background-color: #eee;
    }
  </style>
  
      <h2>$student_name ($student_cwid)
      ";
  if ($student_pidm > 0) {
    $rtn .= "<br>PIDM: $student_pidm";
  }
  if ($school_name) {
    $rtn .= "<br>" . t("School:") . "<em>$school_name</em>";
  }
  $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>";


  watchdog('stats', "report_student_course_list student_id:$student_cwid, school_id:$school_id, student_name:$student_name", array());


  return $rtn;


}