function course_search_edit_course_details_form
Search API
6.x course_search.edit.inc | course_search_edit_course_details_form() |
4.x course_search.edit.inc | course_search_edit_course_details_form() |
5.x course_search.edit.inc | course_search_edit_course_details_form() |
This form lets the user edit the course's syllabus or rotation schedule
File
- modules/
course_search/ course_search.edit.inc, line 14 - This file contains functions relating to editing the course info, like rotation schedule and syllabus
Code
function course_search_edit_course_details_form() {
$form = array();
fp_add_css(fp_get_module_path("course_search") . "/css/course_search_style.css");
$weight = 0;
$course_id = $_REQUEST ["course_id"];
$subject_id = $_REQUEST ["subject_id"];
$course_num = $_REQUEST ["course_num"];
$db = get_global_database_handler();
$school_id = $db->get_school_id_for_course_id($course_id);
$catalog_year = variable_get_for_school("current_catalog_year", 2006, $school_id);
$course = new Course($course_id, false, null, false, $catalog_year);
$course->load_descriptive_data(false, true, false, true);
$school_code = "School #" . $school_id;
if (module_enabled("schools")) {
$school_code = schools_get_school_code_for_id($school_id);
fp_set_title(t("Edit Course Info for @course - School @school", array("@course" => "$subject_id $course_num", "@school" => $school_code)));
}
else {
fp_set_title(t("Edit Course Info for @course", array("@course" => "$subject_id $course_num")));
}
$form ["#attributes"] = array("enctype" => "multipart/form-data");
$form ["course_id"] = array(
"type" => "hidden",
"value" => $course_id,
);
$form ["subject_id"] = array(
"type" => "hidden",
"value" => $subject_id,
);
$form ["course_num"] = array(
"type" => "hidden",
"value" => $course_num,
);
$form ["school_id"] = array(
"type" => "hidden",
"value" => $school_id,
);
$course->catalog_year = $catalog_year;
// Find out filename/link of current syllabus.
$filelink = "- None currently entered -";
$filename = "";
if ($syllabus_details = course_search_get_course_syllabus_details($course_id)) {
$filename = $syllabus_details ["filename"];
}
$bool_delete_cb = FALSE;
if ($filename != "") {
$filelink = $filename;
$bool_delete_cb = TRUE;
}
$form ["mark_course_title_and_description"] = array(
"value" => "<strong>$course->title (" . $course->get_catalog_hours() . " " . t("hrs.") . ")</strong>
<div>$course->description</div>
",
'weight' => $weight++,
);
$form ["syllabus"] = array(
"type" => "file",
"label" => t("Submit new sample course syllabus:"),
"prefix" => "<hr>" . t("Current sample syllabus:") . " " . $filelink,
"description" => t("Note: selecting a new file will replace any existing
syllabus. Remember to click Submit after selecting a file."),
'weight' => $weight++,
);
if ($bool_delete_cb) {
$form ["del_syllabus"] = array(
"type" => "checkboxes",
"options" => array("yes" => t("Delete the existing syllabus?")),
'weight' => $weight++,
);
}
if ($filename != "") {
$s_url = $syllabus_details ["url"];
$form ["mark_syl_download_info"] = array(
"value" => "<p>" . t("Syllabus may be downloaded using this address: ") . "<a href='$s_url'>$s_url</a></p>",
'weight' => $weight++,
);
}
$form ["mark_rotation_and_capacity"] = array(
"value" => "<b>" . t("Course Rotation Schedule & Seat Capacity:") . "</b>
<br>" . t("Select semesters/terms in which this Course
will be offered for the next five years, as well as how many seats are expected. Seat capacity will only be saved for courses
which are checked as being offered."),
'weight' => $weight++,
);
$term_array = csv_to_array(variable_get_for_school("course_search_avail_term_id_suffix_order", '', $school_id));
$form ["mark_cb_wrapper"] = array(
"value" => "<div class='rotation-form-checkboxes'>",
'weight' => $weight++,
);
$term_structures = get_term_structures($school_id);
$y = 1;
for ($t = $catalog_year; $t <= $catalog_year + 5; $t++) {
$form ["year$y"] = array(
"type" => "hidden",
"value" => $t,
);
foreach ($term_array as $x) {
$check_year = $t;
$term_id = $check_year . $x;
// Should we make any adjustments based on the term_structure?
// Does the term suffix ($x) call for the year to be
// subtracted by 1? 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)
if (@strtoupper($term_structures [$x]["disp_adjust"]) == "[Y-1]") {
$term_id = ($check_year + 1) . $x;
}
$cb_disp_name = get_term_description($term_id, TRUE, $school_id);
$cbname = $term_id;
$cb_default_val = array();
$capacity_default_val = "";
// See if this box should be checked...
$res = db_query("select * from course_rotation_schedule
where `course_id`='?'
and `term_id`='$term_id' ", $course_id);
if (db_num_rows($res) > 0) {
$cb_default_val = array("yes" => "yes");
$cur = db_fetch_array($res);
if (intval($cur ['capacity']) > 0) {
$capacity_default_val = intval($cur ['capacity']);
}
}
$form ['mark_start_' . $cbname] = array(
'value' => "<div class='course-search-edit-term-wrapper'>",
'weight' => $weight++,
);
$form ["cb_$cbname"] = array(
"type" => "checkboxes",
"options" => array("yes" => $cb_disp_name),
"value" => $cb_default_val,
'weight' => $weight++,
);
$form ["capacity_$cbname"] = array(
"type" => "textfield",
"attributes" => array("placeholder" => t("# Seats"), "class" => "capacity-textfield"),
"value" => $capacity_default_val,
'weight' => $weight++,
);
$form ['mark_end_' . $cbname] = array(
'value' => "</div>",
'weight' => $weight++,
);
} // foreach term_array
$form ["mark_horizontal_line"] = array(
"value" => "<hr style='border:1px dashed #ccc;'><br>",
'weight' => $weight++,
);
$y++;
}
$form ["mark_close_cb_wrapper"] = array(
"value" => "</div>",
'weight' => $weight++,
);
// Not anticipated check.
$default_val = array();
$res = db_query("SELECT * FROM course_rotation_schedule
WHERE `course_id`='?'
AND `term_id`='NOTA' ", $course_id);
//debug_c_t("$t$x");
if (db_num_rows($res) > 0)
{
$default_val = array("yes" => "yes");
}
$form ["not_anticipated"] = array(
"type" => "checkboxes",
"label" => t("Not Anticipated:"),
"options" => array("yes" => t("This course is not anticipated.")),
"value" => $default_val,
"description" => t("Checking this box means that the course is not
anticipated to be offered within the time range above.
This will override any selections made above."),
'weight' => $weight++,
);
$form ["submit"] = array(
"type" => "submit",
"value" => t("Submit"),
"prefix" => "<hr>",
'weight' => $weight++,
);
return $form;
}