function course_search_display_edit_courses

6.x course_search.edit.inc course_search_display_edit_courses()
4.x course_search.edit.inc course_search_display_edit_courses()
5.x course_search.edit.inc course_search_display_edit_courses()

Display a plain list of courses, making it easier for admins to edit schedules and details in one spot.

File

modules/course_search/course_search.edit.inc, line 428
This file contains functions relating to editing the course info, like rotation schedule and syllabus

Code

function course_search_display_edit_courses() 
 {

  $rtn = "";

  $school_id = 0;
  if (@$_REQUEST ['school_id'] != '') {
    $school_id = intval($_REQUEST ['school_id']);
  }


  if (module_enabled("schools")) { // The schools module is enabled.  We need to first ask what school we want to look at. 

    $rtn .= "<div class='current-school'>" . t("Current school: ") . "<strong>" . schools_get_school_name_for_id($school_id) . "</strong>
                     - " . l(t("Change?"), "tools/course-search") . "</div><br>";
  }

  $current_catalog_year = variable_get_for_school("current_catalog_year", "", $school_id);
  // catalog_year is always just whatever the current year is.
  $catalog_year = $current_catalog_year;


  $cc = 1;

  // Get the "upper range" (UR) and
  // lower range (LR) of the courses in question...
  $ur = trim(@$_GET ["ur"]);
  $lr = trim(@$_GET ["lr"]);
  if ($ur == "") 
   { // meaning, no range was set.  Use A - AZZZZZ, so, all of the A's.
    $ur = @$_SESSION ["dec_ur"];
    $lr = @$_SESSION ["dec_lr"];
    if ($ur == "") 
     { // if still blank, assign it..
      $ur = "A";
      $lr = "AZZZZ";
    }

  }
  $_SESSION ["dec_ur"] = $ur;
  $_SESSION ["dec_lr"] = $lr;


  $rtn .= "
      <div class='tenpt' style='margin-bottom: 20px;'>
        " . t("To update a course's sample syllabus or schedule,
        please select the course from the list below.") . "       
      </div>
      ";



  $letter_ranges = array(
    "A" => array("A", "AZZZZ"),
    "B" => array("B", "BZZZZ"),
    "C-CN" => array("C", "CNZZZ"),
    "CO-CZ" => array("CO", "CZZZZ"),
    "D" => array("D", "DZZZZ"),
    "E" => array("E", "EZZZZ"),
    "F" => array("F", "FZZZZ"),
    "G" => array("G", "GZZZZ"),
    "H" => array("H", "HZZZZ"),
    "I-L" => array("I", "LZZZZ"),
    "M-MR" => array("M", "MRZZZ"),
    "MS-MZ" => array("MS", "MZZZZ"),
    "N-O" => array("N", "OZZZZ"),
    "P" => array("P", "PZZZZ"),
    "Q-R" => array("Q", "RZZZZ"),
    "S-SO" => array("S", "SOZZZ"),
    "SP-SZ" => array("SP", "SZZZZ"),
    "T-Z" => array("T", "ZZZZZ"),
  );


  $rtn .= "<div class='admin-courses-select-letter-bar'>
          ";
  foreach ($letter_ranges as $disp => $vals) {
    $rtn .= l($disp, "tools/course-search/edit-list", "school_id=$school_id&ur=" . $vals [0] . "&lr=" . $vals [1], array("class" => "admin-courses-letter-link")) . " &nbsp; ";
  }

  $rtn .= "</div>
            <hr>";





  $rtn .= "<table border='0' cellpadding='3' cellspacing='0' width='100%'>
      <tr>
        <th class='tenpt'>Course</td>";
  if (module_enabled('schools')) {
    $rtn .= "       
        <th class='tenpt' align='center'>School</td>
        ";
  }
  $rtn .= "        
        <th class='tenpt' align='center'>Sched</td>
        <th class='tenpt' align='center'>Syl</td>
        <th class='tenpt' align='center'>Updated</td>
      </tr>";

  $res = db_query("SELECT * FROM courses
                        WHERE catalog_year = ? 
                        AND subject_id BETWEEN ? AND ?
                        AND delete_flag = 0
                        AND exclude = 0
                        AND school_id = ?
                        ORDER BY subject_id, course_num ", $catalog_year, $ur, $lr, $school_id);
  while ($cur = db_fetch_array($res)) {
    extract($cur, 3, "db");

    $syl = $sch = $school = $updated = "";
    // Right here, maybe check to see if this course has
    // a syllabus and/or schedule entered?

    $school = "#" . $cur ['school_id'];
    if (module_enabled("schools")) {
      $school = schools_get_school_code_for_id($school_id);
    }

    $syllabus_details = course_search_get_course_syllabus_details($db_course_id);
    $filename = @$syllabus_details ["filename"];


    if ($filename != "") {

      $url = $syllabus_details ["url"];

      $syl = "<a href='$url'><i class='fa fa-file-o'></i></a>";

      $updated = $syllabus_details ["posted"];
    }
    $schedule_array = course_search_get_course_rotation_schedule($db_course_id, $catalog_year, 100, TRUE);
    $not_ant = course_search_get_course_rotation_schedule_not_anticipated($db_course_id);
    if (count($schedule_array) > 0 || $not_ant == true) {
      $sch = "<img src='" . fp_theme_location() . "/images/small_check.gif'>";
      if ($not_ant) {
        $sch = "NA";
      }
      // When was the schedule last updated?
      $res2 = db_query("SELECT * FROM course_rotation_schedule
                       WHERE course_id = ? 
                       LIMIT 1", $db_course_id);
      $cur2 = db_fetch_array($res2);
      if ($cur2) {
        $updated2 = $cur2 ["posted"];
        if ($updated2 > $updated) {
          $updated = $updated2;
        }
      }
    }

    if ($updated != "") {
      $updated = date("n/d/Y", $updated);
    }



    $hrs = $db_min_hours;
    if (trim($db_min_hours) != trim($db_max_hours)) {
      $hrs .= " - $db_max_hours";
    }

    $hrs .= " hrs.";

    $rep_hours = "";
    if ($db_repeat_hours > $db_min_hours) 
     {
      $rep_hours = " rep to $db_repeat_hours hrs.";
    }

    // remove special chars from subject_id...
    $display_subject_id = $db_subject_id;
    $db_subject_id = urlencode($db_subject_id);


    $rtn .= "<tr>
        <td valign='top' >";

    /*$rtn .= "<div style='padding:3px;'>
          <a href='$moduleActionURL&performAction=editSpecificCourse&courseID=$db_course_id&subjectID=$db_subject_id&courseNum=$db_course_num'>$displaySubjectID $db_course_num - $db_title</a><!-- - $hrs$repHours --></div>";
*/

    $rtn .= l("$display_subject_id $db_course_num - $db_title", "tools/course-search/edit-info-details", "school_id=$school_id&course_id=$db_course_id&subject_id=$db_subject_id&course_num=$db_course_num");
    // https://orion.ulm.edu/flightpath/tools/course-search/edit-info-details?course_id=468798&subject_id=ACCT&course_num=1010

    $rtn .= "</td>";
    if (module_enabled('schools')) {
      $rtn .= "   <td >$school</td>";
    }
    $rtn .= "
        <td >$sch</td>
        <td >$syl</td>
        <td >$updated</td>
          </tr>";

  } // while


  $rtn .= "</table>";


  return $rtn;


}