version 1.36.2.2, 2009/10/02 16:15:49
|
version 1.37, 2009/10/24 03:24:13
|
Line 52 described at http://www.lon-capa.org.
|
Line 52 described at http://www.lon-capa.org.
|
|
|
=item onload_action() |
=item onload_action() |
|
|
=item check_can_request() |
|
|
|
=item course_types() |
|
|
|
=item print_main_menu() |
=item print_main_menu() |
|
|
=item request_administration() |
=item request_administration() |
Line 238 sub handler {
|
Line 234 sub handler {
|
foreach my $item (@code_order) { |
foreach my $item (@code_order) { |
$crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item}; |
$crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item}; |
} |
} |
if ($crosslistcode ne '') { |
if ($crosslistcode ne '') { |
($codechk{$i}, my $rest) = |
($codechk{$i}, my $rest) = |
&Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode); |
&Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode); |
} |
} |
unless ($codechk{$i} eq 'valid') { |
unless ($codechk{$i} eq 'valid') { |
Line 277 sub handler {
|
Line 273 sub handler {
|
my $loaditems = &onload_action($action,$state); |
my $loaditems = &onload_action($action,$state); |
|
|
my %can_request; |
my %can_request; |
my $canreq = &check_can_request($dom,\%can_request); |
my $canreq = &Apache::lonnet::check_can_request($dom,\%can_request); |
if ($action eq 'new') { |
if ($action eq 'new') { |
if ($canreq) { |
if ($canreq) { |
if ($state eq 'crstype') { |
if ($state eq 'crstype') { |
Line 594 sub onload_action {
|
Line 590 sub onload_action {
|
return \%loaditems; |
return \%loaditems; |
} |
} |
|
|
sub check_can_request { |
|
my ($dom,$can_request) = @_; |
|
my $canreq = 0; |
|
my ($types,$typename) = &course_types(); |
|
my @options = ('approval','validate','autolimit'); |
|
my $optregex = join('|',@options); |
|
if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) { |
|
foreach my $type (@{$types}) { |
|
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
|
$env{'user.domain'}, |
|
$type,undef,'requestcourses')) { |
|
$canreq ++; |
|
if ($dom eq $env{'user.domain'}) { |
|
$can_request->{$type} = 1; |
|
} |
|
} |
|
if ($env{'environment.reqcrsotherdom.'.$type} ne '') { |
|
my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type}); |
|
if (@curr > 0) { |
|
$canreq ++; |
|
unless ($dom eq $env{'user.domain'}) { |
|
if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) { |
|
$can_request->{$type} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
return $canreq; |
|
} |
|
|
|
sub course_types { |
|
my @types = ('unofficial'); |
|
my %typename = ( |
|
official => 'Official course', |
|
unofficial => 'Unofficial course', |
|
community => 'Community', |
|
); |
|
return (\@types,\%typename); |
|
} |
|
|
|
|
|
sub print_main_menu { |
sub print_main_menu { |
my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_; |
my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_; |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
my $onchange; |
my $onchange; |
unless ($env{'form.interface'} eq 'textual') { |
unless ($env{'form.interface'} eq 'textual') { |
$onchange = 1; |
$onchange = 1; |
Line 658 sub print_main_menu {
|
Line 611 sub print_main_menu {
|
} |
} |
} |
} |
|
|
my $standby=&mt('Course selected. Please stand by.'); |
|
my $js = <<"END"; |
my $js = <<"END"; |
|
|
function enterrole (thisform,rolecode,buttonname) { |
|
document.title='$standby'; |
|
window.status='$standby'; |
|
thisform.newrole.value=rolecode; |
|
thisform.selectrole.value='1'; |
|
thisform.submit(); |
|
} |
|
|
|
function ToSyllabus(cdom,cnum) { |
|
if (cdom == '' || cdom == null) { |
|
return; |
|
} |
|
if (cnum == '' || cnum == null) { |
|
return; |
|
} |
|
var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'; |
|
var url = "/public/"+cdom+"/"+cnum+"/syllabus"; |
|
syllwin = window.open(url,'',options,1); |
|
syllwin.focus(); |
|
return; |
|
} |
|
|
|
function nextPage(formname) { |
function nextPage(formname) { |
var crschoice = document.mainmenu_coursetype.crstype.value; |
var crschoice = document.mainmenu_coursetype.crstype.value; |
var actionchoice = document.mainmenu_action.action.value; |
var actionchoice = document.mainmenu_action.action.value; |
Line 747 END
|
Line 677 END
|
} |
} |
|
|
END |
END |
$r->print(&header('Concept Test Courses',$js.$jscript,$loaditems).$crumb); |
|
my $existing = &existing_courses(); |
$r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb. |
if ($existing) { |
'<p>'.&mt('Request creation of a new course, or review your pending course requests.').'</p>'. |
$r->print('<div class="LC_left_float">'. |
'<div>'. |
'<h3>'.&mt('Request creation of a new course').'</h3>'); |
|
} else { |
|
$r->print('<div><h3>'.&mt('Request creation of a new course, or review your pending course requests.').'</h3>'); |
|
} |
|
$r->print('<p>'. |
|
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::start_pick_box(). |
&Apache::lonhtmlcommon::row_title(&mt('Course Domain')). |
&Apache::lonhtmlcommon::row_title(&mt('Course Domain')). |
'<form name="domforcourse" method="post" action="/adm/requestcourse">'); |
'<form name="domforcourse" method="post" action="/adm/requestcourse">'. |
$r->print('GCI Web Center Concept Test Delivery (gcitest)'."\n". |
&Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange)); |
'<input type="hidden" value="gcitest" name="showdom" />'); |
if (!$onchange) { |
|
$r->print(' <input type="submit" name="godom" value="'. |
|
&mt('Change').'" />'); |
|
} |
$r->print('</form>'.&Apache::lonhtmlcommon::row_closure()); |
$r->print('</form>'.&Apache::lonhtmlcommon::row_closure()); |
|
|
my $formname = 'requestcrs'; |
my $formname = 'requestcrs'; |
Line 770 END
|
Line 698 END
|
<select size="1" name="action" > |
<select size="1" name="action" > |
<option value="new">'.&mt('New request').'</option> |
<option value="new">'.&mt('New request').'</option> |
<option value="view">'.&mt('View/Modify/Cancel pending requests').'</option> |
<option value="view">'.&mt('View/Modify/Cancel pending requests').'</option> |
|
<option value="log">'.&mt('View request history').'</option> |
</select></form>'. |
</select></form>'. |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(&mt('Course Type')). |
&Apache::lonhtmlcommon::row_title(&mt('Course Type')).' |
&mt($typename->{'unofficial'})."\n". |
<form name="mainmenu_coursetype" method="post" action=""> |
'<form name="mainmenu_coursetype" method="post" action="">'."\n". |
<select size="1" name="crstype"> |
'<input type="hidden" name="crstype" value="unofficial" ></form>'."\n". |
<option value="any">'.&mt('All types').'</option>'); |
|
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { |
|
foreach my $type (@{$types}) { |
|
my $selected = ''; |
|
if ($type eq 'official') { |
|
$selected = ' selected="selected"'; |
|
} |
|
$r->print('<option value="'.$type.'"'.$selected.'>'.&mt($typename->{$type}). |
|
'</option>'."\n"); |
|
} |
|
} |
|
$r->print('</select></form>'."\n". |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::row_closure(1)."\n". |
&Apache::lonhtmlcommon::end_pick_box().'</p>'."\n". |
&Apache::lonhtmlcommon::end_pick_box().'</div>'."\n". |
'<p><form name="'.$formname.'" method="post" action="">'."\n". |
'<div><form name="'.$formname.'" method="post" action="">'."\n". |
'<input type="hidden" name="state" value="crstype" />'."\n". |
'<input type="hidden" name="state" value="crstype" />'."\n". |
'<input type="hidden" name="showdom" value="'.$dom.'" />'."\n". |
'<input type="hidden" name="showdom" value="'.$dom.'" />'."\n". |
'<input type="hidden" name="crstype" value="" />'."\n". |
'<input type="hidden" name="crstype" value="" />'."\n". |
'<input type="hidden" name="action" value="" />'."\n". |
'<input type="hidden" name="action" value="" />'."\n". |
'<input type="button" name="next" value="'.$nexttext. |
'<input type="button" name="next" value="'.$nexttext. |
'" onclick="javascript:nextPage(document.'.$formname.')" />'."\n". |
'" onclick="javascript:nextPage(document.'.$formname.')" />'."\n". |
'</form></p>'); |
'</form></div>'); |
if ($existing) { |
|
$r->print('</div><div class="LC_left_float"><h3>'.&mt('Enter an existing Concept Test course').'</h3>'.$existing.'</div><div class="LC_clear_float_footer"></div>'); |
|
} else { |
|
$r->print('</div>'); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return; |
return; |
} |
} |
|
|
sub existing_courses { |
|
my $output; |
|
my %roleshash = &Apache::lonnet::get_my_roles(undef,undef,'userroles',undef, |
|
['cc'],['gcitest']); |
|
my %courses; |
|
if (keys(%roleshash) > 0) { |
|
foreach my $key (keys(%roleshash)) { |
|
my ($cnum,$cdom,$role) = split(':',$key); |
|
my ($tstart,$tend) = split(':',$roleshash{$key}); |
|
my %coursehash = &Apache::lonnet::coursedescription($cdom.'/'.$cnum); |
|
$courses{$cdom.'_'.$cnum}{'description'} = $coursehash{'description'}; |
|
$courses{$cdom.'_'.$cnum}{'owner'} = $coursehash{'internal.courseowner'}; |
|
if (defined($coursehash{'default_enrollment_start_date'}) ) { |
|
$courses{$cdom.'_'.$cnum}{'startaccess'} = |
|
&Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_start_date'}); |
|
} |
|
if (defined($coursehash{'default_enrollment_end_date'}) ) { |
|
$courses{$cdom.'_'.$cnum}{'endaccess'} = |
|
&Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_end_date'}); |
|
if ($coursehash{'default_enrollment_end_date'} == 0) { |
|
$courses{$cdom.'_'.$cnum}{'endaccess'} = &mt('No ending date'); |
|
} |
|
} |
|
} |
|
$output = '<form name="pickrole" action="/adm/roles" method="post">'. |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(); |
|
my @coltitles = ('Select','Title','Owner(s)', |
|
'Default Access Dates for Students','Student Counts'); |
|
foreach my $item (@coltitles) { |
|
$output .= '<th>'; |
|
if ($item eq 'Select') { |
|
$output .= ' '; |
|
} else { |
|
$output .= &mt($item); |
|
} |
|
$output .= '</th>'; |
|
} |
|
$output .= &Apache::loncommon::end_data_table_header_row(); |
|
my %courseinfo = &build_courseinfo_hash(\%courses); |
|
my %Sortby; |
|
foreach my $course (sort(keys(%courses))) { |
|
my $clean_title = $courseinfo{$course}{'title'}; |
|
$clean_title =~ s/\W+//g; |
|
if ($clean_title eq '') { |
|
$clean_title = $courseinfo{$course}{'title'}; |
|
} |
|
push(@{$Sortby{$clean_title}},$course); |
|
} |
|
my @sorted_courses; |
|
my @sorted_courses = sort { lc($a) cmp lc($b) } (keys(%Sortby)); |
|
foreach my $item (@sorted_courses) { |
|
foreach my $course (@{$Sortby{$item}}) { |
|
my ($cdom,$cnum) = split('_',$course); |
|
$output.= &Apache::loncommon::start_data_table_row(). |
|
&courseinfo_row($courseinfo{$course},$cnum,$cdom). |
|
&Apache::loncommon::end_data_table_row(); |
|
} |
|
} |
|
$output .= &Apache::loncommon::end_data_table(). |
|
'<input type="hidden" name="newrole" value="" />'. |
|
'<input type="hidden" name="selectrole" value="" /></form>'; |
|
} |
|
return $output; |
|
} |
|
|
|
sub build_courseinfo_hash { |
|
my ($courses) = @_; |
|
my %courseinfo; |
|
foreach my $course (keys(%{$courses})) { |
|
my ($cdom,$cnum) = split('_',$course); |
|
my $descr; |
|
if (ref($courses->{$course}) eq 'HASH') { |
|
$descr = $courses->{$course}{'description'}; |
|
} |
|
my $cleandesc=&HTML::Entities::encode($descr,'<>&"'); |
|
$cleandesc=~s/'/\\'/g; |
|
$cleandesc =~ s/^\s+//; |
|
my ($cdom,$cnum)=split(/\_/,$course); |
|
my ($singleowner,@owners,%ownernames); |
|
if (ref($courses->{$course}) eq 'HASH') { |
|
$singleowner = $courses->{$course}{'owner'}; |
|
push(@owners,$singleowner); |
|
if (ref($courses->{$course}{'co-owners'}) eq 'ARRAY') { |
|
foreach my $item (@{$courses->{$course}{'co-owners'}}) { |
|
push(@owners,$item); |
|
} |
|
} |
|
} |
|
foreach my $owner (@owners) { |
|
my ($ownername,$ownerdom); |
|
if ($owner =~ /:/) { |
|
($ownername,$ownerdom) = split(/:/,$owner); |
|
} else { |
|
$ownername = $owner; |
|
if ($owner ne '') { |
|
$ownerdom = $cdom; |
|
} |
|
} |
|
if ($ownername ne '' && $ownerdom ne '') { |
|
my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom); |
|
$ownernames{$ownername.':'.$ownerdom} = \%namehash; |
|
} |
|
} |
|
$courseinfo{$course}{'cdom'} = $cdom; |
|
$courseinfo{$course}{'cnum'} = $cnum; |
|
my @lastnames; |
|
foreach my $owner (keys(%ownernames)) { |
|
if (ref($ownernames{$owner}) eq 'HASH') { |
|
push(@lastnames,$ownernames{$owner}{'lastname'}); |
|
} |
|
} |
|
$courseinfo{$course}{'ownerlastnames'} = join(', ',sort(@lastnames)); |
|
$courseinfo{$course}{'title'} = $cleandesc; |
|
$courseinfo{$course}{'owner'} = $singleowner; |
|
my @classids; |
|
$courseinfo{$course}{'counts'} = &count_students($cdom,$cnum,0); |
|
my $startaccess = $courses->{$course}{'startaccess'}; |
|
my $endaccess = $courses->{$course}{'endaccess'}; |
|
my $accessdates; |
|
if ($startaccess) { |
|
$accessdates .= '<i>'.&mt('From:[_1]','</i> '.$startaccess).'<br />'; |
|
} |
|
if ($endaccess) { |
|
$accessdates .= '<i>'.&mt('To:[_1]','</i> '.$endaccess).'<br />'; |
|
} |
|
$courseinfo{$course}{'access'} = $accessdates; |
|
} |
|
return %courseinfo; |
|
} |
|
|
|
sub courseinfo_row { |
|
my ($info,$cnum,$cdom) = @_; |
|
my $output; |
|
if (ref($info) eq 'HASH') { |
|
my $rolecode = 'cc./'.$cdom.'/'.$cnum; |
|
my $buttonname = $rolecode; |
|
$buttonname=~s/\W//g; |
|
$output .= '<td><input type="button" name="'.$buttonname.'" value="'.&mt('Select').'" onclick="javascript:enterrole(this.form,'."'$rolecode','$buttonname'".')" ></td>'. |
|
'<td>'.$info->{'title'}.' <font size="-2">'. |
|
'<a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'. |
|
&mt('Syllabus').'</a></font></td>'. |
|
'<td>'.$info->{'ownerlastnames'}.'</td>'. |
|
'<td>'.$info->{'access'}.'</td>'. |
|
'<td>'.$info->{'counts'}.'</td>'; |
|
} else { |
|
$output = '<td colspan="4">'.&mt('No information available for [_1].', |
|
$cdom.'_'.$cnum).'</td>'; |
|
return $output; |
|
} |
|
return $output; |
|
} |
|
|
|
sub count_students { |
|
my ($cdom,$cnum,$numsec) = @_; |
|
my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum); |
|
my %student_count = ( |
|
Active => 0, |
|
Future => 0, |
|
Expired => 0, |
|
); |
|
my %idx; |
|
$idx{'status'} = &Apache::loncoursedata::CL_STATUS(); |
|
my %status_title = &Apache::lonlocal::texthash( |
|
Expired => 'Previous access', |
|
Active => 'Current access', |
|
Future => 'Future access', |
|
); |
|
|
|
while (my ($student,$data) = each(%$classlist)) { |
|
$student_count{$data->[$idx{'status'}]} ++; |
|
} |
|
|
|
my $countslist = &mt('[quant,_1,section:,sections:,No sections]',$numsec).'<br />'; |
|
foreach my $status ('Active','Future') { |
|
$countslist .= '<span class="LC_nobreak">'.$status_title{$status}.': '. |
|
$student_count{$status}.'</span><br />'; |
|
} |
|
return $countslist; |
|
} |
|
|
|
|
|
sub request_administration { |
sub request_administration { |
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb, |
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb, |
$newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist, |
$newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist, |
Line 1951 sub print_request_status {
|
Line 1704 sub print_request_status {
|
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, |
my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, |
$env{'user.name'},'^status:'.$dom); |
$env{'user.name'},'^status:'.$dom); |
my ($output,$formname,%queue_by_date); |
my ($output,$formname,%queue_by_date); |
my ($types,$typenames) = &course_types(); |
my ($types,$typenames) = &Apache::loncommon::course_types(); |
foreach my $key (keys(%statusinfo)) { |
foreach my $key (keys(%statusinfo)) { |
if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) { |
if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) { |
(undef,my($cdom,$cnum)) = split(':',$key); |
(undef,my($cdom,$cnum)) = split(':',$key); |
Line 2073 sub print_cancel_request {
|
Line 1826 sub print_cancel_request {
|
} |
} |
$output = &mt('No further action will be taken'); |
$output = &mt('No further action will be taken'); |
} elsif (ref($history{'details'}) eq 'HASH') { |
} elsif (ref($history{'details'}) eq 'HASH') { |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
my $showtype = $crstype; |
my $showtype = $crstype; |
if (defined($typename->{$crstype})) { |
if (defined($typename->{$crstype})) { |
$showtype = $typename->{$crstype}; |
$showtype = $typename->{$crstype}; |
Line 2159 sub print_request_logs {
|
Line 1912 sub print_request_logs {
|
sub print_review { |
sub print_review { |
my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom, |
my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom, |
$disallowed,$disallowmsg) = @_; |
$disallowed,$disallowmsg) = @_; |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
my ($owner,$ownername,$owneremail); |
my ($owner,$ownername,$owneremail); |
if ($uname eq '' || $udom eq '') { |
if ($uname eq '' || $udom eq '') { |
$uname = $env{'user.name'}; |
$uname = $env{'user.name'}; |
Line 2625 sub get_course_dom {
|
Line 2378 sub get_course_dom {
|
} |
} |
} |
} |
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) { |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
if (ref($types) eq 'ARRAY') { |
if (ref($types) eq 'ARRAY') { |
foreach my $type (@{$types}) { |
foreach my $type (@{$types}) { |
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
Line 3290 sub check_autolimit {
|
Line 3043 sub check_autolimit {
|
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_; |
my ($uname,$udom,$dom,$crstype,$limit,$message) = @_; |
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'}, |
my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'}, |
'userroles',['active','future'],['cc'],[$dom]); |
'userroles',['active','future'],['cc'],[$dom]); |
my ($types,$typename) = &course_types(); |
my ($types,$typename) = &Apache::loncommon::course_types(); |
my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname); |
my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname); |
my %count; |
my %count; |
if (ref($types) eq 'ARRAY') { |
if (ref($types) eq 'ARRAY') { |