function _AdvisingScreen::display_popup_course_description

4.x _AdvisingScreen.php _AdvisingScreen::display_popup_course_description($course_id = "", Course $course = null, $group = null, $show_advising_buttons = false)
5.x _AdvisingScreen.php _AdvisingScreen::display_popup_course_description($course_id = "", Course $course = null, $group = null, $show_advising_buttons = false)

Displays the contents of the Descripton tab for the course popup.

Parameters

int $course_id:

  • The course_id of the course to show. Leave blank if supplying the object instead.

Course $course:

  • The course object to display. Leave as NULL if supplying the course_id instead.

Group $group:

  • The Group object that this course has been placed into.

bool $show_advising_buttons:

  • Should we show the advising buttons in this popup? Would be set to false for student view, or for anyone who is not allowed to advise this course into a group for the student.

Return value

string

File

classes/_AdvisingScreen.php, line 1795

Class

_AdvisingScreen

Code

function display_popup_course_description($course_id = "", Course $course = null, $group = null, $show_advising_buttons = false) 
 {
  $pC = "";

  if ($course_id != "" && $course_id != 0) {

    $course = new Course($course_id);
  }



  $db_group_requirement_id = $_REQUEST ["db_group_requirement_id"];



  if ($course == null) 
   {
    // No course available!
    $pC .= fp_render_curved_line(t("Description"));
    $pC .= "<div class='tenpt'>" . t("No course was selected.  Please
					click the Select tab at the top of the screen.") . "
					</div>";
    return $pC;
  }


  $advising_term_id = $GLOBALS ["fp_advising"]["advising_term_id"];


  $course->load_descriptive_data();

  $course_hours = $course->get_hours();

  if ($course->bool_transfer) 
   {


  }

  // Does this course have more than one valid (non-excluded) name?
  $other_valid_names = "";
  if (count($course->array_valid_names) > 1) 
   {
    for ($t = 0; $t < count($course->array_valid_names); $t++) 
     {
      $name = $course->array_valid_names [$t];
      if ($name == "$course->subject_id~$course->course_num") 
       {
        continue;
      }
      $other_valid_names .= ", " . str_replace("~", " ", $name);
    }
  }

  $course->fix_title();

  $initials = $GLOBALS ["fp_system_settings"]["school_initials"];

  $pC .= fp_render_curved_line("$course->subject_id $course->course_num$other_valid_names <!--EQV1-->");
  $bool_transferEqv = true;
  if ($course->bool_transfer) 
   {
    // This is a transfer course.  Begin by displaying the transfer credit's
    // information.

    $course->course_transfer->load_descriptive_transfer_data($this->student->student_id);
    $hrs = $course->course_transfer->get_hours() * 1;
    if ($hrs == 0) 
     {
      $hrs = $course->get_hours();
    }

    // make transfer course titles all caps.
    $course->course_transfer->title = strtoupper($course->course_transfer->title);

    $pC .= "<div style='margin-top: 13px;' class='tenpt'>
				<b>" . t("Transfer Credit Information:") . "</b><br>
				<div style='margin-left: 20px;' class='tenpt'>
					" . t("Course:") . " " . $course->course_transfer->subject_id . " " . $course->course_transfer->course_num . " 
					- " . $course->course_transfer->title . " ($hrs hrs)<br>
					" . t("Institution:") . " " . $this->fix_institution_name($course->course_transfer->institution_name) . "<br>
					" . t("Term:") . " " . $course->get_term_description() . "<br>
					<!-- Grade: " . $course->grade . "<br> -->
					";

    $transfer_eqv_text = $course->course_transfer->transfer_eqv_text;
    if ($transfer_eqv_text == "") {
      $transfer_eqv_text = t("Not entered or not applicable.");
      $bool_transferEqv = false;
    }

    $pC .= "$initials Eqv: $transfer_eqv_text<br>
				</div>
					</div>";

  }


  $pC .= "
		   	<div style='margin-top: 13px;'>
				<div class='tenpt'>";
  if ($course->course_id != 0) 
   {
    $use_hours = $course_hours;
    if ($course->bool_transfer) 
     {
      $pC .= "<b>$initials " . t("Equivalent Course Information:") . "</b><br>
						<b>$course->subject_id $course->course_num</b> - ";
      $new_course = new Course();
      $new_course->course_id = $course->course_id;
      $new_course->load_descriptive_data();
      $use_hours = $new_course->get_catalog_hours();
    }
    $pC .= "
					<b>$course->title ($use_hours " . t("hrs") . ")</b>";
  }
  if ($course->bool_substitution_new_from_split || $course->bool_substitution_split) 
   {
    $pC .= "<div class='tenpt' style='margin-bottom:5px;'>
						<i>" . t("This course's hours were split in a substitution.") . "</i> 
						<a href='javascript: alertSplitSub();'>?</a>
					</div>";
  }

  $pC .= "</div>";

  if ($course->course_id != 0) 
   {
    $pC .= "
			<div class='tenpt'>
					$course->description
				</div>
			</div>
				";
  }

  if ($course->bool_transfer == true && $course->course_id < 1 && $course->bool_substitution == false) 
   { // No local eqv!

    $pC .= "<div class='tenpt' style='margin-top: 10px;'><b>Note:</b> ";
    /*
			$pC .= "
			<b>Note:</b> This course is a transfer credit which
			the student completed at <i>";

			$pC .= $this->fix_institution_name($course->course_transfer->institution_name) . "</i>.";
			*/
    $pC = str_replace("<!--EQV1-->", " (" . t("Transfer Credit") . ")", $pC);
    if (!$bool_transferEqv) 
     {
      $t_msg = t("This course does not have an assigned @initials equivalency, or the equivalency
							has been removed for this student.
						Ask your advisor if this course will count towards your degree.", array("@initials" => $initials)) . "
					</div>";
    }
    else {
      $t_msg = t("FlightPath cannot assign this course to a @initials equivalency on
							the student's degree plan, 
							or the equivalency
							has been removed for this student.
						Ask your advisor if this course will count towards your degree.", array("@initials" => $initials)) . "
					</div>";
    }

    $pC .= $t_msg;

  }
  elseif ($course->bool_transfer == true && $course->course_id > 0 && $course->bool_substitution == false) 
   { // Has a local eqv!

    $t_s_i = $course->course_transfer->subject_id;
    $t_c_n = $course->course_transfer->course_num;
    /*			$pC .= "<div class='tenpt' style='margin-top: 10px;'>
			<b>Note:</b> The course listed above is equivalent
			to <b>$t_s_i $t_c_n</b>,
			which the student completed at <i>";

			// Replace the temporary comment <!--EQV1--> in the header with
			// the new eqv information.
			*/
    $pC = str_replace("<!--EQV1-->", " (" . t("Transfer Credit") . " $t_s_i $t_c_n)", $pC);
    /*			$pC .= $this->fix_institution_name($course->course_transfer->institution_name);
			$pC .= "</i>.";
			*/
    // Admin function only.
    if (user_has_permission("can_substitute")) 
     {
      $pC .= "<div align='left' class='tenpt'>
					<b>" . t("Special administrative function:") . "</b>
						<a href='javascript: popupUnassignTransferEqv(\"" . $course->course_transfer->course_id . "\");'>" . t("Remove this equivalency?") . "</a></div>";
      $pC .= "</div>";
    }


    $pC .= "</div>";
  }


  if ($course->term_id != "" && $course->term_id != "11111" && $course->display_status != "eligible" && $course->display_status != "disabled") 
   {
    $pC .= "<div class='tenpt' style='margin-top: 10px;'>
						" . t("The student enrolled in this course in") . " " . $course->get_term_description() . ".
					</div>";
  }
  else if ($course->term_id == "11111") 
   {
    $pC .= "<div class='tenpt' style='margin-top: 10px;'>
						" . t("The exact date that the student enrolled in this course
						cannot be retrieved at this time.  Please check the
						student's official transcript for more details.") . "
					</div>";

  }

  if ($course->assigned_to_group_id * 1 > 0 && $course->grade != "" && $course->bool_transfer != true && $course->bool_substitution != true) 
   {
    //$g = new Group($course->assigned_to_group_id);
    $g = new Group();
    $g->group_id = $course->assigned_to_group_id;
    $g->load_descriptive_data();

    $pC .= "<div class='tenpt' style='margin-top: 10px;'>
						<img src='" . fp_theme_location() . "/images/icons/$g->icon_filename' width='19' height='19'>
						&nbsp;
						" . t("This course is a member of") . " $g->title.
					";
    // If user is an admin...
    if (user_has_permission("can_substitute")) {
      $tflag = intval($course->bool_transfer);
      $pC .= "<div align='left' class='tenpt'>
					<b>" . t("Special administrative function:") . "</b>
						<a href='javascript: popupUnassignFromGroup(\"$course->course_id\",\"$course->term_id\",\"$tflag\",\"$g->group_id\");'>" . t("Remove from this group?") . "</a></div>";
      $pC .= "</div>";
    }

  }
  else if ($course->grade != "" && $course->bool_transfer != true && $course->bool_substitution != true && $course->bool_has_been_assigned == true) {
    // Course is not assigned to a group; it's on the bare degree plan.  group_id = 0.
    // If user is an admin...
    if (user_has_permission("can_substitute")) 
     {
      $tflag = intval($course->bool_transfer);
      $pC .= "<div align='left' class='tenpt'>
					<b>" . t("Special administrative function:") . "</b>
						<a href='javascript: popupUnassignFromGroup(\"$course->course_id\",\"$course->term_id\",\"$tflag\",\"0\");'>" . t("Remove from the degree plan?") . "</a></div>";
      $pC .= "</div>";
    }

  }


  // Substitutors get extra information:
  if (user_has_permission("can_substitute") && $course->assigned_to_group_id > 0) {


    $pC .= "<div class='tenpt' style='margin-top: 20px;'>
					<b>" . t("Special administrative information:") . "</b>
					
				<span id='viewinfolink'
				onClick='document.getElementById(\"admin_info\").style.display=\"\"; this.style.display=\"none\"; '
				class='hand' style='color: blue;'
				> - " . t("Click to show") . " -</span>					
					
					<div style='padding-left: 20px; display:none;' id='admin_info'>
					";

    // Course is assigned to a group.
    if ($course->assigned_to_group_id > 0) {
      $group = new Group();
      $group->group_id = $course->assigned_to_group_id;
      $group->load_descriptive_data();

      $pC .= "
  					" . t("Course is assigned to group:") . "<br>
  					&nbsp; " . t("Group ID:") . " $group->group_id<br>
  					&nbsp; " . t("Title:") . " $group->title<br>";
      $pC .= "&nbsp; <i>" . t("Internal name:") . " $group->group_name</i><br>";

      $pC .= "&nbsp; " . t("Catalog year:") . " $group->catalog_year
  			";
    }
    $pC .= "
					</div>
					
					</div>";
  }


  if ($course->bool_substitution == true) 
   {
    // Find out who did it and if they left any remarks.
    $db = $this->db;
    $temp = $db->get_substitution_details($course->db_substitution_id);
    $by = $db->get_faculty_name($temp ["faculty_id"], false);
    $remarks = $temp ["remarks"];
    $ondate = format_date($temp ["posted"], "", "n/d/Y");


    if ($by != "") 
     {
      $by = " by $by, on $ondate.";
    }

    if ($remarks != "") 
     {
      $remarks = " " . t("Substitution remarks:") . " <i>$remarks</i>.";
    }

    $forthecourse = t("for the original course
						requirement of") . " <b>" . $course->course_substitution->subject_id . " 
						" . $course->course_substitution->course_num . "</b>";
    if ($temp ["required_course_id"] * 1 == 0) 
     {
      $forthecourse = "";
    }

    $pC .= "<div class='tenpt' style='margin-top: 10px;'>
						<b>" . t("Note:") . "</b> " . t("This course was substituted into the 
						degree plan") . " $forthecourse
						$by$remarks";


    if (user_has_permission("can_substitute")) {
      $pC .= "<div align='left' class='tenpt' style='padding-left: 10px;'>
					<b>" . t("Special administrative function:") . "</b>
					<a href='javascript: popupRemoveSubstitution(\"$course->db_substitution_id\");'>" . t("Remove substitution?") . "</a>
					</div>";
    }

  }

  // Only show if the course has not been taken...
  if ($course->has_variable_hours() && $course->grade == "") 
   {
    $pC .= "<div class='tenpt' style='margin-top: 10px;'>
					" . t("This course has variable hours. Please select 
					how many hours this course will be worth:") . "<br>
					<center>
					<select name='selHours' id='selHours' onChange='popupSetVarHours();'>
					";

    // Correct for ghost hours, if they are there.
    $min_h = $course->min_hours;
    $max_h = $course->max_hours;
    if ($course->bool_ghost_min_hour) {
      $min_h = 0;
    }
    if ($course->bool_ghost_hour) {
      $max_h = 0;
    }

    for ($t = $min_h; $t <= $max_h; $t++) 
     {
      $sel = "";
      if ($t == $course->advised_hours) {
        $sel = "SELECTED";
      }
      $pC .= "<option value='$t' $sel>$t</option>";
    }
    $pC .= "</select> " . t("hours.") . "<br>
					
					</center>
					</div>";

    if ($course->advised_hours > -1) 
     {
      $var_hours_default = $course->advised_hours;
    }
    else {
      $var_hours_default = $min_h;
    }

  }

  if ($show_advising_buttons == true && !$this->bool_blank) {

    // Insert a hidden radio button so the javascript works okay...
    $pC .= "<input type='radio' name='course' value='$course->course_id' checked='checked'
					style='display: none;'>
					<input type='hidden' name='varHours' id='varHours' value='$var_hours_default'>";

    if (user_has_permission("can_advise_students")) 
     {
      $pC .= "<div style='margin-top: 20px;'>
				" . fp_render_button(t("Select Course"), "popupAssignSelectedCourseToGroup(\"$group->assigned_to_semester_num\", \"$group->group_id\",\"$advising_term_id\",\"$db_group_requirement_id\");", true, "style='font-size: 10pt;'") . "
				</div>
				
				";
    }
  }
  else if ($show_advising_buttons == false && $course->has_variable_hours() == true && $course->grade == "" && user_has_permission("can_advise_students") && !$this->bool_blank) {
    // Show an "update" button, and use the course's assigned_to_group_id and
    // assigned_to_semester_num.
    $pC .= "
					<input type='hidden' name='varHours' id='varHours' value='$var_hours_default'>";


    $pC .= fp_render_button(t("Update"), "popupUpdateSelectedCourse(\"$course->course_id\",\"$course->assigned_to_group_id\",\"$course->assigned_to_semester_num\",\"$course->random_id\",\"$advising_term_id\");");

  }


  return $pC;
}