return'<div><div class="message message-confirmation"><h3 class="message-title">Success</h3><div class="message-copy"><p>All accounts were created successfully.</p></div></div><div>'
return'<div><div class="message message-warning"><h3 class="message-title">Warnings</h3><div class="message-copy"><p>The following warnings were generated:</p><ul class="list-summary summary-items"><li class="summary-item">user1 (user1email): (email is in valid)</li></ul></div></div></div>'
expect(window.alert).toHaveBeenCalledWith("Your message must have at least one target.")
expect($.ajax).not.toHaveBeenCalled()
it'cannot send an email with no subject',->
spyOn(window,"alert")
spyOn($,"ajax")
@send_email.$subject.val("")
@send_email.$btn_send.click()
expect(window.alert).toHaveBeenCalledWith("Your message must have a subject.")
expect($.ajax).not.toHaveBeenCalled()
it'cannot send an email with no message',->
spyOn(window,"alert")
spyOn($,"ajax")
@send_email.$emailEditor=
save:->
{"data":""}
@send_email.$btn_send.click()
expect(window.alert).toHaveBeenCalledWith("Your message cannot be blank.")
expect($.ajax).not.toHaveBeenCalled()
it'can send a simple message to a single target',->
spyOn($,"ajax").and.callFake((params)=>
params.success()
)
@send_email.$btn_send.click()
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.')
expect($.ajax).toHaveBeenCalledWith(@ajax_params)
it'can send a simple message to a multiple targets',->
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.')
expect($.ajax).toHaveBeenCalledWith(@ajax_params)
it'can handle an error result from the bulk email api',->
msg=gettext("Could not find a user with username or email address '<%- identifier %>'.");
returnthis.show_errors(_.template(msg,{
identifier:data.unique_student_identifier
}));
}elseif(data.inactiveUser){
msg=gettext("Error: User '<%- username %>' has not yet activated their account. Users must create and activate their accounts before they can be assigned a role.");// eslint-disable-line max-len
returnthis.show_errors(_.template(msg,{
username:data.unique_student_identifier
}));
}elseif(data.removingSelfAsInstructor){
returnthis.show_errors(
gettext('Error: You cannot remove yourself from the Instructor group!')
`// Translators: A list of users appears after this sentence. This situation arises when a staff member tries to unenroll a user who is not currently enrolled in this course.`
gettext("Everyone who has staff privileges in this course")
elseifvalue=="learners"
gettext("All learners who are enrolled in this course")
else
gettext("All learners in the {cohort_name} cohort").replace('{cohort_name}',value.slice(value.indexOf(':')+1))
success_message=gettext("Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.")
confirm_message=gettext("You are sending an email message with the subject {subject} to the following recipients.")
successMessage=gettext('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.');// eslint-disable-line max-len
confirmMessage=gettext(
'You are sending an email message with the subject {subject} to the following recipients.');
gettext('Please enter a student email address or username.')
);
}
errorMessage=gettext("Error getting student progress url for '<%- student_id %>'. Make sure that the student identifier is spelled correctly.");// eslint-disable-line max-len
gettext('Please enter a student email address or username.')
);
}
if(!problemToReset){
returnstudentadmin.$request_err_grade.text(gettext('Please enter a problem location.'));
}
sendData={
unique_student_identifier:uniqStudentIdentifier,
problem_to_reset:problemToReset,
delete_module:false
success_message=gettext("Success! Problem attempts reset for problem '<%= problem_id %>' and student '<%= student_id %>'.")
error_message=gettext("Error resetting problem attempts for problem '<%= problem_id %>' and student '<%= student_id %>'. Make sure that the problem and student identifiers are complete and correct.")
successMessage=gettext("Success! Problem attempts reset for problem '<%- problem_id %>' and student '<%- student_id %>'.");// eslint-disable-line max-len
errorMessage=gettext("Error resetting problem attempts for problem '<%= problem_id %>' and student '<%- student_id %>'. Make sure that the problem and student identifiers are complete and correct.");// eslint-disable-line max-len
error_message=gettext("Error deleting student '<%= student_id %>'s state on problem '<%= problem_id %>'. Make sure that the problem and student identifiers are complete and correct.")
success_message=gettext("Started rescore problem task for problem '<%= problem_id %>' and student '<%= student_id %>'. Click the 'Show Background Task History for Student' button to see the status of the task.")
error_message=gettext("Error starting a task to rescore problem '<%= problem_id %>' for student '<%= student_id %>'. Make sure that the the problem and student identifiers are complete and correct.")
error_message=gettext("Error getting task history for problem '<%= problem_id %>' and student '<%= student_id %>'. Make sure that the problem and student identifiers are complete and correct.")
errorMessage=gettext("Error deleting student '<%- student_id %>'s state on problem '<%- problem_id %>'. Make sure that the problem and student identifiers are complete and correct.");// eslint-disable-line max-len
gettext('Please enter a student email address or username.')
);
}
if(!problemToReset){
returnstudentadmin.$request_err_grade.text(
gettext('Please enter a problem location.')
);
}
sendData={
unique_student_identifier:uniqStudentIdentifier,
problem_to_reset:problemToReset
};
successMessage=gettext("Started rescore problem task for problem '<%- problem_id %>' and student '<%- student_id %>'. Click the 'Show Background Task History for Student' button to see the status of the task.");// eslint-disable-line max-len
fullSuccessMessage=_.template(successMessage)({
student_id:uniqStudentIdentifier,
problem_id:problemToReset
});
errorMessage=gettext("Error starting a task to rescore problem '<%- problem_id %>' for student '<%- student_id %>'. Make sure that the the problem and student identifiers are complete and correct.");// eslint-disable-line max-len
gettext('Please enter a student email address or username.')
);
}
if(!problemToReset){
returnstudentadmin.$request_err_grade.text(
gettext('Please enter a problem location.')
);
}
sendData={
unique_student_identifier:uniqStudentIdentifier,
problem_location_str:problemToReset
};
errorMessage=gettext("Error getting task history for problem '<%- problem_id %>' and student '<%- student_id %>'. Make sure that the problem and student identifiers are complete and correct.");// eslint-disable-line max-len
success_message=gettext("Started entrance exam rescore task for student '{student_id}'. Click the 'Show Background Task History for Student' button to see the status of the task.")
error_message=gettext("Error starting a task to rescore entrance exam for student '{student_id}'. Make sure that entrance exam has problems in it and student identifier is correct.")
successMessage=gettext("Started entrance exam rescore task for student '{student_id}'. Click the 'Show Background Task History for Student' button to see the status of the task.");// eslint-disable-line max-len
errorMessage=gettext("Error starting a task to rescore entrance exam for student '{student_id}'. Make sure that entrance exam has problems in it and student identifier is correct.");// eslint-disable-line max-len
errorMessage=gettext("An error occurred. Make sure that the student's username or email address is correct and try again.");// eslint-disable-line max-len
success_message=gettext("Successfully started task to reset attempts for problem '<%= problem_id %>'. Click the 'Show Background Task History for Problem' button to see the status of the task.")
error_message=gettext("Error starting a task to reset attempts for all students on problem '<%= problem_id %>'. Make sure that the problem identifier is complete and correct.")
success_message=gettext("Successfully started task to rescore problem '<%= problem_id %>' for all students. Click the 'Show Background Task History for Problem' button to see the status of the task.")
errorMessage=gettext("Error deleting entrance exam state for student '{student_id}'. Make sure student identifier is correct.");// eslint-disable-line max-len
errorMessage=gettext("Error getting entrance exam task history for student '{student_id}'. Make sure student identifier is correct.");// eslint-disable-line max-len
successMessage=gettext("Successfully started task to reset attempts for problem '<%- problem_id %>'. Click the 'Show Background Task History for Problem' button to see the status of the task.");// eslint-disable-line max-len
fullSuccessMessage=_.template(successMessage)({
problem_id:problemToReset
});
errorMessage=gettext("Error starting a task to reset attempts for all students on problem '<%- problem_id %>'. Make sure that the problem identifier is complete and correct.");// eslint-disable-line max-len
successMessage=gettext("Successfully started task to rescore problem '<%- problem_id %>' for all students. Click the 'Show Background Task History for Problem' button to see the status of the task.");// eslint-disable-line max-len
fullSuccessMessage=_.template(successMessage)({
problem_id:problemToReset
});
errorMessage=gettext("Error starting a task to rescore problem '<%- problem_id %>'. Make sure that the problem identifier is complete and correct.");// eslint-disable-line max-len
ifvalueisnullthenreturngettext("An error occurred retrieving your email. Please try again later, and contact technical support if the problem persists.")
returngettext('An error occurred retrieving your email. Please try again later, and contact technical support if the problem persists.');// eslint-disable-line max-len
toolTip:gettext('Links are generated on demand and expire within 5 minutes due to the sensitive nature of student information.'),// eslint-disable-line max-len
return'<div><div class="message message-warning"><h3 class="message-title">Warnings</h3><div class="message-copy"><p>The following warnings were generated:</p><ul class="list-summary summary-items"><li class="summary-item">user1 (user1email): (email is in valid)</li></ul></div></div></div>';// eslint-disable-line max-len
it('cannot send an email with no target',function(){
vartarget,i,len,ref;
spyOn(window,'alert');
spyOn($,'ajax');
ref=this.send_email.$send_to;
for(i=0,len=ref.length;i<len;i++){
target=ref[i];
target.checked=false;
}
this.send_email.$btn_send.click();
expect(window.alert).toHaveBeenCalledWith('Your message must have at least one target.');
returnexpect($.ajax).not.toHaveBeenCalled();
});
it('cannot send an email with no subject',function(){
spyOn(window,'alert');
spyOn($,'ajax');
this.send_email.$subject.val('');
this.send_email.$btn_send.click();
expect(window.alert).toHaveBeenCalledWith('Your message must have a subject.');
returnexpect($.ajax).not.toHaveBeenCalled();
});
it('cannot send an email with no message',function(){
spyOn(window,'alert');
spyOn($,'ajax');
this.send_email.$emailEditor={
save:function(){
return{
data:''
};
}
};
this.send_email.$btn_send.click();
expect(window.alert).toHaveBeenCalledWith('Your message cannot be blank.');
returnexpect($.ajax).not.toHaveBeenCalled();
});
it('can send a simple message to a single target',function(){
spyOn($,'ajax').and.callFake(function(params){
returnparams.success();
});
this.send_email.$btn_send.click();
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.');// eslint-disable-line max-len
expect($('.msg-confirm').text()).toEqual('Your email message was successfully queued for sending. In courses with a large number of learners, email messages to learners might take up to an hour to be sent.');// eslint-disable-line max-len