--- loncom/interface/lonparmset.pm 2000/11/22 12:16:03 1.4
+++ loncom/interface/lonparmset.pm 2002/08/19 23:01:27 1.63
@@ -1,244 +1,1504 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# (Handler to resolve ambiguous file locations
+# $Id: lonparmset.pm,v 1.63 2002/08/19 23:01:27 bowersj2 Exp $
#
-# (TeX Content Handler
+# Copyright Michigan State University Board of Trustees
#
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
-# 10/11,10/12,10/16 Gerd Kortemeyer)
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
#
-# 11/20,11/21,11/22 Gerd Kortemeyer
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+###################################################################
+###################################################################
+
+=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;
use strict;
use Apache::lonnet;
use Apache::Constants qw(:common :http REDIRECT);
+use Apache::loncommon;
use GDBM_File;
-use Apache::lonmeta;
+use Apache::lonhomework;
+use Apache::lonxml;
my %courseopt;
my %useropt;
-my %bighash;
my %parmhash;
my @ids;
my %symbp;
+my %mapp;
my %typep;
+my %keyp;
my $uname;
my $udom;
my $uhome;
-
my $csec;
+my $coursename;
+
+##################################################
+##################################################
+
+=pod
+
+=item parmval
+
+Figure out a cascading parameter.
+
+Inputs: $what $id $def
-my $fcat;
+Returns: I am not entirely sure.
-# -------------------------------------------- Figure out a cascading parameter
+=cut
+##################################################
+##################################################
sub parmval {
- my ($what,$id)=@_;
+ my ($what,$id,$def)=@_;
+ my $result='';
+ my @outpar=();
# ----------------------------------------------------- Cascading lookup scheme
- my $symbparm=$symbp{$id}.'.'.$what;
- my $reslevel=
- $ENV{'request.course.id'}.'.'.$symbparm;
- my $seclevel=
- $ENV{'request.course.id'}.'.'.
- $ENV{'request.course.sec'}.'.'.$what;
- my $courselevel=
- $ENV{'request.course.id'}.'.'.$what;
-# ----------------------------------------------------------- first, check user
+ my $symbparm=$symbp{$id}.'.'.$what;
+ my $mapparm=$mapp{$id}.'___(all).'.$what;
+
+ my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what;
+ my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
+ my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
+
+ my $courselevel=$ENV{'request.course.id'}.'.'.$what;
+ my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
+ my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
+
+# -------------------------------------------------------- first, check default
+
+ if ($def) { $outpar[11]=$def; $result=11; }
+
+# ----------------------------------------------------- second, check map parms
+
+ my $thisparm=$parmhash{$symbparm};
+ if ($thisparm) { $outpar[10]=$thisparm; $result=10; }
+
+# --------------------------------------------------------- third, check course
+
+ if ($courseopt{$courselevel}) {
+ $outpar[9]=$courseopt{$courselevel};
+ $result=9;
+ }
+
+ if ($courseopt{$courselevelm}) {
+ $outpar[8]=$courseopt{$courselevelm};
+ $result=8;
+ }
+
+ if ($courseopt{$courselevelr}) {
+ $outpar[7]=$courseopt{$courselevelr};
+ $result=7;
+ }
+
+ if ($csec) {
+ if ($courseopt{$seclevel}) {
+ $outpar[6]=$courseopt{$seclevel};
+ $result=6;
+ }
+ if ($courseopt{$seclevelm}) {
+ $outpar[5]=$courseopt{$seclevelm};
+ $result=5;
+ }
+
+ if ($courseopt{$seclevelr}) {
+ $outpar[4]=$courseopt{$seclevelr};
+ $result=4;
+ }
+ }
+
+# ---------------------------------------------------------- fourth, check user
+
+ if ($uname) {
+ if ($useropt{$courselevel}) {
+ $outpar[3]=$useropt{$courselevel};
+ $result=3;
+ }
+
+ if ($useropt{$courselevelm}) {
+ $outpar[2]=$useropt{$courselevelm};
+ $result=2;
+ }
+
+ if ($useropt{$courselevelr}) {
+ $outpar[1]=$useropt{$courselevelr};
+ $result=1;
+ }
+ }
+
+ return ($result,@outpar);
+}
+
+##################################################
+##################################################
+
+=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)=@_;
+ 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;
+}
+
+##################################################
+##################################################
+
+=pod
- if ($uname) {
- if ($useropt{$reslevel}) { return $useropt{$reslevel}; }
- if ($useropt{$seclevel}) { return $useropt{$seclevel}; }
- if ($useropt{$courselevel}) { return $useropt{$courselevel}; }
- }
+=item plink
-# -------------------------------------------------------- second, check course
+Produces a link anchor.
- if ($courseopt{$reslevel}) { return $courseopt{$reslevel}; }
- if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; }
- if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; }
+Inputs: $type,$dis,$value,$marker,$return,$call
-# ------------------------------------------------------ third, check map parms
+Returns: scalar with html code for a link which will envoke the
+javascript function 'pjump'.
- my $thisparm=$parmhash{$symbparm};
- if ($thisparm) { return $thisparm; }
-
-# --------------------------------------------- last, look in resource metadata
+=cut
- my $filename='/home/httpd/res/'.$bighash{'src_'.$id}.'.meta';
- if (-e $filename) {
- my @content;
- {
- my $fh=Apache::File->new($filename);
- @content=<$fh>;
+##################################################
+##################################################
+sub plink {
+ my ($type,$dis,$value,$marker,$return,$call)=@_;
+ my $winvalue=$value;
+ unless ($winvalue) {
+ if ($type=~/^date/) {
+ $winvalue=$ENV{'form.recent_'.$type};
+ } else {
+ $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]};
+ }
+ }
+ return
+ ''.
+ &valout($value,$type).'';
+}
+
+
+sub startpage {
+ my ($r,$id,$udom,$csec,$uname)=@_;
+ $r->content_type('text/html');
+ $r->send_http_header;
+ $r->print(<
+
+LON-CAPA Course Parameters
+
+
+
+
Set Course Parameters for Course:
+$ENV{'course.'.$ENV{'request.course.id'}.'.description'}