version 1.15, 2005/09/13 07:31:08
|
version 1.27, 2005/10/27 15:11:03
|
Line 58 sub start_page {
|
Line 58 sub start_page {
|
$r->print($html.'<head><title>'. |
$r->print($html.'<head><title>'. |
&mt('Request another Worktime').'</title></head>'); |
&mt('Request another Worktime').'</title></head>'); |
$r->print(&Apache::loncommon::bodytag('Requesting another Worktime')); |
$r->print(&Apache::loncommon::bodytag('Requesting another Worktime')); |
$r->print('<p>'.$env{'form.command'}.'</p>'); |
|
} |
} |
|
|
sub end_page { |
sub end_page { |
Line 453 STUFF
|
Line 452 STUFF
|
} |
} |
|
|
sub show_table { |
sub show_table { |
my ($r,$symb,$mgr)=@_; |
my ($r,$mgr)=@_; |
|
|
my ($cnum,$cdom)=&get_course(); |
my ($cnum,$cdom)=&get_course(); |
my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); |
my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum); |
|
if ( (keys(%slots))[0] =~ /^error: 2 /) { |
|
undef(%slots); |
|
} |
my $available; |
my $available; |
if ($mgr eq 'F') { |
if ($mgr eq 'F') { |
$r->print('<form method="POST" action="/adm/slotrequest"> |
$r->print('<form method="POST" action="/adm/slotrequest"> |
<input type="hidden" name="command" value="uploadstart" /> |
<input type="hidden" name="command" value="uploadstart" /> |
<input type="hidden" name="symb" value="'.$env{'form.symb'}.'" /> |
|
<input type="submit" name="start" value="'.&mt('Upload Slot List').'" /> |
<input type="submit" name="start" value="'.&mt('Upload Slot List').'" /> |
</form>'); |
</form>'); |
} |
} |
|
my $linkstart='<a href="/adm/slotrequest?command=showslots&order='; |
$r->print('<table border="1"> |
$r->print('<table border="1"> |
<tr> |
<tr> |
<th>Slot name</th> |
<th></th> |
<th>Type</th> |
<th>'.$linkstart.'name" >Slot name</a></th> |
<th>Description</th> |
<th>'.$linkstart.'type" >Type</a></th> |
<th>Start Time</th> |
<th>'.$linkstart.'description" >Description</a></th> |
<th>End Time</th> |
<th>'.$linkstart.'starttime" >Start Time</a></th> |
<th>Max space</th> |
<th>'.$linkstart.'endtime" >End Time</a></th> |
<th>Scheduled Students</th> |
<th>'.$linkstart.'startreserve">Time Students Can Start Reserving</a></th> |
<th>Proctors</th> |
<th>'.$linkstart.'secret" >Secret</a></th> |
<th>Unique Period</th> |
<th>'.$linkstart.'maxspace" >Max space</a></th> |
|
<th> Scheduled Students</th> |
|
<th>'.$linkstart.'unique" >Unique Period</a></th> |
</tr>'); |
</tr>'); |
foreach my $slot (sort |
my %name_cache; |
{ return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'} } |
my $slotsort = sub { |
(keys(%slots))) { |
if ($env{'form.order'}=~/^(type|description|endtime|maxspace)$/) { |
|
if (lc($slots{$a}->{$env{'form.order'}}) |
|
ne lc($slots{$b}->{$env{'form.order'}})) { |
|
return (lc($slots{$a}->{$env{'form.order'}}) |
|
cmp lc($slots{$b}->{$env{'form.order'}})); |
|
} |
|
} elsif ($env{'form.order'} eq 'name') { |
|
if (lc($a) cmp lc($b)) { |
|
return lc($a) cmp lc($b); |
|
} |
|
} elsif ($env{'form.order'} eq 'unique') { |
|
|
|
if ($slots{$a}->{'uniqueperiod'}[0] |
|
ne $slots{$b}->{'uniqueperiod'}[0]) { |
|
return ($slots{$a}->{'uniqueperiod'}[0] |
|
cmp $slots{$b}->{'uniqueperiod'}[0]); |
|
} |
|
if ($slots{$a}->{'uniqueperiod'}[1] |
|
ne $slots{$b}->{'uniqueperiod'}[1]) { |
|
return ($slots{$a}->{'uniqueperiod'}[1] |
|
cmp $slots{$b}->{'uniqueperiod'}[1]); |
|
} |
|
} |
|
return $slots{$a}->{'starttime'} <=> $slots{$b}->{'starttime'}; |
|
}; |
|
foreach my $slot (sort $slotsort (keys(%slots))) { |
if (defined($slots{$slot}->{'type'}) |
if (defined($slots{$slot}->{'type'}) |
&& $slots{$slot}->{'type'} ne 'schedulable_student') { |
&& $slots{$slot}->{'type'} ne 'schedulable_student') { |
#next; |
#next; |
Line 492 sub show_table {
|
Line 521 sub show_table {
|
my (undef,$id)=split("\0",$entry); |
my (undef,$id)=split("\0",$entry); |
$ids.= $id.'-> '.$consumed{$entry}->{'name'}.'<br />'; |
$ids.= $id.'-> '.$consumed{$entry}->{'name'}.'<br />'; |
} |
} |
my $start=localtime($slots{$slot}->{'starttime'}); |
my $start=($slots{$slot}->{'starttime'}? |
my $end=localtime($slots{$slot}->{'endtime'}); |
&Apache::lonlocal::locallocaltime($slots{$slot}->{'starttime'}):''); |
|
my $end=($slots{$slot}->{'endtime'}? |
|
&Apache::lonlocal::locallocaltime($slots{$slot}->{'endtime'}):''); |
|
my $start_reserve=($slots{$slot}->{'endtime'}? |
|
&Apache::lonlocal::locallocaltime($slots{$slot}->{'startreserve'}):''); |
|
|
my $unique; |
my $unique; |
if (ref($slots{$slot}{'uniqueperiod'})) { |
if (ref($slots{$slot}{'uniqueperiod'})) { |
$unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','. |
$unique=localtime($slots{$slot}{'uniqueperiod'}[0]).','. |
localtime($slots{$slot}{'uniqueperiod'}[1]); |
localtime($slots{$slot}{'uniqueperiod'}[1]); |
} |
} |
|
my @proctors = map { |
|
my ($uname,$udom)=split(/@/,$_); |
|
my $fullname=$name_cache{$_}; |
|
if (!defined($fullname)) { |
|
&Apache::lonnet::logthis("Gettign $uname $udom"); |
|
$fullname = &Apache::loncommon::plainname($uname,$udom); |
|
$fullname =~s/\s/ /g; |
|
$name_cache{$_} = $fullname; |
|
} |
|
&Apache::loncommon::aboutmewrapper($fullname,$uname,$udom); |
|
} (split(/\s*,\s*/,$slots{$slot}->{'proctor'})); |
|
|
|
my $proctors=join(', ',@proctors); |
|
|
|
my $edit=(<<EDITFORM); |
|
<form method="POST" action="/adm/helper/newslot.helper"> |
|
<input type="hidden" name="name" value="$slot" /> |
|
<input type="submit" name="Edit" value="Edit" /> |
|
</form> |
|
EDITFORM |
$r->print(<<STUFF); |
$r->print(<<STUFF); |
<tr> |
<tr> |
|
<td rowspan="2">$edit</td> |
<td>$slot</td> |
<td>$slot</td> |
<td>$slots{$slot}->{'type'}</td> |
<td>$slots{$slot}->{'type'}</td> |
<td>$description</td> |
<td>$description</td> |
<td>$start</td> |
<td>$start</td> |
<td>$end</td> |
<td>$end</td> |
|
<td>$start_reserve</td> |
|
<td>$slots{$slot}->{'secret'}</td> |
<td>$slots{$slot}->{'maxspace'}</td> |
<td>$slots{$slot}->{'maxspace'}</td> |
<td>$ids</td> |
<td>$ids</td> |
<td>$slots{$slot}->{'proctor'}</td> |
|
<td>$unique</td> |
<td>$unique</td> |
</tr> |
</tr> |
|
<tr> |
|
<td colspan="10">$proctors</td> |
|
</tr> |
STUFF |
STUFF |
} |
} |
$r->print('</table>'); |
$r->print('</table>'); |
} |
} |
|
|
sub upload_start { |
sub upload_start { |
my ($r,$symb)=@_; |
my ($r)=@_; |
$r->print(&Apache::grades::checkforfile_js()); |
$r->print(&Apache::grades::checkforfile_js()); |
my $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
my $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n"; |
$result.=' <b>'. |
$result.=' <b>'. |
Line 529 sub upload_start {
|
Line 587 sub upload_start {
|
my $ignore=&mt('Ignore First Line'); |
my $ignore=&mt('Ignore First Line'); |
$result.=<<ENDUPFORM; |
$result.=<<ENDUPFORM; |
<form method="post" enctype="multipart/form-data" action="/adm/slotrequest" name="slotupload"> |
<form method="post" enctype="multipart/form-data" action="/adm/slotrequest" name="slotupload"> |
<input type="hidden" name="symb" value="$symb" /> |
|
<input type="hidden" name="command" value="csvuploadmap" /> |
<input type="hidden" name="command" value="csvuploadmap" /> |
$upfile_select |
$upfile_select |
<br /><input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Data" /> |
<br /><input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Data" /> |
Line 542 ENDUPFORM
|
Line 599 ENDUPFORM
|
} |
} |
|
|
sub csvuploadmap_header { |
sub csvuploadmap_header { |
my ($r,$symb,$datatoken,$distotal)= @_; |
my ($r,$datatoken,$distotal)= @_; |
my $javascript; |
my $javascript; |
if ($env{'form.upfile_associate'} eq 'reverse') { |
if ($env{'form.upfile_associate'} eq 'reverse') { |
$javascript=&csvupload_javascript_reverse_associate(); |
$javascript=&csvupload_javascript_reverse_associate(); |
Line 566 to this page if the data selected is ins
|
Line 623 to this page if the data selected is ins
|
<input type="hidden" name="upfiletype" value="$env{'form.upfiletype'}" /> |
<input type="hidden" name="upfiletype" value="$env{'form.upfiletype'}" /> |
<input type="hidden" name="upfile_associate" |
<input type="hidden" name="upfile_associate" |
value="$env{'form.upfile_associate'}" /> |
value="$env{'form.upfile_associate'}" /> |
<input type="hidden" name="symb" value="$symb" /> |
|
<input type="hidden" name="command" value="csvuploadassign" /> |
<input type="hidden" name="command" value="csvuploadassign" /> |
<hr /> |
<hr /> |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
Line 641 ENDPICK
|
Line 697 ENDPICK
|
} |
} |
|
|
sub csv_upload_map { |
sub csv_upload_map { |
my ($r,$symb)= @_; |
my ($r)= @_; |
|
|
my $datatoken; |
my $datatoken; |
if (!$env{'form.datatoken'}) { |
if (!$env{'form.datatoken'}) { |
Line 652 sub csv_upload_map {
|
Line 708 sub csv_upload_map {
|
} |
} |
my @records=&Apache::loncommon::upfile_record_sep(); |
my @records=&Apache::loncommon::upfile_record_sep(); |
if ($env{'form.noFirstLine'}) { shift(@records); } |
if ($env{'form.noFirstLine'}) { shift(@records); } |
&csvuploadmap_header($r,$symb,$datatoken,$#records+1); |
&csvuploadmap_header($r,$datatoken,$#records+1); |
my ($i,$keyfields); |
my ($i,$keyfields); |
if (@records) { |
if (@records) { |
my @fields=&csvupload_fields(); |
my @fields=&csvupload_fields(); |
Line 692 sub csvupload_fields {
|
Line 748 sub csvupload_fields {
|
} |
} |
|
|
sub csv_upload_assign { |
sub csv_upload_assign { |
my ($r,$symb)= @_; |
my ($r,$mgr)= @_; |
&Apache::loncommon::load_tmp_file($r); |
&Apache::loncommon::load_tmp_file($r); |
my @slotdata = &Apache::loncommon::upfile_record_sep(); |
my @slotdata = &Apache::loncommon::upfile_record_sep(); |
if ($env{'form.noFirstLine'}) { shift(@slotdata); } |
if ($env{'form.noFirstLine'}) { shift(@slotdata); } |
Line 715 sub csv_upload_assign {
|
Line 771 sub csv_upload_assign {
|
$slot{'starttime'}=&UnixDate($entries{$fields{'starttime'}},"%s"); |
$slot{'starttime'}=&UnixDate($entries{$fields{'starttime'}},"%s"); |
} |
} |
if ($entries{$fields{'endtime'}}) { |
if ($entries{$fields{'endtime'}}) { |
$slot{'endtime'}=&UnixDate($entries{$fields{'starttime'}},"%s"); |
$slot{'endtime'}=&UnixDate($entries{$fields{'endtime'}},"%s"); |
|
} |
|
if ($entries{$fields{'startreserve'}}) { |
|
$slot{'startreserve'}= |
|
&UnixDate($entries{$fields{'startreserve'}},"%s"); |
} |
} |
foreach my $key ('ip','proctor','description','maxspace', |
foreach my $key ('ip','proctor','description','maxspace', |
'secret','symb') { |
'secret','symb') { |
Line 737 sub csv_upload_assign {
|
Line 797 sub csv_upload_assign {
|
} |
} |
$r->print("<br />Created $countdone slots\n"); |
$r->print("<br />Created $countdone slots\n"); |
$r->print("<br />\n"); |
$r->print("<br />\n"); |
&show_table($r,$symb); |
&show_table($r,$mgr); |
return ''; |
return ''; |
} |
} |
|
|
Line 746 sub handler {
|
Line 806 sub handler {
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); |
&start_page($r); |
&start_page($r); |
my $symb=&Apache::lonnet::unescape($env{'form.symb'}); |
|
my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb); |
|
if ($res !~ /\.task$/) { |
|
&fail($r,'not_valid'); |
|
return OK; |
|
} |
|
$env{'request.symb'}=$symb; |
|
my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
my $vgr=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
my $mgr=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}); |
my $mgr=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}); |
if ($env{'form.command'} eq 'showslots' && $vgr eq 'F') { |
if ($env{'form.command'} eq 'showslots' && $vgr eq 'F') { |
&show_table($r,$symb,$mgr); |
&show_table($r,$mgr); |
} elsif ($env{'form.command'} eq 'uploadstart' && $mgr eq 'F') { |
} elsif ($env{'form.command'} eq 'uploadstart' && $mgr eq 'F') { |
&upload_start($r,$symb); |
&upload_start($r); |
} elsif ($env{'form.command'} eq 'csvuploadmap' && $mgr eq 'F') { |
} elsif ($env{'form.command'} eq 'csvuploadmap' && $mgr eq 'F') { |
&csv_upload_map($r,$symb); |
&csv_upload_map($r); |
} elsif ($env{'form.command'} eq 'csvuploadassign' && $mgr eq 'F') { |
} elsif ($env{'form.command'} eq 'csvuploadassign' && $mgr eq 'F') { |
if ($env{'form.associate'} ne 'Reverse Association') { |
if ($env{'form.associate'} ne 'Reverse Association') { |
&csv_upload_assign($r,$symb); |
&csv_upload_assign($r,$mgr); |
} else { |
} else { |
if ( $env{'form.upfile_associate'} ne 'reverse' ) { |
if ( $env{'form.upfile_associate'} ne 'reverse' ) { |
$env{'form.upfile_associate'} = 'reverse'; |
$env{'form.upfile_associate'} = 'reverse'; |
} else { |
} else { |
$env{'form.upfile_associate'} = 'forward'; |
$env{'form.upfile_associate'} = 'forward'; |
} |
} |
&csv_upload_map($r,$symb); |
&csv_upload_map($r); |
} |
} |
|
} elsif ($env{'form.command'} eq 'editslot' && $mgr eq 'F') { |
|
&show_slot_edit($r); |
} else { |
} else { |
|
my $symb=&Apache::lonnet::unescape($env{'form.symb'}); |
|
my (undef,undef,$res)=&Apache::lonnet::decode_symb($symb); |
|
if ($res !~ /\.task$/) { |
|
&fail($r,'not_valid'); |
|
return OK; |
|
} |
|
$env{'request.symb'}=$symb; |
my ($status) = &Apache::lonhomework::check_task_access('0'); |
my ($status) = &Apache::lonhomework::check_task_access('0'); |
if ($status eq 'CAN_ANSWER' || |
if ($status eq 'CAN_ANSWER' || |
$status eq 'NEEDS_CHECKIN' || |
$status eq 'NEEDS_CHECKIN' || |