function _AdvisingScreen::draw_course_row

4.x _AdvisingScreen.php _AdvisingScreen::draw_course_row(Course $course, $icon_filename = "", $title_text = "", $js_toggle_and_save = false, $bool_display_check = true, $bool_add_footnote = true, $bool_add_asterisk_to_transfers = false)
5.x _AdvisingScreen.php _AdvisingScreen::draw_course_row(Course $course, $icon_filename = "", $title_text = "", $js_toggle_and_save = false, $bool_display_check = true, $bool_add_footnote = true, $bool_add_asterisk_to_transfers = false)

This is used by lots of other functions to display a course on the screen. It will show the course, the hours, the grade, and quality points, as well as any necessary icons next to it.

Parameters

Course $course:

string $icon_filename:

string $title_text:

bool $js_toggle_and_save:

  • If set to TRUE, when the checkbox next to this course is clicked, the page will be submitted and a draft will be saved.

bool $bool_display_check:

  • If set to FALSE, no checkbox will be displayed for this course row.

bool $bool_add_footnote:

bool $bool_add_asterisk_to_transfers:

Return value

string

5 calls to _AdvisingScreen::draw_course_row()
_AdvisingScreen::build_excess_credit in classes/_AdvisingScreen.php
Constructs the HTML to show the Excess Credits list.
_AdvisingScreen::build_graduate_credit in classes/_AdvisingScreen.php
Constructs the HTML which will be used to display the student's graduate credits (if any exist)
_AdvisingScreen::build_transfer_credit in classes/_AdvisingScreen.php
Constructs the HTML which will be used to display the student's transfer credits
_AdvisingScreen::display_group_course_list in classes/_AdvisingScreen.php
Displays all the courses in a CourseList object, using the draw_course_row function.
_AdvisingScreen::display_semester in classes/_AdvisingScreen.php
Given a Semester object, this will generate the HTML to draw it out to the screen.

File

classes/_AdvisingScreen.php, line 3921

Class

_AdvisingScreen

Code

function draw_course_row(Course $course, $icon_filename = "", $title_text = "", $js_toggle_and_save = false, $bool_display_check = true, $bool_add_footnote = true, $bool_add_asterisk_to_transfers = false) 
 {
  // Display a course itself...

  $theme = array();
  $theme ["screen"] = $this;
  $theme ["student"] = $this->student;
  $theme ["degree_plan"] = $this->degree_plan;

  $pC = "";
  $w1_1 = $this->width_array [0];
  $w1_2 = $this->width_array [1];
  $w1_3 = $this->width_array [2];
  $w2 = $this->width_array [3];
  $w3 = $this->width_array [4];
  $w4 = $this->width_array [5];
  $w5 = $this->width_array [6];
  $w6 = $this->width_array [7];

  $img_path = fp_theme_location() . "/images";

  // The current term we are advising for.
  $advising_term_id = @$GLOBALS ["fp_advising"]["advising_term_id"];

  $pts = "";

  if (!$advising_term_id) {
    $advising_term_id = 0;
  }

  $extra_classes = "";

  $course->assign_display_status();
  // If the course has already been advised in a different semester,
  // we should set the advising_term_id to that and disable unchecking.
  if ($course->advised_term_id * 1 > 0 && $course->bool_advised_to_take == true && $course->advised_term_id != $advising_term_id) 
   {
    $course->display_status = "disabled";
    $advising_term_id = $course->advised_term_id;
  }

  // Add the name of the course to the extra-classes
  $extra_classes .= " cr-" . fp_get_machine_readable($course->subject_id . " " . $course->course_num);

  // Has the course been assigned to more than one degree?
  if (count($course->assigned_to_degree_ids_array) > 1) {
    $extra_classes .= " course-assigned-more-than-one-degree course-assigned-" . count($course->assigned_to_degree_ids_array) . "-degrees";
  }

  // If this is a course fragment, created as a remainder of a split substitution, add extra class.
  if (@$course->details_by_degree_array [$course->req_by_degree_id]["bool_substitution_new_from_split"]) {
    $extra_classes .= " course-sub-new-from-split";
  }
  if (@$course->details_by_degree_array [$course->req_by_degree_id]["bool_substitution_split"]) {
    $extra_classes .= " course-sub-split";
  }



  // If the course has NOT been assigned, but is appearing in more than one degree, give it an extra CSS class
  // Check to see if the course is in our required_courses_id_array for more than one degree.
  if ($course->display_status == "eligible") {
    if (isset($this->degree_plan->required_course_id_array [$course->course_id])) {


      if (count($this->degree_plan->required_course_id_array [$course->course_id]) > 1) {
        // Add a new classname for this course...
        $extra_classes .= " course-appears-in-mult-degrees course-appears-in-" . count($this->degree_plan->required_course_id_array [$course->course_id]) . "-degrees";
      }
    }
  }


  if ($course->subject_id == "") 
   {
    $course->load_descriptive_data();
  }

  $subject_id = $course->subject_id;
  $course_num = $course->course_num;

  $o_subject_id = $subject_id;
  $o_course_num = $course_num;

  $degree_id = $course->req_by_degree_id;

  $footnote = "";
  $ast = "";
  // Is this actually a transfer course?  If so, display its
  // original subject_id and course_num.
  if ($course->bool_transfer == true) 
   {
    $subject_id = $course->course_transfer->subject_id;
    $course_num = $course->course_transfer->course_num;
    $institution_name = $course->course_transfer->institution_name;

    if ($bool_add_asterisk_to_transfers == true) 
     {
      $course->course_transfer->load_descriptive_transfer_data($this->student->student_id);
      if ($course->course_transfer->transfer_eqv_text != "") 
       {
        $ast = "*";
        $GLOBALS ["advising_course_has_asterisk"] = true;
      }
    }

    // Apply a footnote if it has a local eqv.
    if ($bool_add_footnote == true && $course->course_id > 0) 
     {
      $footnote = "";

      $footnote .= "<span class='superscript'>T";
      $fcount = @count($this->footnote_array ["transfer"]) + 1;
      if ($course->get_has_been_displayed() == true) 
       { // If we've already displayed this course once, and are
        // now showing it again (like in the Transfer Credit list)
        // we do not want to increment the footnote counter.
        $fcount = $course->transfer_footnote;
      }
      $course->transfer_footnote = $fcount;
      $footnote .= "$fcount</span>";
      $this->footnote_array ["transfer"][$fcount] = "$o_subject_id $o_course_num ~~ $subject_id $course_num ~~  ~~ $institution_name";
    }
  }


  $hours = $course->get_hours_awarded();


  if ($course->get_bool_substitution() == TRUE) 
   {

    $hours = $course->get_substitution_hours();

    $temp_sub_course = $course->get_course_substitution();

    //fpm($temp_sub_course);
    if (is_object($temp_sub_course)) 
     {

      if ($temp_sub_course->subject_id == "") 
       { // Reload subject_id, course_num, etc, for the substitution course,
        // which is actually the original requirement.
        $temp_sub_course->load_descriptive_data();
      }

      $o_subject_id = $temp_sub_course->subject_id;
      $o_course_num = $temp_sub_course->course_num;
    }


    if ($bool_add_footnote == true) 
     {
      if (!isset($this->footnote_array ["substitution"])) {
        $this->footnote_array ["substitution"] = array();
      }
      $footnote = "";
      $footnote .= "<span class='superscript'>S";
      $fcount = count($this->footnote_array ["substitution"]) + 1;
      if ($course->get_has_been_displayed($course->req_by_degree_id) == true) 
       { // If we've already displayed this course once, and are
        // now showing it again (like in the Transfer Credit list)
        // we do not want to increment the footnote counter.
        $fcount = $course->substitution_footnote;
      }
      $course->substitution_footnote = $fcount;
      $footnote .= "$fcount</span>";
      $r = $course->req_by_degree_id;

      @$sub_id = $course->db_substitution_id_array [$r];
      $this->footnote_array ["substitution"][$fcount] = "$o_subject_id $o_course_num ~~ $subject_id $course_num ~~ " . $course->get_substitution_hours() . " ~~ " . $course->get_first_assigned_to_group_id() . " ~~ $sub_id";

    }
  } // if course->get_bool_substitution() == true



  if ($hours <= 0) {
    // Some kind of error-- default to catalog hours
    $hours = $course->get_catalog_hours();
  }

  $hours = $hours * 1; // force numeric, trim extra zeros.

  $var_hour_icon = "&nbsp;";


  if ($course->has_variable_hours() == true && !$course->bool_taken) 
   {
    // The bool_taken part of this IF statement is because if the course
    // has been completed, we should only use the hours_awarded.

    $var_hour_icon = "<img src='" . fp_theme_location() . "/images/var_hour.gif'
								title='" . t("This course has variable hours.") . "'
								alt='" . t("This course has variable hours.") . "'>";
    $hours = $course->get_advised_hours();

  }

  if ($course->bool_ghost_hour == TRUE) {
    // This course was given a "ghost hour", meaning it is actually
    // worth 0 hours, not 1, even though it's hours_awarded is currently
    // set to 1.  So, let's just make the display be 0.
    $hours = "0";
  }

  $grade = $course->grade;

  $dispgrade = $grade;
  // If there is a MID, then this is a midterm grade.
  $dispgrade = str_replace("MID", "<span class='superscript'>" . t("mid") . "</span>", $dispgrade);

  if (strtoupper($grade) == "E") 
   { // Currently enrolled.  Show no grade.
    $dispgrade = "";
  }

  if ($course->bool_hide_grade) 
   {
    $dispgrade = "--";
    $this->bool_hiding_grades = true;
  }

  $display_status = $course->display_status;

  if ($display_status == "completed") 
   {
    $pts = $this->get_quality_points($grade, $hours);
  }

  $course_id = $course->course_id;
  $semester_num = $course->assigned_to_semester_num;
  //$group_id = $course->assigned_to_group_id;
  $group_id = $course->get_first_assigned_to_group_id();
  $hid_group_id = str_replace("_", "U", $group_id); // replace _ with placeholder U so it doesn't mess up submission.
  $random_id = $course->random_id;
  $advised_hours = $course->advised_hours * 1;

  $unique_id = $course_id . "_" . $semester_num . "_" . mt_rand(1, 99999);
  $hid_name = "advcr_$course_id" . "_$semester_num" . "_$hid_group_id" . "_$advised_hours" . "_$random_id" . "_$advising_term_id" . "_$degree_id" . "_r" . mt_rand(1, 99);

  // Due to an interesting bug, the hid_name cannot contain periods.  So, if a course
  // has decimal hours, we need to replace the decimal with a placeholder.
  if (strstr($hid_name, ".")) {
    $hid_name = str_replace(".", "DoT", $hid_name);
  }



  $hid_value = "";
  $opchecked = "";
  if ($course->bool_advised_to_take == true) 
   {
    $hid_value = "true";
    $opchecked = "-check";
  }

  $op_on_click_function = "toggleSelection";
  if ($js_toggle_and_save == true) 
   {
    $op_on_click_function = "toggleSelectionAndSave";
  }

  $extra_js_vars = "";
  if ($course->display_status == "disabled") 
   { // Checkbox needs to be disabled because this was advised in another
    // term.
    $op_on_click_function = "toggleDisabledChangeTerm";
    $course->term_id = $course->advised_term_id;
    $extra_js_vars = $course->get_term_description();

  }

  if ($course->display_status == "completed" || $course->display_status == "enrolled") 
   {
    $op_on_click_function = "toggleDisabledCompleted";
    $opchecked = "";
    $extra_js_vars = $course->display_status;
  }

  if ($course->display_status == "retake") 
   {
    // this course was probably subbed in while the student
    // was still enrolled, and they have since made an F or W.
    // So, disable it.
    $op_on_click_function = "dummyToggleSelection";
    $opchecked = "";
  }


  if ($this->bool_print || $this->bool_blank) 
   {
    // If this is print view, disable clicking.
    $op_on_click_function = "dummyToggleSelection";
  }


  if (!user_has_permission("can_advise_students")) 
   {
    // This user does not have the abilty to advise,
    // so take away the ability to toggle anything (like
    // we are in print view).
    $op_on_click_function = "dummyToggleSelection";
  }

  $extra_css = "";
  if ($opchecked == "-check") {
    $extra_css .= " advise-checkbox-$display_status-checked";
  }

  /*
		$op = "<span class='advise-checkbox advise-checkbox-$display_status $extra_css'
		             id='cb_span_$unique_id'
		             onClick='{$op_on_click_function}(\"$unique_id\",\"$display_status\",\"$extra_js_vars\");'></span>";
    */

  $theme ["op"] = array(
    "display_status" => $display_status,
    "extra_css" => $extra_css,
    "unique_id" => $unique_id,
    "onclick" => array(
      "function" => $op_on_click_function,
      "arguments" => array($unique_id, $display_status, $extra_js_vars),
    ),
    "hidden_field" => "<input type='hidden' name='$hid_name' id='advcr_$unique_id' value='$hid_value'>",
  );

  /*
 * 
          <img src='$img_path/cb_" . $display_status . "$opchecked.gif'
          border='0'
          id='cb_$unique_id'
          onclick='{$op_on_click_function}(\"$unique_id\",\"$display_status\",\"$extra_js_vars\");'
          >*/


  //$hid = "<input type='hidden' name='$hid_name'
  //				id='advcr_$unique_id' value='$hid_value'>";

  // Okay, we can't actually serialize a course, as it takes too much space.
  // It was slowing down the page load significantly!  So, I am going
  // to use a function I wrote called to_data_string().

  $data_string = $course->to_data_string();
  $blank_degree_id = "";
  if ($this->bool_blank == true) 
   {
    $blank_degree_id = $this->degree_plan->degree_id;
  }

  $js_code = "describeCourse(\"$data_string\",\"$blank_degree_id\");";

  $theme ["course"]["js_code"] = $js_code;

  // Assemble theme array elements for the course itself.
  $theme ["course"] = array(
    "course" => $course,
    "js_code" => $js_code,
    "subject_id" => $subject_id,
    "course_num" => $course_num,
    "display_status" => $display_status,
    "extra_classes" => $extra_classes,
    "footnote" => $footnote,
    "hours" => $hours,
    "var_hour_icon" => $var_hour_icon,
    "dispgrade" => $dispgrade,
    "grade" => $grade,
    "pts" => $pts,
    "title" => $title_text,
    "group_id" => $group_id,
  );





  // If the course has a 'u' in it, it is a 'University Capstone' course.
  if (strstr($course->requirement_type, "u")) {
    $icon_filename = "ucap.gif";
    $title_text = t("This course is a University Capstone.");
  }

  if ($icon_filename != "") {
    //$icon_link = "<img src='" . fp_theme_location() . "/images/icons/$icon_filename' width='19' height='19' border='0' alt='$title_text' title='$title_text'>";

    $theme ["icon"] = array();
    $theme ["icon"]["filename"] = $icon_filename;
    $theme ["icon"]["location"] = fp_theme_location() . "/images/icons";
    $theme ["icon"]["title"] = $title_text;

  }

  /*
		$on_mouse_over = " onmouseover=\"style.backgroundColor='#FFFF99'\"
      				onmouseout=\"style.backgroundColor='white'\" ";

     */

  $on_mouse_over = "
            onmouseover='$(this).addClass(\"selection_highlight\");'
            onmouseout='$(this).removeClass(\"selection_highlight\");'
    ";

  if (fp_screen_is_mobile()) {
    $on_mouse_over = ""; // Causes problems for some mobile devices.
  }

  $hand_class = "hand";

  if ($bool_display_check == false) {
    //$op = $hid = "";

    unset($theme ["op"]);
  }


  if ($this->bool_print) {
    // In print view, disable all popups and mouseovers.
    $on_mouse_over = "";
    //$js_code = "";
    $theme ["course"]["js_code"] = "";
    $hand_class = "";
  }



  // Invoke a hook on our theme array, so other modules have a chance to change it up.   
  invoke_hook("theme_advise_course_row", array(&$theme));

  /////////////////////////////////
  // Actually draw out our $theme array now....

  // The checkbox & hidden element....
  $op = $hid = "";
  if (isset($theme ["op"]) && count($theme ["op"]) > 0) {

    $onclick = "";
    $onclick = $theme ["op"]["onclick"]["function"] . "(\"" . join("\",\"", $theme ["op"]["onclick"]["arguments"]) . "\")";

    $op = "<span class='advise-checkbox advise-checkbox-{$theme ["op"]["display_status"]} {$theme ["op"]["extra_css"]}'
                 id='cb_span_{$theme ["op"]["unique_id"]}'
                 onClick='$onclick;'></span>";
    $hid = $theme ["op"]["hidden_field"];
  }

  // The icon....
  $icon_html = "";
  if (isset($theme ["icon"]) && count($theme ["icon"]) > 0) {
    $icon_html = "<img class='advising-course-row-icon'
                      src='{$theme ["icon"]["location"]}/{$theme ["icon"]["filename"]}' width='19' height='19' border='0' alt='{$theme ["icon"]["title"]}' title='{$theme ["icon"]["title"]}'>";
  }


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

  // Draw the actual course row...

  $pC .= "<tr><td colspan='8'>";

  if ($course->get_bool_substitution_new_from_split() != TRUE || ($course->get_bool_substitution_new_from_split() == TRUE && $course->display_status != "eligible")) {

    if ($course_num == "") {
      $course_num = "&nbsp;";
    }

    $js_code = $theme ["course"]["js_code"];

    $pC .= "
   		<table border='0' cellpadding='0' width='100%' cellspacing='0' align='left' class='draw-course-row'>
     	<tr height='20' class='$hand_class {$theme ["course"]["display_status"]} {$theme ["course"]["extra_classes"]}'
      		$on_mouse_over title='{$theme ["course"]["title"]}' >
      		<td style='width:$w1_1; white-space:nowrap;' class='w1_1' align='left'>$op$hid</td>
        
      		<td style='width:$w1_2; white-space:nowrap;' align='left'   class='w1_2' onClick='$js_code'>$icon_html</td>
      		<td style='width:$w1_3; white-space:nowrap;' align='left'   class='w1_3' onClick='$js_code'>&nbsp;$ast</td>
      		<td align='left' style='width:$w2; white-space:nowrap;' class='tenpt underline  w2 '  onClick='$js_code'>
       				{$theme ["course"]["subject_id"]}</td>
       		<td class='tenpt underline w3' style='width:$w3; white-space:nowrap;' align='left' 
       			         onClick='$js_code'>
        			       {$theme ["course"]["course_num"]}{$theme ["course"]["footnote"]}</td>
	         <td class='tenpt underline w4' style='width:$w4; max-width:36px; white-space:nowrap;'  onClick='$js_code'>{$theme ["course"]["hours"]}{$theme ["course"]["var_hour_icon"]}</td>
       	   <td class='tenpt underline w5'  style='width:$w5; max-width:35px; white-space:nowrap;'  onClick='$js_code'>{$theme ["course"]["dispgrade"]}&nbsp;</td>
       	   <td class='tenpt underline w6' style='width:$w6; max-width:31px; white-space:nowrap;' onClick='$js_code'>{$theme ["course"]["pts"]}&nbsp;</td>
       	
     	</tr>
     	</table>";

  }
  else {
    // These are the leftover hours from a partial substitution.

    $pC .= "
   		<table border='0' cellpadding='0' width='100%' cellspacing='0' align='left' class='draw-course-row-leftover-hours'>
     	<tr height='20' class='hand {$theme ["course"]["display_status"]}'
      		$on_mouse_over title='{$theme ["course"]["title"]}'>
      		<td width='$w1_1'  class='w1_1' align='left'>$op$hid</td>
      		<td width='$w1_2'  class='w1_2' align='left' onClick='$js_code'>$icon_html</td>
      		<td width='$w1_3'  class='w1_3' align='left' onClick='$js_code'>&nbsp;</td>
      		<td align='left' class='tenpt underline course-part-sub-hrs-left' onClick='$js_code'
      			colspan='4'>
       				&nbsp; &nbsp; {$theme ["course"]["subject_id"]} &nbsp;
        			{$theme ["course"]["course_num"]}{$theme ["course"]["footnote"]}
	       			&nbsp; ({$theme ["course"]["hours"]} " . t("hrs left") . ")
       	   	</td>
     	</tr>
     	</table>";

  }

  $pC .= "</td></tr>";


  return $pC;
}