function admin_edit_degree_form
Search API
7.x admin.degrees.inc | admin_edit_degree_form($degree_id, $de_catalog_year) |
6.x admin.degrees.inc | admin_edit_degree_form( |
5.x admin.degrees.inc | admin_edit_degree_form($major_code, $de_catalog_year) |
Meant to replace the old-fashioned display_edit_degree function...
File
- modules/
admin/ admin.degrees.inc, line 1346
Code
function admin_edit_degree_form($major_code, $de_catalog_year) {
$form = array();
fp_set_title(t("Edit Degree") . " $major_code - $de_catalog_year");
// Add in our CSS and JS
fp_add_js(fp_get_module_path("admin") . "/js/admin.js");
fp_add_css(fp_get_module_path("admin") . "/css/admin.css");
$button_msg = trim(addslashes(@$_REQUEST ["button_msg"]));
$db = get_global_database_handler();
$degree_id = intval($db->get_degree_id($major_code, $de_catalog_year, true));
// The intval says, if it's false, make it = 0. otherwise keep the number
// that is returned.
$degree = new DegreePlan($degree_id, null, false, false, true);
$degree->load_descriptive_data();
if (user_has_permission("can_view_advanced")) {
$form ["markup_adv"] = array(
"value" => "<span class='tenpt deg-advanced-msg' style='background-color: yellow; margin-left: 20px;'>
Advanced: degree_id = $degree_id. catalog_year: $de_catalog_year
</span>",
);
}
$form ["degree_id"] = array(
"type" => "hidden",
"value" => $degree_id,
);
$form ["major_code"] = array(
"type" => "hidden",
"value" => $major_code,
);
$form ["de_catalog_year"] = array(
"type" => "hidden",
"value" => $de_catalog_year,
);
$form ["scroll_top"] = array(
"type" => "hidden",
"value" => '',
);
$form ["perform_action2"] = array(
"type" => "hidden",
"value" => '',
);
$form ["markup_degree_header"] = array(
"value" => "<h3>$degree->degree_type $degree->title<br>$major_code ($de_catalog_year)</h3>",
"weight" => 1010,
);
//////////////////////////////////////////////////////
// Top part of degree entry....
$form ["degree_type"] = array(
"type" => "textfield",
"label" => t("Degree Type:"),
"size" => 3,
"value" => $degree->degree_type,
"popup_description" => t("For example: BS, BA, Ph.D, etc."),
"weight" => 1020,
);
// Display degree_class pulldown.
$options = array();
$degree_classes = fp_get_degree_classifications();
foreach ($degree_classes ["levels"] as $level => $details) {
foreach ($degree_classes ["levels"][$level] as $machine_name => $title) {
//$rtn .= "<option value='$machine_name' $sel>$level - $title</option>";
$options [$machine_name] = "$level - $title";
}
}
$form ["degree_class"] = array(
"type" => "select",
"label" => t("Classification:"),
"options" => $options,
"value" => $degree->degree_class,
"hide_please_select" => TRUE,
"popup_description" => t("Select which classification this degree plan is listed under. The number beside the title is the 'level' of the degree classification.
1 - Degrees which a student may graduate in. Ex: Majors.
2 - Degree plans which are secondary to top level degree plans. Ex: Minors.
3 - Degree plans which are only selectable as add-ons to an existing degree plan. Ex: Concentrations.
You may edit these classifications in the Configure School Data form, from the Admin Console."),
"weight" => 1030,
);
$form ["degree_level"] = array(
"type" => "select",
"label" => t("Level:"),
"size" => 1,
"options" => array('UG' => 'UG - Under Grad', 'GR' => 'GR - Grad'),
"value" => $degree->degree_level,
"hide_please_select" => TRUE,
"popup_description" => t("Select the degree level code in this box. By default, it is assumed to be an \"Undergraduate\" (UG) degree.
Select \"GR\" for a degree which should only be accessible to Graduate students in What If mode.
"),
"weight" => 1040,
);
$form ["advising_weight"] = array(
"type" => "textfield",
"label" => t("Advising Weight:"),
"size" => 1,
"value" => $degree->db_advising_weight,
"popup_description" => t("If this degree is ever combined with another degree, this value, the advising weight, determines
the order in which the degrees will be displayed on the View tab and in What If mode.
The default is zero (0). To place this degree above normal degrees, set it to a negative value (ex: -1, -10, etc.).
Set it higher to place it below normal degrees. (Ex: 10, 20, 30, etc).
To prevent confusion, it's recommended that a degree's tracks have the same advising weight as the main degree.
If you are unsure what to enter, leave it set to 0 (zero)."),
"weight" => 1050,
);
$form ["title"] = array(
"type" => "textfield",
"label" => t("Title:"),
"size" => 80,
"maxlength" => 100,
"value" => $degree->title,
"popup_description" => t("This is the full title of the degree. Ex: Computer Science, Accounting, etc."),
"weight" => 1060,
);
$form ["exclude"] = array(
"type" => "textfield",
"label" => t("Exclude:"),
"size" => 1,
"value" => intval($degree->db_exclude),
"popup_description" => t("If the Exclude value is set to 1 (the number one), then this degree will show up in gray on the list of degrees. It will also not be selectable in What If mode in FlightPath.
If you are not sure what to enter, either leave it blank or enter a 0 (zero)."),
"weight" => 1070,
);
$form ["allow_dynamic"] = array(
"type" => "textfield",
"label" => t("Allow Dynamic:"),
"size" => 1,
"value" => intval($degree->db_allow_dynamic),
"popup_description" => t("If this value is set to 1 (the number one), then this degree plan is able to be combined with other degrees which are also set to Allow Dynamic.
If you are unsure what to enter, either leave blank or enter a 0 (the number zero)."),
"weight" => 1080,
);
$form ["override_degree_hours"] = array(
"type" => "textfield",
"label" => t("Override Degree Hours:"),
"size" => 1,
"value" => $degree->db_override_degree_hours,
"popup_description" => t("You may specify a number of degree hours here (ex: 125). FlightPath will use this value, instead of calculating the number of hours
required for this degree. If you are unsure what to put here, leave it blank, or enter zero, for FlightPath to calculate hours normally."),
"weight" => 1090,
);
$form ['below_degree_details_markup'] = array(
'value' => "<div style='clear: both;'></div>",
"weight" => 1110,
);
// Is this a "track"?
if (strstr($major_code, "_"))
{
$form ['track_info_markup'] = array(
'value' => "<h3>" . t("Track (Level-3) Information") . "</h3>",
"weight" => 1120,
);
$form ['track_title'] = array(
'type' => 'textfield',
'label' => t("Track (Level-3) Title:") . " ",
'size' => 60,
'maxlength' => 100,
'value' => $degree->track_title,
"weight" => 1130,
);
$form ['track_description'] = array(
'type' => 'textarea',
'label' => t("Track (Level-3) Description:"),
'rows' => 4,
'cols' => 60,
'value' => $degree->track_description,
'description' => t("You may enter simple HTML in this field. Ex: <b>bold</b> or <i>italics</i>"),
'popup_description' => t("This is where you can enter a short description of this Level-3 degree track (also called a Degree Option) which will display for the user in a pop-up when they select to change degree options.
\nTo enter a default message, which will display at the top of the selection window, begin the description with:\n DEFAULT: \nIt must be in all caps, and you must have the colon (:) after it.
By doing this in ANY of the track descriptions for a major, FP will ignore all other track descriptions and ONLY display the default.
\n\nExample of usage: DEFAULT: You may select any of these degree options."),
"weight" => 1140,
);
}
///////////////////////////////////////
///////////////////////////////////////
// Semester Blocks //
//////////////////////////////////////
///////////////////////////////////////
$groups_counter = 0; // used to create unique variables for groups
$js_existing_semesters = array();
$form ['blocks_top_markup'] = array(
'value' => "<div style='clear: both;'></div>
<hr>
<div class='add-new-sem-block' style='float: right; margin-top: 5px;'>" . fp_render_button(t("Add New Semester Block"), "adminAddNewSemesterBlock();") . "</div>
<h2>Semester Blocks</h2>
",
"weight" => 2010,
);
$base_weight = 30000;
$first_semester_num = -999;
$degree->list_semesters->reset_counter();
while ($degree->list_semesters->has_more()) {
$semester = $degree->list_semesters->get_next();
if ($semester->semester_num < 0) {
continue;
}
$js_existing_semesters ["semester_" . $semester->semester_num] = $semester->semester_num;
// Record what is the first semester num we have...
if ($first_semester_num == -999) {
$first_semester_num = $semester->semester_num;
}
$sem_default_title = admin_get_semester_name($semester->semester_num);
if ($semester->title == $sem_default_title) {
$semester->title = "";
}
$form ["semester_{$semester->semester_num}_very_top_markup"] = array(
"value" => "",
"weight" => $base_weight + ($semester->semester_num * 100) + 10,
);
$form ['semester_title_' . $semester->semester_num] = array(
'type' => 'textfield',
'prefix' => "<div style='padding-bottom: 3px; margin-top:20px;'><b>Block number: " . ($semester->semester_num + 1) . "</b>
<a href='javascript:adminDeleteSemesterBlock($semester->semester_num);'>Delete?</a>
Default Title: <em>$sem_default_title</em></div>",
'label' => 'Override Title:',
'value' => $semester->title,
'size' => 20,
'popup_description' => t("You may override the default title for a block. For example, if instead of Freshman Year you want it to read Pre-Pharmacy Year 1 in FlightPath,
then you would enter that in this box and hit save.
To change a title back to the default, just leave it blank."),
"weight" => $base_weight + ($semester->semester_num * 100) + 20,
);
// Show the courses for this semester...
$contents = "";
$semester->list_courses->sort_alphabetical_order();
$semester->list_courses->reset_counter();
while ($semester->list_courses->has_more()) {
$course = $semester->list_courses->get_next();
$course->load_descriptive_data();
$contents .= "$course->subject_id $course->course_num $course->requirement_type";
if ($course->min_grade != "D" && $course->min_grade != "") {
$contents .= " ($course->min_grade)";
}
$contents .= "\n";
}
$form ["semester_{$semester->semester_num}_top_table_markup"] = array(
"value" => "<div class='edit-degree-semester-block'>
<table border='1' width='100%' class='edit-degree-semester-block-table'>",
"weight" => $base_weight + ($semester->semester_num * 100) + 30,
);
$form ['courses_' . $semester->semester_num] = array(
'type' => 'textarea',
'prefix' => "<td valign='top' width='30%'>",
'label' => 'Courses: ',
'value' => $contents,
'rows' => 10,
'cols' => 20,
'popup_description' => t("Enter course requirements in this format: \n SUBJECT COURSENUM type (MINGRADE)\n\n
type - lowercase character denoting the requirement type of the course. Make sure you have a space between it and the course number. If no type is specified, it is understood to be a major requirement.\n
min grade - Place the min grade (if there is one) in parenthesis after the type. Make sure there is a space between the min grade and the type (or course number, if there is no type specified).\n Example: ACCT 110 s (C)\n\n
Repeats require no special characters or symbols. Simply enter the course again."),
'suffix' => "</td>",
"weight" => $base_weight + ($semester->semester_num * 100) + 40,
);
// Show the groups (and option for adding groups) for this semester...
$contents = "";
$contents .= "
<table width='100%' border='0' cellspacing='5' class='edit-degree-semester-groups-table'>
<tr>
<th valign='top' class='tenpt' width='1'> </td>
<th valign='top' class='tenpt'>" . t("Group") . "</td>
<th valign='top' class='tenpt' width='5'>" . t("Hrs") . "</td>
<th valign='top' class='tenpt' width='5'>" . t("Grd") . "</td>
<th valign='top' class='tenpt' width='5'>" . t("Type") . "</td>
</tr>
";
$semester->list_groups->sort_alphabetical_order();
$semester->list_groups->reset_counter();
while ($semester->list_groups->has_more()) {
$group = $semester->list_groups->get_next();
$group->load_descriptive_data();
$ghours = $group->hours_required;
// If min hours are specified, set to MIN-MAX.
if ($group->has_min_hours_allowed()) {
$ghours = $group->min_hours_allowed . "-" . $ghours;
}
$contents .= "<tr>
<td valign='middle'>
<a href='javascript: adminDelGroup(\"" . $group->get_db_group_id() . "\",\"$semester->semester_num\");'><img src='" . fp_theme_location() . "/images/delete.png' border='0'></a>
</td>
<td valign='top' class='tenpt'>
$group->title<br><i>$group->group_name</i>
</td>
<td valign='top' class='tenpt'>$ghours</td>
<td valign='top' class='tenpt'>$group->min_grade</td>
<td valign='top' class='tenpt'>$group->requirement_type
</td>
</tr>";
// Let's also add a hidden form element here, for the existing group.
$groups_counter++;
$form ['group_' . $group->get_db_group_id() . '_' . $groups_counter] = array(
'type' => 'hidden',
'value' => $group->get_db_group_id() . "_" . $semester->semester_num . "_" . $ghours . "_" . $group->requirement_type . "_" . $group->min_grade,
);
} // while semester->list_groups
$url = fp_url("admin/degrees/popup-add-group2", "semester_num=$semester->semester_num&de_catalog_year=$de_catalog_year");
$contents .= "</table>
<div style='margin-top: 10px; margin-left: 20px; font-size:0.8em;'>
<a href='javascript: adminPopupWindow(\"$url\");'>" . t("Add an elective group") . "</a>
</div>";
// Display our contents in a markup element for this semester
$form ["semester_groups_" . $semester->semester_num . "_markup"] = array(
'prefix' => "<td valign='top'>",
'label' => t("Groups:"),
'value' => $contents,
"weight" => $base_weight + ($semester->semester_num * 100) + 50,
);
$form ["semester_{$semester->semester_num}_table_bottom_markup"] = array(
"value" => "</table>
</div> <!-- semester block -->",
"weight" => $base_weight + ($semester->semester_num * 100) + 60,
);
$form ["semester_{$semester->semester_num}_below_table_markup"] = array(
"value" => "",
"weight" => $base_weight + ($semester->semester_num * 100) + 70,
);
$form ["semester_{$semester->semester_num}_save_draft_markup"] = array(
"value" => fp_render_button(t("Save Draft for @year", array("@year" => $de_catalog_year)), "adminSubmitDegreeForm2();"),
"weight" => $base_weight + ($semester->semester_num * 100) + 80,
);
} // while degree->list_semesters
// Add our js_existing_semesters array to the javascript on this page, so we can check it later.
fp_add_js($js_existing_semesters, "setting");
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
$bool_start_closed = TRUE;
if (@$degree->public_notes_array [$degree->degree_id] != "") {
$bool_start_closed = FALSE;
}
// Advanced options
$elements = array();
$elements ['public_note'] = array(
'type' => 'textarea',
'label' => t('Public Note'),
'rows' => 4,
'value' => @$degree->public_notes_array [$degree->degree_id],
'description' => t("You may enter simple HTML in this field. Ex: <b>bold</b> or <i>italics</i>"),
'popup_description' => t("A public note will appear at the top of a degree plan when pulled up in FlightPath.
Use this to pass messages to all students and advisors who pull up this degree plan.
\n\nIt will begin with the text 'Important Message': automatically."),
"weight" => 50010,
);
// min/max/default tracks
$elements ['adv_if_tracks_markup'] = array(
'type' => 'markup',
'value' => t('If this degre has tracks, you may enter rules for track selection below, for each
type of level 3 degree (tracks). <b>You may skip classifications which do not pertain to this degree.</b>'),
"weight" => 50020,
);
$c = 10;
$degree_classes = fp_get_degree_classifications();
foreach ($degree_classes ["levels"] as $level => $details) {
$c = $c + 10;
if (intval($level) != 3) {
continue; // we only care about level 3...
}
foreach ($degree_classes ["levels"][$level] as $machine_name => $title) {
$min_tracks = @intval($degree->track_selection_config_array [$machine_name]["min_tracks"]);
$max_tracks = @intval($degree->track_selection_config_array [$machine_name]["max_tracks"]);
$default_tracks = @trim($degree->track_selection_config_array [$machine_name]["default_tracks"]);
if ($min_tracks > 0 || $max_tracks > 0 || $default_tracks != "") {
$bool_start_closed = FALSE;
}
$elements ["tsc_{$machine_name}_min_tracks"] = array(
'type' => 'textfield',
'label' => t('Min:'),
'size' => 2,
'value' => $min_tracks,
'prefix' => "<table width='100%' class='admin-degrees-edit-track-rules-table'>
<tr class='admin-degrees-edit-track-selection-config track-selection-config-$machine_name'>
<td valign='top' width='30%'>
<span class='track-selection-config-title'>$title</span>:
</td>
<td valign='top'>",
'suffix' => "</td>",
'popup_description' => t("This is the minimum number of tracks THIS degree must select. For example, if the degree requires at least one track, enter a 1 (one) in this box.\n\n
The default is zero (0), which means that no track is required for this degree. The user is not required to select any at all.\n\n
If you are unsure what to enter, leave it set to 0 (zero)."),
"weight" => 60000 + $c + 1,
);
$elements ["tsc_{$machine_name}_max_tracks"] = array(
'type' => 'textfield',
'label' => t('Max:'),
'size' => 2,
'value' => $max_tracks,
'prefix' => "<td valign='top'>",
'suffix' => "</td>",
'popup_description' => t("This is the maximum number of tracks THIS degree may select. For example, if the degree requires the student to have NO MORE than 1 track selected, you would enter 1 (one) in this box.\n\n
The default is zero (0), which means that there is no maximum; the user may select as many of this degree's tracks as they wish.\n\n
If you are unsure what to enter, leave it set to 0 (zero)."),
"weight" => 60000 + $c + 5,
);
$elements ["tsc_{$machine_name}_default_tracks"] = array(
'type' => 'textfield',
'label' => t('Default Tracks:'),
'size' => 25,
'value' => $default_tracks,
'prefix' => "<td valign='top'>",
'suffix' => "</td>
</tr>
</table>",
'popup_description' => t("If THIS degree has one or more 'default' tracks associated with it (ex: for What If mode), enter the FULL major codes here, separated by comma.\n\n
For example: ART|_SCULP, ART|_PAINT\n\n
If you are unsure what to enter, leave it blank."),
"weight" => 60000 + $c + 7,
);
} // foreach levels[$level]
} // foreach levels as level => details
// Place in our advanced options fs.
$form ['advanced_options_fs'] = array(
'type' => 'cfieldset',
'label' => t('View advanced options'),
'elements' => array($elements),
'start_closed' => $bool_start_closed,
"weight" => 50100,
);
// Only show delete option based on permission
if (user_has_permission("can_delete_data_entry")) {
$form ['markup_bottom_delete'] = array(
"value" => " <div align='right' class='degrees-delete-degree-wrapper'>
Delete this degree? <input type='button' value='X'
onClick='adminDeleteDegree(\"$degree_id\");'>
</div>
",
"weight" => 90000,
);
}
return $form;
}