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