--- loncom/interface/loncreateuser.pm 2012/12/28 04:12:32 1.370
+++ loncom/interface/loncreateuser.pm 2013/06/04 23:12:08 1.377
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.370 2012/12/28 04:12:32 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.377 2013/06/04 23:12:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1042,7 +1042,8 @@ sub print_user_query_page {
}
sub print_user_modification_page {
- my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype,$brcrum) = @_;
+ my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission,$crstype,
+ $brcrum,$showcredits) = @_;
if (($ccuname eq '') || ($ccdomain eq '')) {
my $usermsg = &mt('No username and/or domain provided.');
$env{'form.phase'} = '';
@@ -1133,7 +1134,7 @@ sub print_user_modification_page {
my $groupslist = &Apache::lonuserutils::get_groupslist();
- my $js = &validation_javascript($context,$ccdomain,$pjump_def,
+ my $js = &validation_javascript($context,$ccdomain,$pjump_def,$crstype,
$groupslist,$newuser,$formname,\%loaditem);
my %breadcrumb_text = &singleuser_breadcrumb($crstype);
my $helpitem = 'Course_Change_Privileges';
@@ -1176,10 +1177,13 @@ sub print_user_modification_page {
ENDFORMINFO
- my (%inccourses,$roledom);
+ my (%inccourses,$roledom,$defaultcredits);
if ($context eq 'course') {
$inccourses{$env{'request.course.id'}}=1;
$roledom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ if ($showcredits) {
+ $defaultcredits = &Apache::lonuserutils::get_defaultcredits();
+ }
} elsif ($context eq 'author') {
$roledom = $env{'request.role.domain'};
} elsif ($context eq 'domain') {
@@ -1319,7 +1323,8 @@ ENDAUTH
$r->print($portfolioform.$domroleform);
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname,
- $permission));
+ $permission,$crstype,$ccuname,
+ $ccdomain,$showcredits));
}
$r->print('
');
} else { # user already exists
@@ -1421,8 +1426,17 @@ ENDNOTOOLSPRIV
unless ($gotdiv) {
$r->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 +1454,7 @@ ENDNOTOOLSPRIV
}
$r->print(' '."\n");
} else {
- $r->print(''.&mt('Add Roles').' ');
+ $r->print(''.&mt('Add Roles').' ');
my $addrolesdisplay = 0;
if ($context eq 'domain' || $context eq 'author') {
$addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);
@@ -1450,23 +1464,23 @@ ENDNOTOOLSPRIV
if (!$addrolesdisplay) {
$addrolesdisplay = $add_domainroles;
}
- $r->print(&course_level_dc($env{'request.role.domain'},'Course'));
- $r->print(' '."\n");
+ $r->print(&course_level_dc($env{'request.role.domain'},$showcredits));
+ $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 +1509,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 +1551,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 +1572,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 +1582,7 @@ sub display_existing_roles {
'ren' => "Re-Enable",
'rol' => "Role",
'ext' => "Extent",
+ 'crd' => "Credits",
'sta' => "Start",
'end' => "End",
);
@@ -1618,6 +1645,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 +1674,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 +1709,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 +1739,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 +1781,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 +1810,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 +1836,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(''.
+'
'.$contextrole.' '.
&Apache::loncommon::start_data_table("LC_createuser").
&Apache::loncommon::start_data_table_header_row().
''.$lt{'rev'}.' '.$lt{'ren'}.' '.$lt{'del'}.
' '.$lt{'rol'}.' '.$lt{'ext'}.
' '.$lt{'sta'}.' '.$lt{'end'}.' '.
&Apache::loncommon::end_data_table_header_row());
- foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+ foreach my $type ('Authoring Space','Course','Community','Domain','System','Unknown') {
if ($output{$type}) {
$r->print($output{$type}."\n");
}
}
- $r->print(&Apache::loncommon::end_data_table());
+ $r->print(&Apache::loncommon::end_data_table().
+ ' ');
}
return;
}
@@ -1830,7 +1873,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 +1924,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 +2357,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
@@ -2593,10 +2636,14 @@ 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
@@ -3009,7 +3056,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 +3066,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 +3110,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',
@@ -3083,10 +3131,8 @@ sub display_userinfo {
'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");
@@ -3145,6 +3191,9 @@ sub display_userinfo {
}
}
$r->print(&Apache::loncommon::end_data_table().' ');
+ } else {
+ $r->print(''.$lt{'ui'}.' '.
+ ''.&mt('No changes made to user information').'
');
}
return;
}
@@ -3325,7 +3374,7 @@ sub tool_changes {
}
sub update_roles {
- my ($r,$context) = @_;
+ my ($r,$context,$showcredits) = @_;
my $now=time;
my @rolechanges;
my %disallowed;
@@ -3345,7 +3394,7 @@ sub update_roles {
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Revoking [_1] in [_2]',
&Apache::lonnet::plaintext($role),
- '"'.&cid_to_cname($scope).'"'),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
$result ne "ok").' ');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).' ');
@@ -3367,7 +3416,7 @@ sub update_roles {
$env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Revoking custom role [_1] by [_2] in [_3]',
- $4,$3.':'.$2,'"'.&cid_to_cname($1).'"'),
+ $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')),
$result ne 'ok').' ');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).' ');
@@ -3388,7 +3437,7 @@ sub update_roles {
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Deleting [_1] in [_2]',
&Apache::lonnet::plaintext($role),
- '"'.&cid_to_cname($scope).'"'),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
$result ne 'ok').' ');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).' ');
@@ -3413,7 +3462,7 @@ sub update_roles {
$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,'"'.&cid_to_cname($1).'"'),
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
$result ne "ok").' ');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).' ');
@@ -3434,7 +3483,14 @@ 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;
@@ -3442,8 +3498,10 @@ sub update_roles {
$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 {
@@ -3451,7 +3509,8 @@ 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).' ';
}
@@ -3469,7 +3528,7 @@ sub update_roles {
$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).'"'),
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
$result ne "ok").' ');
if ($result ne "ok") {
$r->print(&mt('Error: [_1]',$result).' ');
@@ -3530,8 +3589,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);
@@ -3545,13 +3616,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)) {
@@ -3613,13 +3684,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'));
@@ -3631,6 +3725,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);
@@ -3640,7 +3745,8 @@ 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'}));
if ($env{'form.sections'} ne '') {
@@ -4184,6 +4290,7 @@ sub handler {
} else {
$context = 'domain';
}
+
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);
@@ -4215,6 +4322,16 @@ sub handler {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
+ my $showcredits;
+ if ((($context eq 'course') && ($crstype eq 'Course')) ||
+ ($context eq 'domain')) {
+ my %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
+ if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {
+ $showcredits = 1;
+ }
+ }
+
# Main switch on form.action and form.state, as appropriate
if (! exists($env{'form.action'})) {
$args = {bread_crumbs => $brcrum,
@@ -4237,11 +4354,12 @@ sub handler {
if (! exists($env{'form.state'})) {
&Apache::lonuserutils::print_first_users_upload_form($r,$context);
} elsif ($env{'form.state'} eq 'got_file') {
- &Apache::lonuserutils::print_upload_manager_form($r,$context,
- $permission,$crstype);
+ &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission,
+ $crstype,$showcredits);
} elsif ($env{'form.state'} eq 'enrolling') {
if ($env{'form.datatoken'}) {
- &Apache::lonuserutils::upfile_drop_add($r,$context,$permission);
+ &Apache::lonuserutils::upfile_drop_add($r,$context,$permission,
+ $showcredits);
}
} else {
&Apache::lonuserutils::print_first_users_upload_form($r,$context);
@@ -4266,13 +4384,15 @@ sub handler {
.' letters numbers - . @')
.'';
$env{'form.phase'} = '';
- &print_username_entry_form($r,$context,$response,$srch,undef,$crstype,$brcrum);
+ &print_username_entry_form($r,$context,$response,$srch,undef,
+ $crstype,$brcrum,$showcredits);
} else {
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'});
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'});
&print_user_modification_page($r,$ccuname,$ccdomain,
$srch,$response,$context,
- $permission,$crstype,$brcrum);
+ $permission,$crstype,$brcrum,
+ $showcredits);
}
} elsif ($env{'form.phase'} eq 'get_user_info') {
my ($currstate,$response,$forcenewuser,$results) =
@@ -4317,7 +4437,7 @@ sub handler {
$brcrum);
}
} elsif ($env{'form.phase'} eq 'update_user_data') {
- &update_user_data($r,$context,$crstype,$brcrum);
+ &update_user_data($r,$context,$crstype,$brcrum,$showcredits);
} else {
&print_username_entry_form($r,$context,undef,$srch,undef,$crstype,
$brcrum);
@@ -4420,7 +4540,8 @@ sub handler {
$r->print(&header(&add_script($jscript),$args));
}
&Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
- $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
+ $formname,$totcodes,$codetitles,$idlist,$idlist_titles,
+ $showcredits);
}
} elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) {
my $brtext;
@@ -4451,8 +4572,8 @@ sub handler {
} elsif ($env{'form.action'} eq 'dateselect') {
if ($permission->{'cusr'}) {
$r->print(&header(undef,{'no_nav_bar' => 1}).
- &Apache::lonuserutils::date_section_selector($context,
- $permission,$crstype));
+ &Apache::lonuserutils::date_section_selector($context,$permission,
+ $crstype,$showcredits));
} else {
$r->print(&header(undef,{'no_nav_bar' => 1}).
''.&mt('You do not have permission to modify dates or sections for users').' ');
@@ -4554,6 +4675,11 @@ sub add_script {
sub verify_user_display {
my ($context) = @_;
+ my %lt = &Apache::lonlocal::texthash (
+ course => 'course(s): description, section(s), status',
+ community => 'community(s): description, section(s), status',
+ author => 'author',
+ );
my $photos;
if (($context eq 'course') && $env{'request.course.id'}) {
$photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
@@ -4577,16 +4703,25 @@ function updateCols(caller) {
var context = '$context';
var photos = '$photos';
if (caller == 'Status') {
- if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
- document.getElementById('showcolstatus').checked = true;
- document.getElementById('showcolstatus').disabled = '';
- document.getElementById('showcolstart').checked = true;
- document.getElementById('showcolend').checked = true;
- } else {
+ if ((context == 'domain') &&
+ ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
document.getElementById('showcolstatus').checked = false;
document.getElementById('showcolstatus').disabled = 'disabled';
document.getElementById('showcolstart').checked = false;
document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ } else {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ }
}
}
if (caller == 'output') {
@@ -4604,13 +4739,53 @@ function updateCols(caller) {
}
}
if (caller == 'showrole') {
- if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') {
+ if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') ||
+ (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'cr')) {
document.getElementById('showcolrole').checked = true;
document.getElementById('showcolrole').disabled = '';
} else {
document.getElementById('showcolrole').checked = false;
document.getElementById('showcolrole').disabled = 'disabled';
}
+ if (context == 'domain') {
+ if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ }
+ }
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') {
+ document.getElementById('showcolextent').disabled = 'disabled';
+ document.getElementById('showcolextent').checked = 'false';
+ document.getElementById('showextent').style.display='none';
+ document.getElementById('showcoltextextent').innerHTML = '';
+ } else {
+ document.getElementById('showextent').style.display='block';
+ document.getElementById('showextent').style.textAlign='left';
+ document.getElementById('showextent').style.textFace='normal';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ document.getElementById('showcoltextextent').innerHTML="$lt{'author'}";
+ } else {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'community'}";
+ } else {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'course'}";
+ }
+ }
+ }
+ }
}
return;
}
@@ -5850,7 +6025,7 @@ sub role_display_filter {
&mt('Context:').'';
my @posscontexts;
if ($context eq 'course') {
- @posscontexts = ('any','auto','updatenow','createcourse','course','domain','selfenroll','requestcourses');
+ @posscontexts = ('any','automated','updatenow','createcourse','course','domain','selfenroll','requestcourses');
} elsif ($context eq 'domain') {
@posscontexts = ('any','domain','requestauthor','domconfig','server');
} else {
@@ -5862,7 +6037,7 @@ sub role_display_filter {
$selstr = ' selected="selected"';
}
if ($context eq 'course') {
- if (($chgtype eq 'auto') || ($chgtype eq 'updatenow')) {
+ if (($chgtype eq 'automated') || ($chgtype eq 'updatenow')) {
next if (!&Apache::lonnet::auto_run($cnum,$cdom));
}
}
@@ -5898,7 +6073,7 @@ sub rolechg_contexts {
if ($context eq 'course') {
%lt = &Apache::lonlocal::texthash (
any => 'Any',
- auto => 'Automated enrollment',
+ automated => 'Automated Enrollment',
updatenow => 'Roster Update',
createcourse => 'Course Creation',
course => 'User Management in course',
@@ -6423,7 +6598,8 @@ function backPage(formname,prevphase,pre
}
sub course_level_table {
- my (%inccourses) = @_;
+ my ($inccourses,$showcredits,$defaultcredits) = @_;
+ return unless (ref($inccourses) eq 'HASH');
my $table = '';
# Custom Roles?
@@ -6438,11 +6614,12 @@ sub course_level_table {
'rol' => "Role",
'ext' => "Extent",
'grs' => "Section",
+ 'crd' => "Credits",
'sta' => "Start",
'end' => "End"
);
- foreach my $protectedcourse (sort(keys(%inccourses))) {
+ foreach my $protectedcourse (sort(keys(%{$inccourses}))) {
my $thiscourse=$protectedcourse;
$thiscourse=~s:_:/:g;
my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
@@ -6464,12 +6641,14 @@ sub course_level_table {
if ((&Apache::lonnet::allowed('c'.$role,$thiscourse)) ||
((($role eq 'cc') || ($role eq 'co')) && ($isowner))) {
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
- $plrole,\%sections_count,\%lt);
+ $plrole,\%sections_count,\%lt,
+ $defaultcredits,$crstype);
} elsif ($env{'request.course.sec'} ne '') {
if (&Apache::lonnet::allowed('c'.$role,$thiscourse.'/'.
$env{'request.course.sec'})) {
$table .= &course_level_row($protectedcourse,$role,$area,$domain,
- $plrole,\%sections_count,\%lt);
+ $plrole,\%sections_count,\%lt,
+ $defaultcredits,$crstype);
}
}
}
@@ -6491,8 +6670,10 @@ sub course_level_table {
$result .=
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
-''.$lt{'act'}.' '.$lt{'rol'}.' '.$lt{'ext'}.'
-'.$lt{'grs'}.' '.$lt{'sta'}.' '.$lt{'end'}.' '.
+''.$lt{'act'}.' '.$lt{'rol'}.' '."\n".
+''.$lt{'ext'}.' '.$lt{'crd'}.' '."\n".
+''.$lt{'grs'}.' '.$lt{'sta'}.' '."\n".
+''.$lt{'end'}.' '.
&Apache::loncommon::end_data_table_header_row().
$table.
&Apache::loncommon::end_data_table();
@@ -6500,12 +6681,21 @@ $table.
}
sub course_level_row {
- my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,$lt) = @_;
+ my ($protectedcourse,$role,$area,$domain,$plrole,$sections_count,
+ $lt,$defaultcredits,$crstype) = @_;
+ my $creditem;
my $row = &Apache::loncommon::start_data_table_row().
' '."\n".
' '.$plrole.' '."\n".
' '.$area.' Domain: '.$domain.' '."\n";
+ if (($role eq 'st') && ($crstype eq 'Course')) {
+ $row .=
+ ' ';
+ } else {
+ $row .= ' ';
+ }
if (($role eq 'cc') || ($role eq 'co')) {
$row .= ' ';
} elsif ($env{'request.course.sec'} ne '') {
@@ -6531,7 +6721,7 @@ sub course_level_row {
''."\n";
} else {
$row .= ' '."\n";
+ 'name="sec_'.$protectedcourse.'_'.$role.'" />'."\n";
}
}
$row .= < '.
@@ -6555,7 +6745,11 @@ sub course_level_dc {
' ';
my $courseform=&Apache::loncommon::selectcourse_link
('cu','dccourse','dcdomain','coursedesc',undef,undef,'Select','crstype');
- my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser');
+ my $credit_elem;
+ if ($showcredits) {
+ $credit_elem = 'credits';
+ }
+ my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu','role','Course/Community Browser',$credit_elem);
my %lt=&Apache::lonlocal::texthash(
'rol' => "Role",
'grs' => "Section",
@@ -6565,12 +6759,15 @@ sub course_level_dc {
'end' => "End",
'ssd' => "Set Start Date",
'sed' => "Set End Date",
- 'scc' => "Course/Community"
+ 'scc' => "Course/Community",
+ 'crd' => "Credits",
);
my $header = ''.&mt('Course/Community Level').' '.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
- ''.$lt{'scc'}.' '.$lt{'rol'}.' '.$lt{'grs'}.' '.$lt{'sta'}.' '.$lt{'end'}.' '.
+ ''.$lt{'scc'}.' '.$lt{'rol'}.' '."\n".
+ ''.$lt{'grs'}.' '.$lt{'crd'}.' '."\n".
+ ''.$lt{'sta'}.' '.$lt{'end'}.' '."\n".
&Apache::loncommon::end_data_table_header_row();
my $otheritems = &Apache::loncommon::start_data_table_row()."\n".
' '.
@@ -6597,7 +6794,11 @@ sub course_level_dc {
' '.
' '.
' '.
- '';
+ ''."\n";
+ if ($showcredits) {
+ $otheritems .= ' '."\n".
+ ' '."\n";
+ }
$otheritems .= <