Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -79,7 +79,99 @@ |
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
| 83 | + $stats['instructors'] = $this->getInstructorsList( $course ) . $this->getInstructorControls( $course ); |
| 84 | + |
83 | 85 | return $stats; |
84 | 86 | } |
| 87 | + |
| 88 | + /** |
| 89 | + * Returns a list with the instructors for the provided course |
| 90 | + * or a message indicating there are none. |
| 91 | + * |
| 92 | + * @since 0.1 |
| 93 | + * |
| 94 | + * @param EPCourse $course |
| 95 | + * |
| 96 | + * @return string |
| 97 | + */ |
| 98 | + protected function getInstructorsList( EPCourse $course ) { |
| 99 | + $instructors = $course->getInstructors(); |
| 100 | + |
| 101 | + if ( count( $instructors ) > 0 ) { |
| 102 | + $instList = array(); |
| 103 | + |
| 104 | + foreach ( $instructors as /* EPInstructor */ $instructor ) { |
| 105 | + $instList[] = $instructor->getUserLink() . $instructor->getToolLinks( $this->getContext(), $course ); |
| 106 | + } |
| 107 | + |
| 108 | + if ( false ) { // count( $instructors ) == 1 |
| 109 | + $html = $instList[0]; |
| 110 | + } |
| 111 | + else { |
| 112 | + $html = '<ul><li>' . implode( '</li><li>', $instList ) . '</li></ul>'; |
| 113 | + } |
| 114 | + } |
| 115 | + else { |
| 116 | + $html = wfMsgHtml( 'ep-course-no-instructors' ); |
| 117 | + } |
| 118 | + |
| 119 | + return Html::rawElement( |
| 120 | + 'div', |
| 121 | + array( 'id' => 'ep-course-instructors' ), |
| 122 | + $html |
| 123 | + ); |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Returns instructor addition controls for the course if the |
| 128 | + * current user has the right permissions. |
| 129 | + * |
| 130 | + * @since 0.1 |
| 131 | + * |
| 132 | + * @param EPCourse $course |
| 133 | + * |
| 134 | + * @return string |
| 135 | + */ |
| 136 | + protected function getInstructorControls( EPCourse $course ) { |
| 137 | + $user = $this->getUser(); |
| 138 | + $links = array(); |
| 139 | + |
| 140 | + if ( ( $user->isAllowed( 'ep-instructor' ) || $user->isAllowed( 'ep-beinstructor' ) ) |
| 141 | + && !in_array( $user->getId(), $course->getField( 'instructors' ) ) |
| 142 | + ) { |
| 143 | + $links[] = Html::element( |
| 144 | + 'a', |
| 145 | + array( |
| 146 | + 'href' => '#', |
| 147 | + 'class' => 'ep-add-instructor', |
| 148 | + 'data-courseid' => $course->getId(), |
| 149 | + 'data-coursename' => $course->getField( 'name' ), |
| 150 | + 'data-mode' => 'self', |
| 151 | + ), |
| 152 | + wfMsg( 'ep-course-become-instructor' ) |
| 153 | + ); |
| 154 | + } |
| 155 | + |
| 156 | + if ( $user->isAllowed( 'ep-instructor' ) ) { |
| 157 | + $links[] = Html::element( |
| 158 | + 'a', |
| 159 | + array( |
| 160 | + 'href' => '#', |
| 161 | + 'class' => 'ep-add-instructor', |
| 162 | + 'data-courseid' => $course->getId(), |
| 163 | + 'data-coursename' => $course->getField( 'name' ), |
| 164 | + ), |
| 165 | + wfMsg( 'ep-course-add-instructor' ) |
| 166 | + ); |
| 167 | + } |
| 168 | + |
| 169 | + if ( count( $links ) > 0 ) { |
| 170 | + $this->getOutput()->addModules( 'ep.instructor' ); |
| 171 | + return '<br />' . $this->getLanguage()->pipeList( $links ); |
| 172 | + } |
| 173 | + else { |
| 174 | + return ''; |
| 175 | + } |
| 176 | + } |
85 | 177 | |
86 | 178 | } |
\ No newline at end of file |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -89,6 +89,7 @@ |
90 | 90 | 'end' => 'str', // TS_MW |
91 | 91 | 'description' => 'str', |
92 | 92 | 'token' => 'str', |
| 93 | + 'instructors' => 'array', |
93 | 94 | 'online_ambs' => 'array', |
94 | 95 | 'campus_ambs' => 'array', |
95 | 96 | 'field' => 'str', |
— | — | @@ -112,6 +113,7 @@ |
113 | 114 | 'end' => wfTimestamp( TS_MW ), |
114 | 115 | 'description' => '', |
115 | 116 | 'token' => '', |
| 117 | + 'instructors' => array(), |
116 | 118 | 'online_ambs' => array(), |
117 | 119 | 'campus_ambs' => array(), |
118 | 120 | 'field' => '', |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -172,6 +172,9 @@ |
173 | 173 | 'ep-courses-add' => 'Add course', |
174 | 174 | 'ep-courses-noorgs' => 'There are no institutions yet. You need to [[Special:Institutions|add an institution]] before you can create any courses.', |
175 | 175 | 'ep-courses-addorgfirst' => 'There are no institutions yet. You need to [[Special:Institutions|add an institution]] before you can create any courses.', |
| 176 | + 'ep-course-no-instructors' => 'There are no instructors for this course yet.', |
| 177 | + 'ep-course-become-instructor' => 'Become an instructor', |
| 178 | + 'ep-course-add-instructor' => 'Add an instructor', |
176 | 179 | |
177 | 180 | // Special:Students |
178 | 181 | 'ep-students-noresults' => 'There are no students to list.', |
— | — | @@ -300,6 +303,7 @@ |
301 | 304 | 'viewcourseaction-summary-students' => 'Student count', |
302 | 305 | 'viewcourseaction-summary-status' => 'Status', |
303 | 306 | 'viewcourseaction-summary-token' => 'Enrollment token', |
| 307 | + 'viewcourseaction-summary-instructors' => 'Instructors', |
304 | 308 | 'ep-course-description' => 'description', |
305 | 309 | |
306 | 310 | // Institution history |