version 1.97.2.25, 2010/11/15 18:50:37
|
version 1.143, 2012/10/04 13:41:10
|
Line 47 sub modifystudent {
|
Line 47 sub modifystudent {
|
# this one. If $csec is defined, drop them from all other sections of |
# this one. If $csec is defined, drop them from all other sections of |
# this course and add them to section $csec |
# this course and add them to section $csec |
my ($cnum,$cdom) = &get_course_identity($courseid); |
my ($cnum,$cdom) = &get_course_identity($courseid); |
my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1}); |
my %roles = &Apache::lonnet::dump('roles',$udom,$unam); |
my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra); |
|
my ($tmp) = keys(%roles); |
my ($tmp) = keys(%roles); |
# Bail out if we were unable to get the students roles |
# Bail out if we were unable to get the students roles |
return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i); |
return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i); |
Line 1422 sub curr_role_permissions {
|
Line 1421 sub curr_role_permissions {
|
sub my_custom_roles { |
sub my_custom_roles { |
my ($crstype) = @_; |
my ($crstype) = @_; |
my %returnhash=(); |
my %returnhash=(); |
|
my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1}); |
my %rolehash=&Apache::lonnet::dump('roles'); |
my %rolehash=&Apache::lonnet::dump('roles'); |
foreach my $key (keys(%rolehash)) { |
foreach my $key (keys(%rolehash)) { |
if ($key=~/^rolesdef\_(\w+)$/) { |
if ($key=~/^rolesdef\_(\w+)$/) { |
Line 1444 sub print_userlist {
|
Line 1444 sub print_userlist {
|
if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
$env{'form.Status'} = 'Active'; |
$env{'form.Status'} = 'Active'; |
} |
} |
|
my $onchange = "javascript:updateCols('Status');"; |
my $status_select = &Apache::lonhtmlcommon::StatusOptions |
my $status_select = &Apache::lonhtmlcommon::StatusOptions |
($env{'form.Status'}); |
($env{'form.Status'},undef,undef,$onchange); |
|
|
if ($env{'form.showrole'} eq '') { |
if ($env{'form.showrole'} eq '') { |
if ($context eq 'course') { |
if ($context eq 'course') { |
Line 1478 sub print_userlist {
|
Line 1479 sub print_userlist {
|
$r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n". |
$r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n". |
'<input type="hidden" name="action" value="'. |
'<input type="hidden" name="action" value="'. |
$env{'form.action'}.'" />'); |
$env{'form.action'}.'" />'); |
$r->print("<p>\n"); |
$r->print('<div>'."\n"); |
if ($env{'form.action'} ne 'modifystudent') { |
if ($env{'form.action'} ne 'modifystudent') { |
my %lt=&Apache::lonlocal::texthash('csv' => "CSV", |
my %lt=&Apache::lonlocal::texthash('csv' => "CSV", |
'excel' => "Excel", |
'excel' => "Excel", |
'html' => 'HTML'); |
'html' => 'HTML'); |
my $output_selector = '<select size="1" name="output" >'; |
my $output_selector = '<select size="1" name="output" onchange="javascript:updateCols('."'output'".');" >'; |
foreach my $outputformat ('html','csv','excel') { |
foreach my $outputformat ('html','csv','excel') { |
my $option = '<option value="'.$outputformat.'"'; |
my $option = '<option value="'.$outputformat.'"'; |
if ($outputformat eq $env{'form.output'}) { |
if ($outputformat eq $env{'form.output'}) { |
Line 1493 sub print_userlist {
|
Line 1494 sub print_userlist {
|
$output_selector .= "\n".$option; |
$output_selector .= "\n".$option; |
} |
} |
$output_selector .= '</select>'; |
$output_selector .= '</select>'; |
$r->print('<label><span class="LC_nobreak">' |
$r->print('<span class="LC_nobreak">' |
.&mt('Output Format: [_1]',$output_selector) |
.&mt('Output Format: [_1]',$output_selector) |
.'</span></label>'.(' 'x3)); |
.'</span>'.(' 'x3)); |
} |
} |
$r->print('<label><span class="LC_nobreak">' |
$r->print('<span class="LC_nobreak">' |
.&mt('User Status: [_1]',$status_select) |
.&mt('User Status: [_1]',$status_select) |
.'</span></label>'.(' 'x3)."\n"); |
.'</span>'.(' 'x3)."\n"); |
my $roleselected = ''; |
my $roleselected = ''; |
if ($env{'form.showrole'} eq 'Any') { |
if ($env{'form.showrole'} eq 'Any') { |
$roleselected = ' selected="selected"'; |
$roleselected = ' selected="selected"'; |
Line 1510 sub print_userlist {
|
Line 1511 sub print_userlist {
|
($cnum,$cdom) = &get_course_identity(); |
($cnum,$cdom) = &get_course_identity(); |
$r->print(§ion_group_filter($cnum,$cdom)); |
$r->print(§ion_group_filter($cnum,$cdom)); |
} |
} |
|
$r->print('</div><div class="LC_left_float">'. |
|
&column_checkboxes($context,$mode,$formname). |
|
'</div><br clear="all" />'); |
if ($env{'form.phase'} eq '') { |
if ($env{'form.phase'} eq '') { |
$r->print('<br /><br />'.&list_submit_button(&mt('Display List of Users')). |
$r->print(&list_submit_button(&mt('Display List of Users'))."\n". |
"\n</p>\n". |
|
'<input type="hidden" name="phase" value="" /></form>'); |
'<input type="hidden" name="phase" value="" /></form>'); |
return; |
return; |
} |
} |
if (!(($context eq 'domain') && |
if (!(($context eq 'domain') && |
(($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { |
(($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { |
$r->print( |
$r->print(&list_submit_button(&mt('Update Display'))."\n"); |
"\n</p>\n" |
} |
.'<p>' |
|
.&list_submit_button(&mt('Update Display')) |
my @cols = &infocolumns($context,$mode); |
."</p>\n" |
if (!@cols) { |
); |
$r->print('<hr /><span class="LC_warning">'. |
|
&mt('No user information selected for display.').'</span>'. |
|
'<input type="hidden" name="phase" value="display" /></form>'."\n"); |
|
return; |
} |
} |
my ($indexhash,$keylist) = &make_keylist_array(); |
my ($indexhash,$keylist) = &make_keylist_array(); |
my (%userlist,%userinfo,$clearcoursepick); |
my (%userlist,%userinfo,$clearcoursepick); |
if (($context eq 'domain') && |
if (($context eq 'domain') && |
($env{'form.roletype'} eq 'course') || |
($env{'form.roletype'} eq 'course') || |
($env{'form.roletype'} eq 'community')) { |
($env{'form.roletype'} eq 'community')) { |
my ($crstype,$numcodes,$title,$warning); |
my ($crstype,$numcodes,$title,$warning); |
if ($env{'form.roletype'} eq 'course') { |
if ($env{'form.roletype'} eq 'course') { |
Line 1542 sub print_userlist {
|
Line 1548 sub print_userlist {
|
$title = &mt('Select Communities'); |
$title = &mt('Select Communities'); |
$warning = &mt('Warning: data retrieval for multiple communities can take considerable time, as this operation is not currently optimized.'); |
$warning = &mt('Warning: data retrieval for multiple communities can take considerable time, as this operation is not currently optimized.'); |
} |
} |
|
my @standardnames = &Apache::loncommon::get_standard_codeitems(); |
my $courseform = |
my $courseform = |
&Apache::lonhtmlcommon::course_selection($formname,$numcodes, |
&Apache::lonhtmlcommon::course_selection($formname,$numcodes, |
$codetitles,$idlist,$idlist_titles,$crstype); |
$codetitles,$idlist,$idlist_titles,$crstype, |
|
\@standardnames); |
$r->print('<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n". |
$r->print('<p>'.&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::start_pick_box()."\n". |
&Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n". |
&Apache::lonhtmlcommon::row_title($title,'LC_oddrow_value')."\n". |
Line 1563 sub print_userlist {
|
Line 1571 sub print_userlist {
|
$r->print('<hr />'.&mt('Searching').' ...<br /> <br />'); |
$r->print('<hr />'.&mt('Searching').' ...<br /> <br />'); |
} |
} |
} else { |
} else { |
$r->print('<hr />'.&mt('Searching').' ...<br /> <br />'); |
$r->print('<hr /><div id="searching">'.&mt('Searching').' ...</div>'); |
} |
} |
$r->rflush(); |
$r->rflush(); |
if ($context eq 'course') { |
if ($context eq 'course') { |
Line 1683 sub print_userlist {
|
Line 1691 sub print_userlist {
|
} |
} |
} |
} |
if (keys(%userlist) == 0) { |
if (keys(%userlist) == 0) { |
|
my $msg = ''; |
if ($context eq 'author') { |
if ($context eq 'author') { |
$r->print(&mt('There are no co-authors to display.')."\n"); |
$msg = &mt('There are no co-authors to display.'); |
} elsif ($context eq 'domain') { |
} elsif ($context eq 'domain') { |
if ($env{'form.roletype'} eq 'domain') { |
if ($env{'form.roletype'} eq 'domain') { |
$r->print(&mt('There are no users with domain roles to display.')."\n"); |
$msg = &mt('There are no users with domain roles to display.'); |
} elsif ($env{'form.roletype'} eq 'author') { |
} elsif ($env{'form.roletype'} eq 'author') { |
$r->print(&mt('There are no authors or co-authors to display.')."\n"); |
$msg = &mt('There are no authors or co-authors to display.'); |
} elsif ($env{'form.roletype'} eq 'course') { |
} elsif ($env{'form.roletype'} eq 'course') { |
$r->print(&mt('There are no course users to display')."\n"); |
$msg = &mt('There are no course users to display'); |
} elsif ($env{'form.roletype'} eq 'community') { |
} elsif ($env{'form.roletype'} eq 'community') { |
$r->print(&mt('There are no community users to display')."\n"); |
$msg = &mt('There are no community users to display'); |
} |
} |
} elsif ($context eq 'course') { |
} elsif ($context eq 'course') { |
$r->print(&mt('There are no course users to display.')."\n"); |
$r->print(&mt('There are no course users to display.')."\n"); |
} |
} |
|
$r->print('<p class="LC_info"'.$msg.'</p>'."\n") if $msg; |
} else { |
} else { |
# Print out the available choices |
# Print out the available choices |
my $usercount; |
my $usercount; |
Line 1709 sub print_userlist {
|
Line 1719 sub print_userlist {
|
$permission,$env{'form.Status'},\%userlist,$keylist); |
$permission,$env{'form.Status'},\%userlist,$keylist); |
} |
} |
if (!$usercount) { |
if (!$usercount) { |
$r->print('<br /><span class="LC_warning">' |
$r->print('<br /><span class="LC_info">' |
.&mt('There are no users matching the search criteria.') |
.&mt('There are no users matching the search criteria.') |
.'</span>' |
.'</span>' |
); |
); |
Line 1717 sub print_userlist {
|
Line 1727 sub print_userlist {
|
} |
} |
$r->print('<input type="hidden" name="phase" value="'. |
$r->print('<input type="hidden" name="phase" value="'. |
$env{'form.phase'}.'" /></form>'); |
$env{'form.phase'}.'" /></form>'); |
|
return; |
} |
} |
|
|
sub role_filter { |
sub role_filter { |
Line 1729 sub role_filter {
|
Line 1740 sub role_filter {
|
my ($role_select); |
my ($role_select); |
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$role_select = &domain_roles_select(); |
$role_select = &domain_roles_select(); |
$output = '<label><span class="LC_nobreak">' |
$output = '<span class="LC_nobreak">' |
.&mt('Role Type: [_1]',$role_select) |
.&mt('Role Type: [_1]',$role_select) |
.'</span></label>'; |
.'</span>'; |
} else { |
} else { |
$role_select = '<select name="showrole">'."\n". |
$role_select = '<select name="showrole" onchange="javascript:updateCols('."'showrole'".');">'."\n". |
'<option value="Any" '.$roleselected.'>'. |
'<option value="Any" '.$roleselected.'>'. |
&mt('Any role').'</option>'; |
&mt('Any role').'</option>'; |
my ($roletype,$crstype); |
my ($roletype,$crstype); |
Line 1760 sub role_filter {
|
Line 1771 sub role_filter {
|
$role_select .= '<option value="'.$role.'"'.$roleselected.'>'.$plrole.'</option>'; |
$role_select .= '<option value="'.$role.'"'.$roleselected.'>'.$plrole.'</option>'; |
} |
} |
$role_select .= '</select>'; |
$role_select .= '</select>'; |
$output = '<label><span class="LC_nobreak">' |
$output = '<span class="LC_nobreak">' |
.&mt('Role: [_1]',$role_select) |
.&mt('Role: [_1]',$role_select) |
.'</span></label>'; |
.'</span>'; |
} |
} |
return $output; |
return $output; |
} |
} |
Line 1825 sub section_group_filter {
|
Line 1836 sub section_group_filter {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub infocolumns { |
|
my ($context,$mode) = @_; |
|
my @cols; |
|
if (($mode eq 'pickauthor') || ($mode eq 'autoenroll')) { |
|
@cols = &get_cols_array($context,$mode); |
|
} else { |
|
my @posscols = &get_cols_array($context,$mode); |
|
if ($env{'form.phase'} ne '') { |
|
my @checkedcols = &Apache::loncommon::get_env_multiple('form.showcol'); |
|
foreach my $col (@checkedcols) { |
|
if (grep(/^$col$/,@posscols)) { |
|
push(@cols,$col); |
|
} |
|
} |
|
} else { |
|
@cols = @posscols; |
|
} |
|
} |
|
return @cols; |
|
} |
|
|
|
sub get_cols_array { |
|
my ($context,$mode) = @_; |
|
my @cols; |
|
if ($mode eq 'pickauthor') { |
|
@cols = ('username','fullname','status','email'); |
|
} else { |
|
@cols = ('username','domain','id','fullname'); |
|
if ($context eq 'course') { |
|
push(@cols,'section'); |
|
} |
|
push(@cols,('start','end','role')); |
|
if ($context eq 'domain') { |
|
push (@cols,'extent'); |
|
} |
|
unless (($mode eq 'autoenroll') && ($env{'form.Status'} ne 'Any')) { |
|
push(@cols,'status'); |
|
} |
|
if ($context eq 'course') { |
|
push(@cols,'groups'); |
|
} |
|
push(@cols,'email'); |
|
if (($context eq 'course') && ($mode ne 'autoenroll')) { |
|
push(@cols,'lastlogin','clicker'); |
|
} |
|
if (($context eq 'course') && ($mode ne 'autoenroll') && |
|
($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) { |
|
push(@cols,'photos'); |
|
} |
|
} |
|
return @cols; |
|
} |
|
|
|
sub column_checkboxes { |
|
my ($context,$mode,$formname) = @_; |
|
my @cols = &get_cols_array($context,$mode); |
|
my @showncols = &Apache::loncommon::get_env_multiple('form.showcol'); |
|
my (%disabledchk,%unchecked); |
|
if ($env{'form.phase'} eq '') { |
|
$disabledchk{'status'} = 1; |
|
if ($context eq 'course') { |
|
$disabledchk{'role'} = 1; |
|
$unchecked{'photo'} = 1; |
|
} |
|
$unchecked{'clicker'} = 1; |
|
$unchecked{'start'} = 1; |
|
$unchecked{'end'} = 1; |
|
} else { |
|
if ($env{'form.Status'} ne 'Any') { |
|
$disabledchk{'status'} = 1; |
|
} |
|
if ($env{'form.showrole'} ne 'Any') { |
|
$disabledchk{'role'} = 1; |
|
} |
|
} |
|
my $numposs = scalar(@cols); |
|
my $numinrow = 8; |
|
my %lt = &get_column_names($context); |
|
my $output = '<fieldset><legend>'.&mt('Information to show').'</legend>'."\n".'<span class="LC_nobreak">'. |
|
'<input type="button" onclick="javascript:checkAll(document.'.$formname.'.showcol);" value="'.&mt('check all').'" />'. |
|
(' 'x3). |
|
'<input type="button" onclick="javascript:uncheckAll(document.'.$formname.'.showcol);" value="'.&mt('uncheck all').'" />'. |
|
'</span><table>'; |
|
|
|
for (my $i=0; $i<$numposs; $i++) { |
|
my $rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$output .= '</tr>'; |
|
} |
|
$output .= '<tr>'; |
|
} |
|
my $checked; |
|
if ($env{'form.phase'} eq '') { |
|
$checked = ' checked="checked"'; |
|
if ($unchecked{$cols[$i]}) { |
|
$checked = ''; |
|
} |
|
if ($disabledchk{$cols[$i]}) { |
|
$checked = ' disabled="disabled"'; |
|
} |
|
} elsif (grep(/^\Q$cols[$i]\E$/,@showncols)) { |
|
$checked = ' checked="checked"'; |
|
} elsif ($disabledchk{$cols[$i]}) { |
|
$checked = ' disabled="disabled"'; |
|
} |
|
if ($i == $numposs-1) { |
|
my $colsleft = $numinrow-$rem; |
|
if ($colsleft > 1) { |
|
$output .= '<td colspan="'.$colsleft.'">'; |
|
} else { |
|
$output .= '<td>'; |
|
} |
|
} else { |
|
$output .= '<td>'; |
|
} |
|
$output .= '<label><input id="showcol'.$cols[$i].'" type="checkbox" name="showcol" value="'.$cols[$i].'"'.$checked.' />'. |
|
$lt{$cols[$i]}.'</label></td>'; |
|
|
|
} |
|
$output .= '</tr></table></fieldset>'; |
|
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()" />'; |
} |
} |
|
|
|
sub get_column_names { |
|
my ($context) = @_; |
|
my %lt = &Apache::lonlocal::texthash( |
|
'username' => "username", |
|
'domain' => "domain", |
|
'id' => 'ID', |
|
'fullname' => "name", |
|
'section' => "section", |
|
'groups' => "active groups", |
|
'start' => "start date", |
|
'end' => "end date", |
|
'status' => "status", |
|
'role' => "role", |
|
'type' => "enroll type/action", |
|
'email' => "e-mail address", |
|
'photo' => "photo", |
|
'lastlogin' => "last login", |
|
'extent' => "extent", |
|
'ca' => "check all", |
|
'ua' => "uncheck all", |
|
'clicker' => "clicker-ID", |
|
); |
|
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { |
|
$lt{'extent'} = &mt('Course(s): description, section(s), status'); |
|
} elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') { |
|
$lt{'extent'} = &mt('Communities: description, section(s), status'); |
|
} elsif ($context eq 'author') { |
|
$lt{'extent'} = &mt('Author'); |
|
} |
|
return %lt; |
|
} |
|
|
sub gather_userinfo { |
sub gather_userinfo { |
my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_; |
my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_; |
my $viewablesec; |
my $viewablesec; |
Line 1993 function setCourseCat(formname) {
|
Line 2160 function setCourseCat(formname) {
|
if (formname.Year.options[formname.Year.selectedIndex].value == -1) { |
if (formname.Year.options[formname.Year.selectedIndex].value == -1) { |
return; |
return; |
} |
} |
courseSet('Year'); |
courseSet('$codetitles[0]'); |
for (var j=0; j<formname.Semester.length; j++) { |
for (var j=0; j<formname.Semester.length; j++) { |
if (formname.Semester.options[j].value == "$env{'form.Semester'}") { |
if (formname.Semester.options[j].value == "$env{'form.Semester'}") { |
formname.Semester.options[j].selected = true; |
formname.Semester.options[j].selected = true; |
Line 2002 function setCourseCat(formname) {
|
Line 2169 function setCourseCat(formname) {
|
if (formname.Semester.options[formname.Semester.selectedIndex].value == -1) { |
if (formname.Semester.options[formname.Semester.selectedIndex].value == -1) { |
return; |
return; |
} |
} |
courseSet('Semester'); |
courseSet('$codetitles[1]'); |
for (var j=0; j<formname.Department.length; j++) { |
for (var j=0; j<formname.Department.length; j++) { |
if (formname.Department.options[j].value == "$env{'form.Department'}") { formname.Department.options[j].selected = true; |
if (formname.Department.options[j].value == "$env{'form.Department'}") { formname.Department.options[j].selected = true; |
} |
} |
Line 2010 function setCourseCat(formname) {
|
Line 2177 function setCourseCat(formname) {
|
if (formname.Department.options[formname.Department.selectedIndex].value == -1) { |
if (formname.Department.options[formname.Department.selectedIndex].value == -1) { |
return; |
return; |
} |
} |
courseSet('Department'); |
courseSet('$codetitles[2]'); |
for (var j=0; j<formname.Number.length; j++) { |
for (var j=0; j<formname.Number.length; j++) { |
if (formname.Number.options[j].value == "$env{'form.Number'}") { |
if (formname.Number.options[j].value == "$env{'form.Number'}") { |
formname.Number.options[j].selected = true; |
formname.Number.options[j].selected = true; |
Line 2193 sub show_users_list {
|
Line 2360 sub show_users_list {
|
$sortby = 'username'; |
$sortby = 'username'; |
} |
} |
my $setting = $env{'form.roletype'}; |
my $setting = $env{'form.roletype'}; |
my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype); |
my ($cid,$cdom,$cnum,$classgroups,$crstype); |
if ($context eq 'course') { |
if ($context eq 'course') { |
$cid = $env{'request.course.id'}; |
$cid = $env{'request.course.id'}; |
$crstype = &Apache::loncommon::course_type(); |
$crstype = &Apache::loncommon::course_type(); |
Line 2203 sub show_users_list {
|
Line 2370 sub show_users_list {
|
if ($mode eq 'autoenroll') { |
if ($mode eq 'autoenroll') { |
$env{'form.showrole'} = 'st'; |
$env{'form.showrole'} = 'st'; |
} else { |
} else { |
if (! exists($env{'form.displayphotos'})) { |
|
$env{'form.displayphotos'} = 'off'; |
|
} |
|
$displayphotos = $env{'form.displayphotos'}; |
|
if (! exists($env{'form.displayclickers'})) { |
|
$env{'form.displayclickers'} = 'off'; |
|
} |
|
$displayclickers = $env{'form.displayclickers'}; |
|
if ($env{'course.'.$cid.'.internal.showphoto'}) { |
if ($env{'course.'.$cid.'.internal.showphoto'}) { |
$r->print(' |
$r->print(' |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 2226 function photowindow(photolink) {
|
Line 2385 function photowindow(photolink) {
|
</script> |
</script> |
'); |
'); |
} |
} |
$r->print(<<END); |
|
<input type="hidden" name="displayphotos" value="$displayphotos" /> |
|
<input type="hidden" name="displayclickers" value="$displayclickers" /> |
|
END |
|
} |
} |
} elsif ($context eq 'domain') { |
} elsif ($context eq 'domain') { |
if ($setting eq 'community') { |
if ($setting eq 'community') { |
Line 2239 END
|
Line 2394 END
|
} |
} |
} |
} |
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') { |
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') { |
my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript(); |
|
my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode); |
my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode); |
my $verify_action_js = &bulkaction_javascript($formname); |
my $verify_action_js = &bulkaction_javascript($formname); |
$r->print(<<END); |
$r->print(<<END); |
|
|
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
// <![CDATA[ |
// <![CDATA[ |
$check_uncheck_js |
|
|
|
$verify_action_js |
$verify_action_js |
|
|
Line 2304 END
|
Line 2457 END
|
$r->print(<<END); |
$r->print(<<END); |
<input type="hidden" name="sortby" value="$sortby" /> |
<input type="hidden" name="sortby" value="$sortby" /> |
END |
END |
|
my @cols = &infocolumns($context,$mode); |
my %lt=&Apache::lonlocal::texthash( |
my %coltxt = &get_column_names($context); |
'username' => "username", |
my %acttxt = &Apache::lonlocal::texthash( |
'domain' => "domain", |
|
'id' => 'ID', |
|
'fullname' => "name", |
|
'section' => "section", |
|
'groups' => "active groups", |
|
'start' => "start date", |
|
'end' => "end date", |
|
'status' => "status", |
|
'role' => "role", |
|
'type' => "enroll type/action", |
|
'email' => "e-mail address", |
|
'photo' => "photo", |
|
'extent' => "extent", |
|
'pr' => "Proceed", |
'pr' => "Proceed", |
'ca' => "check all", |
|
'ua' => "uncheck all", |
|
'ac' => "Action to take for selected users", |
'ac' => "Action to take for selected users", |
'link' => "Behavior of clickable username link for each user", |
'link' => "Behavior of clickable username link for each user", |
'aboutme' => "Display a user's personal information page", |
'aboutme' => "Display a user's personal information page", |
'owin' => "Open in a new window", |
'owin' => "Open in a new window", |
'modify' => "Modify a user's information", |
'modify' => "Modify a user's information", |
'track' => "View a user's recent activity", |
'track' => "View a user's recent activity", |
'clicker' => "Clicker-ID", |
|
); |
); |
if ($context eq 'domain' && $env{'form.roletype'} eq 'course') { |
my %lt = (%coltxt,%acttxt); |
$lt{'extent'} = &mt('Course(s): description, section(s), status'); |
|
} elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') { |
|
$lt{'extent'} = &mt('Communities: description, section(s), status'); |
|
} elsif ($context eq 'author') { |
|
$lt{'extent'} = &mt('Author'); |
|
} |
|
my @cols; |
|
if ($mode eq 'pickauthor') { |
|
@cols = ('username','fullname','status','email'); |
|
} else { |
|
@cols = ('username','domain','id','fullname'); |
|
if ($context eq 'course') { |
|
push(@cols,'section'); |
|
} |
|
if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course') |
|
&& ($env{'form.roletype'} eq 'community'))) { |
|
push(@cols,('start','end')); |
|
} |
|
if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') { |
|
push(@cols,'role'); |
|
} |
|
if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' || |
|
$env{'form.roletype'} eq 'course' || |
|
$env{'form.roletype'} eq 'community')) { |
|
push (@cols,'extent'); |
|
} |
|
if (($statusmode eq 'Any') && |
|
(!($context eq 'domain' && (($env{'form.roletype'} eq 'course') |
|
|| ($env{'form.roletype'} eq 'community'))))) { |
|
push(@cols,'status'); |
|
} |
|
if ($context eq 'course') { |
|
push(@cols,'groups'); |
|
} |
|
push(@cols,'email'); |
|
} |
|
|
|
my $rolefilter = $env{'form.showrole'}; |
my $rolefilter = $env{'form.showrole'}; |
if ($env{'form.showrole'} eq 'cr') { |
if ($env{'form.showrole'} eq 'cr') { |
$rolefilter = &mt('custom'); |
$rolefilter = &mt('custom'); |
Line 2379 END
|
Line 2479 END
|
if ($mode ne 'autoenroll') { |
if ($mode ne 'autoenroll') { |
$results_description = &results_header_row($rolefilter,$statusmode, |
$results_description = &results_header_row($rolefilter,$statusmode, |
$context,$permission,$mode,$crstype); |
$context,$permission,$mode,$crstype); |
|
$r->print('<b>'.$results_description.'</b><br clear="all" />'); |
$r->print('<b>'.$results_description.'</b><br /><br />'); |
|
} |
} |
my ($output,$actionselect,%canchange,%canchangesec); |
my ($output,$actionselect,%canchange,%canchangesec); |
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { |
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { |
Line 2401 END
|
Line 2500 END
|
END |
END |
if ($actionselect) { |
if ($actionselect) { |
$output .= <<"END"; |
$output .= <<"END"; |
<div class="LC_left_float"><fieldset><legend><b>$lt{'ac'}</b></legend> |
<div class="LC_left_float"><fieldset><legend>$lt{'ac'}</legend> |
$actionselect |
$actionselect |
<br/><br /><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.$formname.actionlist)" /> |
<br/><br /><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.$formname.actionlist)" /> |
<input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.$formname.actionlist)" /><br /><input type="button" value="$lt{'pr'}" onclick="javascript:verify_action('actionlist')" /></fieldset></div> |
<input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.$formname.actionlist)" /><br /><input type="button" value="$lt{'pr'}" onclick="javascript:verify_action('actionlist')" /></fieldset></div> |
Line 2442 END
|
Line 2541 END
|
if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { |
if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { |
$canchangesec{$role} = $env{'request.course.sec'}; |
$canchangesec{$role} = $env{'request.course.sec'}; |
} |
} |
|
} elsif ((($role eq 'co') && ($crstype eq 'Community')) || |
|
(($role eq 'cc') && ($crstype eq 'Course'))) { |
|
if (&is_courseowner($env{'request.course.id'}, |
|
$env{'course.'.$env{'request.course.id'}.'.internal.courseowner'})) { |
|
$canchange{$role} = 1; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
$output .= '<div class="LC_left_float"><fieldset><legend><b>'.$lt{'link'}.'</b></legend>'. |
$output .= '<div class="LC_left_float"><fieldset><legend>'.$lt{'link'}.'</legend>'. |
'<table><tr>'; |
'<table><tr>'; |
my @linkdests = ('aboutme'); |
my @linkdests = ('aboutme'); |
if ($permission->{'cusr'}) { |
if ($permission->{'cusr'}) { |
Line 2457 END
|
Line 2562 END
|
$env{'request.course.sec'})) { |
$env{'request.course.sec'})) { |
push(@linkdests,'track'); |
push(@linkdests,'track'); |
} |
} |
|
|
$output .= '<td>'; |
$output .= '<td>'; |
my $usernamelink = $env{'form.usernamelink'}; |
my $usernamelink = $env{'form.usernamelink'}; |
if ($usernamelink eq '') { |
if ($usernamelink eq '') { |
Line 2473 END
|
Line 2579 END
|
if ($env{'form.userwin'}) { |
if ($env{'form.userwin'}) { |
$checkwin = ' checked="checked"'; |
$checkwin = ' checked="checked"'; |
} |
} |
$output .= '</td><td valign="top" style="border-left: 1px solid;><span class="LC_nobreak"><input type="checkbox" name="userwin" value="1"'.$checkwin.' />'.$lt{'owin'}.'</span></td></tr></table></fieldset></div>'; |
$output .= '</td><td valign="top" style="border-left: 1px solid;"><span class="LC_nobreak"><input type="checkbox" name="userwin" value="1"'.$checkwin.' />'.$lt{'owin'}.'</span></td></tr></table></fieldset></div>'; |
} |
} |
$output .= "\n".'<div class="LC_clear_float_footer"> </div>'."\n". |
$output .= "\n".'<br clear="all" />'."\n". |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(); |
&Apache::loncommon::start_data_table_header_row(); |
if ($mode eq 'autoenroll') { |
if ($mode eq 'autoenroll') { |
Line 2492 END
|
Line 2598 END
|
$output .= "<th><a href=\"javascript:document.$formname.sortby.value='$item';document.$formname.submit();\">$lt{$item}</a></th>\n"; |
$output .= "<th><a href=\"javascript:document.$formname.sortby.value='$item';document.$formname.submit();\">$lt{$item}</a></th>\n"; |
} |
} |
my %role_types = &role_type_names(); |
my %role_types = &role_type_names(); |
if ($context eq 'course' && $mode ne 'autoenroll') { |
|
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') { |
|
# Clicker display on or off? |
|
my %clicker_options = ( |
|
'on' => 'Show', |
|
'off' => 'Hide', |
|
); |
|
my $clickerchg = 'on'; |
|
if ($displayclickers eq 'on') { |
|
$clickerchg = 'off'; |
|
} |
|
$output .= ' <th>'."\n".' ' |
|
.&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id' |
|
,'<a href="javascript:document.'.$formname.'.displayclickers.value=' |
|
."'".$clickerchg."'".';document.'.$formname.'.submit();">' |
|
,'</a>') |
|
."\n".' </th>'."\n"; |
|
|
|
# Photo display on or off? |
|
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { |
|
my %photo_options = &Apache::lonlocal::texthash( |
|
'on' => 'Show', |
|
'off' => 'Hide', |
|
); |
|
my $photochg = 'on'; |
|
if ($displayphotos eq 'on') { |
|
$photochg = 'off'; |
|
} |
|
$output .= ' <th>'."\n".' '. |
|
'<a href="javascript:document.'.$formname.'.displayphotos.value='. |
|
"'".$photochg."'".';document.'.$formname.'.submit();">'. |
|
$photo_options{$photochg}.'</a> '.$lt{'photo'}."\n". |
|
' </th>'."\n"; |
|
} |
|
} |
|
} |
|
$output .= &Apache::loncommon::end_data_table_header_row(); |
$output .= &Apache::loncommon::end_data_table_header_row(); |
# Done with the HTML header line |
# Done with the HTML header line |
} elsif ($mode eq 'csv') { |
} elsif ($mode eq 'csv') { |
Line 2548 END
|
Line 2618 END
|
$CSVfile = undef; |
$CSVfile = undef; |
} |
} |
# |
# |
push @cols,'clicker'; |
|
# Write headers and data to file |
# Write headers and data to file |
print $CSVfile '"'.$results_description.'"'."\n"; |
print $CSVfile '"'.$results_description.'"'."\n"; |
print $CSVfile '"'.join('","',map { |
print $CSVfile '"'.join('","',map { |
&Apache::loncommon::csv_translate($lt{$_}) |
&Apache::loncommon::csv_translate($lt{$_}) |
} (@cols))."\"\n"; |
} (@cols))."\"\n"; |
} elsif ($mode eq 'excel') { |
} elsif ($mode eq 'excel') { |
push @cols,'clicker'; |
|
# Create the excel spreadsheet |
# Create the excel spreadsheet |
($excel_workbook,$excel_filename,$format) = |
($excel_workbook,$excel_filename,$format) = |
&Apache::loncommon::create_workbook($r); |
&Apache::loncommon::create_workbook($r); |
Line 2591 END
|
Line 2659 END
|
Future => 'Future', |
Future => 'Future', |
Expired => 'Expired', |
Expired => 'Expired', |
); |
); |
|
# If this is for a single course get last course "log-in". |
|
my %crslogins; |
|
if ($context eq 'course') { |
|
%crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum); |
|
} |
# 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 2674 END
|
Line 2747 END
|
} |
} |
} |
} |
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { |
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { |
if (($displayphotos eq 'on') && ($role eq 'st')) { |
if ((grep/^photo$/,@cols) && ($role eq 'st')) { |
$userlist->{$user}->[$index{'photo'}] = |
$userlist->{$user}->[$index{'photo'}] = |
&Apache::lonnet::retrievestudentphoto($udom,$uname,'jpg'); |
&Apache::lonnet::retrievestudentphoto($udom,$uname,'jpg'); |
$userlist->{$user}->[$index{'thumbnail'}] = |
$userlist->{$user}->[$index{'thumbnail'}] = |
Line 2726 END
|
Line 2799 END
|
if ($clickers!~/\w/) { $clickers='-'; } |
if ($clickers!~/\w/) { $clickers='-'; } |
$in{'clicker'} = $clickers; |
$in{'clicker'} = $clickers; |
my $role = $in{'role'}; |
my $role = $in{'role'}; |
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); |
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); |
if (! defined($in{'start'}) || $in{'start'} == 0) { |
unless ($mode eq 'excel') { |
$in{'start'} = &mt('none'); |
if (! defined($in{'start'}) || $in{'start'} == 0) { |
} else { |
$in{'start'} = &mt('none'); |
$in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'}); |
} else { |
|
$in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'}); |
|
} |
|
if (! defined($in{'end'}) || $in{'end'} == 0) { |
|
$in{'end'} = &mt('none'); |
|
} else { |
|
$in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'}); |
|
} |
} |
} |
if (! defined($in{'end'}) || $in{'end'} == 0) { |
if ($context eq 'course') { |
$in{'end'} = &mt('none'); |
my $lastlogin = $crslogins{$in{'username'}.':'.$in{'domain'}.':'.$in{'section'}.':'.$role}; |
} else { |
if ($lastlogin ne '') { |
$in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'}); |
$in{'lastlogin'} = &Apache::lonlocal::locallocaltime($lastlogin); |
|
} |
} |
} |
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { |
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
Line 2781 END
|
Line 2862 END
|
if ($showcheckbox) { |
if ($showcheckbox) { |
$checkval = $user; |
$checkval = $user; |
if ($context eq 'course') { |
if ($context eq 'course') { |
if ($role eq 'st') { |
if (($role eq 'co' || $role eq 'cc') && |
$checkval .= ':st'; |
($user =~ /^\Q$env{'user.name'}:$env{'user.domain'}:$role\E/)) { |
} |
$showcheckbox = 0; |
$checkval .= ':'.$in{'section'}; |
} else { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$checkval .= ':'.$in{'type'}.':'. |
$checkval .= ':st'; |
$in{'lockedtype'}; |
} |
} |
$checkval .= ':'.$in{'section'}; |
|
if ($role eq 'st') { |
|
$checkval .= ':'.$in{'type'}.':'. |
|
$in{'lockedtype'}; |
|
} |
|
} |
|
} |
|
if ($showcheckbox) { |
|
$r->print('<td><input type="checkbox" name="'. |
|
'actionlist" value="'.$checkval.'" /></td>'); |
|
} else { |
|
$r->print('<td> </td>'); |
} |
} |
$r->print('<td><input type="checkbox" name="'. |
|
'actionlist" value="'.$checkval.'" /></td>'); |
|
} else { |
} else { |
$r->print('<td> </td>'); |
$r->print('<td> </td>'); |
} |
} |
Line 2810 END
|
Line 2900 END
|
$showitem = $ltstatus{$in{$item}}; |
$showitem = $ltstatus{$in{$item}}; |
} |
} |
$r->print('<td>'.$showitem.'</td>'."\n"); |
$r->print('<td>'.$showitem.'</td>'."\n"); |
} else { |
} elsif ($item eq 'photo') { |
$r->print('<td>'.$in{$item}.'</td>'."\n"); |
if (($context eq 'course') && ($mode ne 'autoenroll') && |
} |
($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) { |
} |
if ($role eq 'st') { |
if (($context eq 'course') && ($mode ne 'autoenroll')) { |
$r->print('<td align="right"><a href="javascript:photowindow('."'".$in{'photo'}."'".')"><img src="'.$in{'thumbnail'}.'" border="1" alt="" /></a></td>'); |
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') { |
} else { |
if ($displayclickers eq 'on') { |
$r->print('<td> </td>'); |
my $clickers = |
} |
|
} |
|
} elsif ($item eq 'clicker') { |
|
if (($context eq 'course') && ($mode ne 'autoenroll')) { |
|
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') { |
|
my $clickers = |
(&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1]; |
(&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1]; |
if ($clickers!~/\w/) { $clickers='-'; } |
if ($clickers!~/\w/) { $clickers='-'; } |
$r->print('<td>'.$clickers.'</td>'); |
$r->print('<td>'.$clickers.'</td>'); |
} else { |
|
$r->print(' <td> </td> '); |
|
} |
|
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { |
|
if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') { |
|
$r->print(' <td align="right"><a href="javascript:photowindow('."'".$in{'photo'}."'".')"><img src="'.$in{'thumbnail'}.'" border="1" alt="" /></a></td>'); |
|
} else { |
} else { |
$r->print(' <td> </td> '); |
$r->print('<td> </td>'."\n"); |
} |
} |
} |
} |
|
} else { |
|
$r->print('<td>'.$in{$item}.'</td>'."\n"); |
} |
} |
} |
} |
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::end_data_table_row()); |
} elsif ($mode eq 'csv') { |
} elsif ($mode eq 'csv') { |
next if (! defined($CSVfile)); |
next if (! defined($CSVfile)); |
# no need to bother with $linkto |
# no need to bother with $linkto |
if (! defined($in{'start'}) || $in{'start'} == 0) { |
|
$in{'start'} = &mt('none'); |
|
} else { |
|
$in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'}); |
|
} |
|
if (! defined($in{'end'}) || $in{'end'} == 0) { |
|
$in{'end'} = &mt('none'); |
|
} else { |
|
$in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'}); |
|
} |
|
my @line = (); |
my @line = (); |
foreach my $item (@cols) { |
foreach my $item (@cols) { |
push @line,&Apache::loncommon::csv_translate($in{$item}); |
push @line,&Apache::loncommon::csv_translate($in{$item}); |
Line 2856 END
|
Line 2937 END
|
my $col = 0; |
my $col = 0; |
foreach my $item (@cols) { |
foreach my $item (@cols) { |
if ($item eq 'start' || $item eq 'end') { |
if ($item eq 'start' || $item eq 'end') { |
if (defined($item) && $item != 0) { |
if ((defined($in{$item})) && ($in{$item} != 0)) { |
$excel_sheet->write($row,$col++, |
$excel_sheet->write($row,$col++, |
&Apache::lonstathelpers::calc_serial($in{item}), |
&Apache::lonstathelpers::calc_serial($in{$item}), |
$format->{'date'}); |
$format->{'date'}); |
} else { |
} else { |
$excel_sheet->write($row,$col++,'none'); |
$excel_sheet->write($row,$col++,'none'); |
Line 3046 sub select_actions {
|
Line 3127 sub select_actions {
|
} |
} |
if ($context eq 'course') { |
if ($context eq 'course') { |
if ($env{'form.showrole'} ne 'Any') { |
if ($env{'form.showrole'} ne 'Any') { |
if (!&Apache::lonnet::allowed('c'.$env{'form.showrole'}, |
my $showactions; |
$env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('c'.$env{'form.showrole'}, |
if ($env{'request.course.sec'} eq '') { |
$env{'request.course.id'})) { |
return; |
$showactions = 1; |
} else { |
} elsif ($env{'request.course.sec'} ne '') { |
if (!&Apache::lonnet::allowed('c'.$env{'form.showrole'},$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { |
if (&Apache::lonnet::allowed('c'.$env{'form.showrole'},$env{'request.course.id'}.'/'.$env{'request.course.sec'})) { |
return; |
$showactions = 1; |
} |
} |
} |
} |
|
unless ($showactions) { |
|
unless (&is_courseowner($env{'request.course.id'}, |
|
$env{'course.'.$env{'request.course.id'}.'.internal.courseowner'})) { |
|
return; |
|
} |
} |
} |
} |
} |
} |
} |
Line 3245 ENDJS
|
Line 3331 ENDJS
|
chse => 'Changes in section affiliation to apply to selected users', |
chse => 'Changes in section affiliation to apply to selected users', |
fors => 'For student roles, changing the section will result in a section switch as students may only be in one section of a course at a time.', |
fors => 'For student roles, changing the section will result in a section switch as students may only be in one section of a course at a time.', |
forn => 'For a course role that is not "student", users may have roles in more than one section at a time.', |
forn => 'For a course role that is not "student", users may have roles in more than one section at a time.', |
reta => "Retain each user's current section affiliations?", |
reta => "Retain each user's current section affiliations?", |
dnap => '(Does not apply to student roles).', |
dnap => '(Does not apply to student roles).', |
); |
); |
my ($date_items,$headertext); |
my ($date_items,$headertext); |
Line 3478 sub results_header_row {
|
Line 3564 sub results_header_row {
|
} |
} |
} elsif (($env{'form.roletype'} eq 'course') || |
} elsif (($env{'form.roletype'} eq 'course') || |
($env{'form.roletype'} eq 'community')) { |
($env{'form.roletype'} eq 'community')) { |
|
|
my $coursefilter = $env{'form.coursepick'}; |
my $coursefilter = $env{'form.coursepick'}; |
if ($env{'form.roletype'} eq 'course') { |
if ($env{'form.roletype'} eq 'course') { |
if ($coursefilter eq 'category') { |
if ($coursefilter eq 'category') { |
Line 3581 END
|
Line 3666 END
|
} |
} |
} |
} |
if (!$studentcount) { |
if (!$studentcount) { |
|
my $msg = ''; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$r->print(&mt('There are no members to drop.')); |
$msg = &mt('There are no members to drop.'); |
} else { |
} else { |
$r->print(&mt('There are no students to drop.')); |
$msg = &mt('There are no students to drop.'); |
} |
} |
|
$r->print('<p class="LC_info">'.$msg.'</p>'); |
return; |
return; |
} |
} |
my ($classgroups) = &Apache::loncoursedata::get_group_memberships( |
my ($classgroups) = &Apache::loncoursedata::get_group_memberships( |
Line 3742 sub print_first_users_upload_form {
|
Line 3829 sub print_first_users_upload_form {
|
&mt("How do I create a CSV file from a spreadsheet")) |
&mt("How do I create a CSV file from a spreadsheet")) |
.'</div><br clear="all" />'."\n"; |
.'</div><br clear="all" />'."\n"; |
$str .= &Apache::lonhtmlcommon::start_pick_box() |
$str .= &Apache::lonhtmlcommon::start_pick_box() |
.&Apache::lonhtmlcommon::row_title(&mt('File')) |
.&Apache::lonhtmlcommon::row_title(&mt('File')); |
.&Apache::loncommon::upfile_select_html() |
if (&Apache::lonlocal::current_language() ne 'en') { |
|
if ($context eq 'course') { |
|
$str .= '<p class="LC_info">'."\n" |
|
.&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n" |
|
.'</p>'."\n"; |
|
} |
|
} |
|
$str .= &Apache::loncommon::upfile_select_html() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_closure() |
.&Apache::lonhtmlcommon::row_title( |
.&Apache::lonhtmlcommon::row_title( |
'<label for="noFirstLine">' |
'<label for="noFirstLine">' |
Line 3877 sub upfile_drop_add {
|
Line 3971 sub upfile_drop_add {
|
} elsif ($setting eq 'course') { |
} elsif ($setting eq 'course') { |
$defaultrole = $env{'form.courserole'}; |
$defaultrole = $env{'form.courserole'}; |
$defaultsec = $env{'form.sections'}; |
$defaultsec = $env{'form.sections'}; |
} |
} |
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
$defaultrole = $env{'form.defaultrole'}; |
$defaultrole = $env{'form.defaultrole'}; |
} elsif ($context eq 'course') { |
} elsif ($context eq 'course') { |
Line 3987 sub upfile_drop_add {
|
Line 4081 sub upfile_drop_add {
|
my (%curr_rules,%got_rules,%alerts,%cancreate); |
my (%curr_rules,%got_rules,%alerts,%cancreate); |
my %customroles = &my_custom_roles($crstype); |
my %customroles = &my_custom_roles($crstype); |
my @permitted_roles = |
my @permitted_roles = |
&roles_on_upload($context,$setting,$crstype,%customroles); |
&roles_on_upload($context,$setting,$crstype,%customroles); |
my %longtypes = &Apache::lonlocal::texthash( |
my %longtypes = &Apache::lonlocal::texthash( |
official => 'Institutional', |
official => 'Institutional', |
unofficial => 'Non-institutional', |
unofficial => 'Non-institutional', |
); |
); |
map { $cancreate{$_} = &can_create_user($domain,$context,$_); } keys(%longtypes); |
my $newuserdom = $env{'request.role.domain'}; |
|
map { $cancreate{$_} = &can_create_user($newuserdom,$context,$_); } keys(%longtypes); |
# Get new users list |
# Get new users list |
foreach my $line (@userdata) { |
foreach my $line (@userdata) { |
my @secs; |
my @secs; |
Line 4019 sub upfile_drop_add {
|
Line 4114 sub upfile_drop_add {
|
$gen=$entries{$fields{'gen'}}; |
$gen=$entries{$fields{'gen'}}; |
} |
} |
} |
} |
|
|
if ($entries{$fields{'username'}} |
if ($entries{$fields{'username'}} |
ne &LONCAPA::clean_username($entries{$fields{'username'}})) { |
ne &LONCAPA::clean_username($entries{$fields{'username'}})) { |
my $nowhitespace; |
my $nowhitespace; |
Line 4146 sub upfile_drop_add {
|
Line 4242 sub upfile_drop_add {
|
my (%rulematch,%inst_results,%idinst_results); |
my (%rulematch,%inst_results,%idinst_results); |
my $uhome=&Apache::lonnet::homeserver($username,$userdomain); |
my $uhome=&Apache::lonnet::homeserver($username,$userdomain); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
if ($userdomain ne $domain) { |
if ($userdomain ne $newuserdom) { |
$r->print('<br />'. |
if ($context eq 'course') { |
&mt('[_1]: The domain specified ([_2]) is different to that of the course.', |
$r->print('<br />'. |
'<b>'.$username.'</b>',$userdomain).'<br />'. |
&mt('[_1]: The domain specified ([_2]) is different to that of the course.', |
&mt('The user does not already exist, and you may not create a new user in a different domain.')); |
'<b>'.$username.'</b>',$userdomain).'<br />'); |
|
} elsif ($context eq 'author') { |
|
$r->print(&mt('[_1]: The domain specified ([_2]) is different to that of the author.', |
|
'<b>'.$username.'</b>',$userdomain).'<br />'); |
|
} else { |
|
$r->print(&mt('[_1]: The domain specified ([_2]) is different to that of your current role.', |
|
'<b>'.$username.'</b>',$userdomain).'<br />'); |
|
} |
|
$r->print(&mt('The user does not already exist, and you may not create a new user in a different domain.')); |
next; |
next; |
} |
} |
$checkid = 1; |
$checkid = 1; |
$newuser = 1; |
$newuser = 1; |
my $user = $username.':'.$domain; |
my $user = $username.':'.$newuserdom; |
my $checkhash; |
my $checkhash; |
my $checks = { 'username' => 1 }; |
my $checks = { 'username' => 1 }; |
$checkhash->{$username.':'.$domain} = { 'newuser' => 1, }; |
$checkhash->{$username.':'.$newuserdom} = { 'newuser' => 1, }; |
&Apache::loncommon::user_rule_check($checkhash,$checks, |
&Apache::loncommon::user_rule_check($checkhash,$checks, |
\%alerts,\%rulematch,\%inst_results,\%curr_rules, |
\%alerts,\%rulematch,\%inst_results,\%curr_rules, |
\%got_rules); |
\%got_rules); |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if (ref($alerts{'username'}{$newuserdom}) eq 'HASH') { |
if ($alerts{'username'}{$domain}{$username}) { |
if ($alerts{'username'}{$newuserdom}{$username}) { |
$r->print('<br />'. |
$r->print('<br />'. |
&mt('[_1]: matches the username format at your institution, but is not known to your directory service.','<b>'.$username.'</b>').'<br />'. |
&mt('[_1]: matches the username format at your institution, but is not known to your directory service.','<b>'.$username.'</b>').'<br />'. |
&mt('Consequently, the user was not created.')); |
&mt('Consequently, the user was not created.')); |
Line 4271 sub upfile_drop_add {
|
Line 4375 sub upfile_drop_add {
|
$role = 'cr_'.$env{'user.domain'}.'_'. |
$role = 'cr_'.$env{'user.domain'}.'_'. |
$env{'user.name'}.'_'.$role; |
$env{'user.name'}.'_'.$role; |
} |
} |
if (($role ne 'cc') && ($role ne 'co')) { |
if (($role ne 'cc') && ($role ne 'co')) { |
if (@secs > 1) { |
if (@secs > 1) { |
$multiple = 1; |
$multiple = 1; |
foreach my $sec (@secs) { |
foreach my $sec (@secs) { |
Line 4359 sub upfile_drop_add {
|
Line 4463 sub upfile_drop_add {
|
if (! defined($classlist)) { |
if (! defined($classlist)) { |
$r->print('<form name="studentform" method="post" action="/adm/createuser" />'. |
$r->print('<form name="studentform" method="post" action="/adm/createuser" />'. |
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'. |
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'. |
&mt('There are no students with current/future access to the course.'). |
'<p class="LC_info">'.&mt('There are no students with current/future access to the course.').'</p>'. |
'</form>'."\n"); |
'</form>'."\n"); |
} elsif (ref($classlist) eq 'HASH') { |
} elsif (ref($classlist) eq 'HASH') { |
# Remove the students we just added from the list of students. |
# Remove the students we just added from the list of students. |
Line 4483 sub print_drop_menu {
|
Line 4587 sub print_drop_menu {
|
'<form name="studentform" method="post">'."\n"); |
'<form name="studentform" method="post">'."\n"); |
my $classlist = &Apache::loncoursedata::get_classlist(); |
my $classlist = &Apache::loncoursedata::get_classlist(); |
if (! defined($classlist)) { |
if (! defined($classlist)) { |
|
my $msg = ''; |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$r->print(&mt('There are no members currently enrolled.')."\n"); |
$msg = &mt('There are no members currently enrolled.'); |
} else { |
} else { |
$r->print(&mt('There are no students currently enrolled.')."\n"); |
$msg = &mt('There are no students currently enrolled.'); |
} |
} |
|
$r->print('<p class="LC_info">'.$msg."</p>\n"); |
} else { |
} else { |
&show_drop_list($r,$classlist,'nosort',$permission,$crstype); |
&show_drop_list($r,$classlist,'nosort',$permission,$crstype); |
} |
} |
Line 4677 sub update_user_list {
|
Line 4783 sub update_user_list {
|
if ($sec eq '') { |
if ($sec eq '') { |
$nochg = 1; |
$nochg = 1; |
$keepnosection = 1; |
$keepnosection = 1; |
} else { |
} else { |
push(@retained,$sec); |
push(@retained,$sec); |
} |
} |
} |
} |
Line 4706 sub update_user_list {
|
Line 4812 sub update_user_list {
|
$result = 'ok'; |
$result = 'ok'; |
$nothingtodo = 1; |
$nothingtodo = 1; |
} else { |
} else { |
foreach my $newsec (@newsecs) { |
foreach my $newsec (@newsecs) { |
if (!grep(/^\Q$newsec\E$/,@retained)) { |
if (!grep(/^\Q$newsec\E$/,@retained)) { |
if ($role eq 'st') { |
if ($role eq 'st') { |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid,'',$context); |
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$newsec,$end,$start,$type,$locktype,$cid,'',$context); |
if (@newsecs > 1) { |
if (@newsecs > 1) { |
my $showsingle; |
my $showsingle; |
if ($newsec eq '') { |
if ($newsec eq '') { |
$showsingle = &mt('No section'); |
$showsingle = &mt('No section'); |
} else { |
} else { |
Line 4719 sub update_user_list {
|
Line 4825 sub update_user_list {
|
} |
} |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$warn_singlesec = &mt('Although more than one section was indicated, a role was only added for the first section - [_1], as each community member may only be in one section at a time.','<i>'.$showsingle.'</i>'); |
$warn_singlesec = &mt('Although more than one section was indicated, a role was only added for the first section - [_1], as each community member may only be in one section at a time.','<i>'.$showsingle.'</i>'); |
} else { |
} else { |
$warn_singlesec = &mt('Although more than one section was indicated, a role was only added for the first section - [_1], as each student may only be in one section of a course at a time.','<i>'.$showsingle.'</i>'); |
$warn_singlesec = &mt('Although more than one section was indicated, a role was only added for the first section - [_1], as each student may only be in one section of a course at a time.','<i>'.$showsingle.'</i>'); |
} |
} |
$showsecs = $showsingle; |
$showsecs = $showsingle; |
last; |
last; |
} else { |
} else { |
if ($newsec eq '') { |
if ($newsec eq '') { |
Line 4735 sub update_user_list {
|
Line 4841 sub update_user_list {
|
my $newscope = $scopestem; |
my $newscope = $scopestem; |
if ($newsec ne '') { |
if ($newsec ne '') { |
$newscope .= '/'.$newsec; |
$newscope .= '/'.$newsec; |
push(@shownew,$newsec); |
push(@shownew,$newsec); |
} |
} |
$result = &Apache::lonnet::assignrole($udom,$uname, |
$result = &Apache::lonnet::assignrole($udom,$uname, |
$newscope,$role,$end,$start); |
$newscope,$role,$end,$start); |
|
|
} |
} |
} |
} |
} |
} |
Line 4788 sub update_user_list {
|
Line 4895 sub update_user_list {
|
$r->print('<div class="LC_warning">'.$warn_singlesec.'</div>'); |
$r->print('<div class="LC_warning">'.$warn_singlesec.'</div>'); |
} |
} |
} elsif ($choice eq 'chgdates') { |
} elsif ($choice eq 'chgdates') { |
$r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for '[_3]' - [_4]",$plrole,$extent, |
$r->print(&mt("$result_text{'ok'}{$choice} role of '[_1]' in [_2] for '[_3]' - [_4]",$plrole,$extent, |
'<i>'.&Apache::loncommon::plainname($uname,$udom).'</i>', |
'<i>'.&Apache::loncommon::plainname($uname,$udom).'</i>', |
$dates).'<br />'); |
$dates).'<br />'); |
$count ++; |
$count ++; |
Line 5261 sub can_modify_userinfo {
|
Line 5368 sub can_modify_userinfo {
|
} |
} |
|
|
sub check_usertype { |
sub check_usertype { |
my ($dom,$uname,$rules) = @_; |
my ($dom,$uname,$rules,$curr_rules,$got_rules) = @_; |
my $usertype; |
my $usertype; |
if (ref($rules) eq 'HASH') { |
if ((ref($got_rules) eq 'HASH') && (ref($curr_rules) eq 'HASH')) { |
my @user_rules = keys(%{$rules}); |
if (!$got_rules->{$dom}) { |
if (@user_rules > 0) { |
my %domconfig = &Apache::lonnet::get_dom('configuration', |
my %rule_check = &Apache::lonnet::inst_rulecheck($dom,$uname,undef,'username',\@user_rules); |
['usercreation'],$dom); |
if (keys(%rule_check) > 0) { |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
$usertype = 'unofficial'; |
foreach my $item ('username','id') { |
foreach my $item (keys(%rule_check)) { |
if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') { |
if ($rule_check{$item}) { |
$curr_rules->{$dom}{$item} = |
$usertype = 'official'; |
$domconfig{'usercreation'}{$item.'_rule'}; |
last; |
} |
|
} |
|
} |
|
$got_rules->{$dom} = 1; |
|
} |
|
if (ref($rules) eq 'HASH') { |
|
my @user_rules; |
|
if (ref($curr_rules->{$dom}{'username'}) eq 'ARRAY') { |
|
foreach my $rule (keys(%{$rules})) { |
|
if (grep(/^\Q$rule\E/,@{$curr_rules->{$dom}{'username'}})) { |
|
push(@user_rules,$rule); |
|
} |
|
} |
|
} |
|
if (@user_rules > 0) { |
|
my %rule_check = &Apache::lonnet::inst_rulecheck($dom,$uname,undef,'username',\@user_rules); |
|
if (keys(%rule_check) > 0) { |
|
$usertype = 'unofficial'; |
|
foreach my $item (keys(%rule_check)) { |
|
if ($rule_check{$item}) { |
|
$usertype = 'official'; |
|
last; |
|
} |
} |
} |
} |
} |
} |
} |
Line 5620 sub sectioncheck_alerts {
|
Line 5749 sub sectioncheck_alerts {
|
my %alerts = &Apache::lonlocal::texthash( |
my %alerts = &Apache::lonlocal::texthash( |
curd => 'You must select a course or community in the current domain', |
curd => 'You must select a course or community in the current domain', |
inea => 'In each course, each user may only have one student role at a time', |
inea => 'In each course, each user may only have one student role at a time', |
inco => 'In each community, each user may only have one member role at a time', |
inco => 'In each community, each user may only have one member role at a time', |
youh => 'You had selected', |
youh => 'You had selected', |
sect => 'sections', |
sect => 'sections', |
plsm => 'Please modify your selections so they include no more than one section', |
plsm => 'Please modify your selections so they include no more than one section', |
Line 5648 sub authcheck_alerts {
|
Line 5777 sub authcheck_alerts {
|
return %alerts; |
return %alerts; |
} |
} |
|
|
|
sub is_courseowner { |
|
my ($thiscourse,$courseowner) = @_; |
|
if ($courseowner eq '') { |
|
if ($env{'request.course.id'} eq $thiscourse) { |
|
$courseowner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'}; |
|
} |
|
} |
|
if ($courseowner ne '') { |
|
if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) { |
|
return 1; |
|
} |
|
} |
|
return; |
|
} |
|
|
1; |
1; |
|
|