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