Annotation of loncom/interface/lonparmset.pm, revision 1.204
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.204 ! www 4: # $Id: lonparmset.pm,v 1.203 2005/06/03 14:25:49 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.197 www 65: use Apache::lonnavmaps;
1.1 www 66:
1.198 www 67: # --- Caches local to lonparmset
1.2 www 68:
1.199 www 69: my $parmhashid;
70: my %parmhash;
1.201 www 71: my $symbsid;
72: my %symbs;
1.198 www 73:
74: # --- end local caches
75:
1.59 matthew 76: ##################################################
77: ##################################################
78:
79: =pod
80:
81: =item parmval
82:
83: Figure out a cascading parameter.
84:
1.71 albertel 85: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 86: $id - a bighash Id number
1.71 albertel 87: $def - the resource's default value 'stupid emacs
88:
89: 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
90:
1.182 albertel 91: 11 - General Course
92: 10 - Map or Folder level in course
93: 9- resource default
94: 8- map default
1.71 albertel 95: 7 - resource level in course
96: 6 - General for section
1.82 www 97: 5 - Map or Folder level for section
1.71 albertel 98: 4 - resource level in section
99: 3 - General for specific student
1.82 www 100: 2 - Map or Folder level for specific student
1.71 albertel 101: 1 - resource level for specific student
1.2 www 102:
1.59 matthew 103: =cut
104:
105: ##################################################
1.2 www 106: sub parmval {
1.187 www 107: my ($what,$id,$def,$uname,$udom,$csec)=@_;
1.201 www 108: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec);
109: }
110:
111: sub parmval_by_symb {
112: my ($what,$symb,$def,$uname,$udom,$csec)=@_;
1.198 www 113: # load caches
1.200 www 114:
1.198 www 115: &cacheparmhash();
1.200 www 116:
117: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
118: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
119: my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
120: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
121:
1.198 www 122:
1.8 www 123: my $result='';
1.44 albertel 124: my @outpar=();
1.2 www 125: # ----------------------------------------------------- Cascading lookup scheme
1.201 www 126: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.10 www 127:
1.201 www 128: my $symbparm=$symb.'.'.$what;
129: my $mapparm=$map.'___(all).'.$what;
1.10 www 130:
1.190 albertel 131: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
132: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
133: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
134:
135: my $courselevel=$env{'request.course.id'}.'.'.$what;
136: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
137: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.2 www 138:
1.11 www 139:
140:
1.182 albertel 141: # --------------------------------------------------------- first, check course
1.11 www 142:
1.200 www 143: if (defined($$courseopt{$courselevel})) {
144: $outpar[11]=$$courseopt{$courselevel};
1.182 albertel 145: $result=11;
1.43 albertel 146: }
1.11 www 147:
1.200 www 148: if (defined($$courseopt{$courselevelm})) {
149: $outpar[10]=$$courseopt{$courselevelm};
1.182 albertel 150: $result=10;
1.43 albertel 151: }
1.11 www 152:
1.182 albertel 153: # ------------------------------------------------------- second, check default
154:
155: if (defined($def)) { $outpar[9]=$def; $result=9; }
156:
157: # ------------------------------------------------------ third, check map parms
158:
159: my $thisparm=$parmhash{$symbparm};
160: if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; }
161:
1.200 www 162: if (defined($$courseopt{$courselevelr})) {
163: $outpar[7]=$$courseopt{$courselevelr};
1.43 albertel 164: $result=7;
165: }
1.11 www 166:
1.182 albertel 167: # ------------------------------------------------------ fourth, back to course
1.71 albertel 168: if (defined($csec)) {
1.200 www 169: if (defined($$courseopt{$seclevel})) {
170: $outpar[6]=$$courseopt{$seclevel};
1.43 albertel 171: $result=6;
172: }
1.200 www 173: if (defined($$courseopt{$seclevelm})) {
174: $outpar[5]=$$courseopt{$seclevelm};
1.43 albertel 175: $result=5;
176: }
177:
1.200 www 178: if (defined($$courseopt{$seclevelr})) {
1.201 www 179: $outpar[4]=$$courseopt{$seclevelr};
1.43 albertel 180: $result=4;
181: }
182: }
1.11 www 183:
1.182 albertel 184: # ---------------------------------------------------------- fifth, check user
1.11 www 185:
1.71 albertel 186: if (defined($uname)) {
1.200 www 187: if (defined($$useropt{$courselevel})) {
188: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 189: $result=3;
190: }
1.10 www 191:
1.200 www 192: if (defined($$useropt{$courselevelm})) {
193: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 194: $result=2;
195: }
1.2 www 196:
1.200 www 197: if (defined($$useropt{$courselevelr})) {
198: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 199: $result=1;
200: }
201: }
1.44 albertel 202: return ($result,@outpar);
1.2 www 203: }
204:
1.198 www 205: sub resetparmhash {
206: $parmhashid='';
207: }
208:
209: sub cacheparmhash {
210: if ($parmhashid eq $env{'request.course.fn'}) { return; }
211: my %parmhashfile;
212: if (tie(%parmhashfile,'GDBM_File',
213: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
214: %parmhash=%parmhashfile;
215: untie %parmhashfile;
216: $parmhashid=$env{'request.course.fn'};
217: }
218: }
219:
1.203 www 220: sub resetsymbcache {
221: $symbsid='';
222: }
223:
1.201 www 224: sub symbcache {
225: my $id=shift;
226: if ($symbsid ne $env{'request.course.id'}) {
227: %symbs=();
228: }
229: unless ($symbs{$id}) {
230: my $navmap = Apache::lonnavmaps::navmap->new();
231: if ($id=~/\./) {
232: my $resource=$navmap->getById($id);
233: $symbs{$id}=$resource->symb();
234: } else {
235: my $resource=$navmap->getByMapPc($id);
236: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
237: }
238: $symbsid=$env{'request.course.id'};
239: }
240: return $symbs{$id};
241: }
242:
1.186 www 243: ##################################################
244: ##################################################
245: #
1.197 www 246: # Store a parameter by ID
1.186 www 247: #
248: # Takes
249: # - resource id
250: # - name of parameter
251: # - level
252: # - new value
253: # - new type
1.187 www 254: # - username
255: # - userdomain
256:
1.186 www 257: sub storeparm {
1.187 www 258: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
1.201 www 259: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
1.197 www 260: }
261:
262: #
263: # Store a parameter by symb
264: #
265: # Takes
266: # - symb
267: # - name of parameter
268: # - level
269: # - new value
270: # - new type
271: # - username
272: # - userdomain
273:
274: sub storeparm_by_symb {
275: # ---------------------------------------------------------- Get symb, map, etc
276: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
277: # ---------------------------------------------------------- Construct prefixes
1.186 www 278: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 279: my $map=(&Apache::lonnet::decode_symb($symb))[0];
280: my $symbparm=$symb.'.'.$spnam;
281: my $mapparm=$map.'___(all).'.$spnam;
282:
1.190 albertel 283: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
284: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
285: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 286:
1.190 albertel 287: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
288: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
289: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 290:
291: my $storeunder='';
292: if (($snum==11) || ($snum==3)) { $storeunder=$courselevel; }
293: if (($snum==10) || ($snum==2)) { $storeunder=$courselevelm; }
294: if (($snum==7) || ($snum==1)) { $storeunder=$courselevelr; }
295: if ($snum==6) { $storeunder=$seclevel; }
296: if ($snum==5) { $storeunder=$seclevelm; }
297: if ($snum==4) { $storeunder=$seclevelr; }
298:
299: my $delete;
300: if ($nval eq '') { $delete=1;}
301: my %storecontent = ($storeunder => $nval,
302: $storeunder.'.type' => $ntype);
303: my $reply='';
304: if ($snum>3) {
305: # ---------------------------------------------------------------- Store Course
306: #
1.200 www 307: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
308: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 309: # Expire sheets
310: &Apache::lonnet::expirespread('','','studentcalc');
311: if (($snum==7) || ($snum==4)) {
1.197 www 312: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.186 www 313: } elsif (($snum==8) || ($snum==5)) {
1.197 www 314: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 315: } else {
316: &Apache::lonnet::expirespread('','','assesscalc');
317: }
318: # Store parameter
319: if ($delete) {
320: $reply=&Apache::lonnet::del
1.200 www 321: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.186 www 322: } else {
323: $reply=&Apache::lonnet::cput
1.200 www 324: ('resourcedata',\%storecontent,$cdom,$cnum);
1.186 www 325: }
1.200 www 326: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 327: } else {
328: # ------------------------------------------------------------------ Store User
329: #
330: # Expire sheets
331: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
332: if ($snum==1) {
333: &Apache::lonnet::expirespread
1.197 www 334: ($uname,$udom,'assesscalc',$symb);
1.186 www 335: } elsif ($snum==2) {
336: &Apache::lonnet::expirespread
1.197 www 337: ($uname,$udom,'assesscalc',$map);
1.186 www 338: } else {
339: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
340: }
341: # Store parameter
342: if ($delete) {
343: $reply=&Apache::lonnet::del
344: ('resourcedata',[keys(%storecontent)],$udom,$uname);
345: } else {
346: $reply=&Apache::lonnet::cput
347: ('resourcedata',\%storecontent,$udom,$uname);
348: }
1.191 albertel 349: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 350: }
351:
352: if ($reply=~/^error\:(.*)/) {
353: return "<font color=red>Write Error: $1</font>";
354: }
355: return '';
356: }
357:
1.59 matthew 358: ##################################################
359: ##################################################
360:
361: =pod
362:
363: =item valout
364:
365: Format a value for output.
366:
367: Inputs: $value, $type
368:
369: Returns: $value, formatted for output. If $type indicates it is a date,
370: localtime($value) is returned.
1.9 www 371:
1.59 matthew 372: =cut
373:
374: ##################################################
375: ##################################################
1.9 www 376: sub valout {
377: my ($value,$type)=@_;
1.59 matthew 378: my $result = '';
379: # Values of zero are valid.
380: if (! $value && $value ne '0') {
1.71 albertel 381: $result = ' ';
1.59 matthew 382: } else {
1.66 www 383: if ($type eq 'date_interval') {
384: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
385: $year=$year-70;
386: $mday--;
387: if ($year) {
388: $result.=$year.' yrs ';
389: }
390: if ($mon) {
391: $result.=$mon.' mths ';
392: }
393: if ($mday) {
394: $result.=$mday.' days ';
395: }
396: if ($hour) {
397: $result.=$hour.' hrs ';
398: }
399: if ($min) {
400: $result.=$min.' mins ';
401: }
402: if ($sec) {
403: $result.=$sec.' secs ';
404: }
405: $result=~s/\s+$//;
406: } elsif ($type=~/^date/) {
1.59 matthew 407: $result = localtime($value);
408: } else {
409: $result = $value;
410: }
411: }
412: return $result;
1.9 www 413: }
414:
1.59 matthew 415: ##################################################
416: ##################################################
417:
418: =pod
1.5 www 419:
1.59 matthew 420: =item plink
421:
422: Produces a link anchor.
423:
424: Inputs: $type,$dis,$value,$marker,$return,$call
425:
426: Returns: scalar with html code for a link which will envoke the
427: javascript function 'pjump'.
428:
429: =cut
430:
431: ##################################################
432: ##################################################
1.5 www 433: sub plink {
434: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 435: my $winvalue=$value;
436: unless ($winvalue) {
437: if ($type=~/^date/) {
1.190 albertel 438: $winvalue=$env{'form.recent_'.$type};
1.23 www 439: } else {
1.190 albertel 440: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 441: }
442: }
443: return
1.43 albertel 444: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
445: .$marker."','".$return."','".$call."'".');">'.
446: &valout($value,$type).'</a><a name="'.$marker.'"></a>';
1.5 www 447: }
448:
1.44 albertel 449: sub startpage {
1.202 www 450: my ($r,$id,$udom,$csec,$uname,$have_assessments)=@_;
1.99 albertel 451:
1.120 www 452: my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
1.98 www 453: 'onUnload="pclose()"');
1.204 ! www 454: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Table Mode Parameter Setting');
1.81 www 455: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
456: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
457: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 458: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.133 www 459: my %lt=&Apache::lonlocal::texthash(
460: 'captm' => "Course Assessments Parameters - Table Mode",
461: 'sg' => "Section/Group",
462: 'fu' => "For User",
463: 'oi' => "or ID",
464: 'ad' => "at Domain"
465: );
1.183 albertel 466: my $html=&Apache::lonxml::xmlbegin();
1.44 albertel 467: $r->print(<<ENDHEAD);
1.183 albertel 468: $html
1.44 albertel 469: <head>
470: <title>LON-CAPA Course Parameters</title>
471: <script>
472:
473: function pclose() {
474: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
475: "height=350,width=350,scrollbars=no,menubar=no");
476: parmwin.close();
477: }
478:
1.88 matthew 479: $pjump_def
1.44 albertel 480:
481: function psub() {
482: pclose();
483: if (document.parmform.pres_marker.value!='') {
484: document.parmform.action+='#'+document.parmform.pres_marker.value;
485: var typedef=new Array();
486: typedef=document.parmform.pres_type.value.split('_');
487: if (document.parmform.pres_type.value!='') {
488: if (typedef[0]=='date') {
489: eval('document.parmform.recent_'+
490: document.parmform.pres_type.value+
491: '.value=document.parmform.pres_value.value;');
492: } else {
493: eval('document.parmform.recent_'+typedef[0]+
494: '.value=document.parmform.pres_value.value;');
495: }
496: }
497: document.parmform.submit();
498: } else {
499: document.parmform.pres_value.value='';
500: document.parmform.pres_marker.value='';
501: }
502: }
503:
1.57 albertel 504: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
505: var options = "width=" + w + ",height=" + h + ",";
506: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
507: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
508: var newWin = window.open(url, wdwName, options);
509: newWin.focus();
510: }
1.44 albertel 511: </script>
1.81 www 512: $selscript
1.44 albertel 513: </head>
1.64 www 514: $bodytag
1.193 albertel 515: $breadcrumbs
1.137 albertel 516: ENDHEAD
1.189 www 517: my %sectionhash=();
518: my $sections='';
519: if (&Apache::loncommon::get_sections(
1.190 albertel 520: $env{'course.'.$env{'request.course.id'}.'.domain'},
521: $env{'course.'.$env{'request.course.id'}.'.num'},
1.189 www 522: \%sectionhash)) {
523: $sections=$lt{'sg'}.': <select name="csec">';
524: foreach ('',sort keys %sectionhash) {
525: $sections.='<option value="'.$_.'"'.
526: ($_ eq $csec?'selected="selected"':'').'>'.$_.'</option>';
527: }
528: $sections.='</select>';
529: }
530: $r->print(<<ENDHEAD3);
1.193 albertel 531: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.133 www 532: <h4>$lt{'captm'}</h4>
1.137 albertel 533: ENDHEAD3
1.99 albertel 534:
1.202 www 535: if (!$have_assessments) {
536: $r->print('<font color="red">'.&mt('There are no assessment parameters in this course to set.').'</font><br />');
1.99 albertel 537: } else {
538: $r->print(<<ENDHEAD);
1.44 albertel 539: <b>
1.189 www 540: $sections
1.188 www 541: <br />
1.133 www 542: $lt{'fu'}
1.188 www 543: <input type="text" value="$uname" size="12" name="uname" />
1.133 www 544: $lt{'oi'}
1.188 www 545: <input type="text" value="$id" size="12" name="id" />
1.133 www 546: $lt{'ad'}
1.81 www 547: $chooseopt
1.44 albertel 548: </b>
549: <input type="hidden" value='' name="pres_value">
550: <input type="hidden" value='' name="pres_type">
551: <input type="hidden" value='' name="pres_marker">
552: ENDHEAD
1.99 albertel 553: }
1.44 albertel 554: }
555:
556: sub print_row {
1.201 www 557: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.187 www 558: $defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
1.66 www 559: # get the values for the parameter in cascading order
560: # empty levels will remain empty
1.44 albertel 561: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.187 www 562: $rid,$$default{$which},$uname,$udom,$csec);
1.66 www 563: # get the type for the parameters
564: # problem: these may not be set for all levels
565: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
566: $$name{$which}.'.type',
1.187 www 567: $rid,$$defaulttype{$which},$uname,$udom,$csec);
1.66 www 568: # cascade down manually
1.182 albertel 569: my $cascadetype=$$defaulttype{$which};
570: for (my $i=11;$i>0;$i--) {
1.66 www 571: if ($typeoutpar[$i]) {
572: $cascadetype=$typeoutpar[$i];
573: } else {
574: $typeoutpar[$i]=$cascadetype;
575: }
576: }
1.57 albertel 577: my $parm=$$display{$which};
578:
1.203 www 579: if ($parmlev eq 'full') {
1.57 albertel 580: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
581: .$$part{$which}.'</td>');
582: } else {
583: $parm=~s|\[.*\]\s||g;
584: }
585:
1.159 albertel 586: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
1.57 albertel 587:
1.44 albertel 588: my $thismarker=$which;
589: $thismarker=~s/^parameter\_//;
590: my $mprefix=$rid.'&'.$thismarker.'&';
591:
1.57 albertel 592: if ($parmlev eq 'general') {
593:
594: if ($uname) {
1.66 www 595: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 596: } elsif ($csec) {
1.66 www 597: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 598: } else {
1.182 albertel 599: &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 600: }
601: } elsif ($parmlev eq 'map') {
602:
603: if ($uname) {
1.66 www 604: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 605: } elsif ($csec) {
1.66 www 606: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 607: } else {
1.182 albertel 608: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 609: }
610: } else {
611:
1.182 albertel 612: &print_td($r,11,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 613:
1.203 www 614: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
615: &print_td($r,9,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
616: &print_td($r,8,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
617: &print_td($r,7,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
618:
619: if ($csec) {
620: &print_td($r,6,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
621: &print_td($r,5,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
622: &print_td($r,4,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
623: }
624: if ($uname) {
625: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
626: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
627: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
628: }
1.57 albertel 629:
630: } # end of $parmlev if/else
631:
1.136 albertel 632: $r->print('<td bgcolor=#CCCCFF align="center">'.
633: &valout($outpar[$result],$typeoutpar[$result]).'</td>');
634:
1.203 www 635: if ($parmlev eq 'full') {
1.136 albertel 636: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 637: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 638:
1.70 albertel 639: # this doesn't seem to work, and I don't think is correct
640: # my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
641: # '.'.$$name{$which}.'.type',$symbp{$rid});
642: # this seems to work
1.136 albertel 643: my $sessionvaltype=$typeoutpar[$result];
644: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
645: $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
1.66 www 646: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 647: '</font></td>');
1.136 albertel 648: }
1.44 albertel 649: $r->print('</tr>');
1.57 albertel 650: $r->print("\n");
1.44 albertel 651: }
1.59 matthew 652:
1.44 albertel 653: sub print_td {
1.66 www 654: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 655: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 656: ' align="center">');
1.182 albertel 657: if ($which<8 || $which > 9) {
1.114 www 658: $r->print(&plink($$typeoutpar[$which],
659: $$display{$value},$$outpar[$which],
660: $mprefix."$which",'parmform.pres','psub'));
661: } else {
662: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
663: }
664: $r->print('</td>'."\n");
1.57 albertel 665: }
666:
1.201 www 667:
1.63 bowersj2 668: =pod
669:
670: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
671:
672: Input: See list below:
673:
674: =over 4
675:
676: =item B<ids>: An array that will contain all of the ids in the course.
677:
678: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
679:
1.171 www 680: =item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
1.63 bowersj2 681:
682: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
683:
684: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
685:
686: =item B<allkeys>: hash, full key to part->display value (what's display value?)
687:
688: =item B<allmaps>: hash, ???
689:
690: =item B<fcat>: ???
691:
692: =item B<defp>: hash, ???
693:
694: =item B<mapp>: ??
695:
696: =item B<symbp>: hash, id->full sym?
697:
698: =back
699:
700: =cut
701:
702: sub extractResourceInformation {
703: my $ids = shift;
704: my $typep = shift;
705: my $keyp = shift;
706: my $allparms = shift;
707: my $allparts = shift;
708: my $allkeys = shift;
709: my $allmaps = shift;
710: my $fcat = shift;
711: my $defp = shift;
712: my $mapp = shift;
713: my $symbp = shift;
1.82 www 714: my $maptitles=shift;
1.196 www 715: my $uris=shift;
716:
1.63 bowersj2 717:
1.196 www 718: my $navmap = Apache::lonnavmaps::navmap->new();
719: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
720: foreach my $resource (@allres) {
721: my $id=$resource->id();
722: my ($mapid,$resid)=split(/\./,$id);
723: if ($mapid eq '0') { next; }
724: $$ids[$#$ids+1]=$id;
725: my $srcf=$resource->src();
726: $srcf=~/\.(\w+)$/;
727: $$typep{$id}=$1;
728: $$keyp{$id}='';
729: $$uris{$id}=$srcf;
730: foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
731: if ($_=~/^parameter\_(.*)/) {
732: my $key=$_;
733: my $allkey=$1;
734: $allkey=~s/\_/\./g;
735: if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq
736: 'parm') {
737: next; #hide hidden things
1.63 bowersj2 738: }
1.196 www 739: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
740: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
741: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
742: my $parmdis = $display;
743: $parmdis =~ s|(\[Part.*)$||g;
744: my $partkey = $part;
745: $partkey =~ tr|_|.|;
746: $$allparms{$name} = $parmdis;
747: $$allparts{$part} = "[Part $part]";
748: $$allkeys{$allkey}=$display;
749: if ($allkey eq $fcat) {
750: $$defp{$id}= &Apache::lonnet::metadata($srcf,$key);
751: }
752: if ($$keyp{$id}) {
753: $$keyp{$id}.=','.$key;
1.175 albertel 754: } else {
1.196 www 755: $$keyp{$id}=$key;
1.175 albertel 756: }
1.63 bowersj2 757: }
758: }
1.196 www 759: $$mapp{$id}=
760: &Apache::lonnet::declutter($resource->enclosing_map_src());
761: $$mapp{$mapid}=$$mapp{$id};
762: $$allmaps{$mapid}=$$mapp{$id};
763: if ($mapid eq '1') {
764: $$maptitles{$mapid}='Main Course Documents';
765: } else {
766: $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
767: }
768: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
769: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
770: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.63 bowersj2 771: }
772: }
773:
1.59 matthew 774: ##################################################
775: ##################################################
776:
777: =pod
778:
779: =item assessparms
780:
781: Show assessment data and parameters. This is a large routine that should
782: be simplified and shortened... someday.
783:
784: Inputs: $r
785:
786: Returns: nothing
787:
1.63 bowersj2 788: Variables used (guessed by Jeremy):
789:
790: =over 4
791:
792: =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.
793:
794: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
795:
796: =item B<allmaps>:
797:
798: =back
799:
1.59 matthew 800: =cut
801:
802: ##################################################
803: ##################################################
1.30 www 804: sub assessparms {
1.1 www 805:
1.43 albertel 806: my $r=shift;
1.201 www 807:
808: my @ids=();
809: my %symbp=();
810: my %mapp=();
811: my %typep=();
812: my %keyp=();
813: my %uris=();
814: my %maptitles=();
815:
1.2 www 816: # -------------------------------------------------------- Variable declaration
1.129 www 817: my %allkeys=();
818: my %allmaps=();
819: my %alllevs=();
1.57 albertel 820:
1.187 www 821: my $uname;
822: my $udom;
823: my $uhome;
824: my $csec;
825:
1.190 albertel 826: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 827:
1.57 albertel 828: $alllevs{'Resource Level'}='full';
829: $alllevs{'Map Level'}='map';
830: $alllevs{'Course Level'}='general';
831:
832: my %allparms;
833: my %allparts;
834:
1.43 albertel 835: my %defp;
836:
837: @ids=();
838: %symbp=();
839: %typep=();
840:
841: my $message='';
842:
1.190 albertel 843: $csec=$env{'form.csec'};
1.188 www 844:
1.190 albertel 845: if ($udom=$env{'form.udom'}) {
846: } elsif ($udom=$env{'request.role.domain'}) {
847: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 848: } else {
849: $udom=$r->dir_config('lonDefDomain');
850: }
1.43 albertel 851:
1.134 albertel 852: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 853: my $pschp=$env{'form.pschp'};
1.134 albertel 854: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 855: if (!@psprt) { $psprt[0]='0'; }
1.190 albertel 856: my $showoptions=$env{'form.showoptions'};
1.57 albertel 857:
1.43 albertel 858: my $pssymb='';
1.57 albertel 859: my $parmlev='';
1.190 albertel 860: my $prevvisit=$env{'form.prevvisit'};
1.57 albertel 861:
1.190 albertel 862: unless ($env{'form.parmlev'}) {
1.57 albertel 863: $parmlev = 'map';
864: } else {
1.190 albertel 865: $parmlev = $env{'form.parmlev'};
1.57 albertel 866: }
1.26 www 867:
1.29 www 868: # ----------------------------------------------- Was this started from grades?
869:
1.190 albertel 870: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
871: && (!$env{'form.dis'})) {
872: my $url=$env{'form.url'};
1.194 albertel 873: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 874: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 875: if (!@pscat) { @pscat=('all'); }
1.43 albertel 876: $pschp='';
1.57 albertel 877: $parmlev = 'full';
1.190 albertel 878: } elsif ($env{'form.symb'}) {
879: $pssymb=$env{'form.symb'};
1.92 albertel 880: if (!@pscat) { @pscat=('all'); }
1.43 albertel 881: $pschp='';
1.57 albertel 882: $parmlev = 'full';
1.43 albertel 883: } else {
1.190 albertel 884: $env{'form.url'}='';
1.43 albertel 885: }
886:
1.190 albertel 887: my $id=$env{'form.id'};
1.43 albertel 888: if (($id) && ($udom)) {
889: $uname=(&Apache::lonnet::idget($udom,$id))[1];
890: if ($uname) {
891: $id='';
892: } else {
893: $message=
1.133 www 894: "<font color=red>".&mt("Unknown ID")." '$id' ".
895: &mt('at domain')." '$udom'</font>";
1.43 albertel 896: }
897: } else {
1.190 albertel 898: $uname=$env{'form.uname'};
1.43 albertel 899: }
900: unless ($udom) { $uname=''; }
901: $uhome='';
902: if ($uname) {
903: $uhome=&Apache::lonnet::homeserver($uname,$udom);
904: if ($uhome eq 'no_host') {
905: $message=
1.133 www 906: "<font color=red>".&mt("Unknown user")." '$uname' ".
907: &mt("at domain")." '$udom'</font>";
1.43 albertel 908: $uname='';
1.12 www 909: } else {
1.103 albertel 910: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 911: $env{'request.course.id'});
1.43 albertel 912: if ($csec eq '-1') {
913: $message="<font color=red>".
1.133 www 914: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
915: &mt("not in this course")."</font>";
1.43 albertel 916: $uname='';
1.190 albertel 917: $csec=$env{'form.csec'};
1.43 albertel 918: } else {
919: my %name=&Apache::lonnet::userenvironment($udom,$uname,
920: ('firstname','middlename','lastname','generation','id'));
1.133 www 921: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 922: $name{'firstname'}.' '.$name{'middlename'}.' '
923: .$name{'lastname'}.' '.$name{'generation'}.
1.133 www 924: "<br>\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 925: }
1.12 www 926: }
1.43 albertel 927: }
1.2 www 928:
1.43 albertel 929: unless ($csec) { $csec=''; }
1.12 www 930:
1.190 albertel 931: my $fcat=$env{'form.fcat'};
1.43 albertel 932: unless ($fcat) { $fcat=''; }
1.2 www 933:
1.14 www 934: # --------------------------------------------------------- Get all assessments
1.196 www 935: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
1.63 bowersj2 936:
1.57 albertel 937: $mapp{'0.0'} = '';
938: $symbp{'0.0'} = '';
1.99 albertel 939:
1.14 www 940: # ---------------------------------------------------------- Anything to store?
1.190 albertel 941: if ($env{'form.pres_marker'}) {
942: $message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),
943: $env{'form.pres_value'},
944: $env{'form.pres_type'},
1.187 www 945: $uname,$udom,$csec);
1.68 www 946: # ---------------------------------------------------------------- Done storing
1.130 www 947: $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 948: }
1.2 www 949: # ------------------------------------------------------------------- Sort this
1.17 www 950:
1.44 albertel 951: @ids=sort {
952: if ($fcat eq '') {
953: $a<=>$b;
954: } else {
1.187 www 955: my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
1.44 albertel 956: my $aparm=$outpar[$result];
1.187 www 957: ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
1.44 albertel 958: my $bparm=$outpar[$result];
959: 1*$aparm<=>1*$bparm;
960: }
961: } @ids;
1.57 albertel 962: #----------------------------------------------- if all selected, fill in array
963: if ($pscat[0] eq "all" || !@pscat) {@pscat = (keys %allparms);}
964: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 965: # ------------------------------------------------------------------ Start page
1.63 bowersj2 966:
1.202 www 967: &startpage($r,$id,$udom,$csec,$uname,scalar(keys(%allkeys)));
1.99 albertel 968:
1.57 albertel 969: $r->print('<input type="hidden" value="true" name="prevvisit">');
970:
1.44 albertel 971: foreach ('tolerance','date_default','date_start','date_end',
972: 'date_interval','int','float','string') {
973: $r->print('<input type="hidden" value="'.
1.190 albertel 974: $env{'form.recent_'.$_}.'" name="recent_'.$_.'">');
1.44 albertel 975: }
976:
1.57 albertel 977: $r->print('<h2>'.$message.'</h2><table>');
978:
1.130 www 979: my $submitmessage = &mt('Update Section or Specific User');
1.44 albertel 980: if (!$pssymb) {
1.160 www 981: $r->print('<tr><td>'.&mt('Select Parameter Level').
982: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').
983: '</td><td colspan="2">');
1.57 albertel 984: $r->print('<select name="parmlev">');
985: foreach (reverse sort keys %alllevs) {
986: $r->print('<option value="'.$alllevs{$_}.'"');
987: if ($parmlev eq $alllevs{$_}) {
988: $r->print(' selected');
989: }
990: $r->print('>'.$_.'</option>');
991: }
992: $r->print("</select></td>\n");
993:
1.101 www 994: $r->print('</tr>');
1.128 albertel 995: if ($parmlev ne 'general') {
1.130 www 996: $r->print('<tr><td>'.&mt('Select Enclosing Map or Folder').'</td>');
1.128 albertel 997: $r->print('<td colspan="2"><select name="pschp">');
1.130 www 998: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1.128 albertel 999: foreach (sort {$allmaps{$a} cmp $allmaps{$b}} keys %allmaps) {
1000: $r->print('<option value="'.$_.'"');
1001: if (($pschp eq $_)) { $r->print(' selected'); }
1002: $r->print('>'.$maptitles{$_}.($allmaps{$_}!~/^uploaded/?' ['.$allmaps{$_}.']':'').'</option>');
1003: }
1004: $r->print("</select></td></tr>\n");
1005: }
1.44 albertel 1006: } else {
1.125 www 1007: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.130 www 1008: $r->print("<tr><td>".&mt('Specific Resource')."</td><td>$resource</td>");
1.57 albertel 1009: $r->print('<td><input type="submit" name="dis" value="'.$submitmessage.'"></td>');
1010: $r->print('</tr>');
1011: $r->print('<input type="hidden" value="'.$pssymb.'" name="symb">');
1012: }
1013:
1.185 albertel 1014: $r->print('<tr><td colspan="3"><hr /><label><input type="checkbox"');
1.57 albertel 1015: if ($showoptions eq 'show') {$r->print(" checked ");}
1.185 albertel 1016: $r->print(' name="showoptions" value="show" />'.&mt('Show More Options').'</label><hr /></td></tr>');
1.57 albertel 1017: # $r->print("<tr><td>Show: $showoptions</td></tr>");
1018: # $r->print("<tr><td>pscat: @pscat</td></tr>");
1019: # $r->print("<tr><td>psprt: @psprt</td></tr>");
1020: # $r->print("<tr><td>fcat: $fcat</td></tr>");
1021:
1022: if ($showoptions eq 'show') {
1023: my $tempkey;
1024:
1.130 www 1025: $r->print('<tr><td colspan="3" align="center">'.&mt('Select Parameters to View').'</td></tr>');
1.57 albertel 1026:
1.176 albertel 1027: $r->print('<tr><td colspan="2"><table><tr>');
1.57 albertel 1028: my $cnt=0;
1029: foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} }
1030: keys %allparms ) {
1031: ++$cnt;
1.176 albertel 1032: $r->print('</tr><tr>') if ($cnt%2);
1.57 albertel 1033: $r->print('<td><input type="checkbox" name="pscat" ');
1034: $r->print('value="'.$tempkey.'"');
1035: if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) {
1036: $r->print(' checked');
1037: }
1.176 albertel 1038: $r->print('>'.$allparms{$tempkey}.'</td>');
1039: }
1040: $r->print('
1041: </tr><tr><td>
1042: <script type="text/javascript">
1043: function checkall(value, checkName) {
1044: for (i=0; i<document.forms.parmform.elements.length; i++) {
1045: ele = document.forms.parmform.elements[i];
1046: if (ele.name == checkName) {
1047: document.forms.parmform.elements[i].checked=value;
1048: }
1.57 albertel 1049: }
1.176 albertel 1050: }
1051: </script>
1052: <input type="button" onclick="checkall(true, \'pscat\')" value="Select All" />
1053: </td><td>
1054: <input type="button" onclick="checkall(false, \'pscat\')" value="Unselect All" />
1055: </td>
1056: ');
1.57 albertel 1057: $r->print('</tr></table>');
1058:
1059: # $r->print('<tr><td>Select Parts</td><td>');
1060: $r->print('<td><select multiple name="psprt" size="5">');
1061: $r->print('<option value="all"');
1062: $r->print(' selected') unless (@psprt);
1.130 www 1063: $r->print('>'.&mt('All Parts').'</option>');
1.76 www 1064: my %temphash=();
1065: foreach (@psprt) { $temphash{$_}=1; }
1.57 albertel 1066: foreach $tempkey (sort keys %allparts) {
1067: unless ($tempkey =~ /\./) {
1068: $r->print('<option value="'.$tempkey.'"');
1.76 www 1069: if ($psprt[0] eq "all" || $temphash{$tempkey}) {
1.57 albertel 1070: $r->print(' selected');
1071: }
1072: $r->print('>'.$allparts{$tempkey}.'</option>');
1073: }
1074: }
1075: $r->print('</select></td></tr><tr><td colspan="3"><hr /></td></tr>');
1076:
1.130 www 1077: $r->print('<tr><td>'.&mt('Sort list by').'</td><td>');
1.57 albertel 1078: $r->print('<select name="fcat">');
1.130 www 1079: $r->print('<option value="">'.&mt('Enclosing Map or Folder').'</option>');
1.57 albertel 1080: foreach (sort keys %allkeys) {
1081: $r->print('<option value="'.$_.'"');
1082: if ($fcat eq $_) { $r->print(' selected'); }
1083: $r->print('>'.$allkeys{$_}.'</option>');
1084: }
1085: $r->print('</select></td>');
1086:
1087: $r->print('</tr><tr><td colspan="3"><hr /></td></tr>');
1088:
1089: } else { # hide options - include any necessary extras here
1090:
1091: $r->print('<input type="hidden" name="fcat" value="'.$fcat.'">'."\n");
1092:
1093: unless (@pscat) {
1094: foreach (keys %allparms ) {
1095: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1096: }
1097: } else {
1098: foreach (@pscat) {
1099: $r->print('<input type="hidden" name="pscat" value="'.$_.'">'."\n");
1100: }
1101: }
1102:
1103: unless (@psprt) {
1104: foreach (keys %allparts ) {
1105: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1106: }
1107: } else {
1108: foreach (@psprt) {
1109: $r->print('<input type="hidden" name="psprt" value="'.$_.'">'."\n");
1110: }
1111: }
1112:
1.44 albertel 1113: }
1.101 www 1114: $r->print('</table><br />');
1115: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.130 www 1116: $submitmessage = &mt("Update Course Assessment Parameter Display");
1.101 www 1117: } else {
1.130 www 1118: $submitmessage = &mt("Set/Modify Course Assessment Parameters");
1.101 www 1119: }
1120: $r->print('<input type="submit" name="dis" value="'.$submitmessage.'">');
1.57 albertel 1121:
1.76 www 1122: # my @temp_psprt;
1123: # foreach my $t (@psprt) {
1124: # push(@temp_psprt, grep {eval (/^$t\./ || ($_ == $t))} (keys %allparts));
1125: # }
1.57 albertel 1126:
1.76 www 1127: # @psprt = @temp_psprt;
1.57 albertel 1128:
1129: my @temp_pscat;
1130: map {
1131: my $cat = $_;
1132: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1133: } @pscat;
1134:
1135: @pscat = @temp_pscat;
1136:
1137: if (($prevvisit) || ($pschp) || ($pssymb)) {
1.10 www 1138: # ----------------------------------------------------------------- Start Table
1.57 albertel 1139: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1140: my $csuname=$env{'user.name'};
1141: my $csudom=$env{'user.domain'};
1.57 albertel 1142:
1.203 www 1143: if ($parmlev eq 'full') {
1.57 albertel 1144: my $coursespan=$csec?8:5;
1145: $r->print('<p><table border=2>');
1146: $r->print('<tr><td colspan=5></td>');
1.130 www 1147: $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
1.57 albertel 1148: if ($uname) {
1149: $r->print("<th colspan=3 rowspan=2>");
1.130 www 1150: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1151: }
1.133 www 1152: my %lt=&Apache::lonlocal::texthash(
1153: 'pie' => "Parameter in Effect",
1154: 'csv' => "Current Session Value",
1155: 'at' => 'at',
1156: 'rl' => "Resource Level",
1157: 'ic' => 'in Course',
1158: 'aut' => "Assessment URL and Title",
1.143 albertel 1159: 'type' => 'Type',
1.133 www 1160: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1161: 'part' => 'Part',
1.133 www 1162: 'pn' => 'Parameter Name',
1163: 'def' => 'default',
1164: 'femof' => 'from Enclosing Map or Folder',
1165: 'gen' => 'general',
1166: 'foremf' => 'for Enclosing Map or Folder',
1167: 'fr' => 'for Resource'
1168: );
1.57 albertel 1169: $r->print(<<ENDTABLETWO);
1.133 www 1170: <th rowspan=3>$lt{'pie'}</th>
1171: <th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th>
1.182 albertel 1172: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
1173: <th colspan=1>$lt{'ic'}</th>
1174:
1.10 www 1175: ENDTABLETWO
1.57 albertel 1176: if ($csec) {
1.133 www 1177: $r->print("<th colspan=3>".
1178: &mt("in Section/Group")." $csec</th>");
1.57 albertel 1179: }
1180: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1181: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1182: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1183: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1184: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1185: ENDTABLEHEADFOUR
1.57 albertel 1186:
1187: if ($csec) {
1.130 www 1188: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1189: }
1190:
1191: if ($uname) {
1.130 www 1192: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1193: }
1194:
1195: $r->print('</tr>');
1196:
1197: my $defbgone='';
1198: my $defbgtwo='';
1199:
1200: foreach (@ids) {
1201:
1202: my $rid=$_;
1203: my ($inmapid)=($rid=~/\.(\d+)$/);
1204:
1.152 albertel 1205: if ((!$pssymb &&
1206: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1207: ||
1208: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1209: # ------------------------------------------------------ Entry for one resource
1.184 albertel 1210: if ($defbgone eq '"#E0E099"') {
1211: $defbgone='"#E0E0DD"';
1.57 albertel 1212: } else {
1.184 albertel 1213: $defbgone='"#E0E099"';
1.57 albertel 1214: }
1.184 albertel 1215: if ($defbgtwo eq '"#FFFF99"') {
1216: $defbgtwo='"#FFFFDD"';
1.57 albertel 1217: } else {
1.184 albertel 1218: $defbgtwo='"#FFFF99"';
1.57 albertel 1219: }
1220: my $thistitle='';
1221: my %name= ();
1222: undef %name;
1223: my %part= ();
1224: my %display=();
1225: my %type= ();
1226: my %default=();
1.196 www 1227: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1228:
1229: foreach (split(/\,/,$keyp{$rid})) {
1230: my $tempkeyp = $_;
1231: if (grep $_ eq $tempkeyp, @catmarker) {
1232: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1233: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1234: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1235: unless ($display{$_}) { $display{$_}=''; }
1236: $display{$_}.=' ('.$name{$_}.')';
1237: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1238: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1239: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1240: }
1241: }
1242: my $totalparms=scalar keys %name;
1243: if ($totalparms>0) {
1244: my $firstrow=1;
1.180 albertel 1245: my $title=&Apache::lonnet::gettitle($uri);
1.57 albertel 1246: $r->print('<tr><td bgcolor='.$defbgone.
1247: ' rowspan='.$totalparms.
1248: '><tt><font size=-1>'.
1249: join(' / ',split(/\//,$uri)).
1250: '</font></tt><p><b>'.
1.154 albertel 1251: "<a href=\"javascript:openWindow('".
1252: &Apache::lonnet::clutter($uri).
1.57 albertel 1253: "', 'metadatafile', '450', '500', 'no', 'yes')\";".
1.127 albertel 1254: " TARGET=_self>$title");
1.57 albertel 1255:
1256: if ($thistitle) {
1257: $r->print(' ('.$thistitle.')');
1258: }
1259: $r->print('</a></b></td>');
1260: $r->print('<td bgcolor='.$defbgtwo.
1261: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1262: '</td>');
1263:
1264: $r->print('<td bgcolor='.$defbgone.
1265: ' rowspan='.$totalparms.
1266: '><tt><font size=-1>');
1267:
1268: $r->print(' / res / ');
1269: $r->print(join(' / ', split(/\//,$mapp{$rid})));
1270:
1271: $r->print('</font></tt></td>');
1272:
1273: foreach (sort keys %name) {
1274: unless ($firstrow) {
1275: $r->print('<tr>');
1276: } else {
1277: undef $firstrow;
1278: }
1279:
1.201 www 1280: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 1281: \%type,\%display,$defbgone,$defbgtwo,
1.187 www 1282: $parmlev,$uname,$udom,$csec);
1.57 albertel 1283: }
1284: }
1285: }
1286: } # end foreach ids
1.43 albertel 1287: # -------------------------------------------------- End entry for one resource
1.57 albertel 1288: $r->print('</table>');
1.203 www 1289: } # end of full
1.57 albertel 1290: #--------------------------------------------------- Entry for parm level map
1291: if ($parmlev eq 'map') {
1292: my $defbgone = '"E0E099"';
1293: my $defbgtwo = '"FFFF99"';
1294:
1295: my %maplist;
1296:
1297: if ($pschp eq 'all') {
1298: %maplist = %allmaps;
1299: } else {
1300: %maplist = ($pschp => $mapp{$pschp});
1301: }
1302:
1303: #-------------------------------------------- for each map, gather information
1304: my $mapid;
1.60 albertel 1305: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1306: my $maptitle = $maplist{$mapid};
1.57 albertel 1307:
1308: #----------------------- loop through ids and get all parameter types for map
1309: #----------------------------------------- and associated information
1310: my %name = ();
1311: my %part = ();
1312: my %display = ();
1313: my %type = ();
1314: my %default = ();
1315: my $map = 0;
1316:
1317: # $r->print("Catmarker: @catmarker<br />\n");
1318:
1319: foreach (@ids) {
1320: ($map)=(/([\d]*?)\./);
1321: my $rid = $_;
1322:
1323: # $r->print("$mapid:$map: $rid <br /> \n");
1324:
1325: if ($map eq $mapid) {
1.196 www 1326: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1327: # $r->print("Keys: $keyp{$rid} <br />\n");
1328:
1329: #--------------------------------------------------------------------
1330: # @catmarker contains list of all possible parameters including part #s
1331: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1332: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1333: # When storing information, store as part 0
1334: # When requesting information, request from full part
1335: #-------------------------------------------------------------------
1336: foreach (split(/\,/,$keyp{$rid})) {
1337: my $tempkeyp = $_;
1338: my $fullkeyp = $tempkeyp;
1.73 albertel 1339: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1340:
1341: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1342: $part{$tempkeyp}="0";
1343: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1344: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1345: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1346: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1347: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1348: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1349: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1350: }
1351: } # end loop through keys
1352: }
1353: } # end loop through ids
1354:
1355: #---------------------------------------------------- print header information
1.133 www 1356: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 1357: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.57 albertel 1358: $r->print(<<ENDMAPONE);
1359: <center><h4>
1.135 albertel 1360: Set Defaults for All Resources in $foldermap<br />
1361: <font color="red"><i>$showtitle</i></font><br />
1.57 albertel 1362: Specifically for
1363: ENDMAPONE
1364: if ($uname) {
1365: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1366: ('firstname','middlename','lastname','generation', 'id'));
1367: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1368: .$name{'lastname'}.' '.$name{'generation'};
1.135 albertel 1369: $r->print(&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
1.130 www 1370: &mt('in')." \n");
1.57 albertel 1371: } else {
1.135 albertel 1372: $r->print("<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n");
1.57 albertel 1373: }
1374:
1.135 albertel 1375: if ($csec) {$r->print(&mt("Section")." <font color=\"red\"><i>$csec</i></font> ".
1.130 www 1376: &mt('of')." \n")};
1.57 albertel 1377:
1.135 albertel 1378: $r->print("<font color=\"red\"><i>$coursename</i></font><br />");
1379: $r->print("</h4>\n");
1.57 albertel 1380: #---------------------------------------------------------------- print table
1381: $r->print('<p><table border="2">');
1.130 www 1382: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1383: $r->print('<th>'.&mt('Default Value').'</th>');
1384: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1385:
1386: foreach (sort keys %name) {
1.168 matthew 1387: $r->print('<tr>');
1.201 www 1388: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.57 albertel 1389: \%type,\%display,$defbgone,$defbgtwo,
1.187 www 1390: $parmlev,$uname,$udom,$csec);
1.57 albertel 1391: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1392: }
1393: $r->print("</table></center>");
1394: } # end each map
1395: } # end of $parmlev eq map
1396: #--------------------------------- Entry for parm level general (Course level)
1397: if ($parmlev eq 'general') {
1398: my $defbgone = '"E0E099"';
1399: my $defbgtwo = '"FFFF99"';
1400:
1401: #-------------------------------------------- for each map, gather information
1402: my $mapid="0.0";
1403: #----------------------- loop through ids and get all parameter types for map
1404: #----------------------------------------- and associated information
1405: my %name = ();
1406: my %part = ();
1407: my %display = ();
1408: my %type = ();
1409: my %default = ();
1410:
1411: foreach (@ids) {
1412: my $rid = $_;
1413:
1.196 www 1414: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1415:
1416: #--------------------------------------------------------------------
1417: # @catmarker contains list of all possible parameters including part #s
1418: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1419: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1420: # When storing information, store as part 0
1421: # When requesting information, request from full part
1422: #-------------------------------------------------------------------
1423: foreach (split(/\,/,$keyp{$rid})) {
1424: my $tempkeyp = $_;
1425: my $fullkeyp = $tempkeyp;
1.73 albertel 1426: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1427: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1428: $part{$tempkeyp}="0";
1429: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1430: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1431: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1432: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1433: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1434: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1435: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1436: }
1437: } # end loop through keys
1438: } # end loop through ids
1439:
1440: #---------------------------------------------------- print header information
1.133 www 1441: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 1442: $r->print(<<ENDMAPONE);
1.133 www 1443: <center><h4>$setdef
1.135 albertel 1444: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 1445: ENDMAPONE
1446: if ($uname) {
1447: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1448: ('firstname','middlename','lastname','generation', 'id'));
1449: my $person=$name{'firstname'}.' '.$name{'middlename'}.' '
1450: .$name{'lastname'}.' '.$name{'generation'};
1.135 albertel 1451: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 1452: } else {
1.135 albertel 1453: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 1454: }
1455:
1.135 albertel 1456: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1457: $r->print("</h4>\n");
1.57 albertel 1458: #---------------------------------------------------------------- print table
1459: $r->print('<p><table border="2">');
1.130 www 1460: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1461: $r->print('<th>'.&mt('Default Value').'</th>');
1462: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1463:
1464: foreach (sort keys %name) {
1.168 matthew 1465: $r->print('<tr>');
1.201 www 1466: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.187 www 1467: \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
1.57 albertel 1468: # $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
1469: }
1470: $r->print("</table></center>");
1471: } # end of $parmlev eq general
1.43 albertel 1472: }
1.44 albertel 1473: $r->print('</form></body></html>');
1.57 albertel 1474: } # end sub assessparms
1.30 www 1475:
1.59 matthew 1476:
1477: ##################################################
1478: ##################################################
1479:
1480: =pod
1481:
1482: =item crsenv
1483:
1.105 matthew 1484: Show and set course data and parameters. This is a large routine that should
1.59 matthew 1485: be simplified and shortened... someday.
1486:
1487: Inputs: $r
1488:
1489: Returns: nothing
1490:
1491: =cut
1492:
1493: ##################################################
1494: ##################################################
1.30 www 1495: sub crsenv {
1496: my $r=shift;
1497: my $setoutput='';
1.64 www 1498: my $bodytag=&Apache::loncommon::bodytag(
1499: 'Set Course Environment Parameters');
1.194 albertel 1500: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,
1501: 'Edit Course Environment');
1.190 albertel 1502: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1503: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 1504:
1505: #
1506: # Go through list of changes
1.190 albertel 1507: foreach (keys %env) {
1.105 matthew 1508: next if ($_!~/^form\.(.+)\_setparmval$/);
1509: my $name = $1;
1.190 albertel 1510: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 1511: if ($name eq 'newp') {
1.190 albertel 1512: $name = $env{'form.newp_name'};
1.105 matthew 1513: }
1514: if ($name eq 'url') {
1515: $value=~s/^\/res\///;
1516: my $bkuptime=time;
1517: my @tmp = &Apache::lonnet::get
1518: ('environment',['url'],$dom,$crs);
1.130 www 1519: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 1520: &Apache::lonnet::put
1521: ('environment',
1522: {'top level map backup '.$bkuptime => $tmp[1] },
1523: $dom,$crs).
1524: '<br>';
1525: }
1526: #
1527: # Deal with modified default spreadsheets
1528: if ($name =~ /^spreadsheet_default_(classcalc|
1529: studentcalc|
1530: assesscalc)$/x) {
1531: my $sheettype = $1;
1532: if ($sheettype eq 'classcalc') {
1533: # no need to do anything since viewing the sheet will
1534: # cause it to be updated.
1535: } elsif ($sheettype eq 'studentcalc') {
1536: # expire all the student spreadsheets
1537: &Apache::lonnet::expirespread('','','studentcalc');
1538: } else {
1539: # expire all the assessment spreadsheets
1540: # this includes non-default spreadsheets, but better to
1541: # be safe than sorry.
1542: &Apache::lonnet::expirespread('','','assesscalc');
1543: # expire all the student spreadsheets
1544: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 1545: }
1.105 matthew 1546: }
1547: #
1.107 matthew 1548: # Deal with the enrollment dates
1549: if ($name =~ /^default_enrollment_(start|end)_date$/) {
1550: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
1551: }
1.178 raeburn 1552: # Get existing cloners
1553: my @oldcloner = ();
1554: if ($name eq 'cloners') {
1555: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
1556: if ($clonenames{'cloners'} =~ /,/) {
1557: @oldcloner = split/,/,$clonenames{'cloners'};
1558: } else {
1559: $oldcloner[0] = $clonenames{'cloners'};
1560: }
1561: }
1.107 matthew 1562: #
1.105 matthew 1563: # Let the user know we made the changes
1.153 albertel 1564: if ($name && defined($value)) {
1.178 raeburn 1565: if ($name eq 'cloners') {
1566: $value =~ s/^,//;
1567: $value =~ s/,$//;
1568: }
1.105 matthew 1569: my $put_result = &Apache::lonnet::put('environment',
1570: {$name=>$value},$dom,$crs);
1571: if ($put_result eq 'ok') {
1.130 www 1572: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>'.$value.'</b>.<br />';
1.178 raeburn 1573: if ($name eq 'cloners') {
1574: &change_clone($value,\@oldcloner);
1575: }
1.179 raeburn 1576: # Flush the course logs so course description is immediately updated
1577: if ($name eq 'description' && defined($value)) {
1578: &Apache::lonnet::flushcourselogs();
1579: }
1.105 matthew 1580: } else {
1.130 www 1581: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
1582: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 1583: }
1584: }
1.38 harris41 1585: }
1.108 www 1586: # ------------------------- Re-init course environment entries for this session
1587:
1.190 albertel 1588: &Apache::lonnet::coursedescription($env{'request.course.id'});
1.105 matthew 1589:
1.30 www 1590: # -------------------------------------------------------- Get parameters again
1.45 matthew 1591:
1592: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 1593: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 1594: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 1595: my $output='';
1.45 matthew 1596: if (! exists($values{'con_lost'})) {
1.30 www 1597: my %descriptions=
1.140 sakharuk 1598: ('url' => '<b>'.&mt('Top Level Map').'</b> '.
1.46 matthew 1599: '<a href="javascript:openbrowser'.
1.47 matthew 1600: "('envform','url','sequence')\">".
1.140 sakharuk 1601: &mt('Select Map').'</a><br /><font color=red> '.
1602: &mt('Modification may make assessment data inaccessible').
1603: '</font>',
1604: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 1605: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 1606: '</b><br />'.
1607: '('.&mt('internal').', '.&mt('optional').')',
1.177 raeburn 1608: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain)</tt><br />'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'),
1.150 www 1609: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1610: '<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'),
1.140 sakharuk 1611: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '.
1.52 www 1612: '<a href="javascript:openbrowser'.
1613: "('envform','default_xml_style'".
1.140 sakharuk 1614: ",'sty')\">$SelectStyleFile</a><br>",
1.141 sakharuk 1615: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').
1616: '</b><br />(<tt>user:domain,'.
1.74 www 1617: 'user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 1618: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'.
1.74 www 1619: '(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 1620: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b>'.
1.75 albertel 1621: '<br />(<tt>user:domain,user:domain(section;section;...;*;...),...</tt>)',
1.141 sakharuk 1622: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'.
1.158 sakharuk 1623: '('.&mt('"[_1]" for default hiding','<tt>yes</tt>').')',
1.141 sakharuk 1624: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'.
1.158 sakharuk 1625: '('.&mt('"[_1]" for visible separation','<tt>yes</tt>').', '.
1.141 sakharuk 1626: &mt('changes will not show until next login').')',
1.169 matthew 1627: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b>'.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'),
1.118 matthew 1628:
1.141 sakharuk 1629: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').
1630: '</b><br />"<tt>st</tt>": '.
1.158 sakharuk 1631: &mt('student').', "<tt>ta</tt>": '.
1.118 matthew 1632: 'TA, "<tt>in</tt>": '.
1.158 sakharuk 1633: &mt('instructor').';<br /><tt>'.&mt('role,role,...').'</tt>) '.
1.118 matthew 1634: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1635: 'plc.users.denied' =>
1.141 sakharuk 1636: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.118 matthew 1637: '(<tt>user:domain,user:domain,...</tt>)',
1638:
1.141 sakharuk 1639: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').
1640: '</b><br />"<tt>st</tt>": '.
1.61 albertel 1641: 'student, "<tt>ta</tt>": '.
1642: 'TA, "<tt>in</tt>": '.
1.75 albertel 1643: 'instructor;<br /><tt>role,role,...</tt>) '.
1.61 albertel 1644: Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 1645: 'pch.users.denied' =>
1.141 sakharuk 1646: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.53 www 1647: '(<tt>user:domain,user:domain,...</tt>)',
1.49 matthew 1648: 'spreadsheet_default_classcalc'
1.141 sakharuk 1649: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 1650: '<a href="javascript:openbrowser'.
1651: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 1652: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 1653: 'spreadsheet_default_studentcalc'
1.141 sakharuk 1654: => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
1.50 matthew 1655: '<a href="javascript:openbrowser'.
1656: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 1657: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 1658: 'spreadsheet_default_assesscalc'
1.141 sakharuk 1659: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 1660: '<a href="javascript:openbrowser'.
1661: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 1662: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 1663: 'allow_limited_html_in_feedback'
1.141 sakharuk 1664: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.158 sakharuk 1665: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.170 raeburn 1666: 'allow_discussion_post_editing'
1667: => '<b>'.&mt('Allow users to edit/delete their own discussion posts').'</b><br />'.
1668: '('.&mt('Set value to "[_1]" to allow',"<tt>yes</tt>").')',
1.89 albertel 1669: 'rndseed'
1.140 sakharuk 1670: => '<b>'.&mt('Randomization algorithm used').'</b> <br />'.
1671: '<font color="red">'.&mt('Modifying this will make problems').' '.
1672: &mt('have different numbers and answers').'</font>',
1.151 albertel 1673: 'receiptalg'
1674: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
1675: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 1676: 'suppress_tries'
1677: => '<b>'.&mt('Suppress number of tries in printing').'</b>('.
1678: &mt('yes if supress').')',
1.113 sakharuk 1679: 'problem_stream_switch'
1.141 sakharuk 1680: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.158 sakharuk 1681: ' ('.&mt('"[_1]" if allowed, anything else if not','<tt>yes</tt>').')',
1.161 sakharuk 1682: 'default_paper_size'
1683: => '<b>'.&mt('Default paper type').'</b><br />'.
1684: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
1685: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
1686: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.111 sakharuk 1687: 'anonymous_quiz'
1.150 www 1688: => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
1.141 sakharuk 1689: ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
1690: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date when enrolling students').'</b>',
1691: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date when enrolling students').'</b>',
1.150 www 1692: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b>'.
1693: '<br />(<tt>user:domain,user:domain,...</tt>)',
1.140 sakharuk 1694: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 1695: 'disable_receipt_display'
1.141 sakharuk 1696: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 1697: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.163 albertel 1698: 'disablesigfigs'
1699: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
1700: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.149 albertel 1701: 'tthoptions'
1702: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>'
1.107 matthew 1703: );
1.177 raeburn 1704: my @Display_Order = ('url','description','courseid','cloners','grading',
1.107 matthew 1705: 'default_xml_style','pageseparators',
1706: 'question.email','comment.email','policy.email',
1.169 matthew 1707: 'student_classlist_view',
1.118 matthew 1708: 'plc.roles.denied','plc.users.denied',
1.107 matthew 1709: 'pch.roles.denied','pch.users.denied',
1710: 'allow_limited_html_in_feedback',
1.170 raeburn 1711: 'allow_discussion_post_editing',
1.108 www 1712: 'languages',
1.150 www 1713: 'nothideprivileged',
1.107 matthew 1714: 'rndseed',
1.151 albertel 1715: 'receiptalg',
1.107 matthew 1716: 'problem_stream_switch',
1.164 sakharuk 1717: 'suppress_tries',
1.161 sakharuk 1718: 'default_paper_size',
1.115 www 1719: 'disable_receipt_display',
1.107 matthew 1720: 'spreadsheet_default_classcalc',
1721: 'spreadsheet_default_studentcalc',
1722: 'spreadsheet_default_assesscalc',
1723: 'hideemptyrows',
1724: 'default_enrollment_start_date',
1725: 'default_enrollment_end_date',
1.163 albertel 1726: 'tthoptions',
1727: 'disablesigfigs'
1.107 matthew 1728: );
1729: foreach my $parameter (sort(keys(%values))) {
1.142 raeburn 1730: unless ($parameter =~ m/^internal\./) {
1731: if (! $descriptions{$parameter}) {
1732: $descriptions{$parameter}=$parameter;
1733: push(@Display_Order,$parameter);
1734: }
1735: }
1.43 albertel 1736: }
1.107 matthew 1737: foreach my $parameter (@Display_Order) {
1738: my $description = $descriptions{$parameter};
1.51 matthew 1739: # onchange is javascript to automatically check the 'Set' button.
1.69 www 1740: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 1741: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 1742: '.checked=true;"';
1.107 matthew 1743: $output .= '<tr><td>'.$description.'</td>';
1744: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
1745: $output .= '<td>'.
1746: &Apache::lonhtmlcommon::date_setter('envform',
1747: $parameter.'_value',
1748: $values{$parameter},
1749: $onchange).
1750: '</td>';
1751: } else {
1752: $output .= '<td>'.
1753: &Apache::lonhtmlcommon::textbox($parameter.'_value',
1754: $values{$parameter},
1755: 40,$onchange).'</td>';
1756: }
1757: $output .= '<td>'.
1758: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
1759: '</td>';
1760: $output .= "</tr>\n";
1.51 matthew 1761: }
1.69 www 1762: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 1763: '[\'envform\'].elements[\'newp_setparmval\']'.
1764: '.checked=true;"';
1.130 www 1765: $output.='<tr><td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 1766: '<input type="text" size=40 name="newp_name" '.
1767: $onchange.' /></td><td>'.
1768: '<input type="text" size=40 name="newp_value" '.
1769: $onchange.' /></td><td>'.
1770: '<input type="checkbox" name="newp_setparmval" /></td></tr>';
1.43 albertel 1771: }
1.157 sakharuk 1772: my %lt=&Apache::lonlocal::texthash(
1773: 'par' => 'Parameter',
1774: 'val' => 'Value',
1775: 'set' => 'Set',
1776: 'sce' => 'Set Course Environment'
1777: );
1778:
1.140 sakharuk 1779: my $Parameter=&mt('Parameter');
1780: my $Value=&mt('Value');
1.141 sakharuk 1781: my $Set=&mt('Set');
1.167 albertel 1782: my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset');
1.183 albertel 1783: my $html=&Apache::lonxml::xmlbegin();
1.190 albertel 1784: $r->print(<<ENDenv);
1.183 albertel 1785: $html
1786: <head>
1.46 matthew 1787: <script type="text/javascript" language="Javascript" >
1.155 albertel 1788: $browse_js
1.46 matthew 1789: </script>
1.30 www 1790: <title>LON-CAPA Course Environment</title>
1791: </head>
1.64 www 1792: $bodytag
1.193 albertel 1793: $breadcrumbs
1794: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 1795: $setoutput
1796: <p>
1797: <table border=2>
1.157 sakharuk 1798: <tr><th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}?</th></tr>
1.30 www 1799: $output
1800: </table>
1.157 sakharuk 1801: <input type="submit" name="crsenv" value="$lt{'sce'}">
1.30 www 1802: </form>
1803: </body>
1804: </html>
1.190 albertel 1805: ENDenv
1.30 www 1806: }
1.120 www 1807: ##################################################
1.30 www 1808:
1.124 www 1809: my $tableopen;
1810:
1811: sub tablestart {
1812: if ($tableopen) {
1813: return '';
1814: } else {
1815: $tableopen=1;
1.130 www 1816: return '<table border="2"><tr><th>'.&mt('Parameter').'</th><th>'.
1817: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 1818: }
1819: }
1820:
1821: sub tableend {
1822: if ($tableopen) {
1823: $tableopen=0;
1824: return '</table>';
1825: } else {
1826: return'';
1827: }
1828: }
1829:
1.120 www 1830: sub overview {
1831: my $r=shift;
1832: my $bodytag=&Apache::loncommon::bodytag(
1833: 'Set/Modify Course Assessment Parameters');
1.190 albertel 1834: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1835: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.194 albertel 1836: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef,'Overview');
1.183 albertel 1837: my $html=&Apache::lonxml::xmlbegin();
1.120 www 1838: $r->print(<<ENDOVER);
1.183 albertel 1839: $html
1.120 www 1840: <head>
1841: <title>LON-CAPA Course Environment</title>
1842: </head>
1843: $bodytag
1.193 albertel 1844: $breadcrumbs
1845: <form method="post" action="/adm/parmset?action=setoverview" name="overviewform">
1.120 www 1846: <input type="hidden" name="overview" value="1" />
1847: ENDOVER
1.124 www 1848: # Setting
1849: my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
1850: my %newdata=();
1851: undef %newdata;
1852: my @deldata=();
1853: undef @deldata;
1.190 albertel 1854: foreach (keys %env) {
1.124 www 1855: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
1856: my $cmd=$1;
1857: my $thiskey=$2;
1858: if ($cmd eq 'set') {
1.190 albertel 1859: my $data=$env{$_};
1.124 www 1860: if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
1861: } elsif ($cmd eq 'del') {
1862: push (@deldata,$thiskey);
1863: } elsif ($cmd eq 'datepointer') {
1.190 albertel 1864: my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
1.153 albertel 1865: if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }
1.124 www 1866: }
1867: }
1868: }
1869: # Store
1.144 www 1870: my $delentries=$#deldata+1;
1871: my @newdatakeys=keys %newdata;
1872: my $putentries=$#newdatakeys+1;
1873: if ($delentries) {
1874: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1875: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
1876: } else {
1877: $r->print('<h2><font color="red">'.
1878: &mt('Error deleting parameters').'</font></h2>');
1879: }
1880: }
1881: if ($putentries) {
1882: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1883: $r->print('<h2>'.&mt('Stored [_1] parameter(s)</h2>',$putentries));
1884: } else {
1885: $r->print('<h2><font color="red">'.
1886: &mt('Error storing parameters').'</font></h2>');
1887: }
1888: }
1.122 www 1889: # Read and display
1890: my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);
1891: my $oldsection='';
1892: my $oldrealm='';
1893: my $oldpart='';
1.123 www 1894: my $pointer=0;
1.124 www 1895: $tableopen=0;
1.145 www 1896: my $foundkeys=0;
1.122 www 1897: foreach my $thiskey (sort keys %resourcedata) {
1.123 www 1898: if ($resourcedata{$thiskey.'.type'}) {
1899: my ($course,$middle,$part,$name)=
1900: ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 1901: my $section=&mt('All Students');
1.122 www 1902: if ($middle=~/^\[(.*)\]\./) {
1.130 www 1903: $section=&mt('Group/Section').': '.$1;
1.122 www 1904: $middle=~s/^\[(.*)\]\.//;
1905: }
1.123 www 1906: $middle=~s/\.$//;
1.130 www 1907: my $realm='<font color="red">'.&mt('All Resources').'</font>';
1.122 www 1908: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.174 albertel 1909: $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
1.122 www 1910: } elsif ($middle) {
1.174 albertel 1911: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1912: $realm='<font color="orange">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><font color="#aaaaaa" size="-2">('.$url.' in '.$map.' id: '.$id.')</font></font>';
1.122 www 1913: }
1914: if ($section ne $oldsection) {
1.124 www 1915: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
1.122 www 1916: $oldsection=$section;
1917: $oldrealm='';
1918: }
1919: if ($realm ne $oldrealm) {
1.124 www 1920: $r->print(&tableend()."\n<h2>$realm</h2>");
1.122 www 1921: $oldrealm=$realm;
1922: $oldpart='';
1923: }
1924: if ($part ne $oldpart) {
1.124 www 1925: $r->print(&tableend().
1.130 www 1926: "\n<h3><font color='blue'>".&mt('Part').": $part</font></h3>");
1.122 www 1927: $oldpart=$part;
1928: }
1.123 www 1929: #
1930: # Ready to print
1931: #
1.124 www 1932: $r->print(&tablestart().'<tr><td><b>'.$name.
1933: ':</b></td><td><input type="checkbox" name="del_'.
1934: $thiskey.'" /></td><td>');
1.145 www 1935: $foundkeys++;
1.123 www 1936: if ($resourcedata{$thiskey.'.type'}=~/^date/) {
1937: my $jskey='key_'.$pointer;
1938: $pointer++;
1939: $r->print(
1940: &Apache::lonhtmlcommon::date_setter('overviewform',
1941: $jskey,
1942: $resourcedata{$thiskey}).
1943: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
1944: );
1945: } else {
1946: $r->print(
1947: '<input type="text" name="set_'.$thiskey.'" value="'.
1948: $resourcedata{$thiskey}.'">');
1949: }
1.124 www 1950: $r->print('</td></tr>');
1.122 www 1951: }
1.121 www 1952: }
1.124 www 1953:
1.145 www 1954: $r->print(&tableend().'<p>'.
1955: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no course or section parameters.')).'</p></form></body></html>');
1.120 www 1956: }
1.121 www 1957:
1.59 matthew 1958: ##################################################
1959: ##################################################
1.178 raeburn 1960:
1961: =pod
1962:
1963: =item change clone
1964:
1965: Modifies the list of courses a user can clone (stored
1966: in the user's environemnt.db file), called when a
1967: change is made to the list of users allowed to clone
1968: a course.
1969:
1970: Inputs: $action,$cloner
1971: where $action is add or drop, and $cloner is identity of
1972: user for whom cloning ability is to be changed in course.
1973:
1974: Returns:
1975:
1976: =cut
1977:
1978: ##################################################
1979: ##################################################
1980:
1981:
1982: sub change_clone {
1983: my ($clonelist,$oldcloner) = @_;
1984: my ($uname,$udom);
1.190 albertel 1985: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1986: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 1987: my $clone_crs = $cnum.':'.$cdom;
1988:
1989: if ($cnum && $cdom) {
1990: my @allowclone = ();
1991: if ($clonelist =~ /,/) {
1992: @allowclone = split/,/,$clonelist;
1993: } else {
1994: $allowclone[0] = $clonelist;
1995: }
1996: foreach my $currclone (@allowclone) {
1997: if (!grep/^$currclone$/,@$oldcloner) {
1998: ($uname,$udom) = split/:/,$currclone;
1999: if ($uname && $udom) {
2000: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2001: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2002: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
2003: if ($currclonecrs{'cloneable'} eq '') {
2004: $currclonecrs{'cloneable'} = $clone_crs;
2005: } else {
2006: $currclonecrs{'cloneable'} .= ','.$clone_crs;
2007: }
2008: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
2009: }
2010: }
2011: }
2012: }
2013: }
2014: foreach my $oldclone (@$oldcloner) {
2015: if (!grep/^$oldclone$/,@allowclone) {
2016: ($uname,$udom) = split/:/,$oldclone;
2017: if ($uname && $udom) {
2018: unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
2019: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
2020: my %newclonecrs = ();
2021: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
2022: if ($currclonecrs{'cloneable'} =~ /,/) {
2023: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
2024: foreach (@currclonecrs) {
2025: unless ($_ eq $clone_crs) {
2026: $newclonecrs{'cloneable'} .= $_.',';
2027: }
2028: }
2029: $newclonecrs{'cloneable'} =~ s/,$//;
2030: } else {
2031: $newclonecrs{'cloneable'} = '';
2032: }
2033: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
2034: }
2035: }
2036: }
2037: }
2038: }
2039: }
2040: }
2041:
1.193 albertel 2042:
2043: ##################################################
2044: ##################################################
2045:
2046: =pod
2047:
2048: =item * header
2049:
2050: Output html header for page
2051:
2052: =cut
2053:
2054: ##################################################
2055: ##################################################
2056: sub header {
2057: my $html=&Apache::lonxml::xmlbegin();
2058: my $bodytag=&Apache::loncommon::bodytag('Parameter Manager');
2059: my $title = &mt('LON-CAPA Parameter Manager');
2060: return(<<ENDHEAD);
2061: $html
2062: <head>
2063: <title>$title</title>
2064: </head>
2065: $bodytag
2066: ENDHEAD
2067: }
2068: ##################################################
2069: ##################################################
2070: sub print_main_menu {
2071: my ($r,$parm_permission)=@_;
2072: #
2073: $r->print(<<ENDMAINFORMHEAD);
2074: <form method="post" enctype="multipart/form-data"
2075: action="/adm/parmset" name="studentform">
2076: ENDMAINFORMHEAD
2077: #
1.195 albertel 2078: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2079: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.193 albertel 2080: my @menu =
2081: (
2082: { text => 'Set Course Environment Parameters',
1.204 ! www 2083: action => 'crsenv',
1.193 albertel 2084: permission => $parm_permission,
2085: },
2086: { text => 'Set/Modify Course Assessment Parameters - Helper Mode',
2087: url => '/adm/helper/parameter.helper',
2088: permission => $parm_permission,
2089: },
2090: { text => 'Modify Course Assessment Parameters - Overview Mode',
2091: action => 'setoverview',
2092: permission => $parm_permission,
2093: },
2094: { text => 'Set/Modify Course Assessment Parameters - Table Mode',
2095: action => 'settable',
2096: permission => $parm_permission,
1.204 ! www 2097: help => 'Cascading_Parameters',
1.193 albertel 2098: },
2099: # { text => 'Set Parameter Default Preferences',
2100: # help => 'Course_View_Class_List',
2101: # action => 'setdefaults',
2102: # permission => $parm_permission,
2103: # },
2104: );
2105: my $menu_html = '';
2106: foreach my $menu_item (@menu) {
2107: next if (! $menu_item->{'permission'});
2108: $menu_html.='<p>';
2109: $menu_html.='<font size="+1">';
2110: if (exists($menu_item->{'url'})) {
2111: $menu_html.=qq{<a href="$menu_item->{'url'}">};
2112: } else {
2113: $menu_html.=
2114: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
2115: }
2116: $menu_html.= &mt($menu_item->{'text'}).'</a></font>';
2117: if (exists($menu_item->{'help'})) {
2118: $menu_html.=
2119: &Apache::loncommon::help_open_topic($menu_item->{'help'});
2120: }
2121: $menu_html.='</p>'.$/;
2122: }
2123: $r->print($menu_html);
2124: return;
2125: }
2126:
2127:
2128:
2129:
1.178 raeburn 2130: ##################################################
2131: ##################################################
1.30 www 2132:
1.59 matthew 2133: =pod
2134:
1.83 bowersj2 2135: =item * handler
1.59 matthew 2136:
2137: Main handler. Calls &assessparms and &crsenv subroutines.
2138:
2139: =cut
2140: ##################################################
2141: ##################################################
1.85 bowersj2 2142: use Data::Dumper;
1.30 www 2143: sub handler {
1.43 albertel 2144: my $r=shift;
1.30 www 2145:
1.43 albertel 2146: if ($r->header_only) {
1.126 www 2147: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 2148: $r->send_http_header;
2149: return OK;
2150: }
1.193 albertel 2151: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.194 albertel 2152: ['action','state']);
1.131 www 2153:
1.83 bowersj2 2154:
1.193 albertel 2155: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 2156: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
2157: text=>"Parameter Manager",
1.204 ! www 2158: faq=>10,
1.194 albertel 2159: bug=>'Instructor Interface'});
1.203 www 2160:
1.30 www 2161: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 2162: my $parm_permission =
2163: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 2164: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 2165: $env{'request.course.sec'}));
1.194 albertel 2166: if ($env{'request.course.id'} && $parm_permission) {
1.193 albertel 2167:
2168: # Start Page
1.126 www 2169: &Apache::loncommon::content_type($r,'text/html');
1.106 www 2170: $r->send_http_header;
1.30 www 2171:
1.203 www 2172:
2173: # id numbers can change on re-ordering of folders
2174:
2175: &resetsymbcache();
2176:
1.193 albertel 2177: #
2178: # Main switch on form.action and form.state, as appropriate
2179: #
2180: # Check first if coming from someone else headed directly for
2181: # the table mode
2182: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
2183: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
2184: &assessparms($r);
2185:
2186: } elsif (! exists($env{'form.action'})) {
2187: $r->print(&header());
1.194 albertel 2188: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
2189: 'Parameter Manager'));
1.193 albertel 2190: &print_main_menu($r,$parm_permission);
2191: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 2192: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
2193: text=>"Course Environment"});
2194: $r->print(&Apache::lonhtmlcommon::breadcrumbs(undef,
2195: 'Edit Course Environment'));
1.193 albertel 2196: &crsenv($r);
2197: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 2198: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
2199: text=>"Overview Mode"});
1.121 www 2200: &overview($r);
1.193 albertel 2201: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 2202: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 ! www 2203: text=>"Table Mode",
! 2204: help => 'Course_Setting_Parameters'});
1.121 www 2205: &assessparms($r);
1.193 albertel 2206: }
2207:
1.43 albertel 2208: } else {
1.1 www 2209: # ----------------------------- Not in a course, or not allowed to modify parms
1.190 albertel 2210: $env{'user.error.msg'}=
1.43 albertel 2211: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
2212: return HTTP_NOT_ACCEPTABLE;
2213: }
2214: return OK;
1.1 www 2215: }
2216:
2217: 1;
2218: __END__
2219:
1.59 matthew 2220: =pod
1.38 harris41 2221:
2222: =back
2223:
2224: =cut
1.1 www 2225:
2226:
2227:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>