--- loncom/interface/loncreateuser.pm 2012/12/28 04:12:32 1.370
+++ loncom/interface/loncreateuser.pm 2013/03/01 04:55:34 1.375
@@ -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.375 2013/03/01 04:55:34 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('
'."\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) {
@@ -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]',
@@ -1797,9 +1840,8 @@ sub display_existing_roles {
} else {
$contextrole = &mt('Existing Roles in this Domain');
}
- $r->print('
-'.$lt{'rer'}.'
'.
-''.$contextrole.'
'.
+ $r->print(''.
+'