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