Annotation of loncom/interface/lonparmset.pm, revision 1.112
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.112 ! albertel 4: # $Id: lonparmset.pm,v 1.111 2003/06/24 20:54:20 sakharuk 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).
491: ' align="center">'.
1.66 www 492: &plink($$typeoutpar[$which],$$display{$value},$$outpar[$which],
1.57 albertel 493: $mprefix."$which",'parmform.pres','psub').'</td>'."\n");
494: }
495:
496: sub get_env_multiple {
497: my ($name) = @_;
498: my @values;
499: if (defined($ENV{$name})) {
500: # exists is it an array
501: if (ref($ENV{$name})) {
502: @values=@{ $ENV{$name} };
503: } else {
504: $values[0]=$ENV{$name};
505: }
506: }
507: return(@values);
1.44 albertel 508: }
509:
1.63 bowersj2 510: =pod
511:
512: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
513:
514: Input: See list below:
515:
516: =over 4
517:
518: =item B<ids>: An array that will contain all of the ids in the course.
519:
520: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
521:
522: =item B<keyp>: hash, id->key list, will contain a comma seperated list of the meta-data keys available for the given id
523:
524: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
525:
526: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
527:
528: =item B<allkeys>: hash, full key to part->display value (what's display value?)
529:
530: =item B<allmaps>: hash, ???
531:
532: =item B<fcat>: ???
533:
534: =item B<defp>: hash, ???
535:
536: =item B<mapp>: ??
537:
538: =item B<symbp>: hash, id->full sym?
539:
540: =back
541:
542: =cut
543:
544: sub extractResourceInformation {
545: my $bighash = shift;
546: my $ids = shift;
547: my $typep = shift;
548: my $keyp = shift;
549: my $allparms = shift;
550: my $allparts = shift;
551: my $allkeys = shift;
552: my $allmaps = shift;
553: my $fcat = shift;
554: my $defp = shift;
555: my $mapp = shift;
556: my $symbp = shift;
1.82 www 557: my $maptitles=shift;
1.63 bowersj2 558:
559: foreach (keys %$bighash) {
560: if ($_=~/^src\_(\d+)\.(\d+)$/) {
561: my $mapid=$1;
562: my $resid=$2;
563: my $id=$mapid.'.'.$resid;
564: my $srcf=$$bighash{$_};
565: if ($srcf=~/\.(problem|exam|quiz|assess|survey|form)$/) {
566: $$ids[$#$ids+1]=$id;
567: $$typep{$id}=$1;
568: $$keyp{$id}='';
1.65 albertel 569: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
1.63 bowersj2 570: if ($_=~/^parameter\_(.*)/) {
571: my $key=$_;
572: my $allkey=$1;
573: $allkey=~s/\_/\./g;
574: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
575: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
576: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
577: my $parmdis = $display;
578: $parmdis =~ s|(\[Part.*$)||g;
579: my $partkey = $part;
580: $partkey =~ tr|_|.|;
581: $$allparms{$name} = $parmdis;
582: $$allparts{$part} = "[Part $part]";
583: $$allkeys{$allkey}=$display;
584: if ($allkey eq $fcat) {
585: $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
586: }
587: if ($$keyp{$id}) {
588: $$keyp{$id}.=','.$key;
589: } else {
590: $$keyp{$id}=$key;
591: }
592: }
593: }
594: $$mapp{$id}=
595: &Apache::lonnet::declutter($$bighash{'map_id_'.$mapid});
596: $$mapp{$mapid}=$$mapp{$id};
597: $$allmaps{$mapid}=$$mapp{$id};
1.82 www 598: $$maptitles{$mapid}=
599: $$bighash{'title_'.$$bighash{'ids_'.&Apache::lonnet::clutter($$mapp{$id})}};
600: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
1.63 bowersj2 601: $$symbp{$id}=$$mapp{$id}.
602: '___'.$resid.'___'.
603: &Apache::lonnet::declutter($srcf);
604: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
605: }
606: }
607: }
608: }
609:
1.59 matthew 610: ##################################################
611: ##################################################
612:
613: =pod
614:
615: =item assessparms
616:
617: Show assessment data and parameters. This is a large routine that should
618: be simplified and shortened... someday.
619:
620: Inputs: $r
621:
622: Returns: nothing
623:
1.63 bowersj2 624: Variables used (guessed by Jeremy):
625:
626: =over 4
627:
628: =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.
629:
630: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
631:
632: =item B<allmaps>:
633:
634: =back
635:
1.59 matthew 636: =cut
637:
638: ##################################################
639: ##################################################
1.30 www 640: sub assessparms {
1.1 www 641:
1.43 albertel 642: my $r=shift;
1.2 www 643: # -------------------------------------------------------- Variable declaration
1.43 albertel 644: my %allkeys;
645: my %allmaps;
1.57 albertel 646: my %alllevs;
647:
648: $alllevs{'Resource Level'}='full';
649: # $alllevs{'Resource Level [BRIEF]'}='brief';
650: $alllevs{'Map Level'}='map';
651: $alllevs{'Course Level'}='general';
652:
653: my %allparms;
654: my %allparts;
655:
1.43 albertel 656: my %defp;
657: %courseopt=();
658: %useropt=();
1.44 albertel 659: my %bighash=();
1.43 albertel 660:
661: @ids=();
662: %symbp=();
663: %typep=();
664:
665: my $message='';
666:
667: $csec=$ENV{'form.csec'};
668: $udom=$ENV{'form.udom'};
669: unless ($udom) { $udom=$r->dir_config('lonDefDomain'); }
670:
1.57 albertel 671: my @pscat=&get_env_multiple('form.pscat');
1.43 albertel 672: my $pschp=$ENV{'form.pschp'};
1.57 albertel 673: my @psprt=&get_env_multiple('form.psprt');
1.76 www 674: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 675: my $showoptions=$ENV{'form.showoptions'};
676:
1.43 albertel 677: my $pssymb='';
1.57 albertel 678: my $parmlev='';
679: my $prevvisit=$ENV{'form.prevvisit'};
680:
681: # unless ($parmlev==$ENV{'form.parmlev'}) {
682: # $parmlev = 'full';
683: # }
684:
685: unless ($ENV{'form.parmlev'}) {
686: $parmlev = 'map';
687: } else {
688: $parmlev = $ENV{'form.parmlev'};
689: }
1.26 www 690:
1.29 www 691: # ----------------------------------------------- Was this started from grades?
692:
1.43 albertel 693: if (($ENV{'form.command'} eq 'set') && ($ENV{'form.url'})
694: && (!$ENV{'form.dis'})) {
695: my $url=$ENV{'form.url'};
696: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
697: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 698: if (!@pscat) { @pscat=('all'); }
1.43 albertel 699: $pschp='';
1.57 albertel 700: $parmlev = 'full';
1.43 albertel 701: } elsif ($ENV{'form.symb'}) {
702: $pssymb=$ENV{'form.symb'};
1.92 albertel 703: if (!@pscat) { @pscat=('all'); }
1.43 albertel 704: $pschp='';
1.57 albertel 705: $parmlev = 'full';
1.43 albertel 706: } else {
707: $ENV{'form.url'}='';
708: }
709:
710: my $id=$ENV{'form.id'};
711: if (($id) && ($udom)) {
712: $uname=(&Apache::lonnet::idget($udom,$id))[1];
713: if ($uname) {
714: $id='';
715: } else {
716: $message=
717: "<font color=red>Unknown ID '$id' at domain '$udom'</font>";
718: }
719: } else {
720: $uname=$ENV{'form.uname'};
721: }
722: unless ($udom) { $uname=''; }
723: $uhome='';
724: if ($uname) {
725: $uhome=&Apache::lonnet::homeserver($uname,$udom);
726: if ($uhome eq 'no_host') {
727: $message=
728: "<font color=red>Unknown user '$uname' at domain '$udom'</font>";
729: $uname='';
1.12 www 730: } else {
1.103 albertel 731: $csec=&Apache::lonnet::getsection($udom,$uname,
732: $ENV{'request.course.id'});
1.43 albertel 733: if ($csec eq '-1') {
734: $message="<font color=red>".
1.45 matthew 735: "User '$uname' at domain '$udom' not ".
736: "in this course</font>";
1.43 albertel 737: $uname='';
738: $csec=$ENV{'form.csec'};
739: } else {
740: my %name=&Apache::lonnet::userenvironment($udom,$uname,
741: ('firstname','middlename','lastname','generation','id'));
742: $message="\n<p>\nFull Name: ".
743: $name{'firstname'}.' '.$name{'middlename'}.' '
744: .$name{'lastname'}.' '.$name{'generation'}.
745: "<br>\nID: ".$name{'id'}.'<p>';
746: }
1.12 www 747: }
1.43 albertel 748: }
1.2 www 749:
1.43 albertel 750: unless ($csec) { $csec=''; }
1.12 www 751:
1.44 albertel 752: my $fcat=$ENV{'form.fcat'};
1.43 albertel 753: unless ($fcat) { $fcat=''; }
1.2 www 754:
755: # ------------------------------------------------------------------- Tie hashs
1.44 albertel 756: if (!(tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
1.58 albertel 757: &GDBM_READER(),0640))) {
1.44 albertel 758: $r->print("Unable to access course data. (File $ENV{'request.course.fn'}.db not tieable)");
759: return ;
760: }
761: if (!(tie(%parmhash,'GDBM_File',
1.58 albertel 762: $ENV{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {
1.44 albertel 763: $r->print("Unable to access parameter data. (File $ENV{'request.course.fn'}_parms.db not tieable)");
764: return ;
765: }
1.63 bowersj2 766:
1.14 www 767: # --------------------------------------------------------- Get all assessments
1.82 www 768: extractResourceInformation(\%bighash, \@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles);
1.63 bowersj2 769:
1.57 albertel 770: $mapp{'0.0'} = '';
771: $symbp{'0.0'} = '';
1.99 albertel 772:
1.14 www 773: # ---------------------------------------------------------- Anything to store?
1.44 albertel 774: if ($ENV{'form.pres_marker'}) {
775: my ($sresid,$spnam,$snum)=split(/\&/,$ENV{'form.pres_marker'});
776: $spnam=~s/\_([^\_]+)$/\.$1/;
1.15 www 777: # ---------------------------------------------------------- Construct prefixes
1.14 www 778:
1.44 albertel 779: my $symbparm=$symbp{$sresid}.'.'.$spnam;
780: my $mapparm=$mapp{$sresid}.'___(all).'.$spnam;
781:
782: my $seclevel=$ENV{'request.course.id'}.'.['.$csec.'].'.$spnam;
783: my $seclevelr=$ENV{'request.course.id'}.'.['.$csec.'].'.$symbparm;
784: my $seclevelm=$ENV{'request.course.id'}.'.['.$csec.'].'.$mapparm;
785:
786: my $courselevel=$ENV{'request.course.id'}.'.'.$spnam;
787: my $courselevelr=$ENV{'request.course.id'}.'.'.$symbparm;
788: my $courselevelm=$ENV{'request.course.id'}.'.'.$mapparm;
789:
790: my $storeunder='';
791: if (($snum==9) || ($snum==3)) { $storeunder=$courselevel; }
792: if (($snum==8) || ($snum==2)) { $storeunder=$courselevelm; }
793: if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
794: if ($snum==6) { $storeunder=$seclevel; }
795: if ($snum==5) { $storeunder=$seclevelm; }
796: if ($snum==4) { $storeunder=$seclevelr; }
797:
1.79 albertel 798: my $delete;
799: if ($ENV{'form.pres_value'} eq '') { $delete=1;}
1.66 www 800: my %storecontent = ($storeunder => $ENV{'form.pres_value'},
801: $storeunder.'.type' => $ENV{'form.pres_type'});
1.44 albertel 802: my $reply='';
803: if ($snum>3) {
1.14 www 804: # ---------------------------------------------------------------- Store Course
1.24 www 805: #
806: # Expire sheets
1.44 albertel 807: &Apache::lonnet::expirespread('','','studentcalc');
808: if (($snum==7) || ($snum==4)) {
809: &Apache::lonnet::expirespread('','','assesscalc',$symbp{$sresid});
810: } elsif (($snum==8) || ($snum==5)) {
811: &Apache::lonnet::expirespread('','','assesscalc',$mapp{$sresid});
812: } else {
813: &Apache::lonnet::expirespread('','','assesscalc');
814: }
1.24 www 815: # Store parameter
1.79 albertel 816: if ($delete) {
817: $reply=&Apache::lonnet::del
818: ('resourcedata',[keys(%storecontent)],
819: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
820: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
821: } else {
822: $reply=&Apache::lonnet::cput
823: ('resourcedata',\%storecontent,
824: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
825: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
826: }
1.44 albertel 827: } else {
1.14 www 828: # ------------------------------------------------------------------ Store User
1.24 www 829: #
830: # Expire sheets
1.44 albertel 831: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
832: if ($snum==1) {
833: &Apache::lonnet::expirespread
834: ($uname,$udom,'assesscalc',$symbp{$sresid});
835: } elsif ($snum==2) {
836: &Apache::lonnet::expirespread
837: ($uname,$udom,'assesscalc',$mapp{$sresid});
838: } else {
839: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
840: }
1.24 www 841: # Store parameter
1.79 albertel 842: if ($delete) {
843: $reply=&Apache::lonnet::del
844: ('resourcedata',[keys(%storecontent)],$udom,$uname);
845: } else {
846: $reply=&Apache::lonnet::cput
847: ('resourcedata',\%storecontent,$udom,$uname);
848: }
1.44 albertel 849: }
1.15 www 850:
1.44 albertel 851: if ($reply=~/^error\:(.*)/) {
852: $message.="<font color=red>Write Error: $1</font>";
853: }
1.68 www 854: # ---------------------------------------------------------------- Done storing
1.80 www 855: $message.='<h3>Changes can take up to 10 minutes before being active for all students</h3>';
1.68 www 856: }
1.67 www 857: # --------------------------------------------- Devalidate cache for this child
1.109 albertel 858: &Apache::lonnet::devalidatecourseresdata(
1.67 www 859: $ENV{'course.'.$ENV{'request.course.id'}.'.num'},
860: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'});
1.109 albertel 861: &Apache::lonnet::clear_EXT_cache_status();
1.2 www 862: # -------------------------------------------------------------- Get coursedata
1.45 matthew 863: %courseopt = &Apache::lonnet::dump
864: ('resourcedata',
865: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
866: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
1.44 albertel 867: # --------------------------------------------------- Get userdata (if present)
868: if ($uname) {
1.45 matthew 869: %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);
1.44 albertel 870: }
1.14 www 871:
1.2 www 872: # ------------------------------------------------------------------- Sort this
1.17 www 873:
1.44 albertel 874: @ids=sort {
875: if ($fcat eq '') {
876: $a<=>$b;
877: } else {
878: my ($result,@outpar)=&parmval($fcat,$a,$defp{$a});
879: my $aparm=$outpar[$result];
880: ($result,@outpar)=&parmval($fcat,$b,$defp{$b});
881: my $bparm=$outpar[$result];
882: 1*$aparm<=>1*$bparm;
883: }
884: } @ids;
1.57 albertel 885: #----------------------------------------------- if all selected, fill in array
886: if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
887: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 888: # ------------------------------------------------------------------ Start page
1.63 bowersj2 889:
1.99 albertel 890: my $have_assesments=1;
891: if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }
892:
893: &startpage($r,$id,$udom,$csec,$uname,$have_assesments);
894:
1.112 ! albertel 895: if (!$have_assesments) {
! 896: untie(%bighash);
! 897: untie(%parmhash);
! 898: return '';
! 899: }
1.44 albertel 900: # if ($ENV{'form.url'}) {
901: # $r->print('<input type="hidden" value="'.$ENV{'form.url'}.
902: # '" name="url"><input type="hidden" name="command" value="set">');
903: # }
1.57 albertel 904: $r->print('<input type="hidden" value="true" name="prevvisit">');
905:
1.44 albertel 906: foreach ('tolerance','date_default','date_start','date_end',
907: 'date_interval','int','float','string') {
908: $r->print('<input type="hidden" value="'.
909: $ENV{'form.recent_'.$_}.'" name="recent_'.$_.'">');
910: }
911:
1.57 albertel 912: $r->print('<h2>'.$message.'</h2><table>');
913:
914: my $submitmessage;
1.44 albertel 915: if (!$pssymb) {
1.101 www 916: $r->print('<tr><td>Select Parameter Level</td><td colspan="2">');
1.57 albertel 917: $r->print('<select name="parmlev">');
918: foreach (reverse sort keys %alllevs) {
919: $r->print('<option value="'.$alllevs{$_}.'"');
920: if ($parmlev eq $alllevs{$_}) {
921: $r->print(' selected');
922: }
923: $r->print('>'.$_.'</option>');
924: }
925: $r->print("</select></td>\n");
926:
1.101 www 927: $r->print('</tr>');
1.57 albertel 928:
1.82 www 929: $r->print('<tr><td>Select Enclosing Map or Folder</td>');
1.57 albertel 930: $r->print('<td colspan="2"><select name="pschp">');
1.82 www 931: $r->print('<option value="all">All Maps or Folders</option>');
1.57 albertel 932: foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
933: $r->print('<option value="'.$_.'"');
934: if (($pschp eq $_)) { $r->print(' selected'); }
1.82 www 935: $r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').'</option>');
1.57 albertel 936: }
937: $r->print("</select></td></tr>\n");
1.44 albertel 938: } else {
1.57 albertel 939: my ($map,$id,$resource)=split(/___/,$pssymb);
940: $r->print("<tr><td>Specific Resource</td><td>$resource</td>");
941: $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
942: $r->print('</tr>');
943: $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
944: }
945:
946: $r->print('<tr><td colspan="3"><hr /><input type="checkbox"');
947: if ($showoptions eq 'show') {$r->print(" checked ");}
1.101 www 948: $r->print(' name="showoptions" value="show">Show More Options<hr /></td></tr>');
1.57 albertel 949: # $r->print("<tr><td>Show: $showoptions</td></tr>");
950: # $r->print("<tr><td>pscat: @pscat</td></tr>");
951: # $r->print("<tr><td>psprt: @psprt</td></tr>");
952: # $r->print("<tr><td>fcat: $fcat</td></tr>");
953:
954: if ($showoptions eq 'show') {
955: my $tempkey;
956:
957: $r->print('<tr><td colspan="3" align="center">Select Parameters to View</td></tr>');
958:
959: $r->print('<tr><td colspan="2"><table>');
960: $r->print('<tr><td><input type="checkbox" name="pscat" value="all"');
961: $r->print(' checked') unless (@pscat);
962: $r->print('>All Parameters</td>');
963:
964: my $cnt=0;
965: foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
966: keys %allparms ) {
967: ++$cnt;
968: $r->print('</tr><tr>') unless ($cnt%2);
969: $r->print('<td><input type="checkbox" name="pscat" ');
970: $r->print('value="'.$tempkey.'"');
971: if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
972: $r->print(' checked');
973: }
974: $r->print('>'.$allparms{$tempkey}.'</td>');
975: }
976: $r->print('</tr></table>');
977:
978: # $r->print('<tr><td>Select Parts</td><td>');
979: $r->print('<td><select multiple name="psprt" size="5">');
980: $r->print('<option value="all"');
981: $r->print(' selected') unless (@psprt);
982: $r->print('>All Parts</option>');
1.76 www 983: my %temphash=();
984: foreach (@psprt) { $temphash{$_}=1; }
1.57 albertel 985: foreach $tempkey (sort keys %allparts) {
986: unless ($tempkey =~ /\./) {
987: $r->print('<option value="'.$tempkey.'"');
1.76 www 988: if ($psprt[0] eq "all" || $temphash{$tempkey}) {
1.57 albertel 989: $r->print(' selected');
990: }
991: $r->print('>'.$allparts{$tempkey}.'</option>');
992: }
993: }
994: $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
995:
996: $r->print('<tr><td>Sort list by</td><td>');
997: $r->print('<select name="fcat">');
1.82 www 998: $r->print('<option value="">Enclosing Map or Folder</option>');
1.57 albertel 999: foreach (sort keys %allkeys) {
1000: $r->print('<option value="'.$_.'"');
1001: if ($fcat eq $_) { $r->print(' selected'); }
1002: $r->print('>'.$allkeys{$_}.'</option>');
1003: }
1004: $r->print('</select></td>');
1005:
1006: $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
1007:
1008: } else { # hide options - include any necessary extras here
1009:
1010: $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
1011:
1012: unless (@pscat) {
1013: foreach (keys %allparms ) {
1014: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1015: }
1016: } else {
1017: foreach (@pscat) {
1018: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1019: }
1020: }
1021:
1022: unless (@psprt) {
1023: foreach (keys %allparts ) {
1024: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1025: }
1026: } else {
1027: foreach (@psprt) {
1028: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1029: }
1030: }
1031:
1.44 albertel 1032: }
1.101 www 1033: $r->print('</table><br />');
1034: if (($prevvisit) || ($pschp) || ($pssymb)) {
1035: $submitmessage = "Update Course Assessment Parameter Display";
1036: } else {
1037: $submitmessage = "Set Course Assessment Parameters";
1038: }
1039: $r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
1.57 albertel 1040:
1.76 www 1041: # my @temp_psprt;
1042: # foreach my $t (@psprt) {
1043: # push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
1044: # }
1.57 albertel 1045:
1.76 www 1046: # @psprt = @temp_psprt;
1.57 albertel 1047:
1048: my @temp_pscat;
1049: map {
1050: my $cat = $_;
1051: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1052: } @pscat;
1053:
1054: @pscat = @temp_pscat;
1055:
1056: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.10 www 1057: # ----------------------------------------------------------------- Start Table
1.57 albertel 1058: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1059: my $csuname=$ENV{'user.name'};
1060: my $csudom=$ENV{'user.domain'};
1061:
1062: if ($parmlev eq 'full' || $parmlev eq 'brief') {
1063: my $coursespan=$csec?8:5;
1064: $r->print('<p><table border=2>');
1065: $r->print('<tr><td colspan=5></td>');
1066: $r->print('<th colspan='.($coursespan).'>Any User</th>');
1067: if ($uname) {
1068: $r->print("<th colspan=3 rowspan=2>");
1069: $r->print("User $uname at Domain $udom</th>");
1070: }
1071: $r->print(<<ENDTABLETWO);
1.33 www 1072: <th rowspan=3>Parameter in Effect</th>
1073: <th rowspan=3>Current Session Value<br>($csuname at $csudom)</th>
1.57 albertel 1074: </tr><tr><td colspan=5></td><th colspan=2>Resource Level</th>
1.10 www 1075: <th colspan=3>in Course</th>
1076: ENDTABLETWO
1.57 albertel 1077: if ($csec) {
1078: $r->print("<th colspan=3>in Section/Group $csec</th>");
1079: }
1080: $r->print(<<ENDTABLEHEADFOUR);
1.11 www 1081: </tr><tr><th>Assessment URL and Title</th><th>Type</th>
1.102 albertel 1082: <th>Enclosing Map or Folder</th><th>Part</th><th>Parameter Name</th>
1.82 www 1083: <th>default</th><th>from Enclosing Map or Folder</th>
1084: <th>general</th><th>for Enclosing Map or Folder</th><th>for Resource</th>
1.10 www 1085: ENDTABLEHEADFOUR
1.57 albertel 1086:
1087: if ($csec) {
1.82 www 1088: $r->print('<th>general</th><th>for Enclosing Map or Folder</th><th>for Resource</th>');
1.57 albertel 1089: }
1090:
1091: if ($uname) {
1.82 www 1092: $r->print('<th>general</th><th>for Enclosing Map or Folder</th><th>for Resource</th>');
1.57 albertel 1093: }
1094:
1095: $r->print('</tr>');
1096:
1097: my $defbgone='';
1098: my $defbgtwo='';
1099:
1100: foreach (@ids) {
1101:
1102: my $rid=$_;
1103: my ($inmapid)=($rid=~/\.(\d+)$/);
1104:
1105: if (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}) ||
1106: ($pssymb eq $symbp{$rid})) {
1.4 www 1107: # ------------------------------------------------------ Entry for one resource
1.57 albertel 1108: if ($defbgone eq '"E0E099"') {
1109: $defbgone='"E0E0DD"';
1110: } else {
1111: $defbgone='"E0E099"';
1112: }
1113: if ($defbgtwo eq '"FFFF99"') {
1114: $defbgtwo='"FFFFDD"';
1115: } else {
1116: $defbgtwo='"FFFF99"';
1117: }
1118: my $thistitle='';
1119: my %name= ();
1120: undef %name;
1121: my %part= ();
1122: my %display=();
1123: my %type= ();
1124: my %default=();
1125: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1126:
1127: foreach (split(/\,/,$keyp{$rid})) {
1128: my $tempkeyp = $_;
1129: if (grep $_ eq $tempkeyp, @catmarker) {
1130: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1131: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1132: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1133: unless ($display{$_}) { $display{$_}=''; }
1134: $display{$_}.=' ('.$name{$_}.')';
1135: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1136: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1137: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1138: }
1139: }
1140: my $totalparms=scalar keys %name;
1141: if ($totalparms>0) {
1142: my $firstrow=1;
1143:
1144: $r->print('<tr><td bgcolor='.$defbgone.
1145: ' rowspan='.$totalparms.
1146: '><tt><font size=-1>'.
1147: join(' / ',split(/\//,$uri)).
1148: '</font></tt><p><b>'.
1149: "<a href=\"javascript:openWindow('/res/".$uri.
1150: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1151: " TARGET=_self>$bighash{'title_'.$rid}");
1152:
1153: if ($thistitle) {
1154: $r->print(' ('.$thistitle.')');
1155: }
1156: $r->print('</a></b></td>');
1157: $r->print('<td bgcolor='.$defbgtwo.
1158: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1159: '</td>');
1160:
1161: $r->print('<td bgcolor='.$defbgone.
1162: ' rowspan='.$totalparms.
1163: '><tt><font size=-1>');
1164:
1165: $r->print(' / res / ');
1166: $r->print(join(' / ', split(/\//,$mapp{$rid})));
1167:
1168: $r->print('</font></tt></td>');
1169:
1170: foreach (sort keys %name) {
1171: unless ($firstrow) {
1172: $r->print('<tr>');
1173: } else {
1174: undef $firstrow;
1175: }
1176:
1177: &print_row($r,$_,\%part,\%name,$rid,\%default,
1178: \%type,\%display,$defbgone,$defbgtwo,
1179: $parmlev);
1180: }
1181: }
1182: }
1183: } # end foreach ids
1.43 albertel 1184: # -------------------------------------------------- End entry for one resource
1.57 albertel 1185: $r->print('</table>');
1186: } # end of brief/full
1187: #--------------------------------------------------- Entry for parm level map
1188: if ($parmlev eq 'map') {
1189: my $defbgone = '"E0E099"';
1190: my $defbgtwo = '"FFFF99"';
1191:
1192: my %maplist;
1193:
1194: if ($pschp eq 'all') {
1195: %maplist = %allmaps;
1196: } else {
1197: %maplist = ($pschp => $mapp{$pschp});
1198: }
1199:
1200: #-------------------------------------------- for each map, gather information
1201: my $mapid;
1.60 albertel 1202: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1203: my $maptitle = $maplist{$mapid};
1.57 albertel 1204:
1205: #----------------------- loop through ids and get all parameter types for map
1206: #----------------------------------------- and associated information
1207: my %name = ();
1208: my %part = ();
1209: my %display = ();
1210: my %type = ();
1211: my %default = ();
1212: my $map = 0;
1213:
1214: # $r->print("Catmarker: @catmarker<br />\n");
1215:
1216: foreach (@ids) {
1217: ($map)=(/([\d]*?)\./);
1218: my $rid = $_;
1219:
1220: # $r->print("$mapid:$map: $rid <br /> \n");
1221:
1222: if ($map eq $mapid) {
1223: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1224: # $r->print("Keys: $keyp{$rid} <br />\n");
1225:
1226: #--------------------------------------------------------------------
1227: # @catmarker contains list of all possible parameters including part #s
1228: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1229: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1230: # When storing information, store as part 0
1231: # When requesting information, request from full part
1232: #-------------------------------------------------------------------
1233: foreach (split(/\,/,$keyp{$rid})) {
1234: my $tempkeyp = $_;
1235: my $fullkeyp = $tempkeyp;
1.73 albertel 1236: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1237:
1238: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1239: $part{$tempkeyp}="0";
1240: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1241: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1242: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1243: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1244: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1245: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1246: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1247: }
1248: } # end loop through keys
1249: }
1250: } # end loop through ids
1251:
1252: #---------------------------------------------------- print header information
1.82 www 1253: my $foldermap=($maptitle=~/^uploaded/?'Folder':'Map');
1254: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1255: $r->print(<<ENDMAPONE);
1256: <center><h4>
1.82 www 1257: <font color="red">Set Defaults for All Resources in $foldermap<br />
1258: <i>$showtitle</i><br />
1.57 albertel 1259: Specifically for
1260: ENDMAPONE
1261: if ($uname) {
1262: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1263: ('firstname','middlename','lastname','generation', 'id'));
1264: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1265: .$name{'lastname'}.' '.$name{'generation'};
1266: $r->print("User <i>$uname \($person\) </i> in \n");
1267: } else {
1268: $r->print("<i>all</i> users in \n");
1269: }
1270:
1271: if ($csec) {$r->print("Section <i>$csec</i> of \n")};
1272:
1273: $r->print("<i>$coursename</i><br />");
1274: $r->print("</font></h4>\n");
1275: #---------------------------------------------------------------- print table
1276: $r->print('<p><table border="2">');
1277: $r->print('<tr><th>Parameter Name</th>');
1278: $r->print('<th>Default Value</th>');
1279: $r->print('<th>Parameter in Effect</th></tr>');
1280:
1281: foreach (sort keys %name) {
1282: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1283: \%type,\%display,$defbgone,$defbgtwo,
1284: $parmlev);
1285: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1286: }
1287: $r->print("</table></center>");
1288: } # end each map
1289: } # end of $parmlev eq map
1290: #--------------------------------- Entry for parm level general (Course level)
1291: if ($parmlev eq 'general') {
1292: my $defbgone = '"E0E099"';
1293: my $defbgtwo = '"FFFF99"';
1294:
1295: #-------------------------------------------- for each map, gather information
1296: my $mapid="0.0";
1297: #----------------------- loop through ids and get all parameter types for map
1298: #----------------------------------------- and associated information
1299: my %name = ();
1300: my %part = ();
1301: my %display = ();
1302: my %type = ();
1303: my %default = ();
1304:
1305: foreach (@ids) {
1306: my $rid = $_;
1307:
1308: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1309:
1310: #--------------------------------------------------------------------
1311: # @catmarker contains list of all possible parameters including part #s
1312: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1313: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1314: # When storing information, store as part 0
1315: # When requesting information, request from full part
1316: #-------------------------------------------------------------------
1317: foreach (split(/\,/,$keyp{$rid})) {
1318: my $tempkeyp = $_;
1319: my $fullkeyp = $tempkeyp;
1.73 albertel 1320: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1321: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1322: $part{$tempkeyp}="0";
1323: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1324: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1325: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1326: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1327: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1328: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1329: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1330: }
1331: } # end loop through keys
1332: } # end loop through ids
1333:
1334: #---------------------------------------------------- print header information
1335: $r->print(<<ENDMAPONE);
1336: <center><h4>
1337: <font color="red">Set Defaults for All Resources in Course
1338: <i>$coursename</i><br />
1339: ENDMAPONE
1340: if ($uname) {
1341: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1342: ('firstname','middlename','lastname','generation', 'id'));
1343: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1344: .$name{'lastname'}.' '.$name{'generation'};
1345: $r->print(" User <i>$uname \($person\) </i> \n");
1346: } else {
1347: $r->print("<i>ALL</i> USERS \n");
1348: }
1349:
1350: if ($csec) {$r->print("Section <i>$csec</i>\n")};
1351: $r->print("</font></h4>\n");
1352: #---------------------------------------------------------------- print table
1353: $r->print('<p><table border="2">');
1354: $r->print('<tr><th>Parameter Name</th>');
1355: $r->print('<th>Default Value</th>');
1356: $r->print('<th>Parameter in Effect</th></tr>');
1357:
1358: foreach (sort keys %name) {
1359: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1360: \%type,\%display,$defbgone,$defbgtwo,$parmlev);
1361: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1362: }
1363: $r->print("</table></center>");
1364: } # end of $parmlev eq general
1.43 albertel 1365: }
1.44 albertel 1366: $r->print('</form></body></html>');
1367: untie(%bighash);
1368: untie(%parmhash);
1.57 albertel 1369: } # end sub assessparms
1.30 www 1370:
1.59 matthew 1371:
1372: ##################################################
1373: ##################################################
1374:
1375: =pod
1376:
1377: =item crsenv
1378:
1.105 matthew 1379: Show and set course data and parameters. This is a large routine that should
1.59 matthew 1380: be simplified and shortened... someday.
1381:
1382: Inputs: $r
1383:
1384: Returns: nothing
1385:
1386: =cut
1387:
1388: ##################################################
1389: ##################################################
1.30 www 1390: sub crsenv {
1391: my $r=shift;
1392: my $setoutput='';
1.64 www 1393: my $bodytag=&Apache::loncommon::bodytag(
1394: 'Set Course Environment Parameters');
1.45 matthew 1395: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1396: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1.105 matthew 1397:
1398: #
1399: # Go through list of changes
1.38 harris41 1400: foreach (keys %ENV) {
1.105 matthew 1401: next if ($_!~/^form\.(.+)\_setparmval$/);
1402: my $name = $1;
1403: my $value = $ENV{'form.'.$name.'_value'};
1404: if ($name eq 'newp') {
1405: $name = $ENV{'form.newp_name'};
1406: }
1407: if ($name eq 'url') {
1408: $value=~s/^\/res\///;
1409: my $bkuptime=time;
1410: my @tmp = &Apache::lonnet::get
1411: ('environment',['url'],$dom,$crs);
1412: $setoutput.='Backing up previous URL: '.
1413: &Apache::lonnet::put
1414: ('environment',
1415: {'top level map backup '.$bkuptime => $tmp[1] },
1416: $dom,$crs).
1417: '<br>';
1418: }
1419: #
1420: # Deal with modified default spreadsheets
1421: if ($name =~ /^spreadsheet_default_(classcalc|
1422: studentcalc|
1423: assesscalc)$/x) {
1424: my $sheettype = $1;
1425: if ($sheettype eq 'classcalc') {
1426: # no need to do anything since viewing the sheet will
1427: # cause it to be updated.
1428: } elsif ($sheettype eq 'studentcalc') {
1429: # expire all the student spreadsheets
1430: &Apache::lonnet::expirespread('','','studentcalc');
1431: } else {
1432: # expire all the assessment spreadsheets
1433: # this includes non-default spreadsheets, but better to
1434: # be safe than sorry.
1435: &Apache::lonnet::expirespread('','','assesscalc');
1436: # expire all the student spreadsheets
1437: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 1438: }
1.105 matthew 1439: }
1440: #
1.107 matthew 1441: # Deal with the enrollment dates
1442: if ($name =~ /^default_enrollment_(start|end)_date$/) {
1443: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
1444: }
1445: #
1.105 matthew 1446: # Let the user know we made the changes
1447: if ($name) {
1448: my $put_result = &Apache::lonnet::put('environment',
1449: {$name=>$value},$dom,$crs);
1450: if ($put_result eq 'ok') {
1451: $setoutput.='Set <b>'.$name.'</b> to <b>'.$value.'</b>.<br />';
1452: } else {
1453: $setoutput.='Unable to set <b>'.$name.'</b> to '.
1454: '<b>'.$value.'</b> due to '.$put_result.'.<br />';
1.30 www 1455: }
1456: }
1.38 harris41 1457: }
1.108 www 1458: # ------------------------- Re-init course environment entries for this session
1459:
1460: &Apache::lonnet::coursedescription($ENV{'request.course.id'});
1.105 matthew 1461:
1.30 www 1462: # -------------------------------------------------------- Get parameters again
1.45 matthew 1463:
1464: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.30 www 1465: my $output='';
1.45 matthew 1466: if (! exists($values{'con_lost'})) {
1.30 www 1467: my %descriptions=
1.47 matthew 1468: ('url' => '<b>Top Level Map</b> '.
1.46 matthew 1469: '<a href="javascript:openbrowser'.
1.47 matthew 1470: "('envform','url','sequence')\">".
1.100 www 1471: 'Select Map</a><br /><font color=red> '.
1.45 matthew 1472: 'Modification may make assessment data '.
1473: 'inaccessible</font>',
1474: 'description' => '<b>Course Description</b>',
1.75 albertel 1475: 'courseid' => '<b>Course ID or number</b><br />'.
1.45 matthew 1476: '(internal, optional)',
1.52 www 1477: 'default_xml_style' => '<b>Default XML Style File</b> '.
1478: '<a href="javascript:openbrowser'.
1479: "('envform','default_xml_style'".
1.100 www 1480: ",'sty')\">Select Style File</a><br>",
1.74 www 1481: 'question.email' => '<b>Feedback Addresses for Resource Content '.
1.75 albertel 1482: 'Questions</b><br />(<tt>user:domain,'.
1.74 www 1483: 'user:domain(section;section;...;*;...),...</tt>)',
1.75 albertel 1484: 'comment.email' => '<b>Feedback Addresses for Course Content Comments</b><br />'.
1.74 www 1485: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.45 matthew 1486: 'policy.email' => '<b>Feedback Addresses for Course Policy</b>'.
1.75 albertel 1487: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1488: 'hideemptyrows' => '<b>Hide Empty Rows in Spreadsheets</b><br />'.
1.45 matthew 1489: '("<tt>yes</tt>" for default hiding)',
1.75 albertel 1490: 'pageseparators' => '<b>Visibly Separate Items on Pages</b><br />'.
1.93 bowersj2 1491: '("<tt>yes</tt>" for visible separation, '.
1492: 'changes will not show until next login)',
1.45 matthew 1493: 'pch.roles.denied'=> '<b>Disallow Resource Discussion for '.
1.75 albertel 1494: 'Roles</b><br />"<tt>st</tt>": '.
1.61 albertel 1495: 'student, "<tt>ta</tt>": '.
1496: 'TA, "<tt>in</tt>": '.
1.75 albertel 1497: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 1498: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 1499: 'pch.users.denied' =>
1.75 albertel 1500: '<b>Disallow Resource Discussion for Users</b><br />'.
1.53 www 1501: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 1502: 'spreadsheet_default_classcalc'
1.52 www 1503: => '<b>Default Course Spreadsheet</b> '.
1.50 matthew 1504: '<a href="javascript:openbrowser'.
1505: "('envform','spreadsheet_default_classcalc'".
1.100 www 1506: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.49 matthew 1507: 'spreadsheet_default_studentcalc'
1.52 www 1508: => '<b>Default Student Spreadsheet</b> '.
1.50 matthew 1509: '<a href="javascript:openbrowser'.
1510: "('envform','spreadsheet_default_calc'".
1.100 www 1511: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.49 matthew 1512: 'spreadsheet_default_assesscalc'
1.52 www 1513: => '<b>Default Assessment Spreadsheet</b> '.
1.50 matthew 1514: '<a href="javascript:openbrowser'.
1515: "('envform','spreadsheet_default_assesscalc'".
1.100 www 1516: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.75 albertel 1517: 'allow_limited_html_in_feedback'
1518: => '<b>Allow limited HTML in discussion posts</b><br />'.
1.108 www 1519: '(Set value to "<tt>yes</tt>" to allow)',
1.89 albertel 1520: 'rndseed'
1.90 albertel 1521: => '<b>Randomization algorithm used</b> <br />'.
1.89 albertel 1522: '<font color="red">Modifying this will make problems '.
1.94 sakharuk 1523: 'have different numbers and answers</font>',
1.110 sakharuk 1524: 'problem_split'
1.104 matthew 1525: => '<b>Allow problems to be split over pages</b><br />'.
1.110 sakharuk 1526: ' ("<tt>yes</tt>" if allowed, anything else if not)',,
1.111 sakharuk 1527: 'anonymous_quiz'
1.110 sakharuk 1528: => '<b>Anonimous quiz/exam</b><br />'.
1529: ' (<tt><b>yes</b> to avoid print students names </tt>)',
1.108 www 1530: 'default_enrollment_start_date' => '<b>Default beginning date '.
1531: 'when enrolling students</b>',
1532: 'default_enrollment_end_date' => '<b>Default ending date '.
1533: 'when enrolling students</b>',
1534: 'languages' => '<b>Languages used</b>'
1.107 matthew 1535: );
1536: my @Display_Order = ('url','description','courseid',
1537: 'default_xml_style','pageseparators',
1538: 'question.email','comment.email','policy.email',
1539: 'pch.roles.denied','pch.users.denied',
1540: 'allow_limited_html_in_feedback',
1.108 www 1541: 'languages',
1.107 matthew 1542: 'rndseed',
1543: 'problem_stream_switch',
1544: 'spreadsheet_default_classcalc',
1545: 'spreadsheet_default_studentcalc',
1546: 'spreadsheet_default_assesscalc',
1547: 'hideemptyrows',
1548: 'default_enrollment_start_date',
1549: 'default_enrollment_end_date',
1550: );
1551: foreach my $parameter (sort(keys(%values))) {
1552: if (! $descriptions{$parameter}) {
1553: $descriptions{$parameter}=$parameter;
1554: push(@Display_Order,$parameter);
1.43 albertel 1555: }
1556: }
1.107 matthew 1557: foreach my $parameter (@Display_Order) {
1558: my $description = $descriptions{$parameter};
1.51 matthew 1559: # onchange is javascript to automatically check the 'Set' button.
1.69 www 1560: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 1561: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 1562: '.checked=true;"';
1.107 matthew 1563: $output .= '<tr><td>'.$description.'</td>';
1564: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
1565: $output .= '<td>'.
1566: &Apache::lonhtmlcommon::date_setter('envform',
1567: $parameter.'_value',
1568: $values{$parameter},
1569: $onchange).
1570: '</td>';
1571: } else {
1572: $output .= '<td>'.
1573: &Apache::lonhtmlcommon::textbox($parameter.'_value',
1574: $values{$parameter},
1575: 40,$onchange).'</td>';
1576: }
1577: $output .= '<td>'.
1578: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
1579: '</td>';
1580: $output .= "</tr>\n";
1.51 matthew 1581: }
1.69 www 1582: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 1583: '[\'envform\'].elements[\'newp_setparmval\']'.
1584: '.checked=true;"';
1585: $output.='<tr><td><i>Create New Environment Variable</i><br />'.
1586: '<input type="text" size=40 name="newp_name" '.
1587: $onchange.' /></td><td>'.
1588: '<input type="text" size=40 name="newp_value" '.
1589: $onchange.' /></td><td>'.
1590: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 1591: }
1.30 www 1592: $r->print(<<ENDENV);
1593: <html>
1.46 matthew 1594: <script type="text/javascript" language="Javascript" >
1595: var editbrowser;
1.47 matthew 1596: function openbrowser(formname,elementname,only,omit) {
1.46 matthew 1597: var url = '/res/?';
1598: if (editbrowser == null) {
1599: url += 'launch=1&';
1600: }
1601: url += 'catalogmode=interactive&';
1602: url += 'mode=parmset&';
1603: url += 'form=' + formname + '&';
1.47 matthew 1604: if (only != null) {
1605: url += 'only=' + only + '&';
1606: }
1607: if (omit != null) {
1608: url += 'omit=' + omit + '&';
1609: }
1.46 matthew 1610: url += 'element=' + elementname + '';
1611: var title = 'Browser';
1612: var options = 'scrollbars=1,resizable=1,menubar=0';
1613: options += ',width=700,height=600';
1614: editbrowser = open(url,title,options,'1');
1615: editbrowser.focus();
1616: }
1617: </script>
1.30 www 1618: <head>
1619: <title>LON-CAPA Course Environment</title>
1620: </head>
1.64 www 1621: $bodytag
1.30 www 1622: <form method="post" action="/adm/parmset" name="envform">
1623: $setoutput
1624: <p>
1625: <table border=2>
1626: <tr><th>Parameter</th><th>Value</th><th>Set?</th></tr>
1627: $output
1628: </table>
1629: <input type="submit" name="crsenv" value="Set Course Environment">
1630: </form>
1631: </body>
1632: </html>
1633: ENDENV
1634: }
1635:
1.59 matthew 1636: ##################################################
1637: ##################################################
1.30 www 1638:
1.59 matthew 1639: =pod
1640:
1.83 bowersj2 1641: =item * handler
1.59 matthew 1642:
1643: Main handler. Calls &assessparms and &crsenv subroutines.
1644:
1645: =cut
1646:
1647: ##################################################
1648: ##################################################
1.85 bowersj2 1649: use Data::Dumper;
1.30 www 1650: sub handler {
1.43 albertel 1651: my $r=shift;
1.30 www 1652:
1.43 albertel 1653: if ($r->header_only) {
1654: $r->content_type('text/html');
1655: $r->send_http_header;
1656: return OK;
1657: }
1658: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
1.83 bowersj2 1659:
1.30 www 1660: # ----------------------------------------------------- Needs to be in a course
1661:
1.43 albertel 1662: if (($ENV{'request.course.id'}) &&
1663: (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) {
1.106 www 1664:
1665: $r->content_type('text/html');
1666: $r->send_http_header;
1.57 albertel 1667:
1668: $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1.30 www 1669:
1.43 albertel 1670: unless (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) {
1.30 www 1671: # --------------------------------------------------------- Bring up assessment
1.43 albertel 1672: &assessparms($r);
1.30 www 1673: # ---------------------------------------------- This is for course environment
1.43 albertel 1674: } else {
1675: &crsenv($r);
1676: }
1677: } else {
1.1 www 1678: # ----------------------------- Not in a course, or not allowed to modify parms
1.43 albertel 1679: $ENV{'user.error.msg'}=
1680: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
1681: return HTTP_NOT_ACCEPTABLE;
1682: }
1683: return OK;
1.1 www 1684: }
1685:
1686: 1;
1687: __END__
1688:
1.59 matthew 1689: =pod
1.38 harris41 1690:
1691: =back
1692:
1693: =cut
1.1 www 1694:
1695:
1696:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>