Index: trunk/extensions/EducationProgram/includes/EPStudent.php |
— | — | @@ -22,14 +22,6 @@ |
23 | 23 | protected $terms = false; |
24 | 24 | |
25 | 25 | /** |
26 | | - * Cached array of the EPCourse objects. |
27 | | - * |
28 | | - * @since 0.1 |
29 | | - * @var array|false |
30 | | - */ |
31 | | - protected $courses = false; |
32 | | - |
33 | | - /** |
34 | 26 | * @see parent::getFieldTypes |
35 | 27 | * |
36 | 28 | * @since 0.1 |
— | — | @@ -119,15 +111,15 @@ |
120 | 112 | } |
121 | 113 | |
122 | 114 | /** |
| 115 | + * Returns the courses this student is linked to (via terms). |
123 | 116 | * |
124 | | - * |
125 | 117 | * @since 0.1 |
126 | 118 | * |
127 | | - * @param null $fields |
| 119 | + * @param string|null|array $fields |
128 | 120 | * @param array $conditions |
129 | 121 | * @param array $termConditions |
130 | 122 | * |
131 | | - * @return array |
| 123 | + * @return array of EPCourse |
132 | 124 | */ |
133 | 125 | public function getCourses( $fields = null, array $conditions = array(), array $termConditions = array() ) { |
134 | 126 | $courseIds = array_reduce( |
— | — | @@ -141,17 +133,37 @@ |
142 | 134 | return array(); |
143 | 135 | } |
144 | 136 | |
145 | | - $conditions['id'] = $courseIds; |
| 137 | + $conditions['id'] = array_unique( $courseIds ); |
146 | 138 | |
147 | 139 | return EPCourse::select( $fields, array( 'id' => $conditions ) ); |
148 | 140 | } |
149 | 141 | |
| 142 | + /** |
| 143 | + * Returns the courses this student is currently enrolled in. |
| 144 | + * |
| 145 | + * @since 0.1 |
| 146 | + * |
| 147 | + * @param string|null|array $fields |
| 148 | + * @param array $conditions |
| 149 | + * |
| 150 | + * @return array of EPCourse |
| 151 | + */ |
150 | 152 | public function getCurrentCourses( $fields = null, array $conditions = array() ) { |
151 | 153 | return $this->getCourses( $fields, $conditions, array( |
152 | 154 | 'end >= ' . wfGetDB( DB_SLAVE )->addQuotes( wfTimestampNow() ) |
153 | 155 | ) ); |
154 | 156 | } |
155 | 157 | |
| 158 | + /** |
| 159 | + * Returns the courses this student was previously enrolled in. |
| 160 | + * |
| 161 | + * @since 0.1 |
| 162 | + * |
| 163 | + * @param string|null|array $fields |
| 164 | + * @param array $conditions |
| 165 | + * |
| 166 | + * @return array of EPCourse |
| 167 | + */ |
156 | 168 | public function getPassedCourses( $fields = null, array $conditions = array() ) { |
157 | 169 | return $this->getCourses( $fields, $conditions, array( |
158 | 170 | 'end < ' . wfGetDB( DB_SLAVE )->addQuotes( wfTimestampNow() ) |