Annotation of loncom/interface/lonparmset.pm, revision 1.412
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.412 ! bisitz 4: # $Id: lonparmset.pm,v 1.411 2008/10/10 10:54:03 bisitz 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.307 raeburn 66: use Apache::longroup;
1.303 www 67: use Apache::lonrss;
1.350 albertel 68: use LONCAPA qw(:DEFAULT :match);
1.1 www 69:
1.198 www 70:
1.59 matthew 71: ##################################################
72: ##################################################
73:
74: =pod
75:
76: =item parmval
77:
78: Figure out a cascading parameter.
79:
1.71 albertel 80: Inputs: $what - a parameter spec (incluse part info and name I.E. 0.weight)
1.162 albertel 81: $id - a bighash Id number
1.71 albertel 82: $def - the resource's default value 'stupid emacs
83:
1.269 raeburn 84: 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 14 possible levels
1.71 albertel 85:
1.306 albertel 86: 14- General Course
87: 13- Map or Folder level in course
1.269 raeburn 88: 12- resource default
89: 11- map default
1.306 albertel 90: 10- resource level in course
1.269 raeburn 91: 9 - General for section
92: 8 - Map or Folder level for section
93: 7 - resource level in section
94: 6 - General for group
95: 5 - Map or Folder level for group
96: 4 - resource level in group
1.71 albertel 97: 3 - General for specific student
1.82 www 98: 2 - Map or Folder level for specific student
1.71 albertel 99: 1 - resource level for specific student
1.2 www 100:
1.59 matthew 101: =cut
102:
103: ##################################################
1.2 www 104: sub parmval {
1.275 raeburn 105: my ($what,$id,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
106: return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec,
107: $cgroup,$courseopt);
1.201 www 108: }
109:
110: sub parmval_by_symb {
1.275 raeburn 111: my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_;
1.200 www 112:
1.352 albertel 113: my $useropt;
114: if ($uname ne '' && $udom ne '') {
115: $useropt = &Apache::lonnet::get_userresdata($uname,$udom);
116: }
1.200 www 117:
1.8 www 118: my $result='';
1.44 albertel 119: my @outpar=();
1.2 www 120: # ----------------------------------------------------- Cascading lookup scheme
1.201 www 121: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 122: $map = &Apache::lonnet::deversion($map);
1.10 www 123:
1.201 www 124: my $symbparm=$symb.'.'.$what;
125: my $mapparm=$map.'___(all).'.$what;
1.10 www 126:
1.269 raeburn 127: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$what;
128: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
129: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
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:
1.182 albertel 140: # --------------------------------------------------------- first, check course
1.11 www 141:
1.200 www 142: if (defined($$courseopt{$courselevel})) {
1.269 raeburn 143: $outpar[14]=$$courseopt{$courselevel};
144: $result=14;
1.43 albertel 145: }
1.11 www 146:
1.200 www 147: if (defined($$courseopt{$courselevelm})) {
1.269 raeburn 148: $outpar[13]=$$courseopt{$courselevelm};
149: $result=13;
1.43 albertel 150: }
1.11 www 151:
1.182 albertel 152: # ------------------------------------------------------- second, check default
153:
1.269 raeburn 154: if (defined($def)) { $outpar[12]=$def; $result=12; }
1.182 albertel 155:
156: # ------------------------------------------------------ third, check map parms
157:
1.376 albertel 158: my $thisparm=&parmhash($symbparm);
1.269 raeburn 159: if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; }
1.182 albertel 160:
1.200 www 161: if (defined($$courseopt{$courselevelr})) {
1.269 raeburn 162: $outpar[10]=$$courseopt{$courselevelr};
163: $result=10;
1.43 albertel 164: }
1.11 www 165:
1.182 albertel 166: # ------------------------------------------------------ fourth, back to course
1.352 albertel 167: if ($csec ne '') {
1.200 www 168: if (defined($$courseopt{$seclevel})) {
1.269 raeburn 169: $outpar[9]=$$courseopt{$seclevel};
170: $result=9;
1.43 albertel 171: }
1.200 www 172: if (defined($$courseopt{$seclevelm})) {
1.269 raeburn 173: $outpar[8]=$$courseopt{$seclevelm};
174: $result=8;
1.43 albertel 175: }
176:
1.200 www 177: if (defined($$courseopt{$seclevelr})) {
1.269 raeburn 178: $outpar[7]=$$courseopt{$seclevelr};
179: $result=7;
1.43 albertel 180: }
181: }
1.275 raeburn 182: # ------------------------------------------------------ fifth, check course group
1.352 albertel 183: if ($cgroup ne '') {
1.269 raeburn 184: if (defined($$courseopt{$grplevel})) {
185: $outpar[6]=$$courseopt{$grplevel};
186: $result=6;
187: }
188: if (defined($$courseopt{$grplevelm})) {
189: $outpar[5]=$$courseopt{$grplevelm};
190: $result=5;
191: }
192: if (defined($$courseopt{$grplevelr})) {
193: $outpar[4]=$$courseopt{$grplevelr};
194: $result=4;
195: }
196: }
1.11 www 197:
1.182 albertel 198: # ---------------------------------------------------------- fifth, check user
1.11 www 199:
1.352 albertel 200: if ($uname ne '') {
1.200 www 201: if (defined($$useropt{$courselevel})) {
202: $outpar[3]=$$useropt{$courselevel};
1.43 albertel 203: $result=3;
204: }
1.10 www 205:
1.200 www 206: if (defined($$useropt{$courselevelm})) {
207: $outpar[2]=$$useropt{$courselevelm};
1.43 albertel 208: $result=2;
209: }
1.2 www 210:
1.200 www 211: if (defined($$useropt{$courselevelr})) {
212: $outpar[1]=$$useropt{$courselevelr};
1.43 albertel 213: $result=1;
214: }
215: }
1.44 albertel 216: return ($result,@outpar);
1.2 www 217: }
218:
1.198 www 219:
220:
1.376 albertel 221: # --- Caches local to lonparmset
222:
223:
224: sub reset_caches {
225: &resetparmhash();
226: &resetsymbcache();
227: &resetrulescache();
1.203 www 228: }
229:
1.376 albertel 230: {
231: my $parmhashid;
232: my %parmhash;
233: sub resetparmhash {
234: undef($parmhashid);
235: undef(%parmhash);
236: }
237:
238: sub cacheparmhash {
239: if ($parmhashid eq $env{'request.course.fn'}) { return; }
240: my %parmhashfile;
241: if (tie(%parmhashfile,'GDBM_File',
242: $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
243: %parmhash=%parmhashfile;
244: untie(%parmhashfile);
245: $parmhashid=$env{'request.course.fn'};
246: }
1.201 www 247: }
1.376 albertel 248:
249: sub parmhash {
250: my ($id) = @_;
251: &cacheparmhash();
252: return $parmhash{$id};
253: }
254: }
255:
256: {
257: my $symbsid;
258: my %symbs;
259: sub resetsymbcache {
260: undef($symbsid);
261: undef(%symbs);
262: }
263:
264: sub symbcache {
265: my $id=shift;
266: if ($symbsid ne $env{'request.course.id'}) {
267: undef(%symbs);
268: }
269: if (!$symbs{$id}) {
270: my $navmap = Apache::lonnavmaps::navmap->new();
271: if ($id=~/\./) {
272: my $resource=$navmap->getById($id);
273: $symbs{$id}=$resource->symb();
274: } else {
275: my $resource=$navmap->getByMapPc($id);
276: $symbs{$id}=&Apache::lonnet::declutter($resource->src());
277: }
278: $symbsid=$env{'request.course.id'};
1.201 www 279: }
1.376 albertel 280: return $symbs{$id};
1.201 www 281: }
1.376 albertel 282: }
1.201 www 283:
1.376 albertel 284: {
285: my $rulesid;
286: my %rules;
287: sub resetrulescache {
288: undef($rulesid);
289: undef(%rules);
290: }
291:
292: sub rulescache {
293: my $id=shift;
294: if ($rulesid ne $env{'request.course.id'}
295: && !defined($rules{$id})) {
296: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
297: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
298: %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
299: $rulesid=$env{'request.course.id'};
300: }
301: return $rules{$id};
1.221 www 302: }
303: }
304:
1.229 www 305: sub preset_defaults {
306: my $type=shift;
307: if (&rulescache($type.'_action') eq 'default') {
308: # yes, there is something
309: return (&rulescache($type.'_hours'),
310: &rulescache($type.'_min'),
311: &rulescache($type.'_sec'),
312: &rulescache($type.'_value'));
313: } else {
314: # nothing there or something else
315: return ('','','','','');
316: }
317: }
318:
1.186 www 319: ##################################################
1.277 www 320:
321: sub date_sanity_info {
322: my $checkdate=shift;
323: unless ($checkdate) { return ''; }
324: my $result='';
325: my $crsprefix='course.'.$env{'request.course.id'}.'.';
326: if ($env{$crsprefix.'default_enrollment_end_date'}) {
327: if ($checkdate>$env{$crsprefix.'default_enrollment_end_date'}) {
328: $result.='<br />'.&mt('After course enrollment end!');
329: }
330: }
331: if ($env{$crsprefix.'default_enrollment_start_date'}) {
332: if ($checkdate<$env{$crsprefix.'default_enrollment_start_date'}) {
333: $result.='<br />'.&mt('Before course enrollment start!');
334: }
335: }
336: return $result;
337: }
338: ##################################################
1.186 www 339: ##################################################
340: #
1.197 www 341: # Store a parameter by ID
1.186 www 342: #
343: # Takes
344: # - resource id
345: # - name of parameter
346: # - level
347: # - new value
348: # - new type
1.187 www 349: # - username
350: # - userdomain
351:
1.186 www 352: sub storeparm {
1.269 raeburn 353: my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.275 raeburn 354: &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,'',$cgroup);
1.197 www 355: }
356:
357: #
358: # Store a parameter by symb
359: #
360: # Takes
361: # - symb
362: # - name of parameter
363: # - level
364: # - new value
365: # - new type
366: # - username
367: # - userdomain
1.226 www 368: my %recstack;
1.197 www 369: sub storeparm_by_symb {
1.275 raeburn 370: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_;
1.226 www 371: unless ($recflag) {
372: # first time call
373: %recstack=();
374: $recflag=1;
375: }
376: # store parameter
377: &storeparm_by_symb_inner
1.269 raeburn 378: ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup);
1.266 www 379: # don't do anything if parameter was reset
380: unless ($nval) { return; }
1.226 www 381: my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
382: # remember that this was set
383: $recstack{$parm}=1;
384: # what does this trigger?
385: foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
386: # don't backfire
387: unless ((!$triggered) || ($recstack{$triggered})) {
388: my $action=&rulescache($triggered.'_action');
389: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
390: # set triggered parameter on same level
391: my $newspnam=$prefix.$triggered;
1.227 www 392: my $newvalue='';
1.228 www 393: my $active=1;
394: if ($action=~/^when\_setting/) {
395: # are there restrictions?
396: if (&rulescache($triggered.'_triggervalue')=~/\w/) {
397: $active=0;
398: foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
399: if (lc($possiblevalue) eq lc($nval)) { $active=1; }
400: }
401: }
402: $newvalue=&rulescache($triggered.'_value');
1.227 www 403: } else {
404: my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
1.228 www 405: if ($action=~/^later\_than/) {
406: $newvalue=$nval+$totalsecs;
407: } else {
408: $newvalue=$nval-$totalsecs;
409: }
410: }
411: if ($active) {
412: &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
1.275 raeburn 413: $uname,$udom,$csec,$recflag,$cgroup);
1.227 www 414: }
1.226 www 415: }
416: }
417: return '';
418: }
419:
1.293 www 420: sub log_parmset {
421: return &Apache::lonnet::instructor_log('parameterlog',@_);
1.284 www 422: }
423:
1.226 www 424: sub storeparm_by_symb_inner {
1.197 www 425: # ---------------------------------------------------------- Get symb, map, etc
1.269 raeburn 426: my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$cgroup)=@_;
1.197 www 427: # ---------------------------------------------------------- Construct prefixes
1.186 www 428: $spnam=~s/\_([^\_]+)$/\.$1/;
1.197 www 429: my $map=(&Apache::lonnet::decode_symb($symb))[0];
1.305 albertel 430: $map = &Apache::lonnet::deversion($map);
431:
1.197 www 432: my $symbparm=$symb.'.'.$spnam;
433: my $mapparm=$map.'___(all).'.$spnam;
434:
1.269 raeburn 435: my $grplevel=$env{'request.course.id'}.'.['.$cgroup.'].'.$spnam;
436: my $grplevelr=$env{'request.course.id'}.'.['.$cgroup.'].'.$symbparm;
437: my $grplevelm=$env{'request.course.id'}.'.['.$cgroup.'].'.$mapparm;
438:
1.190 albertel 439: my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$spnam;
440: my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
441: my $seclevelm=$env{'request.course.id'}.'.['.$csec.'].'.$mapparm;
1.186 www 442:
1.190 albertel 443: my $courselevel=$env{'request.course.id'}.'.'.$spnam;
444: my $courselevelr=$env{'request.course.id'}.'.'.$symbparm;
445: my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
1.186 www 446:
447: my $storeunder='';
1.269 raeburn 448: if (($snum==14) || ($snum==3)) { $storeunder=$courselevel; }
449: if (($snum==13) || ($snum==2)) { $storeunder=$courselevelm; }
450: if (($snum==10) || ($snum==1)) { $storeunder=$courselevelr; }
451: if ($snum==9) { $storeunder=$seclevel; }
452: if ($snum==8) { $storeunder=$seclevelm; }
453: if ($snum==7) { $storeunder=$seclevelr; }
454: if ($snum==6) { $storeunder=$grplevel; }
455: if ($snum==5) { $storeunder=$grplevelm; }
456: if ($snum==4) { $storeunder=$grplevelr; }
457:
1.186 www 458:
459: my $delete;
460: if ($nval eq '') { $delete=1;}
461: my %storecontent = ($storeunder => $nval,
462: $storeunder.'.type' => $ntype);
463: my $reply='';
464: if ($snum>3) {
465: # ---------------------------------------------------------------- Store Course
466: #
1.200 www 467: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
468: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.186 www 469: # Expire sheets
470: &Apache::lonnet::expirespread('','','studentcalc');
1.269 raeburn 471: if (($snum==10) || ($snum==7) || ($snum==4)) {
1.197 www 472: &Apache::lonnet::expirespread('','','assesscalc',$symb);
1.269 raeburn 473: } elsif (($snum==11) || ($snum==8) || ($snum==5)) {
1.197 www 474: &Apache::lonnet::expirespread('','','assesscalc',$map);
1.186 www 475: } else {
476: &Apache::lonnet::expirespread('','','assesscalc');
477: }
478: # Store parameter
479: if ($delete) {
480: $reply=&Apache::lonnet::del
1.200 www 481: ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
1.290 www 482: &log_parmset(\%storecontent,1);
1.186 www 483: } else {
484: $reply=&Apache::lonnet::cput
1.200 www 485: ('resourcedata',\%storecontent,$cdom,$cnum);
1.290 www 486: &log_parmset(\%storecontent);
1.186 www 487: }
1.200 www 488: &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
1.186 www 489: } else {
490: # ------------------------------------------------------------------ Store User
491: #
492: # Expire sheets
493: &Apache::lonnet::expirespread($uname,$udom,'studentcalc');
494: if ($snum==1) {
495: &Apache::lonnet::expirespread
1.197 www 496: ($uname,$udom,'assesscalc',$symb);
1.186 www 497: } elsif ($snum==2) {
498: &Apache::lonnet::expirespread
1.197 www 499: ($uname,$udom,'assesscalc',$map);
1.186 www 500: } else {
501: &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
502: }
503: # Store parameter
504: if ($delete) {
505: $reply=&Apache::lonnet::del
506: ('resourcedata',[keys(%storecontent)],$udom,$uname);
1.290 www 507: &log_parmset(\%storecontent,1,$uname,$udom);
1.186 www 508: } else {
509: $reply=&Apache::lonnet::cput
510: ('resourcedata',\%storecontent,$udom,$uname);
1.290 www 511: &log_parmset(\%storecontent,0,$uname,$udom);
1.186 www 512: }
1.191 albertel 513: &Apache::lonnet::devalidateuserresdata($uname,$udom);
1.186 www 514: }
515:
516: if ($reply=~/^error\:(.*)/) {
1.314 albertel 517: return "<span class=\"LC_error\">Write Error: $1</span>";
1.186 www 518: }
519: return '';
520: }
521:
1.59 matthew 522: ##################################################
523: ##################################################
524:
525: =pod
526:
527: =item valout
528:
529: Format a value for output.
530:
1.320 www 531: Inputs: $value, $type, $editable
1.59 matthew 532:
533: Returns: $value, formatted for output. If $type indicates it is a date,
534: localtime($value) is returned.
1.320 www 535: $editable will return an icon to click on
1.9 www 536:
1.59 matthew 537: =cut
538:
539: ##################################################
540: ##################################################
1.9 www 541: sub valout {
1.320 www 542: my ($value,$type,$editable)=@_;
1.59 matthew 543: my $result = '';
544: # Values of zero are valid.
545: if (! $value && $value ne '0') {
1.320 www 546: if ($editable) {
1.324 www 547: $result = '<span class="LC_clickhere">*</span>';
1.320 www 548: } else {
549: $result=' ';
550: }
1.59 matthew 551: } else {
1.66 www 552: if ($type eq 'date_interval') {
553: my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
554: $year=$year-70;
555: $mday--;
556: if ($year) {
557: $result.=$year.' yrs ';
558: }
559: if ($mon) {
560: $result.=$mon.' mths ';
561: }
562: if ($mday) {
563: $result.=$mday.' days ';
564: }
565: if ($hour) {
566: $result.=$hour.' hrs ';
567: }
568: if ($min) {
569: $result.=$min.' mins ';
570: }
571: if ($sec) {
572: $result.=$sec.' secs ';
573: }
574: $result=~s/\s+$//;
1.213 www 575: } elsif (&isdateparm($type)) {
1.361 albertel 576: $result = &Apache::lonlocal::locallocaltime($value).
577: &date_sanity_info($value);
1.59 matthew 578: } else {
579: $result = $value;
1.378 albertel 580: $result = &HTML::Entities::encode($result,'"<>&');
1.59 matthew 581: }
582: }
583: return $result;
1.9 www 584: }
585:
1.59 matthew 586: ##################################################
587: ##################################################
588:
589: =pod
1.5 www 590:
1.59 matthew 591: =item plink
592:
593: Produces a link anchor.
594:
595: Inputs: $type,$dis,$value,$marker,$return,$call
596:
597: Returns: scalar with html code for a link which will envoke the
598: javascript function 'pjump'.
599:
600: =cut
601:
602: ##################################################
603: ##################################################
1.5 www 604: sub plink {
605: my ($type,$dis,$value,$marker,$return,$call)=@_;
1.23 www 606: my $winvalue=$value;
607: unless ($winvalue) {
1.213 www 608: if (&isdateparm($type)) {
1.190 albertel 609: $winvalue=$env{'form.recent_'.$type};
1.23 www 610: } else {
1.190 albertel 611: $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
1.23 www 612: }
613: }
1.229 www 614: my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
615: my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
616: unless (defined($winvalue)) { $winvalue=$val; }
1.378 albertel 617: my $valout = &valout($value,$type,1);
618: foreach my $item (\$type, \$dis, \$winvalue, \$marker, \$return, \$call,
619: \$hour, \$min, \$sec) {
620: $$item = &HTML::Entities::encode($$item,'"<>&');
621: $$item =~ s/\'/\\\'/g;
622: }
1.270 www 623: return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$marker.'" /></td></tr><tr><td align="center">'.
1.43 albertel 624: '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
1.229 www 625: .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
1.378 albertel 626: $valout.'</a></td></tr></table>';
1.5 www 627: }
628:
1.280 albertel 629: sub page_js {
630:
1.81 www 631: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.88 matthew 632: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.280 albertel 633:
634: return(<<ENDJS);
635: <script type="text/javascript">
1.44 albertel 636:
637: function pclose() {
638: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
639: "height=350,width=350,scrollbars=no,menubar=no");
640: parmwin.close();
641: }
642:
1.88 matthew 643: $pjump_def
1.44 albertel 644:
645: function psub() {
646: pclose();
647: if (document.parmform.pres_marker.value!='') {
648: document.parmform.action+='#'+document.parmform.pres_marker.value;
649: var typedef=new Array();
650: typedef=document.parmform.pres_type.value.split('_');
651: if (document.parmform.pres_type.value!='') {
652: if (typedef[0]=='date') {
653: eval('document.parmform.recent_'+
654: document.parmform.pres_type.value+
655: '.value=document.parmform.pres_value.value;');
656: } else {
657: eval('document.parmform.recent_'+typedef[0]+
658: '.value=document.parmform.pres_value.value;');
659: }
660: }
661: document.parmform.submit();
662: } else {
663: document.parmform.pres_value.value='';
664: document.parmform.pres_marker.value='';
665: }
666: }
667:
1.57 albertel 668: function openWindow(url, wdwName, w, h, toolbar,scrollbar) {
669: var options = "width=" + w + ",height=" + h + ",";
670: options += "resizable=yes,scrollbars="+scrollbar+",status=no,";
671: options += "menubar=no,toolbar="+toolbar+",location=no,directories=no";
672: var newWin = window.open(url, wdwName, options);
673: newWin.focus();
674: }
1.44 albertel 675: </script>
1.81 www 676: $selscript
1.280 albertel 677: ENDJS
678:
679: }
680: sub startpage {
681: my ($r) = @_;
1.281 albertel 682:
1.282 albertel 683: my %loaditems = ('onunload' => "pclose()",
1.283 albertel 684: 'onload' => "group_or_section('cgroup')",);
1.280 albertel 685:
1.281 albertel 686: my $start_page =
687: &Apache::loncommon::start_page('Set/Modify Course Parameters',
688: &page_js(),
1.282 albertel 689: {'add_entries' => \%loaditems,});
1.280 albertel 690: my $breadcrumbs =
1.321 www 691: &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode');
1.280 albertel 692: $r->print(<<ENDHEAD);
1.281 albertel 693: $start_page
1.193 albertel 694: $breadcrumbs
695: <form method="post" action="/adm/parmset?action=settable" name="parmform">
1.280 albertel 696: <input type="hidden" value='' name="pres_value" />
697: <input type="hidden" value='' name="pres_type" />
698: <input type="hidden" value='' name="pres_marker" />
699: <input type="hidden" value='1' name="prevvisit" />
1.44 albertel 700: ENDHEAD
701: }
702:
1.209 www 703:
1.44 albertel 704: sub print_row {
1.201 www 705: my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
1.275 raeburn 706: $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_;
707: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
708: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
709: my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
1.66 www 710: # get the values for the parameter in cascading order
711: # empty levels will remain empty
1.44 albertel 712: my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
1.275 raeburn 713: $rid,$$default{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 714: # get the type for the parameters
715: # problem: these may not be set for all levels
716: my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
1.275 raeburn 717: $$name{$which}.'.type',$rid,
718: $$defaulttype{$which},$uname,$udom,$csec,$cgroup,$courseopt);
1.66 www 719: # cascade down manually
1.182 albertel 720: my $cascadetype=$$defaulttype{$which};
1.269 raeburn 721: for (my $i=14;$i>0;$i--) {
1.66 www 722: if ($typeoutpar[$i]) {
723: $cascadetype=$typeoutpar[$i];
724: } else {
725: $typeoutpar[$i]=$cascadetype;
726: }
727: }
1.57 albertel 728: my $parm=$$display{$which};
729:
1.203 www 730: if ($parmlev eq 'full') {
1.57 albertel 731: $r->print('<td bgcolor='.$defbgtwo.' align="center">'
732: .$$part{$which}.'</td>');
733: } else {
734: $parm=~s|\[.*\]\s||g;
735: }
1.231 www 736: my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
737: if ($automatic) {
1.314 albertel 738: $parm.='<span class="LC_warning"><br />'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'</span>';
1.231 www 739: }
1.159 albertel 740: $r->print('<td bgcolor='.$defbgone.'>'.$parm.'</td>');
1.57 albertel 741:
1.44 albertel 742: my $thismarker=$which;
743: $thismarker=~s/^parameter\_//;
744: my $mprefix=$rid.'&'.$thismarker.'&';
1.275 raeburn 745: my $effective_parm = &valout($outpar[$result],$typeoutpar[$result]);
746: my ($othergrp,$grp_parm,$controlgrp);
1.44 albertel 747:
1.57 albertel 748: if ($parmlev eq 'general') {
749:
750: if ($uname) {
1.66 www 751: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 752: } elsif ($cgroup) {
753: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 754: } elsif ($csec) {
1.269 raeburn 755: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 756: } else {
1.269 raeburn 757: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 758: }
759: } elsif ($parmlev eq 'map') {
760:
761: if ($uname) {
1.66 www 762: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.269 raeburn 763: } elsif ($cgroup) {
764: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 765: } elsif ($csec) {
1.269 raeburn 766: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 767: } else {
1.269 raeburn 768: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 769: }
770: } else {
1.275 raeburn 771: if ($uname) {
772: if (@{$usersgroups} > 1) {
773: my ($coursereply,$grp_parm,$controlgrp);
774: ($coursereply,$othergrp,$grp_parm,$controlgrp) =
775: &print_usergroups($r,$$part{$which}.'.'.$$name{$which},
776: $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
777: if ($coursereply && $result > 3) {
778: if (defined($controlgrp)) {
779: if ($cgroup ne $controlgrp) {
780: $effective_parm = $grp_parm;
781: $result = 0;
782: }
783: }
784: }
785: }
786: }
1.57 albertel 787:
1.269 raeburn 788: &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.57 albertel 789:
1.269 raeburn 790: &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
791: &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
792: &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 793: &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
794:
795: if ($csec) {
1.269 raeburn 796: &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
797: &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
798: &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
1.203 www 799: }
1.269 raeburn 800:
801: if ($cgroup) {
802: &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
803: &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
804: &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
805: }
1.275 raeburn 806:
1.203 www 807: if ($uname) {
1.275 raeburn 808: if ($othergrp) {
809: $r->print($othergrp);
810: }
1.203 www 811: &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
812: &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
813: &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display);
814: }
1.57 albertel 815:
816: } # end of $parmlev if/else
1.275 raeburn 817: $r->print('<td bgcolor="#CCCCFF" align="center">'.$effective_parm.'</td>');
1.136 albertel 818:
1.203 www 819: if ($parmlev eq 'full') {
1.136 albertel 820: my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
1.201 www 821: '.'.$$name{$which},$$symbp{$rid});
1.136 albertel 822: my $sessionvaltype=$typeoutpar[$result];
823: if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
1.275 raeburn 824: $r->print('<td bgcolor="#999999" align="center"><font color="#FFFFFF">'.
1.66 www 825: &valout($sessionval,$sessionvaltype).' '.
1.57 albertel 826: '</font></td>');
1.136 albertel 827: }
1.44 albertel 828: $r->print('</tr>');
1.57 albertel 829: $r->print("\n");
1.44 albertel 830: }
1.59 matthew 831:
1.44 albertel 832: sub print_td {
1.66 www 833: my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_;
1.57 albertel 834: $r->print('<td bgcolor='.(($result==$which)?'"#AAFFAA"':$defbg).
1.114 www 835: ' align="center">');
1.269 raeburn 836: if ($which<11 || $which > 12) {
1.114 www 837: $r->print(&plink($$typeoutpar[$which],
838: $$display{$value},$$outpar[$which],
839: $mprefix."$which",'parmform.pres','psub'));
840: } else {
841: $r->print(&valout($$outpar[$which],$$typeoutpar[$which]));
842: }
843: $r->print('</td>'."\n");
1.57 albertel 844: }
845:
1.275 raeburn 846: sub print_usergroups {
847: my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
848: my $courseid = $env{'request.course.id'};
849: my $output;
850: my $symb = &symbcache($rid);
851: my $symbparm=$symb.'.'.$what;
852: my $map=(&Apache::lonnet::decode_symb($symb))[0];
853: my $mapparm=$map.'___(all).'.$what;
854: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype) =
855: &parm_control_group($courseid,$usersgroups,$symbparm,$mapparm,$what,
856: $courseopt);
857: my $bgcolor = $defbg;
858: my $grp_parm;
859: if (($coursereply) && ($cgroup ne $resultgroup)) {
860: if ($result > 3) {
861: $bgcolor = '"#AAFFAA"';
862: $grp_parm = &valout($coursereply,$resulttype);
863: }
864: $grp_parm = &valout($coursereply,$resulttype);
865: $output = '<td bgcolor='.$bgcolor.' align="center">';
866: if ($resultgroup && $resultlevel) {
867: $output .= '<small><b>'.$resultgroup.'</b> ('.$resultlevel.'): </small>'.$grp_parm;
868: } else {
869: $output .= ' ';
870: }
871: $output .= '</td>';
872: } else {
873: $output .= '<td bgcolor='.$bgcolor.'> </td>';
874: }
875: return ($coursereply,$output,$grp_parm,$resultgroup);
876: }
877:
878: sub parm_control_group {
879: my ($courseid,$usersgroups,$symbparm,$mapparm,$what,$courseopt) = @_;
880: my ($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
881: my $grpfound = 0;
882: my @levels = ($symbparm,$mapparm,$what);
883: my @levelnames = ('resource','map/folder','general');
884: foreach my $group (@{$usersgroups}) {
885: if ($grpfound) { last; }
886: for (my $i=0; $i<@levels; $i++) {
887: my $item = $courseid.'.['.$group.'].'.$levels[$i];
888: if (defined($$courseopt{$item})) {
889: $coursereply = $$courseopt{$item};
890: $resultitem = $item;
891: $resultgroup = $group;
892: $resultlevel = $levelnames[$i];
893: $resulttype = $$courseopt{$item.'.type'};
894: $grpfound = 1;
895: last;
896: }
897: }
898: }
899: return($coursereply,$resultitem,$resultgroup,$resultlevel,$resulttype);
900: }
1.201 www 901:
1.63 bowersj2 902: =pod
903:
904: =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
905:
906: Input: See list below:
907:
908: =over 4
909:
910: =item B<ids>: An array that will contain all of the ids in the course.
911:
912: =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
913:
1.171 www 914: =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 915:
916: =item B<allparms>: hash, name of parameter->display value (what is the display value?)
917:
918: =item B<allparts>: hash, part identification->text representation of part, where the text representation is "[Part $part]"
919:
920: =item B<allkeys>: hash, full key to part->display value (what's display value?)
921:
922: =item B<allmaps>: hash, ???
923:
924: =item B<fcat>: ???
925:
926: =item B<defp>: hash, ???
927:
928: =item B<mapp>: ??
929:
930: =item B<symbp>: hash, id->full sym?
931:
932: =back
933:
934: =cut
935:
936: sub extractResourceInformation {
937: my $ids = shift;
938: my $typep = shift;
939: my $keyp = shift;
940: my $allparms = shift;
941: my $allparts = shift;
942: my $allmaps = shift;
943: my $mapp = shift;
944: my $symbp = shift;
1.82 www 945: my $maptitles=shift;
1.196 www 946: my $uris=shift;
1.210 www 947: my $keyorder=shift;
1.211 www 948: my $defkeytype=shift;
1.196 www 949:
1.210 www 950: my $keyordercnt=100;
1.63 bowersj2 951:
1.196 www 952: my $navmap = Apache::lonnavmaps::navmap->new();
953: my @allres=$navmap->retrieveResources(undef,undef,1,undef,1);
954: foreach my $resource (@allres) {
955: my $id=$resource->id();
956: my ($mapid,$resid)=split(/\./,$id);
957: if ($mapid eq '0') { next; }
958: $$ids[$#$ids+1]=$id;
959: my $srcf=$resource->src();
960: $srcf=~/\.(\w+)$/;
961: $$typep{$id}=$1;
962: $$keyp{$id}='';
963: $$uris{$id}=$srcf;
1.363 albertel 964: foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
965: next if ($key!~/^parameter_/);
966:
1.209 www 967: # Hidden parameters
1.363 albertel 968: next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
1.209 www 969: #
970: # allparms is a hash of parameter names
971: #
1.363 albertel 972: my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
1.375 albertel 973: if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) {
1.363 albertel 974: my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
1.196 www 975: my $parmdis = $display;
1.412 ! bisitz 976: $parmdis =~ s/\s*\[Part.*$//g;
1.363 albertel 977: $$allparms{$name}=$parmdis;
978: if (ref($defkeytype)) {
979: $$defkeytype{$name}=
980: &Apache::lonnet::metadata($srcf,$key.'.type');
981: }
982: }
983:
1.209 www 984: #
985: # allparts is a hash of all parts
986: #
1.363 albertel 987: my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
1.410 bisitz 988: $$allparts{$part} = &mt('Part: [_1]',$part);
1.209 www 989: #
990: # Remember all keys going with this resource
991: #
1.363 albertel 992: if ($$keyp{$id}) {
993: $$keyp{$id}.=','.$key;
994: } else {
995: $$keyp{$id}=$key;
996: }
1.210 www 997: #
998: # Put in order
999: #
1.363 albertel 1000: unless ($$keyorder{$key}) {
1001: $$keyorder{$key}=$keyordercnt;
1002: $keyordercnt++;
1003: }
1004: }
1.210 www 1005:
1.363 albertel 1006:
1007: if (!exists($$mapp{$mapid})) {
1008: $$mapp{$id}=
1009: &Apache::lonnet::declutter($resource->enclosing_map_src());
1010: $$mapp{$mapid}=$$mapp{$id};
1011: $$allmaps{$mapid}=$$mapp{$id};
1012: if ($mapid eq '1') {
1.401 bisitz 1013: $$maptitles{$mapid}=&mt('Main Course Documents');
1.363 albertel 1014: } else {
1015: $$maptitles{$mapid}=
1016: &Apache::lonnet::gettitle($$mapp{$id});
1.63 bowersj2 1017: }
1.363 albertel 1018: $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
1019: $$symbp{$mapid}=$$mapp{$id}.'___(all)';
1.196 www 1020: } else {
1.363 albertel 1021: $$mapp{$id} = $$mapp{$mapid};
1.196 www 1022: }
1023: $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
1.63 bowersj2 1024: }
1025: }
1026:
1.208 www 1027:
1028: ##################################################
1029: ##################################################
1030:
1.213 www 1031: sub isdateparm {
1032: my $type=shift;
1033: return (($type=~/^date/) && (!($type eq 'date_interval')));
1034: }
1035:
1.208 www 1036: sub parmmenu {
1.211 www 1037: my ($r,$allparms,$pscat,$keyorder)=@_;
1.208 www 1038: my $tempkey;
1039: $r->print(<<ENDSCRIPT);
1040: <script type="text/javascript">
1041: function checkall(value, checkName) {
1042: for (i=0; i<document.forms.parmform.elements.length; i++) {
1043: ele = document.forms.parmform.elements[i];
1044: if (ele.name == checkName) {
1045: document.forms.parmform.elements[i].checked=value;
1046: }
1047: }
1048: }
1.210 www 1049:
1050: function checkthis(thisvalue, checkName) {
1051: for (i=0; i<document.forms.parmform.elements.length; i++) {
1052: ele = document.forms.parmform.elements[i];
1053: if (ele.name == checkName) {
1054: if (ele.value == thisvalue) {
1055: document.forms.parmform.elements[i].checked=true;
1056: }
1057: }
1058: }
1059: }
1060:
1061: function checkdates() {
1062: checkthis('duedate','pscat');
1063: checkthis('opendate','pscat');
1064: checkthis('answerdate','pscat');
1.218 www 1065: }
1066:
1067: function checkdisset() {
1068: checkthis('discussend','pscat');
1069: checkthis('discusshide','pscat');
1070: }
1071:
1072: function checkcontdates() {
1073: checkthis('contentopen','pscat');
1074: checkthis('contentclose','pscat');
1075: }
1076:
1.210 www 1077:
1078: function checkvisi() {
1079: checkthis('hiddenresource','pscat');
1080: checkthis('encrypturl','pscat');
1081: checkthis('problemstatus','pscat');
1082: checkthis('contentopen','pscat');
1083: checkthis('opendate','pscat');
1084: }
1085:
1086: function checkparts() {
1087: checkthis('hiddenparts','pscat');
1088: checkthis('display','pscat');
1089: checkthis('ordered','pscat');
1090: }
1091:
1092: function checkstandard() {
1093: checkall(false,'pscat');
1094: checkdates();
1095: checkthis('weight','pscat');
1096: checkthis('maxtries','pscat');
1097: }
1098:
1.208 www 1099: </script>
1100: ENDSCRIPT
1.209 www 1101: $r->print();
1.317 albertel 1102: $r->print("\n<table id=\"LC_parm_overview_parm_menu\"><tr>");
1.208 www 1103: my $cnt=0;
1.211 www 1104: foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) {
1.317 albertel 1105: $r->print("\n<td><label><input type='checkbox' name='pscat' ");
1.208 www 1106: $r->print('value="'.$tempkey.'"');
1107: if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
1108: $r->print(' checked');
1109: }
1.411 bisitz 1110: $r->print('>'.($$allparms{$tempkey}=~/\S/ ? &mt($$allparms{$tempkey})
1111: : &mt($tempkey))
1.375 albertel 1112: .'</label></td>');
1.209 www 1113: $cnt++;
1114: if ($cnt==3) {
1115: $r->print("</tr>\n<tr>");
1116: $cnt=0;
1117: }
1.208 www 1118: }
1.410 bisitz 1119: $r->print('</tr>'
1120: .'<tr id=\"LC_parm_overview_parm_menu_selectors\">'
1121: .'<td valign="top">'
1122: .'<fieldset><legend><b>'.&mt('Parameter Selection').'</b></legend>'
1123: .'<span class="LC_nobreak">'
1124: .'• <a href="javascript:checkall(true, \'pscat\')">'.&mt('Select All').'</a>'
1125: .'</span>'
1126: .'<br />'
1127: .'<span class="LC_nobreak">'
1128: .'• <a href="javascript:checkstandard()">'.&mt('Select Common Only').'</a>'
1129: .'</span>'
1130: .'<br />'
1131: .'<span class="LC_nobreak">'
1132: .'• <a href="javascript:checkall(false, \'pscat\')">'.&mt('Unselect All').'</a>'
1133: .'</span>'
1134: .'</fieldset>'
1135: .'</td>'
1136: .'<td colspan="2" valign="top">'
1137: .'<fieldset><legend><b>'.&mt('Add Selection for...').'</b></legend>'
1138: .'<span class="LC_nobreak">'
1139: .'• <a href="javascript:checkdates()">'.&mt('Problem Dates').'</a>'
1140: .'</span>'
1141: .'<span class="LC_nobreak">'
1142: .' • <a href="javascript:checkcontdates()">'.&mt('Content Dates').'</a>'
1143: .'</span>'
1144: # .'<br />'
1145: .'<span class="LC_nobreak">'
1146: .' • <a href="javascript:checkdisset()">'.&mt('Discussion Settings').'</a>'
1147: .'</span>'
1148: .'<span class="LC_nobreak">'
1149: .' • <a href="javascript:checkvisi()">'.&mt('Visibilities').'</a>'
1150: .'</span>'
1151: # .'<br />'
1152: .'<span class="LC_nobreak">'
1153: .' • <a href="javascript:checkparts()">'.&mt('Part Parameters').'</a>'
1154: .'</span>'
1155: .'</fieldset>'
1156: .'</td>'
1157: .'</tr></table>'
1158: );
1.208 www 1159: }
1160:
1.209 www 1161: sub partmenu {
1162: my ($r,$allparts,$psprt)=@_;
1.211 www 1163: $r->print('<select multiple name="psprt" size="8">');
1.208 www 1164: $r->print('<option value="all"');
1.401 bisitz 1165: $r->print(' selected="selected"') unless (@{$psprt});
1.208 www 1166: $r->print('>'.&mt('All Parts').'</option>');
1167: my %temphash=();
1168: foreach (@{$psprt}) { $temphash{$_}=1; }
1.234 albertel 1169: foreach my $tempkey (sort {
1170: if ($a==$b) { return ($a cmp $b) } else { return ($a <=> $b); }
1171: } keys(%{$allparts})) {
1.208 www 1172: unless ($tempkey =~ /\./) {
1173: $r->print('<option value="'.$tempkey.'"');
1174: if ($$psprt[0] eq "all" || $temphash{$tempkey}) {
1.401 bisitz 1175: $r->print(' selected="selected"');
1.208 www 1176: }
1177: $r->print('>'.$$allparts{$tempkey}.'</option>');
1178: }
1179: }
1.209 www 1180: $r->print('</select>');
1181: }
1182:
1183: sub usermenu {
1.275 raeburn 1184: my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_;
1.209 www 1185: my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '.
1186: &Apache::loncommon::selectstudent_link('parmform','uname','udom');
1187: my $selscript=&Apache::loncommon::studentbrowser_javascript();
1.412 ! bisitz 1188:
1.209 www 1189: my $sections='';
1.300 albertel 1190: my %sectionhash = &Apache::loncommon::get_sections();
1191:
1.269 raeburn 1192: my $groups;
1.307 raeburn 1193: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1194:
1.412 ! bisitz 1195: my $g_s_header='';
! 1196: my $g_s_footer='';
! 1197:
1.300 albertel 1198: if (%sectionhash) {
1.412 ! bisitz 1199: $sections=&mt('Section:').' <select name="csec"';
1.299 albertel 1200: if (%grouphash && $parmlev ne 'full') {
1.269 raeburn 1201: $sections .= qq| onchange="group_or_section('csec')" |;
1202: }
1203: $sections .= '>';
1.275 raeburn 1204: foreach my $section ('',sort keys %sectionhash) {
1205: $sections.='<option value="'.$section.'" '.
1206: ($section eq $csec?'selected="selected"':'').'>'.$section.
1207: '</option>';
1.209 www 1208: }
1209: $sections.='</select>';
1.269 raeburn 1210: }
1.412 ! bisitz 1211:
1.300 albertel 1212: if (%sectionhash && %grouphash && $parmlev ne 'full') {
1.412 ! bisitz 1213: $sections .= ' '.&mt('or').' ';
1.269 raeburn 1214: $sections .= qq|
1215: <script type="text/javascript">
1216: function group_or_section(caller) {
1217: if (caller == "cgroup") {
1218: if (document.parmform.cgroup.selectedIndex != 0) {
1219: document.parmform.csec.selectedIndex = 0;
1220: }
1221: } else {
1222: if (document.parmform.csec.selectedIndex != 0) {
1223: document.parmform.cgroup.selectedIndex = 0;
1224: }
1225: }
1226: }
1227: </script>
1228: |;
1229: } else {
1230: $sections .= qq|
1231: <script type="text/javascript">
1232: function group_or_section(caller) {
1233: return;
1234: }
1235: </script>
1236: |;
1237: }
1.299 albertel 1238:
1239: if (%grouphash) {
1.412 ! bisitz 1240: $groups=&mt('Group:').' <select name="cgroup"';
1.300 albertel 1241: if (%sectionhash && $env{'form.action'} eq 'settable') {
1.269 raeburn 1242: $groups .= qq| onchange="group_or_section('cgroup')" |;
1243: }
1244: $groups .= '>';
1.275 raeburn 1245: foreach my $grp ('',sort keys %grouphash) {
1246: $groups.='<option value="'.$grp.'" ';
1247: if ($grp eq $cgroup) {
1248: unless ((defined($uname)) && ($grp eq '')) {
1249: $groups .= 'selected="selected" ';
1250: }
1251: } elsif (!defined($cgroup)) {
1252: if (@{$usersgroups} == 1) {
1253: if ($grp eq $$usersgroups[0]) {
1254: $groups .= 'selected="selected" ';
1255: }
1256: }
1257: }
1258: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1259: }
1260: $groups.='</select>';
1261: }
1.412 ! bisitz 1262:
! 1263: if (%sectionhash || %grouphash) {
! 1264: $g_s_header='<fieldset><legend>'.&mt('Group/Section').'</legend><div>';
! 1265: $g_s_footer='</div></fieldset>';
! 1266: }
! 1267:
! 1268: $r->print('<b>'
! 1269: .$g_s_header
! 1270: .$sections
! 1271: .$groups
! 1272: .$g_s_footer
! 1273: .'<fieldset><legend>'.&mt('User').'</legend><div>'
! 1274: .&mt('For User [_1] or Student/Employee ID [_2] at Domain [_3]'
! 1275: ,'<input type="text" value="'.$uname.'" size="12" name="uname" />'
! 1276: ,'<input type="text" value="'.$id.'" size="12" name="id" /> '
! 1277: ,$chooseopt)
! 1278: .'</div></fieldset>'
! 1279: .'</b>'
! 1280: );
1.209 www 1281: }
1282:
1283: sub displaymenu {
1.211 www 1284: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.209 www 1285: $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
1286: &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1287: &parmmenu($r,$allparms,$pscat,$keyorder);
1.412 ! bisitz 1288: $r->print('</td><td valign="top" align="center">');
1.209 www 1289: &partmenu($r,$allparts,$psprt);
1290: $r->print('</td></tr></table>');
1291: }
1292:
1293: sub mapmenu {
1294: my ($r,$allmaps,$pschp,$maptitles)=@_;
1.231 www 1295: $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
1.209 www 1296: $r->print('<select name="pschp">');
1297: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1298: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1299: $r->print('<option value="'.$_.'"');
1.401 bisitz 1300: if (($pschp eq $_)) { $r->print(' selected="selected"'); }
1.209 www 1301: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1302: }
1303: $r->print("</select>");
1304: }
1305:
1306: sub levelmenu {
1307: my ($r,$alllevs,$parmlev)=@_;
1.231 www 1308: $r->print('<b>'.&mt('Select Parameter Level').
1309: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
1.209 www 1310: $r->print('<select name="parmlev">');
1311: foreach (reverse sort keys %{$alllevs}) {
1312: $r->print('<option value="'.$$alllevs{$_}.'"');
1313: if ($parmlev eq $$alllevs{$_}) {
1.401 bisitz 1314: $r->print(' selected="selected"');
1.209 www 1315: }
1.401 bisitz 1316: $r->print('>'.&mt($_).'</option>');
1.208 www 1317: }
1.209 www 1318: $r->print("</select>");
1.208 www 1319: }
1320:
1.211 www 1321:
1322: sub sectionmenu {
1323: my ($r,$selectedsections)=@_;
1.300 albertel 1324: my %sectionhash = &Apache::loncommon::get_sections();
1325: return if (!%sectionhash);
1326:
1327: $r->print('<select name="Section" multiple="true" size="8" >');
1328: foreach my $s ('all',sort keys %sectionhash) {
1329: $r->print(' <option value="'.$s.'"');
1330: foreach (@{$selectedsections}) {
1331: if ($s eq $_) {
1.401 bisitz 1332: $r->print(' selected="selected"');
1.300 albertel 1333: last;
1.212 www 1334: }
1335: }
1.300 albertel 1336: $r->print('>'.$s."</option>\n");
1337: }
1338: $r->print("</select>\n");
1.269 raeburn 1339: }
1340:
1341: sub groupmenu {
1342: my ($r,$selectedgroups)=@_;
1.307 raeburn 1343: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1344: return if (!%grouphash);
1345:
1346: $r->print('<select name="Group" multiple="true" size="8" >');
1347: foreach my $group (sort(keys(%grouphash))) {
1348: $r->print(' <option value="'.$group.'"');
1349: foreach (@{$selectedgroups}) {
1350: if ($group eq $_) {
1.401 bisitz 1351: $r->print(' selected="selected"');
1.299 albertel 1352: last;
1353: }
1354: }
1355: $r->print('>'.$group."</option>\n");
1.211 www 1356: }
1.299 albertel 1357: $r->print("</select>\n");
1.211 www 1358: }
1359:
1.269 raeburn 1360:
1.210 www 1361: sub keysplit {
1362: my $keyp=shift;
1363: return (split(/\,/,$keyp));
1364: }
1365:
1366: sub keysinorder {
1367: my ($name,$keyorder)=@_;
1368: return sort {
1369: $$keyorder{$a} <=> $$keyorder{$b};
1370: } (keys %{$name});
1371: }
1372:
1.236 albertel 1373: sub keysinorder_bytype {
1374: my ($name,$keyorder)=@_;
1375: return sort {
1376: my $ta=(split('_',$a))[-1];
1377: my $tb=(split('_',$b))[-1];
1378: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1379: return ($a cmp $b);
1380: }
1381: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1382: } (keys %{$name});
1383: }
1384:
1.211 www 1385: sub keysindisplayorder {
1386: my ($name,$keyorder)=@_;
1387: return sort {
1388: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1389: } (keys %{$name});
1390: }
1391:
1.214 www 1392: sub sortmenu {
1393: my ($r,$sortorder)=@_;
1.236 albertel 1394: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1395: if ($sortorder eq 'realmstudent') {
1396: $r->print(' checked="on"');
1397: }
1398: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1399: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1400: if ($sortorder eq 'studentrealm') {
1401: $r->print(' checked="on"');
1402: }
1.236 albertel 1403: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1404: '</label>');
1.214 www 1405: }
1406:
1.211 www 1407: sub standardkeyorder {
1408: return ('parameter_0_opendate' => 1,
1409: 'parameter_0_duedate' => 2,
1410: 'parameter_0_answerdate' => 3,
1411: 'parameter_0_interval' => 4,
1412: 'parameter_0_weight' => 5,
1413: 'parameter_0_maxtries' => 6,
1414: 'parameter_0_hinttries' => 7,
1415: 'parameter_0_contentopen' => 8,
1416: 'parameter_0_contentclose' => 9,
1417: 'parameter_0_type' => 10,
1418: 'parameter_0_problemstatus' => 11,
1419: 'parameter_0_hiddenresource' => 12,
1420: 'parameter_0_hiddenparts' => 13,
1421: 'parameter_0_display' => 14,
1422: 'parameter_0_ordered' => 15,
1423: 'parameter_0_tol' => 16,
1424: 'parameter_0_sig' => 17,
1.218 www 1425: 'parameter_0_turnoffunit' => 18,
1426: 'parameter_0_discussend' => 19,
1427: 'parameter_0_discusshide' => 20);
1.211 www 1428: }
1429:
1.59 matthew 1430: ##################################################
1431: ##################################################
1432:
1433: =pod
1434:
1435: =item assessparms
1436:
1437: Show assessment data and parameters. This is a large routine that should
1438: be simplified and shortened... someday.
1439:
1440: Inputs: $r
1441:
1442: Returns: nothing
1443:
1.63 bowersj2 1444: Variables used (guessed by Jeremy):
1445:
1446: =over 4
1447:
1448: =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.
1449:
1450: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
1451:
1452: =item B<allmaps>:
1453:
1454: =back
1455:
1.59 matthew 1456: =cut
1457:
1458: ##################################################
1459: ##################################################
1.30 www 1460: sub assessparms {
1.1 www 1461:
1.43 albertel 1462: my $r=shift;
1.201 www 1463:
1464: my @ids=();
1465: my %symbp=();
1466: my %mapp=();
1467: my %typep=();
1468: my %keyp=();
1469: my %uris=();
1470: my %maptitles=();
1471:
1.2 www 1472: # -------------------------------------------------------- Variable declaration
1.209 www 1473:
1.129 www 1474: my %allmaps=();
1475: my %alllevs=();
1.57 albertel 1476:
1.187 www 1477: my $uname;
1478: my $udom;
1479: my $uhome;
1480: my $csec;
1.269 raeburn 1481: my $cgroup;
1.275 raeburn 1482: my @usersgroups = ();
1.187 www 1483:
1.190 albertel 1484: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1485:
1.57 albertel 1486: $alllevs{'Resource Level'}='full';
1.215 www 1487: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1488: $alllevs{'Course Level'}='general';
1489:
1490: my %allparms;
1491: my %allparts;
1.210 www 1492: #
1493: # Order in which these parameters will be displayed
1494: #
1.211 www 1495: my %keyorder=&standardkeyorder();
1496:
1.43 albertel 1497: @ids=();
1498: %symbp=();
1499: %typep=();
1500:
1501: my $message='';
1502:
1.190 albertel 1503: $csec=$env{'form.csec'};
1.269 raeburn 1504: $cgroup=$env{'form.cgroup'};
1.188 www 1505:
1.190 albertel 1506: if ($udom=$env{'form.udom'}) {
1507: } elsif ($udom=$env{'request.role.domain'}) {
1508: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1509: } else {
1510: $udom=$r->dir_config('lonDefDomain');
1511: }
1.43 albertel 1512:
1.134 albertel 1513: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1514: my $pschp=$env{'form.pschp'};
1.134 albertel 1515: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1516: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1517:
1.43 albertel 1518: my $pssymb='';
1.57 albertel 1519: my $parmlev='';
1520:
1.190 albertel 1521: unless ($env{'form.parmlev'}) {
1.57 albertel 1522: $parmlev = 'map';
1523: } else {
1.190 albertel 1524: $parmlev = $env{'form.parmlev'};
1.57 albertel 1525: }
1.26 www 1526:
1.29 www 1527: # ----------------------------------------------- Was this started from grades?
1528:
1.190 albertel 1529: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1530: && (!$env{'form.dis'})) {
1531: my $url=$env{'form.url'};
1.194 albertel 1532: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1533: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1534: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1535: $pschp='';
1.57 albertel 1536: $parmlev = 'full';
1.190 albertel 1537: } elsif ($env{'form.symb'}) {
1538: $pssymb=$env{'form.symb'};
1.92 albertel 1539: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1540: $pschp='';
1.57 albertel 1541: $parmlev = 'full';
1.43 albertel 1542: } else {
1.190 albertel 1543: $env{'form.url'}='';
1.43 albertel 1544: }
1545:
1.190 albertel 1546: my $id=$env{'form.id'};
1.43 albertel 1547: if (($id) && ($udom)) {
1548: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1549: if ($uname) {
1550: $id='';
1551: } else {
1552: $message=
1.314 albertel 1553: '<span class="LC_error">'.&mt("Unknown ID")." '$id' ".
1554: &mt('at domain')." '$udom'</span>";
1.43 albertel 1555: }
1556: } else {
1.190 albertel 1557: $uname=$env{'form.uname'};
1.43 albertel 1558: }
1559: unless ($udom) { $uname=''; }
1560: $uhome='';
1561: if ($uname) {
1562: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1563: if ($uhome eq 'no_host') {
1564: $message=
1.314 albertel 1565: '<span class="LC_error">'.&mt("Unknown user")." '$uname' ".
1566: &mt("at domain")." '$udom'</span>";
1.43 albertel 1567: $uname='';
1.12 www 1568: } else {
1.103 albertel 1569: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1570: $env{'request.course.id'});
1.269 raeburn 1571:
1.43 albertel 1572: if ($csec eq '-1') {
1.314 albertel 1573: $message='<span class="LC_error">'.
1.133 www 1574: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1.314 albertel 1575: &mt("not in this course")."</span>";
1.43 albertel 1576: $uname='';
1.190 albertel 1577: $csec=$env{'form.csec'};
1.269 raeburn 1578: $cgroup=$env{'form.cgroup'};
1.43 albertel 1579: } else {
1580: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1581: ('firstname','middlename','lastname','generation','id'));
1.133 www 1582: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1583: $name{'firstname'}.' '.$name{'middlename'}.' '
1584: .$name{'lastname'}.' '.$name{'generation'}.
1.336 albertel 1585: "<br />\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1586: }
1.297 raeburn 1587: @usersgroups = &Apache::lonnet::get_users_groups(
1.275 raeburn 1588: $udom,$uname,$env{'request.course.id'});
1.297 raeburn 1589: if (@usersgroups > 0) {
1.306 albertel 1590: unless (grep(/^\Q$cgroup\E$/,@usersgroups)) {
1.275 raeburn 1591: $cgroup = $usersgroups[0];
1.297 raeburn 1592: }
1.269 raeburn 1593: }
1.12 www 1594: }
1.43 albertel 1595: }
1.2 www 1596:
1.43 albertel 1597: unless ($csec) { $csec=''; }
1.269 raeburn 1598: unless ($cgroup) { $cgroup=''; }
1.12 www 1599:
1.14 www 1600: # --------------------------------------------------------- Get all assessments
1.210 www 1601: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1602: \%mapp, \%symbp,\%maptitles,\%uris,
1603: \%keyorder);
1.63 bowersj2 1604:
1.57 albertel 1605: $mapp{'0.0'} = '';
1606: $symbp{'0.0'} = '';
1.99 albertel 1607:
1.14 www 1608: # ---------------------------------------------------------- Anything to store?
1.190 albertel 1609: if ($env{'form.pres_marker'}) {
1.205 www 1610: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
1611: my @values=split(/\&\&\&/,$env{'form.pres_value'});
1612: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1613: for (my $i=0;$i<=$#markers;$i++) {
1614: $message.=&storeparm(split(/\&/,$markers[$i]),
1615: $values[$i],
1616: $types[$i],
1.269 raeburn 1617: $uname,$udom,$csec,$cgroup);
1.205 www 1618: }
1.68 www 1619: # ---------------------------------------------------------------- Done storing
1.130 www 1620: $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 1621: }
1.57 albertel 1622: #----------------------------------------------- if all selected, fill in array
1.209 www 1623: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1624: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
1.57 albertel 1625: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 1626: # ------------------------------------------------------------------ Start page
1.63 bowersj2 1627:
1.209 www 1628: &startpage($r);
1.57 albertel 1629:
1.44 albertel 1630: foreach ('tolerance','date_default','date_start','date_end',
1631: 'date_interval','int','float','string') {
1632: $r->print('<input type="hidden" value="'.
1.378 albertel 1633: &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>').
1634: '" name="recent_'.$_.'" />');
1.44 albertel 1635: }
1.57 albertel 1636:
1.44 albertel 1637: if (!$pssymb) {
1.209 www 1638: $r->print('<table border="1"><tr><td>');
1639: &levelmenu($r,\%alllevs,$parmlev);
1.128 albertel 1640: if ($parmlev ne 'general') {
1.209 www 1641: $r->print('<td>');
1642: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
1643: $r->print('</td>');
1.128 albertel 1644: }
1.209 www 1645: $r->print('</td></tr></table>');
1.211 www 1646: &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
1.44 albertel 1647: } else {
1.125 www 1648: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.312 albertel 1649: my $title = &Apache::lonnet::gettitle($pssymb);
1650: $r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource).
1651: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.238 www 1652: '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
1653: ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
1.57 albertel 1654: }
1.275 raeburn 1655: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
1.57 albertel 1656:
1.210 www 1657: $r->print('<p>'.$message.'</p>');
1658:
1.209 www 1659: $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
1.57 albertel 1660:
1661: my @temp_pscat;
1662: map {
1663: my $cat = $_;
1664: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1665: } @pscat;
1666:
1667: @pscat = @temp_pscat;
1668:
1.209 www 1669: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 1670: # ----------------------------------------------------------------- Start Table
1.57 albertel 1671: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1672: my $csuname=$env{'user.name'};
1673: my $csudom=$env{'user.domain'};
1.57 albertel 1674:
1.203 www 1675: if ($parmlev eq 'full') {
1.57 albertel 1676: my $coursespan=$csec?8:5;
1.275 raeburn 1677: my $userspan=3;
1.269 raeburn 1678: if ($cgroup ne '') {
1679: $coursespan += 3;
1680: }
1681:
1.57 albertel 1682: $r->print('<p><table border=2>');
1683: $r->print('<tr><td colspan=5></td>');
1.130 www 1684: $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
1.57 albertel 1685: if ($uname) {
1.275 raeburn 1686: if (@usersgroups > 1) {
1687: $userspan ++;
1688: }
1689: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.130 www 1690: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1691: }
1.133 www 1692: my %lt=&Apache::lonlocal::texthash(
1693: 'pie' => "Parameter in Effect",
1694: 'csv' => "Current Session Value",
1695: 'at' => 'at',
1696: 'rl' => "Resource Level",
1697: 'ic' => 'in Course',
1698: 'aut' => "Assessment URL and Title",
1.143 albertel 1699: 'type' => 'Type',
1.133 www 1700: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1701: 'part' => 'Part',
1.133 www 1702: 'pn' => 'Parameter Name',
1703: 'def' => 'default',
1704: 'femof' => 'from Enclosing Map or Folder',
1705: 'gen' => 'general',
1706: 'foremf' => 'for Enclosing Map or Folder',
1707: 'fr' => 'for Resource'
1708: );
1.57 albertel 1709: $r->print(<<ENDTABLETWO);
1.133 www 1710: <th rowspan=3>$lt{'pie'}</th>
1.336 albertel 1711: <th rowspan=3>$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th>
1.182 albertel 1712: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
1713: <th colspan=1>$lt{'ic'}</th>
1714:
1.10 www 1715: ENDTABLETWO
1.57 albertel 1716: if ($csec) {
1.133 www 1717: $r->print("<th colspan=3>".
1.269 raeburn 1718: &mt("in Section")." $csec</th>");
1719: }
1720: if ($cgroup) {
1721: $r->print("<th colspan=3>".
1722: &mt("in Group")." $cgroup</th>");
1.57 albertel 1723: }
1724: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1725: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1726: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1727: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1728: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1729: ENDTABLEHEADFOUR
1.57 albertel 1730:
1731: if ($csec) {
1.130 www 1732: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1733: }
1734:
1.269 raeburn 1735: if ($cgroup) {
1736: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1737: }
1738:
1.57 albertel 1739: if ($uname) {
1.275 raeburn 1740: if (@usersgroups > 1) {
1741: $r->print('<th>'.&mt('Control by other group?').'</th>');
1742: }
1.130 www 1743: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1744: }
1745:
1746: $r->print('</tr>');
1747:
1748: my $defbgone='';
1749: my $defbgtwo='';
1.269 raeburn 1750: my $defbgthree = '';
1.57 albertel 1751:
1752: foreach (@ids) {
1753:
1754: my $rid=$_;
1755: my ($inmapid)=($rid=~/\.(\d+)$/);
1756:
1.152 albertel 1757: if ((!$pssymb &&
1758: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1759: ||
1760: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1761: # ------------------------------------------------------ Entry for one resource
1.184 albertel 1762: if ($defbgone eq '"#E0E099"') {
1763: $defbgone='"#E0E0DD"';
1.57 albertel 1764: } else {
1.184 albertel 1765: $defbgone='"#E0E099"';
1.57 albertel 1766: }
1.184 albertel 1767: if ($defbgtwo eq '"#FFFF99"') {
1768: $defbgtwo='"#FFFFDD"';
1.57 albertel 1769: } else {
1.184 albertel 1770: $defbgtwo='"#FFFF99"';
1.57 albertel 1771: }
1.269 raeburn 1772: if ($defbgthree eq '"#FFBB99"') {
1773: $defbgthree='"#FFBBDD"';
1774: } else {
1775: $defbgthree='"#FFBB99"';
1776: }
1777:
1.57 albertel 1778: my $thistitle='';
1779: my %name= ();
1780: undef %name;
1781: my %part= ();
1782: my %display=();
1783: my %type= ();
1784: my %default=();
1.196 www 1785: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1786:
1.210 www 1787: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1788: my $tempkeyp = $_;
1789: if (grep $_ eq $tempkeyp, @catmarker) {
1790: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1791: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1792: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1793: unless ($display{$_}) { $display{$_}=''; }
1794: $display{$_}.=' ('.$name{$_}.')';
1795: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1796: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1797: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1798: }
1799: }
1800: my $totalparms=scalar keys %name;
1801: if ($totalparms>0) {
1802: my $firstrow=1;
1.274 albertel 1803: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.57 albertel 1804: $r->print('<tr><td bgcolor='.$defbgone.
1805: ' rowspan='.$totalparms.
1806: '><tt><font size=-1>'.
1807: join(' / ',split(/\//,$uri)).
1808: '</font></tt><p><b>'.
1.154 albertel 1809: "<a href=\"javascript:openWindow('".
1.274 albertel 1810: &Apache::lonnet::clutter($uri).'?symb='.
1.308 www 1811: &escape($symbp{$rid}).
1.336 albertel 1812: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
1813: " target=\"_self\">$title");
1.57 albertel 1814:
1815: if ($thistitle) {
1816: $r->print(' ('.$thistitle.')');
1817: }
1818: $r->print('</a></b></td>');
1819: $r->print('<td bgcolor='.$defbgtwo.
1820: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1821: '</td>');
1822:
1823: $r->print('<td bgcolor='.$defbgone.
1824: ' rowspan='.$totalparms.
1.238 www 1825: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.57 albertel 1826:
1.236 albertel 1827: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 1828: unless ($firstrow) {
1829: $r->print('<tr>');
1830: } else {
1831: undef $firstrow;
1832: }
1.201 www 1833: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 1834: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 1835: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 raeburn 1836: $cgroup,\@usersgroups);
1.57 albertel 1837: }
1838: }
1839: }
1840: } # end foreach ids
1.43 albertel 1841: # -------------------------------------------------- End entry for one resource
1.57 albertel 1842: $r->print('</table>');
1.203 www 1843: } # end of full
1.57 albertel 1844: #--------------------------------------------------- Entry for parm level map
1845: if ($parmlev eq 'map') {
1846: my $defbgone = '"E0E099"';
1847: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1848: my $defbgthree = '"FFBB99"';
1.57 albertel 1849:
1850: my %maplist;
1851:
1852: if ($pschp eq 'all') {
1853: %maplist = %allmaps;
1854: } else {
1855: %maplist = ($pschp => $mapp{$pschp});
1856: }
1857:
1858: #-------------------------------------------- for each map, gather information
1859: my $mapid;
1.60 albertel 1860: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1861: my $maptitle = $maplist{$mapid};
1.57 albertel 1862:
1863: #----------------------- loop through ids and get all parameter types for map
1864: #----------------------------------------- and associated information
1865: my %name = ();
1866: my %part = ();
1867: my %display = ();
1868: my %type = ();
1869: my %default = ();
1870: my $map = 0;
1871:
1872: # $r->print("Catmarker: @catmarker<br />\n");
1873:
1874: foreach (@ids) {
1875: ($map)=(/([\d]*?)\./);
1876: my $rid = $_;
1877:
1878: # $r->print("$mapid:$map: $rid <br /> \n");
1879:
1880: if ($map eq $mapid) {
1.196 www 1881: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1882: # $r->print("Keys: $keyp{$rid} <br />\n");
1883:
1884: #--------------------------------------------------------------------
1885: # @catmarker contains list of all possible parameters including part #s
1886: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1887: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1888: # When storing information, store as part 0
1889: # When requesting information, request from full part
1890: #-------------------------------------------------------------------
1.210 www 1891: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1892: my $tempkeyp = $_;
1893: my $fullkeyp = $tempkeyp;
1.73 albertel 1894: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1895:
1896: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1897: $part{$tempkeyp}="0";
1898: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1899: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1900: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1901: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1902: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1903: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1904: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1905: }
1906: } # end loop through keys
1907: }
1908: } # end loop through ids
1909:
1910: #---------------------------------------------------- print header information
1.133 www 1911: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 1912: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 1913: my $tmp="";
1.57 albertel 1914: if ($uname) {
1.267 albertel 1915: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 1916: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
1917: &mt('in')." \n";
1.57 albertel 1918: } else {
1.401 bisitz 1919: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 1920: }
1.269 raeburn 1921: if ($cgroup) {
1.401 bisitz 1922: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
1923: "</i></font> ".&mt('of')." \n";
1.269 raeburn 1924: $csec = '';
1925: } elsif ($csec) {
1.401 bisitz 1926: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
1927: "</i></font> ".&mt('of')." \n";
1.269 raeburn 1928: }
1.401 bisitz 1929: $r->print('<div align="center"><h4>'
1930: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 1931: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 1932: ,$tmp
1933: ,'<font color="red"><i>'.$coursename.'</i></font>'
1934: )
1935: ."<br /></h4>\n"
1936: );
1.57 albertel 1937: #---------------------------------------------------------------- print table
1938: $r->print('<p><table border="2">');
1.130 www 1939: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1940: $r->print('<th>'.&mt('Default Value').'</th>');
1941: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1942:
1.210 www 1943: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 1944: $r->print('<tr>');
1.201 www 1945: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 1946: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1947: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 1948: }
1.401 bisitz 1949: $r->print("</table></div>");
1.57 albertel 1950: } # end each map
1951: } # end of $parmlev eq map
1952: #--------------------------------- Entry for parm level general (Course level)
1953: if ($parmlev eq 'general') {
1954: my $defbgone = '"E0E099"';
1955: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1956: my $defbgthree = '"FFBB99"';
1.57 albertel 1957:
1958: #-------------------------------------------- for each map, gather information
1959: my $mapid="0.0";
1960: #----------------------- loop through ids and get all parameter types for map
1961: #----------------------------------------- and associated information
1962: my %name = ();
1963: my %part = ();
1964: my %display = ();
1965: my %type = ();
1966: my %default = ();
1967:
1968: foreach (@ids) {
1969: my $rid = $_;
1970:
1.196 www 1971: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1972:
1973: #--------------------------------------------------------------------
1974: # @catmarker contains list of all possible parameters including part #s
1975: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1976: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1977: # When storing information, store as part 0
1978: # When requesting information, request from full part
1979: #-------------------------------------------------------------------
1.210 www 1980: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1981: my $tempkeyp = $_;
1982: my $fullkeyp = $tempkeyp;
1.73 albertel 1983: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1984: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1985: $part{$tempkeyp}="0";
1986: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1987: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1988: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1989: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1990: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1991: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1992: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1993: }
1994: } # end loop through keys
1995: } # end loop through ids
1996:
1997: #---------------------------------------------------- print header information
1.133 www 1998: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 1999: $r->print(<<ENDMAPONE);
1.133 www 2000: <center><h4>$setdef
1.135 albertel 2001: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 2002: ENDMAPONE
2003: if ($uname) {
1.267 albertel 2004: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 2005: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 2006: } else {
1.135 albertel 2007: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 2008: }
2009:
1.135 albertel 2010: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 2011: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 2012: $r->print("</h4>\n");
1.57 albertel 2013: #---------------------------------------------------------------- print table
2014: $r->print('<p><table border="2">');
1.130 www 2015: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
2016: $r->print('<th>'.&mt('Default Value').'</th>');
2017: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 2018:
1.210 www 2019: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 2020: $r->print('<tr>');
1.201 www 2021: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2022: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2023: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2024: }
2025: $r->print("</table></center>");
2026: } # end of $parmlev eq general
1.43 albertel 2027: }
1.280 albertel 2028: $r->print('</form>'.&Apache::loncommon::end_page());
1.57 albertel 2029: } # end sub assessparms
1.30 www 2030:
1.59 matthew 2031:
2032: ##################################################
2033: ##################################################
2034:
2035: =pod
2036:
2037: =item crsenv
2038:
1.105 matthew 2039: Show and set course data and parameters. This is a large routine that should
1.59 matthew 2040: be simplified and shortened... someday.
2041:
2042: Inputs: $r
2043:
2044: Returns: nothing
2045:
2046: =cut
2047:
2048: ##################################################
2049: ##################################################
1.30 www 2050: sub crsenv {
2051: my $r=shift;
2052: my $setoutput='';
1.280 albertel 2053:
1.298 albertel 2054: my $breadcrumbs =
2055: &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
1.190 albertel 2056: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2057: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 2058:
1.392 raeburn 2059: my (%crsinfo,$chome);
2060:
1.105 matthew 2061: #
2062: # Go through list of changes
1.190 albertel 2063: foreach (keys %env) {
1.105 matthew 2064: next if ($_!~/^form\.(.+)\_setparmval$/);
2065: my $name = $1;
1.190 albertel 2066: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 2067: if ($name eq 'newp') {
1.190 albertel 2068: $name = $env{'form.newp_name'};
1.105 matthew 2069: }
2070: if ($name eq 'url') {
2071: $value=~s/^\/res\///;
2072: my $bkuptime=time;
2073: my @tmp = &Apache::lonnet::get
2074: ('environment',['url'],$dom,$crs);
1.130 www 2075: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 2076: &Apache::lonnet::put
2077: ('environment',
2078: {'top level map backup '.$bkuptime => $tmp[1] },
2079: $dom,$crs).
1.336 albertel 2080: '<br />';
1.105 matthew 2081: }
2082: #
2083: # Deal with modified default spreadsheets
2084: if ($name =~ /^spreadsheet_default_(classcalc|
2085: studentcalc|
2086: assesscalc)$/x) {
2087: my $sheettype = $1;
2088: if ($sheettype eq 'classcalc') {
2089: # no need to do anything since viewing the sheet will
2090: # cause it to be updated.
2091: } elsif ($sheettype eq 'studentcalc') {
2092: # expire all the student spreadsheets
2093: &Apache::lonnet::expirespread('','','studentcalc');
2094: } else {
2095: # expire all the assessment spreadsheets
2096: # this includes non-default spreadsheets, but better to
2097: # be safe than sorry.
2098: &Apache::lonnet::expirespread('','','assesscalc');
2099: # expire all the student spreadsheets
2100: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2101: }
1.105 matthew 2102: }
2103: #
1.107 matthew 2104: # Deal with the enrollment dates
2105: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2106: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2107: }
1.364 albertel 2108: #
2109: # Deal with the emails
2110: if ($name =~ /\.email$/) {
1.371 albertel 2111: foreach my $specifier (split(',',$value)) {
2112: my ($user,$sections_or_groups)=
2113: ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
2114: if (!$sections_or_groups) {
2115: $user = $specifier;
2116: }
2117: my ($name,$domain) = split(':',$user);
2118: if (!defined($user) || !defined($domain)) {
2119: $setoutput.= '<br /> <span class="LC_error">'.
2120: &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user).
2121: '</span>';
2122: undef($value);
2123: } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
2124: $setoutput.= '<br /> <span class="LC_error">'.
2125: &mt("Invalid email address specified, user [_1] is unknown.",$name).
2126: '</span>';
2127: undef($value);
2128: }
1.364 albertel 2129: }
2130: }
1.178 raeburn 2131: # Get existing cloners
2132: my @oldcloner = ();
2133: if ($name eq 'cloners') {
2134: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2135: if ($clonenames{'cloners'} =~ /,/) {
2136: @oldcloner = split/,/,$clonenames{'cloners'};
2137: } else {
2138: $oldcloner[0] = $clonenames{'cloners'};
2139: }
2140: }
1.107 matthew 2141: #
1.105 matthew 2142: # Let the user know we made the changes
1.153 albertel 2143: if ($name && defined($value)) {
1.379 raeburn 2144: my %failed_cloners;
1.178 raeburn 2145: if ($name eq 'cloners') {
1.239 raeburn 2146: $value =~ s/\s//g;
1.178 raeburn 2147: $value =~ s/^,//;
2148: $value =~ s/,$//;
1.239 raeburn 2149: # check requested clones are valid users.
1.379 raeburn 2150: %failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2151: }
1.105 matthew 2152: my $put_result = &Apache::lonnet::put('environment',
2153: {$name=>$value},$dom,$crs);
2154: if ($put_result eq 'ok') {
1.392 raeburn 2155: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';
2156: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2157: $setoutput .= &Apache::lonlocal::locallocaltime($value);
1.406 raeburn 2158: } elsif ($name eq 'categories') {
2159: $setoutput .= $env{'form.categories_display'};
1.392 raeburn 2160: } else {
2161: $setoutput .= $value;
2162: }
2163: $setoutput .= '</b>.<br />';
1.178 raeburn 2164: if ($name eq 'cloners') {
2165: &change_clone($value,\@oldcloner);
2166: }
1.382 raeburn 2167: # Update environment and nohist_courseids.db
1.402 raeburn 2168: if (($name eq 'description') || ($name eq 'cloners') ||
1.403 raeburn 2169: ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.392 raeburn 2170: if ($chome eq '') {
2171: %crsinfo =
2172: &Apache::lonnet::courseiddump($dom,'.',1,'.','.',
1.403 raeburn 2173: $crs,undef,undef,'.');
1.392 raeburn 2174: $chome = &Apache::lonnet::homeserver($crs,$dom);
2175: }
2176: }
1.179 raeburn 2177: if ($name eq 'description' && defined($value)) {
1.393 raeburn 2178: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
1.382 raeburn 2179: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2180: $crsinfo{$env{'request.course.id'}}{'description'} = $value;
1.392 raeburn 2181: my $putresult =
2182: &Apache::lonnet::courseidput($dom,\%crsinfo,
2183: $chome,'notime');
2184: }
2185: }
1.403 raeburn 2186: if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.402 raeburn 2187: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1.403 raeburn 2188: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});
2189: $crsinfo{$env{'request.course.id'}}{$name} = $value;
1.402 raeburn 2190: my $putresult =
2191: &Apache::lonnet::courseidput($dom,\%crsinfo,
2192: $chome,'notime');
2193: }
2194: }
1.105 matthew 2195: } else {
1.130 www 2196: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2197: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2198: }
1.379 raeburn 2199: if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {
2200: $setoutput.= &mt('Unable to include').': ';
2201: my @fails;
2202: my $num = 0;
2203: if (defined($failed_cloners{'format'})) {
2204: $fails[$num] .= '<b>'.$failed_cloners{'format'}.
2205: '</b>, '.&mt('reason').' - '.
2206: &mt('Invalid format');
2207: $num ++;
2208: }
2209: if (defined($failed_cloners{'domain'})) {
2210: $fails[$num] .= '<b>'.$failed_cloners{'domain'}.
2211: '</b>, '.&mt('reason').' - '.
2212: &mt('Domain does not exist');
2213: $num ++;
2214: }
2215: if (defined($failed_cloners{'newuser'})) {
2216: $fails[$num] .= '<b>'.$failed_cloners{'newuser'}. '</b>, '.&mt('reason').' - '.
2217: &mt('LON-CAPA user(s) do(es) not exist.').
2218: '.<br />'.&mt('Please ').
2219: ' <a href="/adm/createuser">'.
2220: &mt('add the user(s)').'</a>, '.
2221: &mt('and then return to the ').
2222: '<a href="/adm/parmset?action=crsenv">'.
2223: &mt('Course Parameters page').'</a> '.
2224: &mt('to add the new user(s) to the list of possible cloners');
2225: }
2226: $setoutput .= join('; ',@fails).'.<br />';
1.239 raeburn 2227: }
1.30 www 2228: }
1.38 harris41 2229: }
1.315 albertel 2230:
2231: my $start_table =&Apache::loncommon::start_data_table();
2232: my $start_header_row=&Apache::loncommon::start_data_table_header_row();
2233: my $end_header_row =&Apache::loncommon::end_data_table_header_row();
1.108 www 2234: # ------------------------- Re-init course environment entries for this session
2235:
1.302 albertel 2236: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.296 albertel 2237: {'freshen_cache' => 1});
1.105 matthew 2238:
1.30 www 2239: # -------------------------------------------------------- Get parameters again
1.45 matthew 2240:
2241: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2242: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2243: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2244: my $output='';
1.403 raeburn 2245: my $can_categorize;
1.45 matthew 2246: if (! exists($values{'con_lost'})) {
1.30 www 2247: my %descriptions=
1.395 bisitz 2248: ('url' => '<b>'.&mt('Top Level Map').'</b><br />'.
1.46 matthew 2249: '<a href="javascript:openbrowser'.
1.47 matthew 2250: "('envform','url','sequence')\">".
1.314 albertel 2251: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1.395 bisitz 2252: &mt('Modification may make assessment data inaccessible!').
1.314 albertel 2253: '</span>',
1.140 sakharuk 2254: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2255: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2256: '</b><br />'.
1.395 bisitz 2257: '('.&mt('internal, optional').')',
2258: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br />'
2259: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")<br />'
2260: .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'<br />'
2261: .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"<tt>*:domain</tt>"').'<br />'
2262: .&mt('Use [_1] to allow unrestricted cloning in all domains.','"<tt>*</tt>"'),
1.150 www 2263: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1.395 bisitz 2264: &mt('[_1], [_2], or [_3]','"<tt>standard</tt>"','"<tt>external</tt>"','"<tt>spreadsheet</tt>"').&Apache::loncommon::help_open_topic('GradingOptions'),
2265: 'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'
2266: .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'<br />'
2267: .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"<tt>any</tt>"','"<tt>section</tt>"').')',
2268: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b><br />'.
1.52 www 2269: '<a href="javascript:openbrowser'.
2270: "('envform','default_xml_style'".
1.336 albertel 2271: ",'sty')\">$SelectStyleFile</a><br />",
1.395 bisitz 2272: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').'</b><br />'
2273: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2274: 'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback').'</b>',
2275: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'
2276: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2277: 'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback').'</b>',
2278: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b><br />'
2279: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2280: 'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback').'</b>',
2281: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'
2282: .'('.&mt('[_1] for default hiding','"<tt>yes</tt>"').')',
2283: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'
2284: .'('.&mt('[_1] for visible separation.','"<tt>yes</tt>"').' '
2285: .&mt('Changes will not show until next login.').')',
2286: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b><br />'
2287: .'('.&mt('[_1]: students can view all sections. [_2]: students can only view their own section. blank or [_3] prevents student view.','"<tt>all</tt>"','"<tt>section</tt>"','"<tt>disabled</tt>"').')',
2288: 'student_classlist_portfiles' => '<b>'.&mt('Include link to accessible portfolio files').'</b><br />'
2289: .'('.&mt('[_1] for link to each a listing of each student\'s files.','"<tt>yes</tt>"').')',
2290: 'student_classlist_opt_in' => '<b>'.&mt("Student's agreement needed for listing in student-viewable roster").'</b><br />'
2291: .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"<tt>yes</tt>"').')',
2292: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').'</b><br />'
2293: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2294: .'("<tt>'.&mt('role,role,...').'</tt>") '
2295: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.118 matthew 2296: 'plc.users.denied' =>
1.141 sakharuk 2297: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.395 bisitz 2298: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.118 matthew 2299:
1.395 bisitz 2300: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').'</b><br />'
2301: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"')
2302: .'("<tt>'.&mt('role,role,...').'</tt>") '
2303: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2304: 'pch.users.denied' =>
1.141 sakharuk 2305: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.395 bisitz 2306: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.49 matthew 2307: 'spreadsheet_default_classcalc'
1.141 sakharuk 2308: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2309: '<a href="javascript:openbrowser'.
2310: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2311: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2312: 'spreadsheet_default_studentcalc'
1.395 bisitz 2313: => '<b>'.&mt('Default Student Spreadsheet').'</b><br />'.
1.50 matthew 2314: '<a href="javascript:openbrowser'.
2315: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2316: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2317: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2318: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2319: '<a href="javascript:openbrowser'.
2320: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2321: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2322: 'allow_limited_html_in_feedback'
1.141 sakharuk 2323: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.395 bisitz 2324: '('.&mt('Set value to [_1] to allow.','"<tt>yes</tt>"').')',
1.170 raeburn 2325: 'allow_discussion_post_editing'
1.395 bisitz 2326: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />'
2327: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2328: .'('.&mt('Set value to [_1] to allow all roles.','"<tt>yes</tt>"').')'
2329: .'("<tt>'.&mt('role:section,role:section,...').'</tt>")<br />'
2330: .'('.&mt('Example: "<tt>st:001,st:002,in,cc</tt>" would permit students in sections 001 and 002 and instructors in any section, and course coordinators to edit their own posts.').')',
1.89 albertel 2331: 'rndseed'
1.395 bisitz 2332: => '<b>'.&mt('Randomization algorithm used').'</b><br />'
2333: .'<span class="LC_error">'
2334: .&mt('Modifying this will make problems have different numbers and answers!')
2335: .'</span>',
1.151 albertel 2336: 'receiptalg'
2337: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2338: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2339: 'suppress_tries'
1.272 albertel 2340: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.395 bisitz 2341: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.113 sakharuk 2342: 'problem_stream_switch'
1.141 sakharuk 2343: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.395 bisitz 2344: ' ('.&mt('[_1] if allowed, anything else if not','"<tt>yes</tt>"').')',
1.161 sakharuk 2345: 'default_paper_size'
2346: => '<b>'.&mt('Default paper type').'</b><br />'.
2347: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2348: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2349: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.319 foxr 2350: 'print_header_format'
1.395 bisitz 2351: => ' <b>'.&mt('Print header format').'</b><br />'
2352: .&mt('Substitutions:<br />[_1]: student name, [_2]: course id, [_3]: assignment note. Numbers after the <tt>%</tt> limit the field size.','"<tt>%n</tt>"','"<tt>%c</tt>"','"<tt>%a</tt>"'),
1.217 albertel 2353: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2354: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.395 bisitz 2355: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b><br />'
2356: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")',
1.140 sakharuk 2357: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2358: 'disable_receipt_display'
1.141 sakharuk 2359: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2360: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.313 albertel 2361: 'task_messages'
1.395 bisitz 2362: => '<b>'.&mt('Send message to student when clicking Done on Tasks').'</b><br /> ('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','"<tt>only_student</tt>"','"<tt>student_and_user_notes_screen</tt>"').')',
1.163 albertel 2363: 'disablesigfigs'
2364: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2365: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2366: 'disableexampointprint'
2367: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2368: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2369: 'externalsyllabus'
1.279 www 2370: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2371: 'tthoptions'
1.367 albertel 2372: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>',
2373:
2374: 'texengine'
1.395 bisitz 2375: => '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'
1.396 bisitz 2376: .'('.&mt('[_1], [_2] (Convert to Images), [_3] (TeX to HTML), or blank for student\'s preference','"<tt>jsMath</tt>"','"<tt>mimetex</tt>"','"<tt>tth</tt>"').')',
1.397 www 2377: 'timezone'
1.400 raeburn 2378: => '<b>'.&mt('Timezone in which the course takes place').'</b>',
1.392 raeburn 2379:
1.400 raeburn 2380: 'suppress_embed_prompt'
2381: => '<b>'.&mt('Suppress prompt to upload items referenced in a web page being uploaded to portfolio, when current role is student.').'</b><br />'.
1.402 raeburn 2382: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.403 raeburn 2383: 'hidefromcat'
1.402 raeburn 2384: => '<b>'.&mt('Exclude from course catalog').'</b><br />'.
2385: ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"<tt>yes</tt>"').')',
1.403 raeburn 2386: 'categories'
2387: => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.
2388: &mt('Display Categories').'</a>',
1.409 raeburn 2389: 'datelocale'
2390: => '<b>'.&mt('Locale used for course calendar').'</b>',
1.402 raeburn 2391: );
2392: my @Display_Order = ('url','description','courseid','cloners');
1.403 raeburn 2393: (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
2394: if ($can_toggle_cat) {
1.402 raeburn 2395: push(@Display_Order,'hidefromcat');
2396: }
1.403 raeburn 2397: if ($can_categorize) {
2398: push(@Display_Order,'categories');
2399: }
1.402 raeburn 2400: push (@Display_Order,('grading',
1.278 www 2401: 'externalsyllabus',
1.107 matthew 2402: 'default_xml_style','pageseparators',
1.402 raeburn 2403: 'question.email','question.email.text','comment.email',
2404: 'comment.email.text','policy.email','policy.email.text',
1.169 matthew 2405: 'student_classlist_view',
1.372 raeburn 2406: 'student_classlist_opt_in',
2407: 'student_classlist_portfiles',
1.118 matthew 2408: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2409: 'pch.roles.denied','pch.users.denied',
2410: 'allow_limited_html_in_feedback',
1.170 raeburn 2411: 'allow_discussion_post_editing',
1.108 www 2412: 'languages',
1.397 www 2413: 'timezone',
1.409 raeburn 2414: 'datelocale',
1.150 www 2415: 'nothideprivileged',
1.107 matthew 2416: 'rndseed',
1.151 albertel 2417: 'receiptalg',
1.107 matthew 2418: 'problem_stream_switch',
1.164 sakharuk 2419: 'suppress_tries',
1.400 raeburn 2420: 'suppress_embed_prompt',
1.161 sakharuk 2421: 'default_paper_size',
1.319 foxr 2422: 'print_header_format',
1.115 www 2423: 'disable_receipt_display',
1.107 matthew 2424: 'spreadsheet_default_classcalc',
2425: 'spreadsheet_default_studentcalc',
2426: 'spreadsheet_default_assesscalc',
2427: 'hideemptyrows',
2428: 'default_enrollment_start_date',
2429: 'default_enrollment_end_date',
1.163 albertel 2430: 'tthoptions',
1.367 albertel 2431: 'texengine',
1.251 albertel 2432: 'disablesigfigs',
1.313 albertel 2433: 'disableexampointprint',
1.402 raeburn 2434: 'task_messages','task_grading'));
1.107 matthew 2435: foreach my $parameter (sort(keys(%values))) {
1.405 raeburn 2436: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2437: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2438: || ($parameter eq 'type')) {
1.142 raeburn 2439: if (! $descriptions{$parameter}) {
2440: $descriptions{$parameter}=$parameter;
2441: push(@Display_Order,$parameter);
2442: }
2443: }
1.43 albertel 2444: }
1.315 albertel 2445:
1.107 matthew 2446: foreach my $parameter (@Display_Order) {
2447: my $description = $descriptions{$parameter};
1.51 matthew 2448: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2449: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2450: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2451: '.checked=true;"';
1.315 albertel 2452: $output .= &Apache::loncommon::start_data_table_row().
2453: '<td>'.$description.'</td>';
1.107 matthew 2454: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2455: $output .= '<td>'.
2456: &Apache::lonhtmlcommon::date_setter('envform',
2457: $parameter.'_value',
2458: $values{$parameter},
2459: $onchange).
2460: '</td>';
1.398 www 2461: } elsif ($parameter eq 'timezone') {
1.399 raeburn 2462: my $includeempty = 1;
2463: my $timezone = &Apache::lonlocal::gettimezone();
1.398 www 2464: $output .= '<td>'.
2465: &Apache::loncommon::select_timezone($parameter.'_value',
1.399 raeburn 2466: $timezone,
2467: $onchange,$includeempty).'</td>';
1.409 raeburn 2468: } elsif ($parameter eq 'datelocale') {
2469: my $includeempty = 1;
2470: my $locale_obj = &Apache::lonlocal::getdatelocale();
2471: my $currdatelocale;
2472: if (ref($locale_obj)) {
2473: $currdatelocale = $locale_obj->id();
2474: }
2475: $output .= '<td>'.
2476: &Apache::loncommon::select_datelocale($parameter.'_value',
2477: $currdatelocale,
2478: $onchange,$includeempty).'</td>';
1.406 raeburn 2479: } elsif ($parameter eq 'categories') {
2480: my $catdisplay;
2481: if ($values{'categories'} ne '') {
2482: my @curritems = split(/\&/,$values{'categories'});
2483: foreach my $item (@curritems) {
2484: my ($name,$parent,$pos) = split(/:/,$item);
2485: $catdisplay .= &unescape($name).'&';
2486: }
2487: $catdisplay =~ s/\&$//;
2488: }
2489: $output .= '<td>'.
2490: '<input type="hidden" name="categories_value" value="'.
2491: $values{'categories'}.'" />'.
2492: '<input type="textbox" name="categories_display" value="'.
2493: $catdisplay.'" readonly="readonly" size="40" /></td>';
1.107 matthew 2494: } else {
2495: $output .= '<td>'.
2496: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2497: $values{$parameter},
2498: 40,$onchange).'</td>';
2499: }
2500: $output .= '<td>'.
2501: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
2502: '</td>';
1.315 albertel 2503: $output .= &Apache::loncommon::end_data_table_row()."\n";
1.51 matthew 2504: }
1.69 www 2505: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2506: '[\'envform\'].elements[\'newp_setparmval\']'.
2507: '.checked=true;"';
1.315 albertel 2508: $output.=&Apache::loncommon::start_data_table_row().
2509: '<td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 2510: '<input type="text" size=40 name="newp_name" '.
2511: $onchange.' /></td><td>'.
2512: '<input type="text" size=40 name="newp_value" '.
2513: $onchange.' /></td><td>'.
1.315 albertel 2514: '<input type="checkbox" name="newp_setparmval" /></td>'.
2515: &Apache::loncommon::end_data_table_row()."\n";
1.43 albertel 2516: }
1.157 sakharuk 2517: my %lt=&Apache::lonlocal::texthash(
2518: 'par' => 'Parameter',
2519: 'val' => 'Value',
1.395 bisitz 2520: 'set' => 'Set?',
2521: 'sav' => 'Save'
1.157 sakharuk 2522: );
2523:
1.140 sakharuk 2524: my $Parameter=&mt('Parameter');
2525: my $Value=&mt('Value');
1.141 sakharuk 2526: my $Set=&mt('Set');
1.403 raeburn 2527: my ($jscript,$categorize_js);
2528: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
2529: if ($can_categorize) {
2530: $categorize_js = <<ENDSCRIPT;
2531: function catsbrowser() {
2532: var catswin = null;
2533: var url = '/adm/parmset?action=categorizecourse';
2534: if (!catswin || catswin.closed) {
2535: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2536: } else {
2537: catswin.focus();
2538: }
2539: }
2540: ENDSCRIPT
2541: }
2542: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
2543: $browse_js."\n".$categorize_js."\n".'</script>';
1.280 albertel 2544: my $start_page =
1.323 albertel 2545: &Apache::loncommon::start_page('Set Course Environment',
1.403 raeburn 2546: $jscript);
1.280 albertel 2547: my $end_page =
2548: &Apache::loncommon::end_page();
1.315 albertel 2549: my $end_table=&Apache::loncommon::end_data_table();
1.280 albertel 2550: $r->print(<<ENDENV);
2551: $start_page
1.193 albertel 2552: $breadcrumbs
2553: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2554: $setoutput
1.395 bisitz 2555: <div><input type="submit" name="crsenv" value="$lt{'sav'}" /></div>
1.315 albertel 2556: $start_table
2557: $start_header_row
1.395 bisitz 2558: <th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>
1.315 albertel 2559: $end_header_row
1.30 www 2560: $output
1.315 albertel 2561: $end_table
1.395 bisitz 2562: <input type="submit" name="crsenv" value="$lt{'sav'}" />
1.30 www 2563: </form>
1.280 albertel 2564: $end_page
2565: ENDENV
1.30 www 2566: }
1.402 raeburn 2567:
1.403 raeburn 2568: sub can_modify_catsettings {
1.402 raeburn 2569: my ($dom) = @_;
2570: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.403 raeburn 2571: my ($can_toggle_cat,$can_categorize);
1.402 raeburn 2572: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2573: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2574: $can_toggle_cat = 1;
2575: }
1.403 raeburn 2576: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2577: $can_categorize = 1;
2578: }
2579: }
2580: return ($can_toggle_cat,$can_categorize);
2581: }
2582:
2583: sub assign_course_categories {
2584: my ($r) = @_;
2585: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2586: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2587: my $hascats = 0;
2588: my $cathash;
2589: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2590: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2591: $cathash = $domconf{'coursecategories'}{'cats'};
2592: if (ref($cathash) eq 'HASH') {
2593: $hascats = 1;
2594: }
1.402 raeburn 2595: }
1.403 raeburn 2596: my $catwin_js;
2597: if ($hascats) {
2598: my $alert = &mt('Use \"Save\" in the main window to save course categories');
2599: $catwin_js = <<ENDSCRIPT;
2600: <script type="text/javascript">
2601:
2602: function updateCategories() {
2603: var newcategories = '';
1.406 raeburn 2604: var unescapedcats = '';
1.403 raeburn 2605: if (document.chgcats.usecategory.length) {
2606: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2607: if (document.chgcats.usecategory[i].checked == true) {
2608: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1.406 raeburn 2609: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1.403 raeburn 2610: }
2611: }
2612: if (newcategories.length > 0) {
2613: newcategories = newcategories.slice(0,-1);
2614: }
1.406 raeburn 2615: if (unescapedcats.length > 0) {
1.408 raeburn 2616: unescapedcats = unescapedcats.slice(0,-3);
1.406 raeburn 2617: }
1.403 raeburn 2618: } else {
2619: if (document.chgcats.usecategory.checked == true) {
2620: newcategories = document.chgcats.usecategory.value;
1.406 raeburn 2621: unescapedcats = document.chgcats.catname.value;
1.403 raeburn 2622: }
2623: }
2624: opener.document.envform.categories_value.value = newcategories;
1.406 raeburn 2625: opener.document.envform.categories_display.value = unescapedcats;
1.403 raeburn 2626: opener.document.envform.categories_setparmval.checked = true;
2627: alert("$alert");
2628: self.close();
2629: return;
2630: }
2631:
2632: </script>
2633: ENDSCRIPT
2634: } else {
2635: my $onload;
2636: }
2637: my $start_page =
2638: &Apache::loncommon::start_page('Course Categories',$catwin_js,
2639: {'only_body' => 1,});
2640: my $end_page = &Apache::loncommon::end_page();
2641: my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';
2642: if ($hascats) {
2643: my %currsettings =
2644: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2645: $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.
2646: '<form name="chgcats" action="/adm/parmset" method="post">'."\n"
2647: .&Apache::loncommon::assign_categories_table($cathash,
2648: $currsettings{'categories'})."\n"
2649: .'<br /><input type="button" name="changes" value="'
2650: .&mt('Copy to main window').'" '
2651: .'onclick="javascript:updateCategories()" /></form><br />';
2652: } else {
2653: $categoriesform .= &mt('No categories defined for this domain');
2654: }
2655: $r->print($start_page.$categoriesform.$end_page);
2656: return;
1.402 raeburn 2657: }
2658:
1.120 www 2659: ##################################################
1.207 www 2660: # Overview mode
2661: ##################################################
1.124 www 2662: my $tableopen;
2663:
2664: sub tablestart {
2665: if ($tableopen) {
2666: return '';
2667: } else {
2668: $tableopen=1;
1.295 albertel 2669: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
1.130 www 2670: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2671: }
2672: }
2673:
2674: sub tableend {
2675: if ($tableopen) {
2676: $tableopen=0;
1.295 albertel 2677: return &Apache::loncommon::end_data_table();
1.124 www 2678: } else {
2679: return'';
2680: }
2681: }
2682:
1.207 www 2683: sub readdata {
2684: my ($crs,$dom)=@_;
2685: # Read coursedata
2686: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2687: # Read userdata
2688:
2689: my $classlist=&Apache::loncoursedata::get_classlist();
2690: foreach (keys %$classlist) {
1.350 albertel 2691: if ($_=~/^($match_username)\:($match_domain)$/) {
1.207 www 2692: my ($tuname,$tudom)=($1,$2);
2693: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2694: foreach my $userkey (keys %{$useropt}) {
2695: if ($userkey=~/^$env{'request.course.id'}/) {
2696: my $newkey=$userkey;
2697: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2698: $$resourcedata{$newkey}=$$useropt{$userkey};
2699: }
2700: }
2701: }
2702: }
2703: return $resourcedata;
2704: }
2705:
2706:
1.124 www 2707: # Setting
1.208 www 2708:
2709: sub storedata {
2710: my ($r,$crs,$dom)=@_;
1.207 www 2711: # Set userlevel immediately
2712: # Do an intermediate store of course level
2713: my $olddata=&readdata($crs,$dom);
1.124 www 2714: my %newdata=();
2715: undef %newdata;
2716: my @deldata=();
2717: undef @deldata;
1.190 albertel 2718: foreach (keys %env) {
1.124 www 2719: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2720: my $cmd=$1;
2721: my $thiskey=$2;
1.207 www 2722: my ($tuname,$tudom)=&extractuser($thiskey);
2723: my $tkey=$thiskey;
2724: if ($tuname) {
2725: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2726: }
1.385 albertel 2727: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.384 albertel 2728: my ($data, $typeof, $text);
2729: if ($cmd eq 'set') {
2730: $data=$env{$_};
2731: $typeof=$env{'form.typeof_'.$thiskey};
2732: $text = &mt('Saved modified parameter for');
2733: } elsif ($cmd eq 'datepointer') {
2734: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
2735: $typeof=$env{'form.typeof_'.$thiskey};
2736: $text = &mt('Saved modified date for');
1.385 albertel 2737: } elsif ($cmd eq 'dateinterval') {
2738: $data=&get_date_interval_from_form($thiskey);
2739: $typeof=$env{'form.typeof_'.$thiskey};
2740: $text = &mt('Saved modified date for');
1.384 albertel 2741: }
2742: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 2743: if ($tuname) {
1.212 www 2744: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2745: $tkey.'.type' => $typeof},
2746: $tudom,$tuname) eq 'ok') {
1.290 www 2747: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.384 albertel 2748: $r->print('<br />'.$text.' '.
1.207 www 2749: &Apache::loncommon::plainname($tuname,$tudom));
2750: } else {
1.314 albertel 2751: $r->print('<div class="LC_error">'.
1.365 albertel 2752: &mt('Error saving parameters').'</div>');
1.207 www 2753: }
2754: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2755: } else {
2756: $newdata{$thiskey}=$data;
1.212 www 2757: $newdata{$thiskey.'.type'}=$typeof;
2758: }
1.207 www 2759: }
1.124 www 2760: } elsif ($cmd eq 'del') {
1.207 www 2761: if ($tuname) {
2762: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 2763: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 2764: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2765: } else {
1.314 albertel 2766: $r->print('<div class="LC_error">'.
2767: &mt('Error deleting parameters').'</div>');
1.207 www 2768: }
2769: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2770: } else {
1.333 albertel 2771: push (@deldata,$thiskey,$thiskey.'.type');
1.207 www 2772: }
1.124 www 2773: }
2774: }
2775: }
1.207 www 2776: # Store all course level
1.144 www 2777: my $delentries=$#deldata+1;
2778: my @newdatakeys=keys %newdata;
2779: my $putentries=$#newdatakeys+1;
2780: if ($delentries) {
2781: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 2782: my %loghash=map { $_ => '' } @deldata;
2783: &log_parmset(\%loghash,1);
1.144 www 2784: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2785: } else {
1.314 albertel 2786: $r->print('<div class="LC_error">'.
2787: &mt('Error deleting parameters').'</div>');
1.144 www 2788: }
1.205 www 2789: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2790: }
2791: if ($putentries) {
2792: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 2793: &log_parmset(\%newdata,0);
1.365 albertel 2794: $r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2795: } else {
1.314 albertel 2796: $r->print('<div class="LC_error">'.
1.365 albertel 2797: &mt('Error saving parameters').'</div>');
1.144 www 2798: }
1.205 www 2799: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2800: }
1.208 www 2801: }
1.207 www 2802:
1.208 www 2803: sub extractuser {
2804: my $key=shift;
1.350 albertel 2805: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 2806: }
1.206 www 2807:
1.381 albertel 2808: sub parse_listdata_key {
2809: my ($key,$listdata) = @_;
2810: # split into student/section affected, and
2811: # the realm (folder/resource part and parameter
2812: my ($student,$realm) =
2813: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
2814: # if course wide student would be undefined
2815: if (!defined($student)) {
2816: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
2817: }
2818: # strip off the .type if it's not the Question type parameter
2819: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
2820: $realm=~s/\.type//;
2821: }
2822: # split into resource+part and parameter name
1.388 albertel 2823: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
2824: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 2825: return ($student,$res,$part,$parm);
2826: }
2827:
1.208 www 2828: sub listdata {
1.214 www 2829: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2830: # Start list output
1.206 www 2831:
1.122 www 2832: my $oldsection='';
2833: my $oldrealm='';
2834: my $oldpart='';
1.123 www 2835: my $pointer=0;
1.124 www 2836: $tableopen=0;
1.145 www 2837: my $foundkeys=0;
1.248 albertel 2838: my %keyorder=&standardkeyorder();
1.381 albertel 2839:
1.214 www 2840: foreach my $thiskey (sort {
1.381 albertel 2841: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
2842: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
2843:
2844: # get the numerical order for the param
2845: $aparm=$keyorder{'parameter_0_'.$aparm};
2846: $bparm=$keyorder{'parameter_0_'.$bparm};
2847:
2848: my $result=0;
2849:
1.214 www 2850: if ($sortorder eq 'realmstudent') {
1.381 albertel 2851: if ($ares ne $bres ) {
2852: $result = ($ares cmp $bres);
2853: } elsif ($astudent ne $bstudent) {
2854: $result = ($astudent cmp $bstudent);
2855: } elsif ($apart ne $bpart ) {
2856: $result = ($apart cmp $bpart);
1.237 albertel 2857: }
1.381 albertel 2858: } else {
2859: if ($astudent ne $bstudent) {
2860: $result = ($astudent cmp $bstudent);
2861: } elsif ($ares ne $bres ) {
2862: $result = ($ares cmp $bres);
2863: } elsif ($apart ne $bpart ) {
2864: $result = ($apart cmp $bpart);
1.247 albertel 2865: }
1.381 albertel 2866: }
2867:
2868: if (!$result) {
2869: if (defined($aparm) && defined($bparm)) {
2870: $result = ($aparm <=> $bparm);
2871: } elsif (defined($aparm)) {
2872: $result = -1;
2873: } elsif (defined($bparm)) {
2874: $result = 1;
1.248 albertel 2875: }
1.214 www 2876: }
1.381 albertel 2877:
2878: $result;
1.214 www 2879: } keys %{$listdata}) {
1.381 albertel 2880:
1.211 www 2881: if ($$listdata{$thiskey.'.type'}) {
2882: my $thistype=$$listdata{$thiskey.'.type'};
2883: if ($$resourcedata{$thiskey.'.type'}) {
2884: $thistype=$$resourcedata{$thiskey.'.type'};
2885: }
1.207 www 2886: my ($middle,$part,$name)=
2887: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 2888: my $section=&mt('All Students');
1.207 www 2889: if ($middle=~/^\[(.*)\]/) {
1.206 www 2890: my $issection=$1;
1.350 albertel 2891: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
1.206 www 2892: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
2893: } else {
2894: $section=&mt('Group/Section').': '.$issection;
2895: }
1.207 www 2896: $middle=~s/^\[(.*)\]//;
1.122 www 2897: }
1.207 www 2898: $middle=~s/\.+$//;
2899: $middle=~s/^\.+//;
1.316 albertel 2900: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.122 www 2901: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 2902: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><span class="LC_parm_folder">('.$1.')</span></span>';
1.122 www 2903: } elsif ($middle) {
1.174 albertel 2904: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 2905: $realm='<span class="LC_parm_scope_resource">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><span class="LC_parm_symb">('.$url.' in '.$map.' id: '.$id.')</span></span>';
1.122 www 2906: }
1.214 www 2907: if ($sortorder eq 'realmstudent') {
2908: if ($realm ne $oldrealm) {
2909: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
2910: $oldrealm=$realm;
2911: $oldsection='';
2912: }
2913: if ($section ne $oldsection) {
2914: $r->print(&tableend()."\n<h2>$section</h2>");
2915: $oldsection=$section;
2916: $oldpart='';
2917: }
2918: } else {
2919: if ($section ne $oldsection) {
2920: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
2921: $oldsection=$section;
2922: $oldrealm='';
2923: }
2924: if ($realm ne $oldrealm) {
2925: $r->print(&tableend()."\n<h2>$realm</h2>");
2926: $oldrealm=$realm;
2927: $oldpart='';
2928: }
1.122 www 2929: }
2930: if ($part ne $oldpart) {
1.124 www 2931: $r->print(&tableend().
1.316 albertel 2932: "\n<span class=\"LC_parm_part\">".&mt('Part').": $part</span>");
1.122 www 2933: $oldpart=$part;
2934: }
1.123 www 2935: #
2936: # Ready to print
2937: #
1.295 albertel 2938: $r->print(&tablestart().
2939: &Apache::loncommon::start_data_table_row().
2940: '<td><b>'.&standard_parameter_names($name).
1.293 www 2941: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 2942: $thiskey.'" /></td><td>');
1.145 www 2943: $foundkeys++;
1.213 www 2944: if (&isdateparm($thistype)) {
1.123 www 2945: my $jskey='key_'.$pointer;
2946: $pointer++;
2947: $r->print(
1.232 albertel 2948: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 2949: $jskey,
1.219 www 2950: $$resourcedata{$thiskey},
1.325 www 2951: '',1,'','').
1.277 www 2952: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.390 www 2953: (($$resourcedata{$thiskey}!=0)?'<a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
2954: &mt('Shift all dates based on this date').'</a>':'').
1.277 www 2955: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 2956: );
1.385 albertel 2957: } elsif ($thistype eq 'date_interval') {
2958: $r->print(&date_interval_selector($thiskey,
2959: $$resourcedata{$thiskey}));
1.383 albertel 2960: } elsif ($thistype =~ m/^string/) {
2961: $r->print(&string_selector($thistype,$thiskey,
2962: $$resourcedata{$thiskey}));
1.123 www 2963: } else {
1.383 albertel 2964: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
1.123 www 2965: }
1.211 www 2966: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
2967: $thistype.'">');
1.295 albertel 2968: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 2969: }
1.121 www 2970: }
1.208 www 2971: return $foundkeys;
2972: }
2973:
1.385 albertel 2974:
2975: sub date_interval_selector {
2976: my ($thiskey, $showval) = @_;
2977: my $result;
2978: foreach my $which (['days', 86400, 31],
2979: ['hours', 3600, 23],
2980: ['minutes', 60, 59],
2981: ['seconds', 1, 59]) {
2982: my ($name, $factor, $max) = @{ $which };
2983: my $amount = int($showval/$factor);
2984: $showval %= $factor;
2985: my %select = ((map {$_ => $_} (0..$max)),
2986: 'select_form_order' => [0..$max]);
2987: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
2988: %select);
2989: $result .= ' '.&mt($name);
2990: }
2991: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
2992: return $result;
2993:
2994: }
2995:
2996: sub get_date_interval_from_form {
2997: my ($key) = @_;
2998: my $seconds = 0;
2999: foreach my $which (['days', 86400],
3000: ['hours', 3600],
3001: ['minutes', 60],
3002: ['seconds', 1]) {
3003: my ($name, $factor) = @{ $which };
3004: if (defined($env{'form.'.$name.'_'.$key})) {
3005: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3006: }
3007: }
3008: return $seconds;
3009: }
3010:
3011:
1.383 albertel 3012: sub default_selector {
3013: my ($thiskey, $showval) = @_;
1.385 albertel 3014: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3015: }
3016:
3017: my %strings =
3018: (
3019: 'string_yesno'
3020: => [[ 'yes', 'Yes' ],
3021: [ 'no', 'No' ]],
3022: 'string_problemstatus'
3023: => [[ 'yes', 'Yes' ],
1.394 www 3024: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
1.383 albertel 3025: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3026: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
3027: );
3028:
3029:
3030: sub string_selector {
3031: my ($thistype, $thiskey, $showval) = @_;
3032:
3033: if (!exists($strings{$thistype})) {
3034: return &default_selector($thiskey,$showval);
3035: }
3036:
3037: my $result;
3038: foreach my $possibilities (@{ $strings{$thistype} }) {
3039: my ($name, $description) = @{ $possibilities };
3040: $result .= '<label><input type="radio" name="set_'.$thiskey.
3041: '" value="'.$name.'"';
3042: if ($showval eq $name) {
3043: $result .= ' checked="checked"';
3044: }
3045: $result .= ' />'.&mt($description).'</label> ';
3046: }
3047: return $result;
3048: }
3049:
1.389 www 3050: #
3051: # Shift all start and end dates by $shift
3052: #
3053:
3054: sub dateshift {
3055: my ($shift)=@_;
3056: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3057: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3058: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3059: # ugly retro fix for broken version of types
3060: foreach my $key (keys %data) {
3061: if ($key=~/\wtype$/) {
3062: my $newkey=$key;
3063: $newkey=~s/type$/\.type/;
3064: $data{$newkey}=$data{$key};
3065: delete $data{$key};
3066: }
3067: }
1.391 www 3068: my %storecontent=();
1.389 www 3069: # go through all parameters and look for dates
3070: foreach my $key (keys %data) {
3071: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3072: my $newdate=$data{$key}+$shift;
1.391 www 3073: $storecontent{$key}=$newdate;
1.389 www 3074: }
3075: }
1.391 www 3076: my $reply=&Apache::lonnet::cput
3077: ('resourcedata',\%storecontent,$dom,$crs);
3078: if ($reply eq 'ok') {
3079: &log_parmset(\%storecontent);
3080: }
3081: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3082: return $reply;
1.389 www 3083: }
3084:
1.208 www 3085: sub newoverview {
1.280 albertel 3086: my ($r) = @_;
3087:
1.208 www 3088: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3089: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3090: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 3091: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3092: $r->print(<<ENDOVER);
1.280 albertel 3093: $start_page
1.208 www 3094: $breadcrumbs
1.232 albertel 3095: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3096: ENDOVER
1.211 www 3097: my @ids=();
3098: my %typep=();
3099: my %keyp=();
3100: my %allparms=();
3101: my %allparts=();
3102: my %allmaps=();
3103: my %mapp=();
3104: my %symbp=();
3105: my %maptitles=();
3106: my %uris=();
3107: my %keyorder=&standardkeyorder();
3108: my %defkeytype=();
3109:
3110: my %alllevs=();
3111: $alllevs{'Resource Level'}='full';
1.215 www 3112: $alllevs{'Map/Folder Level'}='map';
1.211 www 3113: $alllevs{'Course Level'}='general';
3114:
3115: my $csec=$env{'form.csec'};
1.269 raeburn 3116: my $cgroup=$env{'form.cgroup'};
1.211 www 3117:
3118: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3119: my $pschp=$env{'form.pschp'};
3120: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
3121: if (!@psprt) { $psprt[0]='0'; }
3122:
3123: my @selected_sections =
3124: &Apache::loncommon::get_env_multiple('form.Section');
3125: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3126: foreach my $sec (@selected_sections) {
3127: if ($sec eq 'all') {
1.211 www 3128: @selected_sections = ('all');
3129: }
3130: }
1.269 raeburn 3131: my @selected_groups =
3132: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3133:
3134: my $pssymb='';
3135: my $parmlev='';
3136:
3137: unless ($env{'form.parmlev'}) {
3138: $parmlev = 'map';
3139: } else {
3140: $parmlev = $env{'form.parmlev'};
3141: }
3142:
3143: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3144: \%mapp, \%symbp,\%maptitles,\%uris,
3145: \%keyorder,\%defkeytype);
3146:
1.374 albertel 3147: if (grep {$_ eq 'all'} (@psprt)) {
3148: @psprt = keys(%allparts);
3149: }
1.211 www 3150: # Menu to select levels, etc
3151:
1.317 albertel 3152: $r->print('<table id="LC_parm_overview_scope">
3153: <tr><td class="LC_parm_overview_level_menu">');
1.211 www 3154: &levelmenu($r,\%alllevs,$parmlev);
3155: if ($parmlev ne 'general') {
1.317 albertel 3156: $r->print('<td class="LC_parm_overview_map_menu">');
1.211 www 3157: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
3158: $r->print('</td>');
3159: }
3160: $r->print('</td></tr></table>');
3161:
1.317 albertel 3162: $r->print('<table id="LC_parm_overview_controls">
3163: <tr><td class="LC_parm_overview_parm_selectors">');
1.211 www 3164: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.317 albertel 3165: $r->print('</td><td class="LC_parm_overview_restrictions">
3166: <table class="LC_parm_overview_restrictions">'.
3167: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3168: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3169: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3170: $r->print('</td><td>');
1.211 www 3171: §ionmenu($r,\@selected_sections);
1.317 albertel 3172: $r->print('</td><td>');
1.269 raeburn 3173: &groupmenu($r,\@selected_groups);
3174: $r->print('</td></tr></table>');
1.214 www 3175: $r->print('</td></tr></table>');
3176:
3177: my $sortorder=$env{'form.sortorder'};
3178: unless ($sortorder) { $sortorder='realmstudent'; }
3179: &sortmenu($r,$sortorder);
3180:
3181: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 3182:
3183: # Build the list data hash from the specified parms
3184:
3185: my $listdata;
3186: %{$listdata}=();
3187:
3188: foreach my $cat (@pscat) {
1.269 raeburn 3189: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3190: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3191: }
3192:
1.212 www 3193: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3194:
1.212 www 3195: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3196:
3197: # Read modified data
3198:
3199: my $resourcedata=&readdata($crs,$dom);
3200:
3201: # List data
3202:
1.214 www 3203: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3204: }
3205: $r->print(&tableend().
1.365 albertel 3206: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.280 albertel 3207: '</form>'.&Apache::loncommon::end_page());
1.208 www 3208: }
3209:
1.269 raeburn 3210: sub secgroup_lister {
3211: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3212: foreach my $item (@{$selections}) {
3213: foreach my $part (@{$psprt}) {
3214: my $rootparmkey=$env{'request.course.id'};
3215: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3216: $rootparmkey.='.['.$item.']';
3217: }
3218: if ($parmlev eq 'general') {
3219: # course-level parameter
3220: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3221: $$listdata{$newparmkey}=1;
3222: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3223: } elsif ($parmlev eq 'map') {
3224: # map-level parameter
3225: foreach my $mapid (keys %{$allmaps}) {
3226: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3227: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3228: $$listdata{$newparmkey}=1;
3229: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3230: }
3231: } else {
3232: # resource-level parameter
3233: foreach my $rid (@{$ids}) {
3234: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3235: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3236: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3237: $$listdata{$newparmkey}=1;
3238: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3239: }
3240: }
3241: }
3242: }
3243: }
3244:
1.208 www 3245: sub overview {
1.280 albertel 3246: my ($r) = @_;
1.208 www 3247: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3248: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3249:
3250: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3251: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3252: $r->print(<<ENDOVER);
1.280 albertel 3253: $start_page
1.208 www 3254: $breadcrumbs
1.232 albertel 3255: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 3256: ENDOVER
3257: # Store modified
3258:
3259: &storedata($r,$crs,$dom);
3260:
3261: # Read modified data
3262:
3263: my $resourcedata=&readdata($crs,$dom);
3264:
1.214 www 3265:
3266: my $sortorder=$env{'form.sortorder'};
3267: unless ($sortorder) { $sortorder='realmstudent'; }
3268: &sortmenu($r,$sortorder);
3269:
1.208 www 3270: # List data
3271:
1.214 www 3272: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3273:
1.145 www 3274: $r->print(&tableend().'<p>'.
1.280 albertel 3275: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.
3276: &Apache::loncommon::end_page());
1.120 www 3277: }
1.121 www 3278:
1.333 albertel 3279: sub clean_parameters {
3280: my ($r) = @_;
3281: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3282: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3283:
3284: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3285: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3286: $r->print(<<ENDOVER);
3287: $start_page
3288: $breadcrumbs
3289: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3290: ENDOVER
3291: # Store modified
3292:
3293: &storedata($r,$crs,$dom);
3294:
3295: # Read modified data
3296:
3297: my $resourcedata=&readdata($crs,$dom);
3298:
3299: # List data
3300:
3301: $r->print('<h3>'.
3302: &mt('These parameters refer to resources that do not exist.').
3303: '</h3>'.
3304: '<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.'<br />'.
3305: '<br />');
3306: $r->print(&Apache::loncommon::start_data_table().
3307: '<tr>'.
3308: '<th>'.&mt('Delete').'</th>'.
3309: '<th>'.&mt('Parameter').'</th>'.
3310: '</tr>');
3311: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
3312: next if (!exists($resourcedata->{$thiskey.'.type'})
3313: && $thiskey=~/\.type$/);
3314: my %data = &parse_key($thiskey);
1.383 albertel 3315: if (1) { #exists($data{'realm_exists'})
3316: #&& !$data{'realm_exists'}) {
1.333 albertel 3317: $r->print(&Apache::loncommon::start_data_table_row().
3318: '<tr>'.
3319: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3320:
3321: $r->print('<td>');
1.362 albertel 3322: my $display_value = $resourcedata->{$thiskey};
3323: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3324: $display_value =
3325: &Apache::lonlocal::locallocaltime($display_value);
3326: }
1.333 albertel 3327: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
3328: &standard_parameter_names($data{'parameter_name'}),
3329: $resourcedata->{$thiskey}));
3330: $r->print('<br />');
3331: if ($data{'scope_type'} eq 'all') {
3332: $r->print(&mt('All users'));
3333: } elsif ($data{'scope_type'} eq 'user') {
3334: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3335: } elsif ($data{'scope_type'} eq 'section') {
3336: $r->print(&mt('Section: [_1]',$data{'scope'}));
3337: } elsif ($data{'scope_type'} eq 'group') {
3338: $r->print(&mt('Group: [_1]',$data{'scope'}));
3339: }
3340: $r->print('<br />');
3341: if ($data{'realm_type'} eq 'all') {
3342: $r->print(&mt('All Resources'));
3343: } elsif ($data{'realm_type'} eq 'folder') {
3344: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3345: } elsif ($data{'realm_type'} eq 'symb') {
3346: my ($map,$resid,$url) =
3347: &Apache::lonnet::decode_symb($data{'realm'});
3348: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3349: $url,$resid,$map));
3350: }
1.362 albertel 3351: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
1.333 albertel 3352: $r->print('</td></tr>');
3353:
3354: }
3355: }
3356: $r->print(&Apache::loncommon::end_data_table().'<p>'.
3357: '<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.
3358: '</p></form>'.
3359: &Apache::loncommon::end_page());
3360: }
3361:
1.390 www 3362: sub date_shift_one {
3363: my ($r) = @_;
3364: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3365: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3366:
3367: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3368: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3369: $r->print(<<ENDOVER);
3370: $start_page
3371: $breadcrumbs
3372: ENDOVER
3373: $r->print('<form name="shiftform" method="post">'.
3374: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3375: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3376: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
3377: &Apache::lonhtmlcommon::date_setter('shiftform',
3378: 'timeshifted',
3379: $env{'form.timebase'},,
3380: '').
3381: '</td></tr></table>'.
3382: '<input type="hidden" name="action" value="dateshift2" />'.
3383: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3384: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
3385: $r->print(&Apache::loncommon::end_page());
3386: }
3387:
3388: sub date_shift_two {
3389: my ($r) = @_;
3390: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3391: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3392: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3393: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3394: $r->print(<<ENDOVER);
3395: $start_page
3396: $breadcrumbs
3397: ENDOVER
3398: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3399: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3400: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3401: &Apache::lonlocal::locallocaltime($timeshifted)));
3402: my $delta=$timeshifted-$env{'form.timebase'};
3403: &dateshift($delta);
3404: $r->print(&Apache::loncommon::end_page());
3405: }
3406:
1.333 albertel 3407: sub parse_key {
3408: my ($key) = @_;
3409: my %data;
3410: my ($middle,$part,$name)=
3411: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3412: $data{'scope_type'} = 'all';
3413: if ($middle=~/^\[(.*)\]/) {
3414: $data{'scope'} = $1;
1.350 albertel 3415: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
1.333 albertel 3416: $data{'scope_type'} = 'user';
3417: $data{'scope'} = [$1,$2];
3418: } else {
3419: #FIXME check for group scope
3420: $data{'scope_type'} = 'section';
3421: }
3422: $middle=~s/^\[(.*)\]//;
3423: }
3424: $middle=~s/\.+$//;
3425: $middle=~s/^\.+//;
3426: $data{'realm_type'}='all';
3427: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3428: $data{'realm'} = $1;
3429: $data{'realm_type'} = 'folder';
3430: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3431: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
3432: } elsif ($middle) {
3433: $data{'realm'} = $middle;
3434: $data{'realm_type'} = 'symb';
3435: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3436: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3437: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
3438: }
3439:
3440: $data{'parameter_part'} = $part;
3441: $data{'parameter_name'} = $name;
3442:
3443: return %data;
3444: }
3445:
1.59 matthew 3446: ##################################################
3447: ##################################################
1.333 albertel 3448:
1.178 raeburn 3449: =pod
1.239 raeburn 3450:
3451: =item check_cloners
3452:
3453: Checks if new users included in list of allowed cloners
3454: are valid users. Replaces supplied list with
3455: cleaned list containing only users with valid usernames
3456: and domains.
3457:
3458: Inputs: $clonelist, $oldcloner
3459: where $clonelist is ref to array of requested cloners,
3460: and $oldcloner is ref to array of currently allowed
3461: cloners.
3462:
3463: Returns: string - comma separated list of requested
3464: cloners (username:domain) who do not exist in system.
3465:
3466: =item change_clone
3467:
1.178 raeburn 3468: Modifies the list of courses a user can clone (stored
1.239 raeburn 3469: in the user's environment.db file), called when a
1.178 raeburn 3470: change is made to the list of users allowed to clone
3471: a course.
1.239 raeburn 3472:
1.178 raeburn 3473: Inputs: $action,$cloner
3474: where $action is add or drop, and $cloner is identity of
3475: user for whom cloning ability is to be changed in course.
3476:
3477: =cut
1.380 albertel 3478:
1.178 raeburn 3479: ##################################################
3480: ##################################################
3481:
1.239 raeburn 3482: sub extract_cloners {
3483: my ($clonelist,$allowclone) = @_;
3484: if ($clonelist =~ /,/) {
1.380 albertel 3485: @{$allowclone} = split(/,/,$clonelist);
1.239 raeburn 3486: } else {
3487: $$allowclone[0] = $clonelist;
3488: }
3489: }
3490:
3491: sub check_cloners {
3492: my ($clonelist,$oldcloner) = @_;
1.379 raeburn 3493: my ($clean_clonelist,%disallowed);
1.239 raeburn 3494: my @allowclone = ();
3495: &extract_cloners($$clonelist,\@allowclone);
3496: foreach my $currclone (@allowclone) {
1.380 albertel 3497: if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
1.379 raeburn 3498: if ($currclone eq '*') {
3499: $clean_clonelist .= $currclone.',';
3500: } else {
3501: my ($uname,$udom) = split(/:/,$currclone);
3502: if ($uname eq '*') {
3503: if ($udom =~ /^$match_domain$/) {
1.380 albertel 3504: if (!&Apache::lonnet::domain($udom)) {
1.379 raeburn 3505: $disallowed{'domain'} .= $currclone.',';
3506: } else {
3507: $clean_clonelist .= $currclone.',';
3508: }
3509: } else {
3510: $disallowed{'format'} .= $currclone.',';
3511: }
3512: } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
3513: $disallowed{'format'} .= $currclone.',';
1.239 raeburn 3514: } else {
1.379 raeburn 3515: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3516: $disallowed{'newuser'} .= $currclone.',';
3517: } else {
3518: $clean_clonelist .= $currclone.',';
3519: }
1.239 raeburn 3520: }
3521: }
3522: } else {
3523: $clean_clonelist .= $currclone.',';
3524: }
3525: }
1.379 raeburn 3526: foreach my $key (keys(%disallowed)) {
3527: $disallowed{$key} =~ s/,$//;
1.239 raeburn 3528: }
3529: if ($clean_clonelist) {
3530: $clean_clonelist =~ s/,$//;
3531: }
3532: $$clonelist = $clean_clonelist;
1.379 raeburn 3533: return %disallowed;
3534: }
1.178 raeburn 3535:
3536: sub change_clone {
3537: my ($clonelist,$oldcloner) = @_;
3538: my ($uname,$udom);
1.190 albertel 3539: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3540: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 3541: my $clone_crs = $cnum.':'.$cdom;
3542:
3543: if ($cnum && $cdom) {
1.239 raeburn 3544: my @allowclone;
3545: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 3546: foreach my $currclone (@allowclone) {
1.380 albertel 3547: if (!grep(/^$currclone$/,@$oldcloner)) {
1.379 raeburn 3548: if ($currclone ne '*') {
1.380 albertel 3549: ($uname,$udom) = split(/:/,$currclone);
1.379 raeburn 3550: if ($uname && $udom && $uname ne '*') {
3551: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3552: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3553: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3554: if ($currclonecrs{'cloneable'} eq '') {
3555: $currclonecrs{'cloneable'} = $clone_crs;
3556: } else {
3557: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3558: }
3559: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.178 raeburn 3560: }
3561: }
3562: }
3563: }
3564: }
3565: }
3566: foreach my $oldclone (@$oldcloner) {
1.380 albertel 3567: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
1.379 raeburn 3568: if ($oldclone ne '*') {
1.380 albertel 3569: ($uname,$udom) = split(/:/,$oldclone);
1.379 raeburn 3570: if ($uname && $udom && $uname ne '*' ) {
3571: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3572: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3573: my %newclonecrs = ();
3574: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3575: if ($currclonecrs{'cloneable'} =~ /,/) {
3576: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3577: foreach my $crs (@currclonecrs) {
3578: if ($crs ne $clone_crs) {
3579: $newclonecrs{'cloneable'} .= $crs.',';
3580: }
1.178 raeburn 3581: }
1.379 raeburn 3582: $newclonecrs{'cloneable'} =~ s/,$//;
3583: } else {
3584: $newclonecrs{'cloneable'} = '';
1.178 raeburn 3585: }
1.379 raeburn 3586: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.178 raeburn 3587: }
3588: }
3589: }
3590: }
3591: }
3592: }
3593: }
3594: }
3595:
1.193 albertel 3596:
3597: ##################################################
3598: ##################################################
3599:
3600: =pod
3601:
3602: =item * header
3603:
3604: Output html header for page
3605:
3606: =cut
3607:
3608: ##################################################
3609: ##################################################
3610: sub header {
1.280 albertel 3611: return &Apache::loncommon::start_page('Parameter Manager');
1.193 albertel 3612: }
3613: ##################################################
3614: ##################################################
3615: sub print_main_menu {
3616: my ($r,$parm_permission)=@_;
3617: #
3618: $r->print(<<ENDMAINFORMHEAD);
3619: <form method="post" enctype="multipart/form-data"
3620: action="/adm/parmset" name="studentform">
3621: ENDMAINFORMHEAD
3622: #
1.195 albertel 3623: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3624: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3625: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3626: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.268 albertel 3627:
1.193 albertel 3628: my @menu =
1.322 www 3629: ( { divider=>'Settings for Your Course',
3630: },
1.323 albertel 3631: { text => 'Set Course Environment',
1.204 www 3632: action => 'crsenv',
1.193 albertel 3633: permission => $parm_permission,
1.324 www 3634: help => 'Course_Environment',
1.193 albertel 3635: },
1.255 banghart 3636: { text => 'Set Portfolio Metadata',
1.259 banghart 3637: action => 'setrestrictmeta',
1.240 banghart 3638: permission => $parm_permission,
3639: },
1.271 www 3640: { text => 'Manage Course Slots',
1.268 albertel 3641: url => '/adm/slotrequest?command=showslots',
3642: permission => $vgr,
3643: },
1.366 albertel 3644: { text => 'Reset Student Access Times',
3645: url => '/adm/helper/resettimes.helper',
3646: permission => $mgr,
3647: },
3648:
1.322 www 3649: { text => 'Set Parameter Setting Default Actions',
3650: action => 'setdefaults',
3651: permission => $parm_permission,
3652: },
3653: { divider => 'New and Existing Parameter Settings for Your Resources',
1.268 albertel 3654: },
1.216 www 3655: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 3656: url => '/adm/helper/parameter.helper',
3657: permission => $parm_permission,
1.324 www 3658: help => 'Parameter_Helper',
1.193 albertel 3659: },
1.322 www 3660: { text => 'Set/Modify Resource Parameters - Overview Mode',
1.208 www 3661: action => 'newoverview',
3662: permission => $parm_permission,
1.324 www 3663: help => 'Parameter_Overview',
1.193 albertel 3664: },
1.216 www 3665: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 3666: action => 'settable',
3667: permission => $parm_permission,
1.324 www 3668: help => 'Table_Mode',
1.193 albertel 3669: },
1.322 www 3670: { divider => 'Existing Parameter Settings for Your Resources',
3671: },
3672: { text => 'Modify Resource Parameters - Overview Mode',
3673: action => 'setoverview',
1.220 www 3674: permission => $parm_permission,
1.324 www 3675: help => 'Parameter_Overview',
1.322 www 3676: },
1.292 www 3677: { text => 'Parameter Change Log and Course Blog Posting/User Notification',
1.284 www 3678: action => 'parameterchangelog',
3679: permission => $parm_permission,
1.220 www 3680: },
1.193 albertel 3681: );
3682: my $menu_html = '';
3683: foreach my $menu_item (@menu) {
1.268 albertel 3684: if ($menu_item->{'divider'}) {
1.322 www 3685: $menu_html .= '<h3>'.&mt($menu_item->{'divider'}).'</h3>';
1.268 albertel 3686: next;
3687: }
1.193 albertel 3688: next if (! $menu_item->{'permission'});
3689: $menu_html.='<p>';
1.316 albertel 3690: $menu_html.='<span class="LC_parm_menu_item">';
1.193 albertel 3691: if (exists($menu_item->{'url'})) {
3692: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3693: } else {
3694: $menu_html.=
3695: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3696: }
1.316 albertel 3697: $menu_html.= &mt($menu_item->{'text'}).'</a></span>';
1.193 albertel 3698: if (exists($menu_item->{'help'})) {
3699: $menu_html.=
3700: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3701: }
3702: $menu_html.='</p>'.$/;
3703: }
3704: $r->print($menu_html);
3705: return;
3706: }
1.255 banghart 3707: ### Set portfolio metadata
1.252 banghart 3708: sub output_row {
1.347 banghart 3709: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3710: my $output;
1.263 banghart 3711: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3712: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3713: if (!defined($options)) {
1.254 banghart 3714: $options = 'active,stuadd';
1.261 banghart 3715: $values = '';
1.252 banghart 3716: }
1.337 banghart 3717: if (!($options =~ /deleted/)) {
3718: my @options= ( ['active', 'Show to student'],
1.351 banghart 3719: ['stuadd', 'Provide text area for students to type catalog information'],
3720: ['choices','Provide choices for students to select from']);
3721: # ['onlyone','Student may select only one choice']);
1.337 banghart 3722: if ($added_flag) {
3723: push @options,['deleted', 'Delete Metadata Field'];
3724: }
1.351 banghart 3725: $output = &Apache::loncommon::start_data_table_row();
3726: $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
3727: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3728: foreach my $opt (@options) {
3729: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
1.347 banghart 3730: $output .= &Apache::loncommon::continue_data_table_row();
1.351 banghart 3731: $output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label>
3732: <input type="checkbox" name="'.
3733: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3734: &mt($opt->[1]).'</label></span> </td>';
1.347 banghart 3735: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3736: }
1.351 banghart 3737: $output .= &Apache::loncommon::continue_data_table_row();
3738: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
3739: $output .= &Apache::loncommon::end_data_table_row();
3740: my $multiple_checked;
3741: my $single_checked;
3742: if ($options =~ m/onlyone/) {
3743: $multiple_checked = "";
3744: $single_checked = " CHECKED ";
3745: } else {
3746: $multiple_checked = " CHECKED ";
3747: $single_checked = "";
3748: }
3749: $output .= &Apache::loncommon::continue_data_table_row();
3750: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
3751: <input type="radio" name="'.$field_name.'_onlyone" value="multiple" '.$multiple_checked .'/>
3752: Student may select multiple choices from list</span></td>';
3753: $output .= &Apache::loncommon::end_data_table_row();
3754: $output .= &Apache::loncommon::continue_data_table_row();
3755: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
3756: <input type="radio" name="'.$field_name.'_onlyone" value="single" '.$single_checked.'/>
3757: Student may select only one choice from list</span></td>';
3758: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3759: }
3760: return ($output);
3761: }
1.340 banghart 3762: sub order_meta_fields {
3763: my ($r)=@_;
3764: my $idx = 1;
3765: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3766: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3767: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.345 banghart 3768: &Apache::lonhtmlcommon::add_breadcrumb
3769: ({href=>"/adm/parmset?action=setrestrictmeta",
3770: text=>"Restrict Metadata"},
3771: {text=>"Order Metadata"});
3772: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 3773: if ($env{'form.storeorder'}) {
3774: my $newpos = $env{'form.newpos'} - 1;
3775: my $currentpos = $env{'form.currentpos'} - 1;
3776: my @neworder = ();
3777: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3778: my $i;
1.341 banghart 3779: if ($newpos > $currentpos) {
1.340 banghart 3780: # moving stuff up
3781: for ($i=0;$i<$currentpos;$i++) {
3782: $neworder[$i]=$oldorder[$i];
3783: }
3784: for ($i=$currentpos;$i<$newpos;$i++) {
3785: $neworder[$i]=$oldorder[$i+1];
3786: }
3787: $neworder[$newpos]=$oldorder[$currentpos];
3788: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
3789: $neworder[$i]=$oldorder[$i];
3790: }
3791: } else {
3792: # moving stuff down
3793: for ($i=0;$i<$newpos;$i++) {
3794: $neworder[$i]=$oldorder[$i];
3795: }
3796: $neworder[$newpos]=$oldorder[$currentpos];
3797: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3798: $neworder[$i]=$oldorder[$i-1];
3799: }
3800: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3801: $neworder[$i]=$oldorder[$i];
3802: }
3803: }
3804: my $ordered_fields = join ",", @neworder;
1.343 banghart 3805: my $put_result = &Apache::lonnet::put('environment',
3806: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.393 raeburn 3807: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3808: }
1.357 raeburn 3809: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3810: my $ordered_fields;
1.340 banghart 3811: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3812: if (!@fields_in_order) {
3813: # no order found, pick sorted order then create metadata.addedorder key.
3814: foreach my $key (sort keys %$fields) {
3815: push @fields_in_order, $key;
1.341 banghart 3816: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3817: }
1.341 banghart 3818: my $put_result = &Apache::lonnet::put('environment',
3819: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3820: }
1.340 banghart 3821: $r->print('<table>');
3822: my $num_fields = scalar(@fields_in_order);
3823: foreach my $key (@fields_in_order) {
3824: $r->print('<tr><td>');
3825: $r->print('<form method="post" action="">');
3826: $r->print('<select name="newpos" onChange="this.form.submit()">');
3827: for (my $i = 1;$i le $num_fields;$i ++) {
3828: if ($i eq $idx) {
3829: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3830: } else {
3831: $r->print('<option value="'.$i.'">'.$i.'</option>');
3832: }
3833: }
3834: $r->print('</select></td><td>');
3835: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3836: $r->print('<input type="hidden" name="storeorder" value="true" />');
3837: $r->print('</form>');
3838: $r->print($$fields{$key}.'</td></tr>');
3839: $idx ++;
3840: }
3841: $r->print('</table>');
3842: return 'ok';
3843: }
1.359 banghart 3844: sub continue {
3845: my $output;
3846: $output .= '<form action="" method="post">';
3847: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
3848: $output .= '<input type="submit" value="Continue" />';
3849: return ($output);
3850: }
1.334 banghart 3851: sub addmetafield {
3852: my ($r)=@_;
3853: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
3854: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 3855: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3856: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 3857: if (exists($env{'form.undelete'})) {
1.358 banghart 3858: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 3859: foreach my $meta_field(@meta_fields) {
3860: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
3861: $options =~ s/deleted//;
3862: $options =~ s/,,/,/;
3863: my $put_result = &Apache::lonnet::put('environment',
3864: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
3865:
3866: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
3867: }
1.359 banghart 3868: $r->print(&continue());
1.339 banghart 3869: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 3870: my $meta_field = $env{'form.fieldname'};
3871: my $display_field = $env{'form.fieldname'};
3872: $meta_field =~ s/\W/_/g;
1.338 banghart 3873: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 3874: my $put_result = &Apache::lonnet::put('environment',
3875: {'metadata.'.$meta_field.'.values'=>"",
3876: 'metadata.'.$meta_field.'.added'=>"$display_field",
3877: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 3878: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
3879: $r->print(&continue());
1.335 banghart 3880: } else {
1.357 raeburn 3881: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 3882: if ($fields) {
3883: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
3884: $r->print('<form method="post" action="">');
3885: foreach my $key(keys(%$fields)) {
1.358 banghart 3886: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 3887: }
3888: $r->print('<input type="submit" name="undelete" value="Undelete" />');
3889: $r->print('</form>');
3890: }
3891: $r->print('<hr /><strong>Or</strong> you may enter a new metadata field name.<form method="post" action="/adm/parmset?action=addmetadata"');
1.335 banghart 3892: $r->print('<input type="text" name="fieldname" /><br />');
3893: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 3894: }
1.361 albertel 3895: $r->print('</form>');
1.334 banghart 3896: }
1.259 banghart 3897: sub setrestrictmeta {
1.240 banghart 3898: my ($r)=@_;
1.242 banghart 3899: my $next_meta;
1.244 banghart 3900: my $output;
1.245 banghart 3901: my $item_num;
1.246 banghart 3902: my $put_result;
1.280 albertel 3903: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 3904: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 3905: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3906: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 3907: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 3908: my $save_field = '';
1.259 banghart 3909: if ($env{'form.restrictmeta'}) {
1.254 banghart 3910: foreach my $field (sort(keys(%env))) {
1.252 banghart 3911: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 3912: my $options;
1.252 banghart 3913: my $meta_field = $1;
3914: my $meta_key = $2;
1.253 banghart 3915: if ($save_field ne $meta_field) {
1.252 banghart 3916: $save_field = $meta_field;
1.253 banghart 3917: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 3918: $options.='stuadd,';
3919: }
1.351 banghart 3920: if ($env{'form.'.$meta_field.'_choices'}) {
3921: $options.='choices,';
3922: }
3923: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
1.254 banghart 3924: $options.='onlyone,';
3925: }
3926: if ($env{'form.'.$meta_field.'_active'}) {
3927: $options.='active,';
1.253 banghart 3928: }
1.337 banghart 3929: if ($env{'form.'.$meta_field.'_deleted'}) {
3930: $options.='deleted,';
3931: }
1.259 banghart 3932: my $name = $save_field;
1.253 banghart 3933: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 3934: {'metadata.'.$meta_field.'.options'=>$options,
3935: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 3936: },$dom,$crs);
1.252 banghart 3937: }
3938: }
3939: }
3940: }
1.296 albertel 3941: &Apache::lonnet::coursedescription($env{'request.course.id'},
3942: {'freshen_cache' => 1});
1.335 banghart 3943: # Get the default metadata fields
1.258 albertel 3944: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 3945: # Now get possible added metadata fields
1.357 raeburn 3946: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 3947: my $row_alt = 1;
1.347 banghart 3948: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 3949: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 3950: if ($field ne 'courserestricted') {
1.346 banghart 3951: $row_alt = $row_alt ? 0 : 1;
1.347 banghart 3952: $output.= &output_row($r, $field, $metadata_fields{$field});
1.265 banghart 3953: }
1.255 banghart 3954: }
1.351 banghart 3955: my $buttons = (<<ENDButtons);
3956: <input type="submit" name="restrictmeta" value="Save" />
3957: </form><br />
3958: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
3959: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
3960: </form>
3961: <br />
3962: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
3963: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
3964: ENDButtons
1.337 banghart 3965: my $added_flag = 1;
1.335 banghart 3966: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 3967: $row_alt = $row_alt ? 0 : 1;
3968: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 3969: }
1.347 banghart 3970: $output .= &Apache::loncommon::end_data_table();
1.244 banghart 3971: $r->print(<<ENDenv);
1.259 banghart 3972: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 3973: $output
1.351 banghart 3974: $buttons
1.340 banghart 3975: </form>
1.244 banghart 3976: ENDenv
1.280 albertel 3977: $r->print(&Apache::loncommon::end_page());
1.240 banghart 3978: return 'ok';
3979: }
1.220 www 3980: ##################################################
1.335 banghart 3981: sub get_added_meta_fieldnames {
1.357 raeburn 3982: my ($cid) = @_;
1.335 banghart 3983: my %fields;
3984: foreach my $key(%env) {
1.357 raeburn 3985: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 3986: my $field_name = $1;
3987: my ($display_field_name) = $env{$key};
3988: $fields{$field_name} = $display_field_name;
3989: }
3990: }
3991: return \%fields;
3992: }
1.339 banghart 3993: sub get_deleted_meta_fieldnames {
1.357 raeburn 3994: my ($cid) = @_;
1.339 banghart 3995: my %fields;
3996: foreach my $key(%env) {
1.357 raeburn 3997: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 3998: my $field_name = $1;
3999: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
4000: my ($display_field_name) = $env{$key};
4001: $fields{$field_name} = $display_field_name;
4002: }
4003: }
4004: }
4005: return \%fields;
4006: }
1.220 www 4007: sub defaultsetter {
1.280 albertel 4008: my ($r) = @_;
4009:
4010: my $start_page =
4011: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4012: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 4013: $r->print(<<ENDDEFHEAD);
1.280 albertel 4014: $start_page
1.220 www 4015: $breadcrumbs
4016: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
4017: ENDDEFHEAD
1.280 albertel 4018:
4019: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4020: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4021: my @ids=();
4022: my %typep=();
4023: my %keyp=();
4024: my %allparms=();
4025: my %allparts=();
4026: my %allmaps=();
4027: my %mapp=();
4028: my %symbp=();
4029: my %maptitles=();
4030: my %uris=();
4031: my %keyorder=&standardkeyorder();
4032: my %defkeytype=();
4033:
4034: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
4035: \%mapp, \%symbp,\%maptitles,\%uris,
4036: \%keyorder,\%defkeytype);
1.224 www 4037: if ($env{'form.storerules'}) {
4038: my %newrules=();
4039: my @delrules=();
1.226 www 4040: my %triggers=();
1.225 albertel 4041: foreach my $key (keys(%env)) {
4042: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 4043: my $tempkey=$1;
1.226 www 4044: my $action=$env{$key};
4045: if ($action) {
4046: $newrules{$tempkey.'_action'}=$action;
4047: if ($action ne 'default') {
4048: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4049: $triggers{$whichparm}.=$tempkey.':';
4050: }
4051: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 4052: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4053: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 4054: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4055: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4056: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4057: } else {
4058: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 4059: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 4060: }
4061: } else {
1.225 albertel 4062: push(@delrules,$tempkey.'_action');
1.226 www 4063: push(@delrules,$tempkey.'_type');
1.225 albertel 4064: push(@delrules,$tempkey.'_hours');
4065: push(@delrules,$tempkey.'_min');
4066: push(@delrules,$tempkey.'_sec');
4067: push(@delrules,$tempkey.'_value');
1.224 www 4068: }
4069: }
4070: }
1.226 www 4071: foreach my $key (keys %allparms) {
4072: $newrules{$key.'_triggers'}=$triggers{$key};
4073: }
1.224 www 4074: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4075: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4076: &resetrulescache();
4077: }
1.227 www 4078: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
4079: 'hours' => 'Hours',
1.221 www 4080: 'min' => 'Minutes',
4081: 'sec' => 'Seconds',
4082: 'yes' => 'Yes',
4083: 'no' => 'No');
1.222 www 4084: my @standardoptions=('','default');
4085: my @standarddisplay=('',&mt('Default value when manually setting'));
4086: my @dateoptions=('','default');
4087: my @datedisplay=('',&mt('Default value when manually setting'));
4088: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
4089: unless ($tempkey) { next; }
4090: push @standardoptions,'when_setting_'.$tempkey;
4091: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4092: if (&isdateparm($defkeytype{$tempkey})) {
4093: push @dateoptions,'later_than_'.$tempkey;
4094: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4095: push @dateoptions,'earlier_than_'.$tempkey;
4096: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4097: }
4098: }
1.231 www 4099: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
4100: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4101: $r->print("\n".&Apache::loncommon::start_data_table().
4102: &Apache::loncommon::start_data_table_header_row().
4103: "<th>".&mt('Rule for parameter').'</th><th>'.
4104: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4105: &Apache::loncommon::end_data_table_header_row());
1.221 www 4106: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 4107: unless ($tempkey) { next; }
1.318 albertel 4108: $r->print("\n".&Apache::loncommon::start_data_table_row().
4109: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 4110: my $action=&rulescache($tempkey.'_action');
4111: $r->print('<select name="'.$tempkey.'_action">');
4112: if (&isdateparm($defkeytype{$tempkey})) {
4113: for (my $i=0;$i<=$#dateoptions;$i++) {
4114: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4115: $r->print("\n<option value='$dateoptions[$i]'".
4116: ($dateoptions[$i] eq $action?' selected="selected"':'').
4117: ">$datedisplay[$i]</option>");
4118: }
4119: } else {
4120: for (my $i=0;$i<=$#standardoptions;$i++) {
4121: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4122: $r->print("\n<option value='$standardoptions[$i]'".
4123: ($standardoptions[$i] eq $action?' selected="selected"':'').
4124: ">$standarddisplay[$i]</option>");
4125: }
4126: }
4127: $r->print('</select>');
1.227 www 4128: unless (&isdateparm($defkeytype{$tempkey})) {
4129: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4130: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4131: }
1.222 www 4132: $r->print("\n</td><td>\n");
4133:
1.221 www 4134: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4135: my $days=&rulescache($tempkey.'_days');
1.222 www 4136: my $hours=&rulescache($tempkey.'_hours');
4137: my $min=&rulescache($tempkey.'_min');
4138: my $sec=&rulescache($tempkey.'_sec');
1.221 www 4139: $r->print(<<ENDINPUTDATE);
1.227 www 4140: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4141: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4142: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4143: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4144: ENDINPUTDATE
4145: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4146: my $yeschecked='';
4147: my $nochecked='';
4148: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
4149: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
4150:
1.221 www 4151: $r->print(<<ENDYESNO);
1.224 www 4152: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
4153: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 4154: ENDYESNO
4155: } else {
1.224 www 4156: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 4157: }
1.318 albertel 4158: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4159: }
1.318 albertel 4160: $r->print(&Apache::loncommon::end_data_table().
4161: "\n<input type='submit' name='storerules' value='".
1.365 albertel 4162: &mt('Save Rules')."' /></form>\n".
1.280 albertel 4163: &Apache::loncommon::end_page());
1.220 www 4164: return;
4165: }
1.193 albertel 4166:
1.290 www 4167: sub components {
1.330 albertel 4168: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4169:
4170: if ($typeflag) {
1.290 www 4171: $key=~s/\.type$//;
4172: }
1.330 albertel 4173:
4174: my ($middle,$part,$name)=
4175: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4176: my $issection;
1.330 albertel 4177:
1.290 www 4178: my $section=&mt('All Students');
4179: if ($middle=~/^\[(.*)\]/) {
1.291 www 4180: $issection=$1;
4181: $section=&mt('Group/Section').': '.$issection;
1.290 www 4182: $middle=~s/^\[(.*)\]//;
4183: }
4184: $middle=~s/\.+$//;
4185: $middle=~s/^\.+//;
1.291 www 4186: if ($uname) {
4187: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4188: $issection='';
4189: }
1.316 albertel 4190: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.304 www 4191: my $realmdescription=&mt('all resources');
1.290 www 4192: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 4193: $realm='<span class="LC_parm_scope_folder">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <span class="LC_parm_folder"><br />('.$1.')</span></span>';
1.304 www 4194: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
4195: } elsif ($middle) {
1.290 www 4196: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 4197: $realm='<span class="LC_parm_scope_resource">'.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).' <br /><span class="LC_parm_symb">('.$url.' in '.$map.' id: '.$id.')</span></span>';
1.304 www 4198: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4199: }
1.291 www 4200: my $what=$part.'.'.$name;
1.330 albertel 4201: return ($realm,$section,$name,$part,
1.304 www 4202: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4203: }
1.293 www 4204:
1.328 albertel 4205: my %standard_parms;
4206: sub load_parameter_names {
4207: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4208: while (my $configline=<$config>) {
4209: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4210: chomp($configline);
4211: my ($short,$plain)=split(/:/,$configline);
4212: my (undef,$name,$type)=split(/\&/,$short,3);
4213: if ($type eq 'display') {
4214: $standard_parms{$name} = $plain;
4215: }
4216: }
4217: close($config);
4218: $standard_parms{'int_pos'} = 'Positive Integer';
4219: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4220: %standard_parms=&Apache::lonlocal::texthash(%standard_parms);
4221: }
4222:
1.292 www 4223: sub standard_parameter_names {
4224: my ($name)=@_;
1.328 albertel 4225: if (!%standard_parms) {
4226: &load_parameter_names();
4227: }
1.292 www 4228: if ($standard_parms{$name}) {
4229: return $standard_parms{$name};
4230: } else {
4231: return $name;
4232: }
4233: }
1.290 www 4234:
1.309 www 4235: #
4236: # Parameter Change Log
4237: #
4238:
4239:
1.285 albertel 4240: sub parm_change_log {
1.284 www 4241: my ($r)=@_;
1.327 albertel 4242: $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
4243: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
4244:
1.286 www 4245: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
4246: $env{'course.'.$env{'request.course.id'}.'.domain'},
4247: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4248:
1.301 www 4249: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4250:
1.327 albertel 4251: $r->print('<form action="/adm/parmset?action=parameterchangelog"
4252: method="post" name="parameterlog">');
1.311 albertel 4253:
4254: my %saveable_parameters = ('show' => 'scalar',);
4255: &Apache::loncommon::store_course_settings('parameter_log',
4256: \%saveable_parameters);
4257: &Apache::loncommon::restore_course_settings('parameter_log',
4258: \%saveable_parameters);
1.348 www 4259: $r->print(&Apache::loncommon::display_filter().
1.326 www 4260: '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
4261: ' '.&mt('Include parameter types').'</label>'.
1.327 albertel 4262: '<input type="submit" value="'.&mt('Display').'" /></form>');
1.301 www 4263:
1.291 www 4264: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
4265: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4266: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
4267: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4268: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4269: &Apache::loncommon::end_data_table_header_row());
1.309 www 4270: my $shown=0;
1.349 www 4271: my $folder='';
4272: if ($env{'form.displayfilter'} eq 'currentfolder') {
4273: my $last='';
4274: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4275: &GDBM_READER(),0640)) {
4276: $last=$hash{'last_known'};
4277: untie(%hash);
4278: }
4279: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
4280: }
1.356 albertel 4281: foreach my $id (sort
4282: {
4283: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4284: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4285: }
4286: my $aid = (split('00000',$a))[-1];
4287: my $bid = (split('00000',$b))[-1];
4288: return $bid<=>$aid;
4289: } (keys(%parmlog))) {
1.294 www 4290: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.332 albertel 4291: my $count = 0;
1.288 albertel 4292: my $time =
1.294 www 4293: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 4294: my $plainname =
1.294 www 4295: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4296: $parmlog{$id}{'exe_udom'});
1.288 albertel 4297: my $about_me_link =
1.289 www 4298: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 4299: $parmlog{$id}{'exe_uname'},
4300: $parmlog{$id}{'exe_udom'});
1.293 www 4301: my $send_msg_link='';
1.294 www 4302: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4303: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 4304: $send_msg_link ='<br />'.
1.288 albertel 4305: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 4306: $parmlog{$id}{'exe_uname'},
4307: $parmlog{$id}{'exe_udom'});
1.288 albertel 4308: }
1.301 www 4309: my $row_start=&Apache::loncommon::start_data_table_row();
1.290 www 4310: my $makenewrow=0;
4311: my %istype=();
1.332 albertel 4312: my $output;
1.293 www 4313: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4314: my $value=$parmlog{$id}{'logentry'}{$changed};
1.331 albertel 4315: my $typeflag = ($changed =~/\.type$/ &&
4316: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4317: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
4318: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.349 www 4319: if ($env{'form.displayfilter'} eq 'currentfolder') {
4320: if ($folder) {
4321: if ($middle!~/^\Q$folder\E/) { next; }
4322: }
4323: }
1.326 www 4324: if ($typeflag) {
1.329 albertel 4325: $istype{$parmname}=$value;
1.326 www 4326: if (!$env{'form.includetypes'}) { next; }
4327: }
1.332 albertel 4328: $count++;
4329: if ($makenewrow) {
4330: $output .= $row_start;
4331: } else {
4332: $makenewrow=1;
4333: }
4334: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.292 www 4335: &standard_parameter_names($parmname).'</td><td>'.
1.332 albertel 4336: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
1.291 www 4337: my $stillactive=0;
1.332 albertel 4338: if ($parmlog{$id}{'delflag'}) {
4339: $output .= &mt('Deleted');
1.288 albertel 4340: } else {
1.290 www 4341: if ($typeflag) {
1.332 albertel 4342: $output .= &mt('Type: [_1]',&standard_parameter_names($value));
1.290 www 4343: } else {
1.291 www 4344: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4345: $uname,$udom,$issection,$issection,$courseopt);
4346: if (&isdateparm($istype{$parmname})) {
1.332 albertel 4347: $output .= &Apache::lonlocal::locallocaltime($value);
1.291 www 4348: } else {
1.332 albertel 4349: $output .= $value;
1.291 www 4350: }
4351: if ($value ne $all[$level]) {
1.332 albertel 4352: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
1.291 www 4353: } else {
4354: $stillactive=1;
4355: }
1.290 www 4356: }
1.288 albertel 4357: }
1.332 albertel 4358: $output .= '</td><td>';
1.291 www 4359: if ($stillactive) {
1.304 www 4360: my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
4361: my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
4362: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 4363: if (($uname) && ($udom)) {
1.332 albertel 4364: $output .=
4365: &Apache::loncommon::messagewrapper('Notify User',
4366: $uname,$udom,$title,
4367: $description);
1.292 www 4368: } else {
1.332 albertel 4369: $output .=
4370: &Apache::lonrss::course_blog_link($id,$title,
4371: $description);
1.292 www 4372: }
1.291 www 4373: }
1.332 albertel 4374: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
1.288 albertel 4375: }
1.349 www 4376: if ($env{'form.displayfilter'} eq 'containing') {
4377: my $wholeentry=$about_me_link.':'.
4378: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4379: $output;
4380: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4381: }
4382: if ($count) {
4383: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4384: <td rowspan="'.$count.'">'.$about_me_link.
4385: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4386: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4387: $send_msg_link.'</td>'.$output);
1.349 www 4388: $shown++;
4389: }
1.311 albertel 4390: if (!($env{'form.show'} eq &mt('all')
4391: || $shown<=$env{'form.show'})) { last; }
1.286 www 4392: }
1.301 www 4393: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4394: $r->print(&Apache::loncommon::end_page());
4395: }
4396:
1.355 albertel 4397: sub check_for_course_info {
4398: my $navmap = Apache::lonnavmaps::navmap->new();
4399: return 1 if ($navmap);
4400: return 0;
4401: }
4402:
1.178 raeburn 4403: ##################################################
4404: ##################################################
1.30 www 4405:
1.59 matthew 4406: =pod
4407:
1.83 bowersj2 4408: =item * handler
1.59 matthew 4409:
4410: Main handler. Calls &assessparms and &crsenv subroutines.
4411:
4412: =cut
1.376 albertel 4413:
1.59 matthew 4414: ##################################################
4415: ##################################################
1.259 banghart 4416:
1.30 www 4417: sub handler {
1.43 albertel 4418: my $r=shift;
1.30 www 4419:
1.376 albertel 4420: &reset_caches();
4421:
1.43 albertel 4422: if ($r->header_only) {
1.126 www 4423: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 4424: $r->send_http_header;
4425: return OK;
4426: }
1.193 albertel 4427: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 4428: ['action','state',
4429: 'pres_marker',
4430: 'pres_value',
1.206 www 4431: 'pres_type',
1.390 www 4432: 'udom','uname','symb','serial','timebase']);
1.131 www 4433:
1.83 bowersj2 4434:
1.193 albertel 4435: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4436: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
4437: text=>"Parameter Manager",
1.204 www 4438: faq=>10,
1.324 www 4439: bug=>'Instructor Interface',
4440: help => 'Parameter_Manager'});
1.203 www 4441:
1.30 www 4442: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4443: my $parm_permission =
4444: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 4445: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 4446: $env{'request.course.sec'}));
1.355 albertel 4447: my $exists = &check_for_course_info();
4448:
4449: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4450:
4451: # Start Page
1.126 www 4452: &Apache::loncommon::content_type($r,'text/html');
1.106 www 4453: $r->send_http_header;
1.30 www 4454:
1.203 www 4455:
1.193 albertel 4456: #
4457: # Main switch on form.action and form.state, as appropriate
4458: #
4459: # Check first if coming from someone else headed directly for
4460: # the table mode
4461: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
4462: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
1.324 www 4463: &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters',
4464: text=>"Problem Parameters"});
1.193 albertel 4465: &assessparms($r);
4466:
4467: } elsif (! exists($env{'form.action'})) {
4468: $r->print(&header());
1.298 albertel 4469: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 4470: &print_main_menu($r,$parm_permission);
4471: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 4472: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
4473: text=>"Course Environment"});
1.193 albertel 4474: &crsenv($r);
4475: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 4476: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4477: text=>"Overview Mode"});
1.121 www 4478: &overview($r);
1.334 banghart 4479: } elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) {
4480: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4481: text=>"Add Metadata Field"});
4482: &addmetafield($r);
1.340 banghart 4483: } elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) {
4484: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4485: text=>"Add Metadata Field"});
4486: &order_meta_fields($r);
1.259 banghart 4487: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
4488: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
4489: text=>"Restrict Metadata"});
4490: &setrestrictmeta($r);
1.208 www 4491: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
4492: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4493: text=>"Overview Mode"});
4494: &newoverview($r);
1.220 www 4495: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
4496: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
4497: text=>"Set Defaults"});
4498: &defaultsetter($r);
4499: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 4500: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 4501: text=>"Table Mode",
4502: help => 'Course_Setting_Parameters'});
1.121 www 4503: &assessparms($r);
1.284 www 4504: } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) {
4505: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.292 www 4506: text=>"Parameter Change Log"});
1.285 albertel 4507: &parm_change_log($r);
1.333 albertel 4508: } elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) {
4509: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
4510: text=>"Clean Parameters"});
4511: &clean_parameters($r);
1.390 www 4512: } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) {
4513: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.391 www 4514: text=>"Shifting Dates"});
1.390 www 4515: &date_shift_one($r);
4516: } elsif ($env{'form.action'} eq 'dateshift2' && $parm_permission) {
4517: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.391 www 4518: text=>"Shifting Dates"});
1.390 www 4519: &date_shift_two($r);
1.403 raeburn 4520: } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) {
4521: &assign_course_categories($r);
4522: }
1.43 albertel 4523: } else {
1.1 www 4524: # ----------------------------- Not in a course, or not allowed to modify parms
1.355 albertel 4525: if ($exists) {
4526: $env{'user.error.msg'}=
4527: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4528: } else {
4529: $env{'user.error.msg'}=
4530: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4531: }
1.43 albertel 4532: return HTTP_NOT_ACCEPTABLE;
4533: }
1.376 albertel 4534: &reset_caches();
4535:
1.43 albertel 4536: return OK;
1.1 www 4537: }
4538:
4539: 1;
4540: __END__
4541:
1.59 matthew 4542: =pod
1.38 harris41 4543:
4544: =back
4545:
4546: =cut
1.1 www 4547:
4548:
4549:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>