--- loncom/interface/lonparmset.pm 2001/07/06 14:55:05 1.31 +++ loncom/interface/lonparmset.pm 2001/12/27 17:00:30 1.42 @@ -1,24 +1,56 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # +# $Id: lonparmset.pm,v 1.42 2001/12/27 17:00:30 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,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 Gerd Kortemeyer +# 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 +# +### package Apache::lonparmset; use strict; use Apache::lonnet; use Apache::Constants qw(:common :http REDIRECT); +use Apache::loncommon; use GDBM_File; @@ -186,6 +218,10 @@ sub assessparms { $pssymb=&Apache::lonnet::symbread($url); $pscat='all'; $pschp=''; + } elsif ($ENV{'form.symb'}) { + $pssymb=$ENV{'form.symb'}; + $pscat='all'; + $pschp=''; } else { $ENV{'form.url'}=''; } @@ -223,7 +259,7 @@ sub assessparms { my %name=&Apache::lonnet::userenvironment($udom,$uname, ('firstname','middlename','lastname','generation','id')); $message="\n

\nFull Name: ". - $name{'firstname'}.' '.$name{'middlename'} + $name{'firstname'}.' '.$name{'middlename'}.' ' .$name{'lastname'}.' '.$name{'generation'}. "
\nID: ".$name{'id'}.'

'; } @@ -245,7 +281,7 @@ sub assessparms { undef %allkeys; undef %allmaps; undef %defp; - map { + foreach (keys %bighash) { if ($_=~/^src\_(\d+)\.(\d+)$/) { my $mapid=$1; my $resid=$2; @@ -255,7 +291,8 @@ sub assessparms { $ids[$#ids+1]=$id; $typep{$id}=$1; $keyp{$id}=''; - map { + foreach (split(/\,/, + &Apache::lonnet::metadata($srcf,'keys'))) { if ($_=~/^parameter\_(.*)/) { my $key=$_; my $allkey=$1; @@ -277,8 +314,7 @@ sub assessparms { $keyp{$id}=$key; } } - } split(/\,/, - &Apache::lonnet::metadata($srcf,'keys')); + } $mapp{$id}= &Apache::lonnet::declutter($bighash{'map_id_'.$mapid}); $allmaps{$mapid}=$mapp{$id}; @@ -287,11 +323,11 @@ sub assessparms { &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/\_/\./; + $spnam=~s/\_([^\_]+)$/\.$1/; # ---------------------------------------------------------- Construct prefixes my $symbparm=$symbp{$sresid}.'.'.$spnam; @@ -379,22 +415,22 @@ sub assessparms { $ENV{'course.'.$ENV{'request.course.id'}.'.num'}.':resourcedata', $ENV{'course.'.$ENV{'request.course.id'}.'.home'}); if ($reply!~/^error\:/) { - map { + foreach (split(/\&/,$reply)) { my ($name,$value)=split(/\=/,$_); $courseopt{&Apache::lonnet::unescape($name)}= &Apache::lonnet::unescape($value); - } split(/\&/,$reply); + } } # --------------------------------------------------- Get userdata (if present) if ($uname) { my $reply= &Apache::lonnet::reply('dump:'.$udom.':'.$uname.':resourcedata',$uhome); if ($reply!~/^error\:/) { - map { + foreach (split(/\&/,$reply)) { my ($name,$value)=split(/\=/,$_); $useropt{&Apache::lonnet::unescape($name)}= &Apache::lonnet::unescape($value); - } split(/\&/,$reply); + } } } @@ -487,37 +523,37 @@ ENDHEAD $r->print(''); } - map { + foreach ('tolerance','date_default','date_start','date_end', + 'date_interval','int','float','string') { $r->print(''); - } ('tolerance','date_default','date_start','date_end','date_interval', - 'int','float','string'); + } $r->print('

'.$message.'

Sort list by'); $r->print('
Select Enclosing Map
Select Parameter

' ); @@ -526,6 +562,8 @@ ENDHEAD my $catmarker='parameter_'.$pscat; $catmarker=~s/\./\_/g; my $coursespan=$csec?8:5; + my $csuname=$ENV{'user.name'}; + my $csudom=$ENV{'user.domain'}; $r->print(< @@ -535,7 +573,9 @@ ENDTABLEHEAD $r->print(""); } $r->print(<Parameter in Effect + + + ENDTABLETWO @@ -554,10 +594,10 @@ ENDTABLEHEADFOUR if ($uname) { $r->print(''); } - $r->print(''); + $r->print(''); my $defbgone=''; my $defbgtwo=''; - map { + foreach (@ids) { my $rid=$_; my ($inmapid)=($rid=~/\.(\d+)$/); if (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}) || @@ -577,13 +617,15 @@ ENDTABLEHEADFOUR @outpar=(); my $thistitle=''; my %name= (); + undef %name; my %part= (); my %display=(); my %type= (); my %default=(); my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid}); - map { + foreach (split(/\,/,$keyp{$rid})) { + if (($_ eq $catmarker) || ($pscat eq 'all')) { $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part'); $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name'); $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display'); @@ -592,13 +634,13 @@ ENDTABLEHEADFOUR $default{$_}=&Apache::lonnet::metadata($uri,$_); $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type'); $thistitle=&Apache::lonnet::metadata($uri,$_.'.title'); - } split(/\,/,$keyp{$rid}); + } + } my $totalparms=scalar keys %name; - my $isdef=1; - unless ($totalparms) { $totalparms=1; $isdef=0; } - if ($pscat ne 'all') { $totalparms=1; } - $r->print(''); - if ($isdef) { - map { - if (($_ eq $catmarker) || ($pscat eq 'all')) { + foreach (sort keys %name) { my $result=&parmval($part{$_}.'.'.$name{$_},$rid,$default{$_}); - + unless ($firstrow) { + $r->print(''); + } else { + $firstrow=0; + } $r->print(""); @@ -674,16 +718,20 @@ ENDTABLEHEADFOUR 'parmform.pres','psub').''); } $r->print( - ''); - $r->print("\n"); + ''); + my $sessionval=&Apache::lonnet::EXT('resource.'.$part{$_}. + '.'.$name{$_},$mapp{$rid}.'___'.$inmapid.'___'.$uri); + if (($type{$_}=~/^date/) && ($sessionval)) + { $sessionval=localtime($sessionval); } + $r->print( + ''); + $r->print(""); } - } sort keys %name; - } else { - $r->print("\n"); - } + } # -------------------------------------------------- End entry for one resource } - } @ids; + } $r->print('
User $uname at Domain $udom
Parameter in EffectCurrent Session Value
($csuname at $csudom)
Resource Level in Coursegeneralfor Enclosing Mapfor Resource
'. join(' / ',split(/\//,$uri)). '

'. @@ -612,11 +654,13 @@ ENDTABLEHEADFOUR $r->print('

'. join(' / ',split(/\//,$mapp{$rid})).'
$part{$_}$display{$_}'.&valout($outpar[$result],$type{$_}).'
'.&valout($outpar[$result],$type{$_}).''.$sessionval.' '. + '
'); } $r->print(''); @@ -696,7 +744,7 @@ sub crsenv { my $r=shift; my $setoutput=''; # -------------------------------------------------- Go through list of changes - map { + foreach (keys %ENV) { if ($_=~/^form\.(.+)\_setparmval$/) { my $name=$1; my $value=$ENV{'form.'.$name.'_value'}; @@ -734,7 +782,7 @@ sub crsenv { '
'; } } - } keys %ENV; + } # -------------------------------------------------------- Get parameters again my $rep=&Apache::lonnet::reply ('dump:'.$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}. @@ -754,24 +802,29 @@ sub crsenv { 'comment.email' => 'Feedback Addresses for Comments
'. '(user:domain,user:domain,...)', 'policy.email' => 'Feedback Addresses for Course Policy
'. - '(user:domain,user:domain,...)' + '(user:domain,user:domain,...)', + 'hideemptyrows' => 'Hide Empty Rows in Spreadsheets
'. + '("yes" for default hiding)', + 'pch.roles.denied'=> 'Disallow Resource Discussion for Students
'. + '("st": student, "ta": TA, "in": instructor;
'. + 'role,role,...)' ); - map { + foreach (split(/\&/,$rep)) { my ($name,$value)=split(/\=/,$_); $name=&Apache::lonnet::unescape($name); $values{$name}=&Apache::lonnet::unescape($value); unless ($descriptions{$name}) { $descriptions{$name}=$name; } - } split(/\&/,$rep); - map { + } + foreach (sort keys %descriptions) { $output.=''.$descriptions{$_}.''; - } keys %descriptions; + } $output.='Create New Environment Variable
'. ''. ''. @@ -810,7 +863,7 @@ sub handler { $r->send_http_header; return OK; } - + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); # ----------------------------------------------------- Needs to be in a course if (($ENV{'request.course.id'}) && @@ -836,5 +889,73 @@ sub handler { __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() : output for value + +=item * + +plink() : produces link anchor + +=item * + +assessparms() : show assess data and parameters + +=item * + +crsenv() : for the course environment + +=back + +=cut +