r109049 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109048‎ | r109049 | r109050 >
Date:17:56, 16 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on instructor management
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPInstructor.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.api.js (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.instructor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPInstructor.php
@@ -110,6 +110,7 @@
111111 public function getUserLink() {
112112 return Linker::userLink(
113113 $this->getUser()->getId(),
 114+ $this->getUser()->getName(),
114115 $this->getName()
115116 );
116117 }
@@ -131,14 +132,18 @@
132133
133134 $links[] = Linker::link( SpecialPage::getTitleFor( 'Contributions', $this->getUser()->getName() ), wfMsgHtml( 'contribslink' ) );
134135
135 - if ( !is_null( $course ) && $context->getUser()->isAllowed( 'ep-instructor' ) ) {
 136+ if ( !is_null( $course ) &&
 137+ ( $context->getUser()->isAllowed( 'ep-instructor' ) || $this->getUser()->getId() == $context->getUser()->getId() ) ) {
136138 $links[] = Html::element(
137139 'a',
138140 array(
139141 'href' => '#',
140142 'class' => 'ep-instructor-remove',
141143 'data-courseid' => $course->getId(),
 144+ 'data-coursename' => $course->getField( 'name' ),
142145 'data-userid' => $this->getUser()->getId(),
 146+ 'data-username' => $this->getUser()->getName(),
 147+ 'data-bestname' => $this->getName(),
143148 ),
144149 wfMsg( 'ep-instructor-remove' )
145150 );
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -383,6 +383,7 @@
384384 'ep-instructor-remove-retry' => 'Retry',
385385 'ep-instructor-remove-failed' => 'Something went wrong - could not remove the instructor from the course.',
386386 'ep-instructor-cancel-button' => 'Cancel',
 387+ 'ep-instructor-remove-text' => 'You are about to remove $2 (Username: $1) as {{GENDER:$1|instructor}} from course $3. Please enter a brief summary with the reason for this removal.',
387388
388389 // EPInstrucor
389390 'ep-instructor-remove' => 'remove from course',
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -336,6 +336,7 @@
337337 'dependencies' => array(
338338 'jquery.ui.dialog',
339339 'ep.api',
 340+ 'mediawiki.jqueryMsg',
340341 ),
341342 'messages' => array(
342343 'ep-instructor-remove-title',
@@ -346,6 +347,7 @@
347348 'ep-instructor-remove-retry',
348349 'ep-instructor-remove-failed',
349350 'ep-instructor-cancel-button',
 351+ 'ep-instructor-remove-text',
350352 ),
351353 );
352354
Index: trunk/extensions/EducationProgram/resources/ep.api.js
@@ -34,7 +34,8 @@
3535
3636 this.addInstructor = function( args ) {
3737 var requestArgs = $.extend( {
38 - 'action': 'addinstructor',
 38+ 'action': 'instructor',
 39+ 'subaction': 'add',
3940 'format': 'json',
4041 'token': window.mw.user.tokens.get( 'editToken' )
4142 }, args );
Index: trunk/extensions/EducationProgram/resources/ep.instructor.js
@@ -13,46 +13,73 @@
1414 $( '.ep-instructor-remove' ).click( function( event ) {
1515 var $this = $( this ),
1616 courseId = $this.attr( 'data-courseid' ),
 17+ courseName = $this.attr( 'data-coursename' ),
1718 userId = $this.attr( 'data-userid' ),
 19+ userName = $this.attr( 'data-username' ),
 20+ bestName = $this.attr( 'data-bestname' ),
1821 $dialog = null;
 22+
 23+ var doRemove = function() {
 24+ var $remove = $( '#ep-instructor-remove-button' );
 25+ var $cancel = $( '#ep-instructor-cancel-button' );
1926
20 - $dialog = $( '<div />' ).html( '' ).dialog( {
 27+ $remove.button( 'option', 'disabled', true );
 28+ $remove.button( 'option', 'label', mw.msg( 'ep-instructor-removing' ) );
 29+
 30+ ep.api.addInstructor( {
 31+ 'courseid': courseId,
 32+ 'userid': userId,
 33+ 'reason': summaryInput.val()
 34+ } ).done( function() {
 35+ $dialog.text( mw.msg( 'ep-instructor-removal-success' ) );
 36+ $remove.remove();
 37+ $cancel.button( 'option', 'label', mw.msg( 'ep-instructor-close-button' ) );
 38+ $cancel.focus();
 39+ } ).fail( function() {
 40+ $remove.button( 'option', 'disabled', false );
 41+ $remove.button( 'option', 'label', mw.msg( 'ep-instructor-remove-retry' ) );
 42+ alert( mw.msg( 'ep-instructor-remove-failed' ) );
 43+ } );
 44+ };
 45+
 46+ var summaryInput = $( '<input>' ).attr( {
 47+ 'type': 'text',
 48+ 'size': 60,
 49+ 'maxlength': 250
 50+ } );
 51+
 52+ $dialog = $( '<div>' ).html( '' ).dialog( {
2153 'title': mw.msg( 'ep-instructor-remove-title' ),
2254 'minWidth': 550,
2355 'buttons': [
2456 {
2557 'text': mw.msg( 'ep-instructor-remove-button' ),
26 - 'id': 'instructor-remove-button',
27 - 'click': function() {
28 - var $remove = $( '#ep-instructor-remove-button' );
29 - var $cancel = $( '#reminder-cancel-button' );
30 -
31 - $remove.button( 'option', 'disabled', true );
32 - $remove.button( 'option', 'label', mw.msg( 'ep-instructor-removing' ) );
33 -
34 - ep.api.addInstructor( {
35 - 'courseid': courseId,
36 - 'userid': userId
37 - } ).done( function() {
38 - $dialog.text( mw.msg( 'ep-instructor-removal-success' ) );
39 - $remove.remove();
40 - $cancel.button( 'option', 'label', mw.msg( 'ep-instructor-close-button' ) );
41 - } ).fail( function() {
42 - $remove.button( 'option', 'label', mw.msg( 'ep-instructor-remove-retry' ) );
43 - $remove.button( 'option', 'disabled', false );
44 - alert( mw.msg( 'ep-instructor-remove-failed' ) );
45 - } );
46 - }
 58+ 'id': 'ep-instructor-remove-button',
 59+ 'click': doRemove
4760 },
4861 {
4962 'text': mw.msg( 'ep-instructor-cancel-button' ),
50 - 'id': 'instructor-cancel-button',
 63+ 'id': 'ep-instructor-cancel-button',
5164 'click': function() {
5265 $dialog.dialog( 'close' );
5366 }
5467 }
5568 ]
5669 } );
 70+
 71+ $dialog.append( $( '<p>' ).text( gM( 'ep-instructor-remove-text', userName, bestName, courseName ) ) );
 72+
 73+ $dialog.append( summaryInput );
 74+
 75+ summaryInput.focus();
 76+
 77+ summaryInput.keypress( function( event ) {
 78+ if ( event.which == '13' ) {
 79+ event.preventDefault();
 80+ doRemove();
 81+ }
 82+ } );
 83+
5784
5885 // TODO: input to provide reason/comment for log
5986 } );

Status & tagging log