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