[LON-CAPA-cvs] cvs: loncom /interface slotrequest.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 07 Oct 2005 19:44:06 -0000
albertel Fri Oct 7 15:44:06 2005 EDT
Modified files:
/loncom/interface slotrequest.pm
Log:
- don't need a symb to view slots
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.18 loncom/interface/slotrequest.pm:1.19
--- loncom/interface/slotrequest.pm:1.18 Tue Sep 13 04:12:03 2005
+++ loncom/interface/slotrequest.pm Fri Oct 7 15:44:06 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for requesting to have slots added to a students record
#
-# $Id: slotrequest.pm,v 1.18 2005/09/13 08:12:03 albertel Exp $
+# $Id: slotrequest.pm,v 1.19 2005/10/07 19:44:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -452,20 +452,23 @@
}
sub show_table {
- my ($r,$symb,$mgr)=@_;
+ my ($r,$mgr)=@_;
my ($cnum,$cdom)=&get_course();
my %slots=&Apache::lonnet::dump('slots',$cdom,$cnum);
+ if ( (keys(%slots))[0] =~ /^error: 2 /) {
+ undef(%slots);
+ }
my $available;
if ($mgr eq 'F') {
$r->print('<form method="POST" action="/adm/slotrequest">
<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').'" />
</form>');
}
$r->print('<table border="1">
<tr>
+ <th></th>
<th>Slot name</th>
<th>Type</th>
<th>Description</th>
@@ -499,8 +502,16 @@
localtime($slots{$slot}{'uniqueperiod'}[1]);
}
+ 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);
<tr>
+ <td>$edit</td>
<td>$slot</td>
<td>$slots{$slot}->{'type'}</td>
<td>$description</td>
@@ -517,7 +528,7 @@
}
sub upload_start {
- my ($r,$symb)=@_;
+ my ($r)=@_;
$r->print(&Apache::grades::checkforfile_js());
my $result.='<table width=100% border=0><tr bgcolor="#e6ffff"><td>'."\n";
$result.=' <b>'.
@@ -528,7 +539,6 @@
my $ignore=&mt('Ignore First Line');
$result.=<<ENDUPFORM;
<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" />
$upfile_select
<br /><input type="button" onClick="javascript:checkUpload(this.form);" value="Upload Data" />
@@ -541,7 +551,7 @@
}
sub csvuploadmap_header {
- my ($r,$symb,$datatoken,$distotal)= @_;
+ my ($r,$datatoken,$distotal)= @_;
my $javascript;
if ($env{'form.upfile_associate'} eq 'reverse') {
$javascript=&csvupload_javascript_reverse_associate();
@@ -565,7 +575,6 @@
<input type="hidden" name="upfiletype" value="$env{'form.upfiletype'}" />
<input type="hidden" name="upfile_associate"
value="$env{'form.upfile_associate'}" />
-<input type="hidden" name="symb" value="$symb" />
<input type="hidden" name="command" value="csvuploadassign" />
<hr />
<script type="text/javascript" language="Javascript">
@@ -640,7 +649,7 @@
}
sub csv_upload_map {
- my ($r,$symb)= @_;
+ my ($r)= @_;
my $datatoken;
if (!$env{'form.datatoken'}) {
@@ -651,7 +660,7 @@
}
my @records=&Apache::loncommon::upfile_record_sep();
if ($env{'form.noFirstLine'}) { shift(@records); }
- &csvuploadmap_header($r,$symb,$datatoken,$#records+1);
+ &csvuploadmap_header($r,$datatoken,$#records+1);
my ($i,$keyfields);
if (@records) {
my @fields=&csvupload_fields();
@@ -691,7 +700,7 @@
}
sub csv_upload_assign {
- my ($r,$symb,$mgr)= @_;
+ my ($r,$mgr)= @_;
&Apache::loncommon::load_tmp_file($r);
my @slotdata = &Apache::loncommon::upfile_record_sep();
if ($env{'form.noFirstLine'}) { shift(@slotdata); }
@@ -736,7 +745,7 @@
}
$r->print("<br />Created $countdone slots\n");
$r->print("<br />\n");
- &show_table($r,$symb,$mgr);
+ &show_table($r,$mgr);
return '';
}
@@ -745,33 +754,35 @@
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
&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 $mgr=&Apache::lonnet::allowed('mgr',$env{'request.course.id'});
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') {
- &upload_start($r,$symb);
+ &upload_start($r);
} 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') {
if ($env{'form.associate'} ne 'Reverse Association') {
- &csv_upload_assign($r,$symb,$mgr);
+ &csv_upload_assign($r,$mgr);
} else {
if ( $env{'form.upfile_associate'} ne 'reverse' ) {
$env{'form.upfile_associate'} = 'reverse';
} else {
$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 {
+ 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');
if ($status eq 'CAN_ANSWER' ||
$status eq 'NEEDS_CHECKIN' ||