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