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