student_profile.module

File

modules/student_profile/student_profile.module
View source
  1. <?php
  2. /**
  3. * Implements hook_menu
  4. */
  5. function student_profile_menu() {
  6. $items = array();
  7. $items["student-profile"] = array(
  8. "title" => "Student Profile",
  9. "page_callback" => "student_profile_display_student_profile_page",
  10. "access_callback" => "system_can_access_student", // make sure we are allowed to access the student specified by current_student_id.
  11. "type" => MENU_TYPE_TAB,
  12. "tab_family" => "system",
  13. "weight" => 10,
  14. "page_settings" => array(
  15. "display_currently_advising" => FALSE,
  16. "screen_mode" => "not_advising",
  17. ),
  18. );
  19. return $items;
  20. }
  21. /**
  22. * Returns an array where we show the percentage of grades that the student has, compared to the whole.
  23. * For example: 50% A's, 10% B's, and so on.
  24. *
  25. * For convenience, we will also include the courses in an array so it can be displayed if desired.
  26. */
  27. function student_profile_get_grade_percentages_for_student($student) {
  28. $rtn = array();
  29. // Init some defaults...
  30. $rtn['grade_counts']['D']['count'] = 0;
  31. $rtn['grade_counts']['F']['count'] = 0;
  32. $rtn['grade_counts']['W']['count'] = 0;
  33. $rtn['grade_counts']['A']['count'] = 0;
  34. $rtn['grade_counts']['B']['count'] = 0;
  35. $rtn['grade_counts']['C']['count'] = 0;
  36. $total_courses = count($student->list_courses_taken->array_list);
  37. if ($total_courses == 0) return $rtn;
  38. foreach ($student->list_courses_taken->array_list as $course) {
  39. $grade = $course->grade;
  40. if (!isset($rtn['grade_counts'][$grade]['count'])) $rtn['grade_counts'][$grade]['count'] = 0;
  41. $rtn['grade_counts'][$grade]['count']++;
  42. $rtn['grade_counts'][$grade]['courses'][] = $course;
  43. }
  44. foreach ($rtn['grade_counts'] as $grade => $val) {
  45. $count = $rtn['grade_counts'][$grade]['count'];
  46. $percent = round(($count / $total_courses) * 100, 1);
  47. $rtn['grade_counts'][$grade]['percent'] = $percent;
  48. $html = "";
  49. if ($count > 0) {
  50. foreach ($val['courses'] as $course) {
  51. $html .= "<div class='grade-perc-course-row'>$course->subject_id $course->course_num $course->grade ($course->term_id)</div>";
  52. }
  53. }
  54. $rtn['grade_counts'][$grade]['courses_html'] = $html;
  55. }
  56. return $rtn;
  57. } // student_profile_get_grade_percentages_for_student($student)
  58. function student_profile_display_student_profile_page() {
  59. global $current_student_id, $user, $student;
  60. if (!isset($student) || $student == null || !is_object($student)) {
  61. $student = new Student($current_student_id);
  62. }
  63. $student_id = $current_student_id;
  64. $rtn = "";
  65. $student_user_id = db_get_user_id_from_cwid($student_id, 'student');
  66. $student_user = fp_load_user($student_user_id);
  67. fp_add_css(fp_get_module_path('student_profile') . '/css/style.css');
  68. fp_add_js(fp_get_module_path('advise') . '/js/advise.js');
  69. fp_set_title('');
  70. $rtn .= "";
  71. $grade_percentages = student_profile_get_grade_percentages_for_student($student);
  72. $percent_D = @floatval($grade_percentages['grade_counts']['D']['percent']);
  73. $percent_D_html = $grade_percentages['grade_counts']['D']['courses_html'];
  74. $percent_F = @floatval($grade_percentages['grade_counts']['F']['percent']);
  75. $percent_F_html = $grade_percentages['grade_counts']['F']['courses_html'];
  76. $percent_W = @floatval($grade_percentages['grade_counts']['W']['percent']);
  77. $percent_W_html = $grade_percentages['grade_counts']['W']['courses_html'];
  78. $D_link = "D's";
  79. if ($percent_D_html != "") {
  80. $D_link = "<a class='grade-percent-link' href='javascript:fp_alert(\"" . base64_encode($percent_D_html) . "\",\"base64\");'>D's</a>";
  81. }
  82. $F_link = "F's";
  83. if ($percent_F_html != "") {
  84. $F_link = "<a class='grade-percent-link' href='javascript:fp_alert(\"" . base64_encode($percent_F_html) . "\",\"base64\");'>F's</a>";
  85. }
  86. $W_link = "W's";
  87. if ($percent_W_html != "") {
  88. $W_link = "<a class='grade-percent-link' href='javascript:fp_alert(\"" . base64_encode($percent_W_html) . "\",\"base64\");'>W's</a>";
  89. }
  90. $profile_items = array();
  91. $active_status = t('Active');
  92. if ($student->is_active !== 1) {
  93. $active_status = t('Inactive');
  94. }
  95. $profile_items['left_side']['active_status'] = array(
  96. 'label' => t('Status:'),
  97. 'content' => $active_status,
  98. );
  99. if (@$student_user->attributes['athlete'] == 'yes') {
  100. $profile_items['left_side']['athlete'] = array(
  101. 'label' => t('Athlete?:'),
  102. 'content' => t('Yes'),
  103. 'mobile_content' => t('Athlete'),
  104. );
  105. }
  106. else {
  107. $profile_items['left_side']['athlete'] = array(
  108. 'label' => t('Athlete?:'),
  109. 'content' => t('No'),
  110. 'mobile_content' => t('Non-Athlete'),
  111. );
  112. }
  113. $profile_items['left_side']['d_f_percent'] = array(
  114. 'label' => 'D%/F%:',
  115. 'content' => "$percent_D% $D_link / $percent_F% $F_link",
  116. );
  117. $url = fp_url('student-profile/priority-calculations');
  118. $title = t("Academic Priority Calculations");
  119. if ($user->is_faculty) {
  120. $priority_val = student_priority_get_academic_priority_value($student_id, 300); // Frequently re-calculate, so we get a "fresh" number.
  121. $temp = student_priority_get_student_academic_priority_label($priority_val);
  122. $machine = $temp['machine'];
  123. $label = $temp['label'];
  124. $profile_items['left_side']['academic_priority'] = array(
  125. 'label' => t('Academic Priority:'),
  126. 'content' => "<span class='profile-priority-bar priority-$machine'>$label</span> <a href='javascript:popupLargeIframeDialog(\"$url\",\"$title\");'><i class='fa fa-question-circle'></i></a>",
  127. );
  128. }
  129. //////
  130. $enrollment_code = trim(@$student_user->attributes['enrollment_code']);
  131. if ($enrollment_code == "") $enrollment_code = "N/A";
  132. $profile_items['right_side']['enrollment_code'] = array(
  133. 'label' => t('Enrollment Code:'),
  134. 'content' => $enrollment_code,
  135. 'mobile_content' => t('Enrollment Code:') . ' ' . $enrollment_code,
  136. );
  137. $financial_aid = trim(@$student_user->attributes['financial_aid']);
  138. if ($financial_aid == "") $financial_aid = t("None");
  139. $profile_items['right_side']['financial_aid'] = array(
  140. 'label' => t('Financial Aid:'),
  141. 'content' => $financial_aid,
  142. 'mobile_content' => t("Fin. Aid:") . ' ' . $financial_aid,
  143. );
  144. $profile_items['right_side']['w_percent'] = array(
  145. 'label' => 'W%:',
  146. 'content' => "$percent_W% $W_link",
  147. );
  148. $rtn .= "<div class='student-profile-header-full'>";
  149. $rtn .= fp_render_student_profile_header(FALSE, $profile_items); // Send more items since this is a "full" profile.
  150. $rtn .= "</div><div class='clear'></div>";
  151. $rtn .= fp_render_section_title(t("Alerts"), "student-profile-alerts");
  152. if (user_has_permission('add_alert_content')) {
  153. $url = fp_url('content/add/alert', 'student_id=' . $student_id);
  154. $title = t("Add New Alert");
  155. $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>";
  156. }
  157. // Take advantage of our "alerts form" from the alerts module.
  158. $rtn .= fp_render_form("alerts_advisees_alerts_form", "normal", $student_id, 5);
  159. watchdog("student_profile", "view $student_id");
  160. // Let's set our breadcrumbs
  161. $db = get_global_database_handler();
  162. $crumbs = array();
  163. $crumbs[] = array(
  164. 'text' => 'Students',
  165. 'path' => 'student-search',
  166. );
  167. $crumbs[] = array(
  168. 'text' => $db->get_student_name($current_student_id) . " ($current_student_id)",
  169. 'path' => 'student-profile',
  170. 'query' => "current_student_id=$current_student_id",
  171. );
  172. fp_set_breadcrumbs($crumbs);
  173. return $rtn;
  174. } // display student profile page

Functions

Namesort descending Description
student_profile_display_student_profile_page
student_profile_get_grade_percentages_for_student Returns an array where we show the percentage of grades that the student has, compared to the whole. For example: 50% A's, 10% B's, and so on.
student_profile_menu Implements hook_menu