version 1.35, 2009/09/11 12:53:10
|
version 1.36.2.2, 2009/10/02 16:15:49
|
Line 178 sub handler {
|
Line 178 sub handler {
|
$trail{'enrollment'} = 'Enrollment'; |
$trail{'enrollment'} = 'Enrollment'; |
} |
} |
|
|
my ($page,$crumb,$newinstcode,$codechk,$checkedcode) = |
my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) = |
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail); |
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail); |
if ($action eq 'display') { |
if ($action eq 'display') { |
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { |
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) { |
Line 238 sub handler {
|
Line 238 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} = |
($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 286 sub handler {
|
Line 286 sub handler {
|
} else { |
} else { |
&request_administration($r,$action,$state,$page,\%states,$dom, |
&request_administration($r,$action,$state,$page,\%states,$dom, |
$jscript,$loaditems,$crumb,$newinstcode, |
$jscript,$loaditems,$crumb,$newinstcode, |
$codechk,$checkedcode,\@invalidcrosslist); |
$codechk,$checkedcode,$description, |
|
\@invalidcrosslist); |
} |
} |
} else { |
} else { |
$r->print(&header('Course Requests').$crumb. |
$r->print(&header('Course Requests').$crumb. |
Line 310 sub handler {
|
Line 311 sub handler {
|
&close_popup_form()); |
&close_popup_form()); |
} else { |
} else { |
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript, |
$loaditems,$crumb,'','','','',$uname,$udom); |
$loaditems,$crumb,'','','','','',$uname,$udom); |
} |
} |
} elsif ($action eq 'log') { |
} elsif ($action eq 'log') { |
&print_request_logs($jscript,$loaditems,$crumb); |
&print_request_logs($jscript,$loaditems,$crumb); |
Line 346 END
|
Line 347 END
|
|
|
sub get_breadcrumbs { |
sub get_breadcrumbs { |
my ($dom,$action,$state,$states,$trail) = @_; |
my ($dom,$action,$state,$states,$trail) = @_; |
my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles); |
my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description); |
my $page = 0; |
my $page = 0; |
if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) { |
if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) { |
if (defined($action)) { |
if (defined($action)) { |
Line 371 sub get_breadcrumbs {
|
Line 372 sub get_breadcrumbs {
|
$$state = 'codepick'; |
$$state = 'codepick'; |
$page --; |
$page --; |
} else { |
} else { |
$codechk = |
($codechk,$description) = |
&Apache::lonnet::auto_validate_instcode('', |
&Apache::lonnet::auto_validate_instcode('', |
$dom,$newinstcode); |
$dom,$newinstcode); |
if ($codechk ne 'valid') { |
if ($codechk ne 'valid') { |
Line 416 sub get_breadcrumbs {
|
Line 417 sub get_breadcrumbs {
|
{text=>'Pick Action'}); |
{text=>'Pick Action'}); |
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); |
} |
} |
return ($page,$crumb,$newinstcode,$codechk,$checkedcode); |
return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description); |
} |
} |
|
|
sub header { |
sub header { |
Line 626 sub check_can_request {
|
Line 627 sub check_can_request {
|
} |
} |
|
|
sub course_types { |
sub course_types { |
my @types = ('official','unofficial','community'); |
my @types = ('unofficial'); |
my %typename = ( |
my %typename = ( |
official => 'Official course', |
official => 'Official course', |
unofficial => 'Unofficial course', |
unofficial => 'Unofficial course', |
Line 657 sub print_main_menu {
|
Line 658 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 723 END
|
Line 747 END
|
} |
} |
|
|
END |
END |
|
$r->print(&header('Concept Test Courses',$js.$jscript,$loaditems).$crumb); |
$r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb. |
my $existing = &existing_courses(); |
'<p>'.&mt('Request creation of a new course, or review your pending course requests.').'</p>'. |
if ($existing) { |
'<div>'. |
$r->print('<div class="LC_left_float">'. |
|
'<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">'); |
&Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange)); |
$r->print('GCI Web Center Concept Test Delivery (gcitest)'."\n". |
if (!$onchange) { |
'<input type="hidden" value="gcitest" name="showdom" />'); |
$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 744 END
|
Line 770 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')). |
<form name="mainmenu_coursetype" method="post" action=""> |
&mt($typename->{'unofficial'})."\n". |
<select size="1" name="crstype"> |
'<form name="mainmenu_coursetype" method="post" action="">'."\n". |
<option value="any">'.&mt('All types').'</option>'); |
'<input type="hidden" name="crstype" value="unofficial" ></form>'."\n". |
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().'</div>'."\n". |
&Apache::lonhtmlcommon::end_pick_box().'</p>'."\n". |
'<div><form name="'.$formname.'" method="post" action="">'."\n". |
'<p><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></div>'); |
'</form></p>'); |
|
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,$invalidcrosslist,$uname,$udom) = @_; |
$newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist, |
|
$uname,$udom) = @_; |
my $js; |
my $js; |
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) { |
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) { |
$js = <<END; |
$js = <<END; |
Line 814 END
|
Line 1016 END
|
} |
} |
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb); |
$r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb); |
&print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode, |
&print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode, |
$codechk,$checkedcode,$invalidcrosslist); |
$codechk,$checkedcode,$description,$invalidcrosslist); |
} elsif ($action eq 'view') { |
} elsif ($action eq 'view') { |
my $jsextra; |
my $jsextra; |
my $formname = 'requestcrs'; |
my $formname = 'requestcrs'; |
Line 1126 sub get_instcode {
|
Line 1328 sub get_instcode {
|
|
|
sub print_request_form { |
sub print_request_form { |
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode, |
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode, |
$invalidcrosslist) = @_; |
$description,$invalidcrosslist) = @_; |
my $formname = 'requestcrs'; |
my $formname = 'requestcrs'; |
my ($next,$prev,$message,$output,$codepicker,$crstype); |
my ($next,$prev,$message,$output,$codepicker,$crstype); |
$prev = $states->{$action}[$page-1]; |
$prev = $states->{$action}[$page-1]; |
Line 1191 sub print_request_form {
|
Line 1393 sub print_request_form {
|
if ($instcode eq '') { |
if ($instcode eq '') { |
$prev = $states->{$action}[$page-2]; |
$prev = $states->{$action}[$page-2]; |
} |
} |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next)); |
$r->print(&courseinfo_form($dom,$formname,$crstype,$next,$description)); |
} elsif ($state eq 'enrollment') { |
} elsif ($state eq 'enrollment') { |
if ($crstype eq 'official') { |
if ($crstype eq 'official') { |
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles, |
Line 2238 sub dates_from_form {
|
Line 2440 sub dates_from_form {
|
} |
} |
|
|
sub courseinfo_form { |
sub courseinfo_form { |
my ($dom,$formname,$crstype,$next) = @_; |
my ($dom,$formname,$crstype,$next,$description) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
official => 'You must provide a (brief) course description.', |
official => 'You must provide a (brief) course description.', |
community => 'You must provide a (brief) community description.' |
community => 'You must provide a (brief) community description.' |
Line 2268 ENDJS
|
Line 2470 ENDJS
|
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').' '.$title.'</h3>'. |
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').' '.$title.'</h3>'. |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_closure(1). |
&Apache::lonhtmlcommon::row_title(&mt('Description')). |
&Apache::lonhtmlcommon::row_title(&mt('Description')). |
'<input type="text" size="40" name="cdescr" />'; |
'<input type="text" size="60" name="cdescr" value="'.$description.'" />'; |
my ($home_server_pick,$numlib) = |
my ($home_server_pick,$numlib) = |
&Apache::loncommon::home_server_form_item($dom,'chome', |
&Apache::loncommon::home_server_form_item($dom,'chome', |
'default','hide'); |
'default','hide'); |