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