admin_edit_course_form

4.x admin.courses.inc admin_edit_course_form()

This form lets the user edit details about a course.

File

modules/admin/admin.courses.inc, line 197

Code

function admin_edit_course_form() {
  $form = array();

  $de_catalog_year = admin_get_de_catalog_year();
  $course_id = $_REQUEST["course_id"];
  $subject_id = $_REQUEST["subject_id"];
  $subject_id = str_replace("_A_", "&", $subject_id);
  $course_num = $_REQUEST["course_num"];

  fp_set_title(t("Edit Course @course", array("@course" => "$subject_id $course_num ($de_catalog_year)")));
  fp_add_css(fp_get_module_path("admin") . "/css/admin.css");
  fp_add_js(fp_get_module_path("admin") . "/js/admin.js");

  $form["de_catalog_year"] = array(
    "type" => "hidden",
    "value" => $de_catalog_year,
  );

  $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["perform_action2"] = array(
    "type" => "hidden",
    "value" => "",
  );

  // Begin the form...

  // TODO:  implement this!
  if ($_SESSION["de_advanced_mode"] == true) {
    $pC .= " <span class='tenpt' style='background-color: yellow; margin-left: 20px;'>
          adv: course_id = $course_id. Used by:
          <a href='javascript: popupWindow(\"admin.php?performAction=popup_degrees_using_course&course_id=$course_id\")'>[degrees]</a>
          <a href='javascript: popupWindow(\"admin.php?performAction=popup_groups_using_course&course_id=$course_id\")'>[groups]</a>
          <a href='javascript: popupWindow(\"admin.php?performAction=popup_students_using_course&course_id=$course_id\")'>[students]</a>
          </span>";
  }

  $course = new Course($course_id, false, null, false, $de_catalog_year, true);
  $course->catalog_year = $de_catalog_year; // Since it may be 1900, force it!
  $course->load_descriptive_data(false, true, false, true, true);

  $course->catalog_year = $de_catalog_year; // Since it may be 1900, force it!
  $all_names = $course->get_all_names(true);
  $warn_eqv = "";
  if (strstr($all_names, ",")) {
    $warn_eqv = "yes";
  }

  // Correct ghosthours, if they exist.
  if ($course->bool_ghost_hour) {
    $course->max_hours = 0;
  }
  if ($course->bool_ghost_min_hour) {
    $course->min_hours = 0;
  }

  $form["course_names"] = array(
    "type" => "textfield",
    "label" => t("Course names(s):"),
    "required" => TRUE,
    "value" => $all_names,
    "popup_description" => t("These are the possible display names for this course. Typically,
                              there will be only one name. Ex: ACCT 110. You must place a space
                              between the subject ID and course number.
                              
                              If this course is known by another name (has an eqv course)
                              then enter it as well using a comma.
                              Ex: ACCT 110, MATH 110A
                              
                              Add the word 'exclude' to prevent it from showing in course
                              selection windows in FlightPath.
                              Ex: ACCT 110, MATH 110A exclude
                              
                              IMPORTANT: Course names are updated for ALL YEARS of a course."),
  );

  $form["title"] = array(
    "type" => "textfield",
    "label" => t("Title:"),
    "value" => $course->title,
    "popup_description" => t("The title of the course displayed in FlightPath."),
  );

  $form["min_hours"] = array(
    "type" => "textfield",
    "label" => t("Min hours:"),
    "size" => 10,
    "value" => $course->min_hours,
    "popup_description" => t("The min and max hours for a course will usually be the same
                              number. Ex: 3.  If they differ, it means the course has
                              variable hours.  
                              
                              For example, if you have a course
                              worth 1-6 hours, enter 1 for min, and 6 for max."),
  );


  $form["max_hours"] = array(
    "type" => "textfield",
    "label" => t("Max hours:"),
    "size" => 10,
    "value" => $course->max_hours,
    "popup_description" => t("The min and max hours for a course will usually be the same
                              number. Ex: 3.  If they differ, it means the course has
                              variable hours.  
                              
                              For example, if you have a course
                              worth 1-6 hours, enter 1 for min, and 6 for max."),
  );

  $form["repeat_hours"] = array(
    "type" => "textfield",
    "label" => t("Repeat hours:"),
    "size" => 10,
    "value" => $course->repeat_hours,
    "popup_description" => t("This is the number of hours a course may be repeated for credit.
                              For example, if a course is worth 3 hours, but may be repeated
                              for up to 9 hours of credit, enter a 9 in this box.
                              
                              If a course CANNOT be repeated for credit, this would
                              be the same number as the min and max, or simply blank.
                              
                              If you are unsure what to enter, leave it blank."),
  );


  $form["description"] = array(
    "type" => "textarea",
    "label" => t("Description"),
    "value" => $course->description,
    "rows" => 4,
    "cols" => 80,
  );

  $form["all_years"] = array(
    "type" => "checkboxes",
    "label" => t("Update for all years?"),
    "options" => array("yes" => t("Update title, description, and hour info for all years of this course.")),
    "popup_description" => t("Check this box and press Submit to update title, description, and hour information
                              for all available years of this course.  Note that course name is automatically
                              updated for all years, regardless if you check this box or not."),
  );


  $form["data_entry_comment"] = array(
    "type" => "textarea",
    "label" => t("Optional Comment: (only seen by other FlightPath administrators)"),
    "rows" => 3,
    "cols" => 80,
    "value" => $course->data_entry_comment,
  );



  $form["submit"] = array(
    "type" => "submit",
    "value" => t("Save for @year", array("@year" => $de_catalog_year)),
    "prefix" => "<hr>",
  );

  $form["mark" . $m++] = array(
    "type" => "markup",
    "value" => "<div align='right'>
                      " . t("Delete this course?") . " <input type='button' value='X'
                      onClick='adminDeleteCourse(\"$course_id\",\"$de_catalog_year\",\"$warn_eqv\");'>
                    </div>",
  );


  return $form;
}