version 1.17, 2005/09/13 07:56:03
|
version 1.24, 2005/10/17 19:26:50
|
Line 452 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 491 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"> |
|
<input type="hidden" name="command" value="editslot" /> |
|
<input type="hidden" name="slot" 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 528 sub upload_start {
|
Line 588 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 541 ENDUPFORM
|
Line 600 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 565 to this page if the data selected is ins
|
Line 624 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 640 ENDPICK
|
Line 698 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 651 sub csv_upload_map {
|
Line 709 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 691 sub csvupload_fields {
|
Line 749 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 716 sub csv_upload_assign {
|
Line 774 sub csv_upload_assign {
|
if ($entries{$fields{'endtime'}}) { |
if ($entries{$fields{'endtime'}}) { |
$slot{'endtime'}=&UnixDate($entries{$fields{'endtime'}},"%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') { |
if ($entries{$fields{$key}}) { |
if ($entries{$fields{$key}}) { |
Line 736 sub csv_upload_assign {
|
Line 798 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 745 sub handler {
|
Line 807 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' || |