Annotation of loncom/interface/lonparmset.pm, revision 1.127
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.127 ! albertel 4: # $Id: lonparmset.pm,v 1.126 2003/09/21 21:40:06 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.125 www 951: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.57 albertel 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;
1.127 ! albertel 1155: my $title=$bighash{'title_'.$rid};
! 1156: $title=~s/\:/:/g;
1.57 albertel 1157: $r->print('<tr><td bgcolor='.$defbgone.
1158: ' rowspan='.$totalparms.
1159: '><tt><font size=-1>'.
1160: join(' / ',split(/\//,$uri)).
1161: '</font></tt><p><b>'.
1162: "<a href=\"javascript:openWindow('/res/".$uri.
1163: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1.127 ! albertel 1164: " TARGET=_self>$title");
1.57 albertel 1165:
1166: if ($thistitle) {
1167: $r->print(' ('.$thistitle.')');
1168: }
1169: $r->print('</a></b></td>');
1170: $r->print('<td bgcolor='.$defbgtwo.
1171: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1172: '</td>');
1173:
1174: $r->print('<td bgcolor='.$defbgone.
1175: ' rowspan='.$totalparms.
1176: '><tt><font size=-1>');
1177:
1178: $r->print(' / res / ');
1179: $r->print(join(' / ', split(/\//,$mapp{$rid})));
1180:
1181: $r->print('</font></tt></td>');
1182:
1183: foreach (sort keys %name) {
1184: unless ($firstrow) {
1185: $r->print('<tr>');
1186: } else {
1187: undef $firstrow;
1188: }
1189:
1190: &print_row($r,$_,\%part,\%name,$rid,\%default,
1191: \%type,\%display,$defbgone,$defbgtwo,
1192: $parmlev);
1193: }
1194: }
1195: }
1196: } # end foreach ids
1.43 albertel 1197: # -------------------------------------------------- End entry for one resource
1.57 albertel 1198: $r->print('</table>');
1199: } # end of brief/full
1200: #--------------------------------------------------- Entry for parm level map
1201: if ($parmlev eq 'map') {
1202: my $defbgone = '"E0E099"';
1203: my $defbgtwo = '"FFFF99"';
1204:
1205: my %maplist;
1206:
1207: if ($pschp eq 'all') {
1208: %maplist = %allmaps;
1209: } else {
1210: %maplist = ($pschp => $mapp{$pschp});
1211: }
1212:
1213: #-------------------------------------------- for each map, gather information
1214: my $mapid;
1.60 albertel 1215: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1216: my $maptitle = $maplist{$mapid};
1.57 albertel 1217:
1218: #----------------------- loop through ids and get all parameter types for map
1219: #----------------------------------------- and associated information
1220: my %name = ();
1221: my %part = ();
1222: my %display = ();
1223: my %type = ();
1224: my %default = ();
1225: my $map = 0;
1226:
1227: # $r->print("Catmarker: @catmarker<br />\n");
1228:
1229: foreach (@ids) {
1230: ($map)=(/([\d]*?)\./);
1231: my $rid = $_;
1232:
1233: # $r->print("$mapid:$map: $rid <br /> \n");
1234:
1235: if ($map eq $mapid) {
1236: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1237: # $r->print("Keys: $keyp{$rid} <br />\n");
1238:
1239: #--------------------------------------------------------------------
1240: # @catmarker contains list of all possible parameters including part #s
1241: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1242: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1243: # When storing information, store as part 0
1244: # When requesting information, request from full part
1245: #-------------------------------------------------------------------
1246: foreach (split(/\,/,$keyp{$rid})) {
1247: my $tempkeyp = $_;
1248: my $fullkeyp = $tempkeyp;
1.73 albertel 1249: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1250:
1251: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1252: $part{$tempkeyp}="0";
1253: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1254: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1255: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1256: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1257: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1258: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1259: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1260: }
1261: } # end loop through keys
1262: }
1263: } # end loop through ids
1264:
1265: #---------------------------------------------------- print header information
1.82 www 1266: my $foldermap=($maptitle=~/^uploaded/?'Folder':'Map');
1267: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1268: $r->print(<<ENDMAPONE);
1269: <center><h4>
1.82 www 1270: <font color="red">Set Defaults for All Resources in $foldermap<br />
1271: <i>$showtitle</i><br />
1.57 albertel 1272: Specifically for
1273: ENDMAPONE
1274: if ($uname) {
1275: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1276: ('firstname','middlename','lastname','generation', 'id'));
1277: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1278: .$name{'lastname'}.' '.$name{'generation'};
1279: $r->print("User <i>$uname \($person\) </i> in \n");
1280: } else {
1281: $r->print("<i>all</i> users in \n");
1282: }
1283:
1284: if ($csec) {$r->print("Section <i>$csec</i> of \n")};
1285:
1286: $r->print("<i>$coursename</i><br />");
1287: $r->print("</font></h4>\n");
1288: #---------------------------------------------------------------- print table
1289: $r->print('<p><table border="2">');
1290: $r->print('<tr><th>Parameter Name</th>');
1291: $r->print('<th>Default Value</th>');
1292: $r->print('<th>Parameter in Effect</th></tr>');
1293:
1294: foreach (sort keys %name) {
1295: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1296: \%type,\%display,$defbgone,$defbgtwo,
1297: $parmlev);
1298: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1299: }
1300: $r->print("</table></center>");
1301: } # end each map
1302: } # end of $parmlev eq map
1303: #--------------------------------- Entry for parm level general (Course level)
1304: if ($parmlev eq 'general') {
1305: my $defbgone = '"E0E099"';
1306: my $defbgtwo = '"FFFF99"';
1307:
1308: #-------------------------------------------- for each map, gather information
1309: my $mapid="0.0";
1310: #----------------------- loop through ids and get all parameter types for map
1311: #----------------------------------------- and associated information
1312: my %name = ();
1313: my %part = ();
1314: my %display = ();
1315: my %type = ();
1316: my %default = ();
1317:
1318: foreach (@ids) {
1319: my $rid = $_;
1320:
1321: my $uri=&Apache::lonnet::declutter($bighash{'src_'.$rid});
1322:
1323: #--------------------------------------------------------------------
1324: # @catmarker contains list of all possible parameters including part #s
1325: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1326: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1327: # When storing information, store as part 0
1328: # When requesting information, request from full part
1329: #-------------------------------------------------------------------
1330: foreach (split(/\,/,$keyp{$rid})) {
1331: my $tempkeyp = $_;
1332: my $fullkeyp = $tempkeyp;
1.73 albertel 1333: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1334: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1335: $part{$tempkeyp}="0";
1336: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1337: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1338: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1339: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1340: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1341: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1342: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1343: }
1344: } # end loop through keys
1345: } # end loop through ids
1346:
1347: #---------------------------------------------------- print header information
1348: $r->print(<<ENDMAPONE);
1349: <center><h4>
1350: <font color="red">Set Defaults for All Resources in Course
1351: <i>$coursename</i><br />
1352: ENDMAPONE
1353: if ($uname) {
1354: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1355: ('firstname','middlename','lastname','generation', 'id'));
1356: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1357: .$name{'lastname'}.' '.$name{'generation'};
1358: $r->print(" User <i>$uname \($person\) </i> \n");
1359: } else {
1360: $r->print("<i>ALL</i> USERS \n");
1361: }
1362:
1363: if ($csec) {$r->print("Section <i>$csec</i>\n")};
1364: $r->print("</font></h4>\n");
1365: #---------------------------------------------------------------- print table
1366: $r->print('<p><table border="2">');
1367: $r->print('<tr><th>Parameter Name</th>');
1368: $r->print('<th>Default Value</th>');
1369: $r->print('<th>Parameter in Effect</th></tr>');
1370:
1371: foreach (sort keys %name) {
1372: &print_row($r,$_,\%part,\%name,$mapid,\%default,
1373: \%type,\%display,$defbgone,$defbgtwo,$parmlev);
1374: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1375: }
1376: $r->print("</table></center>");
1377: } # end of $parmlev eq general
1.43 albertel 1378: }
1.44 albertel 1379: $r->print('</form></body></html>');
1380: untie(%bighash);
1381: untie(%parmhash);
1.57 albertel 1382: } # end sub assessparms
1.30 www 1383:
1.59 matthew 1384:
1385: ##################################################
1386: ##################################################
1387:
1388: =pod
1389:
1390: =item crsenv
1391:
1.105 matthew 1392: Show and set course data and parameters. This is a large routine that should
1.59 matthew 1393: be simplified and shortened... someday.
1394:
1395: Inputs: $r
1396:
1397: Returns: nothing
1398:
1399: =cut
1400:
1401: ##################################################
1402: ##################################################
1.30 www 1403: sub crsenv {
1404: my $r=shift;
1405: my $setoutput='';
1.64 www 1406: my $bodytag=&Apache::loncommon::bodytag(
1407: 'Set Course Environment Parameters');
1.45 matthew 1408: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1409: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1.105 matthew 1410:
1411: #
1412: # Go through list of changes
1.38 harris41 1413: foreach (keys %ENV) {
1.105 matthew 1414: next if ($_!~/^form\.(.+)\_setparmval$/);
1415: my $name = $1;
1416: my $value = $ENV{'form.'.$name.'_value'};
1417: if ($name eq 'newp') {
1418: $name = $ENV{'form.newp_name'};
1419: }
1420: if ($name eq 'url') {
1421: $value=~s/^\/res\///;
1422: my $bkuptime=time;
1423: my @tmp = &Apache::lonnet::get
1424: ('environment',['url'],$dom,$crs);
1425: $setoutput.='Backing up previous URL: '.
1426: &Apache::lonnet::put
1427: ('environment',
1428: {'top level map backup '.$bkuptime => $tmp[1] },
1429: $dom,$crs).
1430: '<br>';
1431: }
1432: #
1433: # Deal with modified default spreadsheets
1434: if ($name =~ /^spreadsheet_default_(classcalc|
1435: studentcalc|
1436: assesscalc)$/x) {
1437: my $sheettype = $1;
1438: if ($sheettype eq 'classcalc') {
1439: # no need to do anything since viewing the sheet will
1440: # cause it to be updated.
1441: } elsif ($sheettype eq 'studentcalc') {
1442: # expire all the student spreadsheets
1443: &Apache::lonnet::expirespread('','','studentcalc');
1444: } else {
1445: # expire all the assessment spreadsheets
1446: # this includes non-default spreadsheets, but better to
1447: # be safe than sorry.
1448: &Apache::lonnet::expirespread('','','assesscalc');
1449: # expire all the student spreadsheets
1450: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 1451: }
1.105 matthew 1452: }
1453: #
1.107 matthew 1454: # Deal with the enrollment dates
1455: if ($name =~ /^default_enrollment_(start|end)_date$/) {
1456: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
1457: }
1458: #
1.105 matthew 1459: # Let the user know we made the changes
1460: if ($name) {
1461: my $put_result = &Apache::lonnet::put('environment',
1462: {$name=>$value},$dom,$crs);
1463: if ($put_result eq 'ok') {
1464: $setoutput.='Set <b>'.$name.'</b> to <b>'.$value.'</b>.<br />';
1465: } else {
1466: $setoutput.='Unable to set <b>'.$name.'</b> to '.
1467: '<b>'.$value.'</b> due to '.$put_result.'.<br />';
1.30 www 1468: }
1469: }
1.38 harris41 1470: }
1.108 www 1471: # ------------------------- Re-init course environment entries for this session
1472:
1473: &Apache::lonnet::coursedescription($ENV{'request.course.id'});
1.105 matthew 1474:
1.30 www 1475: # -------------------------------------------------------- Get parameters again
1.45 matthew 1476:
1477: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.30 www 1478: my $output='';
1.45 matthew 1479: if (! exists($values{'con_lost'})) {
1.30 www 1480: my %descriptions=
1.47 matthew 1481: ('url' => '<b>Top Level Map</b> '.
1.46 matthew 1482: '<a href="javascript:openbrowser'.
1.47 matthew 1483: "('envform','url','sequence')\">".
1.100 www 1484: 'Select Map</a><br /><font color=red> '.
1.45 matthew 1485: 'Modification may make assessment data '.
1486: 'inaccessible</font>',
1487: 'description' => '<b>Course Description</b>',
1.75 albertel 1488: 'courseid' => '<b>Course ID or number</b><br />'.
1.45 matthew 1489: '(internal, optional)',
1.117 matthew 1490: 'grading' => '<b>Grading</b>'.
1491: '"standard" or any other value. '.
1492: 'Default for new courses is "standard".',
1493:
1.52 www 1494: 'default_xml_style' => '<b>Default XML Style File</b> '.
1495: '<a href="javascript:openbrowser'.
1496: "('envform','default_xml_style'".
1.100 www 1497: ",'sty')\">Select Style File</a><br>",
1.74 www 1498: 'question.email' => '<b>Feedback Addresses for Resource Content '.
1.75 albertel 1499: 'Questions</b><br />(<tt>user:domain,'.
1.74 www 1500: 'user:domain(section;section;...;*;...),...</tt>)',
1.75 albertel 1501: 'comment.email' => '<b>Feedback Addresses for Course Content Comments</b><br />'.
1.74 www 1502: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.45 matthew 1503: 'policy.email' => '<b>Feedback Addresses for Course Policy</b>'.
1.75 albertel 1504: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1505: 'hideemptyrows' => '<b>Hide Empty Rows in Spreadsheets</b><br />'.
1.45 matthew 1506: '("<tt>yes</tt>" for default hiding)',
1.75 albertel 1507: 'pageseparators' => '<b>Visibly Separate Items on Pages</b><br />'.
1.93 bowersj2 1508: '("<tt>yes</tt>" for visible separation, '.
1509: 'changes will not show until next login)',
1.118 matthew 1510:
1511: 'plc.roles.denied'=> '<b>Disallow live chatroom use for '.
1512: 'Roles</b><br />"<tt>st</tt>": '.
1513: 'student, "<tt>ta</tt>": '.
1514: 'TA, "<tt>in</tt>": '.
1515: 'instructor;<br /><tt>role,role,...</tt>) '.
1516: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1517: 'plc.users.denied' =>
1518: '<b>Disallow live chatroom use for Users</b><br />'.
1519: '(<tt>user:domain,user:domain,...</tt>)',
1520:
1.45 matthew 1521: 'pch.roles.denied'=> '<b>Disallow Resource Discussion for '.
1.75 albertel 1522: 'Roles</b><br />"<tt>st</tt>": '.
1.61 albertel 1523: 'student, "<tt>ta</tt>": '.
1524: 'TA, "<tt>in</tt>": '.
1.75 albertel 1525: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 1526: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 1527: 'pch.users.denied' =>
1.75 albertel 1528: '<b>Disallow Resource Discussion for Users</b><br />'.
1.53 www 1529: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 1530: 'spreadsheet_default_classcalc'
1.52 www 1531: => '<b>Default Course Spreadsheet</b> '.
1.50 matthew 1532: '<a href="javascript:openbrowser'.
1533: "('envform','spreadsheet_default_classcalc'".
1.100 www 1534: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.49 matthew 1535: 'spreadsheet_default_studentcalc'
1.52 www 1536: => '<b>Default Student Spreadsheet</b> '.
1.50 matthew 1537: '<a href="javascript:openbrowser'.
1538: "('envform','spreadsheet_default_calc'".
1.100 www 1539: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.49 matthew 1540: 'spreadsheet_default_assesscalc'
1.52 www 1541: => '<b>Default Assessment Spreadsheet</b> '.
1.50 matthew 1542: '<a href="javascript:openbrowser'.
1543: "('envform','spreadsheet_default_assesscalc'".
1.100 www 1544: ",'spreadsheet')\">Select Spreadsheet File</a><br />",
1.75 albertel 1545: 'allow_limited_html_in_feedback'
1546: => '<b>Allow limited HTML in discussion posts</b><br />'.
1.108 www 1547: '(Set value to "<tt>yes</tt>" to allow)',
1.89 albertel 1548: 'rndseed'
1.90 albertel 1549: => '<b>Randomization algorithm used</b> <br />'.
1.89 albertel 1550: '<font color="red">Modifying this will make problems '.
1.94 sakharuk 1551: 'have different numbers and answers</font>',
1.113 sakharuk 1552: 'problem_stream_switch'
1.104 matthew 1553: => '<b>Allow problems to be split over pages</b><br />'.
1.115 www 1554: ' ("<tt>yes</tt>" if allowed, anything else if not)',
1.111 sakharuk 1555: 'anonymous_quiz'
1.110 sakharuk 1556: => '<b>Anonimous quiz/exam</b><br />'.
1557: ' (<tt><b>yes</b> to avoid print students names </tt>)',
1.108 www 1558: 'default_enrollment_start_date' => '<b>Default beginning date '.
1559: 'when enrolling students</b>',
1560: 'default_enrollment_end_date' => '<b>Default ending date '.
1561: 'when enrolling students</b>',
1.115 www 1562: 'languages' => '<b>Languages used</b>',
1563: 'disable_receipt_display'
1564: => '<b>Disable display of problem receipts</b><br />'.
1565: ' ("<tt>yes</tt>" to disable, anything else if not)'
1.107 matthew 1566: );
1.117 matthew 1567: my @Display_Order = ('url','description','courseid','grading',
1.107 matthew 1568: 'default_xml_style','pageseparators',
1569: 'question.email','comment.email','policy.email',
1.118 matthew 1570: 'plc.roles.denied','plc.users.denied',
1.107 matthew 1571: 'pch.roles.denied','pch.users.denied',
1572: 'allow_limited_html_in_feedback',
1.108 www 1573: 'languages',
1.107 matthew 1574: 'rndseed',
1575: 'problem_stream_switch',
1.115 www 1576: 'disable_receipt_display',
1.107 matthew 1577: 'spreadsheet_default_classcalc',
1578: 'spreadsheet_default_studentcalc',
1579: 'spreadsheet_default_assesscalc',
1580: 'hideemptyrows',
1581: 'default_enrollment_start_date',
1582: 'default_enrollment_end_date',
1583: );
1584: foreach my $parameter (sort(keys(%values))) {
1585: if (! $descriptions{$parameter}) {
1586: $descriptions{$parameter}=$parameter;
1587: push(@Display_Order,$parameter);
1.43 albertel 1588: }
1589: }
1.107 matthew 1590: foreach my $parameter (@Display_Order) {
1591: my $description = $descriptions{$parameter};
1.51 matthew 1592: # onchange is javascript to automatically check the 'Set' button.
1.69 www 1593: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 1594: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 1595: '.checked=true;"';
1.107 matthew 1596: $output .= '<tr><td>'.$description.'</td>';
1597: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
1598: $output .= '<td>'.
1599: &Apache::lonhtmlcommon::date_setter('envform',
1600: $parameter.'_value',
1601: $values{$parameter},
1602: $onchange).
1603: '</td>';
1604: } else {
1605: $output .= '<td>'.
1606: &Apache::lonhtmlcommon::textbox($parameter.'_value',
1607: $values{$parameter},
1608: 40,$onchange).'</td>';
1609: }
1610: $output .= '<td>'.
1611: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
1612: '</td>';
1613: $output .= "</tr>\n";
1.51 matthew 1614: }
1.69 www 1615: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 1616: '[\'envform\'].elements[\'newp_setparmval\']'.
1617: '.checked=true;"';
1618: $output.='<tr><td><i>Create New Environment Variable</i><br />'.
1619: '<input type="text" size=40 name="newp_name" '.
1620: $onchange.' /></td><td>'.
1621: '<input type="text" size=40 name="newp_value" '.
1622: $onchange.' /></td><td>'.
1623: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 1624: }
1.30 www 1625: $r->print(<<ENDENV);
1626: <html>
1.46 matthew 1627: <script type="text/javascript" language="Javascript" >
1628: var editbrowser;
1.47 matthew 1629: function openbrowser(formname,elementname,only,omit) {
1.46 matthew 1630: var url = '/res/?';
1631: if (editbrowser == null) {
1632: url += 'launch=1&';
1633: }
1634: url += 'catalogmode=interactive&';
1635: url += 'mode=parmset&';
1636: url += 'form=' + formname + '&';
1.47 matthew 1637: if (only != null) {
1638: url += 'only=' + only + '&';
1639: }
1640: if (omit != null) {
1641: url += 'omit=' + omit + '&';
1642: }
1.46 matthew 1643: url += 'element=' + elementname + '';
1644: var title = 'Browser';
1645: var options = 'scrollbars=1,resizable=1,menubar=0';
1646: options += ',width=700,height=600';
1647: editbrowser = open(url,title,options,'1');
1648: editbrowser.focus();
1649: }
1650: </script>
1.30 www 1651: <head>
1652: <title>LON-CAPA Course Environment</title>
1653: </head>
1.64 www 1654: $bodytag
1.30 www 1655: <form method="post" action="/adm/parmset" name="envform">
1656: $setoutput
1657: <p>
1658: <table border=2>
1659: <tr><th>Parameter</th><th>Value</th><th>Set?</th></tr>
1660: $output
1661: </table>
1662: <input type="submit" name="crsenv" value="Set Course Environment">
1663: </form>
1664: </body>
1665: </html>
1666: ENDENV
1667: }
1.120 www 1668: ##################################################
1.30 www 1669:
1.124 www 1670: my $tableopen;
1671:
1672: sub tablestart {
1673: if ($tableopen) {
1674: return '';
1675: } else {
1676: $tableopen=1;
1677: return '<table border="2"><tr><th>Parameter</th><th>Delete</th><th>Set to ...</th></tr>';
1678: }
1679: }
1680:
1681: sub tableend {
1682: if ($tableopen) {
1683: $tableopen=0;
1684: return '</table>';
1685: } else {
1686: return'';
1687: }
1688: }
1689:
1.120 www 1690: sub overview {
1691: my $r=shift;
1692: my $bodytag=&Apache::loncommon::bodytag(
1693: 'Set/Modify Course Assessment Parameters');
1694: my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
1695: my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
1696: $r->print(<<ENDOVER);
1697: <html>
1698: <head>
1699: <title>LON-CAPA Course Environment</title>
1700: </head>
1701: $bodytag
1.123 www 1702: <form method="post" action="/adm/parmset" name="overviewform">
1.120 www 1703: <input type="hidden" name="overview" value="1" />
1704: ENDOVER
1.124 www 1705: # Setting
1706: my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
1707: my %newdata=();
1708: undef %newdata;
1709: my @deldata=();
1710: undef @deldata;
1711: foreach (keys %ENV) {
1712: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
1713: my $cmd=$1;
1714: my $thiskey=$2;
1715: if ($cmd eq 'set') {
1716: my $data=$ENV{$_};
1717: if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
1718: } elsif ($cmd eq 'del') {
1719: push (@deldata,$thiskey);
1720: } elsif ($cmd eq 'datepointer') {
1721: my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_});
1722: if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
1723: }
1724: }
1725: }
1726: # Store
1727: &Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs);
1728: &Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs);
1.122 www 1729: # Read and display
1730: my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
1731: my $oldsection='';
1732: my $oldrealm='';
1733: my $oldpart='';
1.123 www 1734: my $pointer=0;
1.124 www 1735: $tableopen=0;
1.122 www 1736: foreach my $thiskey (sort keys %resourcedata) {
1.123 www 1737: if ($resourcedata{$thiskey.'.type'}) {
1738: my ($course,$middle,$part,$name)=
1739: ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.122 www 1740: my $section='All Students';
1741: if ($middle=~/^\[(.*)\]\./) {
1742: $section='Group/Section: '.$1;
1743: $middle=~s/^\[(.*)\]\.//;
1744: }
1.123 www 1745: $middle=~s/\.$//;
1746: my $realm='<font color="red">All Resources</font>';
1.122 www 1747: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.123 www 1748: $realm='<font color="green">Folder/Map: '.&Apache::lonnet::gettitle($1).'</font>';
1.122 www 1749: } elsif ($middle) {
1.123 www 1750: $realm='<font color="orange">Resource: '.&Apache::lonnet::gettitle($middle).'</font>';
1.122 www 1751: }
1752: if ($section ne $oldsection) {
1.124 www 1753: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
1.122 www 1754: $oldsection=$section;
1755: $oldrealm='';
1756: }
1757: if ($realm ne $oldrealm) {
1.124 www 1758: $r->print(&tableend()."\n<h2>$realm</h2>");
1.122 www 1759: $oldrealm=$realm;
1760: $oldpart='';
1761: }
1762: if ($part ne $oldpart) {
1.124 www 1763: $r->print(&tableend().
1764: "\n<h3><font color='blue'>Part: $part</font></h3>");
1.122 www 1765: $oldpart=$part;
1766: }
1.123 www 1767: #
1768: # Ready to print
1769: #
1.124 www 1770: $r->print(&tablestart().'<tr><td><b>'.$name.
1771: ':</b></td><td><input type="checkbox" name="del_'.
1772: $thiskey.'" /></td><td>');
1.123 www 1773: if ($resourcedata{$thiskey.'.type'}=~/^date/) {
1774: my $jskey='key_'.$pointer;
1775: $pointer++;
1776: $r->print(
1777: &Apache::lonhtmlcommon::date_setter('overviewform',
1778: $jskey,
1779: $resourcedata{$thiskey}).
1780: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
1781: );
1782: } else {
1783: $r->print(
1784: '<input type="text" name="set_'.$thiskey.'" value="'.
1785: $resourcedata{$thiskey}.'">');
1786: }
1.124 www 1787: $r->print('</td></tr>');
1.122 www 1788: }
1.121 www 1789: }
1.124 www 1790:
1791: $r->print(&tableend().
1792: '<p><input type="submit" value="Modify Parameters" /></p></form></body></html>');
1.120 www 1793: }
1.121 www 1794:
1.59 matthew 1795: ##################################################
1796: ##################################################
1.30 www 1797:
1.59 matthew 1798: =pod
1799:
1.83 bowersj2 1800: =item * handler
1.59 matthew 1801:
1802: Main handler. Calls &assessparms and &crsenv subroutines.
1803:
1804: =cut
1805:
1806: ##################################################
1807: ##################################################
1.85 bowersj2 1808: use Data::Dumper;
1.30 www 1809: sub handler {
1.43 albertel 1810: my $r=shift;
1.30 www 1811:
1.43 albertel 1812: if ($r->header_only) {
1.126 www 1813: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 1814: $r->send_http_header;
1815: return OK;
1816: }
1817: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
1.83 bowersj2 1818:
1.30 www 1819: # ----------------------------------------------------- Needs to be in a course
1820:
1.43 albertel 1821: if (($ENV{'request.course.id'}) &&
1822: (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) {
1.106 www 1823:
1.126 www 1824: &Apache::loncommon::content_type($r,'text/html');
1.106 www 1825: $r->send_http_header;
1.57 albertel 1826:
1827: $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
1.30 www 1828:
1.121 www 1829: if (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) {
1.30 www 1830: # ---------------------------------------------- This is for course environment
1.121 www 1831: # -------------------------- also call if toplevel map coudl not be initialized
1832: &crsenv($r);
1.120 www 1833: } elsif ($ENV{'form.overview'}) {
1.121 www 1834: # --------------------------------------------------------------- Overview mode
1835: &overview($r);
1.43 albertel 1836: } else {
1.121 www 1837: # --------------------------------------------------------- Bring up assessment
1838: &assessparms($r);
1.43 albertel 1839: }
1840: } else {
1.1 www 1841: # ----------------------------- Not in a course, or not allowed to modify parms
1.43 albertel 1842: $ENV{'user.error.msg'}=
1843: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
1844: return HTTP_NOT_ACCEPTABLE;
1845: }
1846: return OK;
1.1 www 1847: }
1848:
1849: 1;
1850: __END__
1851:
1.59 matthew 1852: =pod
1.38 harris41 1853:
1854: =back
1855:
1856: =cut
1.1 www 1857:
1858:
1859:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>