'."\n".$form."\n".
+ my $title;
+ if ($env{'form.crstype'} eq 'community') {
+ $title = &mt('Community Request Details');
+ } else {
+ $title = &mt('Course Request Details');
+ }
+ $r->print('
'.$title.' '."\n".$form."\n".
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
- \@code_order)."\n".
+ \@code_order,'','','','',$instcredits)."\n".
' '."\n");
- my @excluded = &get_excluded_elements($dom,$states,'new','review');
+ my @excluded = &get_excluded_elements($dom,$states,'new','review',
+ $showcredits);
push(@excluded,'origcnum');
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'
');
my $other = 'modify';
@@ -867,10 +984,17 @@ END
$navtxt{'next'},$state,$other,$navtxt{'other'});
$r->print('');
} elsif ($state eq 'cancel') {
+ my $title;
+ if ($env{'form.crstype'} eq 'community') {
+ $title = &mt('Cancel community request');
+ } else {
+ $title = &mt('Cancel course request');
+ }
my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
- $r->print('
'.&mt('Cancel course request').' '."\n".$form."\n".
+ $r->print('
'.$title.' '."\n".$form."\n".
$output);
- my @excluded = &get_excluded_elements($dom,$states,'view','cancel');
+ my @excluded = &get_excluded_elements($dom,$states,'view','cancel',
+ $showcredits);
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'
');
my %navtxt = &Apache::lonlocal::texthash (
prev => 'Back',
@@ -917,7 +1041,11 @@ END
'
'."\n".
'
'."\n");
if ($result eq 'ok') {
- $r->print(&mt('Your course request has been cancelled.'));
+ if ($env{'form.crstype'} eq 'community') {
+ $r->print(&mt('Your community request has been cancelled.'));
+ } else {
+ $r->print(&mt('Your course request has been cancelled.'));
+ }
} else {
$r->print('
'.
&mt('The request cancellation process was not complete.').
@@ -932,13 +1060,20 @@ END
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
}
- $r->print(&header('Course Request','','','',{ 'only_body' => 1}).
- $crumb."\n".'
'.&mt('Course Request Details').' '.
+ my ($title,$header);
+ if ($env{'form.crstype'} eq 'community') {
+ $title = 'Community Request';
+ $header = &mt('Community Request');
+ } else {
+ $title = 'Course Request';
+ $header = &mt('Course Request');
+ }
+ $r->print(&header($title,'','','',{ 'only_body' => 1}).
+ $crumb."\n".''.$header.' '.
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
- \@code_order,$uname,$udom)."\n".''.
+ \@code_order,$uname,$udom,'','',$instcredits)."\n".
+ '
'.
&close_popup_form());
- } elsif ($action eq 'log') {
- $r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);
}
$r->print(&Apache::loncommon::end_page());
return;
@@ -1131,7 +1266,7 @@ sub get_instcode {
sub print_request_form {
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
- $description,$invalidcrosslist) = @_;
+ $description,$showcredits,$instcredits,$invalidcrosslist) = @_;
my $formname = 'requestcrs';
my ($next,$prev,$message,$output,$codepicker,$crstype);
$prev = $states->{$action}[$page-1];
@@ -1204,7 +1339,7 @@ sub print_request_form {
}
$r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
\%cat_titles,\%cat_order,\@code_order,
- $invalidcrosslist));
+ $showcredits,$instcredits,$invalidcrosslist));
} elsif ($state eq 'personnel') {
$r->print(&print_personnel_menu($dom,$formname,$crstype,$invalidcrosslist));
} elsif ($state eq 'review') {
@@ -1230,16 +1365,38 @@ sub print_request_form {
}
if ($skipuser) {
push(@disallowed,$i);
- $disallowmsg{$i} = &mt('[_1] was excluded because new users need be from the course domain','
'.$personname.':'.$persondom.' ');
+ $disallowmsg{$i} = &mt('[_1] was excluded because new users need to be from the course domain','
'.$personname.':'.$persondom.' ');
next;
}
}
- if (&get_cancreate_status($persondom,$personname,$dom)) {
- my ($allowed,$msg) =
+ my $usertype = &get_usertype($persondom,$personname,\%curr_rules,\%got_rules);
+ if (&Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype)) {
+ my ($allowed,$msg,$authtype,$authparam) =
&check_newuser_rules($persondom,$personname,
\%alerts,\%rulematch,\%inst_results,
\%curr_rules,\%got_rules);
if ($allowed) {
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($persondom);
+ if ($usertype eq 'official') {
+ if ($authtype eq '') {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ } elsif ($usertype eq 'unofficial') {
+ if ($authtype eq '') {
+ $authtype = 'internal';
+ $authparam = '';
+ }
+ } else {
+ $authtype = $domdefaults{'auth_def'};
+ $authparam = $domdefaults{'auth_arg_def'};
+ }
+ if (($authtype eq '') ||
+ (($authtype =~/^krb/) && ($authparam eq ''))) {
+ push(@disallowed,$i);
+ $disallowmsg{$i} = &mt('[_1] was excluded because institutional information is incomplete for this new user.','
'.$personname.':'.$persondom.' ');
+ next;
+ }
if (ref($inst_results{$personname.':'.$persondom}) eq 'HASH') {
if ($inst_results{$personname.':'.$persondom}{'lastname'} ne '') {
$env{'form.person_'.$i.'_lastname'} = $inst_results{$personname.':'.$persondom}{'lastname'};
@@ -1285,33 +1442,103 @@ sub print_request_form {
if ($env{'form.origcnum'} =~ /^($match_courseid)$/) {
$cnum = $env{'form.origcnum'};
} else {
- $cnum = &Apache::lonnet::generate_coursenum($dom);
+ my $gentype = 'Course';
+ if ($crstype eq 'community') {
+ $gentype = 'Community';
+ }
+ $cnum = &Apache::lonnet::generate_coursenum($dom,$gentype);
}
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
- $r->print('
'.&mt('Review course request details before submission').' '.
- &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg).
+ if ($crstype eq 'community') {
+ $r->print('
'.&mt('Review community request details before submission').' ');
+ } else {
+ $r->print('
'.&mt('Review course request details before submission').' ');
+ }
+ $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg,$instcredits).
'
');
- $navtxt{'next'} = &mt('Submit course request');
+ if ($crstype eq 'community') {
+ $navtxt{'next'} = &mt('Submit community request');
+ } else {
+ $navtxt{'next'} = &mt('Submit course request');
+ }
} elsif ($state eq 'process') {
if ($crstype eq 'official') {
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
}
my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles,
- \@code_order);
+ \@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
- $r->print('
');
if ($storeresult eq 'ok') {
- $r->print(''.
- &mt('Modify this request').' '.(' 'x4));
+ $r->print('
'.
+ &mt('Modify this request').' '.(' 'x4).
+ ''.&mt('Make another request').'
');
+ }
+ if (&Apache::loncoursequeueadmin::author_prompt()) {
+ $r->print('
'.&mt('Access to authoring space').' '.
+ '
'.
+ &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.').
+ ' '.
+ &mt('By contrast, items created in authoring space, then imported into a course, can use all of the features of the assessment engine.').'
'.
+ '
'.&mt('Request authoring space access now?').
+ ' '.
+ ' '.&mt('Yes').' '.
+ (' 'x2).
+ ' '.&mt('No').' '.
+ '
'.
+ '
'.
+ '
'.
+ '
'.
+ '
'.
+ '
'.
+ '
'.
+ '
'.
+ '
');
+ } elsif ($storeresult eq 'created') {
+ $r->print('
'.&mt('Make another request').'
');
+ }
+ }
+ } elsif ($state eq 'reqauthor') {
+ my ($result,@links);
+ if ($env{'form.requestauthor'}) {
+ $r->print(&Apache::loncoursequeueadmin::process_reqauthor(\$result));
+ if ($result eq 'created') {
+ my $role = 'au';
+ my $spec = "$role./$env{'form.showdom'}/";
+ push(@links,&mt('Enter your authoring space with role: [_1]',
+ '
'.
+ &Apache::lonnet::plaintext($role).' '));
+ }
+ }
+ if (($env{'form.disposition'} eq 'created') &&
+ ($env{'form.cnum'} =~ /^$match_courseid$/) &&
+ ($env{'form.showdom'} =~ /^$match_domain$/)) {
+ my ($spec,$area,$role,$type);
+ my $role = 'cc';
+ my $spec = "$role./$env{'form.showdom'}/$env{'form.cnum'}";
+ my $type = 'Course';
+ if ($env{'form.crstype'} eq 'community') {
+ $type = 'Community';
}
- $r->print('
'.&mt('Make another request').' ');
- return;
+ my $showrole = &Apache::lonnet::plaintext($role,$type);
+ unshift(@links,&mt('Enter new course with role: [_1]',
+ '
'.$showrole.' '));
+ }
+ if (@links > 1) {
+ $r->print(&mt('New roles will be listed on your [_1]Roles[_2] page.',
+ '
',' ').' '.&mt('Choose a role:').
+ '
');
+ foreach my $link (@links) {
+ $r->print(''.$link.' ');
+ }
+ $r->print(' ');
+ } elsif (@links == 1) {
+ $r->print('
'.$links[0].'
');
}
}
- my @excluded = &get_excluded_elements($dom,$states,$action,$state);
+ my @excluded = &get_excluded_elements($dom,$states,$action,$state,$showcredits);
if ($state eq 'personnel') {
push(@excluded,'persontotal');
}
@@ -1338,25 +1565,28 @@ sub print_request_form {
$count ++;
}
$env{'form.persontotal'} = $count;
-
}
}
if ($state eq 'enrollment') {
- push(@excluded,'crosslisttotal');
+ push(@excluded,('sectotal','crosslisttotal'));
+ }
+ if (($state eq 'process') || ($state eq 'reqauthor')) {
+ $r->print('');
+ } else {
+ $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'');
+ &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
+ $navtxt{'next'},$state);
}
- $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'');
- &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
- $navtxt{'next'},$state);
return;
}
-sub get_cancreate_status {
- my ($persondom,$personname,$dom) = @_;
+sub get_usertype {
+ my ($persondom,$personname,$curr_rules,$got_rules) = @_;
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($persondom,'username');
my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname,
- $rules);
- return &Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype);
+ $rules,$curr_rules,$got_rules);
+ return $usertype;
}
sub check_newuser_rules {
@@ -1364,7 +1594,7 @@ sub check_newuser_rules {
$got_rules) = @_;
my $allowed = 1;
my $newuser = 1;
- my ($checkhash,$userchkmsg);
+ my ($checkhash,$userchkmsg,$authtype,$authparam);
my $checks = { 'username' => 1 };
$checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser };
&Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch,
@@ -1386,22 +1616,38 @@ sub check_newuser_rules {
}
}
}
- return ($allowed,$userchkmsg);
+ if ($allowed) {
+ if (ref($rulematch) eq 'HASH') {
+ if (ref($rulematch->{$personname.':'.$persondom}) eq 'HASH') {
+ my $matchedrule = $rulematch->{$personname.':'.$persondom}{'username'};
+ my ($rules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($persondom,'username');
+ if (ref($rules) eq 'HASH') {
+ if (ref($rules->{$matchedrule}) eq 'HASH') {
+ $authtype = $rules->{$matchedrule}{'authtype'};
+ $authparam = $rules->{$matchedrule}{'authparm'};
+ }
+ }
+ }
+ }
+ }
+ return ($allowed,$userchkmsg,$authtype,$authparam);
}
sub get_excluded_elements {
- my ($dom,$states,$action,$state) = @_;
+ my ($dom,$states,$action,$state,$showcredits) = @_;
my @excluded = ('counter');
- my %elements = &form_elements($dom);
+ my ($elements,$instcredits) = &form_elements($dom,$showcredits);
if (ref($states) eq 'HASH') {
if (ref($states->{$action}) eq 'ARRAY') {
my @items = @{$states->{$action}};
my $numitems = scalar(@items);
if ($numitems) {
for (my $i=$numitems-1; $i>=0; $i--) {
- if (ref($elements{$action}) eq 'HASH') {
- if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
- foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
+ if ((ref($elements) eq 'HASH') &&
+ (ref($elements->{$action}) eq 'HASH')) {
+ if (ref($elements->{$action}{$items[$i]}) eq 'HASH') {
+ foreach my $key (keys(%{$elements->{$action}{$items[$i]}})) {
push(@excluded,$key);
}
}
@@ -1419,8 +1665,9 @@ sub get_excluded_elements {
sub print_enrollment_menu {
my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,
- $invalidcrosslist) =@_;
- my ($sections,$autoenroll,$access_dates,$output,$hasauto);
+ $showcredits,$instcredits,$invalidcrosslist) =@_;
+ my ($sections,$autoenroll,$access_dates,$output,$hasauto,$hascredits,
+ $creditsrow,$domdefcredits);
my $starttime = time;
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
@@ -1432,11 +1679,39 @@ sub print_enrollment_menu {
'start' => 'Start auto-enrollment',
'end' => 'End auto-enrollment',
);
+ if ($showcredits) {
+ unless ($env{'form.crstype'} eq 'community') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+ $domdefcredits = $domdefs{$env{'form.crstype'}.'credits'};
+ }
+ }
if ($env{'form.crstype'} eq 'official') {
if (&Apache::lonnet::auto_run('',$dom)) {
$output = &show_invalid_crosslists($invalidcrosslist);
my ($section_form,$crosslist_form);
- $section_form = &inst_section_selector($dom,$instcode);
+ if ($instcode ne '') {
+ $section_form = &inst_section_selector($dom,$instcode);
+ if ($section_form eq '') {
+ my $sectotal = $env{'form.sectotal'};
+ if (!$sectotal) {
+ $sectotal = 1;
+ }
+ if ($env{'form.addsection'}) {
+ $sectotal ++;
+ }
+ for (my $i=0; $i<$sectotal; $i++) {
+ $section_form .= §ions_form($dom,$instcode,$i);
+ }
+ if ($section_form) {
+ $section_form .=
+ &Apache::lonhtmlcommon::row_title(&mt('Add another')).
+ '
'.
+ '
'.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
+ }
+ }
+ }
if ($section_form) {
$sections = &Apache::lonhtmlcommon::row_headline().
'
'.&Apache::loncommon::help_open_topic('Course_Request_Sections').
@@ -1457,13 +1732,13 @@ sub print_enrollment_menu {
}
if ($crosslist_form) {
$crosslist_form .=
- &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
+ &Apache::lonhtmlcommon::row_title(&mt('Add another')).
' '.
' '.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
$sections .= &Apache::lonhtmlcommon::row_headline.
- ''.&mt('Crosslisted courses for auto-enrollment').' '.
+ ''.&Apache::loncommon::help_open_topic('Course_Request_Crosslist').' '.&mt('Crosslisted courses for auto-enrollment').' '.
&Apache::lonhtmlcommon::row_closure(1).
$crosslist_form;
}
@@ -1484,12 +1759,29 @@ sub print_enrollment_menu {
&mt('No').''.
&Apache::lonhtmlcommon::row_closure(1).
&date_setting_table($starttime,$endtime,$formname,'enroll',
- $hasauto,%enrolltitles);
+ $hasauto,undef,%enrolltitles);
+ if ($showcredits) {
+ if ($instcredits) {
+ $creditsrow = &mt('[quant,_1,credit]',$instcredits);
+ } else {
+ $creditsrow = ''.
+ ' ';
+ }
+ $hascredits = 1;
+ }
+ }
+ } elsif ($env{'form.crstype'} eq 'unofficial') {
+ if ($showcredits) {
+ $creditsrow = ''.
+ ' ';
+ $hascredits = 1;
}
}
my $access_dates =
&date_setting_table($starttime,$endtime,$formname,'access',$hasauto,
- %accesstitles);
+ $hascredits,%accesstitles);
$output .= &Apache::lonhtmlcommon::start_pick_box();
if ($sections) {
$output .= $sections;
@@ -1508,7 +1800,15 @@ sub print_enrollment_menu {
$output .= &Apache::lonhtmlcommon::row_headline('Access').
''.$header.' '.
&Apache::lonhtmlcommon::row_closure(1).
- $access_dates
+ $access_dates;
+ }
+ if ($creditsrow) {
+ $output .= &Apache::lonhtmlcommon::row_headline('Credits').
+ ''.&mt('Credits earned by students').' '.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::row_title(&mt('Default credits')).
+ $creditsrow.
+ &Apache::lonhtmlcommon::row_closure(1);
}
return ''.&Apache::lonhtmlcommon::start_pick_box().$output.
&Apache::lonhtmlcommon::end_pick_box().'
';
@@ -1573,7 +1873,7 @@ sub inst_section_selector {
}
sub date_setting_table {
- my ($starttime,$endtime,$formname,$prefix,$hasauto,%datetitles) = @_;
+ my ($starttime,$endtime,$formname,$prefix,$hasauto,$hascredits,%datetitles)=@_;
my ($perpetual,$table);
my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
$starttime,'','','',1,'','','',1);
@@ -1584,7 +1884,9 @@ sub date_setting_table {
$perpetual = ' '.
' '.
&mt('No end date').' ';
- $closure = '1';
+ unless ($hascredits) {
+ $closure = '1';
+ }
}
my %help_item = (
@@ -1603,10 +1905,10 @@ sub date_setting_table {
}
$table = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'start'}).
- ' '.$datetitles{'start'}).$startform.
+ ' '.&mt($datetitles{'start'})).$startform.
&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'end'}).
- ' '.$datetitles{'end'}).$endform.$perpetual.
+ ' '.&mt($datetitles{'end'})).$endform.$perpetual.
&Apache::lonhtmlcommon::row_closure($closure);
return $table;
}
@@ -1629,12 +1931,12 @@ sub print_personnel_menu {
}
my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom');
- my $roleoptions;
- my @roles = &Apache::lonuserutils::roles_by_context('course');
my $type = 'Course';
if ($crstype eq 'community') {
$type = 'Community';
}
+ my $roleoptions;
+ my @roles = &Apache::lonuserutils::roles_by_context('course','',$type);
foreach my $role (@roles) {
my $plrole = &Apache::lonnet::plaintext($role,$type);
$roleoptions .= ' '.$plrole.' '."\n";
@@ -1722,13 +2024,17 @@ sub print_personnel_menu {
&Apache::loncommon::help_open_topic('Course_Request_Rolesection').' '.&mt('LON-CAPA Section(s)').' '.$sectionselector.''."\n".
''.&Apache::lonhtmlcommon::row_closure();
}
- $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another')).
' '.
' '.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
- &Apache::lonhtmlcommon::end_pick_box().' '.
- ''.&mt('You may also add users later, once the course has been created, by using the "Manage course users" link, accessible from the "Main Menu".').'
';
+ &Apache::lonhtmlcommon::end_pick_box().'';
+ if ($crstype eq 'community') {
+ $output .= ''.&mt('You may also add users later, once the community has been created, by using the "Manage community users" link, accessible from the "Main Menu".').'
';
+ } else {
+ $output .= ''.&mt('You may also add users later, once the course has been created, by using the "Manage course users" link, accessible from the "Main Menu".').'
';
+ }
return $output;
}
@@ -1749,61 +2055,111 @@ sub current_lc_sections {
return @currsecs;
}
-sub print_request_status {
- my ($dom) = @_;
+sub sorted_request_history {
+ my ($dom,$action,$curr_req) = @_;
+ my ($after,$before,$statusfilter,$crstypefilter);
+ if ($env{'form.status'} ne '') {
+ $statusfilter = $env{'form.status'};
+ }
+ if ($env{'form.crstype'} ne '') {
+ $crstypefilter = $env{'form.crstype'};
+ }
+ if (ref($curr_req) eq 'HASH') {
+ $after = $curr_req->{'requested_after_date'},
+ $before = $curr_req->{'requested_before_date'};
+ $statusfilter = $curr_req->{'status'};
+ $crstypefilter = $curr_req->{'crstype'};
+ }
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
$env{'user.name'},'^status:'.$dom);
- my ($output,$formname,%queue_by_date);
+ my %queue_by_date;
my ($types,$typenames) = &Apache::loncommon::course_types();
foreach my $key (keys(%statusinfo)) {
- if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) {
- (undef,my($cdom,$cnum)) = split(':',$key);
- next if ($cdom ne $dom);
- my $requestkey = $cdom.'_'.$cnum;
- if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
- my %history = &Apache::lonnet::restore($requestkey,'courserequests',
- $env{'user.domain'},$env{'user.name'});
- my $entry;
- my $timestamp = $history{'reqtime'};
- my $crstype = $history{'crstype'};
- my $disposition = $history{'disposition'};
+ if ($action eq 'view') {
+ next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending'));
+ } else {
+ next unless (($statusfilter eq 'any') ||
+ ($statusfilter eq $statusinfo{$key}));
+ }
+ (undef,my($cdom,$cnum)) = split(':',$key);
+ next if ($cdom ne $dom);
+ my $requestkey = $cdom.'_'.$cnum;
+ if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
+ my %history = &Apache::lonnet::restore($requestkey,'courserequests',
+ $env{'user.domain'},$env{'user.name'});
+ my $entry;
+ my $reqtime = $history{'reqtime'};
+ my $lastupdate = $history{'timestamp'};
+ my $crstype = $history{'crstype'};
+ my $disposition = $history{'disposition'};
+ my $status = $history{'status'};
+ if ($action eq 'view') {
next if ((exists($history{'status'})) && ($history{'status'} eq 'created'));
- next unless (($env{'form.crstype'} eq 'any') ||
- ($env{'form.crstype'} eq $crstype));
+ } else {
+ next if (($reqtime < $after) || ($reqtime > $before));
+ }
+ next unless (($crstypefilter eq 'any') ||
+ ($crstypefilter eq $crstype));
+ if ($action eq 'view') {
next unless (($disposition eq 'approval') ||
($disposition eq 'pending'));
- if (ref($history{'details'}) eq 'HASH') {
- $entry = $requestkey.':'.$crstype.':'.
- &escape($history{'details'}{'cdescr'});
- if ($crstype eq 'official') {
- $entry .= ':'.&escape($history{'details'}{'instcode'});
+ }
+ if (ref($history{'details'}) eq 'HASH') {
+ $entry = $requestkey.':'.$crstype.':'.
+ &escape($history{'details'}{'cdescr'});
+ if ($action eq 'log') {
+ $entry .= ':'.$lastupdate.':';
+ if ($statusinfo{$key} ne '') {
+ $entry .= $statusinfo{$key};
+ } elsif ($status ne '') {
+ $entry .= $status;
+ } else {
+ $entry .= $disposition;
}
}
- if ($entry ne '') {
- if (exists($queue_by_date{$timestamp})) {
- if (ref($queue_by_date{$timestamp}) eq 'ARRAY') {
- push(@{$queue_by_date{$timestamp}},$entry);
- }
- } else {
- @{$queue_by_date{$timestamp}} = ($entry);
+ if ($crstype eq 'official') {
+ $entry .= ':'.&escape($history{'details'}{'instcode'});
+ }
+ }
+ if ($entry ne '') {
+ if (exists($queue_by_date{$reqtime})) {
+ if (ref($queue_by_date{$reqtime}) eq 'ARRAY') {
+ push(@{$queue_by_date{$reqtime}},$entry);
}
+ } else {
+ @{$queue_by_date{$reqtime}} = ($entry);
}
}
}
}
- $formname = 'requestcrs';
+ return %queue_by_date;
+}
+
+sub print_request_status {
+ my ($dom,$action) = @_;
+ my %queue_by_date = &sorted_request_history($dom,$action);
my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));
- $output = ''.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
+ if ($env{'form.crstype'} eq 'any') {
+$output .= ''.&mt('You have no matching course or community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
+ } elsif ($env{'form.crstype'} eq 'community') {
+ $output .= ''.&mt('You have no matching community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
+ } else {
+ $output .= ''.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
+ }
}
$output .= '
'.
- &mt('Cancelling the request will remove it from the queue of pending course requests').'
';
+ '';
+ if ($crstype eq 'community') {
+ $output .= &mt('Cancelling the request will remove it from the queue of pending community requests').'
';
+ } else {
+ $output .= &mt('Cancelling the request will remove it from the queue of pending course requests').'';
+ }
$result = 'ok';
} else {
$output = '