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