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