Annotation of loncom/interface/lonparmset.pm, revision 1.411
1.1 www 1: # The LearningOnline Network with CAPA
2: # Handler to set parameters for assessments
3: #
1.411 ! bisitz 4: # $Id: lonparmset.pm,v 1.410 2008/10/10 10:19:08 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.411 ! bisitz 976: $parmdis =~ 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();
1188: my %lt=&Apache::lonlocal::texthash(
1.269 raeburn 1189: 'se' => "Section",
1190: 'gr' => "Group",
1.209 www 1191: 'fu' => "For User",
1192: 'oi' => "or ID",
1193: 'ad' => "at Domain"
1194: );
1195: my $sections='';
1.300 albertel 1196: my %sectionhash = &Apache::loncommon::get_sections();
1197:
1.269 raeburn 1198: my $groups;
1.307 raeburn 1199: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1200:
1.300 albertel 1201: if (%sectionhash) {
1.269 raeburn 1202: $sections=$lt{'se'}.': <select name="csec"';
1.299 albertel 1203: if (%grouphash && $parmlev ne 'full') {
1.269 raeburn 1204: $sections .= qq| onchange="group_or_section('csec')" |;
1205: }
1206: $sections .= '>';
1.275 raeburn 1207: foreach my $section ('',sort keys %sectionhash) {
1208: $sections.='<option value="'.$section.'" '.
1209: ($section eq $csec?'selected="selected"':'').'>'.$section.
1210: '</option>';
1.209 www 1211: }
1212: $sections.='</select>';
1.269 raeburn 1213: }
1.300 albertel 1214: if (%sectionhash && %grouphash && $parmlev ne 'full') {
1.269 raeburn 1215: $sections .= ' or ';
1216: $sections .= qq|
1217: <script type="text/javascript">
1218: function group_or_section(caller) {
1219: if (caller == "cgroup") {
1220: if (document.parmform.cgroup.selectedIndex != 0) {
1221: document.parmform.csec.selectedIndex = 0;
1222: }
1223: } else {
1224: if (document.parmform.csec.selectedIndex != 0) {
1225: document.parmform.cgroup.selectedIndex = 0;
1226: }
1227: }
1228: }
1229: </script>
1230: |;
1231: } else {
1232: $sections .= qq|
1233: <script type="text/javascript">
1234: function group_or_section(caller) {
1235: return;
1236: }
1237: </script>
1238: |;
1239: }
1.299 albertel 1240:
1241: if (%grouphash) {
1.269 raeburn 1242: $groups=$lt{'gr'}.': <select name="cgroup"';
1.300 albertel 1243: if (%sectionhash && $env{'form.action'} eq 'settable') {
1.269 raeburn 1244: $groups .= qq| onchange="group_or_section('cgroup')" |;
1245: }
1246: $groups .= '>';
1.275 raeburn 1247: foreach my $grp ('',sort keys %grouphash) {
1248: $groups.='<option value="'.$grp.'" ';
1249: if ($grp eq $cgroup) {
1250: unless ((defined($uname)) && ($grp eq '')) {
1251: $groups .= 'selected="selected" ';
1252: }
1253: } elsif (!defined($cgroup)) {
1254: if (@{$usersgroups} == 1) {
1255: if ($grp eq $$usersgroups[0]) {
1256: $groups .= 'selected="selected" ';
1257: }
1258: }
1259: }
1260: $groups .= '>'.$grp.'</option>';
1.269 raeburn 1261: }
1262: $groups.='</select>';
1263: }
1264: $r->print(<<ENDMENU);
1.209 www 1265: <b>
1266: $sections
1.269 raeburn 1267: $groups
1.209 www 1268: <br />
1269: $lt{'fu'}
1270: <input type="text" value="$uname" size="12" name="uname" />
1271: $lt{'oi'}
1272: <input type="text" value="$id" size="12" name="id" />
1273: $lt{'ad'}
1274: $chooseopt
1275: </b>
1276: ENDMENU
1277: }
1278:
1279: sub displaymenu {
1.211 www 1280: my ($r,$allparms,$allparts,$pscat,$psprt,$keyorder)=@_;
1.209 www 1281: $r->print('<table border="1"><tr><th>'.&mt('Select Parameters to View').'</th><th>'.
1282: &mt('Select Parts to View').'</th></tr><tr><td>');
1.211 www 1283: &parmmenu($r,$allparms,$pscat,$keyorder);
1.209 www 1284: $r->print('</td><td>');
1285: &partmenu($r,$allparts,$psprt);
1286: $r->print('</td></tr></table>');
1287: }
1288:
1289: sub mapmenu {
1290: my ($r,$allmaps,$pschp,$maptitles)=@_;
1.231 www 1291: $r->print('<b>'.&mt('Select Enclosing Map or Folder').'</b> ');
1.209 www 1292: $r->print('<select name="pschp">');
1293: $r->print('<option value="all">'.&mt('All Maps or Folders').'</option>');
1294: foreach (sort {$$allmaps{$a} cmp $$allmaps{$b}} keys %{$allmaps}) {
1.208 www 1295: $r->print('<option value="'.$_.'"');
1.401 bisitz 1296: if (($pschp eq $_)) { $r->print(' selected="selected"'); }
1.209 www 1297: $r->print('>'.$$maptitles{$_}.($$allmaps{$_}!~/^uploaded/?' ['.$$allmaps{$_}.']':'').'</option>');
1298: }
1299: $r->print("</select>");
1300: }
1301:
1302: sub levelmenu {
1303: my ($r,$alllevs,$parmlev)=@_;
1.231 www 1304: $r->print('<b>'.&mt('Select Parameter Level').
1305: &Apache::loncommon::help_open_topic('Course_Parameter_Levels').'</b> ');
1.209 www 1306: $r->print('<select name="parmlev">');
1307: foreach (reverse sort keys %{$alllevs}) {
1308: $r->print('<option value="'.$$alllevs{$_}.'"');
1309: if ($parmlev eq $$alllevs{$_}) {
1.401 bisitz 1310: $r->print(' selected="selected"');
1.209 www 1311: }
1.401 bisitz 1312: $r->print('>'.&mt($_).'</option>');
1.208 www 1313: }
1.209 www 1314: $r->print("</select>");
1.208 www 1315: }
1316:
1.211 www 1317:
1318: sub sectionmenu {
1319: my ($r,$selectedsections)=@_;
1.300 albertel 1320: my %sectionhash = &Apache::loncommon::get_sections();
1321: return if (!%sectionhash);
1322:
1323: $r->print('<select name="Section" multiple="true" size="8" >');
1324: foreach my $s ('all',sort keys %sectionhash) {
1325: $r->print(' <option value="'.$s.'"');
1326: foreach (@{$selectedsections}) {
1327: if ($s eq $_) {
1.401 bisitz 1328: $r->print(' selected="selected"');
1.300 albertel 1329: last;
1.212 www 1330: }
1331: }
1.300 albertel 1332: $r->print('>'.$s."</option>\n");
1333: }
1334: $r->print("</select>\n");
1.269 raeburn 1335: }
1336:
1337: sub groupmenu {
1338: my ($r,$selectedgroups)=@_;
1.307 raeburn 1339: my %grouphash = &Apache::longroup::coursegroups();
1.299 albertel 1340: return if (!%grouphash);
1341:
1342: $r->print('<select name="Group" multiple="true" size="8" >');
1343: foreach my $group (sort(keys(%grouphash))) {
1344: $r->print(' <option value="'.$group.'"');
1345: foreach (@{$selectedgroups}) {
1346: if ($group eq $_) {
1.401 bisitz 1347: $r->print(' selected="selected"');
1.299 albertel 1348: last;
1349: }
1350: }
1351: $r->print('>'.$group."</option>\n");
1.211 www 1352: }
1.299 albertel 1353: $r->print("</select>\n");
1.211 www 1354: }
1355:
1.269 raeburn 1356:
1.210 www 1357: sub keysplit {
1358: my $keyp=shift;
1359: return (split(/\,/,$keyp));
1360: }
1361:
1362: sub keysinorder {
1363: my ($name,$keyorder)=@_;
1364: return sort {
1365: $$keyorder{$a} <=> $$keyorder{$b};
1366: } (keys %{$name});
1367: }
1368:
1.236 albertel 1369: sub keysinorder_bytype {
1370: my ($name,$keyorder)=@_;
1371: return sort {
1372: my $ta=(split('_',$a))[-1];
1373: my $tb=(split('_',$b))[-1];
1374: if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) {
1375: return ($a cmp $b);
1376: }
1377: $$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb};
1378: } (keys %{$name});
1379: }
1380:
1.211 www 1381: sub keysindisplayorder {
1382: my ($name,$keyorder)=@_;
1383: return sort {
1384: $$keyorder{'parameter_0_'.$a} <=> $$keyorder{'parameter_0_'.$b};
1385: } (keys %{$name});
1386: }
1387:
1.214 www 1388: sub sortmenu {
1389: my ($r,$sortorder)=@_;
1.236 albertel 1390: $r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"');
1.214 www 1391: if ($sortorder eq 'realmstudent') {
1392: $r->print(' checked="on"');
1393: }
1394: $r->print(' />'.&mt('Sort by realm first, then student (group/section)'));
1.236 albertel 1395: $r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"');
1.214 www 1396: if ($sortorder eq 'studentrealm') {
1397: $r->print(' checked="on"');
1398: }
1.236 albertel 1399: $r->print(' />'.&mt('Sort by student (group/section) first, then realm').
1400: '</label>');
1.214 www 1401: }
1402:
1.211 www 1403: sub standardkeyorder {
1404: return ('parameter_0_opendate' => 1,
1405: 'parameter_0_duedate' => 2,
1406: 'parameter_0_answerdate' => 3,
1407: 'parameter_0_interval' => 4,
1408: 'parameter_0_weight' => 5,
1409: 'parameter_0_maxtries' => 6,
1410: 'parameter_0_hinttries' => 7,
1411: 'parameter_0_contentopen' => 8,
1412: 'parameter_0_contentclose' => 9,
1413: 'parameter_0_type' => 10,
1414: 'parameter_0_problemstatus' => 11,
1415: 'parameter_0_hiddenresource' => 12,
1416: 'parameter_0_hiddenparts' => 13,
1417: 'parameter_0_display' => 14,
1418: 'parameter_0_ordered' => 15,
1419: 'parameter_0_tol' => 16,
1420: 'parameter_0_sig' => 17,
1.218 www 1421: 'parameter_0_turnoffunit' => 18,
1422: 'parameter_0_discussend' => 19,
1423: 'parameter_0_discusshide' => 20);
1.211 www 1424: }
1425:
1.59 matthew 1426: ##################################################
1427: ##################################################
1428:
1429: =pod
1430:
1431: =item assessparms
1432:
1433: Show assessment data and parameters. This is a large routine that should
1434: be simplified and shortened... someday.
1435:
1436: Inputs: $r
1437:
1438: Returns: nothing
1439:
1.63 bowersj2 1440: Variables used (guessed by Jeremy):
1441:
1442: =over 4
1443:
1444: =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.
1445:
1446: =item B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
1447:
1448: =item B<allmaps>:
1449:
1450: =back
1451:
1.59 matthew 1452: =cut
1453:
1454: ##################################################
1455: ##################################################
1.30 www 1456: sub assessparms {
1.1 www 1457:
1.43 albertel 1458: my $r=shift;
1.201 www 1459:
1460: my @ids=();
1461: my %symbp=();
1462: my %mapp=();
1463: my %typep=();
1464: my %keyp=();
1465: my %uris=();
1466: my %maptitles=();
1467:
1.2 www 1468: # -------------------------------------------------------- Variable declaration
1.209 www 1469:
1.129 www 1470: my %allmaps=();
1471: my %alllevs=();
1.57 albertel 1472:
1.187 www 1473: my $uname;
1474: my $udom;
1475: my $uhome;
1476: my $csec;
1.269 raeburn 1477: my $cgroup;
1.275 raeburn 1478: my @usersgroups = ();
1.187 www 1479:
1.190 albertel 1480: my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'};
1.187 www 1481:
1.57 albertel 1482: $alllevs{'Resource Level'}='full';
1.215 www 1483: $alllevs{'Map/Folder Level'}='map';
1.57 albertel 1484: $alllevs{'Course Level'}='general';
1485:
1486: my %allparms;
1487: my %allparts;
1.210 www 1488: #
1489: # Order in which these parameters will be displayed
1490: #
1.211 www 1491: my %keyorder=&standardkeyorder();
1492:
1.43 albertel 1493: @ids=();
1494: %symbp=();
1495: %typep=();
1496:
1497: my $message='';
1498:
1.190 albertel 1499: $csec=$env{'form.csec'};
1.269 raeburn 1500: $cgroup=$env{'form.cgroup'};
1.188 www 1501:
1.190 albertel 1502: if ($udom=$env{'form.udom'}) {
1503: } elsif ($udom=$env{'request.role.domain'}) {
1504: } elsif ($udom=$env{'user.domain'}) {
1.172 albertel 1505: } else {
1506: $udom=$r->dir_config('lonDefDomain');
1507: }
1.43 albertel 1508:
1.134 albertel 1509: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
1.190 albertel 1510: my $pschp=$env{'form.pschp'};
1.134 albertel 1511: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
1.76 www 1512: if (!@psprt) { $psprt[0]='0'; }
1.57 albertel 1513:
1.43 albertel 1514: my $pssymb='';
1.57 albertel 1515: my $parmlev='';
1516:
1.190 albertel 1517: unless ($env{'form.parmlev'}) {
1.57 albertel 1518: $parmlev = 'map';
1519: } else {
1.190 albertel 1520: $parmlev = $env{'form.parmlev'};
1.57 albertel 1521: }
1.26 www 1522:
1.29 www 1523: # ----------------------------------------------- Was this started from grades?
1524:
1.190 albertel 1525: if (($env{'form.command'} eq 'set') && ($env{'form.url'})
1526: && (!$env{'form.dis'})) {
1527: my $url=$env{'form.url'};
1.194 albertel 1528: $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
1.43 albertel 1529: $pssymb=&Apache::lonnet::symbread($url);
1.92 albertel 1530: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1531: $pschp='';
1.57 albertel 1532: $parmlev = 'full';
1.190 albertel 1533: } elsif ($env{'form.symb'}) {
1534: $pssymb=$env{'form.symb'};
1.92 albertel 1535: if (!@pscat) { @pscat=('all'); }
1.43 albertel 1536: $pschp='';
1.57 albertel 1537: $parmlev = 'full';
1.43 albertel 1538: } else {
1.190 albertel 1539: $env{'form.url'}='';
1.43 albertel 1540: }
1541:
1.190 albertel 1542: my $id=$env{'form.id'};
1.43 albertel 1543: if (($id) && ($udom)) {
1544: $uname=(&Apache::lonnet::idget($udom,$id))[1];
1545: if ($uname) {
1546: $id='';
1547: } else {
1548: $message=
1.314 albertel 1549: '<span class="LC_error">'.&mt("Unknown ID")." '$id' ".
1550: &mt('at domain')." '$udom'</span>";
1.43 albertel 1551: }
1552: } else {
1.190 albertel 1553: $uname=$env{'form.uname'};
1.43 albertel 1554: }
1555: unless ($udom) { $uname=''; }
1556: $uhome='';
1557: if ($uname) {
1558: $uhome=&Apache::lonnet::homeserver($uname,$udom);
1559: if ($uhome eq 'no_host') {
1560: $message=
1.314 albertel 1561: '<span class="LC_error">'.&mt("Unknown user")." '$uname' ".
1562: &mt("at domain")." '$udom'</span>";
1.43 albertel 1563: $uname='';
1.12 www 1564: } else {
1.103 albertel 1565: $csec=&Apache::lonnet::getsection($udom,$uname,
1.190 albertel 1566: $env{'request.course.id'});
1.269 raeburn 1567:
1.43 albertel 1568: if ($csec eq '-1') {
1.314 albertel 1569: $message='<span class="LC_error">'.
1.133 www 1570: &mt("User")." '$uname' ".&mt("at domain")." '$udom' ".
1.314 albertel 1571: &mt("not in this course")."</span>";
1.43 albertel 1572: $uname='';
1.190 albertel 1573: $csec=$env{'form.csec'};
1.269 raeburn 1574: $cgroup=$env{'form.cgroup'};
1.43 albertel 1575: } else {
1576: my %name=&Apache::lonnet::userenvironment($udom,$uname,
1577: ('firstname','middlename','lastname','generation','id'));
1.133 www 1578: $message="\n<p>\n".&mt("Full Name").": ".
1.43 albertel 1579: $name{'firstname'}.' '.$name{'middlename'}.' '
1580: .$name{'lastname'}.' '.$name{'generation'}.
1.336 albertel 1581: "<br />\n".&mt('ID').": ".$name{'id'}.'<p>';
1.43 albertel 1582: }
1.297 raeburn 1583: @usersgroups = &Apache::lonnet::get_users_groups(
1.275 raeburn 1584: $udom,$uname,$env{'request.course.id'});
1.297 raeburn 1585: if (@usersgroups > 0) {
1.306 albertel 1586: unless (grep(/^\Q$cgroup\E$/,@usersgroups)) {
1.275 raeburn 1587: $cgroup = $usersgroups[0];
1.297 raeburn 1588: }
1.269 raeburn 1589: }
1.12 www 1590: }
1.43 albertel 1591: }
1.2 www 1592:
1.43 albertel 1593: unless ($csec) { $csec=''; }
1.269 raeburn 1594: unless ($cgroup) { $cgroup=''; }
1.12 www 1595:
1.14 www 1596: # --------------------------------------------------------- Get all assessments
1.210 www 1597: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
1598: \%mapp, \%symbp,\%maptitles,\%uris,
1599: \%keyorder);
1.63 bowersj2 1600:
1.57 albertel 1601: $mapp{'0.0'} = '';
1602: $symbp{'0.0'} = '';
1.99 albertel 1603:
1.14 www 1604: # ---------------------------------------------------------- Anything to store?
1.190 albertel 1605: if ($env{'form.pres_marker'}) {
1.205 www 1606: my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
1607: my @values=split(/\&\&\&/,$env{'form.pres_value'});
1608: my @types=split(/\&\&\&/,$env{'form.pres_type'});
1609: for (my $i=0;$i<=$#markers;$i++) {
1610: $message.=&storeparm(split(/\&/,$markers[$i]),
1611: $values[$i],
1612: $types[$i],
1.269 raeburn 1613: $uname,$udom,$csec,$cgroup);
1.205 www 1614: }
1.68 www 1615: # ---------------------------------------------------------------- Done storing
1.130 www 1616: $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 1617: }
1.57 albertel 1618: #----------------------------------------------- if all selected, fill in array
1.209 www 1619: if ($pscat[0] eq "all") {@pscat = (keys %allparms);}
1620: if (!@pscat) { @pscat=('duedate','opendate','answerdate','weight','maxtries') };
1.57 albertel 1621: if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
1.2 www 1622: # ------------------------------------------------------------------ Start page
1.63 bowersj2 1623:
1.209 www 1624: &startpage($r);
1.57 albertel 1625:
1.44 albertel 1626: foreach ('tolerance','date_default','date_start','date_end',
1627: 'date_interval','int','float','string') {
1628: $r->print('<input type="hidden" value="'.
1.378 albertel 1629: &HTML::Entities::encode($env{'form.recent_'.$_},'"&<>').
1630: '" name="recent_'.$_.'" />');
1.44 albertel 1631: }
1.57 albertel 1632:
1.44 albertel 1633: if (!$pssymb) {
1.209 www 1634: $r->print('<table border="1"><tr><td>');
1635: &levelmenu($r,\%alllevs,$parmlev);
1.128 albertel 1636: if ($parmlev ne 'general') {
1.209 www 1637: $r->print('<td>');
1638: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
1639: $r->print('</td>');
1.128 albertel 1640: }
1.209 www 1641: $r->print('</td></tr></table>');
1.211 www 1642: &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder);
1.44 albertel 1643: } else {
1.125 www 1644: my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb);
1.312 albertel 1645: my $title = &Apache::lonnet::gettitle($pssymb);
1646: $r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource).
1647: '<input type="hidden" value="'.$pssymb.'" name="symb" />'.
1.238 www 1648: '<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'.
1649: ($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />');
1.57 albertel 1650: }
1.275 raeburn 1651: &usermenu($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,\@usersgroups);
1.57 albertel 1652:
1.210 www 1653: $r->print('<p>'.$message.'</p>');
1654:
1.209 www 1655: $r->print('<br /><input type="submit" name="dis" value="'.&mt("Update Parameter Display").'" />');
1.57 albertel 1656:
1657: my @temp_pscat;
1658: map {
1659: my $cat = $_;
1660: push(@temp_pscat, map { $_.'.'.$cat } @psprt);
1661: } @pscat;
1662:
1663: @pscat = @temp_pscat;
1664:
1.209 www 1665: if (($env{'form.prevvisit'}) || ($pschp) || ($pssymb)) {
1.10 www 1666: # ----------------------------------------------------------------- Start Table
1.57 albertel 1667: my @catmarker=map { tr|.|_|; 'parameter_'.$_; } @pscat;
1.190 albertel 1668: my $csuname=$env{'user.name'};
1669: my $csudom=$env{'user.domain'};
1.57 albertel 1670:
1.203 www 1671: if ($parmlev eq 'full') {
1.57 albertel 1672: my $coursespan=$csec?8:5;
1.275 raeburn 1673: my $userspan=3;
1.269 raeburn 1674: if ($cgroup ne '') {
1675: $coursespan += 3;
1676: }
1677:
1.57 albertel 1678: $r->print('<p><table border=2>');
1679: $r->print('<tr><td colspan=5></td>');
1.130 www 1680: $r->print('<th colspan='.($coursespan).'>'.&mt('Any User').'</th>');
1.57 albertel 1681: if ($uname) {
1.275 raeburn 1682: if (@usersgroups > 1) {
1683: $userspan ++;
1684: }
1685: $r->print('<th colspan="'.$userspan.'" rowspan="2">');
1.130 www 1686: $r->print(&mt("User")." $uname ".&mt('at Domain')." $udom</th>");
1.57 albertel 1687: }
1.133 www 1688: my %lt=&Apache::lonlocal::texthash(
1689: 'pie' => "Parameter in Effect",
1690: 'csv' => "Current Session Value",
1691: 'at' => 'at',
1692: 'rl' => "Resource Level",
1693: 'ic' => 'in Course',
1694: 'aut' => "Assessment URL and Title",
1.143 albertel 1695: 'type' => 'Type',
1.133 www 1696: 'emof' => "Enclosing Map or Folder",
1.143 albertel 1697: 'part' => 'Part',
1.133 www 1698: 'pn' => 'Parameter Name',
1699: 'def' => 'default',
1700: 'femof' => 'from Enclosing Map or Folder',
1701: 'gen' => 'general',
1702: 'foremf' => 'for Enclosing Map or Folder',
1703: 'fr' => 'for Resource'
1704: );
1.57 albertel 1705: $r->print(<<ENDTABLETWO);
1.133 www 1706: <th rowspan=3>$lt{'pie'}</th>
1.336 albertel 1707: <th rowspan=3>$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th>
1.182 albertel 1708: </tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th>
1709: <th colspan=1>$lt{'ic'}</th>
1710:
1.10 www 1711: ENDTABLETWO
1.57 albertel 1712: if ($csec) {
1.133 www 1713: $r->print("<th colspan=3>".
1.269 raeburn 1714: &mt("in Section")." $csec</th>");
1715: }
1716: if ($cgroup) {
1717: $r->print("<th colspan=3>".
1718: &mt("in Group")." $cgroup</th>");
1.57 albertel 1719: }
1720: $r->print(<<ENDTABLEHEADFOUR);
1.133 www 1721: </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
1722: <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
1.192 albertel 1723: <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
1724: <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
1.10 www 1725: ENDTABLEHEADFOUR
1.57 albertel 1726:
1727: if ($csec) {
1.130 www 1728: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1729: }
1730:
1.269 raeburn 1731: if ($cgroup) {
1732: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1733: }
1734:
1.57 albertel 1735: if ($uname) {
1.275 raeburn 1736: if (@usersgroups > 1) {
1737: $r->print('<th>'.&mt('Control by other group?').'</th>');
1738: }
1.130 www 1739: $r->print('<th>'.&mt('general').'</th><th>'.&mt('for Enclosing Map or Folder').'</th><th>'.&mt('for Resource').'</th>');
1.57 albertel 1740: }
1741:
1742: $r->print('</tr>');
1743:
1744: my $defbgone='';
1745: my $defbgtwo='';
1.269 raeburn 1746: my $defbgthree = '';
1.57 albertel 1747:
1748: foreach (@ids) {
1749:
1750: my $rid=$_;
1751: my ($inmapid)=($rid=~/\.(\d+)$/);
1752:
1.152 albertel 1753: if ((!$pssymb &&
1754: (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid})))
1755: ||
1756: ($pssymb && $pssymb eq $symbp{$rid})) {
1.4 www 1757: # ------------------------------------------------------ Entry for one resource
1.184 albertel 1758: if ($defbgone eq '"#E0E099"') {
1759: $defbgone='"#E0E0DD"';
1.57 albertel 1760: } else {
1.184 albertel 1761: $defbgone='"#E0E099"';
1.57 albertel 1762: }
1.184 albertel 1763: if ($defbgtwo eq '"#FFFF99"') {
1764: $defbgtwo='"#FFFFDD"';
1.57 albertel 1765: } else {
1.184 albertel 1766: $defbgtwo='"#FFFF99"';
1.57 albertel 1767: }
1.269 raeburn 1768: if ($defbgthree eq '"#FFBB99"') {
1769: $defbgthree='"#FFBBDD"';
1770: } else {
1771: $defbgthree='"#FFBB99"';
1772: }
1773:
1.57 albertel 1774: my $thistitle='';
1775: my %name= ();
1776: undef %name;
1777: my %part= ();
1778: my %display=();
1779: my %type= ();
1780: my %default=();
1.196 www 1781: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1782:
1.210 www 1783: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1784: my $tempkeyp = $_;
1785: if (grep $_ eq $tempkeyp, @catmarker) {
1786: $part{$_}=&Apache::lonnet::metadata($uri,$_.'.part');
1787: $name{$_}=&Apache::lonnet::metadata($uri,$_.'.name');
1788: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1789: unless ($display{$_}) { $display{$_}=''; }
1790: $display{$_}.=' ('.$name{$_}.')';
1791: $default{$_}=&Apache::lonnet::metadata($uri,$_);
1792: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
1793: $thistitle=&Apache::lonnet::metadata($uri,$_.'.title');
1794: }
1795: }
1796: my $totalparms=scalar keys %name;
1797: if ($totalparms>0) {
1798: my $firstrow=1;
1.274 albertel 1799: my $title=&Apache::lonnet::gettitle($symbp{$rid});
1.57 albertel 1800: $r->print('<tr><td bgcolor='.$defbgone.
1801: ' rowspan='.$totalparms.
1802: '><tt><font size=-1>'.
1803: join(' / ',split(/\//,$uri)).
1804: '</font></tt><p><b>'.
1.154 albertel 1805: "<a href=\"javascript:openWindow('".
1.274 albertel 1806: &Apache::lonnet::clutter($uri).'?symb='.
1.308 www 1807: &escape($symbp{$rid}).
1.336 albertel 1808: "', 'metadatafile', '450', '500', 'no', 'yes');\"".
1809: " target=\"_self\">$title");
1.57 albertel 1810:
1811: if ($thistitle) {
1812: $r->print(' ('.$thistitle.')');
1813: }
1814: $r->print('</a></b></td>');
1815: $r->print('<td bgcolor='.$defbgtwo.
1816: ' rowspan='.$totalparms.'>'.$typep{$rid}.
1817: '</td>');
1818:
1819: $r->print('<td bgcolor='.$defbgone.
1820: ' rowspan='.$totalparms.
1.238 www 1821: '>'.$maptitles{$mapp{$rid}}.'</td>');
1.57 albertel 1822:
1.236 albertel 1823: foreach (&keysinorder_bytype(\%name,\%keyorder)) {
1.57 albertel 1824: unless ($firstrow) {
1825: $r->print('<tr>');
1826: } else {
1827: undef $firstrow;
1828: }
1.201 www 1829: &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
1.57 albertel 1830: \%type,\%display,$defbgone,$defbgtwo,
1.269 raeburn 1831: $defbgthree,$parmlev,$uname,$udom,$csec,
1.275 raeburn 1832: $cgroup,\@usersgroups);
1.57 albertel 1833: }
1834: }
1835: }
1836: } # end foreach ids
1.43 albertel 1837: # -------------------------------------------------- End entry for one resource
1.57 albertel 1838: $r->print('</table>');
1.203 www 1839: } # end of full
1.57 albertel 1840: #--------------------------------------------------- Entry for parm level map
1841: if ($parmlev eq 'map') {
1842: my $defbgone = '"E0E099"';
1843: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1844: my $defbgthree = '"FFBB99"';
1.57 albertel 1845:
1846: my %maplist;
1847:
1848: if ($pschp eq 'all') {
1849: %maplist = %allmaps;
1850: } else {
1851: %maplist = ($pschp => $mapp{$pschp});
1852: }
1853:
1854: #-------------------------------------------- for each map, gather information
1855: my $mapid;
1.60 albertel 1856: foreach $mapid (sort {$maplist{$a} cmp $maplist{$b}} keys %maplist) {
1857: my $maptitle = $maplist{$mapid};
1.57 albertel 1858:
1859: #----------------------- loop through ids and get all parameter types for map
1860: #----------------------------------------- and associated information
1861: my %name = ();
1862: my %part = ();
1863: my %display = ();
1864: my %type = ();
1865: my %default = ();
1866: my $map = 0;
1867:
1868: # $r->print("Catmarker: @catmarker<br />\n");
1869:
1870: foreach (@ids) {
1871: ($map)=(/([\d]*?)\./);
1872: my $rid = $_;
1873:
1874: # $r->print("$mapid:$map: $rid <br /> \n");
1875:
1876: if ($map eq $mapid) {
1.196 www 1877: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1878: # $r->print("Keys: $keyp{$rid} <br />\n");
1879:
1880: #--------------------------------------------------------------------
1881: # @catmarker contains list of all possible parameters including part #s
1882: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1883: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1884: # When storing information, store as part 0
1885: # When requesting information, request from full part
1886: #-------------------------------------------------------------------
1.210 www 1887: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1888: my $tempkeyp = $_;
1889: my $fullkeyp = $tempkeyp;
1.73 albertel 1890: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1891:
1892: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1893: $part{$tempkeyp}="0";
1894: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1895: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1896: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1897: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1898: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1899: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1900: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1901: }
1902: } # end loop through keys
1903: }
1904: } # end loop through ids
1905:
1906: #---------------------------------------------------- print header information
1.133 www 1907: my $foldermap=&mt($maptitle=~/^uploaded/?'Folder':'Map');
1.82 www 1908: my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':'');
1.401 bisitz 1909: my $tmp="";
1.57 albertel 1910: if ($uname) {
1.267 albertel 1911: my $person=&Apache::loncommon::plainname($uname,$udom);
1.401 bisitz 1912: $tmp.=&mt("User")." <font color=\"red\"><i>$uname \($person\) </i></font> ".
1913: &mt('in')." \n";
1.57 albertel 1914: } else {
1.401 bisitz 1915: $tmp.="<font color=\"red\"><i>".&mt('all').'</i></font> '.&mt('users in')." \n";
1.57 albertel 1916: }
1.269 raeburn 1917: if ($cgroup) {
1.401 bisitz 1918: $tmp.=&mt("Group")." <font color=\"red\"><i>$cgroup".
1919: "</i></font> ".&mt('of')." \n";
1.269 raeburn 1920: $csec = '';
1921: } elsif ($csec) {
1.401 bisitz 1922: $tmp.=&mt("Section")." <font color=\"red\"><i>$csec".
1923: "</i></font> ".&mt('of')." \n";
1.269 raeburn 1924: }
1.401 bisitz 1925: $r->print('<div align="center"><h4>'
1926: .&mt('Set Defaults for All Resources in [_1]Specifically for [_2][_3]'
1.404 bisitz 1927: ,$foldermap.'<br /><font color="red"><i>'.$showtitle.'</i></font><br />'
1.401 bisitz 1928: ,$tmp
1929: ,'<font color="red"><i>'.$coursename.'</i></font>'
1930: )
1931: ."<br /></h4>\n"
1932: );
1.57 albertel 1933: #---------------------------------------------------------------- print table
1934: $r->print('<p><table border="2">');
1.130 www 1935: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
1936: $r->print('<th>'.&mt('Default Value').'</th>');
1937: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 1938:
1.210 www 1939: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 1940: $r->print('<tr>');
1.201 www 1941: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 1942: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
1943: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 1944: }
1.401 bisitz 1945: $r->print("</table></div>");
1.57 albertel 1946: } # end each map
1947: } # end of $parmlev eq map
1948: #--------------------------------- Entry for parm level general (Course level)
1949: if ($parmlev eq 'general') {
1950: my $defbgone = '"E0E099"';
1951: my $defbgtwo = '"FFFF99"';
1.269 raeburn 1952: my $defbgthree = '"FFBB99"';
1.57 albertel 1953:
1954: #-------------------------------------------- for each map, gather information
1955: my $mapid="0.0";
1956: #----------------------- loop through ids and get all parameter types for map
1957: #----------------------------------------- and associated information
1958: my %name = ();
1959: my %part = ();
1960: my %display = ();
1961: my %type = ();
1962: my %default = ();
1963:
1964: foreach (@ids) {
1965: my $rid = $_;
1966:
1.196 www 1967: my $uri=&Apache::lonnet::declutter($uris{$rid});
1.57 albertel 1968:
1969: #--------------------------------------------------------------------
1970: # @catmarker contains list of all possible parameters including part #s
1971: # $fullkeyp contains the full part/id # for the extraction of proper parameters
1972: # $tempkeyp contains part 0 only (no ids - ie, subparts)
1973: # When storing information, store as part 0
1974: # When requesting information, request from full part
1975: #-------------------------------------------------------------------
1.210 www 1976: foreach (&keysplit($keyp{$rid})) {
1.57 albertel 1977: my $tempkeyp = $_;
1978: my $fullkeyp = $tempkeyp;
1.73 albertel 1979: $tempkeyp =~ s/_\w+_/_0_/;
1.57 albertel 1980: if ((grep $_ eq $fullkeyp, @catmarker) &&(!$name{$tempkeyp})) {
1981: $part{$tempkeyp}="0";
1982: $name{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.name');
1983: $display{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.display');
1984: unless ($display{$tempkeyp}) { $display{$tempkeyp}=''; }
1985: $display{$tempkeyp}.=' ('.$name{$tempkeyp}.')';
1.73 albertel 1986: $display{$tempkeyp} =~ s/_\w+_/_0_/;
1.57 albertel 1987: $default{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp);
1988: $type{$tempkeyp}=&Apache::lonnet::metadata($uri,$fullkeyp.'.type');
1989: }
1990: } # end loop through keys
1991: } # end loop through ids
1992:
1993: #---------------------------------------------------- print header information
1.133 www 1994: my $setdef=&mt("Set Defaults for All Resources in Course");
1.57 albertel 1995: $r->print(<<ENDMAPONE);
1.133 www 1996: <center><h4>$setdef
1.135 albertel 1997: <font color="red"><i>$coursename</i></font><br />
1.57 albertel 1998: ENDMAPONE
1999: if ($uname) {
1.267 albertel 2000: my $person=&Apache::loncommon::plainname($uname,$udom);
1.135 albertel 2001: $r->print(" ".&mt("User")."<font color=\"red\"> <i>$uname \($person\) </i></font> \n");
1.57 albertel 2002: } else {
1.135 albertel 2003: $r->print("<i><font color=\"red\"> ".&mt("ALL")."</i> ".&mt("USERS")."</font> \n");
1.57 albertel 2004: }
2005:
1.135 albertel 2006: if ($csec) {$r->print(&mt("Section")."<font color=\"red\"> <i>$csec</i></font>\n")};
1.306 albertel 2007: if ($cgroup) {$r->print(&mt("Group")."<font color=\"red\"> <i>$cgroup</i></font>\n")};
1.135 albertel 2008: $r->print("</h4>\n");
1.57 albertel 2009: #---------------------------------------------------------------- print table
2010: $r->print('<p><table border="2">');
1.130 www 2011: $r->print('<tr><th>'.&mt('Parameter Name').'</th>');
2012: $r->print('<th>'.&mt('Default Value').'</th>');
2013: $r->print('<th>'.&mt('Parameter in Effect').'</th></tr>');
1.57 albertel 2014:
1.210 www 2015: foreach (&keysinorder(\%name,\%keyorder)) {
1.168 matthew 2016: $r->print('<tr>');
1.201 www 2017: &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
1.269 raeburn 2018: \%type,\%display,$defbgone,$defbgtwo,$defbgthree,
2019: $parmlev,$uname,$udom,$csec,$cgroup);
1.57 albertel 2020: }
2021: $r->print("</table></center>");
2022: } # end of $parmlev eq general
1.43 albertel 2023: }
1.280 albertel 2024: $r->print('</form>'.&Apache::loncommon::end_page());
1.57 albertel 2025: } # end sub assessparms
1.30 www 2026:
1.59 matthew 2027:
2028: ##################################################
2029: ##################################################
2030:
2031: =pod
2032:
2033: =item crsenv
2034:
1.105 matthew 2035: Show and set course data and parameters. This is a large routine that should
1.59 matthew 2036: be simplified and shortened... someday.
2037:
2038: Inputs: $r
2039:
2040: Returns: nothing
2041:
2042: =cut
2043:
2044: ##################################################
2045: ##################################################
1.30 www 2046: sub crsenv {
2047: my $r=shift;
2048: my $setoutput='';
1.280 albertel 2049:
1.298 albertel 2050: my $breadcrumbs =
2051: &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment');
1.190 albertel 2052: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2053: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.105 matthew 2054:
1.392 raeburn 2055: my (%crsinfo,$chome);
2056:
1.105 matthew 2057: #
2058: # Go through list of changes
1.190 albertel 2059: foreach (keys %env) {
1.105 matthew 2060: next if ($_!~/^form\.(.+)\_setparmval$/);
2061: my $name = $1;
1.190 albertel 2062: my $value = $env{'form.'.$name.'_value'};
1.105 matthew 2063: if ($name eq 'newp') {
1.190 albertel 2064: $name = $env{'form.newp_name'};
1.105 matthew 2065: }
2066: if ($name eq 'url') {
2067: $value=~s/^\/res\///;
2068: my $bkuptime=time;
2069: my @tmp = &Apache::lonnet::get
2070: ('environment',['url'],$dom,$crs);
1.130 www 2071: $setoutput.=&mt('Backing up previous URL').': '.
1.105 matthew 2072: &Apache::lonnet::put
2073: ('environment',
2074: {'top level map backup '.$bkuptime => $tmp[1] },
2075: $dom,$crs).
1.336 albertel 2076: '<br />';
1.105 matthew 2077: }
2078: #
2079: # Deal with modified default spreadsheets
2080: if ($name =~ /^spreadsheet_default_(classcalc|
2081: studentcalc|
2082: assesscalc)$/x) {
2083: my $sheettype = $1;
2084: if ($sheettype eq 'classcalc') {
2085: # no need to do anything since viewing the sheet will
2086: # cause it to be updated.
2087: } elsif ($sheettype eq 'studentcalc') {
2088: # expire all the student spreadsheets
2089: &Apache::lonnet::expirespread('','','studentcalc');
2090: } else {
2091: # expire all the assessment spreadsheets
2092: # this includes non-default spreadsheets, but better to
2093: # be safe than sorry.
2094: &Apache::lonnet::expirespread('','','assesscalc');
2095: # expire all the student spreadsheets
2096: &Apache::lonnet::expirespread('','','studentcalc');
1.30 www 2097: }
1.105 matthew 2098: }
2099: #
1.107 matthew 2100: # Deal with the enrollment dates
2101: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2102: $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value');
2103: }
1.364 albertel 2104: #
2105: # Deal with the emails
2106: if ($name =~ /\.email$/) {
1.371 albertel 2107: foreach my $specifier (split(',',$value)) {
2108: my ($user,$sections_or_groups)=
2109: ($specifier=~/^([^\(]+)\(([^\)]+)\)/);
2110: if (!$sections_or_groups) {
2111: $user = $specifier;
2112: }
2113: my ($name,$domain) = split(':',$user);
2114: if (!defined($user) || !defined($domain)) {
2115: $setoutput.= '<br /> <span class="LC_error">'.
2116: &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user).
2117: '</span>';
2118: undef($value);
2119: } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') {
2120: $setoutput.= '<br /> <span class="LC_error">'.
2121: &mt("Invalid email address specified, user [_1] is unknown.",$name).
2122: '</span>';
2123: undef($value);
2124: }
1.364 albertel 2125: }
2126: }
1.178 raeburn 2127: # Get existing cloners
2128: my @oldcloner = ();
2129: if ($name eq 'cloners') {
2130: my %clonenames=&Apache::lonnet::dump('environment',$dom,$crs,'cloners');
2131: if ($clonenames{'cloners'} =~ /,/) {
2132: @oldcloner = split/,/,$clonenames{'cloners'};
2133: } else {
2134: $oldcloner[0] = $clonenames{'cloners'};
2135: }
2136: }
1.107 matthew 2137: #
1.105 matthew 2138: # Let the user know we made the changes
1.153 albertel 2139: if ($name && defined($value)) {
1.379 raeburn 2140: my %failed_cloners;
1.178 raeburn 2141: if ($name eq 'cloners') {
1.239 raeburn 2142: $value =~ s/\s//g;
1.178 raeburn 2143: $value =~ s/^,//;
2144: $value =~ s/,$//;
1.239 raeburn 2145: # check requested clones are valid users.
1.379 raeburn 2146: %failed_cloners = &check_cloners(\$value,\@oldcloner);
1.178 raeburn 2147: }
1.105 matthew 2148: my $put_result = &Apache::lonnet::put('environment',
2149: {$name=>$value},$dom,$crs);
2150: if ($put_result eq 'ok') {
1.392 raeburn 2151: $setoutput.=&mt('Set').' <b>'.$name.'</b> '.&mt('to').' <b>';
2152: if ($name =~ /^default_enrollment_(start|end)_date$/) {
2153: $setoutput .= &Apache::lonlocal::locallocaltime($value);
1.406 raeburn 2154: } elsif ($name eq 'categories') {
2155: $setoutput .= $env{'form.categories_display'};
1.392 raeburn 2156: } else {
2157: $setoutput .= $value;
2158: }
2159: $setoutput .= '</b>.<br />';
1.178 raeburn 2160: if ($name eq 'cloners') {
2161: &change_clone($value,\@oldcloner);
2162: }
1.382 raeburn 2163: # Update environment and nohist_courseids.db
1.402 raeburn 2164: if (($name eq 'description') || ($name eq 'cloners') ||
1.403 raeburn 2165: ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.392 raeburn 2166: if ($chome eq '') {
2167: %crsinfo =
2168: &Apache::lonnet::courseiddump($dom,'.',1,'.','.',
1.403 raeburn 2169: $crs,undef,undef,'.');
1.392 raeburn 2170: $chome = &Apache::lonnet::homeserver($crs,$dom);
2171: }
2172: }
1.179 raeburn 2173: if ($name eq 'description' && defined($value)) {
1.393 raeburn 2174: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $value});
1.382 raeburn 2175: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2176: $crsinfo{$env{'request.course.id'}}{'description'} = $value;
1.392 raeburn 2177: my $putresult =
2178: &Apache::lonnet::courseidput($dom,\%crsinfo,
2179: $chome,'notime');
2180: }
2181: }
1.403 raeburn 2182: if (($name eq 'cloners') || ($name eq 'hidefromcat') || ($name eq 'categories')) {
1.402 raeburn 2183: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
1.403 raeburn 2184: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$name => $value});
2185: $crsinfo{$env{'request.course.id'}}{$name} = $value;
1.402 raeburn 2186: my $putresult =
2187: &Apache::lonnet::courseidput($dom,\%crsinfo,
2188: $chome,'notime');
2189: }
2190: }
1.105 matthew 2191: } else {
1.130 www 2192: $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
2193: ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
1.30 www 2194: }
1.379 raeburn 2195: if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) {
2196: $setoutput.= &mt('Unable to include').': ';
2197: my @fails;
2198: my $num = 0;
2199: if (defined($failed_cloners{'format'})) {
2200: $fails[$num] .= '<b>'.$failed_cloners{'format'}.
2201: '</b>, '.&mt('reason').' - '.
2202: &mt('Invalid format');
2203: $num ++;
2204: }
2205: if (defined($failed_cloners{'domain'})) {
2206: $fails[$num] .= '<b>'.$failed_cloners{'domain'}.
2207: '</b>, '.&mt('reason').' - '.
2208: &mt('Domain does not exist');
2209: $num ++;
2210: }
2211: if (defined($failed_cloners{'newuser'})) {
2212: $fails[$num] .= '<b>'.$failed_cloners{'newuser'}. '</b>, '.&mt('reason').' - '.
2213: &mt('LON-CAPA user(s) do(es) not exist.').
2214: '.<br />'.&mt('Please ').
2215: ' <a href="/adm/createuser">'.
2216: &mt('add the user(s)').'</a>, '.
2217: &mt('and then return to the ').
2218: '<a href="/adm/parmset?action=crsenv">'.
2219: &mt('Course Parameters page').'</a> '.
2220: &mt('to add the new user(s) to the list of possible cloners');
2221: }
2222: $setoutput .= join('; ',@fails).'.<br />';
1.239 raeburn 2223: }
1.30 www 2224: }
1.38 harris41 2225: }
1.315 albertel 2226:
2227: my $start_table =&Apache::loncommon::start_data_table();
2228: my $start_header_row=&Apache::loncommon::start_data_table_header_row();
2229: my $end_header_row =&Apache::loncommon::end_data_table_header_row();
1.108 www 2230: # ------------------------- Re-init course environment entries for this session
2231:
1.302 albertel 2232: &Apache::lonnet::coursedescription($env{'request.course.id'},
1.296 albertel 2233: {'freshen_cache' => 1});
1.105 matthew 2234:
1.30 www 2235: # -------------------------------------------------------- Get parameters again
1.45 matthew 2236:
2237: my %values=&Apache::lonnet::dump('environment',$dom,$crs);
1.140 sakharuk 2238: my $SelectStyleFile=&mt('Select Style File');
1.141 sakharuk 2239: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
1.30 www 2240: my $output='';
1.403 raeburn 2241: my $can_categorize;
1.45 matthew 2242: if (! exists($values{'con_lost'})) {
1.30 www 2243: my %descriptions=
1.395 bisitz 2244: ('url' => '<b>'.&mt('Top Level Map').'</b><br />'.
1.46 matthew 2245: '<a href="javascript:openbrowser'.
1.47 matthew 2246: "('envform','url','sequence')\">".
1.314 albertel 2247: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
1.395 bisitz 2248: &mt('Modification may make assessment data inaccessible!').
1.314 albertel 2249: '</span>',
1.140 sakharuk 2250: 'description' => '<b>'.&mt('Course Description').'</b>',
1.158 sakharuk 2251: 'courseid' => '<b>'.&mt('Course ID or number').
1.140 sakharuk 2252: '</b><br />'.
1.395 bisitz 2253: '('.&mt('internal, optional').')',
2254: 'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br />'
2255: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")<br />'
2256: .&mt('Users with active Course Coordinator role in this course are permitted to clone and need not be included.').'<br />'
2257: .&mt('Use [_1] to allow course to be cloned by anyone in the specified domain.','"<tt>*:domain</tt>"').'<br />'
2258: .&mt('Use [_1] to allow unrestricted cloning in all domains.','"<tt>*</tt>"'),
1.150 www 2259: 'grading' => '<b>'.&mt('Grading').'</b><br />'.
1.395 bisitz 2260: &mt('[_1], [_2], or [_3]','"<tt>standard</tt>"','"<tt>external</tt>"','"<tt>spreadsheet</tt>"').&Apache::loncommon::help_open_topic('GradingOptions'),
2261: 'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'
2262: .&mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections.').'<br />'
2263: .'('.&mt('[_1]: they are allowed (this is the default). [_2]: no, they can only grade their own section.','"<tt>any</tt>"','"<tt>section</tt>"').')',
2264: 'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b><br />'.
1.52 www 2265: '<a href="javascript:openbrowser'.
2266: "('envform','default_xml_style'".
1.336 albertel 2267: ",'sty')\">$SelectStyleFile</a><br />",
1.395 bisitz 2268: 'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question').'</b><br />'
2269: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2270: 'question.email.text' => '<b>'.&mt('Custom Text for Resource Content Question Option in Feedback').'</b>',
2271: 'comment.email' => '<b>'.&mt('Feedback Addresses for Course Content Comments').'</b><br />'
2272: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2273: 'comment.email.text' => '<b>'.&mt('Custom Text for Course Content Option in Feedback').'</b>',
2274: 'policy.email' => '<b>'.&mt('Feedback Addresses for Course Policy').'</b><br />'
2275: .'("<tt>'.&mt('user:domain,user:domain(section;section;...;*;...),...').'</tt>")',
2276: 'policy.email.text' => '<b>'.&mt('Custom Text for Course Policy Option in Feedback').'</b>',
2277: 'hideemptyrows' => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b><br />'
2278: .'('.&mt('[_1] for default hiding','"<tt>yes</tt>"').')',
2279: 'pageseparators' => '<b>'.&mt('Visibly Separate Items on Pages').'</b><br />'
2280: .'('.&mt('[_1] for visible separation.','"<tt>yes</tt>"').' '
2281: .&mt('Changes will not show until next login.').')',
2282: 'student_classlist_view' => '<b>'.&mt('Allow students to view classlist.').'</b><br />'
2283: .'('.&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>"').')',
2284: 'student_classlist_portfiles' => '<b>'.&mt('Include link to accessible portfolio files').'</b><br />'
2285: .'('.&mt('[_1] for link to each a listing of each student\'s files.','"<tt>yes</tt>"').')',
2286: 'student_classlist_opt_in' => '<b>'.&mt("Student's agreement needed for listing in student-viewable roster").'</b><br />'
2287: .'('.&mt('[_1] to require students to opt-in to listing in the roster (on the roster page).','"<tt>yes</tt>"').')',
2288: 'plc.roles.denied'=> '<b>'.&mt('Disallow live chatroom use for Roles').'</b><br />'
2289: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2290: .'("<tt>'.&mt('role,role,...').'</tt>") '
2291: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.118 matthew 2292: 'plc.users.denied' =>
1.141 sakharuk 2293: '<b>'.&mt('Disallow live chatroom use for Users').'</b><br />'.
1.395 bisitz 2294: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.118 matthew 2295:
1.395 bisitz 2296: 'pch.roles.denied'=> '<b>'.&mt('Disallow Resource Discussion for Roles').'</b><br />'
2297: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"')
2298: .'("<tt>'.&mt('role,role,...').'</tt>") '
2299: .Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
1.53 www 2300: 'pch.users.denied' =>
1.141 sakharuk 2301: '<b>'.&mt('Disallow Resource Discussion for Users').'</b><br />'.
1.395 bisitz 2302: '("<tt>'.&mt('user:domain,user:domain,...').'</tt>")',
1.49 matthew 2303: 'spreadsheet_default_classcalc'
1.141 sakharuk 2304: => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
1.50 matthew 2305: '<a href="javascript:openbrowser'.
2306: "('envform','spreadsheet_default_classcalc'".
1.141 sakharuk 2307: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2308: 'spreadsheet_default_studentcalc'
1.395 bisitz 2309: => '<b>'.&mt('Default Student Spreadsheet').'</b><br />'.
1.50 matthew 2310: '<a href="javascript:openbrowser'.
2311: "('envform','spreadsheet_default_calc'".
1.141 sakharuk 2312: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.49 matthew 2313: 'spreadsheet_default_assesscalc'
1.141 sakharuk 2314: => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
1.50 matthew 2315: '<a href="javascript:openbrowser'.
2316: "('envform','spreadsheet_default_assesscalc'".
1.141 sakharuk 2317: ",'spreadsheet')\">$SelectSpreadsheetFile</a><br />",
1.75 albertel 2318: 'allow_limited_html_in_feedback'
1.141 sakharuk 2319: => '<b>'.&mt('Allow limited HTML in discussion posts').'</b><br />'.
1.395 bisitz 2320: '('.&mt('Set value to [_1] to allow.','"<tt>yes</tt>"').')',
1.170 raeburn 2321: 'allow_discussion_post_editing'
1.395 bisitz 2322: => '<b>'.&mt('Allow users with specified roles to edit/delete their own discussion posts').'</b><br />'
2323: .'('.&mt('[_1]: student, [_2]: TA, [_3]: instructor','"<tt>st</tt>"','"<tt>ta</tt>"','"<tt>in</tt>"').')<br />'
2324: .'('.&mt('Set value to [_1] to allow all roles.','"<tt>yes</tt>"').')'
2325: .'("<tt>'.&mt('role:section,role:section,...').'</tt>")<br />'
2326: .'('.&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 2327: 'rndseed'
1.395 bisitz 2328: => '<b>'.&mt('Randomization algorithm used').'</b><br />'
2329: .'<span class="LC_error">'
2330: .&mt('Modifying this will make problems have different numbers and answers!')
2331: .'</span>',
1.151 albertel 2332: 'receiptalg'
2333: => '<b>'.&mt('Receipt algorithm used').'</b> <br />'.
2334: &mt('This controls how receipt numbers are generated.'),
1.164 sakharuk 2335: 'suppress_tries'
1.272 albertel 2336: => '<b>'.&mt('Suppress number of tries in printing').'</b><br />'.
1.395 bisitz 2337: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.113 sakharuk 2338: 'problem_stream_switch'
1.141 sakharuk 2339: => '<b>'.&mt('Allow problems to be split over pages').'</b><br />'.
1.395 bisitz 2340: ' ('.&mt('[_1] if allowed, anything else if not','"<tt>yes</tt>"').')',
1.161 sakharuk 2341: 'default_paper_size'
2342: => '<b>'.&mt('Default paper type').'</b><br />'.
2343: ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'.
2344: ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'.
2345: ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
1.319 foxr 2346: 'print_header_format'
1.395 bisitz 2347: => ' <b>'.&mt('Print header format').'</b><br />'
2348: .&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 2349: 'default_enrollment_start_date' => '<b>'.&mt('Default beginning date for student access.').'</b>',
2350: 'default_enrollment_end_date' => '<b>'.&mt('Default ending date for student access.').'</b>',
1.395 bisitz 2351: 'nothideprivileged' => '<b>'.&mt('Privileged users that should not be hidden on staff listings').'</b><br />'
2352: .'("<tt>'.&mt('user:domain,user:domain,*:domain').'</tt>")',
1.140 sakharuk 2353: 'languages' => '<b>'.&mt('Languages used').'</b>',
1.115 www 2354: 'disable_receipt_display'
1.141 sakharuk 2355: => '<b>'.&mt('Disable display of problem receipts').'</b><br />'.
1.158 sakharuk 2356: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.313 albertel 2357: 'task_messages'
1.395 bisitz 2358: => '<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 2359: 'disablesigfigs'
2360: => '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'.
2361: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.251 albertel 2362: 'disableexampointprint'
2363: => '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'.
2364: ' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')',
1.278 www 2365: 'externalsyllabus'
1.279 www 2366: => '<b>'.&mt('URL of Syllabus (not using internal handler)').'</b>',
1.149 albertel 2367: 'tthoptions'
1.367 albertel 2368: => '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>',
2369:
2370: 'texengine'
1.395 bisitz 2371: => '<b>'.&mt('Force all students in the course to use a specific math rendering engine.').'</b><br />'
1.396 bisitz 2372: .'('.&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 2373: 'timezone'
1.400 raeburn 2374: => '<b>'.&mt('Timezone in which the course takes place').'</b>',
1.392 raeburn 2375:
1.400 raeburn 2376: 'suppress_embed_prompt'
2377: => '<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 2378: ' ('.&mt('[_1] to suppress, anything else to not suppress','"<tt>yes</tt>"').')',
1.403 raeburn 2379: 'hidefromcat'
1.402 raeburn 2380: => '<b>'.&mt('Exclude from course catalog').'</b><br />'.
2381: ' ('.&mt('[_1] to exclude, anything else to include - included if assigned an institutional code, or manually catagorized','"<tt>yes</tt>"').')',
1.403 raeburn 2382: 'categories'
2383: => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.
2384: &mt('Display Categories').'</a>',
1.409 raeburn 2385: 'datelocale'
2386: => '<b>'.&mt('Locale used for course calendar').'</b>',
1.402 raeburn 2387: );
2388: my @Display_Order = ('url','description','courseid','cloners');
1.403 raeburn 2389: (my $can_toggle_cat,$can_categorize) = &can_modify_catsettings($dom);
2390: if ($can_toggle_cat) {
1.402 raeburn 2391: push(@Display_Order,'hidefromcat');
2392: }
1.403 raeburn 2393: if ($can_categorize) {
2394: push(@Display_Order,'categories');
2395: }
1.402 raeburn 2396: push (@Display_Order,('grading',
1.278 www 2397: 'externalsyllabus',
1.107 matthew 2398: 'default_xml_style','pageseparators',
1.402 raeburn 2399: 'question.email','question.email.text','comment.email',
2400: 'comment.email.text','policy.email','policy.email.text',
1.169 matthew 2401: 'student_classlist_view',
1.372 raeburn 2402: 'student_classlist_opt_in',
2403: 'student_classlist_portfiles',
1.118 matthew 2404: 'plc.roles.denied','plc.users.denied',
1.107 matthew 2405: 'pch.roles.denied','pch.users.denied',
2406: 'allow_limited_html_in_feedback',
1.170 raeburn 2407: 'allow_discussion_post_editing',
1.108 www 2408: 'languages',
1.397 www 2409: 'timezone',
1.409 raeburn 2410: 'datelocale',
1.150 www 2411: 'nothideprivileged',
1.107 matthew 2412: 'rndseed',
1.151 albertel 2413: 'receiptalg',
1.107 matthew 2414: 'problem_stream_switch',
1.164 sakharuk 2415: 'suppress_tries',
1.400 raeburn 2416: 'suppress_embed_prompt',
1.161 sakharuk 2417: 'default_paper_size',
1.319 foxr 2418: 'print_header_format',
1.115 www 2419: 'disable_receipt_display',
1.107 matthew 2420: 'spreadsheet_default_classcalc',
2421: 'spreadsheet_default_studentcalc',
2422: 'spreadsheet_default_assesscalc',
2423: 'hideemptyrows',
2424: 'default_enrollment_start_date',
2425: 'default_enrollment_end_date',
1.163 albertel 2426: 'tthoptions',
1.367 albertel 2427: 'texengine',
1.251 albertel 2428: 'disablesigfigs',
1.313 albertel 2429: 'disableexampointprint',
1.402 raeburn 2430: 'task_messages','task_grading'));
1.107 matthew 2431: foreach my $parameter (sort(keys(%values))) {
1.405 raeburn 2432: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
2433: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
2434: || ($parameter eq 'type')) {
1.142 raeburn 2435: if (! $descriptions{$parameter}) {
2436: $descriptions{$parameter}=$parameter;
2437: push(@Display_Order,$parameter);
2438: }
2439: }
1.43 albertel 2440: }
1.315 albertel 2441:
1.107 matthew 2442: foreach my $parameter (@Display_Order) {
2443: my $description = $descriptions{$parameter};
1.51 matthew 2444: # onchange is javascript to automatically check the 'Set' button.
1.69 www 2445: my $onchange = 'onFocus="javascript:window.document.forms'.
1.107 matthew 2446: "['envform'].elements['".$parameter."_setparmval']".
1.51 matthew 2447: '.checked=true;"';
1.315 albertel 2448: $output .= &Apache::loncommon::start_data_table_row().
2449: '<td>'.$description.'</td>';
1.107 matthew 2450: if ($parameter =~ /^default_enrollment_(start|end)_date$/) {
2451: $output .= '<td>'.
2452: &Apache::lonhtmlcommon::date_setter('envform',
2453: $parameter.'_value',
2454: $values{$parameter},
2455: $onchange).
2456: '</td>';
1.398 www 2457: } elsif ($parameter eq 'timezone') {
1.399 raeburn 2458: my $includeempty = 1;
2459: my $timezone = &Apache::lonlocal::gettimezone();
1.398 www 2460: $output .= '<td>'.
2461: &Apache::loncommon::select_timezone($parameter.'_value',
1.399 raeburn 2462: $timezone,
2463: $onchange,$includeempty).'</td>';
1.409 raeburn 2464: } elsif ($parameter eq 'datelocale') {
2465: my $includeempty = 1;
2466: my $locale_obj = &Apache::lonlocal::getdatelocale();
2467: my $currdatelocale;
2468: if (ref($locale_obj)) {
2469: $currdatelocale = $locale_obj->id();
2470: }
2471: $output .= '<td>'.
2472: &Apache::loncommon::select_datelocale($parameter.'_value',
2473: $currdatelocale,
2474: $onchange,$includeempty).'</td>';
1.406 raeburn 2475: } elsif ($parameter eq 'categories') {
2476: my $catdisplay;
2477: if ($values{'categories'} ne '') {
2478: my @curritems = split(/\&/,$values{'categories'});
2479: foreach my $item (@curritems) {
2480: my ($name,$parent,$pos) = split(/:/,$item);
2481: $catdisplay .= &unescape($name).'&';
2482: }
2483: $catdisplay =~ s/\&$//;
2484: }
2485: $output .= '<td>'.
2486: '<input type="hidden" name="categories_value" value="'.
2487: $values{'categories'}.'" />'.
2488: '<input type="textbox" name="categories_display" value="'.
2489: $catdisplay.'" readonly="readonly" size="40" /></td>';
1.107 matthew 2490: } else {
2491: $output .= '<td>'.
2492: &Apache::lonhtmlcommon::textbox($parameter.'_value',
2493: $values{$parameter},
2494: 40,$onchange).'</td>';
2495: }
2496: $output .= '<td>'.
2497: &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval').
2498: '</td>';
1.315 albertel 2499: $output .= &Apache::loncommon::end_data_table_row()."\n";
1.51 matthew 2500: }
1.69 www 2501: my $onchange = 'onFocus="javascript:window.document.forms'.
1.51 matthew 2502: '[\'envform\'].elements[\'newp_setparmval\']'.
2503: '.checked=true;"';
1.315 albertel 2504: $output.=&Apache::loncommon::start_data_table_row().
2505: '<td><i>'.&mt('Create New Environment Variable').'</i><br />'.
1.51 matthew 2506: '<input type="text" size=40 name="newp_name" '.
2507: $onchange.' /></td><td>'.
2508: '<input type="text" size=40 name="newp_value" '.
2509: $onchange.' /></td><td>'.
1.315 albertel 2510: '<input type="checkbox" name="newp_setparmval" /></td>'.
2511: &Apache::loncommon::end_data_table_row()."\n";
1.43 albertel 2512: }
1.157 sakharuk 2513: my %lt=&Apache::lonlocal::texthash(
2514: 'par' => 'Parameter',
2515: 'val' => 'Value',
1.395 bisitz 2516: 'set' => 'Set?',
2517: 'sav' => 'Save'
1.157 sakharuk 2518: );
2519:
1.140 sakharuk 2520: my $Parameter=&mt('Parameter');
2521: my $Value=&mt('Value');
1.141 sakharuk 2522: my $Set=&mt('Set');
1.403 raeburn 2523: my ($jscript,$categorize_js);
2524: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
2525: if ($can_categorize) {
2526: $categorize_js = <<ENDSCRIPT;
2527: function catsbrowser() {
2528: var catswin = null;
2529: var url = '/adm/parmset?action=categorizecourse';
2530: if (!catswin || catswin.closed) {
2531: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2532: } else {
2533: catswin.focus();
2534: }
2535: }
2536: ENDSCRIPT
2537: }
2538: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
2539: $browse_js."\n".$categorize_js."\n".'</script>';
1.280 albertel 2540: my $start_page =
1.323 albertel 2541: &Apache::loncommon::start_page('Set Course Environment',
1.403 raeburn 2542: $jscript);
1.280 albertel 2543: my $end_page =
2544: &Apache::loncommon::end_page();
1.315 albertel 2545: my $end_table=&Apache::loncommon::end_data_table();
1.280 albertel 2546: $r->print(<<ENDENV);
2547: $start_page
1.193 albertel 2548: $breadcrumbs
2549: <form method="post" action="/adm/parmset?action=crsenv" name="envform">
1.30 www 2550: $setoutput
1.395 bisitz 2551: <div><input type="submit" name="crsenv" value="$lt{'sav'}" /></div>
1.315 albertel 2552: $start_table
2553: $start_header_row
1.395 bisitz 2554: <th>$lt{'par'}</th><th>$lt{'val'}</th><th>$lt{'set'}</th>
1.315 albertel 2555: $end_header_row
1.30 www 2556: $output
1.315 albertel 2557: $end_table
1.395 bisitz 2558: <input type="submit" name="crsenv" value="$lt{'sav'}" />
1.30 www 2559: </form>
1.280 albertel 2560: $end_page
2561: ENDENV
1.30 www 2562: }
1.402 raeburn 2563:
1.403 raeburn 2564: sub can_modify_catsettings {
1.402 raeburn 2565: my ($dom) = @_;
2566: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.403 raeburn 2567: my ($can_toggle_cat,$can_categorize);
1.402 raeburn 2568: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2569: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
2570: $can_toggle_cat = 1;
2571: }
1.403 raeburn 2572: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
2573: $can_categorize = 1;
2574: }
2575: }
2576: return ($can_toggle_cat,$can_categorize);
2577: }
2578:
2579: sub assign_course_categories {
2580: my ($r) = @_;
2581: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2582: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2583: my $hascats = 0;
2584: my $cathash;
2585: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
2586: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2587: $cathash = $domconf{'coursecategories'}{'cats'};
2588: if (ref($cathash) eq 'HASH') {
2589: $hascats = 1;
2590: }
1.402 raeburn 2591: }
1.403 raeburn 2592: my $catwin_js;
2593: if ($hascats) {
2594: my $alert = &mt('Use \"Save\" in the main window to save course categories');
2595: $catwin_js = <<ENDSCRIPT;
2596: <script type="text/javascript">
2597:
2598: function updateCategories() {
2599: var newcategories = '';
1.406 raeburn 2600: var unescapedcats = '';
1.403 raeburn 2601: if (document.chgcats.usecategory.length) {
2602: for (var i=0; i<document.chgcats.usecategory.length; i++) {
2603: if (document.chgcats.usecategory[i].checked == true) {
2604: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
1.406 raeburn 2605: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
1.403 raeburn 2606: }
2607: }
2608: if (newcategories.length > 0) {
2609: newcategories = newcategories.slice(0,-1);
2610: }
1.406 raeburn 2611: if (unescapedcats.length > 0) {
1.408 raeburn 2612: unescapedcats = unescapedcats.slice(0,-3);
1.406 raeburn 2613: }
1.403 raeburn 2614: } else {
2615: if (document.chgcats.usecategory.checked == true) {
2616: newcategories = document.chgcats.usecategory.value;
1.406 raeburn 2617: unescapedcats = document.chgcats.catname.value;
1.403 raeburn 2618: }
2619: }
2620: opener.document.envform.categories_value.value = newcategories;
1.406 raeburn 2621: opener.document.envform.categories_display.value = unescapedcats;
1.403 raeburn 2622: opener.document.envform.categories_setparmval.checked = true;
2623: alert("$alert");
2624: self.close();
2625: return;
2626: }
2627:
2628: </script>
2629: ENDSCRIPT
2630: } else {
2631: my $onload;
2632: }
2633: my $start_page =
2634: &Apache::loncommon::start_page('Course Categories',$catwin_js,
2635: {'only_body' => 1,});
2636: my $end_page = &Apache::loncommon::end_page();
2637: my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';
2638: if ($hascats) {
2639: my %currsettings =
2640: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
2641: $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.
2642: '<form name="chgcats" action="/adm/parmset" method="post">'."\n"
2643: .&Apache::loncommon::assign_categories_table($cathash,
2644: $currsettings{'categories'})."\n"
2645: .'<br /><input type="button" name="changes" value="'
2646: .&mt('Copy to main window').'" '
2647: .'onclick="javascript:updateCategories()" /></form><br />';
2648: } else {
2649: $categoriesform .= &mt('No categories defined for this domain');
2650: }
2651: $r->print($start_page.$categoriesform.$end_page);
2652: return;
1.402 raeburn 2653: }
2654:
1.120 www 2655: ##################################################
1.207 www 2656: # Overview mode
2657: ##################################################
1.124 www 2658: my $tableopen;
2659:
2660: sub tablestart {
2661: if ($tableopen) {
2662: return '';
2663: } else {
2664: $tableopen=1;
1.295 albertel 2665: return &Apache::loncommon::start_data_table().'<tr><th>'.&mt('Parameter').'</th><th>'.
1.130 www 2666: &mt('Delete').'</th><th>'.&mt('Set to ...').'</th></tr>';
1.124 www 2667: }
2668: }
2669:
2670: sub tableend {
2671: if ($tableopen) {
2672: $tableopen=0;
1.295 albertel 2673: return &Apache::loncommon::end_data_table();
1.124 www 2674: } else {
2675: return'';
2676: }
2677: }
2678:
1.207 www 2679: sub readdata {
2680: my ($crs,$dom)=@_;
2681: # Read coursedata
2682: my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
2683: # Read userdata
2684:
2685: my $classlist=&Apache::loncoursedata::get_classlist();
2686: foreach (keys %$classlist) {
1.350 albertel 2687: if ($_=~/^($match_username)\:($match_domain)$/) {
1.207 www 2688: my ($tuname,$tudom)=($1,$2);
2689: my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
2690: foreach my $userkey (keys %{$useropt}) {
2691: if ($userkey=~/^$env{'request.course.id'}/) {
2692: my $newkey=$userkey;
2693: $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
2694: $$resourcedata{$newkey}=$$useropt{$userkey};
2695: }
2696: }
2697: }
2698: }
2699: return $resourcedata;
2700: }
2701:
2702:
1.124 www 2703: # Setting
1.208 www 2704:
2705: sub storedata {
2706: my ($r,$crs,$dom)=@_;
1.207 www 2707: # Set userlevel immediately
2708: # Do an intermediate store of course level
2709: my $olddata=&readdata($crs,$dom);
1.124 www 2710: my %newdata=();
2711: undef %newdata;
2712: my @deldata=();
2713: undef @deldata;
1.190 albertel 2714: foreach (keys %env) {
1.124 www 2715: if ($_=~/^form\.([a-z]+)\_(.+)$/) {
2716: my $cmd=$1;
2717: my $thiskey=$2;
1.207 www 2718: my ($tuname,$tudom)=&extractuser($thiskey);
2719: my $tkey=$thiskey;
2720: if ($tuname) {
2721: $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
2722: }
1.385 albertel 2723: if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
1.384 albertel 2724: my ($data, $typeof, $text);
2725: if ($cmd eq 'set') {
2726: $data=$env{$_};
2727: $typeof=$env{'form.typeof_'.$thiskey};
2728: $text = &mt('Saved modified parameter for');
2729: } elsif ($cmd eq 'datepointer') {
2730: $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
2731: $typeof=$env{'form.typeof_'.$thiskey};
2732: $text = &mt('Saved modified date for');
1.385 albertel 2733: } elsif ($cmd eq 'dateinterval') {
2734: $data=&get_date_interval_from_form($thiskey);
2735: $typeof=$env{'form.typeof_'.$thiskey};
2736: $text = &mt('Saved modified date for');
1.384 albertel 2737: }
2738: if (defined($data) and $$olddata{$thiskey} ne $data) {
1.207 www 2739: if ($tuname) {
1.212 www 2740: if (&Apache::lonnet::put('resourcedata',{$tkey=>$data,
2741: $tkey.'.type' => $typeof},
2742: $tudom,$tuname) eq 'ok') {
1.290 www 2743: &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom);
1.384 albertel 2744: $r->print('<br />'.$text.' '.
1.207 www 2745: &Apache::loncommon::plainname($tuname,$tudom));
2746: } else {
1.314 albertel 2747: $r->print('<div class="LC_error">'.
1.365 albertel 2748: &mt('Error saving parameters').'</div>');
1.207 www 2749: }
2750: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2751: } else {
2752: $newdata{$thiskey}=$data;
1.212 www 2753: $newdata{$thiskey.'.type'}=$typeof;
2754: }
1.207 www 2755: }
1.124 www 2756: } elsif ($cmd eq 'del') {
1.207 www 2757: if ($tuname) {
2758: if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
1.290 www 2759: &log_parmset({$tkey=>''},1,$tuname,$tudom);
1.207 www 2760: $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
2761: } else {
1.314 albertel 2762: $r->print('<div class="LC_error">'.
2763: &mt('Error deleting parameters').'</div>');
1.207 www 2764: }
2765: &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
2766: } else {
1.333 albertel 2767: push (@deldata,$thiskey,$thiskey.'.type');
1.207 www 2768: }
1.124 www 2769: }
2770: }
2771: }
1.207 www 2772: # Store all course level
1.144 www 2773: my $delentries=$#deldata+1;
2774: my @newdatakeys=keys %newdata;
2775: my $putentries=$#newdatakeys+1;
2776: if ($delentries) {
2777: if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
1.290 www 2778: my %loghash=map { $_ => '' } @deldata;
2779: &log_parmset(\%loghash,1);
1.144 www 2780: $r->print('<h2>'.&mt('Deleted [_1] parameter(s)</h2>',$delentries));
2781: } else {
1.314 albertel 2782: $r->print('<div class="LC_error">'.
2783: &mt('Error deleting parameters').'</div>');
1.144 www 2784: }
1.205 www 2785: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2786: }
2787: if ($putentries) {
2788: if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
1.290 www 2789: &log_parmset(\%newdata,0);
1.365 albertel 2790: $r->print('<h3>'.&mt('Saved [_1] parameter(s)',$putentries/2).'</h3>');
1.144 www 2791: } else {
1.314 albertel 2792: $r->print('<div class="LC_error">'.
1.365 albertel 2793: &mt('Error saving parameters').'</div>');
1.144 www 2794: }
1.205 www 2795: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
1.144 www 2796: }
1.208 www 2797: }
1.207 www 2798:
1.208 www 2799: sub extractuser {
2800: my $key=shift;
1.350 albertel 2801: return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./);
1.208 www 2802: }
1.206 www 2803:
1.381 albertel 2804: sub parse_listdata_key {
2805: my ($key,$listdata) = @_;
2806: # split into student/section affected, and
2807: # the realm (folder/resource part and parameter
2808: my ($student,$realm) =
2809: ($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/);
2810: # if course wide student would be undefined
2811: if (!defined($student)) {
2812: ($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/);
2813: }
2814: # strip off the .type if it's not the Question type parameter
2815: if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) {
2816: $realm=~s/\.type//;
2817: }
2818: # split into resource+part and parameter name
1.388 albertel 2819: my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/);
2820: ($res, my $part) = ($res =~/^(.*)\.(.*)$/);
1.381 albertel 2821: return ($student,$res,$part,$parm);
2822: }
2823:
1.208 www 2824: sub listdata {
1.214 www 2825: my ($r,$resourcedata,$listdata,$sortorder)=@_;
1.207 www 2826: # Start list output
1.206 www 2827:
1.122 www 2828: my $oldsection='';
2829: my $oldrealm='';
2830: my $oldpart='';
1.123 www 2831: my $pointer=0;
1.124 www 2832: $tableopen=0;
1.145 www 2833: my $foundkeys=0;
1.248 albertel 2834: my %keyorder=&standardkeyorder();
1.381 albertel 2835:
1.214 www 2836: foreach my $thiskey (sort {
1.381 albertel 2837: my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata);
2838: my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata);
2839:
2840: # get the numerical order for the param
2841: $aparm=$keyorder{'parameter_0_'.$aparm};
2842: $bparm=$keyorder{'parameter_0_'.$bparm};
2843:
2844: my $result=0;
2845:
1.214 www 2846: if ($sortorder eq 'realmstudent') {
1.381 albertel 2847: if ($ares ne $bres ) {
2848: $result = ($ares cmp $bres);
2849: } elsif ($astudent ne $bstudent) {
2850: $result = ($astudent cmp $bstudent);
2851: } elsif ($apart ne $bpart ) {
2852: $result = ($apart cmp $bpart);
1.237 albertel 2853: }
1.381 albertel 2854: } else {
2855: if ($astudent ne $bstudent) {
2856: $result = ($astudent cmp $bstudent);
2857: } elsif ($ares ne $bres ) {
2858: $result = ($ares cmp $bres);
2859: } elsif ($apart ne $bpart ) {
2860: $result = ($apart cmp $bpart);
1.247 albertel 2861: }
1.381 albertel 2862: }
2863:
2864: if (!$result) {
2865: if (defined($aparm) && defined($bparm)) {
2866: $result = ($aparm <=> $bparm);
2867: } elsif (defined($aparm)) {
2868: $result = -1;
2869: } elsif (defined($bparm)) {
2870: $result = 1;
1.248 albertel 2871: }
1.214 www 2872: }
1.381 albertel 2873:
2874: $result;
1.214 www 2875: } keys %{$listdata}) {
1.381 albertel 2876:
1.211 www 2877: if ($$listdata{$thiskey.'.type'}) {
2878: my $thistype=$$listdata{$thiskey.'.type'};
2879: if ($$resourcedata{$thiskey.'.type'}) {
2880: $thistype=$$resourcedata{$thiskey.'.type'};
2881: }
1.207 www 2882: my ($middle,$part,$name)=
2883: ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.130 www 2884: my $section=&mt('All Students');
1.207 www 2885: if ($middle=~/^\[(.*)\]/) {
1.206 www 2886: my $issection=$1;
1.350 albertel 2887: if ($issection=~/^useropt\:($match_username)\:($match_domain)/) {
1.206 www 2888: $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
2889: } else {
2890: $section=&mt('Group/Section').': '.$issection;
2891: }
1.207 www 2892: $middle=~s/^\[(.*)\]//;
1.122 www 2893: }
1.207 www 2894: $middle=~s/\.+$//;
2895: $middle=~s/^\.+//;
1.316 albertel 2896: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.122 www 2897: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 2898: $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 2899: } elsif ($middle) {
1.174 albertel 2900: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 2901: $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 2902: }
1.214 www 2903: if ($sortorder eq 'realmstudent') {
2904: if ($realm ne $oldrealm) {
2905: $r->print(&tableend()."\n<hr /><h1>$realm</h1>");
2906: $oldrealm=$realm;
2907: $oldsection='';
2908: }
2909: if ($section ne $oldsection) {
2910: $r->print(&tableend()."\n<h2>$section</h2>");
2911: $oldsection=$section;
2912: $oldpart='';
2913: }
2914: } else {
2915: if ($section ne $oldsection) {
2916: $r->print(&tableend()."\n<hr /><h1>$section</h1>");
2917: $oldsection=$section;
2918: $oldrealm='';
2919: }
2920: if ($realm ne $oldrealm) {
2921: $r->print(&tableend()."\n<h2>$realm</h2>");
2922: $oldrealm=$realm;
2923: $oldpart='';
2924: }
1.122 www 2925: }
2926: if ($part ne $oldpart) {
1.124 www 2927: $r->print(&tableend().
1.316 albertel 2928: "\n<span class=\"LC_parm_part\">".&mt('Part').": $part</span>");
1.122 www 2929: $oldpart=$part;
2930: }
1.123 www 2931: #
2932: # Ready to print
2933: #
1.295 albertel 2934: $r->print(&tablestart().
2935: &Apache::loncommon::start_data_table_row().
2936: '<td><b>'.&standard_parameter_names($name).
1.293 www 2937: '</b></td><td><input type="checkbox" name="del_'.
1.124 www 2938: $thiskey.'" /></td><td>');
1.145 www 2939: $foundkeys++;
1.213 www 2940: if (&isdateparm($thistype)) {
1.123 www 2941: my $jskey='key_'.$pointer;
2942: $pointer++;
2943: $r->print(
1.232 albertel 2944: &Apache::lonhtmlcommon::date_setter('parmform',
1.123 www 2945: $jskey,
1.219 www 2946: $$resourcedata{$thiskey},
1.325 www 2947: '',1,'','').
1.277 www 2948: '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'.
1.390 www 2949: (($$resourcedata{$thiskey}!=0)?'<a href="/adm/parmset?&action=dateshift1&timebase='.$$resourcedata{$thiskey}.'">'.
2950: &mt('Shift all dates based on this date').'</a>':'').
1.277 www 2951: &date_sanity_info($$resourcedata{$thiskey})
1.123 www 2952: );
1.385 albertel 2953: } elsif ($thistype eq 'date_interval') {
2954: $r->print(&date_interval_selector($thiskey,
2955: $$resourcedata{$thiskey}));
1.383 albertel 2956: } elsif ($thistype =~ m/^string/) {
2957: $r->print(&string_selector($thistype,$thiskey,
2958: $$resourcedata{$thiskey}));
1.123 www 2959: } else {
1.383 albertel 2960: $r->print(&default_selector($thiskey,$$resourcedata{$thiskey}));
1.123 www 2961: }
1.211 www 2962: $r->print('<input type="hidden" name="typeof_'.$thiskey.'" value="'.
2963: $thistype.'">');
1.295 albertel 2964: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.122 www 2965: }
1.121 www 2966: }
1.208 www 2967: return $foundkeys;
2968: }
2969:
1.385 albertel 2970:
2971: sub date_interval_selector {
2972: my ($thiskey, $showval) = @_;
2973: my $result;
2974: foreach my $which (['days', 86400, 31],
2975: ['hours', 3600, 23],
2976: ['minutes', 60, 59],
2977: ['seconds', 1, 59]) {
2978: my ($name, $factor, $max) = @{ $which };
2979: my $amount = int($showval/$factor);
2980: $showval %= $factor;
2981: my %select = ((map {$_ => $_} (0..$max)),
2982: 'select_form_order' => [0..$max]);
2983: $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
2984: %select);
2985: $result .= ' '.&mt($name);
2986: }
2987: $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
2988: return $result;
2989:
2990: }
2991:
2992: sub get_date_interval_from_form {
2993: my ($key) = @_;
2994: my $seconds = 0;
2995: foreach my $which (['days', 86400],
2996: ['hours', 3600],
2997: ['minutes', 60],
2998: ['seconds', 1]) {
2999: my ($name, $factor) = @{ $which };
3000: if (defined($env{'form.'.$name.'_'.$key})) {
3001: $seconds += $env{'form.'.$name.'_'.$key} * $factor;
3002: }
3003: }
3004: return $seconds;
3005: }
3006:
3007:
1.383 albertel 3008: sub default_selector {
3009: my ($thiskey, $showval) = @_;
1.385 albertel 3010: return '<input type="text" name="set_'.$thiskey.'" value="'.$showval.'" />';
1.383 albertel 3011: }
3012:
3013: my %strings =
3014: (
3015: 'string_yesno'
3016: => [[ 'yes', 'Yes' ],
3017: [ 'no', 'No' ]],
3018: 'string_problemstatus'
3019: => [[ 'yes', 'Yes' ],
1.394 www 3020: [ 'answer', 'Yes, and show correct answer if they exceed the maximum number of tries.' ],
1.383 albertel 3021: [ 'no', 'No, don\'t show correct/incorrect feedback.' ],
3022: [ 'no_feedback_ever', 'No, show no feedback at all.' ]],
3023: );
3024:
3025:
3026: sub string_selector {
3027: my ($thistype, $thiskey, $showval) = @_;
3028:
3029: if (!exists($strings{$thistype})) {
3030: return &default_selector($thiskey,$showval);
3031: }
3032:
3033: my $result;
3034: foreach my $possibilities (@{ $strings{$thistype} }) {
3035: my ($name, $description) = @{ $possibilities };
3036: $result .= '<label><input type="radio" name="set_'.$thiskey.
3037: '" value="'.$name.'"';
3038: if ($showval eq $name) {
3039: $result .= ' checked="checked"';
3040: }
3041: $result .= ' />'.&mt($description).'</label> ';
3042: }
3043: return $result;
3044: }
3045:
1.389 www 3046: #
3047: # Shift all start and end dates by $shift
3048: #
3049:
3050: sub dateshift {
3051: my ($shift)=@_;
3052: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3053: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3054: my %data=&Apache::lonnet::dump('resourcedata',$dom,$crs);
3055: # ugly retro fix for broken version of types
3056: foreach my $key (keys %data) {
3057: if ($key=~/\wtype$/) {
3058: my $newkey=$key;
3059: $newkey=~s/type$/\.type/;
3060: $data{$newkey}=$data{$key};
3061: delete $data{$key};
3062: }
3063: }
1.391 www 3064: my %storecontent=();
1.389 www 3065: # go through all parameters and look for dates
3066: foreach my $key (keys %data) {
3067: if ($data{$key.'.type'}=~/^date_(start|end)$/) {
3068: my $newdate=$data{$key}+$shift;
1.391 www 3069: $storecontent{$key}=$newdate;
1.389 www 3070: }
3071: }
1.391 www 3072: my $reply=&Apache::lonnet::cput
3073: ('resourcedata',\%storecontent,$dom,$crs);
3074: if ($reply eq 'ok') {
3075: &log_parmset(\%storecontent);
3076: }
3077: &Apache::lonnet::devalidatecourseresdata($crs,$dom);
3078: return $reply;
1.389 www 3079: }
3080:
1.208 www 3081: sub newoverview {
1.280 albertel 3082: my ($r) = @_;
3083:
1.208 www 3084: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3085: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3086: my $start_page = &Apache::loncommon::start_page('Set Parameters');
1.298 albertel 3087: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3088: $r->print(<<ENDOVER);
1.280 albertel 3089: $start_page
1.208 www 3090: $breadcrumbs
1.232 albertel 3091: <form method="post" action="/adm/parmset?action=newoverview" name="parmform">
1.208 www 3092: ENDOVER
1.211 www 3093: my @ids=();
3094: my %typep=();
3095: my %keyp=();
3096: my %allparms=();
3097: my %allparts=();
3098: my %allmaps=();
3099: my %mapp=();
3100: my %symbp=();
3101: my %maptitles=();
3102: my %uris=();
3103: my %keyorder=&standardkeyorder();
3104: my %defkeytype=();
3105:
3106: my %alllevs=();
3107: $alllevs{'Resource Level'}='full';
1.215 www 3108: $alllevs{'Map/Folder Level'}='map';
1.211 www 3109: $alllevs{'Course Level'}='general';
3110:
3111: my $csec=$env{'form.csec'};
1.269 raeburn 3112: my $cgroup=$env{'form.cgroup'};
1.211 www 3113:
3114: my @pscat=&Apache::loncommon::get_env_multiple('form.pscat');
3115: my $pschp=$env{'form.pschp'};
3116: my @psprt=&Apache::loncommon::get_env_multiple('form.psprt');
3117: if (!@psprt) { $psprt[0]='0'; }
3118:
3119: my @selected_sections =
3120: &Apache::loncommon::get_env_multiple('form.Section');
3121: @selected_sections = ('all') if (! @selected_sections);
1.374 albertel 3122: foreach my $sec (@selected_sections) {
3123: if ($sec eq 'all') {
1.211 www 3124: @selected_sections = ('all');
3125: }
3126: }
1.269 raeburn 3127: my @selected_groups =
3128: &Apache::loncommon::get_env_multiple('form.Group');
1.211 www 3129:
3130: my $pssymb='';
3131: my $parmlev='';
3132:
3133: unless ($env{'form.parmlev'}) {
3134: $parmlev = 'map';
3135: } else {
3136: $parmlev = $env{'form.parmlev'};
3137: }
3138:
3139: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
3140: \%mapp, \%symbp,\%maptitles,\%uris,
3141: \%keyorder,\%defkeytype);
3142:
1.374 albertel 3143: if (grep {$_ eq 'all'} (@psprt)) {
3144: @psprt = keys(%allparts);
3145: }
1.211 www 3146: # Menu to select levels, etc
3147:
1.317 albertel 3148: $r->print('<table id="LC_parm_overview_scope">
3149: <tr><td class="LC_parm_overview_level_menu">');
1.211 www 3150: &levelmenu($r,\%alllevs,$parmlev);
3151: if ($parmlev ne 'general') {
1.317 albertel 3152: $r->print('<td class="LC_parm_overview_map_menu">');
1.211 www 3153: &mapmenu($r,\%allmaps,$pschp,\%maptitles);
3154: $r->print('</td>');
3155: }
3156: $r->print('</td></tr></table>');
3157:
1.317 albertel 3158: $r->print('<table id="LC_parm_overview_controls">
3159: <tr><td class="LC_parm_overview_parm_selectors">');
1.211 www 3160: &parmmenu($r,\%allparms,\@pscat,\%keyorder);
1.317 albertel 3161: $r->print('</td><td class="LC_parm_overview_restrictions">
3162: <table class="LC_parm_overview_restrictions">'.
3163: '<tr><th>'.&mt('Parts').'</th><th>'.&mt('Section(s)').
3164: '</th><th>'.&mt('Group(s)').'</th></tr><tr><td>');
1.211 www 3165: &partmenu($r,\%allparts,\@psprt);
1.317 albertel 3166: $r->print('</td><td>');
1.211 www 3167: §ionmenu($r,\@selected_sections);
1.317 albertel 3168: $r->print('</td><td>');
1.269 raeburn 3169: &groupmenu($r,\@selected_groups);
3170: $r->print('</td></tr></table>');
1.214 www 3171: $r->print('</td></tr></table>');
3172:
3173: my $sortorder=$env{'form.sortorder'};
3174: unless ($sortorder) { $sortorder='realmstudent'; }
3175: &sortmenu($r,$sortorder);
3176:
3177: $r->print('<p><input type="submit" name="dis" value="'.&mt('Display').'" /></p>');
1.211 www 3178:
3179: # Build the list data hash from the specified parms
3180:
3181: my $listdata;
3182: %{$listdata}=();
3183:
3184: foreach my $cat (@pscat) {
1.269 raeburn 3185: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_sections,\%defkeytype,\%allmaps,\@ids,\%symbp);
3186: &secgroup_lister($cat,$pschp,$parmlev,$listdata,\@psprt,\@selected_groups,\%defkeytype,\%allmaps,\@ids,\%symbp);
1.211 www 3187: }
3188:
1.212 www 3189: if (($env{'form.store'}) || ($env{'form.dis'})) {
1.211 www 3190:
1.212 www 3191: if ($env{'form.store'}) { &storedata($r,$crs,$dom); }
1.211 www 3192:
3193: # Read modified data
3194:
3195: my $resourcedata=&readdata($crs,$dom);
3196:
3197: # List data
3198:
1.214 www 3199: &listdata($r,$resourcedata,$listdata,$sortorder);
1.211 www 3200: }
3201: $r->print(&tableend().
1.365 albertel 3202: ((($env{'form.store'}) || ($env{'form.dis'}))?'<p><input type="submit" name="store" value="'.&mt('Save').'" /></p>':'').
1.280 albertel 3203: '</form>'.&Apache::loncommon::end_page());
1.208 www 3204: }
3205:
1.269 raeburn 3206: sub secgroup_lister {
3207: my ($cat,$pschp,$parmlev,$listdata,$psprt,$selections,$defkeytype,$allmaps,$ids,$symbp) = @_;
3208: foreach my $item (@{$selections}) {
3209: foreach my $part (@{$psprt}) {
3210: my $rootparmkey=$env{'request.course.id'};
3211: if (($item ne 'all') && ($item ne 'none') && ($item)) {
3212: $rootparmkey.='.['.$item.']';
3213: }
3214: if ($parmlev eq 'general') {
3215: # course-level parameter
3216: my $newparmkey=$rootparmkey.'.'.$part.'.'.$cat;
3217: $$listdata{$newparmkey}=1;
3218: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3219: } elsif ($parmlev eq 'map') {
3220: # map-level parameter
3221: foreach my $mapid (keys %{$allmaps}) {
3222: if (($pschp ne 'all') && ($pschp ne $mapid)) { next; }
3223: my $newparmkey=$rootparmkey.'.'.$$allmaps{$mapid}.'___(all).'.$part.'.'.$cat;
3224: $$listdata{$newparmkey}=1;
3225: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3226: }
3227: } else {
3228: # resource-level parameter
3229: foreach my $rid (@{$ids}) {
3230: my ($map,$resid,$url)=&Apache::lonnet::decode_symb($$symbp{$rid});
3231: if (($pschp ne 'all') && ($$allmaps{$pschp} ne $map)) { next; }
3232: my $newparmkey=$rootparmkey.'.'.$$symbp{$rid}.'.'.$part.'.'.$cat;
3233: $$listdata{$newparmkey}=1;
3234: $$listdata{$newparmkey.'.type'}=$$defkeytype{$cat};
3235: }
3236: }
3237: }
3238: }
3239: }
3240:
1.208 www 3241: sub overview {
1.280 albertel 3242: my ($r) = @_;
1.208 www 3243: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3244: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.280 albertel 3245:
3246: my $start_page=&Apache::loncommon::start_page('Modify Parameters');
1.298 albertel 3247: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Overview');
1.208 www 3248: $r->print(<<ENDOVER);
1.280 albertel 3249: $start_page
1.208 www 3250: $breadcrumbs
1.232 albertel 3251: <form method="post" action="/adm/parmset?action=setoverview" name="parmform">
1.208 www 3252: ENDOVER
3253: # Store modified
3254:
3255: &storedata($r,$crs,$dom);
3256:
3257: # Read modified data
3258:
3259: my $resourcedata=&readdata($crs,$dom);
3260:
1.214 www 3261:
3262: my $sortorder=$env{'form.sortorder'};
3263: unless ($sortorder) { $sortorder='realmstudent'; }
3264: &sortmenu($r,$sortorder);
3265:
1.208 www 3266: # List data
3267:
1.214 www 3268: my $foundkeys=&listdata($r,$resourcedata,$resourcedata,$sortorder);
1.208 www 3269:
1.145 www 3270: $r->print(&tableend().'<p>'.
1.280 albertel 3271: ($foundkeys?'<input type="submit" value="'.&mt('Modify Parameters').'" />':&mt('There are no parameters.')).'</p></form>'.
3272: &Apache::loncommon::end_page());
1.120 www 3273: }
1.121 www 3274:
1.333 albertel 3275: sub clean_parameters {
3276: my ($r) = @_;
3277: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3278: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3279:
3280: my $start_page=&Apache::loncommon::start_page('Clean Parameters');
3281: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean');
3282: $r->print(<<ENDOVER);
3283: $start_page
3284: $breadcrumbs
3285: <form method="post" action="/adm/parmset?action=cleanparameters" name="parmform">
3286: ENDOVER
3287: # Store modified
3288:
3289: &storedata($r,$crs,$dom);
3290:
3291: # Read modified data
3292:
3293: my $resourcedata=&readdata($crs,$dom);
3294:
3295: # List data
3296:
3297: $r->print('<h3>'.
3298: &mt('These parameters refer to resources that do not exist.').
3299: '</h3>'.
3300: '<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.'<br />'.
3301: '<br />');
3302: $r->print(&Apache::loncommon::start_data_table().
3303: '<tr>'.
3304: '<th>'.&mt('Delete').'</th>'.
3305: '<th>'.&mt('Parameter').'</th>'.
3306: '</tr>');
3307: foreach my $thiskey (sort(keys(%{$resourcedata}))) {
3308: next if (!exists($resourcedata->{$thiskey.'.type'})
3309: && $thiskey=~/\.type$/);
3310: my %data = &parse_key($thiskey);
1.383 albertel 3311: if (1) { #exists($data{'realm_exists'})
3312: #&& !$data{'realm_exists'}) {
1.333 albertel 3313: $r->print(&Apache::loncommon::start_data_table_row().
3314: '<tr>'.
3315: '<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' );
3316:
3317: $r->print('<td>');
1.362 albertel 3318: my $display_value = $resourcedata->{$thiskey};
3319: if (&isdateparm($resourcedata->{$thiskey.'.type'})) {
3320: $display_value =
3321: &Apache::lonlocal::locallocaltime($display_value);
3322: }
1.333 albertel 3323: $r->print(&mt('Parameter: "[_1]" with value: "[_2]"',
3324: &standard_parameter_names($data{'parameter_name'}),
3325: $resourcedata->{$thiskey}));
3326: $r->print('<br />');
3327: if ($data{'scope_type'} eq 'all') {
3328: $r->print(&mt('All users'));
3329: } elsif ($data{'scope_type'} eq 'user') {
3330: $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
3331: } elsif ($data{'scope_type'} eq 'section') {
3332: $r->print(&mt('Section: [_1]',$data{'scope'}));
3333: } elsif ($data{'scope_type'} eq 'group') {
3334: $r->print(&mt('Group: [_1]',$data{'scope'}));
3335: }
3336: $r->print('<br />');
3337: if ($data{'realm_type'} eq 'all') {
3338: $r->print(&mt('All Resources'));
3339: } elsif ($data{'realm_type'} eq 'folder') {
3340: $r->print(&mt('Folder: [_1]'),$data{'realm'});
3341: } elsif ($data{'realm_type'} eq 'symb') {
3342: my ($map,$resid,$url) =
3343: &Apache::lonnet::decode_symb($data{'realm'});
3344: $r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]',
3345: $url,$resid,$map));
3346: }
1.362 albertel 3347: $r->print(' <br /> '.&mt('Part: [_1]',$data{'parameter_part'}));
1.333 albertel 3348: $r->print('</td></tr>');
3349:
3350: }
3351: }
3352: $r->print(&Apache::loncommon::end_data_table().'<p>'.
3353: '<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.
3354: '</p></form>'.
3355: &Apache::loncommon::end_page());
3356: }
3357:
1.390 www 3358: sub date_shift_one {
3359: my ($r) = @_;
3360: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3361: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3362:
3363: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3364: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3365: $r->print(<<ENDOVER);
3366: $start_page
3367: $breadcrumbs
3368: ENDOVER
3369: $r->print('<form name="shiftform" method="post">'.
3370: '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
3371: &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
3372: '<tr><td>'.&mt('Shifted date:').'</td><td>'.
3373: &Apache::lonhtmlcommon::date_setter('shiftform',
3374: 'timeshifted',
3375: $env{'form.timebase'},,
3376: '').
3377: '</td></tr></table>'.
3378: '<input type="hidden" name="action" value="dateshift2" />'.
3379: '<input type="hidden" name="timebase" value="'.$env{'form.timebase'}.'" />'.
3380: '<input type="submit" value="'.&mt('Shift all dates accordingly').'" /></form>');
3381: $r->print(&Apache::loncommon::end_page());
3382: }
3383:
3384: sub date_shift_two {
3385: my ($r) = @_;
3386: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3387: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
3388: my $start_page=&Apache::loncommon::start_page('Shift Dates');
3389: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
3390: $r->print(<<ENDOVER);
3391: $start_page
3392: $breadcrumbs
3393: ENDOVER
3394: my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
3395: $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',
3396: &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
3397: &Apache::lonlocal::locallocaltime($timeshifted)));
3398: my $delta=$timeshifted-$env{'form.timebase'};
3399: &dateshift($delta);
3400: $r->print(&Apache::loncommon::end_page());
3401: }
3402:
1.333 albertel 3403: sub parse_key {
3404: my ($key) = @_;
3405: my %data;
3406: my ($middle,$part,$name)=
3407: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
3408: $data{'scope_type'} = 'all';
3409: if ($middle=~/^\[(.*)\]/) {
3410: $data{'scope'} = $1;
1.350 albertel 3411: if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
1.333 albertel 3412: $data{'scope_type'} = 'user';
3413: $data{'scope'} = [$1,$2];
3414: } else {
3415: #FIXME check for group scope
3416: $data{'scope_type'} = 'section';
3417: }
3418: $middle=~s/^\[(.*)\]//;
3419: }
3420: $middle=~s/\.+$//;
3421: $middle=~s/^\.+//;
3422: $data{'realm_type'}='all';
3423: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
3424: $data{'realm'} = $1;
3425: $data{'realm_type'} = 'folder';
3426: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3427: ($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'});
3428: } elsif ($middle) {
3429: $data{'realm'} = $middle;
3430: $data{'realm_type'} = 'symb';
3431: $data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'});
3432: my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'});
3433: $data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url);
3434: }
3435:
3436: $data{'parameter_part'} = $part;
3437: $data{'parameter_name'} = $name;
3438:
3439: return %data;
3440: }
3441:
1.59 matthew 3442: ##################################################
3443: ##################################################
1.333 albertel 3444:
1.178 raeburn 3445: =pod
1.239 raeburn 3446:
3447: =item check_cloners
3448:
3449: Checks if new users included in list of allowed cloners
3450: are valid users. Replaces supplied list with
3451: cleaned list containing only users with valid usernames
3452: and domains.
3453:
3454: Inputs: $clonelist, $oldcloner
3455: where $clonelist is ref to array of requested cloners,
3456: and $oldcloner is ref to array of currently allowed
3457: cloners.
3458:
3459: Returns: string - comma separated list of requested
3460: cloners (username:domain) who do not exist in system.
3461:
3462: =item change_clone
3463:
1.178 raeburn 3464: Modifies the list of courses a user can clone (stored
1.239 raeburn 3465: in the user's environment.db file), called when a
1.178 raeburn 3466: change is made to the list of users allowed to clone
3467: a course.
1.239 raeburn 3468:
1.178 raeburn 3469: Inputs: $action,$cloner
3470: where $action is add or drop, and $cloner is identity of
3471: user for whom cloning ability is to be changed in course.
3472:
3473: =cut
1.380 albertel 3474:
1.178 raeburn 3475: ##################################################
3476: ##################################################
3477:
1.239 raeburn 3478: sub extract_cloners {
3479: my ($clonelist,$allowclone) = @_;
3480: if ($clonelist =~ /,/) {
1.380 albertel 3481: @{$allowclone} = split(/,/,$clonelist);
1.239 raeburn 3482: } else {
3483: $$allowclone[0] = $clonelist;
3484: }
3485: }
3486:
3487: sub check_cloners {
3488: my ($clonelist,$oldcloner) = @_;
1.379 raeburn 3489: my ($clean_clonelist,%disallowed);
1.239 raeburn 3490: my @allowclone = ();
3491: &extract_cloners($$clonelist,\@allowclone);
3492: foreach my $currclone (@allowclone) {
1.380 albertel 3493: if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {
1.379 raeburn 3494: if ($currclone eq '*') {
3495: $clean_clonelist .= $currclone.',';
3496: } else {
3497: my ($uname,$udom) = split(/:/,$currclone);
3498: if ($uname eq '*') {
3499: if ($udom =~ /^$match_domain$/) {
1.380 albertel 3500: if (!&Apache::lonnet::domain($udom)) {
1.379 raeburn 3501: $disallowed{'domain'} .= $currclone.',';
3502: } else {
3503: $clean_clonelist .= $currclone.',';
3504: }
3505: } else {
3506: $disallowed{'format'} .= $currclone.',';
3507: }
3508: } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {
3509: $disallowed{'format'} .= $currclone.',';
1.239 raeburn 3510: } else {
1.379 raeburn 3511: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
3512: $disallowed{'newuser'} .= $currclone.',';
3513: } else {
3514: $clean_clonelist .= $currclone.',';
3515: }
1.239 raeburn 3516: }
3517: }
3518: } else {
3519: $clean_clonelist .= $currclone.',';
3520: }
3521: }
1.379 raeburn 3522: foreach my $key (keys(%disallowed)) {
3523: $disallowed{$key} =~ s/,$//;
1.239 raeburn 3524: }
3525: if ($clean_clonelist) {
3526: $clean_clonelist =~ s/,$//;
3527: }
3528: $$clonelist = $clean_clonelist;
1.379 raeburn 3529: return %disallowed;
3530: }
1.178 raeburn 3531:
3532: sub change_clone {
3533: my ($clonelist,$oldcloner) = @_;
3534: my ($uname,$udom);
1.190 albertel 3535: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3536: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.178 raeburn 3537: my $clone_crs = $cnum.':'.$cdom;
3538:
3539: if ($cnum && $cdom) {
1.239 raeburn 3540: my @allowclone;
3541: &extract_cloners($clonelist,\@allowclone);
1.178 raeburn 3542: foreach my $currclone (@allowclone) {
1.380 albertel 3543: if (!grep(/^$currclone$/,@$oldcloner)) {
1.379 raeburn 3544: if ($currclone ne '*') {
1.380 albertel 3545: ($uname,$udom) = split(/:/,$currclone);
1.379 raeburn 3546: if ($uname && $udom && $uname ne '*') {
3547: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3548: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3549: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
3550: if ($currclonecrs{'cloneable'} eq '') {
3551: $currclonecrs{'cloneable'} = $clone_crs;
3552: } else {
3553: $currclonecrs{'cloneable'} .= ','.$clone_crs;
3554: }
3555: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.178 raeburn 3556: }
3557: }
3558: }
3559: }
3560: }
3561: }
3562: foreach my $oldclone (@$oldcloner) {
1.380 albertel 3563: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
1.379 raeburn 3564: if ($oldclone ne '*') {
1.380 albertel 3565: ($uname,$udom) = split(/:/,$oldclone);
1.379 raeburn 3566: if ($uname && $udom && $uname ne '*' ) {
3567: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3568: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
3569: my %newclonecrs = ();
3570: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
3571: if ($currclonecrs{'cloneable'} =~ /,/) {
3572: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
3573: foreach my $crs (@currclonecrs) {
3574: if ($crs ne $clone_crs) {
3575: $newclonecrs{'cloneable'} .= $crs.',';
3576: }
1.178 raeburn 3577: }
1.379 raeburn 3578: $newclonecrs{'cloneable'} =~ s/,$//;
3579: } else {
3580: $newclonecrs{'cloneable'} = '';
1.178 raeburn 3581: }
1.379 raeburn 3582: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.178 raeburn 3583: }
3584: }
3585: }
3586: }
3587: }
3588: }
3589: }
3590: }
3591:
1.193 albertel 3592:
3593: ##################################################
3594: ##################################################
3595:
3596: =pod
3597:
3598: =item * header
3599:
3600: Output html header for page
3601:
3602: =cut
3603:
3604: ##################################################
3605: ##################################################
3606: sub header {
1.280 albertel 3607: return &Apache::loncommon::start_page('Parameter Manager');
1.193 albertel 3608: }
3609: ##################################################
3610: ##################################################
3611: sub print_main_menu {
3612: my ($r,$parm_permission)=@_;
3613: #
3614: $r->print(<<ENDMAINFORMHEAD);
3615: <form method="post" enctype="multipart/form-data"
3616: action="/adm/parmset" name="studentform">
3617: ENDMAINFORMHEAD
3618: #
1.195 albertel 3619: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3620: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.268 albertel 3621: my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'});
1.366 albertel 3622: my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'});
1.268 albertel 3623:
1.193 albertel 3624: my @menu =
1.322 www 3625: ( { divider=>'Settings for Your Course',
3626: },
1.323 albertel 3627: { text => 'Set Course Environment',
1.204 www 3628: action => 'crsenv',
1.193 albertel 3629: permission => $parm_permission,
1.324 www 3630: help => 'Course_Environment',
1.193 albertel 3631: },
1.255 banghart 3632: { text => 'Set Portfolio Metadata',
1.259 banghart 3633: action => 'setrestrictmeta',
1.240 banghart 3634: permission => $parm_permission,
3635: },
1.271 www 3636: { text => 'Manage Course Slots',
1.268 albertel 3637: url => '/adm/slotrequest?command=showslots',
3638: permission => $vgr,
3639: },
1.366 albertel 3640: { text => 'Reset Student Access Times',
3641: url => '/adm/helper/resettimes.helper',
3642: permission => $mgr,
3643: },
3644:
1.322 www 3645: { text => 'Set Parameter Setting Default Actions',
3646: action => 'setdefaults',
3647: permission => $parm_permission,
3648: },
3649: { divider => 'New and Existing Parameter Settings for Your Resources',
1.268 albertel 3650: },
1.216 www 3651: { text => 'Set/Modify Resource Parameters - Helper Mode',
1.193 albertel 3652: url => '/adm/helper/parameter.helper',
3653: permission => $parm_permission,
1.324 www 3654: help => 'Parameter_Helper',
1.193 albertel 3655: },
1.322 www 3656: { text => 'Set/Modify Resource Parameters - Overview Mode',
1.208 www 3657: action => 'newoverview',
3658: permission => $parm_permission,
1.324 www 3659: help => 'Parameter_Overview',
1.193 albertel 3660: },
1.216 www 3661: { text => 'Set/Modify Resource Parameters - Table Mode',
1.193 albertel 3662: action => 'settable',
3663: permission => $parm_permission,
1.324 www 3664: help => 'Table_Mode',
1.193 albertel 3665: },
1.322 www 3666: { divider => 'Existing Parameter Settings for Your Resources',
3667: },
3668: { text => 'Modify Resource Parameters - Overview Mode',
3669: action => 'setoverview',
1.220 www 3670: permission => $parm_permission,
1.324 www 3671: help => 'Parameter_Overview',
1.322 www 3672: },
1.292 www 3673: { text => 'Parameter Change Log and Course Blog Posting/User Notification',
1.284 www 3674: action => 'parameterchangelog',
3675: permission => $parm_permission,
1.220 www 3676: },
1.193 albertel 3677: );
3678: my $menu_html = '';
3679: foreach my $menu_item (@menu) {
1.268 albertel 3680: if ($menu_item->{'divider'}) {
1.322 www 3681: $menu_html .= '<h3>'.&mt($menu_item->{'divider'}).'</h3>';
1.268 albertel 3682: next;
3683: }
1.193 albertel 3684: next if (! $menu_item->{'permission'});
3685: $menu_html.='<p>';
1.316 albertel 3686: $menu_html.='<span class="LC_parm_menu_item">';
1.193 albertel 3687: if (exists($menu_item->{'url'})) {
3688: $menu_html.=qq{<a href="$menu_item->{'url'}">};
3689: } else {
3690: $menu_html.=
3691: qq{<a href="/adm/parmset?action=$menu_item->{'action'}">};
3692: }
1.316 albertel 3693: $menu_html.= &mt($menu_item->{'text'}).'</a></span>';
1.193 albertel 3694: if (exists($menu_item->{'help'})) {
3695: $menu_html.=
3696: &Apache::loncommon::help_open_topic($menu_item->{'help'});
3697: }
3698: $menu_html.='</p>'.$/;
3699: }
3700: $r->print($menu_html);
3701: return;
3702: }
1.255 banghart 3703: ### Set portfolio metadata
1.252 banghart 3704: sub output_row {
1.347 banghart 3705: my ($r, $field_name, $field_text, $added_flag) = @_;
1.252 banghart 3706: my $output;
1.263 banghart 3707: my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
3708: my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
1.337 banghart 3709: if (!defined($options)) {
1.254 banghart 3710: $options = 'active,stuadd';
1.261 banghart 3711: $values = '';
1.252 banghart 3712: }
1.337 banghart 3713: if (!($options =~ /deleted/)) {
3714: my @options= ( ['active', 'Show to student'],
1.351 banghart 3715: ['stuadd', 'Provide text area for students to type catalog information'],
3716: ['choices','Provide choices for students to select from']);
3717: # ['onlyone','Student may select only one choice']);
1.337 banghart 3718: if ($added_flag) {
3719: push @options,['deleted', 'Delete Metadata Field'];
3720: }
1.351 banghart 3721: $output = &Apache::loncommon::start_data_table_row();
3722: $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
3723: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3724: foreach my $opt (@options) {
3725: my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
1.347 banghart 3726: $output .= &Apache::loncommon::continue_data_table_row();
1.351 banghart 3727: $output .= '<td>'.(' ' x 5).'<span class="LC_metadata"><label>
3728: <input type="checkbox" name="'.
3729: $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
3730: &mt($opt->[1]).'</label></span> </td>';
1.347 banghart 3731: $output .= &Apache::loncommon::end_data_table_row();
1.337 banghart 3732: }
1.351 banghart 3733: $output .= &Apache::loncommon::continue_data_table_row();
3734: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
3735: $output .= &Apache::loncommon::end_data_table_row();
3736: my $multiple_checked;
3737: my $single_checked;
3738: if ($options =~ m/onlyone/) {
3739: $multiple_checked = "";
3740: $single_checked = " CHECKED ";
3741: } else {
3742: $multiple_checked = " CHECKED ";
3743: $single_checked = "";
3744: }
3745: $output .= &Apache::loncommon::continue_data_table_row();
3746: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
3747: <input type="radio" name="'.$field_name.'_onlyone" value="multiple" '.$multiple_checked .'/>
3748: Student may select multiple choices from list</span></td>';
3749: $output .= &Apache::loncommon::end_data_table_row();
3750: $output .= &Apache::loncommon::continue_data_table_row();
3751: $output .= '<td>'.(' ' x 10).'<span class="LC_metadata">
3752: <input type="radio" name="'.$field_name.'_onlyone" value="single" '.$single_checked.'/>
3753: Student may select only one choice from list</span></td>';
3754: $output .= &Apache::loncommon::end_data_table_row();
1.252 banghart 3755: }
3756: return ($output);
3757: }
1.340 banghart 3758: sub order_meta_fields {
3759: my ($r)=@_;
3760: my $idx = 1;
3761: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3762: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.341 banghart 3763: $r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
1.345 banghart 3764: &Apache::lonhtmlcommon::add_breadcrumb
3765: ({href=>"/adm/parmset?action=setrestrictmeta",
3766: text=>"Restrict Metadata"},
3767: {text=>"Order Metadata"});
3768: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
1.340 banghart 3769: if ($env{'form.storeorder'}) {
3770: my $newpos = $env{'form.newpos'} - 1;
3771: my $currentpos = $env{'form.currentpos'} - 1;
3772: my @neworder = ();
3773: my @oldorder = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3774: my $i;
1.341 banghart 3775: if ($newpos > $currentpos) {
1.340 banghart 3776: # moving stuff up
3777: for ($i=0;$i<$currentpos;$i++) {
3778: $neworder[$i]=$oldorder[$i];
3779: }
3780: for ($i=$currentpos;$i<$newpos;$i++) {
3781: $neworder[$i]=$oldorder[$i+1];
3782: }
3783: $neworder[$newpos]=$oldorder[$currentpos];
3784: for ($i=$newpos+1;$i<=$#oldorder;$i++) {
3785: $neworder[$i]=$oldorder[$i];
3786: }
3787: } else {
3788: # moving stuff down
3789: for ($i=0;$i<$newpos;$i++) {
3790: $neworder[$i]=$oldorder[$i];
3791: }
3792: $neworder[$newpos]=$oldorder[$currentpos];
3793: for ($i=$newpos+1;$i<$currentpos+1;$i++) {
3794: $neworder[$i]=$oldorder[$i-1];
3795: }
3796: for ($i=$currentpos+1;$i<=$#oldorder;$i++) {
3797: $neworder[$i]=$oldorder[$i];
3798: }
3799: }
3800: my $ordered_fields = join ",", @neworder;
1.343 banghart 3801: my $put_result = &Apache::lonnet::put('environment',
3802: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
1.393 raeburn 3803: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields});
1.340 banghart 3804: }
1.357 raeburn 3805: my $fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.341 banghart 3806: my $ordered_fields;
1.340 banghart 3807: my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'};
3808: if (!@fields_in_order) {
3809: # no order found, pick sorted order then create metadata.addedorder key.
3810: foreach my $key (sort keys %$fields) {
3811: push @fields_in_order, $key;
1.341 banghart 3812: $ordered_fields = join ",", @fields_in_order;
1.340 banghart 3813: }
1.341 banghart 3814: my $put_result = &Apache::lonnet::put('environment',
3815: {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
3816: }
1.340 banghart 3817: $r->print('<table>');
3818: my $num_fields = scalar(@fields_in_order);
3819: foreach my $key (@fields_in_order) {
3820: $r->print('<tr><td>');
3821: $r->print('<form method="post" action="">');
3822: $r->print('<select name="newpos" onChange="this.form.submit()">');
3823: for (my $i = 1;$i le $num_fields;$i ++) {
3824: if ($i eq $idx) {
3825: $r->print('<option value="'.$i.'" SELECTED>('.$i.')</option>');
3826: } else {
3827: $r->print('<option value="'.$i.'">'.$i.'</option>');
3828: }
3829: }
3830: $r->print('</select></td><td>');
3831: $r->print('<input type="hidden" name="currentpos" value="'.$idx.'" />');
3832: $r->print('<input type="hidden" name="storeorder" value="true" />');
3833: $r->print('</form>');
3834: $r->print($$fields{$key}.'</td></tr>');
3835: $idx ++;
3836: }
3837: $r->print('</table>');
3838: return 'ok';
3839: }
1.359 banghart 3840: sub continue {
3841: my $output;
3842: $output .= '<form action="" method="post">';
3843: $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';
3844: $output .= '<input type="submit" value="Continue" />';
3845: return ($output);
3846: }
1.334 banghart 3847: sub addmetafield {
3848: my ($r)=@_;
3849: $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
3850: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field'));
1.335 banghart 3851: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3852: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.339 banghart 3853: if (exists($env{'form.undelete'})) {
1.358 banghart 3854: my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');
1.339 banghart 3855: foreach my $meta_field(@meta_fields) {
3856: my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
3857: $options =~ s/deleted//;
3858: $options =~ s/,,/,/;
3859: my $put_result = &Apache::lonnet::put('environment',
3860: {'metadata.'.$meta_field.'.options'=>$options},$dom,$crs);
3861:
3862: $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
3863: }
1.359 banghart 3864: $r->print(&continue());
1.339 banghart 3865: } elsif (exists($env{'form.fieldname'})) {
1.335 banghart 3866: my $meta_field = $env{'form.fieldname'};
3867: my $display_field = $env{'form.fieldname'};
3868: $meta_field =~ s/\W/_/g;
1.338 banghart 3869: $meta_field =~ tr/A-Z/a-z/;
1.335 banghart 3870: my $put_result = &Apache::lonnet::put('environment',
3871: {'metadata.'.$meta_field.'.values'=>"",
3872: 'metadata.'.$meta_field.'.added'=>"$display_field",
3873: 'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
1.359 banghart 3874: $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');
3875: $r->print(&continue());
1.335 banghart 3876: } else {
1.357 raeburn 3877: my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'});
1.339 banghart 3878: if ($fields) {
3879: $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
3880: $r->print('<form method="post" action="">');
3881: foreach my $key(keys(%$fields)) {
1.358 banghart 3882: $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');
1.339 banghart 3883: }
3884: $r->print('<input type="submit" name="undelete" value="Undelete" />');
3885: $r->print('</form>');
3886: }
3887: $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 3888: $r->print('<input type="text" name="fieldname" /><br />');
3889: $r->print('<input type="submit" value="Add Metadata Field" />');
1.334 banghart 3890: }
1.361 albertel 3891: $r->print('</form>');
1.334 banghart 3892: }
1.259 banghart 3893: sub setrestrictmeta {
1.240 banghart 3894: my ($r)=@_;
1.242 banghart 3895: my $next_meta;
1.244 banghart 3896: my $output;
1.245 banghart 3897: my $item_num;
1.246 banghart 3898: my $put_result;
1.280 albertel 3899: $r->print(&Apache::loncommon::start_page('Restrict Metadata'));
1.298 albertel 3900: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata'));
1.240 banghart 3901: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3902: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.259 banghart 3903: my $key_base = $env{'course.'.$env{'request.course.id'}.'.'};
1.252 banghart 3904: my $save_field = '';
1.259 banghart 3905: if ($env{'form.restrictmeta'}) {
1.254 banghart 3906: foreach my $field (sort(keys(%env))) {
1.252 banghart 3907: if ($field=~m/^form.(.+)_(.+)$/) {
1.254 banghart 3908: my $options;
1.252 banghart 3909: my $meta_field = $1;
3910: my $meta_key = $2;
1.253 banghart 3911: if ($save_field ne $meta_field) {
1.252 banghart 3912: $save_field = $meta_field;
1.253 banghart 3913: if ($env{'form.'.$meta_field.'_stuadd'}) {
1.254 banghart 3914: $options.='stuadd,';
3915: }
1.351 banghart 3916: if ($env{'form.'.$meta_field.'_choices'}) {
3917: $options.='choices,';
3918: }
3919: if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
1.254 banghart 3920: $options.='onlyone,';
3921: }
3922: if ($env{'form.'.$meta_field.'_active'}) {
3923: $options.='active,';
1.253 banghart 3924: }
1.337 banghart 3925: if ($env{'form.'.$meta_field.'_deleted'}) {
3926: $options.='deleted,';
3927: }
1.259 banghart 3928: my $name = $save_field;
1.253 banghart 3929: $put_result = &Apache::lonnet::put('environment',
1.262 banghart 3930: {'metadata.'.$meta_field.'.options'=>$options,
3931: 'metadata.'.$meta_field.'.values'=>$env{'form.'.$meta_field.'_values'},
1.253 banghart 3932: },$dom,$crs);
1.252 banghart 3933: }
3934: }
3935: }
3936: }
1.296 albertel 3937: &Apache::lonnet::coursedescription($env{'request.course.id'},
3938: {'freshen_cache' => 1});
1.335 banghart 3939: # Get the default metadata fields
1.258 albertel 3940: my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
1.335 banghart 3941: # Now get possible added metadata fields
1.357 raeburn 3942: my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'});
1.346 banghart 3943: my $row_alt = 1;
1.347 banghart 3944: $output .= &Apache::loncommon::start_data_table();
1.258 albertel 3945: foreach my $field (sort(keys(%metadata_fields))) {
1.265 banghart 3946: if ($field ne 'courserestricted') {
1.346 banghart 3947: $row_alt = $row_alt ? 0 : 1;
1.347 banghart 3948: $output.= &output_row($r, $field, $metadata_fields{$field});
1.265 banghart 3949: }
1.255 banghart 3950: }
1.351 banghart 3951: my $buttons = (<<ENDButtons);
3952: <input type="submit" name="restrictmeta" value="Save" />
3953: </form><br />
3954: <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
3955: <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
3956: </form>
3957: <br />
3958: <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
3959: <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
3960: ENDButtons
1.337 banghart 3961: my $added_flag = 1;
1.335 banghart 3962: foreach my $field (sort(keys(%$added_metadata_fields))) {
1.346 banghart 3963: $row_alt = $row_alt ? 0 : 1;
3964: $output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag, $row_alt);
1.335 banghart 3965: }
1.347 banghart 3966: $output .= &Apache::loncommon::end_data_table();
1.244 banghart 3967: $r->print(<<ENDenv);
1.259 banghart 3968: <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
1.244 banghart 3969: $output
1.351 banghart 3970: $buttons
1.340 banghart 3971: </form>
1.244 banghart 3972: ENDenv
1.280 albertel 3973: $r->print(&Apache::loncommon::end_page());
1.240 banghart 3974: return 'ok';
3975: }
1.220 www 3976: ##################################################
1.335 banghart 3977: sub get_added_meta_fieldnames {
1.357 raeburn 3978: my ($cid) = @_;
1.335 banghart 3979: my %fields;
3980: foreach my $key(%env) {
1.357 raeburn 3981: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.335 banghart 3982: my $field_name = $1;
3983: my ($display_field_name) = $env{$key};
3984: $fields{$field_name} = $display_field_name;
3985: }
3986: }
3987: return \%fields;
3988: }
1.339 banghart 3989: sub get_deleted_meta_fieldnames {
1.357 raeburn 3990: my ($cid) = @_;
1.339 banghart 3991: my %fields;
3992: foreach my $key(%env) {
1.357 raeburn 3993: if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) {
1.339 banghart 3994: my $field_name = $1;
3995: if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) {
3996: my ($display_field_name) = $env{$key};
3997: $fields{$field_name} = $display_field_name;
3998: }
3999: }
4000: }
4001: return \%fields;
4002: }
1.220 www 4003: sub defaultsetter {
1.280 albertel 4004: my ($r) = @_;
4005:
4006: my $start_page =
4007: &Apache::loncommon::start_page('Parameter Setting Default Actions');
1.298 albertel 4008: my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Defaults');
1.220 www 4009: $r->print(<<ENDDEFHEAD);
1.280 albertel 4010: $start_page
1.220 www 4011: $breadcrumbs
4012: <form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
4013: ENDDEFHEAD
1.280 albertel 4014:
4015: my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
4016: my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
1.221 www 4017: my @ids=();
4018: my %typep=();
4019: my %keyp=();
4020: my %allparms=();
4021: my %allparts=();
4022: my %allmaps=();
4023: my %mapp=();
4024: my %symbp=();
4025: my %maptitles=();
4026: my %uris=();
4027: my %keyorder=&standardkeyorder();
4028: my %defkeytype=();
4029:
4030: &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
4031: \%mapp, \%symbp,\%maptitles,\%uris,
4032: \%keyorder,\%defkeytype);
1.224 www 4033: if ($env{'form.storerules'}) {
4034: my %newrules=();
4035: my @delrules=();
1.226 www 4036: my %triggers=();
1.225 albertel 4037: foreach my $key (keys(%env)) {
4038: if ($key=~/^form\.(\w+)\_action$/) {
1.224 www 4039: my $tempkey=$1;
1.226 www 4040: my $action=$env{$key};
4041: if ($action) {
4042: $newrules{$tempkey.'_action'}=$action;
4043: if ($action ne 'default') {
4044: my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
4045: $triggers{$whichparm}.=$tempkey.':';
4046: }
4047: $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
1.224 www 4048: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4049: $newrules{$tempkey.'_days'}=$env{'form.'.$tempkey.'_days'};
1.224 www 4050: $newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
4051: $newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
4052: $newrules{$tempkey.'_sec'}=$env{'form.'.$tempkey.'_sec'};
4053: } else {
4054: $newrules{$tempkey.'_value'}=$env{'form.'.$tempkey.'_value'};
1.227 www 4055: $newrules{$tempkey.'_triggervalue'}=$env{'form.'.$tempkey.'_triggervalue'};
1.224 www 4056: }
4057: } else {
1.225 albertel 4058: push(@delrules,$tempkey.'_action');
1.226 www 4059: push(@delrules,$tempkey.'_type');
1.225 albertel 4060: push(@delrules,$tempkey.'_hours');
4061: push(@delrules,$tempkey.'_min');
4062: push(@delrules,$tempkey.'_sec');
4063: push(@delrules,$tempkey.'_value');
1.224 www 4064: }
4065: }
4066: }
1.226 www 4067: foreach my $key (keys %allparms) {
4068: $newrules{$key.'_triggers'}=$triggers{$key};
4069: }
1.224 www 4070: &Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
4071: &Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
4072: &resetrulescache();
4073: }
1.227 www 4074: my %lt=&Apache::lonlocal::texthash('days' => 'Days',
4075: 'hours' => 'Hours',
1.221 www 4076: 'min' => 'Minutes',
4077: 'sec' => 'Seconds',
4078: 'yes' => 'Yes',
4079: 'no' => 'No');
1.222 www 4080: my @standardoptions=('','default');
4081: my @standarddisplay=('',&mt('Default value when manually setting'));
4082: my @dateoptions=('','default');
4083: my @datedisplay=('',&mt('Default value when manually setting'));
4084: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
4085: unless ($tempkey) { next; }
4086: push @standardoptions,'when_setting_'.$tempkey;
4087: push @standarddisplay,&mt('Automatically set when setting ').$tempkey;
4088: if (&isdateparm($defkeytype{$tempkey})) {
4089: push @dateoptions,'later_than_'.$tempkey;
4090: push @datedisplay,&mt('Automatically set later than ').$tempkey;
4091: push @dateoptions,'earlier_than_'.$tempkey;
4092: push @datedisplay,&mt('Automatically set earlier than ').$tempkey;
4093: }
4094: }
1.231 www 4095: $r->print(&mt('Manual setting rules apply to all interfaces.').'<br />'.
4096: &mt('Automatic setting rules apply to table mode interfaces only.'));
1.318 albertel 4097: $r->print("\n".&Apache::loncommon::start_data_table().
4098: &Apache::loncommon::start_data_table_header_row().
4099: "<th>".&mt('Rule for parameter').'</th><th>'.
4100: &mt('Action').'</th><th>'.&mt('Value').'</th>'.
4101: &Apache::loncommon::end_data_table_header_row());
1.221 www 4102: foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
1.222 www 4103: unless ($tempkey) { next; }
1.318 albertel 4104: $r->print("\n".&Apache::loncommon::start_data_table_row().
4105: "<td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
1.222 www 4106: my $action=&rulescache($tempkey.'_action');
4107: $r->print('<select name="'.$tempkey.'_action">');
4108: if (&isdateparm($defkeytype{$tempkey})) {
4109: for (my $i=0;$i<=$#dateoptions;$i++) {
4110: if ($dateoptions[$i]=~/\_$tempkey$/) { next; }
4111: $r->print("\n<option value='$dateoptions[$i]'".
4112: ($dateoptions[$i] eq $action?' selected="selected"':'').
4113: ">$datedisplay[$i]</option>");
4114: }
4115: } else {
4116: for (my $i=0;$i<=$#standardoptions;$i++) {
4117: if ($standardoptions[$i]=~/\_$tempkey$/) { next; }
4118: $r->print("\n<option value='$standardoptions[$i]'".
4119: ($standardoptions[$i] eq $action?' selected="selected"':'').
4120: ">$standarddisplay[$i]</option>");
4121: }
4122: }
4123: $r->print('</select>');
1.227 www 4124: unless (&isdateparm($defkeytype{$tempkey})) {
4125: $r->print("\n<br />".&mt('Triggering value(s) of other parameter (optional, comma-separated):').
4126: '<input type="text" size="20" name="'.$tempkey.'_triggervalue" value="'.&rulescache($tempkey.'_triggervalue').'" />');
4127: }
1.222 www 4128: $r->print("\n</td><td>\n");
4129:
1.221 www 4130: if (&isdateparm($defkeytype{$tempkey})) {
1.227 www 4131: my $days=&rulescache($tempkey.'_days');
1.222 www 4132: my $hours=&rulescache($tempkey.'_hours');
4133: my $min=&rulescache($tempkey.'_min');
4134: my $sec=&rulescache($tempkey.'_sec');
1.221 www 4135: $r->print(<<ENDINPUTDATE);
1.227 www 4136: <input name="$tempkey\_days" type="text" size="4" value="$days" />$lt{'days'}<br />
1.222 www 4137: <input name="$tempkey\_hours" type="text" size="4" value="$hours" />$lt{'hours'}<br />
4138: <input name="$tempkey\_min" type="text" size="4" value="$min" />$lt{'min'}<br />
4139: <input name="$tempkey\_sec" type="text" size="4" value="$sec" />$lt{'sec'}
1.221 www 4140: ENDINPUTDATE
4141: } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
1.222 www 4142: my $yeschecked='';
4143: my $nochecked='';
4144: if (&rulescache($tempkey.'_value') eq 'yes') { $yeschecked='checked="checked"'; }
4145: if (&rulescache($tempkey.'_value') eq 'no') { $nochecked='checked="checked"'; }
4146:
1.221 www 4147: $r->print(<<ENDYESNO);
1.224 www 4148: <label><input type="radio" name="$tempkey\_value" value="yes" $yeschecked /> $lt{'yes'}</label><br />
4149: <label><input type="radio" name="$tempkey\_value" value="no" $nochecked /> $lt{'no'}</label>
1.221 www 4150: ENDYESNO
4151: } else {
1.224 www 4152: $r->print('<input type="text" size="20" name="'.$tempkey.'_value" value="'.&rulescache($tempkey.'_value').'" />');
1.221 www 4153: }
1.318 albertel 4154: $r->print('</td>'.&Apache::loncommon::end_data_table_row());
1.221 www 4155: }
1.318 albertel 4156: $r->print(&Apache::loncommon::end_data_table().
4157: "\n<input type='submit' name='storerules' value='".
1.365 albertel 4158: &mt('Save Rules')."' /></form>\n".
1.280 albertel 4159: &Apache::loncommon::end_page());
1.220 www 4160: return;
4161: }
1.193 albertel 4162:
1.290 www 4163: sub components {
1.330 albertel 4164: my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;
4165:
4166: if ($typeflag) {
1.290 www 4167: $key=~s/\.type$//;
4168: }
1.330 albertel 4169:
4170: my ($middle,$part,$name)=
4171: ($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
1.291 www 4172: my $issection;
1.330 albertel 4173:
1.290 www 4174: my $section=&mt('All Students');
4175: if ($middle=~/^\[(.*)\]/) {
1.291 www 4176: $issection=$1;
4177: $section=&mt('Group/Section').': '.$issection;
1.290 www 4178: $middle=~s/^\[(.*)\]//;
4179: }
4180: $middle=~s/\.+$//;
4181: $middle=~s/^\.+//;
1.291 www 4182: if ($uname) {
4183: $section=&mt('User').": ".&Apache::loncommon::plainname($uname,$udom);
4184: $issection='';
4185: }
1.316 albertel 4186: my $realm='<span class="LC_parm_scope_all">'.&mt('All Resources').'</span>';
1.304 www 4187: my $realmdescription=&mt('all resources');
1.290 www 4188: if ($middle=~/^(.+)\_\_\_\(all\)$/) {
1.316 albertel 4189: $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 4190: $realmdescription=&mt('folder').' '.&Apache::lonnet::gettitle($1);
4191: } elsif ($middle) {
1.290 www 4192: my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle);
1.316 albertel 4193: $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 4194: $realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle);
1.290 www 4195: }
1.291 www 4196: my $what=$part.'.'.$name;
1.330 albertel 4197: return ($realm,$section,$name,$part,
1.304 www 4198: $what,$middle,$uname,$udom,$issection,$realmdescription);
1.290 www 4199: }
1.293 www 4200:
1.328 albertel 4201: my %standard_parms;
4202: sub load_parameter_names {
4203: open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab");
4204: while (my $configline=<$config>) {
4205: if ($configline !~ /\S/ || $configline=~/^\#/) { next; }
4206: chomp($configline);
4207: my ($short,$plain)=split(/:/,$configline);
4208: my (undef,$name,$type)=split(/\&/,$short,3);
4209: if ($type eq 'display') {
4210: $standard_parms{$name} = $plain;
4211: }
4212: }
4213: close($config);
4214: $standard_parms{'int_pos'} = 'Positive Integer';
4215: $standard_parms{'int_zero_pos'} = 'Positive Integer or Zero';
4216: %standard_parms=&Apache::lonlocal::texthash(%standard_parms);
4217: }
4218:
1.292 www 4219: sub standard_parameter_names {
4220: my ($name)=@_;
1.328 albertel 4221: if (!%standard_parms) {
4222: &load_parameter_names();
4223: }
1.292 www 4224: if ($standard_parms{$name}) {
4225: return $standard_parms{$name};
4226: } else {
4227: return $name;
4228: }
4229: }
1.290 www 4230:
1.309 www 4231: #
4232: # Parameter Change Log
4233: #
4234:
4235:
1.285 albertel 4236: sub parm_change_log {
1.284 www 4237: my ($r)=@_;
1.327 albertel 4238: $r->print(&Apache::loncommon::start_page('Parameter Change Log'));
4239: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log'));
4240:
1.286 www 4241: my %parmlog=&Apache::lonnet::dump('nohist_parameterlog',
4242: $env{'course.'.$env{'request.course.id'}.'.domain'},
4243: $env{'course.'.$env{'request.course.id'}.'.num'});
1.311 albertel 4244:
1.301 www 4245: if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); }
1.311 albertel 4246:
1.327 albertel 4247: $r->print('<form action="/adm/parmset?action=parameterchangelog"
4248: method="post" name="parameterlog">');
1.311 albertel 4249:
4250: my %saveable_parameters = ('show' => 'scalar',);
4251: &Apache::loncommon::store_course_settings('parameter_log',
4252: \%saveable_parameters);
4253: &Apache::loncommon::restore_course_settings('parameter_log',
4254: \%saveable_parameters);
1.348 www 4255: $r->print(&Apache::loncommon::display_filter().
1.326 www 4256: '<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1').
4257: ' '.&mt('Include parameter types').'</label>'.
1.327 albertel 4258: '<input type="submit" value="'.&mt('Display').'" /></form>');
1.301 www 4259:
1.291 www 4260: my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'},
4261: $env{'course.'.$env{'request.course.id'}.'.domain'});
1.301 www 4262: $r->print(&Apache::loncommon::start_data_table().&Apache::loncommon::start_data_table_header_row().
4263: '<th>'.&mt('Time').'</th><th>'.&mt('User').'</th><th>'.&mt('Extent').'</th><th>'.&mt('Users').'</th><th>'.
4264: &mt('Parameter').'</th><th>'.&mt('Part').'</th><th>'.&mt('New Value').'</th><th>'.&mt('Announce').'</th>'.
4265: &Apache::loncommon::end_data_table_header_row());
1.309 www 4266: my $shown=0;
1.349 www 4267: my $folder='';
4268: if ($env{'form.displayfilter'} eq 'currentfolder') {
4269: my $last='';
4270: if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
4271: &GDBM_READER(),0640)) {
4272: $last=$hash{'last_known'};
4273: untie(%hash);
4274: }
4275: if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
4276: }
1.356 albertel 4277: foreach my $id (sort
4278: {
4279: if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {
4280: return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}
4281: }
4282: my $aid = (split('00000',$a))[-1];
4283: my $bid = (split('00000',$b))[-1];
4284: return $bid<=>$aid;
4285: } (keys(%parmlog))) {
1.294 www 4286: my @changes=keys(%{$parmlog{$id}{'logentry'}});
1.332 albertel 4287: my $count = 0;
1.288 albertel 4288: my $time =
1.294 www 4289: &Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'});
1.289 www 4290: my $plainname =
1.294 www 4291: &Apache::loncommon::plainname($parmlog{$id}{'exe_uname'},
4292: $parmlog{$id}{'exe_udom'});
1.288 albertel 4293: my $about_me_link =
1.289 www 4294: &Apache::loncommon::aboutmewrapper($plainname,
1.294 www 4295: $parmlog{$id}{'exe_uname'},
4296: $parmlog{$id}{'exe_udom'});
1.293 www 4297: my $send_msg_link='';
1.294 www 4298: if ((($parmlog{$id}{'exe_uname'} ne $env{'user.name'})
4299: || ($parmlog{$id}{'exe_udom'} ne $env{'user.domain'}))) {
1.293 www 4300: $send_msg_link ='<br />'.
1.288 albertel 4301: &Apache::loncommon::messagewrapper(&mt('Send message'),
1.294 www 4302: $parmlog{$id}{'exe_uname'},
4303: $parmlog{$id}{'exe_udom'});
1.288 albertel 4304: }
1.301 www 4305: my $row_start=&Apache::loncommon::start_data_table_row();
1.290 www 4306: my $makenewrow=0;
4307: my %istype=();
1.332 albertel 4308: my $output;
1.293 www 4309: foreach my $changed (reverse(sort(@changes))) {
1.330 albertel 4310: my $value=$parmlog{$id}{'logentry'}{$changed};
1.331 albertel 4311: my $typeflag = ($changed =~/\.type$/ &&
4312: !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
1.330 albertel 4313: my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
4314: &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
1.349 www 4315: if ($env{'form.displayfilter'} eq 'currentfolder') {
4316: if ($folder) {
4317: if ($middle!~/^\Q$folder\E/) { next; }
4318: }
4319: }
1.326 www 4320: if ($typeflag) {
1.329 albertel 4321: $istype{$parmname}=$value;
1.326 www 4322: if (!$env{'form.includetypes'}) { next; }
4323: }
1.332 albertel 4324: $count++;
4325: if ($makenewrow) {
4326: $output .= $row_start;
4327: } else {
4328: $makenewrow=1;
4329: }
4330: $output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'.
1.292 www 4331: &standard_parameter_names($parmname).'</td><td>'.
1.332 albertel 4332: ($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>';
1.291 www 4333: my $stillactive=0;
1.332 albertel 4334: if ($parmlog{$id}{'delflag'}) {
4335: $output .= &mt('Deleted');
1.288 albertel 4336: } else {
1.290 www 4337: if ($typeflag) {
1.332 albertel 4338: $output .= &mt('Type: [_1]',&standard_parameter_names($value));
1.290 www 4339: } else {
1.291 www 4340: my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what),
4341: $uname,$udom,$issection,$issection,$courseopt);
4342: if (&isdateparm($istype{$parmname})) {
1.332 albertel 4343: $output .= &Apache::lonlocal::locallocaltime($value);
1.291 www 4344: } else {
1.332 albertel 4345: $output .= $value;
1.291 www 4346: }
4347: if ($value ne $all[$level]) {
1.332 albertel 4348: $output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>';
1.291 www 4349: } else {
4350: $stillactive=1;
4351: }
1.290 www 4352: }
1.288 albertel 4353: }
1.332 albertel 4354: $output .= '</td><td>';
1.291 www 4355: if ($stillactive) {
1.304 www 4356: my $title=&mt('Changed [_1]',&standard_parameter_names($parmname));
4357: my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription,
4358: (&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value));
1.292 www 4359: if (($uname) && ($udom)) {
1.332 albertel 4360: $output .=
4361: &Apache::loncommon::messagewrapper('Notify User',
4362: $uname,$udom,$title,
4363: $description);
1.292 www 4364: } else {
1.332 albertel 4365: $output .=
4366: &Apache::lonrss::course_blog_link($id,$title,
4367: $description);
1.292 www 4368: }
1.291 www 4369: }
1.332 albertel 4370: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
1.288 albertel 4371: }
1.349 www 4372: if ($env{'form.displayfilter'} eq 'containing') {
4373: my $wholeentry=$about_me_link.':'.
4374: $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
4375: $output;
4376: if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
4377: }
4378: if ($count) {
4379: $r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td>
1.332 albertel 4380: <td rowspan="'.$count.'">'.$about_me_link.
4381: '<br /><tt>'.$parmlog{$id}{'exe_uname'}.
4382: ':'.$parmlog{$id}{'exe_udom'}.'</tt>'.
4383: $send_msg_link.'</td>'.$output);
1.349 www 4384: $shown++;
4385: }
1.311 albertel 4386: if (!($env{'form.show'} eq &mt('all')
4387: || $shown<=$env{'form.show'})) { last; }
1.286 www 4388: }
1.301 www 4389: $r->print(&Apache::loncommon::end_data_table());
1.284 www 4390: $r->print(&Apache::loncommon::end_page());
4391: }
4392:
1.355 albertel 4393: sub check_for_course_info {
4394: my $navmap = Apache::lonnavmaps::navmap->new();
4395: return 1 if ($navmap);
4396: return 0;
4397: }
4398:
1.178 raeburn 4399: ##################################################
4400: ##################################################
1.30 www 4401:
1.59 matthew 4402: =pod
4403:
1.83 bowersj2 4404: =item * handler
1.59 matthew 4405:
4406: Main handler. Calls &assessparms and &crsenv subroutines.
4407:
4408: =cut
1.376 albertel 4409:
1.59 matthew 4410: ##################################################
4411: ##################################################
1.259 banghart 4412:
1.30 www 4413: sub handler {
1.43 albertel 4414: my $r=shift;
1.30 www 4415:
1.376 albertel 4416: &reset_caches();
4417:
1.43 albertel 4418: if ($r->header_only) {
1.126 www 4419: &Apache::loncommon::content_type($r,'text/html');
1.43 albertel 4420: $r->send_http_header;
4421: return OK;
4422: }
1.193 albertel 4423: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.205 www 4424: ['action','state',
4425: 'pres_marker',
4426: 'pres_value',
1.206 www 4427: 'pres_type',
1.390 www 4428: 'udom','uname','symb','serial','timebase']);
1.131 www 4429:
1.83 bowersj2 4430:
1.193 albertel 4431: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.194 albertel 4432: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
4433: text=>"Parameter Manager",
1.204 www 4434: faq=>10,
1.324 www 4435: bug=>'Instructor Interface',
4436: help => 'Parameter_Manager'});
1.203 www 4437:
1.30 www 4438: # ----------------------------------------------------- Needs to be in a course
1.194 albertel 4439: my $parm_permission =
4440: (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
1.190 albertel 4441: &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
1.193 albertel 4442: $env{'request.course.sec'}));
1.355 albertel 4443: my $exists = &check_for_course_info();
4444:
4445: if ($env{'request.course.id'} && $parm_permission && $exists) {
1.193 albertel 4446:
4447: # Start Page
1.126 www 4448: &Apache::loncommon::content_type($r,'text/html');
1.106 www 4449: $r->send_http_header;
1.30 www 4450:
1.203 www 4451:
1.193 albertel 4452: #
4453: # Main switch on form.action and form.state, as appropriate
4454: #
4455: # Check first if coming from someone else headed directly for
4456: # the table mode
4457: if ((($env{'form.command'} eq 'set') && ($env{'form.url'})
4458: && (!$env{'form.dis'})) || ($env{'form.symb'})) {
1.324 www 4459: &Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters',
4460: text=>"Problem Parameters"});
1.193 albertel 4461: &assessparms($r);
4462:
4463: } elsif (! exists($env{'form.action'})) {
4464: $r->print(&header());
1.298 albertel 4465: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Manager'));
1.193 albertel 4466: &print_main_menu($r,$parm_permission);
4467: } elsif ($env{'form.action'} eq 'crsenv' && $parm_permission) {
1.194 albertel 4468: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=crsenv',
4469: text=>"Course Environment"});
1.193 albertel 4470: &crsenv($r);
4471: } elsif ($env{'form.action'} eq 'setoverview' && $parm_permission) {
1.194 albertel 4472: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4473: text=>"Overview Mode"});
1.121 www 4474: &overview($r);
1.334 banghart 4475: } elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) {
4476: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4477: text=>"Add Metadata Field"});
4478: &addmetafield($r);
1.340 banghart 4479: } elsif ($env{'form.action'} eq 'ordermetadata' && $parm_permission) {
4480: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata',
4481: text=>"Add Metadata Field"});
4482: &order_meta_fields($r);
1.259 banghart 4483: } elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) {
4484: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta',
4485: text=>"Restrict Metadata"});
4486: &setrestrictmeta($r);
1.208 www 4487: } elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) {
4488: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview',
4489: text=>"Overview Mode"});
4490: &newoverview($r);
1.220 www 4491: } elsif ($env{'form.action'} eq 'setdefaults' && $parm_permission) {
4492: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setdefaults',
4493: text=>"Set Defaults"});
4494: &defaultsetter($r);
4495: } elsif ($env{'form.action'} eq 'settable' && $parm_permission) {
1.194 albertel 4496: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.204 www 4497: text=>"Table Mode",
4498: help => 'Course_Setting_Parameters'});
1.121 www 4499: &assessparms($r);
1.284 www 4500: } elsif ($env{'form.action'} eq 'parameterchangelog' && $parm_permission) {
4501: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable',
1.292 www 4502: text=>"Parameter Change Log"});
1.285 albertel 4503: &parm_change_log($r);
1.333 albertel 4504: } elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) {
4505: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters',
4506: text=>"Clean Parameters"});
4507: &clean_parameters($r);
1.390 www 4508: } elsif ($env{'form.action'} eq 'dateshift1' && $parm_permission) {
4509: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=dateshift1&timebase='.$env{'form.timebase'},
1.391 www 4510: text=>"Shifting Dates"});
1.390 www 4511: &date_shift_one($r);
4512: } elsif ($env{'form.action'} eq 'dateshift2' && $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_two($r);
1.403 raeburn 4516: } elsif ($env{'form.action'} eq 'categorizecourse' && $parm_permission) {
4517: &assign_course_categories($r);
4518: }
1.43 albertel 4519: } else {
1.1 www 4520: # ----------------------------- Not in a course, or not allowed to modify parms
1.355 albertel 4521: if ($exists) {
4522: $env{'user.error.msg'}=
4523: "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
4524: } else {
4525: $env{'user.error.msg'}=
4526: "/adm/parmset::0:1:Course environment gone, reinitialize the course";
4527: }
1.43 albertel 4528: return HTTP_NOT_ACCEPTABLE;
4529: }
1.376 albertel 4530: &reset_caches();
4531:
1.43 albertel 4532: return OK;
1.1 www 4533: }
4534:
4535: 1;
4536: __END__
4537:
1.59 matthew 4538: =pod
1.38 harris41 4539:
4540: =back
4541:
4542: =cut
1.1 www 4543:
4544:
4545:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>