course_search.module
Search API
- 7.x modules/course_search/course_search.module
- 6.x modules/course_search/course_search.module
- 4.x modules/course_search/course_search.module
- 5.x modules/course_search/course_search.module
This module allows users to search for courses, descriptions, and, if supported, rotation schedules and sample syllabi.
File
modules/course_search/course_search.moduleView source
- <?php
-
- /**
- * @file
- * This module allows users to search for courses, descriptions, and, if supported, rotation schedules
- * and sample syllabi.
- */
-
-
- function course_search_menu() {
- $items = array();
-
- $items["tools/course-search"] = array(
- "title" => "Course Search",
- "description" => "Use this tool to view course descriptions, sample syllabi, and projected course offering schedules.",
- "page_callback" => "course_search_display_search",
- "access_arguments" => array('access_course_search'),
- "page_settings" => array(
- "page_has_search" => FALSE,
- "page_banner_is_link" => TRUE,
- "page_hide_report_error" => TRUE,
- "target" => "_blank",
- "menu_icon" => fp_get_module_path('course_search') . "/icons/book_go.png",
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- );
-
-
- $items["course-search/get-syllabus"] = array(
- "title" => "Course Search",
- "page_callback" => "course_search_download_syllabus",
- "access_arguments" => array('access_course_search'),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
-
- $items["admin/config/course-search"] = array(
- "title" => "Course Search Settings",
- "description" => "Administer the Course Search module's settings",
- "page_callback" => "fp_render_form",
- "page_arguments" => array("course_search_settings_form", "system_settings"),
- "access_arguments" => array("administer_course_search"),
- "page_settings" => array(
- "page_has_search" => FALSE,
- "page_banner_is_link" => TRUE,
- "page_hide_report_error" => TRUE,
- "menu_icon" => fp_get_module_path('course_search') . "/icons/book_go.png",
- "menu_links" => array(
- 0 => array(
- "text" => "Admin Console",
- "path" => "admin-tools/admin",
- "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
- ),
- ),
- ),
- "type" => MENU_TYPE_NORMAL_ITEM,
- );
-
- $items["tools/course-search/courses"] = array(
- "title" => "Course Search",
- "page_callback" => "course_search_display_courses",
- "access_arguments" => array('access_course_search'),
- "page_settings" => array(
- "page_has_search" => FALSE,
- "page_banner_is_link" => TRUE,
- "page_hide_report_error" => TRUE,
- ),
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
- $items["tools/course-search/edit-list"] = array(
- "title" => "Update Course Information",
- "page_callback" => "course_search_display_edit_courses",
- "access_arguments" => array("can_update_course_info_details"),
- "page_settings" => array(
- "page_has_search" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Back to Course Search",
- "path" => "tools/course-search",
- ),
- ),
- ),
- "file" => menu_get_module_path("course_search") . "/course_search.edit.inc",
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
- $items["tools/course-search/edit-info-details"] = array(
- "title" => "Edit Course Info Details",
- "page_callback" => "fp_render_form",
- "page_arguments" => array("course_search_edit_course_details_form"),
- "access_arguments" => array("can_update_course_info_details"),
- "page_settings" => array(
- "page_has_search" => FALSE,
- "page_banner_is_link" => TRUE,
- "menu_links" => array(
- 0 => array(
- "text" => "Back to Course Search",
- "path" => "tools/course-search",
- ),
- 1 => array(
- "text" => "Back to Course Edit List",
- "path" => "tools/course-search/edit-list",
- ),
- ),
- ),
- "file" => menu_get_module_path("course_search") . "/course_search.edit.inc",
- "type" => MENU_TYPE_CALLBACK,
- );
-
- $items["tools/course-search/view-reports"] = array(
- "title" => "View Reports",
- "page_callback" => "course_search_display_view_reports",
- "access_arguments" => array("can_update_course_info_details"),
- "page_settings" => array(
- "page_has_search" => FALSE,
- "menu_links" => array(
- 0 => array(
- "text" => "Back to Course Search",
- "path" => "tools/course-search",
- ),
- 1 => array(
- "text" => "Back to Course Edit List",
- "path" => "tools/course-search/edit-list",
- ),
- ),
- ),
- "file" => menu_get_module_path("course_search") . "/course_search.edit.inc",
- "type" => MENU_TYPE_CALLBACK,
- );
-
- // Simple callback to download CSV
- $items["tools/course-search/get-offering-csv"] = array(
- "page_callback" => "course_search_get_offering_csv",
- "access_arguments" => array("can_update_course_info_details"),
- "file" => menu_get_module_path("course_search") . "/course_search.edit.inc",
- "type" => MENU_TYPE_CALLBACK,
- );
-
-
- return $items;
- }
-
-
-
-
-
-
-
-
-
- function course_search_perm() {
- return array(
- "access_course_search" => array(
- 'title' => t('Access course search'),
- 'description' => t('Users with this setting are allowed to actually view the course search link,
- descriptions, syllabi, etc.'),
- ),
- "administer_course_search" => array(
- "title" => t("Administer course search"),
- "description" => t("Users with this setting will be able
- to modify settings for the Course Search module."),
- ),
- "can_update_course_info_details" => array(
- "title" => t("Can update course info details"),
- "description" => t("Allows users to update the 'course info' details,
- like the course's sample syllabus and rotation
- schedule."),
- ),
-
-
- );
- }
-
-
-
- /**
- * The system settins form for course_search settings.
- */
- function course_search_settings_form() {
- $form = array();
-
- $form["course_search_avail_term_id_suffix_order"] = array(
- "type" => "textfield",
- "label" => t("Available Term ID Suffixes & Order"),
- "value" => variable_get("course_search_avail_term_id_suffix_order", ""),
- "description" => t("Enter the order of term ID suffixes, so that they will display
- in the correct order in the table of available course
- offerings. Separate by comma.") . "
- <br>
- Ex: 60, 40, 41, 80, 81, mm",
- );
-
- $form["course_search_avail_term_headers"] = array(
- "type" => "textfield",
- "label" => t("Available Term Table Headers"),
- "value" => variable_get("course_search_avail_term_headers", ""),
- "description" => t("Enter the table headers for the available table, in the same
- order as the suffix order above.") . "
- <br>
- Ex: Spring, May, Summer 1, Summer 2, Fall, Winter",
- );
-
-
- $form["course_search_avail_term_mobile_headers"] = array(
- "type" => "textfield",
- "label" => t("Available Term Mobile Table Headers"),
- "value" => variable_get("course_search_avail_term_mobile_headers", ""),
- "description" => t("Enter the table headers for the available table, in the same
- order as the suffix order above, as it should be displayed on
- a mobile device (with a smaller screen).") . "
- <br>
- Ex: Spr, May, Sum1, Sum2, Fall, Win",
- );
-
-
- return $form;
- }
-
-
-
- /**
- * This function will actually deliver a syllabus to the user's browser
- * for download.
- *
- */
- function course_search_download_syllabus() {
- // Get our global variables...
-
- $c = trim($_REQUEST["c"]);
- $id = trim($_REQUEST["id"]);
-
- $db = get_global_database_handler();
-
- $temp = explode("_", $c);
- $subject_id = $temp[0];
- $course_num = $temp[1];
-
- // Get the filename in question...
- $query = "select * from course_syllabi
- where course_perm_id = '?' ";
- $params = array($subject_id . "_" . $course_num);
- if ($id != "") {
- $query = "select * from course_syllabi
- where course_id = '?' ";
- $params = array($id);
- }
-
- $res = db_query($query, $params);
- $cur = db_fetch_array($res);
- $filename = $cur["filename"];
-
- $course_id = $cur["course_id"];
-
- // Get the latest subject_id and course_num for this course!
- $new_course = new Course();
- $new_course->course_id = $course_id;
- $new_course->catalog_year = variable_get("current_catalog_year", 2006);
- $new_course->load_descriptive_data(false, false, true);
-
- $subject_id = $new_course->subject_id;
- $course_num = $new_course->course_num;
-
- $files_path = $GLOBALS["fp_system_settings"]["file_system_path"];
-
- if ($filename == "" || !file_exists("$files_path/custom/files/syllabi/$filename"))
- { // Check to make sure the src file actually exists.
- // Display a message, letting the user know it does not
- // exist.
- watchdog("syllabus", "fail,$c", array(), WATCHDOG_ERROR);
- fp_add_message(t("Sorry, the syllabus for @course could not be found.", array("@course" => "$subject_id $course_num")));
- // Just so admins can see:
- fpm("Admin: file path attempted: $files_path/custom/files/syllabi/$filename");
- return;
- }
-
- watchdog("syllabus", "get,$c", array(), WATCHDOG_DEBUG);
-
- $content_type = "application/plain"; // default, save as generic binary file.
- $temp = explode("\.", $filename);
- $ext = $temp[count($temp) - 1]; // get the original file extension.
-
- // attempt to match to the correct content_type...
- if ($ext == "pdf"){ $content_type = "application/pdf"; }
- if ($ext == "doc") { $content_type = "application/msword"; }
- if ($ext == "docx") { $content_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; }
- if ($ext == "txt") { $content_type = "text/plain"; }
- if ($ext == "pot") { $content_type = "application/mspowerpoint"; }
- if ($ext == "ppt") { $content_type = "application/powerpoint"; }
- if (strstr($ext,"xl")) { $content_type = "application/excel"; }
-
-
-
-
- $fn = urlencode($subject_id . "_" . $course_num . "_SAMPLE_SYLLABUS") .".$ext"; // make it a safe filename.
- $fn = str_replace("+"," ",$fn); // restore spaces from + symbols...
-
- // Give it to the browser!
- header('Content-type: ' . $content_type . '');
- header('Content-Disposition: attachment; filename="' . $fn . '"');
- readfile("$files_path/custom/files/syllabi/" . $filename . "");
- die;
- }
-
-
-
- /**
- * Show the user their select of courses.
- */
- function course_search_display_courses() {
- $rtn = "";
-
- fp_add_css(fp_get_module_path("course_search") . "/css/course_search_style.css");
-
- if (fp_screen_is_mobile()) {
- fp_add_css(fp_get_module_path("course_search") . "/css/course_search_mobile_style.css");
- }
-
-
- $mode = "";
-
-
- // We are going to be setting up a render array for this screen, so other modules can alter it later.
- $render = array();
- $render["#id"] = "course_search_display_courses";
-
- $rtn .= fp_render_curved_line(t("Course Search"));
-
- $settings = fp_get_system_settings();
- $current_catalog_year = $settings["current_catalog_year"];
-
- // catalog_year is always just whatever the current year is.
- $catalog_year = $current_catalog_year;
- $subject_id = $_REQUEST["subject_id"];
-
- $render["#catalog_year"] = array(
- "type" => "do_not_render",
- "value" => $catalog_year,
- );
-
- $render["#subject_id"] = array(
- "type" => "do_not_render",
- "value" => $subject_id,
- );
-
-
-
- $clean_urls = variable_get("clean_urls", FALSE);
-
- // Try to find out the title to this subject, if one exists
- // in our subjects table.
- $res = db_query("SELECT * FROM subjects
- WHERE subject_id ='?' ", $subject_id);
- $cur = db_fetch_array($res);
- $title = $cur["title"];
- if ($title == "") $title = $subject_id;
-
-
- //$rtn .= t("Current catalog year:") . " <b>$catalog_year-" . ($catalog_year +1) . "</b>
- // ";
-
-
- $render["current_cat_year"] = array(
- "value" => t("Current catalog year:") . " <b>$catalog_year-" . ($catalog_year +1) . "</b>",
- );
-
- $important_notice = "
- <div class='tenpt hypo' style='padding: 5px;'>
- <b>Important Notice:</b> <ul style='margin-top: 5px;'>
- <li>Course descriptions are intended for unofficial use only. Consult your catalog for the official listing.</li>
- <li>Anticipated course availability reflects current plans but actual offerings may change because of factors
- unknown at planning time. Consult the schedule of classes for final offerings.</li>
- <li>Sample syllabi are provided for planning purposes only. The syllabus used by an instructor may vary from this sample.</li>
- <li>Please ask your advisor if you have any questions about a course.</li>
- </ul>
- </div>
- ";
-
- if (fp_screen_is_mobile()) {
- // TODO: implement the fieldset thingy.
- //$pC .= $screen->draw_c_fieldset($important_notice, "View important notice", true);
- }
- else {
- //$rtn .= $important_notice;
- $render["important_notice"] = array(
- "value" => $important_notice,
- );
- }
-
- /*
- $rtn .= "
- <!-- <div> -->
-
- <div style='margin: 10px 0 20px 10px; border-bottom: 2px solid black;'>
- <span style='font-size: 14pt; font-weight:bold;'>$title</span>
- " . l("[change]", "tools/course-search", "", array("class" => "nounderline")) . "
- </div>
- ";
- */
- $render["subject_change"] = array(
- "value" => "<div style='margin: 10px 0 20px 10px; border-bottom: 2px solid black;'>
- <span style='font-size: 14pt; font-weight:bold;'>$title</span>
- " . l("[change]", "tools/course-search", "", array("class" => "nounderline")) . "
- </div>",
- );
-
- // Draw the term selector.
- $html = "";
- $only_term = @$_REQUEST["only_term"];
- $html .= "<form id='term_form' action='" . fp_url("tools/course-search/courses") . "' method='GET'>
- <input type='hidden' name='mode' value='$subject_id'>
- <input type='hidden' name='subject_id' value='$subject_id'>
- ";
-
- if (!$clean_urls) {
- // Hack for if clean URLs isn't enabled
- $html .= "<input type='hidden' name='q' value='tools/course-search/courses'>";
- }
-
- $html .= "
- View courses offered:
- <select name='only_term' onChange='document.getElementById(\"term_form\").submit();'>
- <option value=''>Any term</option>
- ";
-
- //$term_array = get_term_id_suffixes();
- $term_array = csv_to_array(variable_get("course_search_avail_term_id_suffix_order"));
-
- $schedule_text = "";
-
- for ($t = $catalog_year; $t <= $catalog_year + 4; $t++)
- {
- $html .= "<option value=''>---------------------</option>";
- foreach($term_array as $x)
- {
- $schedule_text .= "<td class='tenpt' align='center'>";
- $the_term_id = $t . $x;
-
- $temp_course = new Course();
- $temp_course->term_id = $the_term_id;
- $term_desc = $temp_course->get_term_description(false);
-
- $sel = "";
- if ($only_term != "" && $only_term == "$the_term_id") {
- $sel = " selected";
- }
-
- $html .= "<option value='$the_term_id' $sel>$term_desc</option> \n";
- }
-
- }
- $html .= "
- </select>
- </form>";
-
-
- $render["term_selector_form"] = array(
- "value" => $html,
- );
-
-
-
- if ($only_term != "") {
- $temp_course = new Course();
- $temp_course->term_id = $only_term;
- $term_desc = $temp_course->get_term_description(false);
-
- /*
- $rtn .= "<div style='font-weight: bold; padding-bottom: 20px;'>
- The following courses are currently scheduled to be offered during " . $term_desc . ".
- </div>";
- */
-
- $render["term_selected_only_term"] = array(
- "value" => "<div style='font-weight: bold; padding-bottom: 20px;'>
- " . t("The following courses are currently scheduled to be offered during") . $term_desc . "
- </div>",
-
- );
-
- }
-
- $term_structures = get_term_structures();
-
- $grad_notice_flag = false;
- $temp_course = new Course();
- // removed course_num < 500 and
- $result = db_query("SELECT * FROM courses
- WHERE `catalog_year`='?' AND
- `subject_id`='?' AND
- `exclude`='0' ORDER BY `course_num` ", $catalog_year, $subject_id);
- if ($result)
- {
- while ($cur = db_fetch_array($result))
- {
- $n_subject_id = trim($cur["subject_id"]);
- $n_course_num = trim($cur["course_num"]);
- $n_course_id = $cur["course_id"];
- $bool_hide = FALSE;
-
- $title = trim($cur["title"]);
-
- $title = $temp_course->fix_title($title);
-
- $description = trim($cur["description"]);
- if ($description == "")
- {
- $description = t("No description is available at this time. Consult
- the official course catalog for listings.");
- }
-
- $syllabus_text = "";
- $syllabus_array = course_search_get_course_syllabus_details("", "", $n_course_id);
-
- if ($syllabus_array["url"] != "")
- {
- $syllabus_text = "<div class='course-search-sample-syllabus'>
- <a href='{$syllabus_array["url"]}' class='nounderline'>
- <img src='" . fp_theme_location() . "/images/document_icon.gif' border='0' height='12'>
- " . t("Sample Syllabus") . "</a>
-
- </div>
- ";
- }
-
- // Look for all 5 years.
- $long_schedule_array = course_search_get_course_rotation_schedule($n_course_id, $catalog_year, 100, true);
-
- // Only grab next 2 years.
- $schedule_array = course_search_get_course_rotation_schedule($n_course_id, $catalog_year);
-
- $full_schedule_array = course_search_get_course_rotation_schedule($n_course_id);
- $schedule_text = "";
-
- if (count($long_schedule_array) > 0)
- {
- $schedule_text .= "
- <div>
- <b>" . t("Anticipated availability:") . "</b>
- ";
- $s_disp = "auto";
- if ($mode != "advanced")
- { // only show this in the basic mode, not advanced.
- foreach ($schedule_array as $term_id)
- {
- $temp_course = new Course();
- $temp_course->term_id = $term_id;
- $schedule_text .= " " . $temp_course->get_term_description(true) . ",";
- }
- $schedule_text = substr($schedule_text, 0, -1); // take off comma.
- $rnd_div_id = rand(1,999999);
- $schedule_text .= "
- |
- <a href='javascript: toggleHideDiv(\"$rnd_div_id\");' class='nounderline'>
- <span id='SPAN$rnd_div_id'>
- more»
- </span></a> ";
- $s_disp = "none";
- }
-
-
- // Consult our settings to find out what order our terms should be in.
- $term_array = csv_to_array(variable_get("course_search_avail_term_id_suffix_order"));
-
- // Get our table headers
- $avail_headers = variable_get("course_search_avail_term_headers");
- $avail_mobile_headers = variable_get("course_search_avail_term_mobile_headers");
-
-
- $th = explode(",", $avail_headers);
-
- $twidth = "90%";
- $mleft = "20px;";
- if (fp_screen_is_mobile()) {
- $th = explode(",", $avail_mobile_headers);
- $twidth = "100%";
- $mleft = "0";
- }
-
- $schedule_text .= "
- </div>
- <div id='$rnd_div_id' style='display: $s_disp; margin-left: $mleft;'>
- <table border='1' width='$twidth' class='fp-course-search-avail'>
- <tr>
- <td>" . t("Year") . "</td>
- ";
- foreach ($th as $header_text) {
- $schedule_text .= "<td>" . trim($header_text) . "</td>";
- }
- $schedule_text .= " </tr>";
-
- for ($t = $catalog_year; $t <= $catalog_year + 4; $t++)
- {
- $schedule_text .= "<tr>
- <td class='tenpt' align='center'>
- <b>$t</b>
- </td>";
- foreach($term_array as $x)
- {
- $schedule_text .= "<td class='tenpt' align='center'>";
- $the_term_id = $t . $x;
-
- // Does the term suffix ($x) call for the year to be
- // subtracted by 1, or modified at all? This is the case at ULM for fall.
- // Ex: 201340 is Fall of *2012*, not 2013.
- // We can tell this because the term structure (from admin settings)
- //fpm($term_structures);
- if (strtoupper($term_structures[$x]["disp_adjust"]) == "[Y-1]" || strtoupper($term_structures[$x]["disp_adjust"]) == "[Y4-1]") {
- // It is subtracted by one. So the year for "XYZ of 2016" is actually recorded as 2017xyz
- $the_term_id = ($t + 1) . $x;
- }
- if (strtoupper($term_structures[$x]["disp_adjust"]) == "[Y+1]" || strtoupper($term_structures[$x]["disp_adjust"]) == "[Y4+1]") {
- // It is added by one. So the year for "XYZ of 2016" is actually recorded as 2015xyz
- $the_term_id = ($t - 1) . $x;
- }
-
-
-
-
- if (in_array($the_term_id, $full_schedule_array))
- {
- $schedule_text .= "<img src='" . fp_theme_location() . "/images/small_check.gif'>";
- }
- else {
- if ($only_term != "" && $only_term == $the_term_id) {
- // Meaning, the term that the user selected is NOT in this
- // course's schedule. So, we should hide it.
- $bool_hide = TRUE;
- }
- }
- $schedule_text .= " </td>";
-
- }
- $schedule_text .= "</tr>";
- }
-
-
- $schedule_text .= "
- </table>
- </div>
- ";
-
-
-
- }
- else if ($only_term != "") {
- // This is if there are NO schedule offerings, yet the user
- // selected to view a particular term.
- $bool_hide = TRUE;
- }
-
- if (course_search_get_course_rotation_schedule_not_anticipated($n_course_id))
- {
- // This course has no anticipated offerings!
- $schedule_text = "<div><b>" . t("Anticipated availability:") . "</b>
- " . t("There are no anticipated course offerings
- at this time.") . "</div>";
- if ($only_term != "") $bool_hide = TRUE;
- }
-
-
- $min_hours = trim($cur["min_hours"]*1);
- $max_hours = trim($cur["max_hours"]*1);
- if ($min_hours == $max_hours)
- {
- $hours = $min_hours;
- } else {
- $hours = "$min_hours to $max_hours";
- }
-
- $repeat = "";
- if (trim($cur["repeat_hours"]*1) > $min_hours)
- {
- $repeat = "<div class='course-search-repeat'>" . t("May be repeated for up to @repeat hours of credit.", array("@repeat" => $cur["repeat_hours"]*1)) . "</div>";
- if (trim($cur["repeat_hours"]*1) > 20) {
- $repeat = "<div class='course-search-repeat'>" . t("May be repeated for credit.") . "</div>";
- }
- }
-
-
- // Draw it on screen...
- if ($bool_hide != true) {
- /*
- *
- * TODO: This section should really only be if the course is designated as a graduate course or not, not based on course_num.
- *
- if ($grad_notice_flag == false && $course_num > 4999)
- {
- $grad_notice_flag = true;
- $rtn .= "<div style='font-size: 10pt; font-weight: bold;
- border-bottom: 1px solid black;
- margin-left: 10px;
- margin-bottom: 20px;
- margin-top: 50px;'>
- " . t("The following courses are for Graduate Students only.") . "
- </div>";
- }
- * */
-
- $details = $schedule_text . $syllabus_text;
-
- $hyp1 = " - ";
- $on_click = "";
- if (fp_screen_is_mobile()) {
- $on_click = "onClick='toggleCourseExtra(this);'";
- $hyp1 = "";
- }
-
- $html = "";
-
- // Note, the HTML comments are so other modules, that wish to manipulate this block, have something easy to find/replace
-
- $html .= "<div class='course-search-course-block'>
- <!-- TITLE-ROW -->
- <div class='course-search-course-title-row'
- $on_click>
- <!-- COURSE-NAME -->
- <span class='course-search-course-name'>$n_subject_id $n_course_num</span>
- $hyp1
- <!-- END-COURSE-NAME ->
- <!-- COURSE-TITLE -->
- <span class='course-search-course-title'>$title</span> - $hours " . t("hrs.") . "$repeat
- <!-- END-COURSE-TITLE -->
- </div>
- <!-- END-TITLE-ROW -->
- <!-- COURSE-EXTRA -->
- <div class='course-search-course-extra'>
- <!-- DESC -->
- <div class='course-search-course-description'>$description</div>
- <!-- END-DESC -->
- <!-- DETAILS -->
- <div class='course-search-course-details'>$details</div>
- <!-- END-DETAILS -->
- ";
-
-
- if (user_has_permission("can_update_course_info_details") && !fp_screen_is_mobile()) {
- $html .= "<!-- ADMIN-OPTIONS -->
- <div class='course-search-admin-options'>
- " . t("Administrative options:") . "
- " . l(t("Edit syllabus and rotation schedule"), "tools/course-search/edit-info-details", "course_id=$n_course_id&subject_id=$n_subject_id&course_num=$n_course_num") . "
- </div>
- <!-- END-ADMIN-OPTIONS -->";
- }
-
- $html .= "</div>
- <!-- END-COURSE-EXTRA -->"; // div course-search-course-extra
-
- $html .= "</div>"; // div course-search-course-block
-
- $render["course_search_course_block__$n_course_id"] = array(
- "value" => $html,
- );
-
-
- }
-
- }
- }
-
-
- watchdog("course_search", "User viewed courses in subject: @subject", array("@subject" => $subject_id), WATCHDOG_DEBUG);
-
-
- //$pC .= $screen->get_java_script_code();
- $html = '
- <script type="text/javascript">
- function toggleHideDiv(rndDivID)
- {
- var d = document.getElementById(rndDivID);
- if (d.style.display == "none")
- {
- d.style.display = "";
- document.getElementById("SPAN" + rndDivID).innerHTML = "«less";
- } else {
- d.style.display = "none";
- document.getElementById("SPAN" + rndDivID).innerHTML = "more»";
- }
-
- }
-
- function toggleCourseExtra(e) {
- $(e).siblings(".course-search-course-extra").slideToggle("medium");
- }
-
- </script>
-
- ';
-
-
- $render["extra_javascript"] = array(
- "value" => $html,
- );
-
- $rtn .= fp_render_content($render);
-
- return $rtn;
- }
-
-
-
- function course_search_get_course_rotation_schedule_not_anticipated($course_id)
- {
-
- // Returns TRUE if not is NOT ANTICIPATED. False, if this
- // is a normal courses which has an offering, or a blank
- // offering. This will
- // only return true if NOTA is set as a term for this course.
- $res = db_query("SELECT * FROM course_rotation_schedule
- WHERE course_id = '?'
- AND term_id = 'NOTA'
- ", $course_id);
- if (db_num_rows($res) > 0) {
- return true;
- }
-
- return false;
-
- }
-
- function course_search_get_course_rotation_schedule($course_id, $year = "", $limit = 20, $bool_include_next_five_years = false)
- {
- // return an array containing the terms that this course
- // is going to be offered, if any.
- $rtn_array = array();
- $arr = array();
- $year_line = "";
- if ($year != "")
- { // if a year is entered, we will get the next few years, and the previous
- // one for good measure.
- $year_line = "and (`term_id` LIKE '$year%' or `term_id` LIKE '" . ($year+1) . "%') ";
- if ($bool_include_next_five_years)
- {
- $yearm1 = $year - 1;
- $year2 = $year + 1;
- $year3 = $year + 2;
- $year4 = $year + 3;
- $year5 = $year + 4;
- $year6 = $year + 5;
-
- $year_line = "and (`term_id` LIKE '$year%'
- or `term_id` LIKE '$yearm1%'
- or `term_id` LIKE '$year2%'
- or `term_id` LIKE '$year3%'
- or `term_id` LIKE '$year4%'
- or `term_id` LIKE '$year5%'
- or `term_id` LIKE '$year6%'
- ) ";
- }
-
- }
-
-
- $res = db_query("SELECT * FROM course_rotation_schedule
- WHERE `course_id`= ?
- $year_line
- ORDER BY term_id DESC
- LIMIT $limit", $course_id);
- while($cur = db_fetch_array($res))
- {
- $t = $cur["term_id"];
- // Get the term from the end.
- $ss = trim(substr($t,4,1));
- if ($ss == "m"){$ss = "1.5";}
-
- if (is_numeric($ss)) {
- $ss = $ss * 10;
- }
-
- $year = trim(substr($t,0,4));
-
- // We do all this so we can establish an order to the terms
- // by using a sort() command later.
- $arr[] = $year . "~" . $ss . "~" . $t;
- }
-
- sort($arr);
- // Now we want to get out JUST the terms...
- foreach($arr as $line)
- {
- $temp = explode("~",$line);
- $rtn_array[] = trim($temp[2]);
- }
-
- return $rtn_array;
- }
-
-
-
- function course_search_get_course_syllabus_details($subject_id = "", $course_num = "", $course_id = -1)
- {
-
- // This will return an array containing information
- // about a course's syllabus, if it exists.
- $rtn_array = FALSE;
-
- // Does this course have a syllabus?
- $query = "SELECT * FROM course_syllabi
- WHERE `course_perm_id`='$subject_id" . "_$course_num'";
- if ($course_id != -1) {
- $query = "SELECT * FROM course_syllabi
- WHERE `course_id`='$course_id' ";
- }
-
- $res = db_query($query);
- $cur = db_fetch_array($res);
-
- //$url = $GLOBALS["fp_system_settings"]["selfURL"] . "/" . get_module_path("course_search") . "/syllabus.php?id=" . $cur["course_id"];
-
- if ($cur["filename"] != "") {
- $rtn_array = array();
- $rtn_array["url"] = $GLOBALS["fp_system_settings"]["base_url"] . "/" . fp_url("course-search/get-syllabus", "id=" . $cur["course_id"], FALSE);
- $rtn_array["filename"] = $cur["filename"];
- $rtn_array["posted"] = $cur["posted"];
- }
-
-
- return $rtn_array;
-
- }
-
-
-
-
- /**
- * Displays the search pulldown for the user to use to find courses.
- */
- function course_search_display_search() {
-
- $rtn = "";
- $mode = "";
-
- fp_add_css(fp_get_module_path("course_search") . "/css/course_search_style.css");
-
- if (fp_screen_is_mobile()) {
- fp_add_css(fp_get_module_path("course_search") . "/css/course_search_mobile_style.css");
- }
-
-
- $rtn .= "";
-
- if (user_has_permission("can_update_course_info_details")) {
- $rtn .= "<div>" . t("Administrators:") . " " . l(t("Edit course schedules and syllabi"), "tools/course-search/edit-list") . "</div>";
- }
-
- $rtn .= fp_render_curved_line("Course Search");
-
-
- $settings = fp_get_system_settings();
- $current_catalog_year = $settings["current_catalog_year"];
- // catalog_year is always just whatever the current year is.
- $catalog_year = $current_catalog_year;
-
- $clean_urls = variable_get("clean_urls", FALSE); // are clean URLs enabled?
-
- if ($catalog_year == "")
- {
-
- $rtn .= "Please select an available catalog year from the
- list below.<br><br>
- <form action='" . fp_url("tools/course-search") . "' method='GET' name='mainform' id='myform'>
- <table align='center'>
- <td width='150' valign='bottom'>
- <select name='catalog_year'>";
- for ($t = $current_catalog_year; $t >= $GLOBALS["fp_system_settings"]["earliest_catalog_year"]; $t--)
- {
- $rtn .= "<option value='$t'>$t - " . ($t+1) . "</option> \n";
-
- }
- $rtn .= "</select>
- </td>
- <td valign='bottom'>
- <input type='submit' value='Select ->'>
- </td>
- </table>";
-
- if (!$clean_urls) {
- // Hack for if clean URLs isn't enabled
- $rtn .= "<input type='hidden' name='q' value='tools/course-search'>";
- }
-
- $rtn .= " </form>";
-
- }
- else {
- // Catalog year has been selected.
-
- $rtn .= "Current catalog year: <b>$catalog_year-" . ($catalog_year +1) . "</b>
-
- <br><br>
- Please select an available subject from the list below.<br>
- <br>
- <form action='" . fp_url("tools/course-search/courses") . "' method='GET' name='mainform' id='myform'>";
-
- if (!$clean_urls) {
- // Hack for if clean URLs isn't enabled
- $rtn .= "<input type='hidden' name='q' value='tools/course-search/courses'>";
- }
-
- if (!fp_screen_is_mobile()) {
- $rtn .= "
- <div align='center'>
- <select name='subject_id' style='width: 80%;'>
- ";
- }
-
-
- // We want to make a pull-down list of all available subjects.
- // Keep in mind with this join-- we may have courses who have
- // a subject_id, for which we don't have that subject in the subjects
- // table.
-
-
- $query = "SELECT DISTINCT b.subject_id, a.title FROM courses b LEFT JOIN subjects a
- ON (a.subject_id = b.subject_id)
- WHERE exclude = 0
- AND catalog_year = '?'
- ";
-
- $subjects = array();
- $result = db_query($query, $catalog_year);
- while ($cur = db_fetch_array($result))
- {
- //fpm($cur);
- $title = trim($cur["title"]);
- $subject_id = trim($cur["subject_id"]);
-
- if ($title == "") {
- $title = $subject_id;
- }
-
- $subjects[$subject_id] = $title;
- }
-
- asort($subjects);
-
- foreach ($subjects as $subject_id => $title) {
- if (!fp_screen_is_mobile()) {
- $rtn .= "<option value='$subject_id'>$title ($subject_id)</option>";
- }
- else {
- $rtn .= "<a class='course-search-subject-select-line'
- href='" . fp_url("tools/course-search/courses", "subject_id=$subject_id") . "'>
- <div class='course-search-dept-name'>$title ($subject_id)</div>
- </a>";
- }
-
-
- }
-
- if (!fp_screen_is_mobile()) {
- $rtn .= "
- </select>
- <input type='hidden' name='mode' value='$mode'>
- </div><br><br><br>
- <div align='right'>
- <input type='submit' value='Select ->'>
- </div>";
- }
-
- $rtn .= "</form>";
-
- }
-
-
- return $rtn;
- }
-
-
Functions
Name | Description |
---|---|
course_search_display_courses | Show the user their select of courses. |
course_search_display_search | Displays the search pulldown for the user to use to find courses. |
course_search_download_syllabus | This function will actually deliver a syllabus to the user's browser for download. |
course_search_get_course_rotation_schedule | |
course_search_get_course_rotation_schedule_not_anticipated | |
course_search_get_course_syllabus_details | |
course_search_menu | |
course_search_perm | |
course_search_settings_form | The system settins form for course_search settings. |