print('');
}
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
+ my $credits;
+ if ($showcredits) {
+ $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits);
+ if ($credits eq '') {
+ $credits = $defaultcredits;
+ }
+ }
+ $r->print(&date_sections_select($context,$newuser,$formname,
+ $permission,$crstype,$ccuname,
+ $ccdomain,$showcredits));
+ }
if ($gotdiv) {
$r->print('
');
}
@@ -1440,7 +1483,7 @@ ENDNOTOOLSPRIV
}
$r->print('
'."\n");
} else {
- $r->print(''.&mt('Add Roles').'
');
+ $r->print('
'."\n");
} elsif ($context eq 'author') {
if ($addrolesdisplay) {
- $r->print('
print('
print(' onclick="auth_check()" \>'."\n");
} else {
$r->print('onclick="this.form.submit()" \>'."\n");
}
} else {
- $r->print('
'.
+ $r->print('
'.
&mt('Back to previous page').'');
}
} else {
- $r->print(&course_level_table(%inccourses));
- $r->print('
'."\n");
+ $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits));
+ $r->print('
'."\n");
}
}
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
@@ -1495,22 +1538,32 @@ sub singleuser_breadcrumb {
}
sub date_sections_select {
- my ($context,$newuser,$formname,$permission) = @_;
+ my ($context,$newuser,$formname,$permission,$crstype,$ccuname,$ccdomain,
+ $showcredits) = @_;
+ my $credits;
+ if ($showcredits) {
+ my $defaultcredits = &Apache::lonuserutils::get_defaultcredits();
+ $credits = &get_user_credits($ccuname,$ccdomain,$defaultcredits);
+ if ($credits eq '') {
+ $credits = $defaultcredits;
+ }
+ }
my $cid = $env{'request.course.id'};
my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
my $date_table = ''.&mt('Starting and Ending Dates').'
'."\n".
&Apache::lonuserutils::date_setting_table(undef,undef,$context,
undef,$formname,$permission);
my $rowtitle = 'Section';
- my $secbox = ''.&mt('Section').'
'."\n".
+ my $secbox = ''.&mt('Section and Credits').'
'."\n".
&Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
- $permission);
+ $permission,$context,'',$crstype,
+ $showcredits,$credits);
my $output = $date_table.$secbox;
return $output;
}
sub validation_javascript {
- my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname,
+ my ($context,$ccdomain,$pjump_def,$crstype,$groupslist,$newuser,$formname,
$loaditem) = @_;
my $dc_setcourse_code = '';
my $nondc_setsection_code = '';
@@ -1527,7 +1580,8 @@ sub validation_javascript {
if ($context eq 'course') {
$nondc_setsection_code =
&Apache::lonuserutils::setsections_javascript($formname,$groupslist,
- undef,$checkauth);
+ undef,$checkauth,
+ $crstype);
}
if ($checkauth) {
$nondc_setsection_code .=
@@ -1547,7 +1601,8 @@ sub validation_javascript {
}
sub display_existing_roles {
- my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype) = @_;
+ my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype,
+ $showcredits) = @_;
my $now=time;
my %lt=&Apache::lonlocal::texthash(
'rer' => "Existing Roles",
@@ -1556,6 +1611,7 @@ sub display_existing_roles {
'ren' => "Re-Enable",
'rol' => "Role",
'ext' => "Extent",
+ 'crd' => "Credits",
'sta' => "Start",
'end' => "End",
);
@@ -1618,6 +1674,7 @@ sub display_existing_roles {
my $delallowed=0;
my $sortkey=$role_code;
my $class='Unknown';
+ my $credits='';
if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
$class='Course';
my ($coursedom,$coursedir) = ($1,$2);
@@ -1646,6 +1703,15 @@ sub display_existing_roles {
}
$sortkey.="\0$coursedir";
$inccourses->{$cid}=1;
+ if (($showcredits) && ($class eq 'Course') && ($role_code eq 'st')) {
+ my $defaultcredits = $coursedata{'internal.defaultcredits'};
+ $credits =
+ &get_user_credits($ccuname,$ccdomain,$defaultcredits,
+ $coursedom,$coursedir);
+ if ($credits eq '') {
+ $credits = $defaultcredits;
+ }
+ }
if ((&Apache::lonnet::allowed('c'.$role_code,$coursedom.'/'.$coursedir)) ||
(&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
$allowed=1;
@@ -1672,7 +1738,7 @@ sub display_existing_roles {
}
}
if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
- $carea.='
Section: '.$3;
+ $carea.='
'.&mt('Section: [_1]',$3);
$sortkey.="\0$3";
if (!$allowed) {
if ($env{'request.course.sec'} eq $3) {
@@ -1702,7 +1768,7 @@ sub display_existing_roles {
}
}
if ($role_code eq 'ca' || $role_code eq 'au' || $role_code eq 'aa') {
- $class='Construction Space';
+ $class='Authoring Space';
} elsif ($role_code eq 'su') {
$class='System';
} else {
@@ -1744,7 +1810,13 @@ sub display_existing_roles {
}
my $plaintext='';
if (!$croletitle) {
- $plaintext=&Apache::lonnet::plaintext($role_code,$class)
+ $plaintext=&Apache::lonnet::plaintext($role_code,$class);
+ if (($showcredits) && ($credits ne '')) {
+ $plaintext .= '
'.
+ ''.
+ &mt('Credits: [_1]',$credits).
+ '';
+ }
} else {
$plaintext=
&mt('Customrole [_1][_2]defined by [_3]',
@@ -1767,7 +1839,7 @@ sub display_existing_roles {
my $rolesdisplay = 0;
my %output = ();
- foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+ foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') {
$output{$type} = '';
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
@@ -1793,25 +1865,25 @@ sub display_existing_roles {
$contextrole = &mt('Existing Roles in this Course');
}
} elsif ($env{'request.role'} =~ /^au\./) {
- $contextrole = &mt('Existing Co-Author Roles in your Construction Space');
+ $contextrole = &mt('Existing Co-Author Roles in your Authoring Space');
} else {
$contextrole = &mt('Existing Roles in this Domain');
}
- $r->print('
-'.$lt{'rer'}.'
'.
-''.$contextrole.'
'.
+ $r->print(''.
+'
');
}
return;
}
@@ -1830,7 +1902,7 @@ sub new_coauthor_roles {
my $cuname=$env{'user.name'};
my $cudom=$env{'request.role.domain'};
my %lt=&Apache::lonlocal::texthash(
- 'cs' => "Construction Space",
+ 'cs' => "Authoring Space",
'act' => "Activate",
'rol' => "Role",
'ext' => "Extent",
@@ -1881,7 +1953,7 @@ sub new_coauthor_roles {
'');
} elsif (($env{'user.name'} eq $ccuname) &&
($env{'user.domain'} eq $ccdomain)) {
- $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted'));
+ $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Authoring Space is not permitted'));
}
}
return $addrolesdisplay;;
@@ -2314,7 +2386,7 @@ sub get_inststatuses {
# ================================================================= Phase Three
sub update_user_data {
- my ($r,$context,$crstype,$brcrum) = @_;
+ my ($r,$context,$crstype,$brcrum,$showcredits) = @_;
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
# Error messages
@@ -2444,7 +2516,7 @@ sub update_user_data {
my (%alerts,%rulematch,%inst_results,%curr_rules);
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
my @usertools = ('aboutme','blog','webdav','portfolio');
- my @requestcourses = ('official','unofficial','community');
+ my @requestcourses = ('official','unofficial','community','textbook');
my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
@@ -2514,14 +2586,18 @@ sub update_user_data {
my (%changeHash,%newcustom,%changed,%changedinfo);
if ($uhome ne 'no_host') {
if ($context eq 'domain') {
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newcustom{'quota'} = 0;
- } else {
- $newcustom{'quota'} = $env{'form.portfolioquota'};
- $newcustom{'quota'} =~ s/[^\d\.]//g;
+ foreach my $name ('portfolio','author') {
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newcustom{$name.'quota'} = 0;
+ } else {
+ $newcustom{$name.'quota'} = $env{'form.'.$name.'quota'};
+ $newcustom{$name.'quota'} =~ s/[^\d\.]//g;
+ }
+ if ("a_admin($newcustom{$name.'quota'},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
}
- $changed{'quota'} = "a_admin($newcustom{'quota'},\%changeHash);
}
foreach my $item (@usertools) {
if ($env{'form.custom'.$item} == 1) {
@@ -2535,7 +2611,8 @@ sub update_user_data {
$newcustom{$item} = $env{'form.crsreq_'.$item};
if ($env{'form.crsreq_'.$item} eq 'autolimit') {
$newcustom{$item} .= '=';
- unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
+ $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g;
+ if ($env{'form.crsreq_'.$item.'_limit'}) {
$newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
}
}
@@ -2593,20 +2670,25 @@ sub update_user_data {
$r->rflush(); # Finish display of header before time consuming actions start
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state);
##
- my (@userroles,%userupdate,$cnum,$cdom,%namechanged);
+ my (@userroles,%userupdate,$cnum,$cdom,$defaultcredits,%namechanged);
if ($context eq 'course') {
- ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
+ ($cnum,$cdom) =
+ &Apache::lonuserutils::get_course_identity();
$crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
+ if ($showcredits) {
+ $defaultcredits = &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+ }
}
if (! $env{'form.makeuser'} ) {
# Check for need to change
my %userenv = &Apache::lonnet::get
('environment',['firstname','middlename','lastname','generation',
- 'id','permanentemail','portfolioquota','inststatus','tools.aboutme',
- 'tools.blog','tools.webdav','tools.portfolio',
+ 'id','permanentemail','portfolioquota','authorquota','inststatus',
+ 'tools.aboutme','tools.blog','tools.webdav','tools.portfolio',
'requestcourses.official','requestcourses.unofficial',
- 'requestcourses.community','reqcrsotherdom.official',
- 'reqcrsotherdom.unofficial','reqcrsotherdom.community',
+ 'requestcourses.community','requestcourses.textbook',
+ 'reqcrsotherdom.official','reqcrsotherdom.unofficial',
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook',
'requestauthor'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
@@ -2729,10 +2811,10 @@ sub update_user_data {
}
}
}
- my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
- $newinststatus,$oldisdefault,$newisdefault,%oldsettings,
+ my (%quotachanged,%oldquota,%newquota,%olddefquota,%newdefquota,
+ $oldinststatus,$newinststatus,%oldisdefault,%newisdefault,%oldsettings,
%oldsettingstext,%newsettings,%newsettingstext,@disporder,
- $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);
+ %oldsettingstatus,%newsettingstatus);
@disporder = ('inststatus');
if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
push(@disporder,'requestcourses','requestauthor');
@@ -2741,9 +2823,11 @@ sub update_user_data {
}
push(@disporder,('quota','tools'));
$oldinststatus = $userenv{'inststatus'};
- ($olddefquota,$oldsettingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus);
- ($newdefquota,$newsettingstatus) = ($olddefquota,$oldsettingstatus);
+ foreach my $name ('portfolio','author') {
+ ($olddefquota{$name},$oldsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
+ ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
+ }
my %canshow;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$canshow{'quota'} = 1;
@@ -2782,8 +2866,10 @@ sub update_user_data {
$changeHash{'inststatus'} = $newinststatus;
if ($newinststatus ne $oldinststatus) {
$changed{'inststatus'} = $newinststatus;
- ($newdefquota,$newsettingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
+ foreach my $name ('portfolio','author') {
+ ($newdefquota{$name},$newsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+ }
}
if (ref($usertypes) eq 'HASH') {
$newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
@@ -2797,61 +2883,78 @@ sub update_user_data {
$newsettings{'inststatus'} = $othertitle;
if ($newinststatus ne $oldinststatus) {
$changed{'inststatus'} = $changeHash{'inststatus'};
- ($newdefquota,$newsettingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
+ foreach my $name ('portfolio','author') {
+ ($newdefquota{$name},$newsettingstatus{$name}) =
+ &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus,$name);
+ }
}
}
} elsif ($context ne 'selfcreate') {
$canshow{'inststatus'} = 1;
$newsettings{'inststatus'} = $oldsettings{'inststatus'};
}
- $changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
+ foreach my $name ('portfolio','author') {
+ $changeHash{$name.'quota'} = $userenv{$name.'quota'};
+ }
if ($context eq 'domain') {
- if ($userenv{'portfolioquota'} ne '') {
- $oldportfolioquota = $userenv{'portfolioquota'};
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
+ foreach my $name ('portfolio','author') {
+ if ($userenv{$name.'quota'} ne '') {
+ $oldquota{$name} = $userenv{$name.'quota'};
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newquota{$name} = 0;
+ } else {
+ $newquota{$name} = $env{'form.'.$name.'quota'};
+ $newquota{$name} =~ s/[^\d\.]//g;
+ }
+ if ($newquota{$name} != $oldquota{$name}) {
+ if ("a_admin($newquota{$name},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
+ }
} else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
- if ($newportfolioquota != $oldportfolioquota) {
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
+ if ("a_admin('',\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
+ }
}
} else {
- $changed{'quota'} = "a_admin('',\%changeHash);
- $newportfolioquota = $newdefquota;
- $newisdefault = 1;
- }
- } else {
- $oldisdefault = 1;
- $oldportfolioquota = $olddefquota;
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
+ $oldisdefault{$name} = 1;
+ $oldquota{$name} = $olddefquota{$name};
+ if ($env{'form.custom_'.$name.'quota'} == 1) {
+ if ($env{'form.'.$name.'quota'} eq '') {
+ $newquota{$name} = 0;
+ } else {
+ $newquota{$name} = $env{'form.'.$name.'quota'};
+ $newquota{$name} =~ s/[^\d\.]//g;
+ }
+ if ("a_admin($newquota{$name},\%changeHash,$name)) {
+ $changed{$name.'quota'} = 1;
+ }
} else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
+ $newquota{$name} = $newdefquota{$name};
+ $newisdefault{$name} = 1;
}
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
+ }
+ if ($oldisdefault{$name}) {
+ $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name});
+ } else {
+ $oldsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$oldquota{$name});
+ }
+ if ($newisdefault{$name}) {
+ $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name});
} else {
- $newportfolioquota = $newdefquota;
- $newisdefault = 1;
+ $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name});
}
}
- if ($oldisdefault) {
- $oldsettingstext{'quota'} = &get_defaultquota_text($oldsettingstatus);
- }
- if ($newisdefault) {
- $newsettingstext{'quota'} = &get_defaultquota_text($newsettingstatus);
- }
&tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
\%changeHash,\%changed,\%newsettings,\%newsettingstext);
if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
&tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
- &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,
+ \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
} else {
&tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
@@ -2862,8 +2965,10 @@ sub update_user_data {
$namechanged{$item} = 1;
}
}
- $oldsettings{'quota'} = $oldportfolioquota.' Mb';
- $newsettings{'quota'} = $newportfolioquota.' Mb';
+ foreach my $name ('portfolio','author') {
+ $oldsettings{'quota'}{$name} = $oldquota{$name}.' MB';
+ $newsettings{'quota'}{$name} = $newquota{$name}.' MB';
+ }
if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
my ($chgresult,$namechgresult);
if (keys(%changed) > 0) {
@@ -3009,7 +3114,8 @@ sub update_user_data {
}
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
if ($env{'form.action'} eq 'singlestudent') {
- &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype);
+ &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,
+ $crstype,$showcredits,$defaultcredits);
$r->print('');
if ($crstype eq 'Community') {
$r->print(&mt('Enroll Another Member'));
@@ -3018,7 +3124,7 @@ sub update_user_data {
}
$r->print('
');
} else {
- my @rolechanges = &update_roles($r,$context);
+ my @rolechanges = &update_roles($r,$context,$showcredits);
if (keys(%namechanged) > 0) {
if ($context eq 'course') {
if (@userroles > 0) {
@@ -3062,7 +3168,7 @@ sub display_userinfo {
ref($newsetting) eq 'HASH' &&
ref($newsettingtext) eq 'HASH');
my %lt=&Apache::lonlocal::texthash(
- 'ui' => 'User Information (unchanged)',
+ 'ui' => 'User Information',
'uic' => 'User Information Changed',
'firstname' => 'First Name',
'middlename' => 'Middle Name',
@@ -3070,7 +3176,8 @@ sub display_userinfo {
'generation' => 'Generation',
'id' => 'Student/Employee ID',
'permanentemail' => 'Permanent e-mail address',
- 'quota' => 'Disk space allocated to portfolio files',
+ 'portfolioquota' => 'Disk space allocated to portfolio files',
+ 'authorquota' => 'Disk space allocated to authoring space',
'blog' => 'Blog Availability',
'webdav' => 'WebDAV Availability',
'aboutme' => 'Personal Information Page Availability',
@@ -3078,15 +3185,14 @@ sub display_userinfo {
'official' => 'Can Request Official Courses',
'unofficial' => 'Can Request Unofficial Courses',
'community' => 'Can Request Communities',
+ 'textbook' => 'Can Request Textbook Courses',
'requestauthor' => 'Can Request Author Role',
'inststatus' => "Affiliation",
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
);
- my $title = $lt{'ui'};
if ($changed) {
- $title = $lt{'uic'};
- $r->print(''.$title.'
'.
+ $r->print(''.$lt{'uic'}.'
'.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row());
$r->print(" | \n");
@@ -3094,57 +3200,89 @@ sub display_userinfo {
$r->print(''.$lt{'chto'}.' | ');
$r->print(&Apache::loncommon::end_data_table_header_row());
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
-
foreach my $item (@userinfo) {
my $value = $env{'form.c'.$item};
#show changes only:
- unless($value eq $userenv->{$item}){
+ unless ($value eq $userenv->{$item}){
$r->print(&Apache::loncommon::start_data_table_row());
-
$r->print("$lt{$item} | \n");
- $r->print(''.$userenv->{$item}.' | ');
+ $r->print("".$userenv->{$item}." | \n");
$r->print("$value | \n");
-
$r->print(&Apache::loncommon::end_data_table_row());
}
}
foreach my $entry (@{$order}) {
- if ($canshow->{$entry} && ($newsetting->{$entry} ne $newsetting->{$entry})) {
- $r->print(&Apache::loncommon::start_data_table_row());
- if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) {
- foreach my $item (@{$requestcourses}) {
- $r->print("$lt{$item} | \n");
- $r->print("$oldsetting->{$item} $oldsettingtext->{$item} | \n");
- my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
- if ($changedhash->{$item}) {
- $value = ''.$value.'';
+ if ($canshow->{$entry}) {
+ if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom') || ($entry eq 'requestauthor')) {
+ my @items;
+ if ($entry eq 'requestauthor') {
+ @items = ($entry);
+ } else {
+ @items = @{$requestcourses};
+ }
+ foreach my $item (@items) {
+ if (($newsetting->{$item} ne $oldsetting->{$item}) ||
+ ($newsettingtext->{$item} ne $oldsettingtext->{$item})) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$item} | \n");
+ $r->print("".$oldsetting->{$item});
+ if ($oldsettingtext->{$item}) {
+ if ($oldsetting->{$item}) {
+ $r->print(' -- ');
+ }
+ $r->print($oldsettingtext->{$item});
+ }
+ $r->print(" | \n");
+ $r->print("".$newsetting->{$item});
+ if ($newsettingtext->{$item}) {
+ if ($newsetting->{$item}) {
+ $r->print(' -- ');
+ }
+ $r->print($newsettingtext->{$item});
+ }
+ $r->print(" | \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
}
- $r->print("$value | \n");
}
} elsif ($entry eq 'tools') {
foreach my $item (@{$usertools}) {
- $r->print("$lt{$item} | \n");
- $r->print("$oldsetting->{$item} $oldsettingtext->{$item} | \n");
- my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
- if ($changedhash->{$item}) {
- $value = ''.$value.'';
- }
- $r->print("$value | \n");
- }
- } else {
- $r->print("$lt{$entry} | \n");
- $r->print("$oldsetting->{$entry} $oldsettingtext->{$entry} | \n");
- my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};
- if ($changedhash->{$entry}) {
- $value = ''.$value.'';
+ if ($newsetting->{$item} ne $oldsetting->{$item}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$item} | \n");
+ $r->print("".$oldsetting->{$item}.' '.$oldsettingtext->{$item}." | \n");
+ $r->print("".$newsetting->{$item}.' '.$newsettingtext->{$item}." | \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
+ }
+ }
+ } elsif ($entry eq 'quota') {
+ if ((ref($oldsetting->{$entry}) eq 'HASH') && (ref($oldsettingtext->{$entry}) eq 'HASH') &&
+ (ref($newsetting->{$entry}) eq 'HASH') && (ref($newsettingtext->{$entry}) eq 'HASH')) {
+ foreach my $name ('portfolio','author') {
+ if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$name.$entry} | \n");
+ $r->print("".$oldsettingtext->{$entry}->{$name}." | \n");
+ $r->print("".$newsettingtext->{$entry}->{$name}." | \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
+ }
+ }
+ }
+ } else {
+ if ($newsetting->{$entry} ne $oldsetting->{$entry}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("$lt{$entry} | \n");
+ $r->print("".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}." | \n");
+ $r->print("".$newsetting->{$entry}.' '.$newsettingtext->{$entry}." | \n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
}
- $r->print("$value | \n");
}
- $r->print(&Apache::loncommon::end_data_table_row());
}
}
$r->print(&Apache::loncommon::end_data_table().'
');
+ } else {
+ $r->print(''.$lt{'ui'}.'
'.
+ ''.&mt('No changes made to user information').'
');
}
return;
}
@@ -3158,20 +3296,20 @@ sub tool_changes {
(ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) {
return;
}
+ my %reqdisplay = &requestchange_display();
if ($context eq 'reqcrsotherdom') {
my @options = ('approval','validate','autolimit');
my $optregex = join('|',@options);
- my %reqdisplay = &courserequest_display();
my $cdom = $env{'request.role.domain'};
foreach my $tool (@{$usertools}) {
- $oldaccesstext->{$tool} = &mt('No');
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
$newaccesstext->{$tool} = $oldaccesstext->{$tool};
$changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
- my $newop;
+ my ($newop,$limit);
if ($env{'form.'.$context.'_'.$tool}) {
$newop = $env{'form.'.$context.'_'.$tool};
if ($newop eq 'autolimit') {
- my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
+ $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
$limit =~ s/\D+//g;
$newop .= '='.$limit;
}
@@ -3181,7 +3319,15 @@ sub tool_changes {
$changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop,
$changeHash,$context);
if ($changed->{$tool}) {
- $newaccesstext->{$tool} = &mt('Yes');
+ if ($newop =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } else {
+ $newaccesstext->{$tool} = $reqdisplay{$newop};
+ }
} else {
$newaccesstext->{$tool} = $oldaccesstext->{$tool};
}
@@ -3192,8 +3338,17 @@ sub tool_changes {
my $changedoms;
foreach my $req (@curr) {
if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) {
- $oldaccesstext->{$tool} = &mt('Yes');
my $oldop = $1;
+ if ($oldop =~ /^autolimit=(\d*)/) {
+ my $limit = $1;
+ if ($limit) {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } else {
+ $oldaccesstext->{$tool} = $reqdisplay{$oldop};
+ }
if ($oldop ne $newop) {
$changedoms = 1;
foreach my $item (@curr) {
@@ -3227,15 +3382,15 @@ sub tool_changes {
my $limit = $env{'form.'.$context.'_'.$tool.'_limit'};
$limit =~ s/\D+//g;
if ($limit) {
- $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit);
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
} else {
- $newaccesstext->{$tool} = &mt('Yes, processed automatically');
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
}
} else {
$newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}};
}
} else {
- $newaccesstext->{$tool} = &mt('No');
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
}
}
}
@@ -3244,12 +3399,14 @@ sub tool_changes {
return;
}
foreach my $tool (@{$usertools}) {
- my ($newval,$envkey);
+ my ($newval,$limit,$envkey);
$envkey = $context.'.'.$tool;
if ($context eq 'requestcourses') {
$newval = $env{'form.crsreq_'.$tool};
if ($newval eq 'autolimit') {
- $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
+ $limit = $env{'form.crsreq_'.$tool.'_limit'};
+ $limit =~ s/\D+//g;
+ $newval .= '='.$limit;
}
} elsif ($context eq 'requestauthor') {
$newval = $env{'form.'.$context};
@@ -3259,10 +3416,25 @@ sub tool_changes {
}
if ($userenv->{$envkey} ne '') {
$oldaccess->{$tool} = &mt('custom');
- if ($userenv->{$envkey}) {
- $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($userenv->{$envkey} =~ /^autolimit=(\d*)$/) {
+ my $currlimit = $1;
+ if ($currlimit eq '') {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ } else {
+ $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$currlimit);
+ }
+ } elsif ($userenv->{$envkey}) {
+ $oldaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}};
+ } else {
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$envkey}) {
+ $oldaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $oldaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
$changeHash->{$envkey} = $userenv->{$envkey};
if ($env{'form.custom'.$tool} == 1) {
@@ -3271,17 +3443,45 @@ sub tool_changes {
$context);
if ($changed->{$tool}) {
$newaccess->{$tool} = &mt('custom');
- if ($newval) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($newval) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
- if ($userenv->{$context.'.'.$tool}) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
}
} else {
@@ -3294,10 +3494,24 @@ sub tool_changes {
$newaccess->{$tool} = &mt('default');
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
- if ($userenv->{$context.'.'.$tool}) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($userenv->{$context.'.'.$tool}) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
}
}
@@ -3308,10 +3522,24 @@ sub tool_changes {
$context);
if ($changed->{$tool}) {
$newaccess->{$tool} = &mt('custom');
- if ($newval) {
- $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
+ if ($newval =~ /^autolimit/) {
+ if ($limit) {
+ $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit);
+ } else {
+ $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)');
+ }
+ } elsif ($newval) {
+ $newaccesstext->{$tool} = $reqdisplay{$newval};
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
} else {
- $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ if ($newval) {
+ $newaccesstext->{$tool} = &mt("availability set to 'on'");
+ } else {
+ $newaccesstext->{$tool} = &mt("availability set to 'off'");
+ }
}
} else {
$newaccess->{$tool} = $oldaccess->{$tool};
@@ -3325,7 +3553,7 @@ sub tool_changes {
}
sub update_roles {
- my ($r,$context) = @_;
+ my ($r,$context,$showcredits) = @_;
my $now=time;
my @rolechanges;
my %disallowed;
@@ -3343,8 +3571,13 @@ sub update_roles {
$env{'form.ccuname'},
$scope,$role,'','',$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
- &mt('Revoking [_1] in [_2]', &Apache::lonnet::plaintext($role), '"'.&cid_to_cname($scope).'"
'),
- $result ne "ok"));
+ &mt('Revoking [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
@@ -3358,10 +3591,15 @@ sub update_roles {
}
if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) {
# Revoke custom role
+ my $result = &Apache::lonnet::revokecustomrole(
+ $env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
- &mt('Revoking custom role [_1] by [_2]:[_3] in [_4]',$4,$3,$2,'"'.&cid_to_cname($1).'"
'),
- &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context) ne 'ok'));
-
+ &mt('Revoking custom role [_1] by [_2] in [_3]',
+ $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne 'ok').'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3377,14 +3615,19 @@ sub update_roles {
$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Deleting [_1] in [_2]',
- &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($scope).'"
'),$result ne 'ok'));
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne 'ok').'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
$now);
- $r->print($result);
+ $r->print(&Apache::lonhtmlcommon::confirm_success($result));
}
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3393,11 +3636,16 @@ sub update_roles {
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
# Delete custom role
- $r->print(&confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
- $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'
'));
- &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
- 0,1,$context);
+ my $result =
+ &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
+ 0,1,$context);
+ $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
@@ -3414,16 +3662,25 @@ sub update_roles {
my $output;
if ($role eq 'st') {
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
- my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+ my ($cdom,$cnum,$csec) = ($1,$2,$3);
+ my $credits;
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
+ $credits = &get_user_credits($defaultcredits,$cdom,$cnum);
+ }
+ my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
if ($result eq 'refused' && $logmsg) {
$output = $logmsg;
} else {
- $output = "Error: $result\n";
+ $output = &mt('Error: [_1]',$result)."\n";
}
} else {
- $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',&Apache::lonnet::plaintext($role),
- '"'.&cid_to_cname($url).'"',&Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
';
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,'st'),
+ &Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
';
}
}
} else {
@@ -3431,8 +3688,12 @@ sub update_roles {
$env{'form.ccuname'},$url,$role,0,$now,'','',
$context);
$output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
- &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($url).'"').'
',$result ne "ok");
- }
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'
';
+ if ($result ne "ok") {
+ $output .= &mt('Error: [_1]',$result).'
';
+ }
+ }
$r->print($output);
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3444,8 +3705,13 @@ sub update_roles {
my $result = &Apache::lonnet::assigncustomrole(
$env{'form.ccdomain'}, $env{'form.ccuname'},
$url,$rdom,$rnam,$rolename,0,$now,undef,$context);
- $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling custom role [_1] by [_2] in [_3]',
- $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'
'),$result ne "ok");
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Re-enabling custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3502,8 +3768,20 @@ sub update_roles {
# split multiple sections
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
+ my $credits;
+ if ($three eq 'st') {
+ if ($showcredits) {
+ my $defaultcredits =
+ &Apache::lonuserutils::get_defaultcredits($one,$two);
+ $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
if ($num_sections == 0) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
} else {
my %curr_groups =
&Apache::longroup::coursegroups($one,$two);
@@ -3517,13 +3795,13 @@ sub update_roles {
next;
}
my $securl = $url.'/'.$sec;
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits));
} else {
$emptysec = 1;
}
}
if ($emptysec) {
- $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context));
+ $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
}
}
if (!grep(/^\Q$three\E$/,@rolechanges)) {
@@ -3585,13 +3863,36 @@ sub update_roles {
# Flush the course logs so reverse user roles immediately updated
$r->register_cleanup(\&Apache::lonnet::flushcourselogs);
if (@rolechanges == 0) {
- $r->print(&mt('No roles to modify'));
+ $r->print(''.&mt('No roles to modify').'
');
}
return @rolechanges;
}
+sub get_user_credits {
+ my ($uname,$udom,$defaultcredits,$cdom,$cnum) = @_;
+ if ($cdom eq '' || $cnum eq '') {
+ return unless ($env{'request.course.id'});
+ $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ }
+ my $credits;
+ my %currhash =
+ &Apache::lonnet::get('classlist',[$uname.':'.$udom],$cdom,$cnum);
+ if (keys(%currhash) > 0) {
+ my @items = split(/:/,$currhash{$uname.':'.$udom});
+ my $crdidx = &Apache::loncoursedata::CL_CREDITS() - 3;
+ $credits = $items[$crdidx];
+ $credits =~ s/[^\d\.]//g;
+ }
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ return $credits;
+}
+
sub enroll_single_student {
- my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype) = @_;
+ my ($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype,
+ $showcredits,$defaultcredits) = @_;
$r->print('');
if ($crstype eq 'Community') {
$r->print(&mt('Enrolling Member'));
@@ -3603,6 +3904,17 @@ sub enroll_single_student {
# Remove non alphanumeric values from section
$env{'form.sections'}=~s/\W//g;
+ my $credits;
+ if (($showcredits) && ($env{'form.credits'} ne '')) {
+ $credits = $env{'form.credits'};
+ $credits =~ s/[^\d\.]//g;
+ if ($credits ne '') {
+ if ($credits eq $defaultcredits) {
+ undef($credits);
+ }
+ }
+ }
+
# Clean out any old student roles the user has in this class.
&Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
$env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
@@ -3612,9 +3924,10 @@ sub enroll_single_student {
$env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
$env{'form.cmiddlename'},$env{'form.clastname'},
$env{'form.generation'},$env{'form.sections'},$enddate,
- $startdate,'manual',undef,$env{'request.course.id'},'',$context);
+ $startdate,'manual',undef,$env{'request.course.id'},'',$context,
+ $credits);
if ($enroll_result =~ /^ok/) {
- $r->print(&mt('[_1] enrolled',$env{'form.ccuname'}.':'.$env{'form.ccdomain'}));
+ $r->print(&mt('[_1] enrolled',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.''));
if ($env{'form.sections'} ne '') {
$r->print(' '.&mt('in section [_1]',$env{'form.sections'}));
}
@@ -3649,14 +3962,14 @@ sub get_defaultquota_text {
my ($settingstatus) = @_;
my $defquotatext;
if ($settingstatus eq '') {
- $defquotatext = &mt('(default)');
+ $defquotatext = &mt('default');
} else {
my ($usertypes,$order) =
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'});
if ($usertypes->{$settingstatus} eq '') {
- $defquotatext = &mt('(default)');
+ $defquotatext = &mt('default');
} else {
- $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus});
+ $defquotatext = &mt('default for [_1]',$usertypes->{$settingstatus});
}
}
return $defquotatext;
@@ -3681,20 +3994,20 @@ sub update_result_form {
$outcome .= ''."\n";
}
$outcome .= ''."\n".
- ''."\n".
- ''."\n".
+ ''."\n".
+ ''."\n".
'