2011-02-01 09:57:29 +08:00
/ * *
* Copyright ( C ) 2011 Instructure , Inc .
*
* This file is part of Canvas .
*
* Canvas is free software : you can redistribute it and / or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation , version 3 of the License .
*
* Canvas is distributed in the hope that it will be useful , but WITHOUT ANY
* WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE . See the GNU Affero General Public License for more
* details .
*
* You should have received a copy of the GNU Affero General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
* /
2011-08-31 04:32:58 +08:00
I18n . scoped ( 'course_settings' , function ( I18n ) {
2011-10-04 02:18:07 +08:00
var GradePublishing = {
status : null ,
checkup : function ( ) {
$ . ajaxJSON ( $ ( "#publish_to_sis_form" ) . attr ( 'action' ) , 'GET' , { } , function ( data ) {
if ( ! data . hasOwnProperty ( "sis_publish_status" ) ) {
return ;
}
GradePublishing . status = data . sis _publish _status ;
GradePublishing . update ( data . hasOwnProperty ( "sis_publish_messages" ) ? data . sis _publish _messages : { } ) ;
} ) ;
} ,
update : function ( messages , requestInProgress ) {
var $publish _grades _link = $ ( "#publish_grades_link" ) ,
$publish _grades _error = $ ( "#publish_grades_error" ) ;
if ( GradePublishing . status == 'published' ) {
$publish _grades _error . hide ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.republish' , "Republish grades to SIS" ) ) ;
$publish _grades _link . removeClass ( "disabled" ) ;
} else if ( GradePublishing . status == 'publishing' || GradePublishing . status == 'pending' ) {
$publish _grades _error . hide ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.publishing' , "Publishing grades to SIS..." ) ) ;
if ( ! requestInProgress ) {
setTimeout ( GradePublishing . checkup , 5000 ) ;
}
$publish _grades _link . addClass ( "disabled" ) ;
} else if ( GradePublishing . status == 'unpublished' ) {
$publish _grades _error . hide ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.publish' , "Publish grades to SIS" ) ) ;
$publish _grades _link . removeClass ( "disabled" ) ;
} else {
$publish _grades _error . show ( ) ;
$publish _grades _link . html ( I18n . t ( 'links.republish' , "Republish grades to SIS" ) ) ;
$publish _grades _link . removeClass ( "disabled" ) ;
}
$messages = $ ( "#publish_grades_messages" ) ;
$messages . empty ( ) ;
$ . each ( messages , function ( message , count ) {
var $message = $ ( "<span/>" ) ;
$message . text ( message ) ;
var $item = $ ( "<li/>" ) ;
$item . append ( $message ) ;
$item . append ( " - <b>" + count + "</b>" ) ;
$messages . append ( $item ) ;
} ) ;
} ,
publish : function ( ) {
if ( GradePublishing . status == 'publishing' || GradePublishing . status == 'pending' || GradePublishing . status == null ) {
2011-06-21 02:27:54 +08:00
return ;
}
2011-10-04 02:18:07 +08:00
if ( GradePublishing . status == 'published' ) {
if ( ! confirm ( I18n . t ( 'confirm.re_publish_grades' , "Are you sure you want to republish these grades to the student information system?" ) ) )
return ;
} else {
if ( ! confirm ( I18n . t ( 'confirm.publish_grades' , "Are you sure you want to publish these grades to the student information system? You should only do this if all your grades have been finalized." ) ) )
return ;
2011-06-21 02:27:54 +08:00
}
2011-10-04 02:18:07 +08:00
var $publish _to _sis _form = $ ( "#publish_to_sis_form" ) ;
GradePublishing . status = "publishing" ;
GradePublishing . update ( { } , true ) ;
var successful _statuses = { "published" : 1 , "publishing" : 1 , "pending" : 1 } ;
var error = function ( data , xhr , status , error ) {
GradePublishing . status = "unknown" ;
$ . flashError ( I18n . t ( 'errors.publish_grades' , "Something went wrong when trying to publish grades to the student information system. Please try again later." ) ) ;
GradePublishing . update ( { } ) ;
} ;
$ . ajaxJSON ( $publish _to _sis _form . attr ( 'action' ) , 'POST' , $publish _to _sis _form . getFormData ( ) , function ( data ) {
if ( ! data . hasOwnProperty ( "sis_publish_status" ) || ! successful _statuses . hasOwnProperty ( data [ "sis_publish_status" ] ) ) {
error ( null , null , I18n . t ( 'errors.invalid_sis_status' , "Invalid SIS publish status" ) , null ) ;
return ;
}
GradePublishing . status = data . sis _publish _status ;
GradePublishing . update ( data . hasOwnProperty ( "sis_publish_messages" ) ? data . sis _publish _messages : { } ) ;
} , error ) ;
2011-04-15 07:49:30 +08:00
}
}
2011-10-04 02:18:07 +08:00
2011-06-21 02:27:54 +08:00
$ ( document ) . ready ( function ( ) {
var $add _section _form = $ ( "#add_section_form" ) ,
$edit _section _form = $ ( "#edit_section_form" ) ,
$course _form = $ ( "#course_form" ) ,
$hashtag _form = $ ( ".hashtag_form" ) ,
$course _hashtag = $ ( "#course_hashtag" ) ,
$enroll _users _form = $ ( "#enroll_users_form" ) ,
$enrollment _dialog = $ ( "#enrollment_dialog" ) ;
$ ( "#course_details_tabs" ) . tabs ( { cookie : { } } ) . show ( ) ;
$add _section _form . formSubmit ( {
required : [ 'course_section[name]' ] ,
beforeSubmit : function ( data ) {
$add _section _form . find ( "button" ) . attr ( 'disabled' , true ) . text ( I18n . t ( 'buttons.adding_section' , "Adding Section..." ) ) ;
} ,
2011-02-01 09:57:29 +08:00
success : function ( data ) {
2011-06-21 02:27:54 +08:00
var section = data . course _section ,
$section = $ ( ".section_blank:first" ) . clone ( true ) . attr ( 'class' , 'section' ) ,
$option = $ ( "<option/>" ) ;
$add _section _form . find ( "button" ) . attr ( 'disabled' , false ) . text ( I18n . t ( 'buttons.add_section' , "Add Section" ) ) ;
$section . fillTemplateData ( {
data : section ,
hrefValues : [ 'id' ]
2011-02-01 09:57:29 +08:00
} ) ;
2011-06-21 02:27:54 +08:00
$ ( "#course_section_id_holder" ) . show ( ) ;
$option . val ( section . id ) . text ( section . name ) . addClass ( 'option_for_section_' + section . id ) ;
$ ( "#sections .section_blank" ) . before ( $section ) ;
$section . slideDown ( ) ;
$ ( "#course_section_name" ) . val ( ) ;
} ,
error : function ( data ) {
$add _section _form
. formErrors ( data )
. find ( "button" ) . attr ( 'disabled' , false ) . text ( I18n . t ( 'errors.section' , "Add Section Failed, Please Try Again" ) ) ;
2011-02-01 09:57:29 +08:00
}
} ) ;
2011-06-21 02:27:54 +08:00
$ ( ".cant_delete_section_link" ) . click ( function ( event ) {
alert ( $ ( this ) . attr ( 'title' ) ) ;
return false ;
} ) ;
$edit _section _form . formSubmit ( {
beforeSubmit : function ( data ) {
$edit _section _form . hide ( ) ;
var $section = $edit _section _form . parents ( ".section" ) ;
$section . find ( ".name" ) . text ( data [ 'course_section[name]' ] ) . show ( ) ;
$section . loadingImage ( { image _size : "small" } ) ;
return $section ;
} ,
success : function ( data , $section ) {
var section = data . course _section ;
$section . loadingImage ( 'remove' ) ;
$ ( ".option_for_section_" + section . id ) . text ( section . name ) ;
} ,
error : function ( data , $section ) {
$section . loadingImage ( 'remove' ) . find ( ".edit_section_link" ) . click ( ) ;
$edit _section _form . formErrors ( data ) ;
}
} )
. find ( ":text" )
. bind ( 'blur' , function ( ) {
$edit _section _form . submit ( ) ;
} )
. keycodes ( 'return esc' , function ( event ) {
if ( event . keyString == 'return' ) {
$edit _section _form . submit ( ) ;
} else {
$ ( this ) . parents ( ".section" ) . find ( ".name" ) . show ( ) ;
$ ( "body" ) . append ( $edit _section _form . hide ( ) ) ;
}
} ) ;
$ ( ".edit_section_link" ) . click ( function ( ) {
var $this = $ ( this ) ,
$section = $this . parents ( ".section" ) ,
data = $section . getTemplateData ( { textValues : [ 'name' ] } ) ;
$edit _section _form . fillFormData ( data , { object _name : "course_section" } ) ;
$section . find ( ".name" ) . hide ( ) . after ( $edit _section _form . show ( ) ) ;
$edit _section _form . attr ( 'action' , $this . attr ( 'href' ) ) ;
$edit _section _form . find ( ":text:first" ) . focus ( ) . select ( ) ;
return false ;
} ) ;
$ ( ".delete_section_link" ) . click ( function ( ) {
$ ( this ) . parents ( ".section" ) . confirmDelete ( {
url : $ ( this ) . attr ( 'href' ) ,
message : I18n . t ( 'confirm.delete_section' , "Are you sure you want to delete this section?" ) ,
success : function ( data ) {
$ ( this ) . slideUp ( function ( ) {
$ ( this ) . remove ( ) ;
} ) ;
2011-02-01 09:57:29 +08:00
}
2011-06-21 02:27:54 +08:00
} ) ;
return false ;
} ) ;
$ ( "#nav_form" ) . submit ( function ( ) {
tab _id _regex = /(\d+)$/ ;
function tab _id _from _el ( el ) {
var tab _id _str = $ ( el ) . attr ( "id" ) ;
if ( tab _id _str ) {
var comps = tab _id _str . split ( '_' ) ;
if ( comps . length > 0 ) {
tab _id = parseInt ( comps . pop ( ) , 10 ) ;
return tab _id ;
}
}
return null ;
2011-02-01 09:57:29 +08:00
}
2011-06-21 02:27:54 +08:00
var tabs = [ ] ;
$ ( "#nav_enabled_list li" ) . each ( function ( ) {
var tab _id = tab _id _from _el ( this ) ;
if ( tab _id !== null ) { tabs . push ( { id : tab _id } ) ; }
} ) ;
$ ( "#nav_disabled_list li" ) . each ( function ( ) {
var tab _id = tab _id _from _el ( this ) ;
if ( tab _id !== null ) { tabs . push ( { id : tab _id , hidden : true } ) ; }
} ) ;
$ ( "#tabs_json" ) . val ( JSON . stringify ( tabs ) ) ;
return true ;
2011-02-01 09:57:29 +08:00
} ) ;
2011-06-21 02:27:54 +08:00
$ ( ".edit_nav_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
$ ( "#nav_form" ) . dialog ( 'close' ) . dialog ( {
modal : true ,
resizable : false ,
width : 400
} ) . dialog ( 'open' ) ;
2011-02-01 09:57:29 +08:00
} ) ;
2011-06-21 02:27:54 +08:00
$ ( "#nav_enabled_list, #nav_disabled_list" ) . sortable ( {
items : 'li.enabled' ,
connectWith : '.connectedSortable' ,
axis : 'y'
} ) . disableSelection ( ) ;
2011-02-01 09:57:29 +08:00
2011-06-21 02:27:54 +08:00
$ ( ".hashtag_dialog_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
$ ( "#hashtag_dialog" ) . dialog ( 'close' ) . dialog ( {
autoOpen : false ,
title : I18n . t ( 'titles.hashtag_help' , "What's a Hashtag?" ) ,
width : 500
} ) . dialog ( 'open' ) ;
} ) ;
$ ( ".close_dialog_button" ) . click ( function ( ) {
$ ( "#hashtag_dialog" ) . dialog ( 'close' ) ;
} ) ;
$ ( "#course_hashtag" ) . bind ( 'blur change keyup' , function ( ) {
var val = $ ( this ) . val ( ) || "" ;
val = val . replace ( /(\s)+/g , "_" ) . replace ( /#/ , "" ) ;
$ ( "#hashtag_options" ) . showIf ( val && val !== "" ) ;
$ ( this ) . val ( val ) ;
} ) ;
$ ( document ) . fragmentChange ( function ( event , hash ) {
function handleFragmentType ( val ) {
$ ( "#tab-users-link" ) . click ( ) ;
$ ( ".add_users_link:visible" ) . click ( ) ;
$ ( "#enroll_users_form select[name='enrollment_type']" ) . val ( val ) ;
2011-02-01 09:57:29 +08:00
}
2011-06-21 02:27:54 +08:00
if ( hash == "#add_students" ) {
handleFragmentType ( "StudentEnrollment" ) ;
} else if ( hash == "#add_tas" ) {
handleFragmentType ( "TaEnrollment" ) ;
} else if ( hash == "#add_teacher" ) {
handleFragmentType ( "TeacherEnrollment" ) ;
}
} ) ;
$ ( ".edit_course_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
$ ( "#course_form" ) . addClass ( 'editing' ) . find ( ":text:first" ) . focus ( ) . select ( ) ;
2011-10-18 05:06:40 +08:00
$ ( "#course_account_id_lookup" ) . autocomplete ( {
source : $ ( "#course_account_id_url" ) . attr ( 'href' ) ,
select : function ( event , ui ) {
$ ( "#course_account_id" ) . val ( ui . item . id ) ;
}
} ) ;
2011-02-01 09:57:29 +08:00
$hashtag _form . showIf ( $course _hashtag . text ( ) . length > 0 ) ;
2011-06-21 02:27:54 +08:00
$course _hashtag . triggerHandler ( 'blur' ) ;
} ) ;
$ ( ".move_course_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
$ ( "#move_course_dialog" ) . dialog ( 'close' ) . dialog ( {
autoOpen : false ,
title : I18n . t ( 'titles.move_course' , "Move Course" ) ,
width : 500
} ) . dialog ( 'open' ) ;
} ) ;
$ ( "#move_course_dialog" ) . delegate ( '.cancel_button' , 'click' , function ( ) {
$ ( "#move_course_dialog" ) . dialog ( 'close' ) ;
} ) ;
$course _form . find ( ".grading_standard_checkbox" ) . change ( function ( ) {
$course _form . find ( ".grading_standard_link" ) . showIf ( $ ( this ) . attr ( 'checked' ) ) ;
} ) . change ( ) ;
$course _form . formSubmit ( {
processData : function ( data ) {
data [ 'course[hashtag]' ] = ( data [ 'course[hashtag]' ] || "" ) . replace ( /\s/g , "_" ) . replace ( /#/g , "" ) ;
if ( data [ 'course[start_at]' ] ) {
data [ 'course[start_at]' ] += " 12:00am" ;
}
if ( data [ 'course[conclude_at]' ] ) {
data [ 'course[conclude_at]' ] += " 11:55pm" ;
}
return data ;
} ,
beforeSubmit : function ( data ) {
$ ( this ) . loadingImage ( ) . removeClass ( 'editing' ) ;
$ ( this ) . find ( ".readable_license,.account_name,.term_name,.grading_scheme_set" ) . text ( "..." ) ;
2011-07-12 05:36:55 +08:00
$ ( this ) . find ( ".storage_quota_mb" ) . text ( data [ 'course[storage_quota_mb]' ] ) ;
2011-06-21 02:27:54 +08:00
$ ( ".course_form_more_options" ) . hide ( ) ;
} ,
success : function ( data ) {
var course = data . course ;
course . start _at = $ . parseFromISO ( course . start _at ) . datetime _formatted ;
course . conclude _at = $ . parseFromISO ( course . conclude _at ) . datetime _formatted ;
course . is _public = course . is _public ? I18n . t ( 'public_course' , 'Public' ) : I18n . t ( 'private_course' , 'Private' ) ;
course . indexed = course . indexed ? I18n . t ( 'indexed_course' , "Included in public course index" ) : "" ;
course . grading _scheme _set = course . grading _standard _title || ( course . grading _standard _id ? I18n . t ( 'grading_standard_set' , "Currently Set" ) : I18n . t ( 'grading_standard_unset' , "Not Set" ) ) ;
2011-09-27 05:03:05 +08:00
course . restrict _dates = course . restrict _enrollments _to _course _dates ? I18n . t ( 'course_dates_enforced' , "Users can only participate in the course between these dates" ) : I18n . t ( 'course_dates_unenforced' , "These dates will not affect course availability" ) ;
2011-07-13 04:31:40 +08:00
course . locale = $ ( "#course_locale option[value='" + ( course . locale || '' ) + "']" ) . text ( ) ;
if ( course . locale != $course _form . find ( '.locale' ) . text ( ) ) {
location . reload ( ) ;
return ;
}
$ ( this ) . loadingImage ( 'remove' ) ;
2011-06-21 02:27:54 +08:00
$ ( "#course_form .public_options" ) . showIf ( course . is _public ) ;
$ ( "#course_form .self_enrollment_message" ) . css ( 'display' , course . self _enrollment ? '' : 'none' ) ;
$ ( "#course_form" ) . fillTemplateData ( { data : course } ) ;
$ ( ".hashtag_form" ) . showIf ( $ ( "#course_hashtag" ) . text ( ) . length > 0 ) ;
} ,
error : function ( data ) {
$ ( this ) . loadingImage ( 'remove' ) ;
$ ( ".edit_course_link" ) . click ( ) ;
$ ( this ) . formErrors ( data ) ;
2011-02-01 09:57:29 +08:00
}
2011-06-21 02:27:54 +08:00
} )
. find ( ".cancel_button" )
. click ( function ( ) {
$course _form . removeClass ( 'editing' ) ;
$hashtag _form . showIf ( $course _hashtag . text ( ) . length > 0 ) ;
$ ( ".course_form_more_options" ) . hide ( ) ;
} ) . end ( )
. find ( ":text:not(.date_entry)" ) . keycodes ( 'esc' , function ( ) {
$course _form . find ( ".cancel_button:first" ) . click ( ) ;
} ) ;
$enroll _users _form . hide ( ) ;
$ ( ".add_users_link" ) . click ( function ( event ) {
$ ( this ) . hide ( ) ;
event . preventDefault ( ) ;
refactor user creation/invitations closes #5833
fixes #5573, #5572, #5753
* communication channels are now only unique within a single user
* UserList changes
* Always resolve pseudonym#unique_ids
* Support looking up by SMS CCs
* Option to either require e-mails match an existing CC,
or e-mails that don't match a Pseudonym will always be
returned unattached (relying on better merging behavior
to not have a gazillion accounts created)
* Method to return users, creating new ones (*without* a
Pseudonym) if necessary. (can't create with a pseudonym,
since Pseudonym#unique_id is still unique, I can't have
multiple outstanding users with the same unique_id)
* EnrollmentsFromUserList is mostly gutted, now using UserList's
functionality directy.
* Use UserList for adding account admins, removing the now
unused Account#add_admin => User#find_by_email/User#assert_by_email
codepath
* Update UsersController#create to not worry about duplicate
communication channels
* Remove AccountsController#add_user, and just use
UsersController#create
* Change SIS::UserImporter to send out a merge opportunity
e-mail if a conflicting CC is found (but still create the CC)
* In /profile, don't worry about conflicting CCs (the CC confirmation
process will now allow merging)
* Remove CommunicationChannelsController#try_merge and #merge
* For the non-simple case of CoursesController#enrollment_invitation
redirect to /register (CommunicationsChannelController#confirm)
* Remove CoursesController#transfer_enrollment
* Move PseudonymsController#registration_confirmation to
CommunicationChannelsController#confirm (have to be able to
register an account without a Pseudonym yet)
* Fold the old direct confirm functionality in, if there are
no available merge opportunities
* Allow merging the new account with the currently logged in user
* Allow changing the Pseudonym#unique_id when registering a new
account (since there might be conflicts)
* Display a list of merge opportunities based on conflicting
communication channels
* Provide link(s) to log in as the other user,
redirecting back to the registration page after login is
complete (to complete the merge as the current user)
* Remove several assert_* methods that are no longer needed
* Update PseudonymSessionsController a bit to deal with the new
way of dealing with conflicting CCs (especially CCs from LDAP),
and to redirect back to the registration/confirmation page when
attempting to do a merge
* Expose the open_registration setting; use it to control if
inviting users to a course is able to create new users
Change-Id: If2f38818a71af656854d3bf8431ddbf5dcb84691
Reviewed-on: https://gerrit.instructure.com/6149
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
2011-10-13 04:30:48 +08:00
$enroll _users _form . show ( ) ;
2011-06-21 02:27:54 +08:00
$ ( "html,body" ) . scrollTo ( $enroll _users _form ) ;
$enroll _users _form . find ( "textarea" ) . focus ( ) . select ( ) ;
} ) ;
$ ( ".associate_user_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
var $user = $ ( this ) . parents ( ".user" ) ;
var data = $user . getTemplateData ( { textValues : [ 'name' , 'associated_user_id' , 'id' ] } ) ;
link _enrollment . choose ( data . name , data . id , data . associated _user _id , function ( enrollment ) {
if ( enrollment ) {
var user _name = enrollment . associated _user _name ;
$ ( "#enrollment_" + enrollment . id )
. find ( ".associated_user.associated" ) . showIf ( enrollment . associated _user _id ) . end ( )
. find ( ".associated_user.unassociated" ) . showIf ( ! enrollment . associated _user _id ) . end ( )
. fillTemplateData ( { data : enrollment } ) ;
}
} ) ;
} ) ;
$ ( ".course_info" ) . attr ( 'title' , I18n . t ( 'titles.click_to_edit' , 'Click to Edit' ) ) . click ( function ( event ) {
if ( event . target . nodeName == "INPUT" ) {
return ;
}
$ ( ".edit_course_link:first" ) . click ( ) ;
var $obj = $ ( this ) . parents ( "td" ) . find ( ".course_form" ) ;
if ( $obj . length ) {
$obj . focus ( ) . select ( ) ;
}
} ) ;
$ ( ".course_form_more_options_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
$ ( ".course_form_more_options" ) . slideToggle ( ) ;
} ) ;
$ ( ".user_list" ) . delegate ( '.user' , 'mouseover' , function ( event ) {
var $this = $ ( this ) ,
title = $this . attr ( 'title' ) ,
pending _message = I18n . t ( 'details.re_send_invitation' , "This user has not yet accepted their invitation. Click to re-send invitation." ) ;
if ( title != pending _message ) {
$this . data ( 'real_title' , title ) ;
}
if ( $this . hasClass ( 'pending' ) ) {
$this . attr ( 'title' , pending _message ) . css ( 'cursor' , 'pointer' ) ;
} else {
$this . attr ( 'title' , $ ( this ) . data ( 'real_title' ) || I18n . t ( 'defaults.user_name' , "User" ) ) . css ( 'cursor' , '' ) ;
}
} ) ;
$enrollment _dialog . find ( ".cancel_button" ) . click ( function ( ) {
$enrollment _dialog . dialog ( 'close' ) ;
2011-02-11 06:38:47 +08:00
} ) ;
2011-02-01 09:57:29 +08:00
2011-06-21 02:27:54 +08:00
$ ( ".user_list" ) . delegate ( '.user_information_link' , 'click' , function ( event ) {
var $this = $ ( this ) ,
$user = $this . closest ( '.user' ) ,
pending = $user . hasClass ( 'pending' ) ,
data = $user . getTemplateData ( { textValues : [ 'name' , 'invitation_sent_at' ] } ) ,
admin = $user . parents ( ".teacher_enrollments,.ta_enrollments" ) . length > 0 ;
data . re _send _invitation _link = I18n . t ( 'links.re_send_invitation' , "Re-Send Invitation" ) ;
$enrollment _dialog
. data ( 'user' , $user )
. find ( ".re_send_invitation_link" )
. attr ( 'href' , $user . find ( ".re_send_confirmation_url" ) . attr ( 'href' ) ) . end ( )
. find ( ".student_enrollment_re_send" ) . showIf ( pending && ! admin ) . end ( )
. find ( ".admin_enrollment_re_send" ) . showIf ( pending && admin ) . end ( )
. find ( ".accepted_enrollment_re_send" ) . showIf ( ! pending ) . end ( )
. find ( ".invitation_sent_at" ) . showIf ( pending ) . end ( )
. fillTemplateData ( { data : data } )
. dialog ( 'close' )
. dialog ( { autoOpen : false , title : I18n . t ( 'titles.enrollment_details' , "Enrollment Details" ) } )
. dialog ( 'open' ) ;
return false ;
} ) ;
$ ( '.user_list .edit_section_link' ) . click ( function ( event ) {
event . preventDefault ( ) ;
var $this = $ ( this ) ;
$user = $this . closest ( '.user' ) ;
$user . find ( '.section' ) . toggle ( ) ;
$user . find ( '.enrollment_course_section_form' ) . toggle ( ) ;
} ) ;
$ ( '.user_list .enrollment_course_section_form #course_section_id' ) . change ( function ( event ) {
var form = $ ( this ) . parent ( 'form' ) ;
var $this = $ ( this )
var section = form . prev ( '.section' )
$ . ajaxJSON ( form . attr ( 'action' ) , 'POST' , form . getFormData ( ) , function ( data ) {
section . html ( $this . find ( 'option[value="' + $this . val ( ) + '"]' ) . html ( ) ) ;
section . toggle ( ) ;
form . toggle ( ) ;
} , function ( data ) {
$ . flashError ( I18n . t ( 'errors.move_user' , "Something went wrong moving the user to the new section. Please try again later." ) ) ;
} ) ;
} ) ;
2011-02-01 09:57:29 +08:00
2011-06-21 02:27:54 +08:00
$enrollment _dialog . find ( ".re_send_invitation_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
var $link = $ ( this ) ;
$link . text ( I18n . t ( 'links.re_sending_invitation' , "Re-Sending Invitation..." ) ) ;
var url = $link . attr ( 'href' ) ;
$ . ajaxJSON ( url , 'POST' , { } , function ( data ) {
$enrollment _dialog . fillTemplateData ( { data : { invitation _sent _at : I18n . t ( 'invitation_sent_now' , "Just Now" ) } } ) ;
$link . text ( I18n . t ( 'invitation_sent' , "Invitation Sent!" ) ) ;
var $user = $enrollment _dialog . data ( 'user' ) ;
if ( $user ) {
$user . fillTemplateData ( { data : { invitation _sent _at : I18n . t ( 'invitation_sent_now' , "Just Now" ) } } ) ;
}
} , function ( data ) {
$link . text ( I18n . t ( 'errors.invitation' , "Invitation Failed. Please try again." ) ) ;
} ) ;
2011-05-24 03:57:32 +08:00
} ) ;
2011-06-21 02:27:54 +08:00
$ ( ".date_entry" ) . date _field ( ) ;
$ ( ) . data ( 'current_default_wiki_editing_roles' , $ ( "#course_default_wiki_editing_roles" ) . val ( ) ) ;
$ ( "#course_default_wiki_editing_roles" ) . change ( function ( ) {
var $this = $ ( this ) ;
$ ( ".changed_default_wiki_editing_roles" ) . showIf ( $this . val ( ) != $ ( ) . data ( 'current_default_wiki_editing_roles' ) ) ;
$ ( ".default_wiki_editing_roles_change" ) . text ( $this . find ( ":selected" ) . text ( ) ) ;
2011-02-01 09:57:29 +08:00
} ) ;
2011-06-21 02:27:54 +08:00
$ ( ".re_send_invitations_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
var $button = $ ( this ) ,
oldText = I18n . t ( 'links.re_send_all' , "Re-Send All Unaccepted Invitations" ) ;
$button . text ( I18n . t ( 'buttons.re_sending_all' , "Re-Sending Unaccepted Invitations..." ) ) . attr ( 'disabled' , true ) ;
$ . ajaxJSON ( $button . attr ( 'href' ) , 'POST' , { } , function ( data ) {
$button . text ( I18n . t ( 'buttons.re_sent_all' , "Re-Sent All Unaccepted Invitations!" ) ) . attr ( 'disabled' , false ) ;
$ ( ".user_list .user.pending" ) . each ( function ( ) {
var $user = $ ( this ) ;
$user . fillTemplateData ( { data : { invitation _sent _at : I18n . t ( 'invitation_sent_now' , "Just Now" ) } } ) ;
} ) ;
setTimeout ( function ( ) {
$button . text ( oldText ) ;
} , 2500 ) ;
} , function ( ) {
$button . text ( I18n . t ( 'errors.re_send_all' , "Send Failed, Please Try Again" ) ) . attr ( 'disabled' , false ) ;
2011-02-01 09:57:29 +08:00
} ) ;
} ) ;
2011-06-21 02:27:54 +08:00
$ ( "#enrollment_type" ) . change ( function ( ) {
$ ( ".teacherless_invite_message" ) . showIf ( $ ( this ) . find ( ":selected" ) . hasClass ( 'teacherless_invite' ) ) ;
} ) ;
$ ( ".is_public_checkbox" ) . change ( function ( ) {
$ ( ".public_options" ) . showIf ( $ ( this ) . attr ( 'checked' ) ) ;
} ) . change ( ) ;
$ ( ".self_enrollment_checkbox" ) . change ( function ( ) {
$ ( ".open_enrollment_holder" ) . showIf ( $ ( this ) . attr ( 'checked' ) ) ;
} ) . change ( ) ;
2011-04-15 07:49:30 +08:00
2011-06-21 02:27:54 +08:00
$ ( "#publish_grades_link" ) . click ( function ( event ) {
event . preventDefault ( ) ;
2011-10-04 02:18:07 +08:00
GradePublishing . publish ( ) ;
2011-06-21 02:27:54 +08:00
} ) ;
if ( typeof ( sisPublishEnabled ) != 'undefined' && sisPublishEnabled ) {
2011-10-04 02:18:07 +08:00
GradePublishing . checkup ( ) ;
2011-06-21 02:27:54 +08:00
}
2011-10-04 02:18:07 +08:00
2011-08-23 06:25:28 +08:00
$ ( ".reset_course_content_button" ) . click ( function ( event ) {
event . preventDefault ( ) ;
$ ( "#reset_course_content_dialog" ) . dialog ( 'close' ) . dialog ( {
autoOpen : false ,
title : I18n . t ( 'titles.reset_course_content_dialog_help' , "Reset Course Content" ) ,
width : 500
} ) . dialog ( 'open' ) ;
} ) ;
$ ( "#reset_course_content_dialog .cancel_button" ) . click ( function ( ) {
$ ( "#reset_course_content_dialog" ) . dialog ( 'close' ) ;
} ) ;
2011-04-15 07:49:30 +08:00
2011-06-21 02:27:54 +08:00
$ . scrollSidebar ( ) ;
} ) ;
2011-02-01 09:57:29 +08:00
} ) ;