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 2339

Class

_AdvisingScreen

Code

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

  $db = $this->db;

  if ($course_id != "" && $course_id != 0) {
    $course = new Course($course_id);
  }

  // Set up our "render array" for later rendering, using the render API.
  $render = array();
  $render ["#id"] = "AdvisingScreen_display_popup_course_description";

  $render ["#course"] = array(
    "type" => "do_not_render",
    "value" => $course,
  );


  $db_group_requirement_id = @$_REQUEST ["db_group_requirement_id"];



  if ($course == null) 
   {
    // No course available!
    $pC .= fp_render_curved_line(t("Description"));

    $render ["no_course_selected"] = array(
      "value" => t("No course was selected.  Please
          click the Select tab at the top of the screen."),
      "attributes" => array("style" => "margin-top: 13px;", "class" => "tenpt"),
    );

    $pC .= fp_render_content($render);
    return $pC;
  }

  // Not sure I need this line anymore.
  $datastring_max_hours = $course->max_hours;


  $datastring_bool_new_from_split = $course->get_bool_substitution_new_from_split();
  $req_by_degree_id = $course->req_by_degree_id;

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

  $course->load_descriptive_data(TRUE, TRUE, TRUE, FALSE, FALSE, FALSE);

  $course_hours = $course->get_catalog_hours();
  if ($course->bool_transfer) 
   {
    // Nothing at the moment.
  }

  // 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, $course->term_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);

    $html = "";
    $html .= "<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;
    }

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

    $render ["transfer_credit_info"] = array(
      "value" => $html,
    );

  } // if course->bool_transfer





  if ($course->course_id != 0) 
   {
    $html = "";
    $use_hours = $course_hours;

    if ($course->bool_transfer) 
     {
      $html .= "<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();
    }

    // if this is a substitution, use the number of hours for the ORIGNAL course.			
    if ($course->get_bool_substitution() == TRUE) {
      $sub_id = $course->db_substitution_id_array [$course->get_course_substitution()->req_by_degree_id];

      $temp = $db->get_substitution_details($sub_id);
      $sub_hours = @$temp ['sub_hours'] * 1; // trim excess zeros with *1.
      if ($sub_hours < $use_hours) {
        $use_hours = $sub_hours;
      }
    }

    $html .= "
					<b>$course->title ($use_hours " . t("hrs") . ")</b>";


    $render ["course_title_line"] = array(
      "value" => $html,
      "attributes" => array("style" => "margin-top: 13px; margin-bottom: 0;", "class" => "tenpt"),
      "weight" => 10,
    );


    // If the course can be repeated for credit, show that information next.
    if ($course->repeat_hours > $course->min_hours) 
     {
      $html = t("May be repeated for up to @repeat hours of credit.", array("@repeat" => $course->repeat_hours));

      // if it is essentially infinite, then we just say it can be repeated for credit, period.
      if ($course->repeat_hours > 20) {
        $html = t("May be repeated for credit.");
      }

      $render ["course_repeat_line"] = array(
        "value" => $html,
        "attributes" => array("class" => "tenpt course-search-repeat"),
        "weight" => 15,
      );

    }




  } // if course->course_id != 0



  if ($course->get_bool_substitution_new_from_split($req_by_degree_id) || $course->get_bool_substitution_split($req_by_degree_id)) 
   {
    $html = "";
    $html .= "<div class='tenpt' style='margin-bottom:5px;'>
						        <i>" . t("This course's hours were split in a substitution.");

    if ($course->get_bool_substitution_new_from_split()) {
      //$html .= "<br>" . t("Remaining hours after split:") . "  $datastring_max_hours hrs.";


      $sub_remaining_hours = @$course->get_hours_awarded($req_by_degree_id);

      $html .= "<br>" . t("Remaining hours after split:") . "  $sub_remaining_hours hrs.";
    }


    $html .= "</i>
						        <a href='javascript: alertSplitSub();'>?</a>
					     </div>";

    $render ["substitution_split"] = array(
      "value" => $html,
      "weight" => 20,
    );

  }

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

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


    $render ["course_description"] = array(
      "value" => $course->description,
      "attributes" => array("class" => "tenpt"),
      "weight" => 30,
    );

  }

  // The -1 for get_bool_substitution means, is it being used in ANY substitution?
  if ($course->bool_transfer == true && $course->course_id < 1 && $course->get_bool_substitution(-1) == FALSE) 
   { // No local eqv!

    $html = "";
    $html .= "<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); // place the words "transfer credit" in the curved title line at the top.

    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>";
    }

    $html .= $t_msg;

    $render ["course_transfer_no_eqv"] = array(
      "value" => $html,
      "weight" => 40,
    );


  }
  elseif ($course->bool_transfer == true && $course->course_id > 0 && $course->get_bool_substitution(-1) == FALSE) 
   { // Has a local eqv!
    $html = "";

    $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")) 
     {
      $html .= "<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>";

      //$html .= "</div>";  // not sure what this went to.  Commenting out.  
    }


    //$pC .= "</div>";   // not sure what this went to... commenting out.

    $render ["course_transfer_local_eqv"] = array(
      "value" => $html,
      "weight" => 50,
    );


  }


  ////////////////////////////
  //  When was this student enrolled in this course?

  $html = "";
  if ($course->term_id != "" && $course->term_id != Course::COURSE_UNKNOWN_TERM_ID && $course->display_status != "eligible" && $course->display_status != "disabled") 
   {
    $html .= "<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 == Course::COURSE_UNKNOWN_TERM_ID) 
   {
    $html .= "<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>";

  }

  $render ["when_enrolled"] = array(
    "value" => $html,
    "weight" => 50,
  );

  ///////////////////////////////////


  ////////////////////////////////
  // Conditions on which this will even appear?  Like only if the student has more than one degree selected?
  // What degrees is this course fulfilling?    
  if (count($course->assigned_to_degree_ids_array) > 0) {
    $html = "";

    $html .= "<div class='tenpt course-description-assigned-to-degrees'>
                " . t("This course is fulfilling a requirement for: ");
    $c = "";
    $d = "";
    foreach ($course->assigned_to_degree_ids_array as $degree_id) {
      $d .= $degree_id . ",";
      $t_degree_plan = new DegreePlan();
      $t_degree_plan->degree_id = $degree_id;
      $c .= "<span>" . $t_degree_plan->get_title2(FALSE, TRUE) . "</span>, ";
    }
    $c = rtrim($c, ", ");
    $html .= "$c</div>";

    $render ["fulfilling_reqs_for_degrees"] = array(
      "value" => $html,
      "weight" => 60,
    );
    // Also keep track of what degree ids we are fulfilling reqs for, in case we need it later.
    $render ["#fulfilling_reqs_for_degree_ids"] = array(
      "type" => "do_not_render",
      "value" => $d,
    );


  }

  ////////////////
  // Is this course assigned to a group?
  if ($course->disp_for_group_id != "" && $course->grade != "" && $course->bool_transfer != true && $course->get_bool_substitution($course->req_by_degree_id) != TRUE) 
   {

    $html = "";

    //$g = new Group($course->assigned_to_group_id);
    $g = new Group();
    //$g->group_id = $course->assigned_to_group_id;
    //$g->group_id = $course->get_first_assigned_to_group_id();
    $g->group_id = $course->disp_for_group_id;
    $g->load_descriptive_data();

    $html .= "<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);
      $html .= "<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\",\"$req_by_degree_id\");'>" . t("Remove from this group?") . "</a></div>";
      $html .= "</div>";
    }

    $render ["course_assigned_to_group"] = array(
      "value" => $html,
      "weight" => 70,
    );

    $render ["#group"] = array(
      "type" => "do_not_render",
      "value" => $g,
    );


  }
  else if ($course->grade != "" && $course->bool_transfer != true && $course->get_bool_substitution($course->req_by_degree_id) != TRUE && $course->get_has_been_assigned_to_degree_id()) {
    // Course is not assigned to a group; it's on the bare degree plan.  group_id = 0.
    // If user is an admin...

    $html = "";
    if (user_has_permission("can_substitute")) 
     {
      $tflag = intval($course->bool_transfer);
      $html .= "<div align='left' class='tenpt'>
					<b>" . t("Special administrative function:") . "</b>
						<a href='javascript: popupUnassignFromGroup(\"$course->course_id\",\"$course->term_id\",\"$tflag\",\"0\",\"$req_by_degree_id\");'>" . t("Remove from the degree plan?") . "</a></div>";
      $html .= "</div>";
    }

    $render ["course_not_assigned_to_group"] = array(
      "value" => $html,
      "weight" => 80,
    );

  }


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

    $html = "";

    $html .= "
					
				<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'>
					Groups this course has been assigned to:
					";

    // Course is assigned to a group.
    // might be assigned to multiple groups, so show them in a loop
    if ($course->get_first_assigned_to_group_id()) {
      foreach ($course->assigned_to_group_ids_array as $group_id) {
        $group = new Group();
        $group->group_id = $group_id;
        $group->load_descriptive_data();

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

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

    $render ["substitutor_extra"] = array(
      "label" => ("Special administrative information:"),
      "value" => $html,
      "weight" => 90,
      "attributes" => array("class" => "tenpt"),
    );

  }



  // Has the course been substituted into *this* degree plan?
  if ($course->get_bool_substitution() == TRUE) 
   {

    $html = "";

    // Find out who did it and if they left any remarks.			
    $db = $this->db;
    $sub_id = $course->db_substitution_id_array [$course->get_course_substitution()->req_by_degree_id];

    $temp = $db->get_substitution_details($sub_id);

    $required_degree_id = $temp ["required_degree_id"];
    $req_degree_plan = new DegreePlan();
    $req_degree_plan->degree_id = $required_degree_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->get_course_substitution()->subject_id . " 
					" . $course->get_course_substitution()->course_num . " (" . $course->get_course_substitution()->get_hours() . " hrs)</b>";
    if ($temp ["required_course_id"] * 1 == 0) 
     {
      $forthecourse = "";
    }

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


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

    $render ["course_sub_this_degree_plan"] = array(
      "value" => $html,
      "weight" => 100,
    );

  }



  // Variable hours? Only show if the course has not been taken...
  $var_hours_default = "";
  if ($course->has_variable_hours() && $course->grade == "") 
   {
    $html = "";

    $html .= "<div class='tenpt'>
					" . t("This course has variable hours. Please select 
					how many hours this course will be worth:") . "<br>
					<div style='text-align: center;'>
					<select name='selHours' id='selHours' onChange='popupSetVarHours();'>
					";

    // Correct for ghost hours, if they are there.
    $min_h = $course->min_hours * 1;
    $max_h = $course->max_hours * 1;
    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";
      }
      $html .= "<option value='$t' $sel>$t</option>";
    }
    $html .= "</select> " . t("hours.") . "<br>
					
					</div>
					</div>";

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

    $render ["course_var_hour_select"] = array(
      "value" => $html,
      "weight" => 110,
    );

  }


  // Some hidden vars and other details
  $html = "";
  if ($show_advising_buttons == true && !$this->bool_blank) {

    // Insert a hidden radio button so the javascript works okay...
    $html .= "<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")) 
     {
      $html .= fp_render_button(t("Select Course"), "popupAssignSelectedCourseToGroup(\"$group->assigned_to_semester_num\", \"$group->group_id\",\"$advising_term_id\",\"$db_group_requirement_id\",\"$req_by_degree_id\");", true, "style='font-size: 10pt;'");
    }
  }
  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.
    $html .= "
					<input type='hidden' name='varHours' id='varHours' value='$var_hours_default'>";

    // Same situation about the group_id.  I guess need to find out exactly which group it was assigned to?

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

  }

  $render ["hidden_vars_and_buttons"] = array(
    "value" => $html,
    "weight" => 1000,
  );



  // Okay, render our render array and return.    
  $pC .= fp_render_content($render);
  return $pC;
}