version 1.4, 2003/04/23 13:11:45
|
version 1.7, 2003/05/01 20:26:28
|
Line 54 ENDHEAD
|
Line 54 ENDHEAD
|
|
|
# =================================================== Show student list to drop |
# =================================================== Show student list to drop |
sub show_key_list { |
sub show_key_list { |
my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_; |
my ($r,$comment,$newonly,$checkonly,%cenv)=@_; |
|
$comment=~s/\W/\./g; |
|
my %accesskeys=&Apache::lonnet::dump |
|
('accesskeys',$cenv{'domain'},$cenv{'num'}); |
|
$r->print('<table border="2"><tr><th>Key</th><th>Checked Out</th><th>Comments/Remarks/Notes</th></tr>'); |
|
foreach (keys %accesskeys) { |
|
if ($_=~/^error\:/) { |
|
$r->print('<tr><td>No keys have been generated yet.</td></tr>'); |
|
} elsif ($accesskeys{$_}=~/$comment/) { |
|
my ($checkout,$com)=split(/\s*\#\s*/,$accesskeys{$_}); |
|
unless ($checkout) { |
|
if ($checkonly) { next; } |
|
} else { |
|
if ($newonly) { next; } |
|
} |
|
$r->print("\n<tr><td><tt>".$_.'</tt></td><td>'.($checkout? |
|
$checkout:'-').'</td><td>'. |
|
join('<br />',split(/\s*\;\s*/,$com)).'</td></tr>'); |
|
} |
|
} |
|
$r->print('</table>'); |
|
return ''; |
|
# |
|
# Junk below |
|
# |
|
my ($mode,$linkto,$action,$statusmode,$classlist,$keylist); |
# |
# |
# Just junk so that this compiles |
# Just junk so that this compiles |
# |
# |
Line 136 sub togglekeyaccess {
|
Line 161 sub togglekeyaccess {
|
|
|
sub genkeys { |
sub genkeys { |
my ($num,$comments,%cenv)=@_; |
my ($num,$comments,%cenv)=@_; |
|
unless ($comments) { $comments=''; } |
|
$comments=~s/\#/ /g; |
|
$comments=~s/\;/ /g; |
unless ($num) { return 'No number of keys given.'; } |
unless ($num) { return 'No number of keys given.'; } |
unless (($num=~/^\d+$/) && ($num>0)) { |
unless (($num=~/^\d+$/) && ($num>0)) { |
return 'Invalid number of keys given.'; |
return 'Invalid number of keys given.'; |
} |
} |
|
my $batchnumber='BATCH_'.time().'_'.$$; |
return 'Generated '.&Apache::lonnet::generate_access_keys |
return 'Generated '.&Apache::lonnet::generate_access_keys |
($num,$cenv{'domain'},$cenv{'num'},$comments).' of '.$num. |
($num,$cenv{'domain'},$cenv{'num'},$batchnumber.'; '.$comments).' of '. |
' access keys.'; |
$num.' access keys (Batch Number: '.$batchnumber.')',$batchnumber; |
} |
} |
|
|
################################################################### |
################################################################### |
Line 190 sub handler {
|
Line 219 sub handler {
|
$r->print(&togglekeyaccess(%cenv).'<br />'); |
$r->print(&togglekeyaccess(%cenv).'<br />'); |
%cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
%cenv=&Apache::lonnet::coursedescription($ENV{'form.cid'}); |
} |
} |
|
my $batchnumber=''; |
if ($ENV{'form.genkeys'}) { |
if ($ENV{'form.genkeys'}) { |
$r->print( |
(my $msg,$batchnumber)= |
&genkeys($ENV{'form.num'},$ENV{'form.comments'},%cenv).'<br />'); |
&genkeys($ENV{'form.num'},$ENV{'form.comments'},%cenv); |
|
$r->print($msg.'<br />'); |
} |
} |
|
if ($ENV{'form.listkeys'}) { |
|
&show_key_list($r,$ENV{'form.listcom'}, |
|
$ENV{'form.newonly'},$ENV{'form.checkonly'},%cenv); |
|
} |
# --- Menu |
# --- Menu |
$r->print('<h3>Key Access</h3>'); |
$r->print('<h3>Key Access</h3>'); |
if ($cenv{'keyaccess'} eq 'yes') { |
if ($cenv{'keyaccess'} eq 'yes') { |
$r->print('Access to this course is key controlled. <input type="submit" name="toggle" value="Open Access" />') |
$r->print('Access to this course is key controlled.<br /><input type="submit" name="toggle" value="Open Access" />') |
} else { |
} else { |
$r->print('Access to this course is open, no access keys. <input type="submit" name="toggle" value="Control Access" />'); |
$r->print('Access to this course is open, no access keys.<br /><input type="submit" name="toggle" value="Control Access" />'); |
} |
} |
$r->print(<<ENDKEYGEN); |
$r->print(<<ENDKEYMENU); |
<hr /><h3>Generate New Keys</h3> |
<hr /><h3>Generate New Keys</h3> |
Number of keys to be generated: <input type="text" name="num" size="6" /><br /> |
Number of keys to be generated: <input type="text" name="num" size="6" /><br /> |
Comments/Remarks/Notes: <input type="text" name="comments" size="30" /><br /> |
Comments/Remarks/Notes: <input type="text" name="comments" size="30" /><br /> |
<input type="submit" name="genkeys" value="Generate Keys" /> |
<input type="submit" name="genkeys" value="Generate Keys" /> |
ENDKEYGEN |
<hr /><h3>List Keys</h3> |
|
Comments/Remarks/Notes/User/Batch Number: |
|
<input type="text" name="listcom" size="30" value="$batchnumber" /><br /> |
|
<input type="checkbox" name="newonly" /> Unused keys only<br /> |
|
<input type="checkbox" name="checkonly" />Used keys only<br /> |
|
<input type="submit" name="listkeys" value="List Keys" /> |
|
ENDKEYMENU |
$r->print('</form></body></html>'); |
$r->print('</form></body></html>'); |
} |
} |
} else { |
} else { |