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