--- loncom/interface/lonparmset.pm 2000/11/27 15:12:42 1.14 +++ loncom/interface/lonparmset.pm 2001/12/26 21:45:29 1.41 @@ -1,23 +1,57 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # +# $Id: lonparmset.pm,v 1.41 2001/12/26 21:45:29 www Exp $ +# +# Copyright Michigan State University Board of Trustees +# +# This file is part of the LearningOnline Network with CAPA (LON-CAPA). +# +# 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. +# +# 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/ +# # (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 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 Gerd Kortemeyer +# +### package Apache::lonparmset; use strict; use Apache::lonnet; use Apache::Constants qw(:common :http REDIRECT); +use Apache::loncommon; use GDBM_File; -use Apache::lonmeta; my %courseopt; @@ -31,6 +65,11 @@ my @ids; my %symbp; my %mapp; my %typep; +my %keyp; +my %defp; + +my %allkeys; +my %allmaps; my $uname; my $udom; @@ -121,16 +160,6 @@ sub parmval { return $result; } -# ---------------------------------------------------------------- Sort routine - -sub bycat { - if ($fcat eq '') { - $a<=>$b; - } else { - &parmval('0.'.$fcat,$a)<=>&parmval('0.'.$fcat,$b); - } -} - # ------------------------------------------------------------ Output for value sub valout { @@ -143,26 +172,23 @@ sub valout { sub plink { my ($type,$dis,$value,$marker,$return,$call)=@_; - return ''. - &valout($value,$type).''; + &valout($value,$type).''; } -# ================================================================ Main Handler - -sub handler { - my $r=shift; - - if ($r->header_only) { - $r->content_type('text/html'); - $r->send_http_header; - return OK; - } - -# ----------------------------------------------------- Needs to be in a course +sub assessparms { - if (($ENV{'request.course.fn'}) && - (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { + my $r=shift; # -------------------------------------------------------- Variable declaration %courseopt=(); @@ -177,6 +203,29 @@ sub handler { $csec=$ENV{'form.csec'}; $udom=$ENV{'form.udom'}; + unless ($udom) { $udom=$r->dir_config('lonDefDomain'); } + + my $pscat=$ENV{'form.pscat'}; + my $pschp=$ENV{'form.pschp'}; + my $pssymb=''; + +# ----------------------------------------------- Was this started from grades? + + if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'}) + && (!$ENV{'form.dis'})) { + my $url=$ENV{'form.url'}; + $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--; + $pssymb=&Apache::lonnet::symbread($url); + $pscat='all'; + $pschp=''; + } elsif ($ENV{'form.symb'}) { + $pssymb=$ENV{'form.symb'}; + $pscat='all'; + $pschp=''; + } else { + $ENV{'form.url'}=''; + } + my $id=$ENV{'form.id'}; if (($id) && ($udom)) { $uname=(&Apache::lonnet::idget($udom,$id))[1]; @@ -184,7 +233,7 @@ sub handler { $id=''; } else { $message= - "
\nFull Name: ".
- $name{'firstname'}.' '.$name{'middlename'}
+ $name{'firstname'}.' '.$name{'middlename'}.' '
.$name{'lastname'}.' '.$name{'generation'}.
"
\nID: ".$name{'id'}.'
'; } @@ -229,25 +278,57 @@ sub handler { $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER,0640))) { # --------------------------------------------------------- Get all assessments - map { + undef %allkeys; + undef %allmaps; + undef %defp; + foreach (keys %bighash) { if ($_=~/^src\_(\d+)\.(\d+)$/) { my $mapid=$1; my $resid=$2; my $id=$mapid.'.'.$resid; - if ($bighash{$_}=~/\.(problem|exam|quiz|assess|survey|form)$/) { + 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/\_/\./; + my $display= + &Apache::lonnet::metadata($srcf,$key.'.display'); + unless ($display) { + $display= + &Apache::lonnet::metadata($srcf,$key.'.name'); + } + $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}); + $allmaps{$mapid}=$mapp{$id}; $symbp{$id}=$mapp{$id}. '___'.$resid.'___'. - &Apache::lonnet::declutter($bighash{$_}); + &Apache::lonnet::declutter($srcf); } } - } keys %bighash; + } # ---------------------------------------------------------- Anything to store? if ($ENV{'form.pres_marker'}) { my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'}); + $spnam=~s/\_([^\_]+)$/\.$1/; +# ---------------------------------------------------------- Construct prefixes my $symbparm=$symbp{$sresid}.'.'.$spnam; my $mapparm=$mapp{$sresid}.'___(all).'.$spnam; @@ -276,51 +357,101 @@ sub handler { if ($snum==6) { $storeunder=$seclevel; } if ($snum==5) { $storeunder=$seclevelm; } if ($snum==4) { $storeunder=$seclevelr; } + $storeunder=&Apache::lonnet::escape($storeunder); + + my $storecontent= + $storeunder.'='.&Apache::lonnet::escape($ENV{'form.pres_value'}).'&'. + $storeunder.'.type='.&Apache::lonnet::escape($ENV{'form.pres_type'}); - - $message.="