function AdvisingScreen::display_semester

7.x AdvisingScreen.php AdvisingScreen::display_semester(Semester $semester, $bool_display_hour_count = false)
6.x AdvisingScreen.php AdvisingScreen::display_semester(Semester $semester, $bool_display_hour_count = false)

Given a Semester object, this will generate the HTML to draw it out to the screen. We will take advantage of the render engine, so we can utilize hook_content_alter later on.

Parameters

Semester $semester:

bool $bool_display_hour_count:

  • If set to TRUE, it will display a small "hour count" message at the bottom of each semester, showing how many hours are in the semester. Good for debugging purposes.

Return value

string

2 calls to AdvisingScreen::display_semester()
AdvisingScreen::build_added_courses in classes/AdvisingScreen.php
Constructs the HTML to show which courses have been added by an advisor.
AdvisingScreen::build_semester_list in classes/AdvisingScreen.php
Constructs the HTML to display the list of semesters for the student.

File

classes/AdvisingScreen.php, line 3244

Class

AdvisingScreen

Code

function display_semester(Semester $semester, $bool_display_hour_count = false) 
 {
  // Display the contents of a semester object
  // on the screen (in HTML)

  $render = array();
  $render ['#id'] = 'AdvisingScreen_display_semester';
  $render ['#semester'] = $semester;
  $render ['#degree_plan'] = $this->degree_plan;
  $render ['#bool_display_hour_count'] = $bool_display_hour_count;
  $render_weight = 0;
  $render ['semester_box_top'] = array(
    'value' => $this->draw_semester_box_top($semester->title),
    'weight' => $render_weight,
  );

  $count_hoursCompleted = 0;


  $html = array();


  // Create a temporary caching system for degree titles, so we don't have to keep looking them back up.
  if (!isset($GLOBALS ["fp_temp_degree_titles"])) {
    $GLOBALS ["fp_temp_degree_titles"] = array();
    $GLOBALS ["fp_temp_degree_types"] = array();
    $GLOBALS ["fp_temp_degree_classes"] = array();
    $GLOBALS ["fp_temp_degree_levels"] = array();
  }


  $degree_sort_policy = variable_get_for_school("degree_requirement_sort_policy", "alpha", $this->student->school_id);

  // First, display the list of bare courses.
  if ($degree_sort_policy == 'database') {
    $semester->list_courses->sort_degree_requirement_id();
  }
  else {
    // By default, sort alphabetical      
    $semester->list_courses->sort_alphabetical_order(); // sort, including the degree title we're sorting for.
  }
  $semester->list_courses->reset_counter();

  while ($semester->list_courses->has_more()) 
   {
    $course = $semester->list_courses->get_next();

    if (!isset($html [$course->req_by_degree_id])) {
      $html [$course->req_by_degree_id] = "";
    }

    // Is this course being fulfilled by anything?

    if (!($course->course_list_fulfilled_by->is_empty)) 
     { // this requirement is being fulfilled by something the student took...

      $c = $course->course_list_fulfilled_by->get_first();

      $c->req_by_degree_id = $course->req_by_degree_id; // make sure we assign it to the current degree_id.

      // Tell the course what group we are coming from. (in this case: none)
      $c->disp_for_group_id = "";

      $html [$course->req_by_degree_id] .= $this->draw_course_row($c);
      $c->set_has_been_displayed($course->req_by_degree_id);


      if ($c->display_status == "completed") 
       { // We only want to count completed hours, no midterm or enrolled courses.
        $h = $c->get_hours_awarded();
        if ($c->bool_ghost_hour == TRUE) {
          $h = 0;
        }
        $count_hoursCompleted += $h;
      }

    }
    else {
      // This requirement is not being fulfilled...

      // Tell the course what group we are coming from. (in this case: none)
      $course->disp_for_group_id = "";
      $x = $this->draw_course_row($course);
      //fpm(htmlentities($x));             
      $html [$course->req_by_degree_id] .= $x;

    }



  }


  /////////////////////////////////////
  // Now, draw all the groups.
  $semester->list_groups->sort_alphabetical_order();
  $semester->list_groups->reset_counter();
  while ($semester->list_groups->has_more()) 
   {

    $group = $semester->list_groups->get_next();

    if (!isset($html [$group->req_by_degree_id])) {
      $html [$group->req_by_degree_id] = "";
    }

    //$html[$group->req_by_degree_id] .= "<tr class='semester-display-group-tr'><td colspan='8'>";
    $x = $this->display_group($group);
    //fpm(htmlentities($x, TRUE));
    $html [$group->req_by_degree_id] .= $x;
    $count_hoursCompleted += $group->hours_fulfilled_for_credit;
    //$html[$group->req_by_degree_id] .= "</td></tr>";
  } //while groups.




  // Sort by degree's advising weight
  $new_html = array();
  foreach ($html as $req_by_degree_id => $content) {

    $dtitle = @$GLOBALS ["fp_temp_degree_titles"][$req_by_degree_id];
    $dweight = intval(@$GLOBALS ["fp_temp_degree_advising_weights"][$req_by_degree_id]);

    if ($dtitle == "") {
      $t_degree_plan = new DegreePlan();
      $t_degree_plan->degree_id = $req_by_degree_id;
      //$t_degree_plan->load_descriptive_data();            
      $dtitle = $t_degree_plan->get_title2(TRUE, TRUE);
      $dweight = $t_degree_plan->db_advising_weight;
      $dtype = $t_degree_plan->degree_type;
      $dclass = $t_degree_plan->degree_class;
      $dlevel = $t_degree_plan->degree_level;
      $GLOBALS ["fp_temp_degree_titles"][$req_by_degree_id] = $dtitle . " "; //save for next time.
      $GLOBALS ["fp_temp_degree_types"][$req_by_degree_id] = $dtype; //save for next time.
      $GLOBALS ["fp_temp_degree_classes"][$req_by_degree_id] = $dclass; //save for next time.
      $GLOBALS ["fp_temp_degree_levels"][$req_by_degree_id] = $dlevel; //save for next time.
      $GLOBALS ["fp_temp_degree_advising_weights"][$req_by_degree_id] = $dweight . " "; //save for next time.
    }

    $degree_title = fp_get_machine_readable($dtitle); // make it machine readable.  No funny characters.
    $degree_advising_weight = str_pad($dweight, 4, "0", STR_PAD_LEFT);


    $new_html [$degree_advising_weight . "__" . $degree_title][$req_by_degree_id] = $content;

  }

  // Sort by the first index, the advising weight.   

  ksort($new_html);

  $pC = "";

  //////////////////////////
  // Okay, now let's go through our HTML array and add to the screen....
  foreach ($new_html as $w => $html) {
    foreach ($html as $req_by_degree_id => $content) {

      // Get the degree title...        
      $dtitle = @$GLOBALS ["fp_temp_degree_titles"][$req_by_degree_id];
      $dtype = @$GLOBALS ["fp_temp_degree_types"][$req_by_degree_id];
      $dclass = @$GLOBALS ["fp_temp_degree_classes"][$req_by_degree_id];
      $dlevel = @$GLOBALS ["fp_temp_degree_levels"][$req_by_degree_id];
      if ($dtitle == "") {
        $t_degree_plan = new DegreePlan();
        $t_degree_plan->degree_id = $req_by_degree_id;
        //$t_degree_plan->load_descriptive_data();
        $dtitle = $t_degree_plan->get_title2(TRUE, TRUE);

        $dtype = $t_degree_plan->degree_type;
        $dclass = $t_degree_plan->degree_class;
        $dlevel = $t_degree_plan->degree_level;

        $GLOBALS ["fp_temp_degree_titles"][$req_by_degree_id] = $dtitle; //save for next time.
        $GLOBALS ["fp_temp_degree_types"][$req_by_degree_id] = $dtype; //save for next time.
        $GLOBALS ["fp_temp_degree_classes"][$req_by_degree_id] = $dclass; //save for next time.
        $GLOBALS ["fp_temp_degree_levels"][$req_by_degree_id] = $dlevel; //save for next time.

      }

      $css_dtitle = fp_get_machine_readable($dtitle);


      $theme = array(
        'classes' => array(' ', 'required-by-degree',
          "required-by-degree-$css_dtitle",
          "required-by-degree-type-" . fp_get_machine_readable($dtype),
          "required-by-degree-class-" . fp_get_machine_readable($dclass),
          "required-by-degree-level-" . fp_get_machine_readable($dlevel)),
        'css_dtitle' => $css_dtitle,
        'degree_id' => $req_by_degree_id,
        'required_by_html' => "<span class='req-by-label'>" . t("Required by") . "</span> <span class='req-by-degree-title'>$dtitle</span>",
        'view_by' => 'year',
      );


      // Don't display if we are in the Courses Added semester, or if we are NOT a "combined" degree.
      if ($semester->semester_num == DegreePlan::SEMESTER_NUM_FOR_COURSES_ADDED || (is_object($this->degree_plan)) && !$this->degree_plan->is_combined_dynamic_degree_plan) {
        $theme ['required_by_html'] = '';
      }

      invoke_hook("theme_advise_degree_header_row", array(&$theme));

      if ($theme ['required_by_html']) {
        $pC .= "<tr><td colspan='8' class='required-by-td'>
                    <div class='" . implode(' ', $theme ['classes']) . "'>{$theme ['required_by_html']}</div>
                  </td></tr>";
      }

      $pC .= $content;
    }
  }


  $render_weight = $render_weight + 10;

  $render ['semester_content'] = array(
    'value' => $pC,
    'weight' => $render_weight,
  );



  // Add hour count to the bottom...
  if ($bool_display_hour_count == true && $count_hoursCompleted > 0) 
   {
    $p = "<tr><td colspan='8'>
        <div class='advise-completed-hours' style='text-align:right; margin-top: 10px;'>
        <span class='completed-hours-label'>" . t("Completed hours:") . "</span> <span class='count-hours-completed'>$count_hoursCompleted</span>
        </div>        
        </td></tr>";

    $render_weight = $render_weight + 10;
    $render ['semester_disp_hour_count'] = array(
      'value' => $p,
      'weight' => $render_weight,
    );

  }


  // Does the semester have a notice?
  if ($semester->notice != "") 
   {
    $p = "<tr><td colspan='8'>
          <div class='hypo   advise-semester-notice' style='margin-top: 15px; padding: 5px;'>
            <b>" . t("Important Notice:") . "</b> $semester->notice
          </div>
          </td></tr>";

    $render_weight = $render_weight + 10;
    $render ['semester_notice'] = array(
      'value' => $p,
      'weight' => $render_weight,
    );
  }










  //$pC .= $this->draw_semester_box_bottom();
  $render_weight = $render_weight + 10;
  $render ['semester_box_bottom'] = array(
    'value' => $this->draw_semester_box_bottom(),
    'weight' => $render_weight,
  );



  // If the semester has NO content, then just return FALSE.
  if (trim($render ['semester_content']['value']) == "" && !isset($render ['semester_notice']) && !isset($render ['semester_disp_hour_count'])) {
    return FALSE;
  }

  // Otherwise, render out and return the HTML
  return fp_render_content($render);
}