--- loncom/interface/lonparmset.pm 2002/08/08 17:03:20 1.57
+++ loncom/interface/lonparmset.pm 2002/08/19 23:01:27 1.63
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.57 2002/08/08 17:03:20 albertel Exp $
+# $Id: lonparmset.pm,v 1.63 2002/08/19 23:01:27 bowersj2 Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,27 +25,31 @@
#
# http://www.lon-capa.org/
#
-# (Handler to resolve ambiguous file locations
-#
-# (TeX Content Handler
-#
-# YEAR=2000
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
-#
-# 10/11,10/12,10/16 Gerd Kortemeyer)
-#
-# 11/20,11/21,11/22,11/23,11/24,11/25,11/27,11/28,
-# 12/08,12/12,
-# YEAR=2001
-# 16/01/01,02/08,03/20,03/23,03/24,03/26,05/09,
-# 07/05,07/06,08/08,08/09,09/01,09/21 Gerd Kortemeyer
-# 12/17 Scott Harrison
-# 12/19 Guy Albertelli
-# 12/26,12/27 Gerd Kortemeyer
-#
-# YEAR=2002
-# 7/19 Jeremy Bowers
-###
+###################################################################
+###################################################################
+
+=pod
+
+=head1 NAME
+
+lonparmset - Handler to set parameters for assessments and course
+
+=head1 SYNOPSIS
+
+lonparmset provides an interface to setting course parameters.
+
+=head1 DESCRIPTION
+
+This module sets coursewide and assessment parameters.
+
+=head1 INTERNAL SUBROUTINES
+
+=over 4
+
+=cut
+
+###################################################################
+###################################################################
package Apache::lonparmset;
@@ -74,8 +78,23 @@ my $uhome;
my $csec;
my $coursename;
-# -------------------------------------------- Figure out a cascading parameter
+##################################################
+##################################################
+
+=pod
+
+=item parmval
+
+Figure out a cascading parameter.
+
+Inputs: $what $id $def
+
+Returns: I am not entirely sure.
+=cut
+
+##################################################
+##################################################
sub parmval {
my ($what,$id,$def)=@_;
my $result='';
@@ -157,15 +176,58 @@ sub parmval {
return ($result,@outpar);
}
-# ------------------------------------------------------------ Output for value
+##################################################
+##################################################
+
+=pod
+
+=item valout
+
+Format a value for output.
+
+Inputs: $value, $type
+
+Returns: $value, formatted for output. If $type indicates it is a date,
+localtime($value) is returned.
+=cut
+
+##################################################
+##################################################
sub valout {
my ($value,$type)=@_;
- return ($value?(($type=~/^date/)?localtime($value):$value):' ');
+ my $result = '';
+ # Values of zero are valid.
+ if (! $value && $value ne '0') {
+ $result = ' ';
+ } else {
+ if ($type=~/^date/) {
+ $result = localtime($value);
+ } else {
+ $result = $value;
+ }
+ }
+ return $result;
}
-# -------------------------------------------------------- Produces link anchor
+##################################################
+##################################################
+
+=pod
+=item plink
+
+Produces a link anchor.
+
+Inputs: $type,$dis,$value,$marker,$return,$call
+
+Returns: scalar with html code for a link which will envoke the
+javascript function 'pjump'.
+
+=cut
+
+##################################################
+##################################################
sub plink {
my ($type,$dis,$value,$marker,$return,$call)=@_;
my $winvalue=$value;
@@ -341,10 +403,9 @@ sub print_row {
} # end of $parmlev if/else
if ($parmlev eq 'full' || $parmlev eq 'brief') {
- $r->print('
'.
- &valout($outpar[$result],$$type{$which}).' | ');
-
-}
+ $r->print(''.
+ &valout($outpar[$result],$$type{$which}).' | ');
+ }
my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
'.'.$$name{$which},$symbp{$rid});
$r->print(''.
@@ -353,6 +414,7 @@ sub print_row {
$r->print('');
$r->print("\n");
}
+
sub print_td {
my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$type,$display)=@_;
$r->print(' | : Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
+
+Input: See list below:
+
+=over 4
+
+=item B: An array that will contain all of the ids in the course.
+
+=item B: hash, id->type, where "type" contains the extension of the file, thus, I.
+
+=item B: hash, id->key list, will contain a comma seperated list of the meta-data keys available for the given id
+
+=item B: hash, name of parameter->display value (what is the display value?)
+
+=item B: hash, part identification->text representation of part, where the text representation is "[Part $part]"
+
+=item B: hash, full key to part->display value (what's display value?)
+
+=item B: hash, ???
+
+=item B: ???
+
+=item B: hash, ???
+
+=item B: ??
+
+=item B: hash, id->full sym?
+
+=back
+
+=cut
+
+sub extractResourceInformation {
+ my $bighash = shift;
+ my $ids = shift;
+ my $typep = shift;
+ my $keyp = shift;
+ my $allparms = shift;
+ my $allparts = shift;
+ my $allkeys = shift;
+ my $allmaps = shift;
+ my $fcat = shift;
+ my $defp = shift;
+ my $mapp = shift;
+ my $symbp = shift;
+
+ foreach (keys %$bighash) {
+ if ($_=~/^src\_(\d+)\.(\d+)$/) {
+ my $mapid=$1;
+ my $resid=$2;
+ my $id=$mapid.'.'.$resid;
+ my $srcf=$$bighash{$_};
+ if ($srcf=~/\.(problem|exam|quiz|assess|survey|form)$/) {
+ $$ids[$#$ids+1]=$id;
+ $$typep{$id}=$1;
+ $$keyp{$id}='';
+ foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'keys'))) {
+ if ($_=~/^parameter\_(.*)/) {
+ my $key=$_;
+ my $allkey=$1;
+ $allkey=~s/\_/\./g;
+ my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
+ my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
+ my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+ my $parmdis = $display;
+ $parmdis =~ s|(\[Part.*$)||g;
+ my $partkey = $part;
+ $partkey =~ tr|_|.|;
+ $$allparms{$name} = $parmdis;
+ $$allparts{$part} = "[Part $part]";
+ $$allkeys{$allkey}=$display;
+ if ($allkey eq $fcat) {
+ $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
+ }
+ if ($$keyp{$id}) {
+ $$keyp{$id}.=','.$key;
+ } else {
+ $$keyp{$id}=$key;
+ }
+ }
+ }
+ $$mapp{$id}=
+ &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid});
+ $$mapp{$mapid}=$$mapp{$id};
+ $$allmaps{$mapid}=$$mapp{$id};
+ $$symbp{$id}=$$mapp{$id}.
+ '___'.$resid.'___'.
+ &Apache::lonnet::declutter($srcf);
+ $$symbp{$mapid}=$$mapp{$id}.'___(all)';
+ }
+ }
+ }
+}
+
+##################################################
+##################################################
+
+=pod
+
+=item assessparms
+
+Show assessment data and parameters. This is a large routine that should
+be simplified and shortened... someday.
+
+Inputs: $r
+
+Returns: nothing
+
+Variables used (guessed by Jeremy):
+
+=over 4
+
+=item B: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.
+
+=item B: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
+
+=item B:
+
+=back
+
+=cut
+
+##################################################
+##################################################
sub assessparms {
my $r=shift;
@@ -491,62 +679,19 @@ sub assessparms {
# ------------------------------------------------------------------- Tie hashs
if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
- &GDBM_READER,0640))) {
+ &GDBM_READER(),0640))) {
$r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)");
return ;
}
if (!(tie(%parmhash,'GDBM_File',
- $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640))) {
+ $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
$r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)");
return ;
}
+
# --------------------------------------------------------- Get all assessments
- foreach (keys %bighash) {
- if ($_=~/^src\_(\d+)\.(\d+)$/) {
- my $mapid=$1;
- my $resid=$2;
- my $id=$mapid.'.'.$resid;
- my $srcf=$bighash{$_};
- if ($srcf=~/\.(problem|exam|quiz|assess|survey|form)$/) {
- $ids[$#ids+1]=$id;
- $typep{$id}=$1;
- $keyp{$id}='';
- foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'keys'))) {
- if ($_=~/^parameter\_(.*)/) {
- my $key=$_;
- my $allkey=$1;
- $allkey=~s/\_/\./g;
- my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
- my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
- my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
- my $parmdis = $display;
- $parmdis =~ s|(\[Part.*$)||g;
- my $partkey = $part;
- $partkey =~ tr|_|.|;
- $allparms{$name} = $parmdis;
- $allparts{$part} = "[Part $part]";
- $allkeys{$allkey}=$display;
- if ($allkey eq $fcat) {
- $defp{$id}= &Apache::lonnet::metadata($srcf,$key);
- }
- if ($keyp{$id}) {
- $keyp{$id}.=','.$key;
- } else {
- $keyp{$id}=$key;
- }
- }
- }
- $mapp{$id}=
- &Apache::lonnet::declutter($bighash{'map_id_'.$mapid});
- $mapp{$mapid}=$mapp{$id};
- $allmaps{$mapid}=$mapp{$id};
- $symbp{$id}=$mapp{$id}.
- '___'.$resid.'___'.
- &Apache::lonnet::declutter($srcf);
- $symbp{$mapid}=$mapp{$id}.'___(all)';
- }
- }
- }
+ extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp);
+
$mapp{'0.0'} = '';
$symbp{'0.0'} = '';
# ---------------------------------------------------------- Anything to store?
@@ -645,6 +790,7 @@ sub assessparms {
if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
# ------------------------------------------------------------------ Start page
+
&startpage($r,$id,$udom,$csec,$uname);
# if ($ENV{'form.url'}) {
# $r->print('yes" for visible separation)',
'pch.roles.denied'=> 'Disallow Resource Discussion for '.
- 'Roles ' .
- Apache::loncommon::help_open_topic("Course_Disable_Discussion")
- ,
+ 'Roles "st": '.
+ 'student, "ta": '.
+ 'TA, "in": '.
+ 'instructor; role,role,...) '.
+ Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
'pch.users.denied' =>
'Disallow Resource Discussion for Users '.
'(user:domain,user:domain,...)',
@@ -1281,8 +1446,19 @@ $output
ENDENV
}
-# ================================================================ Main Handler
+##################################################
+##################################################
+
+=pod
+
+=item handler
+Main handler. Calls &assessparms and &crsenv subroutines.
+
+=cut
+
+##################################################
+##################################################
sub handler {
my $r=shift;
@@ -1318,70 +1494,7 @@ sub handler {
1;
__END__
-
-=head1 NAME
-
-Apache::lonparmset - Handler to set parameters for assessments
-
-=head1 SYNOPSIS
-
-Invoked by /etc/httpd/conf/srm.conf:
-
-
- PerlAccessHandler Apache::lonacc
- SetHandler perl-script
- PerlHandler Apache::lonparmset
- ErrorDocument 403 /adm/login
- ErrorDocument 406 /adm/roles
- ErrorDocument 500 /adm/errorhandler
-
-
-=head1 INTRODUCTION
-
-This module sets assessment parameters.
-
-This is part of the LearningOnline Network with CAPA project
-described at http://www.lon-capa.org.
-
-=head1 HANDLER SUBROUTINE
-
-This routine is called by Apache and mod_perl.
-
-=over 4
-
-=item *
-
-need to be in course
-
-=item *
-
-bring up assessment screen or course environment
-
-=back
-
-=head1 OTHER SUBROUTINES
-
-=over 4
-
-=item *
-
-parmval() : figure out a cascading parameter
-
-=item *
-
-valout() : format a value for output
-
-=item *
-
-plink() : produces link anchor
-
-=item *
-
-assessparms() : show assess data and parameters
-
-=item *
-
-crsenv() : for the course environment
+=pod
=back
|