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