Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php |
— | — | @@ -71,7 +71,14 @@ |
72 | 72 | |
73 | 73 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-students' ) ) ); |
74 | 74 | |
75 | | - // TODO: students |
| 75 | + $studentIds = array_map( |
| 76 | + function( EPStudent $student ) { |
| 77 | + return $student->getId(); |
| 78 | + }, |
| 79 | + $term->getStudents( 'id' ) |
| 80 | + ); |
| 81 | + |
| 82 | + EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) ); |
76 | 83 | } |
77 | 84 | } |
78 | 85 | } |
Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name ); |
77 | 77 | break; |
78 | 78 | case 'first_enroll': case 'last_active': |
79 | | - htmlspecialchars( $this->getLanguage()->date( $value ) ); |
| 79 | + $value = htmlspecialchars( $this->getLanguage()->date( $value ) ); |
80 | 80 | break; |
81 | 81 | case 'active_enroll': |
82 | 82 | $value = wfMsgHtml( $value === '1' ? 'epstudentpager-yes' : 'epstudentpager-no' ); |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | $value = $this->getLanguage()->pipeList( array_map( |
86 | 86 | function( EPCourse $course ) { |
87 | 87 | return $course->getLink(); |
88 | | - } , |
| 88 | + }, |
89 | 89 | $this->currentObject->getCurrentCourses( 'name' ) |
90 | 90 | ) ); |
91 | 91 | break; |
Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | | - * Returns the orgs this mentor is part of. |
| 103 | + * Returns the terms this student is enrolled in. |
104 | 104 | * Caches the result when no conditions are provided and all fields are selected. |
105 | 105 | * |
106 | 106 | * @since 0.1 |
Index: trunk/extensions/EducationProgram/includes/EPTerm.php |
— | — | @@ -31,6 +31,14 @@ |
32 | 32 | protected $org = false; |
33 | 33 | |
34 | 34 | /** |
| 35 | + * Cached array of the linked EPStudent objects. |
| 36 | + * |
| 37 | + * @since 0.1 |
| 38 | + * @var array|false |
| 39 | + */ |
| 40 | + protected $students = false; |
| 41 | + |
| 42 | + /** |
35 | 43 | * Returns a list of statuses a term can have. |
36 | 44 | * Keys are messages, values are identifiers. |
37 | 45 | * |
— | — | @@ -101,6 +109,60 @@ |
102 | 110 | } |
103 | 111 | |
104 | 112 | /** |
| 113 | + * Returns the students enrolled in this term. |
| 114 | + * |
| 115 | + * @since 0.1 |
| 116 | + * |
| 117 | + * @param string|array|null $fields |
| 118 | + * @param array $conditions |
| 119 | + * |
| 120 | + * @return array of EPStudent |
| 121 | + */ |
| 122 | + protected function doGetStudents( $fields, array $conditions ) { |
| 123 | + $conditions[] = array( array( 'ep_terms', 'id' ), $this->getId() ); |
| 124 | + |
| 125 | + return EPStudent::select( |
| 126 | + $fields, |
| 127 | + $conditions, |
| 128 | + array(), |
| 129 | + array( |
| 130 | + 'ep_students_per_term' => array( 'INNER JOIN', array( array( array( 'ep_students_per_term', 'term_id' ), array( 'ep_terms', 'id' ) ) ) ), |
| 131 | + 'ep_terms' => array( 'INNER JOIN', array( array( array( 'ep_students_per_term', 'term_id' ), array( 'ep_terms', 'id' ) ) ) ) |
| 132 | + ) |
| 133 | + ); |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * Returns the students enrolled in this term. |
| 138 | + * Caches the result when no conditions are provided and all fields are selected. |
| 139 | + * |
| 140 | + * @since 0.1 |
| 141 | + * |
| 142 | + * @param string|array|null $fields |
| 143 | + * @param array $conditions |
| 144 | + * |
| 145 | + * @return array of EPStudent |
| 146 | + */ |
| 147 | + public function getStudents( $fields = null, array $conditions = array() ) { |
| 148 | + if ( count( $conditions ) !== 0 ) { |
| 149 | + return $this->doGetStudents( $fields, $conditions ); |
| 150 | + } |
| 151 | + |
| 152 | + if ( $this->students === false ) { |
| 153 | + $students = $this->doGetStudents( $fields, $conditions ); |
| 154 | + |
| 155 | + if ( is_null( $fields ) ) { |
| 156 | + $this->students = $students; |
| 157 | + } |
| 158 | + |
| 159 | + return $students; |
| 160 | + } |
| 161 | + else { |
| 162 | + return $this->students; |
| 163 | + } |
| 164 | + } |
| 165 | + |
| 166 | + /** |
105 | 167 | * (non-PHPdoc) |
106 | 168 | * @see EPDBObject::loadSummaryFields() |
107 | 169 | */ |