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