version 1.27, 2007/12/22 17:33:26
|
version 1.39, 2008/01/01 20:27:29
|
Line 76 sub modifystudent {
|
Line 76 sub modifystudent {
|
} |
} |
} |
} |
if ($result eq '') { |
if ($result eq '') { |
$result = 'Unable to find section for this student'; |
$result = &mt('Unable to find section for this student'); |
} else { |
} else { |
$result =~ s/(ok:)+/ok/g; |
$result =~ s/(ok:)+/ok/g; |
} |
} |
Line 304 sub print_upload_manager_header {
|
Line 304 sub print_upload_manager_header {
|
my $javascript_validations = |
my $javascript_validations = |
&javascript_validations('upload',$krbdefdom,$password_choice,undef, |
&javascript_validations('upload',$krbdefdom,$password_choice,undef, |
$env{'request.role.domain'},$context, |
$env{'request.role.domain'},$context, |
$permission,$groupslist); |
$groupslist); |
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); |
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); |
$r->print(&mt('Total number of records found in file: <b>[_1]</b>.',$distotal). |
$r->print(&mt('Total number of records found in file: <b>[_1]</b>.',$distotal). |
"<br />\n"); |
"<br />\n"); |
Line 332 sub print_upload_manager_header {
|
Line 332 sub print_upload_manager_header {
|
############################################################### |
############################################################### |
sub javascript_validations { |
sub javascript_validations { |
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain, |
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain, |
$context,$permission,$groupslist)=@_; |
$context,$groupslist)=@_; |
|
|
my %param = ( |
my %param = ( |
kerb_def_dom => $krbdefdom, |
kerb_def_dom => $krbdefdom, |
curr_authtype => $curr_authtype, |
curr_authtype => $curr_authtype, |
); |
); |
if ($mode eq 'createuser') { |
if ($mode eq 'upload') { |
$param{'formname'} = 'cu'; |
|
} elsif ($mode eq 'upload') { |
|
$param{'formname'} = 'studentform'; |
$param{'formname'} = 'studentform'; |
} elsif ($mode eq 'singlestudent') { |
|
$param{'formname'} = 'cu'; |
|
} elsif ($mode eq 'createcourse') { |
} elsif ($mode eq 'createcourse') { |
$param{'formname'} = 'ccrs'; |
$param{'formname'} = 'ccrs'; |
} elsif ($mode eq 'modifycourse') { |
} elsif ($mode eq 'modifycourse') { |
Line 367 sub javascript_validations {
|
Line 362 sub javascript_validations {
|
} |
} |
} elsif ($context eq 'domain') { |
} elsif ($context eq 'domain') { |
$setsection_call = 'setCourse()'; |
$setsection_call = 'setCourse()'; |
$setsections_js = &dc_setcourse_js($param{'formname'},$mode); |
$setsections_js = &dc_setcourse_js($param{'formname'},$mode,$context); |
} |
} |
$finish = " var checkSec = $setsection_call\n". |
$finish = " var checkSec = $setsection_call\n". |
" if (checkSec == 'ok') {\n". |
" if (checkSec == 'ok') {\n". |
Line 389 sub javascript_validations {
|
Line 384 sub javascript_validations {
|
role => 'The optional role field was not specified.', |
role => 'The optional role field was not specified.', |
continue => 'Continue adding users?', |
continue => 'Continue adding users?', |
); |
); |
|
my $function_name = <<"END"; |
my $function_name =(<<END); |
|
$setsections_js |
$setsections_js |
|
|
function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) { |
function verify_message (vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail) { |
Line 456 END
|
Line 450 END
|
foundatype=1; |
foundatype=1; |
if (current.argfield == null || current.argfield == '') { |
if (current.argfield == null || current.argfield == '') { |
var alertmsg = ''; |
var alertmsg = ''; |
switch (current.value) { |
switch (current.radiovalue) { |
case 'krb': |
case 'krb': |
alertmsg = '$alert{'krb'}'; |
alertmsg = '$alert{'krb'}'; |
break; |
break; |
Line 521 END
|
Line 515 END
|
} |
} |
END |
END |
} |
} |
my $result = $function_name; |
my $result = $function_name.$auth_checks.$optional_checks."\n". |
if ( ($mode eq 'upload') || ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) { |
$section_checks.$authheader; |
$result .= $auth_checks; |
|
} |
|
$result .= $optional_checks."\n".$section_checks; |
|
if ( ($mode eq 'upload') || ($mode eq 'createcourse') || ($mode eq 'modifycourse') ) { |
|
$result .= $authheader; |
|
} |
|
return $result; |
return $result; |
} |
} |
############################################################### |
############################################################### |
Line 761 sub print_upload_manager_footer {
|
Line 749 sub print_upload_manager_footer {
|
$permission,$context,'upload'); |
$permission,$context,'upload'); |
$Str .= $secbox."<h3>".&mt('Full Update')."</h3>\n". |
$Str .= $secbox."<h3>".&mt('Full Update')."</h3>\n". |
'<p><label><input type="checkbox" name="fullup" value="yes">'. |
'<p><label><input type="checkbox" name="fullup" value="yes">'. |
' '.&mt('Display students with current/future access, who are not in the uploaded file.').'<br />'.&mt('Students selected from this list can be dropped.'); |
' '.&mt('Display students with current/future access who are not in the uploaded file.').'</label><br />'.&mt('Students selected from this list can be dropped.').'</p>'."\n"; |
"</label></p>\n"; |
|
} |
} |
if ($context eq 'course' || $context eq 'domain') { |
if ($context eq 'course' || $context eq 'domain') { |
$Str .= &forceid_change($context); |
$Str .= &forceid_change($context); |
Line 1264 sub print_userlist {
|
Line 1251 sub print_userlist {
|
if ($env{'form.showrole'} eq 'Any') { |
if ($env{'form.showrole'} eq 'Any') { |
$roleselected = ' selected="selected" '; |
$roleselected = ' selected="selected" '; |
} |
} |
my $role_select; |
my ($role_select,$cnum,$cdom); |
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$role_select = &domain_roles_select(); |
$role_select = &domain_roles_select(); |
$r->print('<label>'.&mt('Role Type: [_1]',$role_select).'</label>'); |
$r->print('<label>'.&mt('Role Type: [_1]',$role_select).'</label>'); |
Line 1288 sub print_userlist {
|
Line 1275 sub print_userlist {
|
} |
} |
$role_select .= '</select>'; |
$role_select .= '</select>'; |
$r->print('<label>'.&mt('Role: [_1]',$role_select).'</label>'); |
$r->print('<label>'.&mt('Role: [_1]',$role_select).'</label>'); |
|
if ($context eq 'course') { |
|
($cnum,$cdom) = &get_course_identity(); |
|
$r->print(§ion_group_filter($cnum,$cdom)); |
|
} |
} |
} |
if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { |
if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { |
$r->print(' '.&list_submit_button(&mt('Update Display')). |
$r->print(' '.&list_submit_button(&mt('Update Display')). |
Line 1307 sub print_userlist {
|
Line 1298 sub print_userlist {
|
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::end_pick_box().'</p>'. |
&Apache::lonhtmlcommon::end_pick_box().'</p>'. |
'<p>'.&list_submit_button(&mt('Update Display')). |
'<p>'.&list_submit_button(&mt('Update Display')). |
"\n</p>\n"); |
"\n".'</p><span class="LC_warning">'.&mt('Warning: data retrieval for multiple courses can take considerable time, as this operation is not currently optimized.').'</span>'."\n"); |
if ($env{'form.coursepick'}) { |
if ($env{'form.coursepick'}) { |
$r->print('<hr />'.&mt('Searching').' ...<br /> <br />'); |
$r->print('<hr />'.&mt('Searching').' ...<br /> <br />'); |
} |
} |
Line 1331 sub print_userlist {
|
Line 1322 sub print_userlist {
|
$userlist{$student} = $classlist->{$student}; |
$userlist{$student} = $classlist->{$student}; |
} |
} |
} |
} |
my $cid = $env{'request.course.id'}; |
|
my ($cnum,$cdom) = &get_course_identity($cid); |
|
my $showroles; |
my $showroles; |
if ($env{'form.showrole'} ne 'Any') { |
if ($env{'form.showrole'} ne 'Any') { |
$showroles = [$env{'form.showrole'}]; |
$showroles = [$env{'form.showrole'}]; |
Line 1340 sub print_userlist {
|
Line 1329 sub print_userlist {
|
$showroles = undef; |
$showroles = undef; |
} |
} |
my $withsec = 1; |
my $withsec = 1; |
|
my $hidepriv = 1; |
my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, |
my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef, |
\@statuses,$showroles,undef,$withsec); |
\@statuses,$showroles,undef,$withsec,$hidepriv); |
&gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo, |
&gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo, |
\%advrolehash,$permission); |
\%advrolehash,$permission); |
} else { |
} else { |
Line 1392 sub print_userlist {
|
Line 1382 sub print_userlist {
|
} elsif ($env{'form.roletype'} eq 'course') { |
} elsif ($env{'form.roletype'} eq 'course') { |
if ($env{'form.coursepick'}) { |
if ($env{'form.coursepick'}) { |
my %courses = &process_coursepick(); |
my %courses = &process_coursepick(); |
my %allusers; |
my %allusers; |
|
my $hidepriv = 1; |
foreach my $cid (keys(%courses)) { |
foreach my $cid (keys(%courses)) { |
my ($cnum,$cdom,$cdesc) = &get_course_identity($cid); |
my ($cnum,$cdom,$cdesc) = &get_course_identity($cid); |
next if ($cnum eq '' || $cdom eq ''); |
next if ($cnum eq '' || $cdom eq ''); |
Line 1410 sub print_userlist {
|
Line 1401 sub print_userlist {
|
foreach my $type (@statuses) { |
foreach my $type (@statuses) { |
$access{$type} = $type; |
$access{$type} = $type; |
} |
} |
&Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash); |
&Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash,$hidepriv); |
foreach my $user (keys(%userdata)) { |
foreach my $user (keys(%userdata)) { |
next if (ref($userinfo{$user}) eq 'HASH'); |
next if (ref($userinfo{$user}) eq 'HASH'); |
foreach my $item ('fullname','id') { |
foreach my $item ('fullname','id') { |
Line 1468 sub print_userlist {
|
Line 1459 sub print_userlist {
|
$env{'form.phase'}.'" /></form>'); |
$env{'form.phase'}.'" /></form>'); |
} |
} |
|
|
|
sub section_group_filter { |
|
my ($cnum,$cdom) = @_; |
|
my @filters; |
|
if ($env{'request.course.sec'} eq '') { |
|
@filters = ('sec'); |
|
} |
|
push(@filters,'grp'); |
|
my %name = ( |
|
sec => 'secfilter', |
|
grp => 'grpfilter', |
|
); |
|
my %title = &Apache::lonlocal::texthash ( |
|
sec => 'Section(s)', |
|
grp => 'Group(s)', |
|
all => 'all', |
|
none => 'none', |
|
); |
|
my ($output,@options); |
|
foreach my $item (@filters) { |
|
my $markup; |
|
if ($env{'form.'.$name{$item}} eq '') { |
|
$env{'form.'.$name{$item}} = 'all'; |
|
} |
|
if ($item eq 'sec') { |
|
if ($env{'form.showrole'} eq 'cc') { |
|
$env{'form.'.$name{$item}} = 'none'; |
|
} |
|
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
|
@options = sort(keys(%sections_count)); |
|
} elsif ($item eq 'grp') { |
|
my %curr_groups = &Apache::longroup::coursegroups(); |
|
@options = sort(keys(%curr_groups)); |
|
} |
|
if (@options > 0) { |
|
my $currsel; |
|
$markup = '<select name="'.$name{$item}.'" />'."\n"; |
|
foreach my $option ('all','none',@options) { |
|
$currsel = ''; |
|
if ($env{'form.'.$name{$item}} eq $option) { |
|
$currsel = ' selected="selected" '; |
|
} |
|
$markup .= ' <option value="'.$option.'"'.$currsel.'>'; |
|
if (($option eq 'all') || ($option eq 'none')) { |
|
$markup .= $title{$option}; |
|
} else { |
|
$markup .= $option; |
|
} |
|
$markup .= '</option>'."\n"; |
|
} |
|
$markup .= '</select>'."\n"; |
|
$output .= (' 'x3).'<label>'.$title{$item}.': '.$markup.'</label>'; |
|
} |
|
} |
|
return $output; |
|
} |
|
|
sub list_submit_button { |
sub list_submit_button { |
my ($text) = @_; |
my ($text) = @_; |
return '<input type="button" name="updatedisplay" value="'.$text.'" onclick="javascript:display_update()" />'; |
return '<input type="button" name="updatedisplay" value="'.$text.'" onclick="javascript:display_update()" />'; |
Line 2047 END
|
Line 2094 END
|
$env{'request.role.domain'})) { |
$env{'request.role.domain'})) { |
$canchange{$role} = 1; |
$canchange{$role} = 1; |
} |
} |
|
} elsif ($setting eq 'author') { |
|
if (&Apache::lonnet::allowed('c'.$role, |
|
$env{'request.role.domain'})) { |
|
$canchange{$role} = 1; |
|
} |
} |
} |
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
if (&Apache::lonnet::allowed('c'.$role, |
if (&Apache::lonnet::allowed('c'.$role, |
Line 2158 END
|
Line 2210 END
|
$index{$idx} = $i++; |
$index{$idx} = $i++; |
} |
} |
my $usercount = 0; |
my $usercount = 0; |
|
my ($secfilter,$grpfilter); |
|
if ($context eq 'course') { |
|
$secfilter = $env{'form.secfilter'}; |
|
$grpfilter = $env{'form.grpfilter'}; |
|
if ($secfilter eq '') { |
|
$secfilter = 'all'; |
|
} |
|
if ($grpfilter eq '') { |
|
$grpfilter = 'all'; |
|
} |
|
} |
# Get groups, role, permanent e-mail so we can sort on them if |
# Get groups, role, permanent e-mail so we can sort on them if |
# necessary. |
# necessary. |
foreach my $user (keys(%{$userlist})) { |
foreach my $user (keys(%{$userlist})) { |
Line 2195 END
|
Line 2258 END
|
delete($userlist->{$user}); |
delete($userlist->{$user}); |
next; |
next; |
} |
} |
if (ref($classgroups) eq 'HASH') { |
if ($context eq 'course') { |
$groups = $classgroups->{$user}; |
my @ac_groups; |
} |
if (ref($classgroups) eq 'HASH') { |
if (ref($groups->{active}) eq 'HASH') { |
$groups = $classgroups->{$user}; |
$userlist->{$user}->[$index{'groups'}] = join(', ',keys(%{$groups->{'active'}})); |
} |
|
if (ref($groups->{'active'}) eq 'HASH') { |
|
@ac_groups = keys(%{$groups->{'active'}}); |
|
$userlist->{$user}->[$index{'groups'}] = join(', ',@ac_groups); |
|
} |
|
if ($mode ne 'autoenroll') { |
|
my $section = $userlist->{$user}->[$index{'section'}]; |
|
if ($secfilter eq 'none') { |
|
if ($section ne '') { |
|
delete($userlist->{$user}); |
|
next; |
|
} |
|
} elsif ($secfilter ne 'all') { |
|
if ($section ne $secfilter) { |
|
delete($userlist->{$user}); |
|
next; |
|
} |
|
} |
|
if ($grpfilter eq 'none') { |
|
if (@ac_groups > 0) { |
|
delete($userlist->{$user}); |
|
next; |
|
} |
|
} elsif ($grpfilter ne 'all') { |
|
if (!grep(/^\Q$grpfilter\E$/,@ac_groups)) { |
|
delete($userlist->{$user}); |
|
next; |
|
} |
|
} |
|
} |
} |
} |
my %emails = &Apache::loncommon::getemails($uname,$udom); |
my %emails = &Apache::loncommon::getemails($uname,$udom); |
if ($emails{'permanentemail'} =~ /\S/) { |
if ($emails{'permanentemail'} =~ /\S/) { |
Line 2274 END
|
Line 2366 END
|
$r->print("<td>$cellentry</td>\n"); |
$r->print("<td>$cellentry</td>\n"); |
} else { |
} else { |
$r->print("<td>$rowcount</td>\n"); |
$r->print("<td>$rowcount</td>\n"); |
$checkval; |
|
if ($actionselect) { |
if ($actionselect) { |
my $showcheckbox; |
my $showcheckbox; |
if ($role =~ /^cr\//) { |
if ($role =~ /^cr\//) { |
Line 2736 sub results_header_row {
|
Line 2827 sub results_header_row {
|
$description .= &mt('All users in course with [_1] roles',$rolefilter); |
$description .= &mt('All users in course with [_1] roles',$rolefilter); |
} |
} |
} |
} |
|
my $constraint; |
my $viewablesec = &viewable_section($permission); |
my $viewablesec = &viewable_section($permission); |
if ($viewablesec ne '') { |
if ($viewablesec ne '') { |
if ($env{'form.showrole'} eq 'st') { |
if ($env{'form.showrole'} eq 'st') { |
$description .= ' '.&mt('(section [_1] only)',$viewablesec); |
$constraint = &mt('only users in section "[_1]"',$viewablesec); |
} elsif ($env{'form.showrole'} ne 'cc') { |
} elsif ($env{'form.showrole'} ne 'cc') { |
$description .= ' '.&mt('(only users affiliated with no section or section [_1])',$viewablesec); |
$constraint = &mt('only users affiliated with no section or section "[_1]"',$viewablesec); |
|
} |
|
if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) { |
|
if ($env{'form.grpfilter'} eq 'none') { |
|
$constraint .= &mt(' and not in any group'); |
|
} else { |
|
$constraint .= &mt(' and members of group: "[_1]"',$env{'form.grpfilter'}); |
|
} |
|
} |
|
} else { |
|
if (($env{'form.secfilter'} ne 'all') && ($env{'form.secfilter'} ne '')) { |
|
if ($env{'form.secfilter'} eq 'none') { |
|
$constraint = &mt('only users affiliated with no section'); |
|
} else { |
|
$constraint = &mt('only users affiliated with section "[_1]"',$env{'form.secfilter'}); |
|
} |
|
} |
|
if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) { |
|
if ($env{'form.grpfilter'} eq 'none') { |
|
if ($constraint eq '') { |
|
$constraint = &mt('only users not in any group'); |
|
} else { |
|
$constraint .= &mt(' and also not in any group'); |
|
} |
|
} else { |
|
if ($constraint eq '') { |
|
$constraint = &mt('only members of group: "[_1]"',$env{'form.grpfilter'}); |
|
} else { |
|
$constraint .= &mt(' and also members of group: "[_1]"'.$env{'form.grpfilter'}); |
|
} |
|
} |
} |
} |
} |
} |
|
if ($constraint ne '') { |
|
$description .= ' ('.$constraint.')'; |
|
} |
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
$description = |
$description = |
&mt('Author space for <span class="LC_cusr_emph">[_1]</span>', |
&mt('Author space for <span class="LC_cusr_emph">[_1]</span>', |
Line 2841 sub viewable_section {
|
Line 2966 sub viewable_section {
|
################################################# |
################################################# |
################################################# |
################################################# |
sub show_drop_list { |
sub show_drop_list { |
my ($r,$classlist,$keylist,$nosort,$permission)=@_; |
my ($r,$classlist,$nosort,$permission) = @_; |
my $cid=$env{'request.course.id'}; |
my $cid = $env{'request.course.id'}; |
my ($cnum,$cdom) = &get_course_identity($cid); |
my ($cnum,$cdom) = &get_course_identity($cid); |
if (! exists($env{'form.sortby'})) { |
if (! exists($env{'form.sortby'})) { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
Line 2852 sub show_drop_list {
|
Line 2977 sub show_drop_list {
|
if ($sortby !~ /^(username|domain|section|groups|fullname|id|start|end)$/) { |
if ($sortby !~ /^(username|domain|section|groups|fullname|id|start|end)$/) { |
$sortby = 'username'; |
$sortby = 'username'; |
} |
} |
my ($classgroups) = &Apache::loncoursedata::get_group_memberships( |
|
$classlist,$keylist,$cdom,$cnum); |
|
# |
|
my $action = "drop"; |
my $action = "drop"; |
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript(); |
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript(); |
$r->print(<<END); |
$r->print(<<END); |
Line 2867 $check_uncheck_js
|
Line 2989 $check_uncheck_js
|
<p> |
<p> |
<input type="hidden" name="phase" value="four"> |
<input type="hidden" name="phase" value="four"> |
END |
END |
|
my ($indexhash,$keylist) = &make_keylist_array(); |
my %lt=&Apache::lonlocal::texthash('usrn' => "username", |
my $studentcount = 0; |
'dom' => "domain", |
if (ref($classlist) eq 'HASH') { |
'sn' => "student name", |
foreach my $student (keys(%{$classlist})) { |
'sec' => "section", |
my $sdata = $classlist->{$student}; |
'start' => "start date", |
my $status = $sdata->[$indexhash->{'status'}]; |
'end' => "end date", |
my $section = $sdata->[$indexhash->{'section'}]; |
'groups' => "active groups", |
if ($status ne 'Active') { |
); |
delete($classlist->{$student}); |
|
next; |
|
} |
|
if ($env{'request.course.sec'} ne '') { |
|
if ($section ne $env{'request.course.sec'}) { |
|
delete($classlist->{$student}); |
|
next; |
|
} |
|
} |
|
$studentcount ++; |
|
} |
|
} |
|
if (!$studentcount) { |
|
$r->print(&mt('There are no students to drop.')); |
|
return; |
|
} |
|
my ($classgroups) = &Apache::loncoursedata::get_group_memberships( |
|
$classlist,$keylist,$cdom,$cnum); |
|
my %lt=&Apache::lonlocal::texthash('usrn' => "username", |
|
'dom' => "domain", |
|
'sn' => "student name", |
|
'sec' => "section", |
|
'start' => "start date", |
|
'end' => "end date", |
|
'groups' => "active groups", |
|
); |
if ($nosort) { |
if ($nosort) { |
$r->print(&Apache::loncommon::start_data_table(). |
$r->print(&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row()); |
&Apache::loncommon::start_data_table_header_row()); |
Line 2918 END
|
Line 3065 END
|
} |
} |
# |
# |
# Sort the students |
# Sort the students |
my %index; |
my $index = $indexhash->{$sortby}; |
my $i; |
my $second = $indexhash->{'username'}; |
foreach (@$keylist) { |
my $third = $indexhash->{'domain'}; |
$index{$_} = $i++; |
|
} |
|
$index{'groups'} = scalar(@$keylist); |
|
my $index = $index{$sortby}; |
|
my $second = $index{'username'}; |
|
my $third = $index{'domain'}; |
|
my @Sorted_Students = sort { |
my @Sorted_Students = sort { |
lc($classlist->{$a}->[$index]) cmp lc($classlist->{$b}->[$index]) |
lc($classlist->{$a}->[$index]) cmp lc($classlist->{$b}->[$index]) |
|| |
|| |
lc($classlist->{$a}->[$second]) cmp lc($classlist->{$b}->[$second]) |
lc($classlist->{$a}->[$second]) cmp lc($classlist->{$b}->[$second]) |
|| |
|| |
lc($classlist->{$a}->[$third]) cmp lc($classlist->{$b}->[$third]) |
lc($classlist->{$a}->[$third]) cmp lc($classlist->{$b}->[$third]) |
} (keys(%$classlist)); |
} (keys(%{$classlist})); |
foreach my $student (@Sorted_Students) { |
foreach my $student (@Sorted_Students) { |
my $error; |
my $error; |
my $sdata = $classlist->{$student}; |
my $sdata = $classlist->{$student}; |
my $username = $sdata->[$index{'username'}]; |
my $username = $sdata->[$indexhash->{'username'}]; |
my $domain = $sdata->[$index{'domain'}]; |
my $domain = $sdata->[$indexhash->{'domain'}]; |
my $section = $sdata->[$index{'section'}]; |
my $section = $sdata->[$indexhash->{'section'}]; |
my $name = $sdata->[$index{'fullname'}]; |
my $name = $sdata->[$indexhash->{'fullname'}]; |
my $id = $sdata->[$index{'id'}]; |
my $id = $sdata->[$indexhash->{'id'}]; |
my $start = $sdata->[$index{'start'}]; |
my $start = $sdata->[$indexhash->{'start'}]; |
my $end = $sdata->[$index{'end'}]; |
my $end = $sdata->[$indexhash->{'end'}]; |
my $groups = $classgroups->{$student}; |
my $groups = $classgroups->{$student}; |
my $active_groups; |
my $active_groups; |
if (ref($groups->{active}) eq 'HASH') { |
if (ref($groups->{active}) eq 'HASH') { |
Line 2959 END
|
Line 3100 END
|
} else { |
} else { |
$end = &Apache::lonlocal::locallocaltime($end); |
$end = &Apache::lonlocal::locallocaltime($end); |
} |
} |
my $status = $sdata->[$index{'status'}]; |
|
next if ($status ne 'Active'); |
|
if ($env{'request.course.sec'} ne '') { |
|
if ($section ne $env{'request.course.sec'}) { |
|
next; |
|
} |
|
} |
|
my $studentkey = $student.':'.$section; |
my $studentkey = $student.':'.$section; |
my $startitem = '<input type="hidden" name="'.$studentkey.'_start" value="'.$sdata->[$index{'start'}].'" />'; |
my $startitem = '<input type="hidden" name="'.$studentkey.'_start" value="'.$sdata->[$indexhash->{'start'}].'" />'; |
# |
# |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(<<"END"); |
$r->print(<<"END"); |
<td><input type="checkbox" name="droplist" value="$student"></td> |
<td><input type="checkbox" name="droplist" value="$studentkey"></td> |
<td>$username</td> |
<td>$username</td> |
<td>$domain</td> |
<td>$domain</td> |
<td>$id</td> |
<td>$id</td> |
<td>$name</td> |
<td>$name</td> |
<td>$section</td> |
<td>$section</td> |
<td>$start</td> |
<td>$start $startitem</td> |
<td>$end</td> |
<td>$end</td> |
<td>$active_groups</td> |
<td>$active_groups</td> |
END |
END |
Line 2985 END
|
Line 3119 END
|
} |
} |
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
%lt=&Apache::lonlocal::texthash( |
%lt=&Apache::lonlocal::texthash( |
'dp' => "Expire Users' Roles", |
'dp' => "Drop Students", |
'ca' => "check all", |
'ca' => "check all", |
'ua' => "uncheck all", |
'ua' => "uncheck all", |
); |
); |
Line 3042 sub upfile_drop_add {
|
Line 3176 sub upfile_drop_add {
|
$fields{$env{'form.f'.$i}}=$keyfields[$i]; |
$fields{$env{'form.f'.$i}}=$keyfields[$i]; |
} |
} |
} |
} |
|
if ($env{'form.fullup'} ne 'yes') { |
|
$r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n". |
|
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'); |
|
} |
# |
# |
# Store the field choices away |
# Store the field choices away |
foreach my $field (qw/username names |
foreach my $field (qw/username names |
Line 3467 sub upfile_drop_add {
|
Line 3605 sub upfile_drop_add {
|
} |
} |
} |
} |
if (!$multiple) { |
if (!$multiple) { |
($userresult,$authresult,$roleresult) = |
($userresult,$authresult,$roleresult,$idresult) = |
&modifyuserrole($context,$setting, |
&modifyuserrole($context,$setting, |
$changeauth,$cid,$domain,$username, |
$changeauth,$cid,$domain,$username, |
$id,$amode,$password,$fname, |
$id,$amode,$password,$fname, |
Line 3487 sub upfile_drop_add {
|
Line 3625 sub upfile_drop_add {
|
} else { |
} else { |
$flushc = |
$flushc = |
&user_change_result($r,$userresult,$authresult, |
&user_change_result($r,$userresult,$authresult, |
$roleresult,\%counts,$flushc, |
$roleresult,$idresult,\%counts,$flushc, |
$username,%userchg); |
$username,\%userchg); |
} |
} |
} else { |
} else { |
if ($context eq 'course') { |
if ($context eq 'course') { |
Line 3510 sub upfile_drop_add {
|
Line 3648 sub upfile_drop_add {
|
} # end of foreach (@userdata) |
} # end of foreach (@userdata) |
# Flush the course logs so reverse user roles immediately updated |
# Flush the course logs so reverse user roles immediately updated |
&Apache::lonnet::flushcourselogs(); |
&Apache::lonnet::flushcourselogs(); |
$r->print("</p>\n<p>\n".&mt('Processed [_1] user(s).',$counts{'user'}). |
$r->print("</p>\n<p>\n".&mt('Processed [quant,_1,user].',$counts{'user'}). |
"</p>\n"); |
"</p>\n"); |
if ($counts{'role'} > 0) { |
if ($counts{'role'} > 0) { |
$r->print("<p>\n". |
$r->print("<p>\n". |
&mt('Roles added for [_1] users. If user is active, the new role will be available when the user next logs in to LON-CAPA.',$counts{'role'})."</p>\n"); |
&mt('Roles added for [quant,_1,user].',$counts{'role'}).' '.&mt('If a user is currently logged-in to LON-CAPA, any new roles which are active will be available when the user next logs in.')."</p>\n"); |
|
} else { |
|
$r->print('<p>'.&mt('No roles added').'</p>'); |
} |
} |
if ($counts{'auth'} > 0) { |
if ($counts{'auth'} > 0) { |
$r->print("<p>\n". |
$r->print("<p>\n". |
Line 3522 sub upfile_drop_add {
|
Line 3662 sub upfile_drop_add {
|
$counts{'auth'})."</p>\n"); |
$counts{'auth'})."</p>\n"); |
} |
} |
$r->print(&print_namespacing_alerts($domain,\%alerts,\%curr_rules)); |
$r->print(&print_namespacing_alerts($domain,\%alerts,\%curr_rules)); |
$r->print('<form name="uploadresult" action="/adm/createuser">'); |
|
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','prevphase','currstate'])); |
|
$r->print('</form>'); |
|
##################################### |
##################################### |
# Drop students # |
# Display list of students to drop # |
##################################### |
##################################### |
if ($env{'form.fullup'} eq 'yes') { |
if ($env{'form.fullup'} eq 'yes') { |
$r->print('<h3>'.&mt('Dropping Students')."</h3>\n"); |
$r->print('<h3>'.&mt('Students to Drop')."</h3>\n"); |
# Get current classlist |
# Get current classlist |
my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist(); |
my $classlist = &Apache::loncoursedata::get_classlist(); |
if (! defined($classlist)) { |
if (! defined($classlist)) { |
$r->print(&mt('There are no students currently enrolled.'). |
$r->print('<form name="studentform" method="post" action="/adm/createuser" />'. |
"\n"); |
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'. |
|
&mt('There are no students with current/future access to the course.'). |
|
'</form>'."\n"); |
} else { |
} else { |
# Remove the students we just added from the list of students. |
# Remove the students we just added from the list of students. |
foreach (@userdata) { |
foreach my $line (@userdata) { |
my %entries=&Apache::loncommon::record_sep($_); |
my %entries=&Apache::loncommon::record_sep($line); |
unless (($entries{$fields{'username'}} eq '') || |
unless (($entries{$fields{'username'}} eq '') || |
(!defined($entries{$fields{'username'}}))) { |
(!defined($entries{$fields{'username'}}))) { |
delete($classlist->{$entries{$fields{'username'}}. |
delete($classlist->{$entries{$fields{'username'}}. |
Line 3546 sub upfile_drop_add {
|
Line 3685 sub upfile_drop_add {
|
} |
} |
} |
} |
# Print out list of dropped students. |
# Print out list of dropped students. |
&show_drop_list($r,$classlist,$keylist,'nosort'); |
&show_drop_list($r,$classlist,'nosort',$permission); |
} |
} |
} |
} |
} # end of unless |
} # end of unless |
|
if ($env{'form.fullup'} ne 'yes') { |
|
$r->print('</form>'); |
|
} |
} |
} |
|
|
sub print_namespacing_alerts { |
sub print_namespacing_alerts { |
Line 3593 sub print_namespacing_alerts {
|
Line 3735 sub print_namespacing_alerts {
|
} |
} |
|
|
sub user_change_result { |
sub user_change_result { |
my ($r,$userresult,$authresult,$roleresult,$counts,$flushc,$username, |
my ($r,$userresult,$authresult,$roleresult,$idresult,$counts,$flushc, |
$userchg) = @_; |
$username,$userchg) = @_; |
my $okresult = 0; |
my $okresult = 0; |
if ($userresult ne 'ok') { |
if ($userresult ne 'ok') { |
if ($userresult =~ /^error:(.+)$/) { |
if ($userresult =~ /^error:(.+)$/) { |
Line 3635 sub user_change_result {
|
Line 3777 sub user_change_result {
|
$flushc=0; |
$flushc=0; |
} |
} |
} |
} |
|
if ($idresult) { |
|
$r->print($idresult); |
|
} |
return $flushc; |
return $flushc; |
} |
} |
|
|
Line 3643 sub print_drop_menu {
|
Line 3788 sub print_drop_menu {
|
my ($r,$context,$permission) = @_; |
my ($r,$context,$permission) = @_; |
$r->print('<h3>'.&mt("Drop Students").'</h3>'."\n". |
$r->print('<h3>'.&mt("Drop Students").'</h3>'."\n". |
'<form name="studentform" method="post">'."\n"); |
'<form name="studentform" method="post">'."\n"); |
my $cid=$env{'request.course.id'}; |
my $classlist = &Apache::loncoursedata::get_classlist(); |
my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist(); |
|
if (! defined($classlist)) { |
if (! defined($classlist)) { |
$r->print(&mt('There are no students currently enrolled.')."\n"); |
$r->print(&mt('There are no students currently enrolled.')."\n"); |
return; |
} else { |
|
&show_drop_list($r,$classlist,'nosort',$permission); |
} |
} |
# Print out the available choices |
|
&show_drop_list($r,$classlist,$keylist,$permission); |
|
$r->print('</form>'. &Apache::loncommon::end_page()); |
$r->print('</form>'. &Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
Line 3662 sub update_user_list {
|
Line 3805 sub update_user_list {
|
my $now = time; |
my $now = time; |
my $count=0; |
my $count=0; |
my @changelist; |
my @changelist; |
if ($choice ne '') { |
if ($choice eq 'drop') { |
@changelist = &Apache::loncommon::get_env_multiple('form.actionlist'); |
|
} else { |
|
@changelist = &Apache::loncommon::get_env_multiple('form.droplist'); |
@changelist = &Apache::loncommon::get_env_multiple('form.droplist'); |
|
} else { |
|
@changelist = &Apache::loncommon::get_env_multiple('form.actionlist'); |
} |
} |
my %result_text = ( ok => { 'revoke' => 'Revoked', |
my %result_text = ( ok => { 'revoke' => 'Revoked', |
'delete' => 'Deleted', |
'delete' => 'Deleted', |
Line 3732 sub update_user_list {
|
Line 3875 sub update_user_list {
|
} |
} |
} |
} |
my $plrole = &Apache::lonnet::plaintext($role); |
my $plrole = &Apache::lonnet::plaintext($role); |
my ($uid,$first,$middle,$last,$gene,$sec); |
|
my $start = $env{'form.'.$item.'_start'}; |
my $start = $env{'form.'.$item.'_start'}; |
my $end = $env{'form.'.$item.'_end'}; |
my $end = $env{'form.'.$item.'_end'}; |
if ($choice eq 'drop') { |
if ($choice eq 'drop') { |
Line 3752 sub update_user_list {
|
Line 3894 sub update_user_list {
|
&Apache::lonnet::revokerole($udom,$uname,$scope,$role); |
&Apache::lonnet::revokerole($udom,$uname,$scope,$role); |
} |
} |
} elsif ($choice eq 'delete') { |
} elsif ($choice eq 'delete') { |
$start = -1; |
|
$end = -1; |
|
if ($role eq 'st') { |
if ($role eq 'st') { |
# FIXME - how does role deletion affect classlist? |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$now,$start,$type,$locktype,$cid); |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid); |
} |
} else { |
$result = |
$result = |
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now, |
&Apache::lonnet::assignrole($udom,$uname,$scope,$role,$now, |
$start,1); |
0,1); |
|
} |
|
} else { |
} else { |
#reenable, activate, change access dates or change section |
#reenable, activate, change access dates or change section |
if ($choice ne 'chgsec') { |
if ($choice ne 'chgsec') { |
Line 3803 sub update_user_list {
|
Line 3941 sub update_user_list {
|
$nochg = 1; |
$nochg = 1; |
} |
} |
} else { |
} else { |
if (!grep(/^\Q$sec\E$/,@newsecs)) { |
if (@newsecs > 0) { |
$revresult = |
if (grep(/^\Q$sec\E$/,@newsecs)) { |
&Apache::lonnet::revokerole($udom,$uname,$scope,$role); |
push(@retained,$sec); |
|
} else { |
|
$revresult = |
|
&Apache::lonnet::revokerole($udom,$uname, |
|
$scope,$role); |
|
} |
} else { |
} else { |
push(@retained,$sec); |
$revresult = |
|
&Apache::lonnet::revokerole($udom,$uname, |
|
$scope,$role); |
} |
} |
} |
} |
} else { |
} else { |
push(@retained,$sec); |
if ($sec eq '') { |
|
$nochg = 1; |
|
} else { |
|
push(@retained,$sec); |
|
} |
} |
} |
# add new sections |
# add new sections |
if (@newsecs == 0) { |
if (@newsecs == 0) { |
if (!$nochg) { |
if (!$nochg) { |
if ($sec ne '') { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = |
$result = |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid); |
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$end,$start,$type,$locktype,$cid); |
} else { |
} else { |
my $newscope = $scopestem; |
my $newscope = $scopestem; |
$result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start); |
$result = &Apache::lonnet::assignrole($udom,$uname,$newscope,$role,$end,$start); |
|
} |
|
} |
} |
} |
} |
} else { |
} else { |
Line 3857 sub update_user_list {
|
Line 4004 sub update_user_list {
|
$count++; |
$count++; |
} else { |
} else { |
$r->print( |
$r->print( |
&mt("Error $result_text{'error'}{$choice} [_1] in [_2] for [_3]:[_4]", |
&mt("Error $result_text{'error'}{$choice} [_1] in [_2] for [_3]: [_4].", |
$plrole,$extent,$uname.':'.$udom,$result).'<br />'); |
$plrole,$extent,$uname.':'.$udom,$result).'<br />'); |
} |
} |
} |
} |
$r->print('<p><b>'.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,users].",$count).'</b></p>'); |
$r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n"); |
|
if ($choice eq 'drop') { |
|
$r->print('<input type="hidden" name="action" value="listusers" />'."\n". |
|
'<input type="hidden" name="Status" value="Active" />'."\n". |
|
'<input type="hidden" name="showrole" value="st" />'."\n"); |
|
} else { |
|
foreach my $item ('action','sortby','roletype','showrole','Status','secfilter','grpfilter') { |
|
if ($env{'form.'.$item} ne '') { |
|
$r->print('<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}. |
|
'" />'."\n"); |
|
} |
|
} |
|
} |
|
$r->print('<p><b>'.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,no users].",$count).'</b></p>'); |
if ($count > 0) { |
if ($count > 0) { |
if ($choice eq 'revoke' || $choice eq 'drop') { |
if ($choice eq 'revoke' || $choice eq 'drop') { |
$r->print('<p>'.&mt('Re-enabling will re-activate data for the role.</p>')); |
$r->print('<p>'.&mt('Re-enabling will re-activate data for the role.</p>')); |
Line 3871 sub update_user_list {
|
Line 4031 sub update_user_list {
|
} |
} |
if ($env{'form.makedatesdefault'}) { |
if ($env{'form.makedatesdefault'}) { |
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') { |
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') { |
$r->print(&make_dates_default($startdate,$enddate)); |
$r->print(&make_dates_default($startdate,$enddate,$context)); |
} |
} |
} |
} |
|
my $linktext = &mt('Display User Lists'); |
|
if ($choice eq 'drop') { |
|
$linktext = &mt('Display current class roster'); |
|
} |
|
$r->print('<a href="javascript:document.studentform.submit()">'.$linktext.'</a></form>'."\n"); |
} |
} |
|
|
sub classlist_drop { |
sub classlist_drop { |
my ($scope,$uname,$udom,$now,$action) = @_; |
my ($scope,$uname,$udom,$now) = @_; |
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)}); |
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)}); |
my $cid=$cdom.'_'.$cnum; |
if (&Apache::lonnet::is_course($cdom,$cnum)) { |
my $user = $uname.':'.$udom; |
my $user = $uname.':'.$udom; |
if ($action eq 'drop') { |
|
if (!&active_student_roles($cnum,$cdom,$uname,$udom)) { |
if (!&active_student_roles($cnum,$cdom,$uname,$udom)) { |
my $result = |
my $result = |
&Apache::lonnet::cput('classlist', |
&Apache::lonnet::cput('classlist', |
{ $user => $now }, |
{ $user => $now },$cdom,$cnum); |
$env{'course.'.$cid.'.domain'}, |
|
$env{'course.'.$cid.'.num'}); |
|
return &mt('Drop from classlist: [_1]', |
return &mt('Drop from classlist: [_1]', |
'<b>'.$result.'</b>').'<br />'; |
'<b>'.$result.'</b>').'<br />'; |
} |
} |
Line 3957 sub course_sections {
|
Line 4119 sub course_sections {
|
my ($sections_count,$role) = @_; |
my ($sections_count,$role) = @_; |
my $output = ''; |
my $output = ''; |
my @sections = (sort {$a <=> $b} keys %{$sections_count}); |
my @sections = (sort {$a <=> $b} keys %{$sections_count}); |
if (scalar(@sections) == 1) { |
my $numsec = scalar(@sections); |
|
if ($numsec <= 1) { |
$output = '<select name="currsec_'.$role.'" >'."\n". |
$output = '<select name="currsec_'.$role.'" >'."\n". |
' <option value="">Select</option>'."\n". |
' <option value="">'.&mt('Select').'</option>'."\n". |
' <option value="">No section</option>'."\n". |
' <option value="">'.&mt('No section').'</option>'."\n"; |
|
if ($numsec == 1) { |
|
$output .= |
' <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n"; |
' <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n"; |
|
} |
} else { |
} else { |
$output = '<select name="currsec_'.$role.'" '; |
$output = '<select name="currsec_'.$role.'" '; |
my $multiple = 4; |
my $multiple = 4; |
if (scalar(@sections) < 4) { $multiple = scalar(@sections); } |
if (scalar(@sections) < 4) { $multiple = scalar(@sections); } |
$output .= 'multiple="multiple" size="'.$multiple.'">'."\n"; |
if ($role eq 'st') { |
|
$output .= '>'."\n". |
|
' <option value="">'.&mt('Select').'</option>'."\n". |
|
' <option value="">'.&mt('No section')."</option>\n"; |
|
} else { |
|
$output .= 'multiple="multiple" size="'.$multiple.'">'."\n"; |
|
} |
foreach my $sec (@sections) { |
foreach my $sec (@sections) { |
$output .= '<option value="'.$sec.'">'.$sec."</option>\n"; |
$output .= '<option value="'.$sec.'">'.$sec."</option>\n"; |
} |
} |
Line 3986 sub get_groupslist {
|
Line 4158 sub get_groupslist {
|
} |
} |
|
|
sub setsections_javascript { |
sub setsections_javascript { |
my ($form,$groupslist) = @_; |
my ($formname,$groupslist,$mode,$checkauth) = @_; |
my ($checkincluded,$finish,$roleplace,$setsection_js); |
my ($checkincluded,$finish,$rolecode,$setsection_js); |
if ($form eq 'cu') { |
if ($mode eq 'upload') { |
|
$checkincluded = 'formname.name == "'.$formname.'"'; |
|
$finish = "return 'ok';"; |
|
$rolecode = "var role = formname.defaultrole.options[formname.defaultrole.selectedIndex].value;\n"; |
|
} elsif ($formname eq 'cu') { |
$checkincluded = 'formname.elements[i-1].checked == true'; |
$checkincluded = 'formname.elements[i-1].checked == true'; |
$finish = 'formname.submit()'; |
if ($checkauth) { |
$roleplace = 3; |
$finish = "var authcheck = auth_check();\n". |
|
" if (authcheck == 'ok') {\n". |
|
" formname.submit();\n". |
|
" }\n"; |
|
} else { |
|
$finish = 'formname.submit()'; |
|
} |
|
$rolecode = "var match = str.split('_'); |
|
var role = match[3];\n"; |
|
} elsif ($formname eq 'enrollstudent') { |
|
$checkincluded = 'formname.name == "'.$formname.'"'; |
|
if ($checkauth) { |
|
$finish = "var authcheck = auth_check();\n". |
|
" if (authcheck == 'ok') {\n". |
|
" formname.submit();\n". |
|
" }\n"; |
|
} else { |
|
$finish = 'formname.submit()'; |
|
} |
|
$rolecode = "var match = str.split('_'); |
|
var role = match[1];\n"; |
} else { |
} else { |
$checkincluded = 'formname.name == "'.$form.'"'; |
$checkincluded = 'formname.name == "'.$formname.'"'; |
$finish = "seccheck = 'ok';"; |
$finish = "seccheck = 'ok';"; |
$roleplace = 1; |
$rolecode = "var match = str.split('_'); |
|
var role = match[1];\n"; |
$setsection_js = "var seccheck = 'alert';"; |
$setsection_js = "var seccheck = 'alert';"; |
} |
} |
my %alerts = &Apache::lonlocal::texthash( |
my %alerts = &Apache::lonlocal::texthash( |
Line 4020 function setSections(formname) {
|
Line 4217 function setSections(formname) {
|
var checkcurr = str.match(re1); |
var checkcurr = str.match(re1); |
if (checkcurr != null) { |
if (checkcurr != null) { |
if ($checkincluded) { |
if ($checkincluded) { |
var match = str.split('_'); |
$rolecode |
var role = match[$roleplace]; |
|
if (role == 'cc') { |
if (role == 'cc') { |
alert("$alerts{'secd'}\\n$alerts{'accr'}"); |
alert("$alerts{'secd'}\\n$alerts{'accr'}"); |
} |
} |
Line 4096 sub can_create_user {
|
Line 4292 sub can_create_user {
|
my ($dom,$context,$usertype) = @_; |
my ($dom,$context,$usertype) = @_; |
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
my $cancreate = 1; |
my $cancreate = 1; |
|
if (&Apache::lonnet::allowed('mau',$dom)) { |
|
return $cancreate; |
|
} |
if (ref($domconf{'usercreation'}) eq 'HASH') { |
if (ref($domconf{'usercreation'}) eq 'HASH') { |
if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') { |
if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') { |
if ($context eq 'course' || $context eq 'author') { |
if ($context eq 'course' || $context eq 'author') { |
Line 4250 sub get_permission {
|
Line 4449 sub get_permission {
|
} else { |
} else { |
my @allroles = &roles_by_context($context); |
my @allroles = &roles_by_context($context); |
foreach my $role (@allroles) { |
foreach my $role (@allroles) { |
if (&Apache::lonnet::allowed('c'.$role,$env{'request.role.domain'})) { $permission{'cusr'} = 1; |
if (&Apache::lonnet::allowed('c'.$role,$env{'request.role.domain'})) { |
|
$permission{'cusr'} = 1; |
last; |
last; |
} |
} |
} |
} |
Line 4322 sub get_course_identity {
|
Line 4522 sub get_course_identity {
|
} |
} |
|
|
sub dc_setcourse_js { |
sub dc_setcourse_js { |
my ($formname,$mode) = @_; |
my ($formname,$mode,$context) = @_; |
my $dc_setcourse_code; |
my ($dc_setcourse_code,$authen_check); |
my $cctext = &Apache::lonnet::plaintext('cc'); |
my $cctext = &Apache::lonnet::plaintext('cc'); |
my %alerts = §ioncheck_alerts(); |
my %alerts = §ioncheck_alerts(); |
my $role = 'role'; |
my $role = 'role'; |
if ($mode eq 'upload') { |
if ($mode eq 'upload') { |
$role = 'courserole'; |
$role = 'courserole'; |
|
} else { |
|
$authen_check = &verify_authen($formname,$context); |
} |
} |
$dc_setcourse_code = (<<"SCRIPTTOP"); |
$dc_setcourse_code = (<<"SCRIPTTOP"); |
|
$authen_check |
|
|
function setCourse() { |
function setCourse() { |
var course = document.$formname.dccourse.value; |
var course = document.$formname.dccourse.value; |
if (course != "") { |
if (course != "") { |
Line 4415 SCRIPTTOP
|
Line 4619 SCRIPTTOP
|
} |
} |
} |
} |
} |
} |
document.$formname.submit(); |
var authcheck = auth_check(); |
|
if (authcheck == 'ok') { |
|
document.$formname.submit(); |
|
} |
} |
} |
|
|
ENDSCRIPT |
ENDSCRIPT |
} else { |
} else { |
$dc_setcourse_code .= " |
$dc_setcourse_code .= " |
Line 4438 ENDSCRIPT
|
Line 4644 ENDSCRIPT
|
return -1; |
return -1; |
} |
} |
ENDSCRIPT |
ENDSCRIPT |
|
return $dc_setcourse_code; |
|
} |
|
|
|
sub verify_authen { |
|
my ($formname,$context) = @_; |
|
my %alerts = &authcheck_alerts(); |
|
my $finish = "return 'ok';"; |
|
if ($context eq 'author') { |
|
$finish = "document.$formname.submit();"; |
|
} |
|
my $outcome = <<"ENDSCRIPT"; |
|
|
|
function auth_check() { |
|
var logintype; |
|
if (document.$formname.login.length) { |
|
if (document.$formname.login.length > 0) { |
|
var loginpicked = 0; |
|
for (var i=0; i<document.$formname.login.length; i++) { |
|
if (document.$formname.login[i].checked == true) { |
|
loginpicked = 1; |
|
logintype = document.$formname.login[i].value; |
|
} |
|
} |
|
if (loginpicked == 0) { |
|
alert("$alerts{'authen'}"); |
|
return; |
|
} |
|
} |
|
} else { |
|
logintype = document.$formname.login.value; |
|
} |
|
if (logintype == 'nochange') { |
|
return 'ok'; |
|
} |
|
var argpicked = document.$formname.elements[logintype+'arg'].value; |
|
if ((argpicked == null) || (argpicked == '') || (typeof argpicked == 'undefined')) { |
|
var alertmsg = ''; |
|
switch (logintype) { |
|
case 'krb': |
|
alertmsg = '$alerts{'krb'}'; |
|
break; |
|
case 'int': |
|
alertmsg = '$alerts{'ipass'}'; |
|
case 'fsys': |
|
alertmsg = '$alerts{'ipass'}'; |
|
break; |
|
case 'loc': |
|
alertmsg = ''; |
|
break; |
|
default: |
|
alertmsg = ''; |
|
} |
|
if (alertmsg != '') { |
|
alert(alertmsg); |
|
return; |
|
} |
|
} |
|
$finish |
|
} |
|
ENDSCRIPT |
} |
} |
|
|
sub sectioncheck_alerts { |
sub sectioncheck_alerts { |
Line 4459 sub sectioncheck_alerts {
|
Line 4725 sub sectioncheck_alerts {
|
return %alerts; |
return %alerts; |
} |
} |
|
|
|
sub authcheck_alerts { |
|
my %alerts = |
|
&Apache::lonlocal::texthash( |
|
authen => 'You must choose an authentication type.', |
|
krb => 'You need to specify the Kerberos domain.', |
|
ipass => 'You need to specify the initial password.', |
|
); |
|
return %alerts; |
|
} |
|
|
1; |
1; |
|
|