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