$lt{'ac'}
+
$lt{'ac'}
$actionselect
@@ -2132,9 +2355,9 @@ END
if ($env{'form.showrole'} eq 'Any') {
my $custom = 1;
if ($context eq 'domain') {
- @allroles = &roles_by_context($setting,$custom);
+ @allroles = &roles_by_context($setting,$custom,$crstype);
} else {
- @allroles = &roles_by_context($context,$custom);
+ @allroles = &roles_by_context($context,$custom,$crstype);
}
} else {
@allroles = ($env{'form.showrole'});
@@ -2168,12 +2391,18 @@ END
}
}
}
- $output .= '';
}
$output .= "\n".''."\n".
&Apache::loncommon::start_data_table().
@@ -2200,37 +2429,38 @@ END
$lt{'type'}
";
} else {
- if ($mode eq 'pickauthor') {
- $output .= "\n".' '."\n";
- } else {
- $output .= "\n".''.&mt('Count').' '."\n";
- }
+ $output .= "\n".' '."\n";
if ($actionselect) {
$output .= ''.&mt('Select').' '."\n";
}
}
foreach my $item (@cols) {
- $output .= "$lt{$item} \n";
+ if (grep(/^\Q$item\E$/,@sortable)) {
+ $output .= "$lt{$item} \n";
+ } else {
+ $output .= "$lt{$item} \n";
+ }
}
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 .= ' '."\n".' '
- .&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id'
+ if ($clickersupport) {
+ my %clicker_options = (
+ 'on' => 'Show',
+ 'off' => 'Hide',
+ );
+ my $clickerchg = 'on';
+ if ($displayclickers eq 'on') {
+ $clickerchg = 'off';
+ }
+ $output .= ' '."\n".' '
+ .&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id'
,''
,' ')
."\n".' '."\n";
-
+ }
# Photo display on or off?
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
my %photo_options = &Apache::lonlocal::texthash(
@@ -2259,20 +2489,28 @@ END
time.'_'.rand(1000000000).'.csv';
unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) {
$r->log_error("Couldn't open $CSVfilename for output $!");
- $r->print(&mt('Problems occurred in writing the CSV file. '
- .'This error has been logged. '
- .'Please alert your LON-CAPA administrator.'));
+ $r->print(
+ ''
+ .&mt('Problems occurred in writing the CSV file.')
+ .' '.&mt('This error has been logged.')
+ .' '.&mt('Please alert your LON-CAPA administrator.')
+ .'
'
+ );
$CSVfile = undef;
}
#
- push @cols,'clicker';
+ if ($clickersupport) {
+ push @cols,'clicker';
+ }
# Write headers and data to file
print $CSVfile '"'.$results_description.'"'."\n";
print $CSVfile '"'.join('","',map {
&Apache::loncommon::csv_translate($lt{$_})
} (@cols))."\"\n";
} elsif ($mode eq 'excel') {
- push @cols,'clicker';
+ if ($clickersupport) {
+ push @cols,'clicker';
+ }
# Create the excel spreadsheet
($excel_workbook,$excel_filename,$format) =
&Apache::loncommon::create_workbook($r);
@@ -2303,6 +2541,45 @@ END
$grpfilter = 'all';
}
}
+ my %ltstatus = &Apache::lonlocal::texthash(
+ Active => 'Active',
+ Future => 'Future',
+ Expired => 'Expired',
+ );
+ # If this is for a single course get last course "log-in" and submissions.
+ my (%crslogins,%stusubmissions,%elapsed,$numparts,%nummultipart,$multipart);
+ my $now = time;
+ if ($context eq 'course') {
+ if ($custommenu) {
+ %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum);
+ %stusubmissions=&Apache::lonnet::dump('nohist_submissiontracker',$cdom,$cnum);
+ %elapsed = &Apache::lonlocal::texthash(
+ -1 => 'more than a month ago',
+ 2592000 => 'within last 30 days',
+ 604800 => 'within last 7 days',
+ 86400 => 'within last 24 hours',
+ );
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (defined($navmap)) {
+ my @allres=$navmap->retrieveResources('/uploaded/'.$cdom.'/'.$cnum.'/default_1261144274.sequence',sub { $_[0]->is_problem() },0);
+ foreach my $resource (@allres) {
+ my @parts = $resource->parts();
+ my $count = scalar(@parts);
+ if ($count > 1) {
+ $nummultipart{$count} ++;
+ }
+ $numparts += $count;
+ }
+ if (keys(%nummultipart) > 0) {
+ $multipart = ' '.'contains';
+ foreach my $key (sort {$a <=> $b} keys(%nummultipart)) {
+ $multipart .= " nummultipart{$key} multipart questions (with $key parts)";
+ }
+ }
+ }
+ }
+ }
+
# Get groups, role, permanent e-mail so we can sort on them if
# necessary.
foreach my $user (keys(%{$userlist})) {
@@ -2330,7 +2607,8 @@ END
}
} elsif ($env{'form.roletype'} eq 'author') {
($uname,$udom,$role) = split(/:/,$user,-1);
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
($uname,$udom,$role) = split(/:/,$user);
}
} else {
@@ -2437,7 +2715,7 @@ END
if ($clickers!~/\w/) { $clickers='-'; }
$in{'clicker'} = $clickers;
my $role = $in{'role'};
- $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}]);
+ $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype);
if (! defined($in{'start'}) || $in{'start'} == 0) {
$in{'start'} = &mt('none');
} else {
@@ -2448,6 +2726,34 @@ END
} else {
$in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'});
}
+ if ($context eq 'course') {
+ if ($custommenu) {
+ my $lastlogin = $crslogins{$in{'username'}.':'.$in{'domain'}.':'.$in{'section'}.':'.$role};
+ if ($lastlogin ne '') {
+ my $sincelogin = $now - $lastlogin;
+ if ($sincelogin < 86400) {
+ $in{'lastlogin'} = $elapsed{'86400'};
+ } elsif ($sincelogin < 604800) {
+ $in{'lastlogin'} = $elapsed{'604800'};
+ } elsif ($sincelogin < 2592000 ) {
+ $in{'lastlogin'} = $elapsed{'2592000'};
+ } else {
+ $in{'lastlogin'} = $elapsed{'-1'};
+ }
+ }
+ }
+ if ($role eq 'st') {
+ my $numsub = $stusubmissions{$in{'username'}.':'.$in{'domain'}."\0attempts"} +
+ $stusubmissions{$in{'username'}.':'.$in{'domain'}."\0pilotsubs"};
+ if (!$numsub) {
+ $in{'submissions'} = 'not attempted';
+ } elsif ($numsub < $numparts) {
+ $in{'submissions'} = 'incomplete ('.$numsub.'/'.$numparts.')';
+ } else {
+ $in{'submissions'} = 'completed';
+ }
+ }
+ }
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
$r->print(&Apache::loncommon::start_data_table_row());
my $checkval;
@@ -2457,7 +2763,7 @@ END
$cellentry = ''.&mt('auto').' Change ';
$autocount ++;
} else {
- $cellentry = '';
}
$r->print("$cellentry \n");
} else {
@@ -2502,7 +2808,7 @@ END
}
}
$r->print(' ');
+ 'actionlist" value="'.$checkval.'" />');
} else {
$r->print(' ');
}
@@ -2515,23 +2821,37 @@ END
$r->print(''.&print_username_link($mode,\%in).' ');
} elsif (($item eq 'start' || $item eq 'end') && ($actionselect)) {
$r->print(''.$in{$item}.' '."\n");
+ } elsif ($item eq 'status') {
+ my $showitem = $in{$item};
+ if (defined($ltstatus{$in{$item}})) {
+ $showitem = $ltstatus{$in{$item}};
+ }
+ $r->print(''.$showitem.' '."\n");
+ } elsif ($item eq 'submissions') {
+ if ($in{$item} =~ /^incomplete/) {
+ $r->print(''.$in{$item}.$multipart.' ');
+ } else {
+ $r->print(''.$in{$item}.' '."\n");
+ }
} else {
$r->print(''.$in{$item}.' '."\n");
}
}
if (($context eq 'course') && ($mode ne 'autoenroll')) {
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
- if ($displayclickers eq 'on') {
- my $clickers =
+ if ($clickersupport) {
+ if ($displayclickers eq 'on') {
+ my $clickers =
(&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
- if ($clickers!~/\w/) { $clickers='-'; }
- $r->print(''.$clickers.' ');
- } else {
- $r->print(' ');
+ if ($clickers!~/\w/) { $clickers='-'; }
+ $r->print(''.$clickers.' ');
+ } else {
+ $r->print(' ');
+ }
}
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') {
- $r->print(' ');
+ $r->print(' ');
} else {
$r->print(' ');
}
@@ -2729,6 +3049,7 @@ sub role_type_names {
'domain' => 'Domain Roles',
'author' => 'Co-Author Roles',
'course' => 'Course Roles',
+ 'community' => 'Community Roles',
);
return %lt;
}
@@ -2818,8 +3139,8 @@ sub select_actions {
}
}
if ($choices{'sections'}) {
- $output .= ' '."\n".
- ' '."\n";
+ $output .= ' '."\n".
+ ' '."\n";
}
}
return $output;
@@ -2833,9 +3154,9 @@ sub date_section_javascript {
delete => "Check the boxes for any users for whom roles are to be deleted, and click 'Proceed'",
none => "Choose an action to take for selected users",
);
- my $output = '
-
ENDTWO
return $output;
}
sub date_section_selector {
- my ($context,$permission) = @_;
+ my ($context,$permission,$crstype) = @_;
my $callingform = $env{'form.callingform'};
my $formname = 'dateselect';
my $groupslist = &get_groupslist();
my $sec_js = &setsections_javascript($formname,$groupslist);
my $output = <<"END";
ENDJS
my %lt = &Apache::lonlocal::texthash (
@@ -2947,7 +3271,7 @@ ENDJS
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 role in a course that is not a student role, a user may have roles in more than one section of a course at a time.',
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);
if ($env{'form.bulkaction'} eq 'chgsec') {
@@ -2961,13 +3285,19 @@ ENDJS
}
$date_items = &date_setting_table($starttime,undef,$context,
$env{'form.bulkaction'},$formname,
- $permission);
+ $permission,$crstype);
}
$output .= ''.$headertext.' '.
'';
return $output;
}
sub section_picker {
- my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode) = @_;
+ my ($cdom,$cnum,$role,$rowtitle,$permission,$context,$mode,$crstype) = @_;
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum);
my $sections_select .= &course_sections(\%sections_count,$role);
my $secbox = ''.&Apache::lonhtmlcommon::start_pick_box()."\n";
if ($mode eq 'upload') {
my ($options,$cb_script,$coursepick) =
- &default_role_selector($context,1);
+ &default_role_selector($context,1,$crstype);
$secbox .= &Apache::lonhtmlcommon::row_title(&mt('role'),'LC_oddrow_value').
$options. &Apache::lonhtmlcommon::row_closure(1)."\n";
}
@@ -3033,26 +3363,50 @@ sub section_picker {
}
sub results_header_row {
- my ($rolefilter,$statusmode,$context,$permission,$mode) = @_;
+ my ($rolefilter,$statusmode,$context,$permission,$mode,$crstype) = @_;
my ($description,$showfilter);
if ($rolefilter ne 'Any') {
$showfilter = $rolefilter;
}
if ($context eq 'course') {
if ($mode eq 'csv' || $mode eq 'excel') {
- $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ if ($crstype eq 'Community') {
+ $description = &mt('Community - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ } else {
+ $description = &mt('Course - [_1]:',$env{'course.'.$env{'request.course.id'}.'.description'}).' ';
+ }
}
if ($statusmode eq 'Expired') {
- $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with expired [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with expired [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Future') {
- $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with future [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with future [_1] roles',$showfilter);
+ }
} elsif ($statusmode eq 'Active') {
- $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('Users in community with active [_1] roles',$showfilter);
+ } else {
+ $description .= &mt('Users in course with active [_1] roles',$showfilter);
+ }
} else {
if ($rolefilter eq 'Any') {
- $description .= &mt('All users in course');
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community');
+ } else {
+ $description .= &mt('All users in course');
+ }
} else {
- $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ if ($crstype eq 'Community') {
+ $description .= &mt('All users in community with [_1] roles',$rolefilter);
+ } else {
+ $description .= &mt('All users in course with [_1] roles',$rolefilter);
+ }
}
}
my $constraint;
@@ -3060,7 +3414,7 @@ sub results_header_row {
if ($viewablesec ne '') {
if ($env{'form.showrole'} eq 'st') {
$constraint = &mt('only users in section "[_1]"',$viewablesec);
- } elsif ($env{'form.showrole'} ne 'cc') {
+ } elsif (($env{'form.showrole'} ne 'cc') && ($env{'form.showrole'} ne 'co')) {
$constraint = &mt('only users affiliated with no section or section "[_1]"',$viewablesec);
}
if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) {
@@ -3148,19 +3502,28 @@ sub results_header_row {
$description .= &mt('All co-authors in domain with [_1] roles',$rolefilter);
}
}
- } elsif ($env{'form.roletype'} eq 'course') {
+ } elsif (($env{'form.roletype'} eq 'course') ||
+ ($env{'form.roletype'} eq 'community')) {
my $coursefilter = $env{'form.coursepick'};
- if ($coursefilter eq 'category') {
- my $instcode = &instcode_from_coursefilter();
- if ($instcode eq '.') {
+ if ($env{'form.roletype'} eq 'course') {
+ if ($coursefilter eq 'category') {
+ my $instcode = &instcode_from_coursefilter();
+ if ($instcode eq '.') {
+ $description .= &mt('All courses in domain').' - ';
+ } else {
+ $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
+ }
+ } elsif ($coursefilter eq 'selected') {
+ $description .= &mt('Selected courses in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
$description .= &mt('All courses in domain').' - ';
- } else {
- $description .= &mt('Courses in domain with institutional code: [_1]',$instcode).' - ';
}
- } elsif ($coursefilter eq 'selected') {
- $description .= &mt('Selected courses in domain').' - ';
- } elsif ($coursefilter eq 'all') {
- $description .= &mt('All courses in domain').' - ';
+ } elsif ($env{'form.roletype'} eq 'community') {
+ if ($coursefilter eq 'selected') {
+ $description .= &mt('Selected communities in domain').' - ';
+ } elsif ($coursefilter eq 'all') {
+ $description .= &mt('All communities in domain').' - ';
+ }
}
if ($statusmode eq 'Expired') {
$description .= &mt('users with expired [_1] roles',$showfilter);
@@ -3197,9 +3560,13 @@ sub viewable_section {
#################################################
#################################################
sub show_drop_list {
- my ($r,$classlist,$nosort,$permission) = @_;
+ my ($r,$classlist,$nosort,$permission,$crstype) = @_;
my $cid = $env{'request.course.id'};
my ($cnum,$cdom) = &get_course_identity($cid);
+ my $displaygroups;
+ unless (&Apache::loncommon::needs_gci_custom()) {
+ $displaygroups = 1;
+ }
if (! exists($env{'form.sortby'})) {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['sortby']);
@@ -3215,10 +3582,12 @@ sub show_drop_list {
-
+
END
my ($indexhash,$keylist) = &make_keylist_array();
my $studentcount = 0;
@@ -3241,7 +3610,11 @@ END
}
}
if (!$studentcount) {
- $r->print(&mt('There are no students to drop.'));
+ if ($crstype eq 'Community') {
+ $r->print(&mt('There are no members to drop.'));
+ } else {
+ $r->print(&mt('There are no students to drop.'));
+ }
return;
}
my ($classgroups) = &Apache::loncoursedata::get_group_memberships(
@@ -3249,11 +3622,16 @@ END
my %lt=&Apache::lonlocal::texthash('usrn' => "username",
'dom' => "domain",
'sn' => "student name",
+ 'mn' => "member name",
'sec' => "section",
'start' => "start date",
'end' => "end date",
'groups' => "active groups",
);
+ my $nametitle = $lt{'sn'};
+ if ($crstype eq 'Community') {
+ $nametitle = $lt{'mn'};
+ }
if ($nosort) {
$r->print(&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row());
@@ -3262,12 +3640,14 @@ END
$lt{'usrn'}
$lt{'dom'}
ID
- $lt{'sn'}
+ $nametitle
$lt{'sec'}
$lt{'start'}
$lt{'end'}
- $lt{'groups'}
END
+ if ($displaygroups) {
+ $r->print(" $lt{'groups'} \n");
+ }
$r->print(&Apache::loncommon::end_data_table_header_row());
} else {
$r->print(&Apache::loncommon::start_data_table().
@@ -3281,17 +3661,20 @@ END
ID
- $lt{'sn'}
+ $nametitle
$lt{'sec'}
$lt{'start'}
$lt{'end'}
-
- $lt{'groups'}
END
+ if ($displaygroups) {
+ $r->print("
+ $lt{'groups'}
+ \n");
+ }
$r->print(&Apache::loncommon::end_data_table_header_row());
}
#
@@ -3336,7 +3719,7 @@ END
#
$r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
-
+
$username
$domain
$id
@@ -3344,21 +3727,32 @@ END
$section
$start $startitem
$end
- $active_groups
END
+ if ($displaygroups) {
+ $r->print(" $active_groups \n");
+ }
$r->print(&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table().' ');
%lt=&Apache::lonlocal::texthash(
'dp' => "Drop Students",
+ 'dm' => "Drop Members",
'ca' => "check all",
'ua' => "uncheck all",
);
+ my $btn = $lt{'dp'};
+ if ($crstype eq 'Community') {
+ $btn = $lt{'dm'};
+ }
$r->print(<<"END");
-
-
-
-
+
+
+
+
+
+
+
+
END
return;
}
@@ -3369,24 +3763,36 @@ END
sub print_first_users_upload_form {
my ($r,$context) = @_;
my $str;
- $str = ' ';
+ $str = ' ';
$str .= ' ';
- $str .= ' ';
- $str .= "".&mt('Upload a file containing information about users')." \n";
- $str .= &Apache::loncommon::upfile_select_html();
- $str .= '';
- $str .= &Apache::loncommon::help_open_topic("Course_Create_Class_List",
- &mt("How do I create a users list from a spreadsheet")).
- " \n";
- $str .= &Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
- &mt("How do I create a CSV file from a spreadsheet"));
- $str .= "
\n";
- $str .= "\n";
- $str .= ' '.
- &mt('Ignore First Line')."
\n";
- $str .= ' '." \n";
- $str .= &Apache::loncommon::end_page();
+ $str .= ' ';
+
+ $str .= ''.&mt('Upload a file containing information about users').' '."\n";
+
+ # Excel and CSV Help
+ $str .= ''
+ .&Apache::loncommon::help_open_topic("Course_Create_Class_List",
+ &mt("How do I create a users list from a spreadsheet"))
+ .'
'."\n"
+ .&Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
+ &mt("How do I create a CSV file from a spreadsheet"))
+ .'
'."\n";
+ $str .= &Apache::lonhtmlcommon::start_pick_box()
+ .&Apache::lonhtmlcommon::row_title(&mt('File'))
+ .&Apache::loncommon::upfile_select_html()
+ .&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title(
+ ''
+ .&mt('Ignore First Line')
+ .' ')
+ .' '
+ .&Apache::lonhtmlcommon::row_closure(1)
+ .&Apache::lonhtmlcommon::end_pick_box();
+
+ $str .= ''
+ .' '
+ .'
';
+
$r->print($str);
return;
}
@@ -3430,11 +3836,25 @@ sub upfile_drop_add {
'ipwd_choice' => 'scalar',
'email_choice' => 'scalar',
'role_choice' => 'scalar',
- 'domain_choice' => 'scalar'});
+ 'domain_choice' => 'scalar',
+ 'inststatus_choice' => 'scalar'});
#
+ my ($cid,$crstype,$setting);
+ if ($context eq 'domain') {
+ $setting = $env{'form.roleaction'};
+ }
+ if ($env{'request.course.id'} ne '') {
+ $cid = $env{'request.course.id'};
+ $crstype = &Apache::loncommon::course_type();
+ } elsif ($setting eq 'course') {
+ if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) {
+ $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'};
+ $crstype = &Apache::loncommon::course_type($cid);
+ }
+ }
my ($startdate,$enddate) = &get_dates_from_form();
if ($env{'form.makedatesdefault'}) {
- $r->print(&make_dates_default($startdate,$enddate,$context));
+ $r->print(&make_dates_default($startdate,$enddate,$context,$crstype));
}
# Determine domain and desired host (home server)
my $defdom=$env{'request.role.domain'};
@@ -3486,9 +3906,8 @@ sub upfile_drop_add {
$amode = ''; # This causes the loop below to be skipped
}
}
- my ($cid,$defaultsec,$defaultrole,$setting);
+ my ($defaultsec,$defaultrole);
if ($context eq 'domain') {
- $setting = $env{'form.roleaction'};
if ($setting eq 'domain') {
$defaultrole = $env{'form.defaultrole'};
} elsif ($setting eq 'course') {
@@ -3501,28 +3920,22 @@ sub upfile_drop_add {
$defaultrole = $env{'form.defaultrole'};
$defaultsec = $env{'form.sections'};
}
- if ($env{'request.course.id'} ne '') {
- $cid = $env{'request.course.id'};
- } elsif ($setting eq 'course') {
- if (&Apache::lonnet::is_course($env{'form.dcdomain'},$env{'form.dccourse'})) {
- $cid = $env{'form.dcdomain'}.'_'.$env{'form.dccourse'};
- }
- }
# Check to see if user information can be changed
my @userinfo = ('firstname','middlename','lastname','generation',
'permanentemail','id');
my %canmodify;
if (&Apache::lonnet::allowed('mau',$domain)) {
+ push(@userinfo,'inststatus');
foreach my $field (@userinfo) {
$canmodify{$field} = 1;
}
}
my (%userlist,%modifiable_fields,@poss_roles);
my $secidx = &Apache::loncoursedata::CL_SECTION();
- my @courseroles = &roles_by_context('course',1);
+ my @courseroles = &roles_by_context('course',1,$crstype);
if (!&Apache::lonnet::allowed('mau',$domain)) {
if ($context eq 'course' || $context eq 'author') {
- @poss_roles = &curr_role_permissions($context);
+ @poss_roles = &curr_role_permissions($context,'','',$crstype);
my @statuses = ('active','future');
my ($indexhash,$keylist) = &make_keylist_array();
my %info;
@@ -3561,6 +3974,8 @@ sub upfile_drop_add {
} else {
$r->print(''.&mt('Adding/Modifying Users')." \n\n");
}
+ $r->rflush;
+
my %counts = (
user => 0,
auth => 0,
@@ -3606,8 +4021,9 @@ sub upfile_drop_add {
}
}
my (%curr_rules,%got_rules,%alerts);
- my %customroles = &my_custom_roles();
- my @permitted_roles = &roles_on_upload($context,$setting,%customroles);
+ my %customroles = &my_custom_roles($crstype);
+ my @permitted_roles =
+ &roles_on_upload($context,$setting,$crstype,%customroles);
# Get new users list
foreach my $line (@userdata) {
my @secs;
@@ -3636,8 +4052,8 @@ sub upfile_drop_add {
if ($entries{$fields{'username'}}
ne &LONCAPA::clean_username($entries{$fields{'username'}})) {
$r->print(' '.
- &mt('[_1] : Unacceptable username for user [_2] [_3] [_4] [_5]',
- $entries{$fields{'username'}},$fname,$mname,$lname,$gen));
+ &mt('[_1]: Unacceptable username for user [_2] [_3] [_4] [_5]',
+ ''.$entries{$fields{'username'}}.' ',$fname,$mname,$lname,$gen));
next;
} else {
if ($entries{$fields{'domain'}}
@@ -3656,10 +4072,10 @@ sub upfile_drop_add {
$entries{$fields{'sec'}} =~ s/\W//g;
my $item = $entries{$fields{'sec'}};
if ($item eq "none" || $item eq 'all') {
- $r->print(' '.&mt('[_1] : Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a reserved word.',$username,$fname,$mname,$lname,$gen,$item));
+ $r->print(' '.&mt('[_1]: Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a reserved word.',''.$username.' ',$fname,$mname,$lname,$gen,$item));
next;
} elsif (exists($curr_groups{$item})) {
- $r->print(' '.&mt('[_1] : Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a course group.',$username,$fname,$mname,$lname,$gen,$item).' '.&mt('Section names and group names must be distinct.'));
+ $r->print(' '.&mt('[_1]: Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]" - this is a course group.',''.$username.' ',$fname,$mname,$lname,$gen,$item).' '.&mt('Section names and group names must be distinct.'));
next;
} else {
push(@secs,$item);
@@ -3671,7 +4087,7 @@ sub upfile_drop_add {
if (ref($userlist{$username.':'.$userdomain}) eq 'ARRAY') {
my $currsec = $userlist{$username.':'.$userdomain}[$secidx];
if ($currsec ne $env{'request.course.sec'}) {
- $r->print(' '.&mt('[_1] : Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]".',$username,$fname,$mname,$lname,$gen,$secs[0]).' ');
+ $r->print(' '.&mt('[_1]: Unable to enroll user [_2] [_3] [_4] [_5] in a section named "[_6]".',''.$username.' ',$fname,$mname,$lname,$gen,$secs[0]).' ');
if ($currsec eq '') {
$r->print(&mt('This user already has an active/future student role in the course, unaffiliated to any section.'));
@@ -3700,7 +4116,15 @@ sub upfile_drop_add {
if (defined($fields{'email'})) {
if (defined($entries{$fields{'email'}})) {
$email=$entries{$fields{'email'}};
- unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; } }
+ unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; }
+ }
+ }
+ # determine affiliation
+ my $inststatus='';
+ if (defined($fields{'inststatus'})) {
+ if (defined($entries{$fields{'inststatus'}})) {
+ $inststatus=$entries{$fields{'inststatus'}};
+ }
}
# determine user password
my $password = $genpwd;
@@ -3721,8 +4145,13 @@ sub upfile_drop_add {
}
if ($role eq '') {
my $rolestr = join(', ',@permitted_roles);
- $r->print(' '.
- &mt('[_1] : You do not have permission to add the requested role [_2] for the user.',$entries{$fields{'username'}},$entries{$fields{'role'}}).' '.&mt('Allowable role(s) is/are: [_1].',$rolestr)."\n");
+ $r->print(' '
+ .&mt('[_1]: You do not have permission to add the requested role [_2] for the user.'
+ ,''.$entries{$fields{'username'}}.' '
+ ,$entries{$fields{'role'}})
+ .' '
+ .&mt('Allowable role(s) is/are: [_1].',$rolestr)."\n"
+ );
next;
}
}
@@ -3778,7 +4207,7 @@ sub upfile_drop_add {
}
}
my @newinfo = (\$fname,\$mname,\$lname,\$gen,\$email,\$id);
- for (my $i=0; $i<@userinfo; $i++) {
+ for (my $i=0; $i<@newinfo; $i++) {
if (${$newinfo[$i]} ne '') {
if (!$canmodify{$userinfo[$i]}) {
${$newinfo[$i]} = '';
@@ -3827,7 +4256,7 @@ sub upfile_drop_add {
$fname,$mname,$lname,$gen,$sec,$enddate,
$startdate,$env{'form.forceid'},
$desiredhost,$email,'manual','',$cid,
- '',$context);
+ '',$context,$inststatus);
$userresult = $roleresult;
} else {
if ($role ne '') {
@@ -3836,7 +4265,7 @@ sub upfile_drop_add {
$role = 'cr_'.$env{'user.domain'}.'_'.
$env{'user.name'}.'_'.$role;
}
- if ($role ne 'cc') {
+ if (($role ne 'cc') && ($role ne 'co')) {
if (@secs > 1) {
$multiple = 1;
foreach my $sec (@secs) {
@@ -3847,7 +4276,7 @@ sub upfile_drop_add {
$mname,$lname,$gen,$sec,
$env{'form.forceid'},$desiredhost,
$email,$role,$enddate,
- $startdate,$checkid);
+ $startdate,$checkid,$inststatus);
}
} elsif (@secs > 0) {
$singlesec = $secs[0];
@@ -3862,7 +4291,8 @@ sub upfile_drop_add {
$id,$amode,$password,$fname,
$mname,$lname,$gen,$singlesec,
$env{'form.forceid'},$desiredhost,
- $email,$role,$enddate,$startdate,$checkid);
+ $email,$role,$enddate,$startdate,
+ $checkid,$inststatus);
}
}
if ($multiple) {
@@ -3882,15 +4312,15 @@ sub upfile_drop_add {
} else {
if ($context eq 'course') {
$r->print(' '.
- &mt('[_1] : Unable to enroll. No password specified.',$username)
+ &mt('[_1]: Unable to enroll. No password specified.',''.$username.' ')
);
} elsif ($context eq 'author') {
$r->print(' '.
- &mt('[_1] : Unable to add co-author. No password specified.',$username)
+ &mt('[_1]: Unable to add co-author. No password specified.',''.$username.' ')
);
} else {
$r->print(' '.
- &mt('[_1] : Unable to add user. No password specified.',$username)
+ &mt('[_1]: Unable to add user. No password specified.',''.$username.' ')
);
}
}
@@ -3993,7 +4423,7 @@ sub user_change_result {
if ($userresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1] : Unable to add/modify: [_2]',$username.':'.$userdomain,$error));
+ &mt('[_1]: Unable to add/modify: [_2]',''.$username.':'.$userdomain.' ',$error));
}
} else {
$counts->{'user'} ++;
@@ -4003,7 +4433,7 @@ sub user_change_result {
if ($authresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1] : Unable to modify authentication: [_2]',$username.':'.$userdomain,$error));
+ &mt('[_1]: Unable to modify authentication: [_2]',''.$username.':'.$userdomain.' ',$error));
}
} else {
$counts->{'auth'} ++;
@@ -4013,7 +4443,7 @@ sub user_change_result {
if ($roleresult =~ /^error:(.+)$/) {
my $error = $1;
$r->print(' '.
- &mt('[_1] : Unable to add role: [_2]',$username.':'.$userdomain,$error));
+ &mt('[_1]: Unable to add role: [_2]',''.$username.':'.$userdomain.' ',$error));
}
} else {
$counts->{'role'} ++;
@@ -4036,14 +4466,24 @@ sub user_change_result {
# ========================================================= Menu Phase Two Drop
sub print_drop_menu {
- my ($r,$context,$permission) = @_;
- $r->print('
'.&mt("Drop Students").' '."\n".
+ my ($r,$context,$permission,$crstype) = @_;
+ my $heading;
+ if ($crstype eq 'Community') {
+ $heading = &mt("Drop Members");
+ } else {
+ $heading = &mt("Drop Students");
+ }
+ $r->print(''.$heading.' '."\n".
''. &Apache::loncommon::end_page());
return;
@@ -4055,6 +4495,10 @@ sub update_user_list {
my ($r,$context,$setting,$choice) = @_;
my $now = time;
my $count=0;
+ my $crstype;
+ if ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ }
my @changelist;
if ($choice eq 'drop') {
@changelist = &Apache::loncommon::get_env_multiple('form.droplist');
@@ -4125,7 +4569,7 @@ sub update_user_list {
}
}
}
- my $plrole = &Apache::lonnet::plaintext($role);
+ my $plrole = &Apache::lonnet::plaintext($role,$crstype);
my $start = $env{'form.'.$item.'_start'};
my $end = $env{'form.'.$item.'_end'};
if ($choice eq 'drop') {
@@ -4182,7 +4626,7 @@ sub update_user_list {
}
} elsif ($choice eq 'chgsec') {
my (@newsecs,$revresult,$nochg,@retained);
- if ($role ne 'cc') {
+ if (($role ne 'cc') && ($role ne 'co')) {
@newsecs = split(/,/,$env{'form.newsecs'});
}
# remove existing section if not to be retained.
@@ -4283,14 +4727,14 @@ sub update_user_list {
$r->print(''.&mt("$result_text{'ok'}{$choice} role(s) for [quant,_1,user,users,no users].",$count).'
');
if ($count > 0) {
if ($choice eq 'revoke' || $choice eq 'drop') {
- $r->print(''.&mt('Re-enabling will re-activate data for the role.
'));
+ $r->print(''.&mt('Re-enabling will re-activate data for the role.').'
');
}
# Flush the course logs so reverse user roles immediately updated
&Apache::lonnet::flushcourselogs();
}
if ($env{'form.makedatesdefault'}) {
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') {
- $r->print(&make_dates_default($startdate,$enddate,$context));
+ $r->print(&make_dates_default($startdate,$enddate,$context,$crstype));
}
}
my $linktext = &mt('Display User Lists');
@@ -4377,7 +4821,7 @@ sub course_sections {
my $output = '';
my @sections = (sort {$a <=> $b} keys %{$sections_count});
my $numsec = scalar(@sections);
- my $is_selected = ' selected="selected" ';
+ my $is_selected = ' selected="selected"';
if ($numsec <= 1) {
$output = ''."\n".
' '.&mt('Select').' '."\n";
@@ -4437,7 +4881,7 @@ sub get_groupslist {
}
sub setsections_javascript {
- my ($formname,$groupslist,$mode,$checkauth) = @_;
+ my ($formname,$groupslist,$mode,$checkauth,$crstype) = @_;
my ($checkincluded,$finish,$rolecode,$setsection_js);
if ($mode eq 'upload') {
$checkincluded = 'formname.name == "'.$formname.'"';
@@ -4476,8 +4920,11 @@ sub setsections_javascript {
}
my %alerts = &Apache::lonlocal::texthash(
secd => 'Section designations do not apply to Course Coordinator roles.',
+ sedn => 'Section designations do not apply to Coordinator roles.',
accr => 'A course coordinator role will be added with access to all sections.',
+ acor => 'A coordinator role will be added with access to all sections',
inea => 'In each course, each user may only have one student role at a time.',
+ inec => 'In each community, each user may only have on member role at a time.',
youh => 'You had selected ',
secs => 'sections.',
plmo => 'Please modify your selections so they include no more than one section.',
@@ -4488,7 +4935,7 @@ sub setsections_javascript {
);
$setsection_js .= <<"ENDSECCODE";
-function setSections(formname) {
+function setSections(formname,crstype) {
var re1 = /^currsec_/;
var groups = new Array($groupslist);
for (var i=0;i 1)) {
- alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}")
+ if (crstype == 'Community') {
+ alert("$alerts{'inea'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
+ } else {
+ alert("$alerts{'inco'} $alerts{'youh'} "+numsec+" $alerts{'secs'}\\n$alerts{'plmo'}");
+ }
return;
}
else {
@@ -4576,7 +5030,7 @@ sub can_create_user {
}
if (ref($domconf{'usercreation'}) eq 'HASH') {
if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') {
- if ($context eq 'course' || $context eq 'author') {
+ if ($context eq 'course' || $context eq 'author' || $context eq 'requestcrs') {
my $creation = $domconf{'usercreation'}{'cancreate'}{$context};
if ($creation eq 'none') {
$cancreate = 0;
@@ -4674,27 +5128,44 @@ sub check_usertype {
}
sub roles_by_context {
- my ($context,$custom) = @_;
+ my ($context,$custom,$crstype) = @_;
my @allroles;
if ($context eq 'course') {
- @allroles = ('st','ad','ta','ep','in','cc');
- if ($custom) {
- push(@allroles,'cr');
+ @allroles = ('st');
+ if ($env{'request.role'} =~ m{^dc\./}) {
+ push(@allroles,'ad');
+ }
+ if (&Apache::loncommon::needs_gci_custom()) {
+ if ($crstype eq 'Community') {
+ push(@allroles,'co');
+ } else {
+ push(@allroles,'cc');
+ }
+ } else {
+ push(@allroles,('ta','ep','in'));
+ if ($crstype eq 'Community') {
+ push(@allroles,'co');
+ } else {
+ push(@allroles,'cc');
+ }
+ if ($custom) {
+ push(@allroles,'cr');
+ }
}
} elsif ($context eq 'author') {
@allroles = ('ca','aa');
} elsif ($context eq 'domain') {
- @allroles = ('li','dg','sc','au','dc');
+ @allroles = ('li','ad','dg','sc','au','dc');
}
return @allroles;
}
sub get_permission {
- my ($context,$roles) = @_;
+ my ($context,$crstype) = @_;
my %permission;
if ($context eq 'course') {
my $custom = 1;
- my @allroles = &roles_by_context($context,$custom);
+ my @allroles = &roles_by_context($context,$custom,$crstype);
foreach my $role (@allroles) {
if (&Apache::lonnet::allowed('c'.$role,$env{'request.course.id'})) {
$permission{'cusr'} = 1;
@@ -4763,9 +5234,9 @@ sub authorpriv {
}
sub roles_on_upload {
- my ($context,$setting,%customroles) = @_;
+ my ($context,$setting,$crstype,%customroles) = @_;
my (@possible_roles,@permitted_roles);
- @possible_roles = &curr_role_permissions($context,$setting,1);
+ @possible_roles = &curr_role_permissions($context,$setting,1,$crstype);
foreach my $role (@possible_roles) {
if ($role eq 'cr') {
push(@permitted_roles,keys(%customroles));
@@ -4801,6 +5272,7 @@ sub dc_setcourse_js {
my ($formname,$mode,$context) = @_;
my ($dc_setcourse_code,$authen_check);
my $cctext = &Apache::lonnet::plaintext('cc');
+ my $cotext = &Apache::lonnet::plaintext('co');
my %alerts = §ioncheck_alerts();
my $role = 'role';
if ($mode eq 'upload') {
@@ -4847,7 +5319,11 @@ function setCourse() {
numsections = numsections + newsecs.length;
}
if ((userrole == 'st') && (numsections > 1)) {
- alert("$alerts{'inea'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.")
+ if (document.$formname.crstype.value == 'Community') {
+ alert("$alerts{'inco'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.")
+ } else {
+ alert("$alerts{'inea'}. $alerts{'youh'} "+numsections+" $alerts{'sect'}.\\n$alerts{'plsm'}.")
+ }
return;
}
for (var j=0; j 0)) {
+ alert("$alerts{'secd'} $cotext $alerts{'role'}.\\n$alerts{'accr'}.");
+ section = "";
+ }
SCRIPTTOP
if ($mode ne 'upload') {
$dc_setcourse_code .= (<<"ENDSCRIPT");
var coursename = "_$env{'request.role.domain'}"+"_"+course+"_"+userrole
var numcourse = getIndex(document.$formname.dccourse);
if (numcourse == "-1") {
- alert("$alerts{'thwa'}");
+ if (document.$formname.type == 'Community') {
+ alert("$alerts{'thwc'}");
+ } else {
+ alert("$alerts{'thwa'}");
+ }
return;
}
else {
@@ -4984,19 +5472,22 @@ ENDSCRIPT
sub sectioncheck_alerts {
my %alerts = &Apache::lonlocal::texthash(
- curd => 'You must select a course 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',
+ inco => 'In each community, each user may only have one member role at a time',
youh => 'You had selected',
sect => 'sections',
plsm => 'Please modify your selections so they include no more than one section',
mayn => 'may not be used as the name for a section, as it is a reserved word',
plsc => 'Please choose a different section name',
mayt => 'may not be used as the name for a section, as it is the name of a course group',
+ mayc => 'may not be used as the name for a section, as it is the name of a community group',
secn => 'Section names and group names must be distinct',
secd => 'Section designations do not apply to ',
role => 'roles',
accr => 'role will be added with access to all sections',
- thwa => 'There was a problem with your course selection'
+ thwa => 'There was a problem with your course selection',
+ thwc => 'There was a problem with your community selection',
);
return %alerts;
}