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