function student_profile_display_student_profile_page

7.x student_profile.module student_profile_display_student_profile_page()
6.x student_profile.module student_profile_display_student_profile_page()

File

modules/student_profile/student_profile.module, line 94

Code

function student_profile_display_student_profile_page() {
  global $current_student_id, $user, $student;

  if (!isset($student) || $student == null || !is_object($student)) {
    $student = new Student($current_student_id);
  }


  $student_id = $current_student_id;
  $rtn = "";

  $student_user_id = db_get_user_id_from_cwid($student_id, 'student');
  $student_user = fp_load_user($student_user_id);


  fp_add_css(fp_get_module_path('student_profile') . '/css/style.css');
  fp_add_js(fp_get_module_path('advise') . '/js/advise.js');


  fp_set_title('');

  $rtn .= "";


  $grade_percentages = student_profile_get_grade_percentages_for_student($student);


  $percent_D = @floatval($grade_percentages ['grade_counts']['D']['percent']);
  $percent_D_html = @$grade_percentages ['grade_counts']['D']['courses_html'];

  $percent_F = @floatval($grade_percentages ['grade_counts']['F']['percent']);
  $percent_F_html = @$grade_percentages ['grade_counts']['F']['courses_html'];

  $percent_W = @floatval($grade_percentages ['grade_counts']['W']['percent']);
  $percent_W_html = @$grade_percentages ['grade_counts']['W']['courses_html'];

  $D_link = "D's";
  if ($percent_D_html != "") {
    $D_link = "<a class='grade-percent-link' href='javascript:fp_alert(\"" . base64_encode($percent_D_html) . "\",\"base64\");'>D's</a>";
  }

  $F_link = "F's";
  if ($percent_F_html != "") {
    $F_link = "<a class='grade-percent-link' href='javascript:fp_alert(\"" . base64_encode($percent_F_html) . "\",\"base64\");'>F's</a>";
  }

  $W_link = "W's";
  if ($percent_W_html != "") {
    $W_link = "<a class='grade-percent-link' href='javascript:fp_alert(\"" . base64_encode($percent_W_html) . "\",\"base64\");'>W's</a>";
  }



  $profile_items = array();

  $active_status = t('Active');
  if ($student->is_active !== 1) {
    $active_status = t('Inactive');
  }

  $profile_items ['left_side']['active_status'] = array(
    'label' => t('Status:'),
    'content' => $active_status,
  );


  if (@$student_user->attributes ['athlete'] == 'yes') {
    $profile_items ['left_side']['athlete'] = array(
      'label' => t('Athlete?:'),
      'content' => t('Yes'),
      'mobile_content' => t('Athlete'),
    );
  }
  else {
    $profile_items ['left_side']['athlete'] = array(
      'label' => t('Athlete?:'),
      'content' => t('No'),
      'mobile_content' => t('Non-Athlete'),
    );
  }

  $profile_items ['left_side']['d_f_percent'] = array(
    'label' => 'D%/F%:',
    'content' => "$percent_D% $D_link / $percent_F% $F_link",
  );

  $url = fp_url('student-profile/priority-calculations');
  $title = t("Academic Priority Calculations");

  if ($user->is_faculty) {

    $priority_val = student_priority_get_academic_priority_value($student_id, 300); // Frequently re-calculate, so we get a "fresh" number.
    $temp = student_priority_get_student_academic_priority_label($priority_val);
    $machine = $temp ['machine'];
    $label = $temp ['label'];

    $profile_items ['left_side']['academic_priority'] = array(
      'label' => t('Academic Priority:'),
      'content' => "<span class='profile-priority-bar priority-$machine'>$label</span> <a href='javascript:popupLargeIframeDialog(\"$url\",\"$title\");'><i class='fa fa-question-circle'></i></a>",
    );
  }
  //////


  $enrollment_code = @$student_user->attributes ['enrollment_code'];
  if (!$enrollment_code || $enrollment_code == '') {
    $enrollment_code = "N/A";
  }

  $profile_items ['right_side']['enrollment_code'] = array(
    'label' => t('Enrollment Code:'),
    'content' => $enrollment_code,
    'mobile_content' => t('Enrollment Code:') . ' ' . $enrollment_code,
  );


  $financial_aid = @$student_user->attributes ['financial_aid'];
  if (!$financial_aid || $financial_aid == "") {
    $financial_aid = t("None");
  }

  $profile_items ['right_side']['financial_aid'] = array(
    'label' => t('Financial Aid:'),
    'content' => $financial_aid,
    'mobile_content' => t("Fin. Aid:") . ' ' . $financial_aid,
  );


  $profile_items ['right_side']['w_percent'] = array(
    'label' => 'W%:',
    'content' => "$percent_W% $W_link",
  );






  $rtn .= "<div class='student-profile-header-full'>";
  $rtn .= fp_render_student_profile_header(FALSE, $profile_items); // Send more items since this is a "full" profile.
  $rtn .= "</div><div class='clear'></div>";

  $rtn .= fp_render_section_title(t("Alerts"), "student-profile-alerts");

  if (user_has_permission('add_alert_content')) {
    $url = fp_url('content/add/alert', 'student_id=' . $student_id);
    $title = t("Add New Alert");
    $rtn .= "<a class='button student-profile-add-new-alert-button' href='javascript:popupLargeIframeDialog(\"$url\",\"$title\");'><i class='fa fa-bell'></i> " . t("Add New Alert") . "</a>";
  }

  // Take advantage of our "alerts form" from the alerts module.  
  $rtn .= fp_render_form("alerts_advisees_alerts_form", "normal", $student_id, 5);




  watchdog("student_profile", "view $student_id");



  // Let's set our breadcrumbs
  $db = get_global_database_handler();
  $crumbs = array();
  $crumbs [] = array(
    'text' => 'Students',
    'path' => 'student-search',
  );
  $crumbs [] = array(
    'text' => $db->get_student_name($current_student_id) . " ($current_student_id)",
    'path' => 'student-profile',
    'query' => "current_student_id=$current_student_id",
  );
  fp_set_breadcrumbs($crumbs);



  return $rtn;
}