Annotation of loncom/interface/lonparmset.pm, revision 1.116
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.116 ! www 4: # $Id: lonparmset.pm,v 1.115 2003/07/15 21:12:01 www Exp $
1.40 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.59 matthew 28: ###################################################################
29: ###################################################################
30:
31: =pod
32:
33: =head1 NAME
34:
35: lonparmset - Handler to set parameters for assessments and course
36:
37: =head1 SYNOPSIS
38:
39: lonparmset provides an interface to setting course parameters.
40:
41: =head1 DESCRIPTION
42:
43: This module sets coursewide and assessment parameters.
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over 4
48:
49: =cut
50:
51: ###################################################################
52: ###################################################################
1.1 www 53:
54: package Apache::lonparmset;
55:
56: use strict;
57: use Apache::lonnet;
58: use Apache::Constants qw(:common :http REDIRECT);
1.88 matthew 59: use Apache::lonhtmlcommon();
1.36 albertel 60: use Apache::loncommon;
1.1 www 61: use GDBM_File;
1.57 albertel 62: use Apache::lonhomework;
63: use Apache::lonxml;
1.4 www 64:
1.1 www 65:
1.2 www 66: my %courseopt;
67: my %useropt;
68: my %parmhash;
69:
1.3 www 70: my @ids;
71: my %symbp;
1.10 www 72: my %mapp;
1.3 www 73: my %typep;
1.16 www 74: my %keyp;
1.2 www 75:
1.82 www 76: my %maptitles;
77:
1.2 www 78: my $uname;
79: my $udom;
80: my $uhome;
81: my $csec;
1.57 albertel 82: my $coursename;
1.2 www 83:
1.59 matthew 84: ##################################################
85: ##################################################
86:
87: =pod
88:
89: =item parmval
90:
91: Figure out a cascading parameter.
92:
1.71 albertel 93: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
94: $id - a bighash Id number
95: $def - the resource's default value 'stupid emacs
96:
97: Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 11 possible levels
98:
99: 11- resource default
100: 10- map default
101: 9 - General Course
1.82 www 102: 8 - Map or Folder level in course
1.71 albertel 103: 7 - resource level in course
104: 6 - General for section
1.82 www 105: 5 - Map or Folder level for section
1.71 albertel 106: 4 - resource level in section
107: 3 - General for specific student
1.82 www 108: 2 - Map or Folder level for specific student
1.71 albertel 109: 1 - resource level for specific student
1.2 www 110:
1.59 matthew 111: =cut
112:
113: ##################################################
114: ##################################################
1.2 www 115: sub parmval {
1.11 www 116: my ($what,$id,$def)=@_;
1.8 www 117: my $result='';
1.44 albertel 118: my @outpar=();
1.2 www 119: # ----------------------------------------------------- Cascading lookup scheme
1.10 www 120:
1.43 albertel 121: my $symbparm=$symbp{$id}.'.'.$what;
122: my $mapparm=$mapp{$id}.'___(all).'.$what;
1.10 www 123:
1.43 albertel 124: my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$what;
125: my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
126: my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
127:
128: my $courselevel=$ENV{'request.course.id'}.'.'.$what;
129: my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
130: my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
1.2 www 131:
1.11 www 132: # -------------------------------------------------------- first, check default
133:
1.43 albertel 134: if ($def) { $outpar[11]=$def; $result=11; }
1.11 www 135:
136: # ----------------------------------------------------- second, check map parms
137:
1.43 albertel 138: my $thisparm=$parmhash{$symbparm};
139: if ($thisparm) { $outpar[10]=$thisparm; $result=10; }
1.11 www 140:
141: # --------------------------------------------------------- third, check course
142:
1.71 albertel 143: if (defined($courseopt{$courselevel})) {
1.43 albertel 144: $outpar[9]=$courseopt{$courselevel};
145: $result=9;
146: }
1.11 www 147:
1.71 albertel 148: if (defined($courseopt{$courselevelm})) {
1.43 albertel 149: $outpar[8]=$courseopt{$courselevelm};
150: $result=8;
151: }
1.11 www 152:
1.71 albertel 153: if (defined($courseopt{$courselevelr})) {
1.43 albertel 154: $outpar[7]=$courseopt{$courselevelr};
155: $result=7;
156: }
1.11 www 157:
1.71 albertel 158: if (defined($csec)) {
159: if (defined($courseopt{$seclevel})) {
1.43 albertel 160: $outpar[6]=$courseopt{$seclevel};
161: $result=6;
162: }
1.71 albertel 163: if (defined($courseopt{$seclevelm})) {
1.43 albertel 164: $outpar[5]=$courseopt{$seclevelm};
165: $result=5;
166: }
167:
1.71 albertel 168: if (defined($courseopt{$seclevelr})) {
1.43 albertel 169: $outpar[4]=$courseopt{$seclevelr};
170: $result=4;
171: }
172: }
1.11 www 173:
174: # ---------------------------------------------------------- fourth, check user
175:
1.71 albertel 176: if (defined($uname)) {
177: if (defined($useropt{$courselevel})) {
1.43 albertel 178: $outpar[3]=$useropt{$courselevel};
179: $result=3;
180: }
1.10 www 181:
1.71 albertel 182: if (defined($useropt{$courselevelm})) {
1.43 albertel 183: $outpar[2]=$useropt{$courselevelm};
184: $result=2;
185: }
1.2 www 186:
1.71 albertel 187: if (defined($useropt{$courselevelr})) {
1.43 albertel 188: $outpar[1]=$useropt{$courselevelr};
189: $result=1;
190: }
191: }
1.44 albertel 192: return ($result,@outpar);
1.2 www 193: }
194:
1.59 matthew 195: ##################################################
196: ##################################################
197:
198: =pod
199:
200: =item valout
201:
202: Format a value for output.
203:
204: Inputs: $value, $type
205:
206: Returns: $value, formatted for output. If $type indicates it is a date,
207: localtime($value) is returned.
1.9 www 208:
1.59 matthew 209: =cut
210:
211: ##################################################
212: ##################################################
1.9 www 213: sub valout {
214: my ($value,$type)=@_;
1.59 matthew 215: my $result = '';
216: # Values of zero are valid.
217: if (! $value && $value ne '0') {
1.71 albertel 218: $result = ' ';
1.59 matthew 219: } else {
1.66 www 220: if ($type eq 'date_interval') {
221: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
222: $year=$year-70;
223: $mday--;
224: if ($year) {
225: $result.=$year.' yrs ';
226: }
227: if ($mon) {
228: $result.=$mon.' mths ';
229: }
230: if ($mday) {
231: $result.=$mday.' days ';
232: }
233: if ($hour) {
234: $result.=$hour.' hrs ';
235: }
236: if ($min) {
237: $result.=$min.' mins ';
238: }
239: if ($sec) {
240: $result.=$sec.' secs ';
241: }
242: $result=~s/\s+$//;
243: } elsif ($type=~/^date/) {
1.59 matthew 244: $result = localtime($value);
245: } else {
246: $result = $value;
247: }
248: }
249: return $result;
1.9 www 250: }
251:
1.59 matthew 252: ##################################################
253: ##################################################
254:
255: =pod
1.5 www 256:
1.59 matthew 257: =item plink
258:
259: Produces a link anchor.
260:
261: Inputs: $type,$dis,$value,$marker,$return,$call
262:
263: Returns: scalar with html code for a link which will envoke the
264: javascript function 'pjump'.
265:
266: =cut
267:
268: ##################################################
269: ##################################################
1.5 www 270: sub plink {
271: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 272: my $winvalue=$value;
273: unless ($winvalue) {
274: if ($type=~/^date/) {
275: $winvalue=$ENV{'form.recent_'.$type};
276: } else {
277: $winvalue=$ENV{'form.recent_'.(split(/\_/,$type))[0]};
278: }
279: }
280: return
1.43 albertel 281: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
282: .$marker."','".$return."','".$call."'".');">'.
283: &valout($value,$type).'</a><a name="'.$marker.'"></a>';
1.5 www 284: }
285:
1.44 albertel 286:
287: sub startpage {
1.99 albertel 288: my ($r,$id,$udom,$csec,$uname,$have_assesments)=@_;
289:
1.98 www 290: my $bodytag=&Apache::loncommon::bodytag('Set Course Parameters','',
291: 'onUnload="pclose()"');
1.81 www 292: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
293: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
294: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 295: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.44 albertel 296: $r->print(<<ENDHEAD);
297: <html>
298: <head>
299: <title>LON-CAPA Course Parameters</title>
300: <script>
301:
302: function pclose() {
303: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
304: "height=350,width=350,scrollbars=no,menubar=no");
305: parmwin.close();
306: }
307:
1.88 matthew 308: $pjump_def
1.44 albertel 309:
310: function psub() {
311: pclose();
312: if (document.parmform.pres_marker.value!='') {
313: document.parmform.action+='#'+document.parmform.pres_marker.value;
314: var typedef=new Array();
315: typedef=document.parmform.pres_type.value.split('_');
316: if (document.parmform.pres_type.value!='') {
317: if (typedef[0]=='date') {
318: eval('document.parmform.recent_'+
319: document.parmform.pres_type.value+
320: '.value=document.parmform.pres_value.value;');
321: } else {
322: eval('document.parmform.recent_'+typedef[0]+
323: '.value=document.parmform.pres_value.value;');
324: }
325: }
326: document.parmform.submit();
327: } else {
328: document.parmform.pres_value.value='';
329: document.parmform.pres_marker.value='';
330: }
331: }
332:
1.57 albertel 333: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
334: var options = "width=" + w + ",height=" + h + ",";
335: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
336: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
337: var newWin = window.open(url, wdwName, options);
338: newWin.focus();
339: }
1.44 albertel 340: </script>
1.81 www 341: $selscript
1.44 albertel 342: </head>
1.64 www 343: $bodytag
1.91 bowersj2 344:
1.44 albertel 345: <form method="post" action="/adm/parmset" name="envform">
346: <h3>Course Environment</h3>
347: <input type="submit" name="crsenv" value="Set Course Environment">
348: </form>
1.101 www 349: <hr />
1.44 albertel 350: <form method="post" action="/adm/parmset" name="parmform">
351: <h3>Course Assessments</h3>
1.101 www 352:
353: <a href="/adm/helper/parameter.helper">Use Assignment Parameter Helper</a>, a
354: simpler interface to set open, due, or answer open dates for problems or
355: sequences.<br /> <br />
1.99 albertel 356: ENDHEAD
357:
358: if (!$have_assesments) {
359: $r->print('<font color="red">There are no assesment parameters in this course to set.</font><br />');
360: } else {
361: $r->print(<<ENDHEAD);
1.44 albertel 362: <b>
363: Section/Group:
364: <input type="text" value="$csec" size="6" name="csec">
365: <br>
366: For User
367: <input type="text" value="$uname" size="12" name="uname">
368: or ID
369: <input type="text" value="$id" size="12" name="id">
370: at Domain
1.81 www 371: $chooseopt
1.44 albertel 372: </b>
373: <input type="hidden" value='' name="pres_value">
374: <input type="hidden" value='' name="pres_type">
375: <input type="hidden" value='' name="pres_marker">
376: ENDHEAD
1.99 albertel 377: }
1.44 albertel 378: }
379:
380: sub print_row {
1.66 www 381: my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
1.57 albertel 382: $defbgtwo,$parmlev)=@_;
1.66 www 383: # get the values for the parameter in cascading order
384: # empty levels will remain empty
1.44 albertel 385: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
386: $rid,$$default{$which});
1.66 www 387: # get the type for the parameters
388: # problem: these may not be set for all levels
389: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
390: $$name{$which}.'.type',
391: $rid,$$defaulttype{$which});
392: # cascade down manually
393: my $cascadetype=$defaulttype;
394: for (my $i=$#typeoutpar;$i>0;$i--) {
395: if ($typeoutpar[$i]) {
396: $cascadetype=$typeoutpar[$i];
397: } else {
398: $typeoutpar[$i]=$cascadetype;
399: }
400: }
401:
1.57 albertel 402: my $parm=$$display{$which};
403:
404: if ($parmlev eq 'full' || $parmlev eq 'brief') {
405: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
406: .$$part{$which}.'</td>');
407: } else {
408: $parm=~s|\[.*\]\s||g;
409: }
410:
411: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
412:
1.44 albertel 413: my $thismarker=$which;
414: $thismarker=~s/^parameter\_//;
415: my $mprefix=$rid.'&'.$thismarker.'&';
416:
1.57 albertel 417: if ($parmlev eq 'general') {
418:
419: if ($uname) {
1.66 www 420: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 421: } elsif ($csec) {
1.66 www 422: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 423: } else {
1.66 www 424: &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 425: }
426: } elsif ($parmlev eq 'map') {
427:
428: if ($uname) {
1.66 www 429: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 430: } elsif ($csec) {
1.66 www 431: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 432: } else {
1.66 www 433: &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 434: }
435: } else {
436:
1.66 www 437: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 438:
439: if ($parmlev eq 'brief') {
440:
1.66 www 441: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 442:
443: if ($csec) {
1.66 www 444: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 445: }
446: if ($uname) {
1.66 www 447: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 448: }
449: } else {
450:
1.66 www 451: &print_td($r,10,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
452: &print_td($r,9,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
453: &print_td($r,8,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
454: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 455:
456: if ($csec) {
1.66 www 457: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
458: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
459: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 460: }
461: if ($uname) {
1.66 www 462: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
463: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
464: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 465: }
466: } # end of $brief if/else
467: } # end of $parmlev if/else
468:
469: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1.59 matthew 470: $r->print('<td bgcolor=#CCCCFF align="center">'.
1.66 www 471: &valout($outpar[$result],$typeoutpar[$result]).'</td>');
1.59 matthew 472: }
1.44 albertel 473: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.57 albertel 474: '.'.$$name{$which},$symbp{$rid});
1.70 albertel 475: # this doesn't seem to work, and I don't think is correct
476: # my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
477: # '.'.$$name{$which}.'.type',$symbp{$rid});
478: # this seems to work
479: my $sessionvaltype=$typeoutpar[$result];
1.72 albertel 480: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.57 albertel 481: $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
1.66 www 482: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 483: '</font></td>');
1.44 albertel 484: $r->print('</tr>');
1.57 albertel 485: $r->print("\n");
1.44 albertel 486: }
1.59 matthew 487:
1.44 albertel 488: sub print_td {
1.66 www 489: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 490: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 491: ' align="center">');
492: if ($which<10) {
493: $r->print(&plink($$typeoutpar[$which],
494: $$display{$value},$$outpar[$which],
495: $mprefix."$which",'parmform.pres','psub'));
496: } else {
497: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
498: }
499: $r->print('</td>'."\n");
1.57 albertel 500: }
501:
502: sub get_env_multiple {
503: my ($name) = @_;
504: my @values;
505: if (defined($ENV{$name})) {
506: # exists is it an array
507: if (ref($ENV{$name})) {
508: @values=@{ $ENV{$name} };
509: } else {
510: $values[0]=$ENV{$name};
511: }
512: }
513: return(@values);
1.44 albertel 514: }
515:
1.63 bowersj2 516: =pod
517:
518: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
519:
520: Input: See list below:
521:
522: =over 4
523:
524: =item B<ids>: An array that will contain all of the ids in the course.
525:
526: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
527:
528: =item B<keyp>: hash, id->key list, will contain a comma seperated list of the meta-data keys available for the given id
529:
530: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
531:
532: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
533:
534: =item B<allkeys>: hash, full key to part->display value (what's display value?)
535:
536: =item B<allmaps>: hash, ???
537:
538: =item B<fcat>: ???
539:
540: =item B<defp>: hash, ???
541:
542: =item B<mapp>: ??
543:
544: =item B<symbp>: hash, id->full sym?
545:
546: =back
547:
548: =cut
549:
550: sub extractResourceInformation {
551: my $bighash = shift;
552: my $ids = shift;
553: my $typep = shift;
554: my $keyp = shift;
555: my $allparms = shift;
556: my $allparts = shift;
557: my $allkeys = shift;
558: my $allmaps = shift;
559: my $fcat = shift;
560: my $defp = shift;
561: my $mapp = shift;
562: my $symbp = shift;
1.82 www 563: my $maptitles=shift;
1.63 bowersj2 564:
565: foreach (keys %$bighash) {
566: if ($_=~/^src\_(\d+)\.(\d+)$/) {
567: my $mapid=$1;
568: my $resid=$2;
569: my $id=$mapid.'.'.$resid;
570: my $srcf=$$bighash{$_};
571: if ($srcf=~/\.(problem|exam|quiz|assess|survey|form)$/) {
572: $$ids[$#$ids+1]=$id;
573: $$typep{$id}=$1;
574: $$keyp{$id}='';
1.65 albertel 575: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
1.63 bowersj2 576: if ($_=~/^parameter\_(.*)/) {
577: my $key=$_;
578: my $allkey=$1;
579: $allkey=~s/\_/\./g;
580: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
581: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
582: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
583: my $parmdis = $display;
584: $parmdis =~ s|(\[Part.*$)||g;
585: my $partkey = $part;
586: $partkey =~ tr|_|.|;
587: $$allparms{$name} = $parmdis;
588: $$allparts{$part} = "[Part $part]";
589: $$allkeys{$allkey}=$display;
590: if ($allkey eq $fcat) {
591: $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
592: }
593: if ($$keyp{$id}) {
594: $$keyp{$id}.=','.$key;
595: } else {
596: $$keyp{$id}=$key;
597: }
598: }
599: }
600: $$mapp{$id}=
601: &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid});
602: $$mapp{$mapid}=$$mapp{$id};
603: $$allmaps{$mapid}=$$mapp{$id};
1.82 www 604: $$maptitles{$mapid}=
605: $$bighash{'title_'.$$bighash{'ids_'.&Apache::lonnet::clutter($$mapp{$id})}};
606: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
1.63 bowersj2 607: $$symbp{$id}=$$mapp{$id}.
608: '___'.$resid.'___'.
609: &Apache::lonnet::declutter($srcf);
610: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
611: }
612: }
613: }
614: }
615:
1.59 matthew 616: ##################################################
617: ##################################################
618:
619: =pod
620:
621: =item assessparms
622:
623: Show assessment data and parameters. This is a large routine that should
624: be simplified and shortened... someday.
625:
626: Inputs: $r
627:
628: Returns: nothing
629:
1.63 bowersj2 630: Variables used (guessed by Jeremy):
631:
632: =over 4
633:
634: =item B<pscat>: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.
635:
636: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
637:
638: =item B<allmaps>:
639:
640: =back
641:
1.59 matthew 642: =cut
643:
644: ##################################################
645: ##################################################
1.30 www 646: sub assessparms {
1.1 www 647:
1.43 albertel 648: my $r=shift;
1.2 www 649: # -------------------------------------------------------- Variable declaration
1.43 albertel 650: my %allkeys;
651: my %allmaps;
1.57 albertel 652: my %alllevs;
653:
654: $alllevs{'Resource Level'}='full';
655: # $alllevs{'Resource Level [BRIEF]'}='brief';
656: $alllevs{'Map Level'}='map';
657: $alllevs{'Course Level'}='general';
658:
659: my %allparms;
660: my %allparts;
661:
1.43 albertel 662: my %defp;
663: %courseopt=();
664: %useropt=();
1.44 albertel 665: my %bighash=();
1.43 albertel 666:
667: @ids=();
668: %symbp=();
669: %typep=();
670:
671: my $message='';
672:
673: $csec=$ENV{'form.csec'};
674: $udom=$ENV{'form.udom'};
675: unless ($udom) { $udom=$r->dir_config('lonDefDomain'); }
676:
1.57 albertel 677: my @pscat=&get_env_multiple('form.pscat');
1.43 albertel 678: my $pschp=$ENV{'form.pschp'};
1.57 albertel 679: my @psprt=&get_env_multiple('form.psprt');
1.76 www 680: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 681: my $showoptions=$ENV{'form.showoptions'};
682:
1.43 albertel 683: my $pssymb='';
1.57 albertel 684: my $parmlev='';
685: my $prevvisit=$ENV{'form.prevvisit'};
686:
687: # unless ($parmlev==$ENV{'form.parmlev'}) {
688: # $parmlev = 'full';
689: # }
690:
691: unless ($ENV{'form.parmlev'}) {
692: $parmlev = 'map';
693: } else {
694: $parmlev = $ENV{'form.parmlev'};
695: }
1.26 www 696:
1.29 www 697: # ----------------------------------------------- Was this started from grades?
698:
1.43 albertel 699: if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'})
700: && (!$ENV{'form.dis'})) {
701: my $url=$ENV{'form.url'};
702: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
703: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 704: if (!@pscat) { @pscat=('all'); }
1.43 albertel 705: $pschp='';
1.57 albertel 706: $parmlev = 'full';
1.43 albertel 707: } elsif ($ENV{'form.symb'}) {
708: $pssymb=$ENV{'form.symb'};
1.92 albertel 709: if (!@pscat) { @pscat=('all'); }
1.43 albertel 710: $pschp='';
1.57 albertel 711: $parmlev = 'full';
1.43 albertel 712: } else {
713: $ENV{'form.url'}='';
714: }
715:
716: my $id=$ENV{'form.id'};
717: if (($id) && ($udom)) {
718: $uname=(&Apache::lonnet::idget($udom,$id))[1];
719: if ($uname) {
720: $id='';
721: } else {
722: $message=
723: "<font color=red>Unknown ID '$id' at domain '$udom'</font>";
724: }
725: } else {
726: $uname=$ENV{'form.uname'};
727: }
728: unless ($udom) { $uname=''; }
729: $uhome='';
730: if ($uname) {
731: $uhome=&Apache::lonnet::homeserver($uname,$udom);
732: if ($uhome eq 'no_host') {
733: $message=
734: "<font color=red>Unknown user '$uname' at domain '$udom'</font>";
735: $uname='';
1.12 www 736: } else {
1.103 albertel 737: $csec=&Apache::lonnet::getsection($udom,$uname,
738: $ENV{'request.course.id'});
1.43 albertel 739: if ($csec eq '-1') {
740: $message="<font color=red>".
1.45 matthew 741: "User '$uname' at domain '$udom' not ".
742: "in this course</font>";
1.43 albertel 743: $uname='';
744: $csec=$ENV{'form.csec'};
745: } else {
746: my %name=&Apache::lonnet::userenvironment($udom,$uname,
747: ('firstname','middlename','lastname','generation','id'));
748: $message="\n<p>\nFull Name: ".
749: $name{'firstname'}.' '.$name{'middlename'}.' '
750: .$name{'lastname'}.' '.$name{'generation'}.
751: "<br>\nID: ".$name{'id'}.'<p>';
752: }
1.12 www 753: }
1.43 albertel 754: }
1.2 www 755:
1.43 albertel 756: unless ($csec) { $csec=''; }
1.12 www 757:
1.44 albertel 758: my $fcat=$ENV{'form.fcat'};
1.43 albertel 759: unless ($fcat) { $fcat=''; }
1.2 www 760:
761: # ------------------------------------------------------------------- Tie hashs
1.44 albertel 762: if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
1.58 albertel 763: &GDBM_READER(),0640))) {
1.44 albertel 764: $r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)");
765: return ;
766: }
767: if (!(tie(%parmhash,'GDBM_File',
1.58 albertel 768: $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
1.44 albertel 769: $r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)");
770: return ;
771: }
1.63 bowersj2 772:
1.14 www 773: # --------------------------------------------------------- Get all assessments
1.82 www 774: extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles);
1.63 bowersj2 775:
1.57 albertel 776: $mapp{'0.0'} = '';
777: $symbp{'0.0'} = '';
1.99 albertel 778:
1.14 www 779: # ---------------------------------------------------------- Anything to store?
1.44 albertel 780: if ($ENV{'form.pres_marker'}) {
781: my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'});
782: $spnam=~s/\_([^\_]+)$/\.$1/;
1.15 www 783: # ---------------------------------------------------------- Construct prefixes
1.14 www 784:
1.44 albertel 785: my $symbparm=$symbp{$sresid}.'.'.$spnam;
786: my $mapparm=$mapp{$sresid}.'___(all).'.$spnam;
787:
788: my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam;
789: my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
790: my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
791:
792: my $courselevel=$ENV{'request.course.id'}.'.'.$spnam;
793: my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
794: my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
795:
796: my $storeunder='';
797: if (($snum==9) || ($snum==3)) { $storeunder=$courselevel; }
798: if (($snum==8) || ($snum==2)) { $storeunder=$courselevelm; }
799: if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
800: if ($snum==6) { $storeunder=$seclevel; }
801: if ($snum==5) { $storeunder=$seclevelm; }
802: if ($snum==4) { $storeunder=$seclevelr; }
803:
1.79 albertel 804: my $delete;
805: if ($ENV{'form.pres_value'} eq '') { $delete=1;}
1.66 www 806: my %storecontent = ($storeunder => $ENV{'form.pres_value'},
807: $storeunder.'.type' => $ENV{'form.pres_type'});
1.44 albertel 808: my $reply='';
809: if ($snum>3) {
1.14 www 810: # ---------------------------------------------------------------- Store Course
1.24 www 811: #
812: # Expire sheets
1.44 albertel 813: &Apache::lonnet::expirespread('','','studentcalc');
814: if (($snum==7) || ($snum==4)) {
815: &Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid});
816: } elsif (($snum==8) || ($snum==5)) {
817: &Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid});
818: } else {
819: &Apache::lonnet::expirespread('','','assesscalc');
820: }
1.24 www 821: # Store parameter
1.79 albertel 822: if ($delete) {
823: $reply=&Apache::lonnet::del
824: ('resourcedata',[keys(%storecontent)],
825: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
826: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
827: } else {
828: $reply=&Apache::lonnet::cput
829: ('resourcedata',\%storecontent,
830: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
831: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
832: }
1.44 albertel 833: } else {
1.14 www 834: # ------------------------------------------------------------------ Store User
1.24 www 835: #
836: # Expire sheets
1.44 albertel 837: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
838: if ($snum==1) {
839: &Apache::lonnet::expirespread
840: ($uname,$udom,'assesscalc',$symbp{$sresid});
841: } elsif ($snum==2) {
842: &Apache::lonnet::expirespread
843: ($uname,$udom,'assesscalc',$mapp{$sresid});
844: } else {
845: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
846: }
1.24 www 847: # Store parameter
1.79 albertel 848: if ($delete) {
849: $reply=&Apache::lonnet::del
850: ('resourcedata',[keys(%storecontent)],$udom,$uname);
851: } else {
852: $reply=&Apache::lonnet::cput
853: ('resourcedata',\%storecontent,$udom,$uname);
854: }
1.44 albertel 855: }
1.15 www 856:
1.44 albertel 857: if ($reply=~/^error\:(.*)/) {
858: $message.="<font color=red>Write Error: $1</font>";
859: }
1.68 www 860: # ---------------------------------------------------------------- Done storing
1.116 ! www 861: $message.='<h3>Changes can take up to 10 minutes before being active for all students.'.&Apache::loncommon::help_open_topic('Caching').'</h3>';
1.68 www 862: }
1.67 www 863: # --------------------------------------------- Devalidate cache for this child
1.109 albertel 864: &Apache::lonnet::devalidatecourseresdata(
1.67 www 865: $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
866: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
1.109 albertel 867: &Apache::lonnet::clear_EXT_cache_status();
1.2 www 868: # -------------------------------------------------------------- Get coursedata
1.45 matthew 869: %courseopt = &Apache::lonnet::dump
870: ('resourcedata',
871: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
872: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.44 albertel 873: # --------------------------------------------------- Get userdata (if present)
874: if ($uname) {
1.45 matthew 875: %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
1.44 albertel 876: }
1.14 www 877:
1.2 www 878: # ------------------------------------------------------------------- Sort this
1.17 www 879:
1.44 albertel 880: @ids=sort {
881: if ($fcat eq '') {
882: $a<=>$b;
883: } else {
884: my ($result,@outpar)=&parmval($fcat,$a,$defp{$a});
885: my $aparm=$outpar[$result];
886: ($result,@outpar)=&parmval($fcat,$b,$defp{$b});
887: my $bparm=$outpar[$result];
888: 1*$aparm<=>1*$bparm;
889: }
890: } @ids;
1.57 albertel 891: #----------------------------------------------- if all selected, fill in array
892: if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
893: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 894: # ------------------------------------------------------------------ Start page
1.63 bowersj2 895:
1.99 albertel 896: my $have_assesments=1;
897: if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
898:
899: &startpage($r,$id,$udom,$csec,$uname,$have_assesments);
900:
1.112 albertel 901: if (!$have_assesments) {
902: untie(%bighash);
903: untie(%parmhash);
904: return '';
905: }
1.44 albertel 906: # if ($ENV{'form.url'}) {
907: # $r->print('<input type="hidden" value="'.$ENV{'form.url'}.
908: # '" name="url"><input type="hidden" name="command" value="set">');
909: # }
1.57 albertel 910: $r->print('<input type="hidden" value="true" name="prevvisit">');
911:
1.44 albertel 912: foreach ('tolerance','date_default','date_start','date_end',
913: 'date_interval','int','float','string') {
914: $r->print('<input type="hidden" value="'.
915: $ENV{'form.recent_'.$_}.'" name="recent_'.$_.'">');
916: }
917:
1.57 albertel 918: $r->print('<h2>'.$message.'</h2><table>');
919:
920: my $submitmessage;
1.44 albertel 921: if (!$pssymb) {
1.101 www 922: $r->print('<tr><td>Select Parameter Level</td><td colspan="2">');
1.57 albertel 923: $r->print('<select name="parmlev">');
924: foreach (reverse sort keys %alllevs) {
925: $r->print('<option value="'.$alllevs{$_}.'"');
926: if ($parmlev eq $alllevs{$_}) {
927: $r->print(' selected');
928: }
929: $r->print('>'.$_.'</option>');
930: }
931: $r->print("</select></td>\n");
932:
1.101 www 933: $r->print('</tr>');
1.57 albertel 934:
1.82 www 935: $r->print('<tr><td>Select Enclosing Map or Folder</td>');
1.57 albertel 936: $r->print('<td colspan="2"><select name="pschp">');
1.82 www 937: $r->print('<option value="all">All Maps or Folders</option>');
1.57 albertel 938: foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
939: $r->print('<option value="'.$_.'"');
940: if (($pschp eq $_)) { $r->print(' selected'); }
1.82 www 941: $r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').'</option>');
1.57 albertel 942: }
943: $r->print("</select></td></tr>\n");
1.44 albertel 944: } else {
1.57 albertel 945: my ($map,$id,$resource)=split(/___/,$pssymb);
946: $r->print("<tr><td>Specific Resource</td><td>$resource</td>");
947: $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
948: $r->print('</tr>');
949: $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
950: }
951:
952: $r->print('<tr><td colspan="3"><hr /><input type="checkbox"');
953: if ($showoptions eq 'show') {$r->print(" checked ");}
1.101 www 954: $r->print(' name="showoptions" value="show">Show More Options<hr /></td></tr>');
1.57 albertel 955: # $r->print("<tr><td>Show: $showoptions</td></tr>");
956: # $r->print("<tr><td>pscat: @pscat</td></tr>");
957: # $r->print("<tr><td>psprt: @psprt</td></tr>");
958: # $r->print("<tr><td>fcat: $fcat</td></tr>");
959:
960: if ($showoptions eq 'show') {
961: my $tempkey;
962:
963: $r->print('<tr><td colspan="3" align="center">Select Parameters to View</td></tr>');
964:
965: $r->print('<tr><td colspan="2"><table>');
966: $r->print('<tr><td><input type="checkbox" name="pscat" value="all"');
967: $r->print(' checked') unless (@pscat);
968: $r->print('>All Parameters</td>');
969:
970: my $cnt=0;
971: foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
972: keys %allparms ) {
973: ++$cnt;
974: $r->print('</tr><tr>') unless ($cnt%2);
975: $r->print('<td><input type="checkbox" name="pscat" ');
976: $r->print('value="'.$tempkey.'"');
977: if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
978: $r->print(' checked');
979: }
980: $r->print('>'.$allparms{$tempkey}.'</td>');
981: }
982: $r->print('</tr></table>');
983:
984: # $r->print('<tr><td>Select Parts</td><td>');
985: $r->print('<td><select multiple name="psprt" size="5">');
986: $r->print('<option value="all"');
987: $r->print(' selected') unless (@psprt);
988: $r->print('>All Parts</option>');
1.76 www 989: my %temphash=();
990: foreach (@psprt) { $temphash{$_}=1; }
1.57 albertel 991: foreach $tempkey (sort keys %allparts) {
992: unless ($tempkey =~ /\./) {
993: $r->print('<option value="'.$tempkey.'"');
1.76 www 994: if ($psprt[0] eq "all" || $temphash{$tempkey}) {
1.57 albertel 995: $r->print(' selected');
996: }
997: $r->print('>'.$allparts{$tempkey}.'</option>');
998: }
999: }
1000: $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
1001:
1002: $r->print('<tr><td>Sort list by</td><td>');
1003: $r->print('<select name="fcat">');
1.82 www 1004: $r->print('<option value="">Enclosing Map or Folder</option>');
1.57 albertel 1005: foreach (sort keys %allkeys) {
1006: $r->print('<option value="'.$_.'"');
1007: if ($fcat eq $_) { $r->print(' selected'); }
1008: $r->print('>'.$allkeys{$_}.'</option>');
1009: }
1010: $r->print('</select></td>');
1011:
1012: $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
1013:
1014: } else { # hide options - include any necessary extras here
1015:
1016: $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
1017:
1018: unless (@pscat) {
1019: foreach (keys %allparms ) {
1020: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1021: }
1022: } else {
1023: foreach (@pscat) {
1024: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1025: }
1026: }
1027:
1028: unless (@psprt) {
1029: foreach (keys %allparts ) {
1030: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1031: }
1032: } else {
1033: foreach (@psprt) {
1034: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1035: }
1036: }
1037:
1.44 albertel 1038: }
1.101 www 1039: $r->print('</table><br />');
1040: if (($prevvisit) || ($pschp) || ($pssymb)) {
1041: $submitmessage = "Update Course Assessment Parameter Display";
1042: } else {
1043: $submitmessage = "Set Course Assessment Parameters";
1044: }
1045: $r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
1.57 albertel 1046:
1.76 www 1047: # my @temp_psprt;
1048: # foreach my $t (@psprt) {
1049: # push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
1050: # }
1.57 albertel 1051:
1.76 www 1052: # @psprt = @temp_psprt;
1.57 albertel 1053:
1054: my @temp_pscat;
1055: map {
1056: my $cat = $_;
1057: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1058: } @pscat;
1059:
1060: @pscat = @temp_pscat;
1061:
1062: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.10 www 1063: # ----------------------------------------------------------------- Start Table
1.57 albertel 1064: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1065: my $csuname=$ENV{'user.name'};
1066: my $csudom=$ENV{'user.domain'};
1067:
1068: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1069: my $coursespan=$csec?8:5;
1070: $r->print('<p><table border=2>');
1071: $r->print('<tr><td colspan=5></td>');
1072: $r->print('<th colspan='.($coursespan).'>Any User</th>');
1073: if ($uname) {
1074: $r->print("<th colspan=3 rowspan=2>");
1075: $r->print("User $uname at Domain $udom</th>");
1076: }
1077: $r->print(<<ENDTABLETWO);
1.33 www 1078: <th rowspan=3>Parameter in Effect</th>
1079: <th rowspan=3>Current Session Value<br>($csuname at $csudom)</th>
1.57 albertel 1080: </tr><tr><td colspan=5></td><th colspan=2>Resource Level</th>
1.10 www 1081: <th colspan=3>in Course</th>
1082: ENDTABLETWO
1.57 albertel 1083: if ($csec) {
1084: $r->print("<th colspan=3>in Section/Group $csec</th>");
1085: }
1086: $r->print(<<ENDTABLEHEADFOUR);
1.11 www 1087: </tr><tr><th>Assessment URL and Title</th><th>Type</th>
1.102 albertel 1088: <th>Enclosing Map or Folder</th><th>Part</th><th>Parameter Name</th>
1.82 www 1089: <th>default</th><th>from Enclosing Map or Folder</th>
1090: <th>general</th><th>for Enclosing Map or Folder</th><th>for Resource</th>
1.10 www 1091: ENDTABLEHEADFOUR
1.57 albertel 1092:
1093: if ($csec) {
1.82 www 1094: $r->print('<th>general</th><th>for Enclosing Map or Folder</th><th>for Resource</th>');
1.57 albertel 1095: }
1096:
1097: if ($uname) {
1.82 www 1098: $r->print('<th>general</th><th>for Enclosing Map or Folder</th><th>for Resource</th>');
1.57 albertel 1099: }
1100:
1101: $r->print('</tr>');
1102:
1103: my $defbgone='';
1104: my $defbgtwo='';
1105:
1106: foreach (@ids) {
1107:
1108: my $rid=$_;
1109: my ($inmapid)=($rid=~/\.(\d+)$/);
1110:
1111: if (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}) ||
1112: ($pssymb eq $symbp{$rid})) {
1.4 www 1113: # ------------------------------------------------------ Entry for one resource
1.57 albertel 1114: if ($defbgone eq '"E0E099"') {
1115: $defbgone='"E0E0DD"';
1116: } else {
1117: $defbgone='"E0E099"';
1118: }
1119: if ($defbgtwo eq '"FFFF99"') {
1120: $defbgtwo='"FFFFDD"';
1121: } else {
1122: $defbgtwo='"FFFF99"';
1123: }
1124: my $thistitle='';
1125: my %name= ();
1126: undef %name;
1127: my %part= ();
1128: my %display=();
1129: my %type= ();
1130: my %default=();
1131: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1132:
1133: foreach (split(/\,/,$keyp{$rid})) {
1134: my $tempkeyp = $_;
1135: if (grep $_ eq $tempkeyp, @catmarker) {
1136: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1137: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1138: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1139: unless ($display{$_}) { $display{$_}=''; }
1140: $display{$_}.=' ('.$name{$_}.')';
1141: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1142: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1143: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1144: }
1145: }
1146: my $totalparms=scalar keys %name;
1147: if ($totalparms>0) {
1148: my $firstrow=1;
1149:
1150: $r->print('<tr><td bgcolor='.$defbgone.
1151: ' rowspan='.$totalparms.
1152: '><tt><font size=-1>'.
1153: join(' / ',split(/\//,$uri)).
1154: '</font></tt><p><b>'.
1155: "<a href=\"javascript:openWindow('/res/".$uri.
1156: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1157: " TARGET=_self>$bighash{'title_'.$rid}");
1158:
1159: if ($thistitle) {
1160: $r->print(' ('.$thistitle.')');
1161: }
1162: $r->print('</a></b></td>');
1163: $r->print('<td bgcolor='.$defbgtwo.
1164: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1165: '</td>');
1166:
1167: $r->print('<td bgcolor='.$defbgone.
1168: ' rowspan='.$totalparms.
1169: '><tt><font size=-1>');
1170:
1171: $r->print(' / res / ');
1172: $r->print(join(' / ', split(/\//,$mapp{$rid})));
1173:
1174: $r->print('</font></tt></td>');
1175:
1176: foreach (sort keys %name) {
1177: unless ($firstrow) {
1178: $r->print('<tr>');
1179: } else {
1180: undef $firstrow;
1181: }
1182:
1183: &print_row($r,$_,\%part,\%name,$rid,\%default,
1184: \%type,\%display,$defbgone,$defbgtwo,
1185: $parmlev);
1186: }
1187: }
1188: }
1189: } # end foreach ids
1.43 albertel 1190: # -------------------------------------------------- End entry for one resource
1.57 albertel 1191: $r->print('</table>');
1192: } # end of brief/full
1193: #--------------------------------------------------- Entry for parm level map
1194: if ($parmlev eq 'map') {
1195: my $defbgone = '"E0E099"';
1196: my $defbgtwo = '"FFFF99"';
1197:
1198: my %maplist;
1199:
1200: if ($pschp eq 'all') {
1201: %maplist = %allmaps;
1202: } else {
1203: %maplist = ($pschp => $mapp{$pschp});
1204: }
1205:
1206: #-------------------------------------------- for each map, gather information
1207: my $mapid;
1.60 albertel 1208: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1209: my $maptitle = $maplist{$mapid};
1.57 albertel 1210:
1211: #----------------------- loop through ids and get all parameter types for map
1212: #----------------------------------------- and associated information
1213: my %name = ();
1214: my %part = ();
1215: my %display = ();
1216: my %type = ();
1217: my %default = ();
1218: my $map = 0;
1219:
1220: # $r->print("Catmarker: @catmarker<br />\n");
1221:
1222: foreach (@ids) {
1223: ($map)=(/([\d]*?)\./);
1224: my $rid = $_;
1225:
1226: # $r->print("$mapid:$map: $rid <br /> \n");
1227:
1228: if ($map eq $mapid) {
1229: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1230: # $r->print("Keys: $keyp{$rid} <br />\n");
1231:
1232: #--------------------------------------------------------------------
1233: # @catmarker contains list of all possible parameters including part #s
1234: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1235: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1236: # When storing information, store as part 0
1237: # When requesting information, request from full part
1238: #-------------------------------------------------------------------
1239: foreach (split(/\,/,$keyp{$rid})) {
1240: my $tempkeyp = $_;
1241: my $fullkeyp = $tempkeyp;
1.73 albertel 1242: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1243:
1244: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1245: $part{$tempkeyp}="0";
1246: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1247: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1248: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1249: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1250: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1251: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1252: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1253: }
1254: } # end loop through keys
1255: }
1256: } # end loop through ids
1257:
1258: #---------------------------------------------------- print header information
1.82 www 1259: my $foldermap=($maptitle=~/^uploaded/?'Folder':'Map');
1260: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1261: $r->print(<<ENDMAPONE);
1262: <center><h4>
1.82 www 1263: <font color="red">Set Defaults for All Resources in $foldermap<br />
1264: <i>$showtitle</i><br />
1.57 albertel 1265: Specifically for
1266: ENDMAPONE
1267: if ($uname) {
1268: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1269: ('firstname','middlename','lastname','generation', 'id'));
1270: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1271: .$name{'lastname'}.' '.$name{'generation'};
1272: $r->print("User <i>$uname \($person\) </i> in \n");
1273: } else {
1274: $r->print("<i>all</i> users in \n");
1275: }
1276:
1277: if ($csec) {$r->print("Section <i>$csec</i> of \n")};
1278:
1279: $r->print("<i>$coursename</i><br />");
1280: $r->print("</font></h4>\n");
1281: #---------------------------------------------------------------- print table
1282: $r->print('<p><table border="2">');
1283: $r->print('<tr><th>Parameter Name</th>');
1284: $r->print('<th>Default Value</th>');
1285: $r->print('<th>Parameter in Effect</th></tr>');
1286:
1287: foreach (sort keys %name) {
1288: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1289: \%type,\%display,$defbgone,$defbgtwo,
1290: $parmlev);
1291: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1292: }
1293: $r->print("</table></center>");
1294: } # end each map
1295: } # end of $parmlev eq map
1296: #--------------------------------- Entry for parm level general (Course level)
1297: if ($parmlev eq 'general') {
1298: my $defbgone = '"E0E099"';
1299: my $defbgtwo = '"FFFF99"';
1300:
1301: #-------------------------------------------- for each map, gather information
1302: my $mapid="0.0";
1303: #----------------------- loop through ids and get all parameter types for map
1304: #----------------------------------------- and associated information
1305: my %name = ();
1306: my %part = ();
1307: my %display = ();
1308: my %type = ();
1309: my %default = ();
1310:
1311: foreach (@ids) {
1312: my $rid = $_;
1313:
1314: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1315:
1316: #--------------------------------------------------------------------
1317: # @catmarker contains list of all possible parameters including part #s
1318: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1319: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1320: # When storing information, store as part 0
1321: # When requesting information, request from full part
1322: #-------------------------------------------------------------------
1323: foreach (split(/\,/,$keyp{$rid})) {
1324: my $tempkeyp = $_;
1325: my $fullkeyp = $tempkeyp;
1.73 albertel 1326: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1327: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1328: $part{$tempkeyp}="0";
1329: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1330: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1331: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1332: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1333: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1334: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1335: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1336: }
1337: } # end loop through keys
1338: } # end loop through ids
1339:
1340: #---------------------------------------------------- print header information
1341: $r->print(<<ENDMAPONE);
1342: <center><h4>
1343: <font color="red">Set Defaults for All Resources in Course
1344: <i>$coursename</i><br />
1345: ENDMAPONE
1346: if ($uname) {
1347: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1348: ('firstname','middlename','lastname','generation', 'id'));
1349: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1350: .$name{'lastname'}.' '.$name{'generation'};
1351: $r->print(" User <i>$uname \($person\) </i> \n");
1352: } else {
1353: $r->print("<i>ALL</i> USERS \n");
1354: }
1355:
1356: if ($csec) {$r->print("Section <i>$csec</i>\n")};
1357: $r->print("</font></h4>\n");
1358: #---------------------------------------------------------------- print table
1359: $r->print('<p><table border="2">');
1360: $r->print('<tr><th>Parameter Name</th>');
1361: $r->print('<th>Default Value</th>');
1362: $r->print('<th>Parameter in Effect</th></tr>');
1363:
1364: foreach (sort keys %name) {
1365: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1366: \%type,\%display,$defbgone,$defbgtwo,$parmlev);
1367: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1368: }
1369: $r->print("</table></center>");
1370: } # end of $parmlev eq general
1.43 albertel 1371: }
1.44 albertel 1372: $r->print('</form></body></html>');
1373: untie(%bighash);
1374: untie(%parmhash);
1.57 albertel 1375: } # end sub assessparms
1.30 www 1376:
1.59 matthew 1377:
1378: ##################################################
1379: ##################################################
1380:
1381: =pod
1382:
1383: =item crsenv
1384:
1.105 matthew 1385: Show and set course data and parameters. This is a large routine that should
1.59 matthew 1386: be simplified and shortened... someday.
1387:
1388: Inputs: $r
1389:
1390: Returns: nothing
1391:
1392: =cut
1393:
1394: ##################################################
1395: ##################################################
1.30 www 1396: sub crsenv {
1397: my $r=shift;
1398: my $setoutput='';
1.64 www 1399: my $bodytag=&Apache::loncommon::bodytag(
1400: 'Set Course Environment Parameters');
1.45 matthew 1401: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1402: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1.105 matthew 1403:
1404: #
1405: # Go through list of changes
1.38 harris41 1406: foreach (keys %ENV) {
1.105 matthew 1407: next if ($_!~/^form\.(.+)\_setparmval$/);
1408: my $name = $1;
1409: my $value = $ENV{'form.'.$name.'_value'};
1410: if ($name eq 'newp') {
1411: $name = $ENV{'form.newp_name'};
1412: }
1413: if ($name eq 'url') {
1414: $value=~s/^\/res\///;
1415: my $bkuptime=time;
1416: my @tmp = &Apache::lonnet::get
1417: ('environment',['url'],$dom,$crs);
1418: $setoutput.='Backing up previous URL: '.
1419: &Apache::lonnet::put
1420: ('environment',
1421: {'top level map backup '.$bkuptime => $tmp[1] },
1422: $dom,$crs).
1423: '<br>';
1424: }
1425: #
1426: # Deal with modified default spreadsheets
1427: if ($name =~ /^spreadsheet_default_(classcalc|
1428: studentcalc|
1429: assesscalc)$/x) {
1430: my $sheettype = $1;
1431: if ($sheettype eq 'classcalc') {
1432: # no need to do anything since viewing the sheet will
1433: # cause it to be updated.
1434: } elsif ($sheettype eq 'studentcalc') {
1435: # expire all the student spreadsheets
1436: &Apache::lonnet::expirespread('','','studentcalc');
1437: } else {
1438: # expire all the assessment spreadsheets
1439: # this includes non-default spreadsheets, but better to
1440: # be safe than sorry.
1441: &Apache::lonnet::expirespread('','','assesscalc');
1442: # expire all the student spreadsheets
1443: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 1444: }
1.105 matthew 1445: }
1446: #
1.107 matthew 1447: # Deal with the enrollment dates
1448: if ($name =~ /^default_enrollment_(start|end)_date$/) {
1449: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
1450: }
1451: #
1.105 matthew 1452: # Let the user know we made the changes
1453: if ($name) {
1454: my $put_result = &Apache::lonnet::put('environment',
1455: {$name=>$value},$dom,$crs);
1456: if ($put_result eq 'ok') {
1457: $setoutput.='Set <b>'.$name.'</b> to <b>'.$value.'</b>.<br />';
1458: } else {
1459: $setoutput.='Unable to set <b>'.$name.'</b> to '.
1460: '<b>'.$value.'</b> due to '.$put_result.'.<br />';
1.30 www 1461: }
1462: }
1.38 harris41 1463: }
1.108 www 1464: # ------------------------- Re-init course environment entries for this session
1465:
1466: &Apache::lonnet::coursedescription($ENV{'request.course.id'});
1.105 matthew 1467:
1.30 www 1468: # -------------------------------------------------------- Get parameters again
1.45 matthew 1469:
1470: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.30 www 1471: my $output='';
1.45 matthew 1472: if (! exists($values{'con_lost'})) {
1.30 www 1473: my %descriptions=
1.47 matthew 1474: ('url' => '<b>Top Level Map</b> '.
1.46 matthew 1475: '<a href="javascript:openbrowser'.
1.47 matthew 1476: "('envform','url','sequence')\">".
1.100 www 1477: 'Select Map</a><br /><font color=red> '.
1.45 matthew 1478: 'Modification may make assessment data '.
1479: 'inaccessible</font>',
1480: 'description' => '<b>Course Description</b>',
1.75 albertel 1481: 'courseid' => '<b>Course ID or number</b><br />'.
1.45 matthew 1482: '(internal, optional)',
1.52 www 1483: 'default_xml_style' => '<b>Default XML Style File</b> '.
1484: '<a href="javascript:openbrowser'.
1485: "('envform','default_xml_style'".
1.100 www 1486: ",'sty')\">Select Style File</a><br>",
1.74 www 1487: 'question.email' => '<b>Feedback Addresses for Resource Content '.
1.75 albertel 1488: 'Questions</b><br />(<tt>user:domain,'.
1.74 www 1489: 'user:domain(section;section;...;*;...),...</tt>)',
1.75 albertel 1490: 'comment.email' => '<b>Feedback Addresses for Course Content Comments</b><br />'.
1.74 www 1491: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.45 matthew 1492: 'policy.email' => '<b>Feedback Addresses for Course Policy</b>'.
1.75 albertel 1493: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1494: 'hideemptyrows' => '<b>Hide Empty Rows in Spreadsheets</b><br />'.
1.45 matthew 1495: '("<tt>yes</tt>" for default hiding)',
1.75 albertel 1496: 'pageseparators' => '<b>Visibly Separate Items on Pages</b><br />'.
1.93 bowersj2 1497: '("<tt>yes</tt>" for visible separation, '.
1498: 'changes will not show until next login)',
1.45 matthew 1499: 'pch.roles.denied'=> '<b>Disallow Resource Discussion for '.
1.75 albertel 1500: 'Roles</b><br />"<tt>st</tt>": '.
1.61 albertel 1501: 'student, "<tt>ta</tt>": '.
1502: 'TA, "<tt>in</tt>": '.
1.75 albertel 1503: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 1504: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 1505: 'pch.users.denied' =>
1.75 albertel 1506: '<b>Disallow Resource Discussion for Users</b><br />'.
1.53 www 1507: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 1508: 'spreadsheet_default_classcalc'
1.52 www 1509: => '<b>Default Course Spreadsheet</b> '.
1.50 matthew 1510: '<a href="javascript:openbrowser'.
1511: "('envform','spreadsheet_default_classcalc'".
1.100 www 1512: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.49 matthew 1513: 'spreadsheet_default_studentcalc'
1.52 www 1514: => '<b>Default Student Spreadsheet</b> '.
1.50 matthew 1515: '<a href="javascript:openbrowser'.
1516: "('envform','spreadsheet_default_calc'".
1.100 www 1517: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.49 matthew 1518: 'spreadsheet_default_assesscalc'
1.52 www 1519: => '<b>Default Assessment Spreadsheet</b> '.
1.50 matthew 1520: '<a href="javascript:openbrowser'.
1521: "('envform','spreadsheet_default_assesscalc'".
1.100 www 1522: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.75 albertel 1523: 'allow_limited_html_in_feedback'
1524: => '<b>Allow limited HTML in discussion posts</b><br />'.
1.108 www 1525: '(Set value to "<tt>yes</tt>" to allow)',
1.89 albertel 1526: 'rndseed'
1.90 albertel 1527: => '<b>Randomization algorithm used</b> <br />'.
1.89 albertel 1528: '<font color="red">Modifying this will make problems '.
1.94 sakharuk 1529: 'have different numbers and answers</font>',
1.113 sakharuk 1530: 'problem_stream_switch'
1.104 matthew 1531: => '<b>Allow problems to be split over pages</b><br />'.
1.115 www 1532: ' ("<tt>yes</tt>" if allowed, anything else if not)',
1.111 sakharuk 1533: 'anonymous_quiz'
1.110 sakharuk 1534: => '<b>Anonimous quiz/exam</b><br />'.
1535: ' (<tt><b>yes</b> to avoid print students names </tt>)',
1.108 www 1536: 'default_enrollment_start_date' => '<b>Default beginning date '.
1537: 'when enrolling students</b>',
1538: 'default_enrollment_end_date' => '<b>Default ending date '.
1539: 'when enrolling students</b>',
1.115 www 1540: 'languages' => '<b>Languages used</b>',
1541: 'disable_receipt_display'
1542: => '<b>Disable display of problem receipts</b><br />'.
1543: ' ("<tt>yes</tt>" to disable, anything else if not)'
1.107 matthew 1544: );
1545: my @Display_Order = ('url','description','courseid',
1546: 'default_xml_style','pageseparators',
1547: 'question.email','comment.email','policy.email',
1548: 'pch.roles.denied','pch.users.denied',
1549: 'allow_limited_html_in_feedback',
1.108 www 1550: 'languages',
1.107 matthew 1551: 'rndseed',
1552: 'problem_stream_switch',
1.115 www 1553: 'disable_receipt_display',
1.107 matthew 1554: 'spreadsheet_default_classcalc',
1555: 'spreadsheet_default_studentcalc',
1556: 'spreadsheet_default_assesscalc',
1557: 'hideemptyrows',
1558: 'default_enrollment_start_date',
1559: 'default_enrollment_end_date',
1560: );
1561: foreach my $parameter (sort(keys(%values))) {
1562: if (! $descriptions{$parameter}) {
1563: $descriptions{$parameter}=$parameter;
1564: push(@Display_Order,$parameter);
1.43 albertel 1565: }
1566: }
1.107 matthew 1567: foreach my $parameter (@Display_Order) {
1568: my $description = $descriptions{$parameter};
1.51 matthew 1569: # onchange is javascript to automatically check the 'Set' button.
1.69 www 1570: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 1571: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 1572: '.checked=true;"';
1.107 matthew 1573: $output .= '<tr><td>'.$description.'</td>';
1574: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
1575: $output .= '<td>'.
1576: &Apache::lonhtmlcommon::date_setter('envform',
1577: $parameter.'_value',
1578: $values{$parameter},
1579: $onchange).
1580: '</td>';
1581: } else {
1582: $output .= '<td>'.
1583: &Apache::lonhtmlcommon::textbox($parameter.'_value',
1584: $values{$parameter},
1585: 40,$onchange).'</td>';
1586: }
1587: $output .= '<td>'.
1588: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
1589: '</td>';
1590: $output .= "</tr>\n";
1.51 matthew 1591: }
1.69 www 1592: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 1593: '[\'envform\'].elements[\'newp_setparmval\']'.
1594: '.checked=true;"';
1595: $output.='<tr><td><i>Create New Environment Variable</i><br />'.
1596: '<input type="text" size=40 name="newp_name" '.
1597: $onchange.' /></td><td>'.
1598: '<input type="text" size=40 name="newp_value" '.
1599: $onchange.' /></td><td>'.
1600: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 1601: }
1.30 www 1602: $r->print(<<ENDENV);
1603: <html>
1.46 matthew 1604: <script type="text/javascript" language="Javascript" >
1605: var editbrowser;
1.47 matthew 1606: function openbrowser(formname,elementname,only,omit) {
1.46 matthew 1607: var url = '/res/?';
1608: if (editbrowser == null) {
1609: url += 'launch=1&';
1610: }
1611: url += 'catalogmode=interactive&';
1612: url += 'mode=parmset&';
1613: url += 'form=' + formname + '&';
1.47 matthew 1614: if (only != null) {
1615: url += 'only=' + only + '&';
1616: }
1617: if (omit != null) {
1618: url += 'omit=' + omit + '&';
1619: }
1.46 matthew 1620: url += 'element=' + elementname + '';
1621: var title = 'Browser';
1622: var options = 'scrollbars=1,resizable=1,menubar=0';
1623: options += ',width=700,height=600';
1624: editbrowser = open(url,title,options,'1');
1625: editbrowser.focus();
1626: }
1627: </script>
1.30 www 1628: <head>
1629: <title>LON-CAPA Course Environment</title>
1630: </head>
1.64 www 1631: $bodytag
1.30 www 1632: <form method="post" action="/adm/parmset" name="envform">
1633: $setoutput
1634: <p>
1635: <table border=2>
1636: <tr><th>Parameter</th><th>Value</th><th>Set?</th></tr>
1637: $output
1638: </table>
1639: <input type="submit" name="crsenv" value="Set Course Environment">
1640: </form>
1641: </body>
1642: </html>
1643: ENDENV
1644: }
1645:
1.59 matthew 1646: ##################################################
1647: ##################################################
1.30 www 1648:
1.59 matthew 1649: =pod
1650:
1.83 bowersj2 1651: =item * handler
1.59 matthew 1652:
1653: Main handler. Calls &assessparms and &crsenv subroutines.
1654:
1655: =cut
1656:
1657: ##################################################
1658: ##################################################
1.85 bowersj2 1659: use Data::Dumper;
1.30 www 1660: sub handler {
1.43 albertel 1661: my $r=shift;
1.30 www 1662:
1.43 albertel 1663: if ($r->header_only) {
1664: $r->content_type('text/html');
1665: $r->send_http_header;
1666: return OK;
1667: }
1668: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
1.83 bowersj2 1669:
1.30 www 1670: # ----------------------------------------------------- Needs to be in a course
1671:
1.43 albertel 1672: if (($ENV{'request.course.id'}) &&
1673: (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) {
1.106 www 1674:
1675: $r->content_type('text/html');
1676: $r->send_http_header;
1.57 albertel 1677:
1678: $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1.30 www 1679:
1.43 albertel 1680: unless (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) {
1.30 www 1681: # --------------------------------------------------------- Bring up assessment
1.43 albertel 1682: &assessparms($r);
1.30 www 1683: # ---------------------------------------------- This is for course environment
1.43 albertel 1684: } else {
1685: &crsenv($r);
1686: }
1687: } else {
1.1 www 1688: # ----------------------------- Not in a course, or not allowed to modify parms
1.43 albertel 1689: $ENV{'user.error.msg'}=
1690: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
1691: return HTTP_NOT_ACCEPTABLE;
1692: }
1693: return OK;
1.1 www 1694: }
1695:
1696: 1;
1697: __END__
1698:
1.59 matthew 1699: =pod
1.38 harris41 1700:
1701: =back
1702:
1703: =cut
1.1 www 1704:
1705:
1706:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>