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