version 1.162, 2014/02/14 17:44:00
|
version 1.170, 2015/06/09 21:22:57
|
Line 450 sub javascript_validations {
|
Line 450 sub javascript_validations {
|
if (($mode eq 'upload') && ($context eq 'domain')) { |
if (($mode eq 'upload') && ($context eq 'domain')) { |
$alert{'inststatus'} = &mt('The optional affiliation field was not specified'); |
$alert{'inststatus'} = &mt('The optional affiliation field was not specified'); |
} |
} |
|
&js_escape(\%alert); |
my $function_name = <<"END"; |
my $function_name = <<"END"; |
$setsections_js |
$setsections_js |
|
|
Line 642 sub upload_manager_javascript_forward_as
|
Line 643 sub upload_manager_javascript_forward_as
|
$numbuttons ++; |
$numbuttons ++; |
} |
} |
if (!$can_assign->{'int'}) { |
if (!$can_assign->{'int'}) { |
my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.').'\n'. |
my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.')."\n". |
&mt('Your current role does not have rights to create users with that authentication type.'); |
&mt('Your current role does not have rights to create users with that authentication type.'); |
|
&js_escape(\$warning); |
$auth_update = <<"END"; |
$auth_update = <<"END"; |
// Currently the initial password field is only supported for internal auth |
// Currently the initial password field is only supported for internal auth |
// (see bug 6368). |
// (see bug 6368). |
Line 781 sub upload_manager_javascript_reverse_as
|
Line 783 sub upload_manager_javascript_reverse_as
|
if (!$can_assign->{'int'}) { |
if (!$can_assign->{'int'}) { |
my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n'). |
my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n'). |
&mt('Your current role does not have rights to create users with that authentication type.'); |
&mt('Your current role does not have rights to create users with that authentication type.'); |
|
&js_escape(\$warning); |
$auth_update = <<"END"; |
$auth_update = <<"END"; |
// Currently the initial password field is only supported for internal auth |
// Currently the initial password field is only supported for internal auth |
// (see bug 6368). |
// (see bug 6368). |
Line 1081 sub forceid_change {
|
Line 1084 sub forceid_change {
|
my ($context) = @_; |
my ($context) = @_; |
my $output = |
my $output = |
'<label><input type="checkbox" name="forceid" value="yes" />' |
'<label><input type="checkbox" name="forceid" value="yes" />' |
.&mt('Disable Student/Employee ID Safeguard and force change of conflicting IDs') |
.&mt('Force change of existing ID') |
.'</label><br />'."\n" |
.'</label>'.&Apache::loncommon::help_open_topic('ForceIDChange')."\n"; |
.&mt('(only do if you know what you are doing.)')."\n"; |
|
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$output .= '<br /><label><input type="checkbox" name="recurseid"'. |
$output .= |
' value="yes" />'. |
'<br />' |
&mt('Update student/employee ID in courses in which user is active/future student,[_1](if forcing change).','<br />'). |
.'<label><input type="checkbox" name="recurseid" value="yes" />' |
'</label>'."\n"; |
.&mt("Update ID in user's course(s).").'</label>'."\n"; |
} |
} |
return $output; |
return $output; |
} |
} |
Line 3174 sub bulkaction_javascript {
|
Line 3176 sub bulkaction_javascript {
|
my $noaction = &mt("You need to select an action to take for the user(s) you have selected"); |
my $noaction = &mt("You need to select an action to take for the user(s) you have selected"); |
my $singconfirm = &mt(' for a single user?'); |
my $singconfirm = &mt(' for a single user?'); |
my $multconfirm = &mt(' for multiple users?'); |
my $multconfirm = &mt(' for multiple users?'); |
|
&js_escape(\$alert); |
|
&js_escape(\$noaction); |
|
&js_escape(\$singconfirm); |
|
&js_escape(\$multconfirm); |
my $output = <<"ENDJS"; |
my $output = <<"ENDJS"; |
function verify_action (field) { |
function verify_action (field) { |
var numchecked = 0; |
var numchecked = 0; |
Line 5216 sub active_student_roles {
|
Line 5222 sub active_student_roles {
|
|
|
sub section_check_js { |
sub section_check_js { |
my $groupslist= &get_groupslist(); |
my $groupslist= &get_groupslist(); |
|
my %js_lt = &Apache::lonlocal::texthash( |
|
mayn => 'may not be used as the name for a section, as it is a reserved word.', |
|
plch => 'Please choose a different section name.', |
|
mnot => 'may not be used as a section name, as it is the name of a course group.', |
|
secn => 'Section names and group names must be distinct. Please choose a different section name.', |
|
); |
|
&js_escape(\%js_lt); |
return <<"END"; |
return <<"END"; |
function validate(caller) { |
function validate(caller) { |
var groups = new Array($groupslist); |
var groups = new Array($groupslist); |
var secname = caller.value; |
var secname = caller.value; |
if ((secname == 'all') || (secname == 'none')) { |
if ((secname == 'all') || (secname == 'none')) { |
alert("'"+secname+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name."); |
alert("'"+secname+"' $js_lt{'mayn'}\\n$js_lt{'plch'}"); |
return 'error'; |
return 'error'; |
} |
} |
if (secname != '') { |
if (secname != '') { |
for (var k=0; k<groups.length; k++) { |
for (var k=0; k<groups.length; k++) { |
if (secname == groups[k]) { |
if (secname == groups[k]) { |
alert("'"+secname+"' may not be used as the name for a section, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name."); |
alert("'"+secname+"' $js_lt{'mnot'}\\n$js_lt{'secn'}"); |
return 'error'; |
return 'error'; |
} |
} |
} |
} |
Line 5268 sub set_login {
|
Line 5281 sub set_login {
|
sub course_sections { |
sub course_sections { |
my ($sections_count,$role,$current_sec) = @_; |
my ($sections_count,$role,$current_sec) = @_; |
my $output = ''; |
my $output = ''; |
my @sections = (sort {$a <=> $b} keys %{$sections_count}); |
my @sections = (sort {$a <=> $b} keys(%{$sections_count})); |
my $numsec = scalar(@sections); |
my $numsec = scalar(@sections); |
my $is_selected = ' selected="selected"'; |
my $is_selected = ' selected="selected"'; |
if ($numsec <= 1) { |
if ($numsec <= 1) { |
Line 5352 sub setsections_javascript {
|
Line 5365 sub setsections_javascript {
|
} |
} |
$rolecode = "var match = str.split('_'); |
$rolecode = "var match = str.split('_'); |
var role = match[3];\n"; |
var role = match[3];\n"; |
} elsif ($formname eq 'enrollstudent') { |
} elsif (($formname eq 'enrollstudent') || ($formname eq 'selfenroll')) { |
$checkincluded = 'formname.name == "'.$formname.'"'; |
$checkincluded = 'formname.name == "'.$formname.'"'; |
if ($checkauth) { |
if ($checkauth) { |
$finish = "var authcheck = auth_check();\n". |
$finish = "var authcheck = auth_check();\n". |
Line 5386 sub setsections_javascript {
|
Line 5399 sub setsections_javascript {
|
mnot => 'may not be used as a section name, as it is the name of a course group.', |
mnot => 'may not be used as a section name, as it is the name of a course group.', |
secn => 'Section names and group names must be distinct. Please choose a different section name.', |
secn => 'Section names and group names must be distinct. Please choose a different section name.', |
nonw => 'Section names may only contain letters or numbers.', |
nonw => 'Section names may only contain letters or numbers.', |
); |
); |
|
&js_escape(\%alerts); |
$setsection_js .= <<"ENDSECCODE"; |
$setsection_js .= <<"ENDSECCODE"; |
|
|
function setSections(formname,crstype) { |
function setSections(formname,crstype) { |
Line 5397 function setSections(formname,crstype) {
|
Line 5411 function setSections(formname,crstype) {
|
var groups = new Array($groupslist); |
var groups = new Array($groupslist); |
for (var i=0;i<formname.elements.length;i++) { |
for (var i=0;i<formname.elements.length;i++) { |
var str = formname.elements[i].name; |
var str = formname.elements[i].name; |
|
if (typeof(str) === "undefined") { |
|
continue; |
|
} |
var checkcurr = str.match(re1); |
var checkcurr = str.match(re1); |
if (checkcurr != null) { |
if (checkcurr != null) { |
var num = i; |
var num = i; |
Line 5702 sub get_permission {
|
Line 5719 sub get_permission {
|
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
$permission{'grp_manage'} = 1; |
$permission{'grp_manage'} = 1; |
} |
} |
|
if ($permission{'cusr'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my %coursehash = ( |
|
'internal.selfenrollmgrdc' => $env{'course.'.$env{'request.course.id'}.'.internal.selfenrollmgrdc'}, |
|
'internal.selfenrollmgrcc' => $env{'course.'.$env{'request.course.id'}.'.internal.selfenrollmgrcc'}, |
|
'internal.coursecode' => $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}, |
|
'internal.textbook' =>$env{'course.'.$env{'request.course.id'}.'.internal.textbook'}, |
|
); |
|
my ($managed_by_cc,$managed_by_dc) = &selfenrollment_administration($cdom,$cnum,$crstype,\%coursehash); |
|
if (ref($managed_by_cc) eq 'ARRAY') { |
|
if (@{$managed_by_cc}) { |
|
$permission{'selfenrolladmin'} = 1; |
|
} |
|
} |
|
} |
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
$permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'}); |
$permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'}); |
$permission{'view'} = $permission{'cusr'}; |
$permission{'view'} = $permission{'cusr'}; |
Line 6004 sub sectioncheck_alerts {
|
Line 6037 sub sectioncheck_alerts {
|
thwa => 'There was a problem with your course selection', |
thwa => 'There was a problem with your course selection', |
thwc => 'There was a problem with your community selection', |
thwc => 'There was a problem with your community selection', |
); |
); |
|
&js_escape(\%alerts); |
return %alerts; |
return %alerts; |
} |
} |
|
|
Line 6014 sub authcheck_alerts {
|
Line 6048 sub authcheck_alerts {
|
krb => 'You need to specify the Kerberos domain.', |
krb => 'You need to specify the Kerberos domain.', |
ipass => 'You need to specify the initial password.', |
ipass => 'You need to specify the initial password.', |
); |
); |
|
&js_escape(\%alerts); |
return %alerts; |
return %alerts; |
} |
} |
|
|
Line 6032 sub is_courseowner {
|
Line 6067 sub is_courseowner {
|
return; |
return; |
} |
} |
|
|
|
sub get_selfenroll_titles { |
|
my @row = ('types','registered','enroll_dates','access_dates','section', |
|
'approval','limit'); |
|
my %lt = &Apache::lonlocal::texthash ( |
|
types => 'Users allowed to self-enroll', |
|
registered => 'Registration status (official courses)' , |
|
enroll_dates => 'Dates self-enrollment available', |
|
access_dates => 'Access dates for self-enrolling users', |
|
section => "Self-enrolling users' section", |
|
approval => 'Processing of requests', |
|
limit => 'Enrollment limit', |
|
); |
|
return (\@row,\%lt); |
|
} |
|
|
|
sub selfenroll_default_descs { |
|
my %desc = ( |
|
types => { |
|
dom => &mt('Course domain'), |
|
all => &mt('Any domain'), |
|
'' => &mt('None'), |
|
}, |
|
limit => { |
|
none => &mt('No limit'), |
|
allstudents => &mt('Limit by total students'), |
|
selfenrolled => &mt('Limit by total self-enrolled'), |
|
}, |
|
approval => { |
|
'0' => &mt('Processed automatically'), |
|
'1' => &mt('Queued for approval'), |
|
'2' => &mt('Queued, pending validation'), |
|
}, |
|
registered => { |
|
0 => 'No registration required', |
|
1 => 'Registered students only', |
|
}, |
|
); |
|
return %desc; |
|
} |
|
|
|
sub selfenroll_validation_types { |
|
my @items = ('url','fields','button','markup'); |
|
my %names = &Apache::lonlocal::texthash ( |
|
url => 'Web address of validation server/script', |
|
fields => 'Form fields to send to validator', |
|
button => 'Text for validation button', |
|
markup => 'Validation description (HTML)', |
|
); |
|
my @fields = ('username','domain','uniquecode','course','coursetype','description'); |
|
return (\@items,\%names,\@fields); |
|
} |
|
|
|
sub get_extended_type { |
|
my ($cdom,$cnum,$crstype,$current) = @_; |
|
my $type = 'unofficial'; |
|
my %settings; |
|
if (ref($current) eq 'HASH') { |
|
%settings = %{$current}; |
|
} else { |
|
%settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook'],$cdom,$cnum); |
|
} |
|
if ($crstype eq 'Community') { |
|
$type = 'community'; |
|
} elsif ($settings{'internal.coursecode'}) { |
|
$type = 'official'; |
|
} elsif ($settings{'internal.textbook'}) { |
|
$type = 'textbook'; |
|
} |
|
return $type; |
|
} |
|
|
|
sub selfenrollment_administration { |
|
my ($cdom,$cnum,$crstype,$coursehash) = @_; |
|
my %settings; |
|
if (ref($coursehash) eq 'HASH') { |
|
%settings = %{$coursehash}; |
|
} else { |
|
%settings = &Apache::lonnet::get('environment', |
|
['internal.selfenrollmgrdc','internal.selfenrollmgrcc', |
|
'internal.coursecode','internal.textbook'],$cdom,$cnum); |
|
} |
|
my ($possconfigs) = &get_selfenroll_titles(); |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
|
my $selfenrolltype = &get_extended_type($cdom,$cnum,$crstype,\%settings); |
|
|
|
my (@in_course,@in_domain); |
|
if ($settings{'internal.selfenrollmgrcc'} ne '') { |
|
@in_course = split(/,/,$settings{'internal.selfenrollmgrcc'}); |
|
my @diffs = &Apache::loncommon::compare_arrays($possconfigs,\@in_course); |
|
unless (@diffs) { |
|
return (\@in_course,\@in_domain); |
|
} |
|
} |
|
if ($settings{'internal.selfenrollmgrdc'} ne '') { |
|
my @in_domain = split(/,/,$settings{'internal.selfenrollmgrdc'}); |
|
my @diffs = &Apache::loncommon::compare_arrays(\@in_domain,$possconfigs); |
|
unless (@diffs) { |
|
return (\@in_course,\@in_domain); |
|
} |
|
} |
|
my @combined = @in_course; |
|
push(@combined,@in_domain); |
|
my @diffs = &Apache::loncommon::compare_arrays(\@combined,$possconfigs); |
|
unless (@diffs) { |
|
return (\@in_course,\@in_domain); |
|
} |
|
if ($domdefaults{$selfenrolltype.'selfenrolladmdc'} eq '') { |
|
push(@in_course,@diffs); |
|
} else { |
|
my @defaultdc = split(/,/,$domdefaults{$selfenrolltype.'selfenrolladmdc'}); |
|
foreach my $item (@diffs) { |
|
if (grep(/^\Q$item\E$/,@defaultdc)) { |
|
push(@in_domain,$item); |
|
} else { |
|
push(@in_course,$item); |
|
} |
|
} |
|
} |
|
return (\@in_course,\@in_domain); |
|
} |
|
|
1; |
1; |
|
|