Annotation of loncom/interface/courseprefs.pm, revision 1.103
1.1 raeburn 1: # The LearningOnline Network with CAPA
1.2 raeburn 2: # Handler to set configuration settings for a course
1.1 raeburn 3: #
1.103 ! raeburn 4: # $Id: courseprefs.pm,v 1.102 2022/02/15 04:28:01 raeburn Exp $
1.1 raeburn 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: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: #
28: ###############################################################
29: ##############################################################
30:
1.23 raeburn 31: =pod
32:
33: =head1 NAME
34:
35: courseprefs- Handler to set/modify course configuration
36:
37: =head1 SYNOPSIS
38:
39: courseprefs provides an interface for setting general course configuration
40:
41: =head1 DESCRIPTION
42:
43: This module is used for configuration of a course
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over
48:
49: =item get_allitems()
50:
51: =item print_config_box()
52:
53: =item process_changes()
54:
1.102 raeburn 55: =item process_linkprot()
56:
1.23 raeburn 57: =item get_sec_str()
58:
59: =item check_clone()
60:
61: =item store_changes()
62:
1.102 raeburn 63: =item store_linkprot()
64:
1.23 raeburn 65: =item update_env()
66:
67: =item display_disallowed()
68:
69: =item get_course()
70:
71: =item get_jscript()
72:
73: =item cloners_javascript()
74:
75: =item print_courseinfo()
76:
77: =item new_cloners_dom_row()
78:
79: =item can_modify_catsettings()
80:
81: =item assign_course_categories()
82:
83: =item print_localization()
84:
85: =item get_lang_choices()
86:
87: =item print_feedback()
88:
89: =item user_table()
90:
91: =item select_recipient()
92:
93: =item select_sections()
94:
95: =item print_discussion()
96:
97: =item role_checkboxes()
98:
99: =item print_classlists()
100:
101: =item print_appearance()
102:
103: =item print_grading()
104:
105: =item print_printouts()
106:
107: =item print_spreadsheet()
108:
109: =item print_bridgetasks()
110:
111: =item print_other()
112:
113: =item get_other_items()
114:
115: =item item_table_row_start()
116:
117: =item item_table_row_end()
118:
119: =item yes_no_radio()
120:
121: =item select_from_options()
122:
123: =item make_item_rows()
124:
125: Creates table used to display and set course configuration items.
126:
127: Inputs: $cdom,$items,$ordered,$settings,$rowtotal,$crstype
128: where $cdom is course's domain, $items is HASH ref for current config
129: item, $ordered is ARRAY ref of items to include in row in
130: display order, $settings is HASH ref of current values forrow,
131: $rowtotal is SCALAR ref used to accumulate row count, $crstype is
132: course type.
133:
134: Returns: $datatable
135: HTML mark-up of data table which accumulates individual rows.
136:
137: =item nothidepriv_row()
138:
139: Creates row containing form elements used to display and set
140: whether Domain coordinators who are currently included in
141: advanced course user .db file for a course are to be hidden (e.g.,
142: in syllabus, or from course user lists).
143:
1.80 raeburn 144: Inputs: $cdom,$item,$settings,$crstype,$noedit
1.23 raeburn 145: where $cdom is course domain, item is nothideprivileged, $settings is
146: HASH ref of the current values for nothideprivileged, $crstype is
147: course type (Course or Community).
148:
149: Return: $datatable
150: HTML mark-up for Privileged users (Domain Coordinators) in staff listing.
151:
152: =item print_hdrfmt_row()
153:
154: Creates row containing form elements used to display and set
155: substitution items and text to be used in the header included
156: on printouts.
157:
158: Inputs: $item,$settings
159: where $item is print_header_format, and $settings is a HASH ref
160: of the current values stored for print_header_format.
161:
162: Returns: $output
163: HTML mark-up containing Javascript functions: reOrder() and getIndexByName()
164: used to dynamically update position selectboxes, and HTML table elements
165: for the "Print header format" row.
166:
167: =item position_selector()
168:
169: Creates a select box which can be used to reorder substitutions
170: and text included in a printout header.
171:
172: Inputs: $pos,$num,$maxnum
173: where $pos is current position, $num is the unique identifier,
174: and $maxnum is the total number of items (both substitutions
175: and text in the printout header.
176:
177: Returns: $output
178: HTML mark-up for the selectbox and a hidden form element containing
179: the current position.
180:
181: =item substitution_selector()
182:
183: Creates a combination of select box for choosing an item
184: (student name, course ID or assignment note) to substitute,
185: and a corresponding size limit in the header used for printouts.
186:
187: Inputs: $num,$subst,$limit,$crstype
188: where $num is the unique identifier, $subst is the current
189: substitution (n,c or a, for name, course or note respectively,
190: $limit is the current size limit (integer), and $crstype is
191: course type - course or community.
192:
193: Returns: $output
194: HTML mark-up for selectbox and textbox (separate table cells).
195:
196: =item change_clone()
197:
198: Modifies the list of courses a user can clone (stored
199: in the user's environment.db file), called when a
200: change is made to the list of users allowed to clone
201: a course.
202:
203: Inputs: $action,$cloner
204: where $action is add or drop, and $cloner is identity of
205: user for whom cloning ability is to be changed in course.
206:
207: Returns: nothing
208:
209: =back
210:
211: =cut
212:
213:
1.1 raeburn 214: package Apache::courseprefs;
215:
216: use strict;
217: use Apache::Constants qw(:common :http);
218: use Apache::lonnet;
219: use Apache::loncommon();
220: use Apache::lonhtmlcommon();
221: use Apache::lonconfigsettings;
1.66 raeburn 222: use Apache::lonrelrequtils;
1.36 raeburn 223: use Apache::lonparmset;
1.71 raeburn 224: use Apache::courseclassifier;
1.1 raeburn 225: use Apache::lonlocal;
226: use LONCAPA qw(:DEFAULT :match);
1.103 ! raeburn 227: use Crypt::CBC;
1.1 raeburn 228:
1.66 raeburn 229: my $registered_cleanup;
230: my $modified_courses;
231:
1.1 raeburn 232: sub handler {
233: my $r=shift;
234: if ($r->header_only) {
235: &Apache::loncommon::content_type($r,'text/html');
236: $r->send_http_header;
237: return OK;
238: }
239: my $context = 'course';
240: my $cid = $env{'request.course.id'};
1.66 raeburn 241: my ($cnum,$cdom,$chome) = &get_course($cid);
1.1 raeburn 242: my $crstype = &Apache::loncommon::course_type();
1.80 raeburn 243: my ($parm_permission,$allowed) = &get_permission($cid);
1.1 raeburn 244: my $navmap = Apache::lonnavmaps::navmap->new();
1.80 raeburn 245: if ($allowed && $navmap) {
1.1 raeburn 246: &Apache::loncommon::content_type($r,'text/html');
247: $r->send_http_header;
248: } else {
249: if ($navmap) {
1.9 raeburn 250: if ($crstype eq 'Community') {
251: $env{'user.error.msg'}=
252: "/adm/courseprefs:opa:0:0:Cannot modify community settings";
253: } else {
254: $env{'user.error.msg'}=
255: "/adm/courseprefs:opa:0:0:Cannot modify course settings";
256: }
1.1 raeburn 257: } else {
1.9 raeburn 258: if ($crstype eq 'Community') {
259: $env{'user.error.msg'}=
260: "/adm/courseprefs::0:1:Course environment gone, reinitialize the community";
261: } else {
262: $env{'user.error.msg'}=
263: "/adm/courseprefs::0:1:Course environment gone, reinitialize the course";
264:
265: }
1.1 raeburn 266: }
267: return HTTP_NOT_ACCEPTABLE;
268: }
269:
1.66 raeburn 270: $registered_cleanup=0;
271: @{$modified_courses}=();
272:
1.4 raeburn 273: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
274: ['phase','actions','origin']);
1.1 raeburn 275: &Apache::lonhtmlcommon::clear_breadcrumbs();
1.4 raeburn 276: if ($env{'form.origin'} eq 'params') {
277: &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",
278: text=>"Parameter Manager"});
279: }
1.9 raeburn 280: my ($brtext,$brtitle,$crsinfotext,$crsinfodesc,$crscateg,$crshide);
281: my %lt;
282: if ($crstype eq 'Community') {
283: %lt = (
1.40 www 284: conf => 'Community Settings',
285: edit => 'Edit Community Settings',
1.9 raeburn 286: gens => 'General community settings',
287: idnu => 'Community ID or number',
1.64 raeburn 288: unco => 'Unique code',
1.9 raeburn 289: desc => 'Community Description',
1.24 raeburn 290: ownr => 'Community Owner',
1.25 raeburn 291: cown => 'Community Co-owners',
1.9 raeburn 292: catg => 'Categorize community',
293: excc => 'Exclude from community catalog',
294: clon => 'Users allowed to clone community',
295: rept => 'Replacement titles for standard community roles',
296: time => 'Timezone where the community is located',
297: date => 'Locale used for community calendar',
298: coco => 'Community Content',
299: copo => 'Community Policy',
1.13 bisitz 300: priv => 'Domain Coordinators in community',
1.9 raeburn 301: defd => 'Default dates for member access',
302: stuv => 'Member-viewable membership list options',
303: stul => 'Member agreement needed to be listed',
1.42 www 304: clas => 'Membership and facilitator listing',
1.57 raeburn 305: prus => 'Privileged users (Domain Coordinators) in facilitator listing',
1.9 raeburn 306: defc => 'Default Community Spreadsheet',
307: defs => 'Default User Spreadsheet',
308: seme => 'Send message to member when clicking Done on Tasks'
309: );
310: } else {
311: %lt = (
1.40 www 312: conf => 'Course Settings',
313: edit => 'Edit Course Settings',
1.20 faziophi 314: gens => 'General course settings',
315: idnu => 'Course ID or number',
1.64 raeburn 316: unco => 'Unique code',
1.20 faziophi 317: desc => 'Course Description',
1.55 raeburn 318: cred => 'Student credits',
1.24 raeburn 319: ownr => 'Course Owner',
1.25 raeburn 320: cown => 'Course Co-owners',
1.9 raeburn 321: catg => 'Categorize course',
322: excc => 'Exclude from course catalog',
323: clon => 'Users allowed to clone course',
324: rept => 'Replacement titles for standard course roles',
1.20 faziophi 325: time => 'Timezone in which the course takes place',
326: date => 'Locale used for course calendar',
1.9 raeburn 327: coco => 'Course Content',
328: copo => 'Course Policy',
1.13 bisitz 329: priv => 'Domain Coordinators in course',
1.9 raeburn 330: defd => 'Default dates for student access',
331: stuv => 'Student-viewable classlist options',
332: stul => 'Student agreement needed to be listed',
1.42 www 333: clas => 'Classlists and staff listing',
1.57 raeburn 334: prus => 'Privileged users (Domain Coordinators) in staff listing',
1.56 raeburn 335: prdo => "Domains to check for privileged users (besides course's domain)",
1.9 raeburn 336: defc => 'Default Course Spreadsheet',
337: defs => 'Default Student Spreadsheet',
338: seme => 'Send message to student when clicking Done on Tasks',
339: );
340: }
1.35 raeburn 341: $lt{'lcrv'} = 'Required LON-CAPA version';
1.1 raeburn 342: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/courseprefs',
1.9 raeburn 343: text=>$lt{'conf'}});
1.1 raeburn 344: my $breadcrumbs =
1.9 raeburn 345: &Apache::lonhtmlcommon::breadcrumbs($lt{'edit'});
1.1 raeburn 346:
347: my $phase = 'pickactions';
348: if ( exists($env{'form.phase'}) ) {
349: $phase = $env{'form.phase'};
350: }
351:
1.80 raeburn 352: if (($phase eq 'categorizecourse') && ($parm_permission->{'categorizecourse'})) {
1.9 raeburn 353: &assign_course_categories($r,$crstype);
1.1 raeburn 354: return OK;
355: }
356:
1.80 raeburn 357: if (($phase eq 'releaseinfo') && ($parm_permission->{'releaseinfo'})) {
1.36 raeburn 358: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
359: if ($loncaparev) {
1.66 raeburn 360: if (&display_loncaparev_constraints($r,$navmap,$loncaparev,$crstype)) {
361: push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]);
362: unless ($registered_cleanup) {
363: my $handlers = $r->get_handlers('PerlCleanupHandler');
364: $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]);
365: $registered_cleanup=1;
366: }
367: }
1.36 raeburn 368: return OK;
369: }
370: }
371:
1.1 raeburn 372: my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
1.102 raeburn 373: my %linkprot=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
1.99 raeburn 374: my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1);
1.102 raeburn 375: foreach my $id (keys(%linkprot)) {
376: if (ref($linkprot{$id}) eq 'HASH') {
1.99 raeburn 377: if (ref($ltienc{$id}) eq 'HASH') {
1.102 raeburn 378: $values{'linkprot'}{$id} = { %{$linkprot{$id}}, %{$ltienc{$id}} };
1.99 raeburn 379: } else {
1.102 raeburn 380: $values{'linkprot'}{$id} = $linkprot{$id};
1.99 raeburn 381: }
382: }
383: unless ($phase eq 'process') {
1.102 raeburn 384: if (ref($values{'linkprot'}{$id}) eq 'HASH') {
385: delete($values{'linkprot'}{$id}{'secret'});
1.99 raeburn 386: }
387: }
388: }
1.102 raeburn 389: if ($linkprot{'lock'}) {
390: delete($linkprot{'lock'});
1.93 raeburn 391: }
1.1 raeburn 392: my @prefs_order = ('courseinfo','localization','feedback','discussion',
393: 'classlists','appearance','grading','printouts',
1.102 raeburn 394: 'menuitems','linkprot','spreadsheet','bridgetasks',
1.93 raeburn 395: 'lti','other');
1.1 raeburn 396:
397: my %prefs = (
398: 'courseinfo' =>
1.9 raeburn 399: { text => $lt{'gens'},
1.44 www 400: help => 'Course_Prefs_General',
1.35 raeburn 401: ordered => ['owner','co-owners','loncaparev','description',
1.64 raeburn 402: 'clonedfrom','courseid','uniquecode','categories',
1.88 raeburn 403: 'hidefromcat','syllabus','cloners','url',
1.64 raeburn 404: 'rolenames'],
1.3 raeburn 405: itemtext => {
1.25 raeburn 406: 'owner' => $lt{'ownr'},
407: 'co-owners' => $lt{'cown'},
408: 'description' => $lt{'desc'},
409: 'courseid' => $lt{'idnu'},
1.64 raeburn 410: 'uniquecode' => $lt{'unco'},
1.25 raeburn 411: 'categories' => $lt{'catg'},
412: 'hidefromcat' => $lt{'excc'},
413: 'cloners' => $lt{'clon'},
1.88 raeburn 414: 'syllabus' => 'Syllabus status',
1.25 raeburn 415: 'url' => 'Top Level Map',
416: 'rolenames' => $lt{'rept'},
1.35 raeburn 417: 'loncaparev' => $lt{'lcrv'},
1.63 raeburn 418: 'clonedfrom' => 'Cloned from',
1.3 raeburn 419: },
1.1 raeburn 420: },
421: 'localization' =>
1.42 www 422: { text => 'Language and time localization',
1.44 www 423: help => 'Course_Prefs_Language',
1.1 raeburn 424: ordered => ['languages','timezone','datelocale'],
1.3 raeburn 425: itemtext => {
1.20 faziophi 426: languages => 'Languages used',
1.9 raeburn 427: timezone => $lt{'time'},
428: datelocale => $lt{'date'},
1.3 raeburn 429: },
1.1 raeburn 430: },
431: 'feedback' =>
1.20 faziophi 432: { text => 'Feedback messages',
1.44 www 433: help => 'Course_Prefs_Feedback',
1.1 raeburn 434: header => [{col1 => 'Questions about:',
1.20 faziophi 435: col2 => 'Recipients'}],
1.3 raeburn 436: ordered => ['question.email','comment.email','policy.email'],
437: itemtext => {
438: 'question.email' => 'Resource Content',
1.9 raeburn 439: 'comment.email' => $lt{'coco'},
440: 'policy.email' => $lt{'copo'},
1.3 raeburn 441: },
1.1 raeburn 442: },
443: 'discussion' =>
444: { text => 'Discussion and Chat',
1.44 www 445: help => 'Course_Prefs_Discussions',
1.31 raeburn 446: ordered => ['pch.roles.denied','pch.users.denied',
1.77 raeburn 447: 'pac.roles.denied','pac.users.denied',
1.31 raeburn 448: 'plc.roles.denied','plc.users.denied',
1.1 raeburn 449: 'allow_limited_html_in_feedback',
1.50 raeburn 450: 'allow_discussion_post_editing',
451: 'discussion_post_fonts'],
1.3 raeburn 452: itemtext => {
1.31 raeburn 453: 'pch.roles.denied' => 'No Resource Discussion',
454: 'pch.users.denied' => 'No Resource Discussion',
455: 'plc.roles.denied' => 'No Chat room use',
456: 'plc.users.denied' => 'No Chat room use',
1.77 raeburn 457: 'pac.roles.denied' => 'No Anonymous Resource Discussion',
458: 'pac.users.denied' => 'No Anonymous Resource Discussion',
1.20 faziophi 459: allow_limited_html_in_feedback => 'Allow limited HTML in discussion',
460: allow_discussion_post_editing => 'Users can edit/delete own discussion posts',
1.77 raeburn 461: discussion_post_fonts => 'Discussion post fonts based on likes/unlikes',
1.3 raeburn 462: },
1.1 raeburn 463: },
464: 'classlists' =>
1.9 raeburn 465: { text => $lt{'clas'},
1.44 www 466: help => 'Course_Prefs_Classlists',
1.1 raeburn 467: header => [{col1 => 'Type',
1.9 raeburn 468: col2 => $lt{'defd'}},
1.1 raeburn 469: {col1 => 'Setting',
1.9 raeburn 470: col2 => $lt{'priv'}},
1.1 raeburn 471: {col1 => 'Setting',
1.9 raeburn 472: col2 => $lt{'stuv'}}],
1.1 raeburn 473: ordered => ['default_enrollment_start_date',
474: 'default_enrollment_end_date',
1.55 raeburn 475: 'defaultcredits',
1.56 raeburn 476: 'nothideprivileged','checkforpriv',
477: 'student_classlist_view',
1.26 raeburn 478: 'student_classlist_opt_in','student_classlist_portfiles'],
1.3 raeburn 479: itemtext => {
480: default_enrollment_start_date => 'Start date',
481: default_enrollment_end_date => 'End date',
1.57 raeburn 482: nothideprivileged => $lt{'prus'},
1.56 raeburn 483: checkforpriv => $lt{'prdo'},
1.9 raeburn 484: student_classlist_view => $lt{'stuv'},
1.26 raeburn 485: student_classlist_opt_in => $lt{'stul'},
1.3 raeburn 486: student_classlist_portfiles => 'Include link to accessible portfolio files',
1.55 raeburn 487: defaultcredits => $lt{'cred'},
1.3 raeburn 488: },
1.1 raeburn 489: },
490: 'appearance' =>
1.20 faziophi 491: { text => 'Display of resources ',
1.44 www 492: help => 'Course_Prefs_Display',
1.1 raeburn 493: ordered => ['default_xml_style','pageseparators',
494: 'disable_receipt_display','texengine',
1.95 raeburn 495: 'tthoptions','uselcmath','usejsme','inline_chem'],
1.3 raeburn 496: itemtext => {
1.17 faziophi 497: default_xml_style => 'Default XML style file',
1.20 faziophi 498: pageseparators => 'Visibly Separate Items on Pages',
499: disable_receipt_display => 'Disable display of problem receipts',
500: texengine => 'Force use of a specific math rendering engine',
1.3 raeburn 501: tthoptions => 'Default set of options to pass to tth/m when converting TeX',
1.69 raeburn 502: uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
503: usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
1.95 raeburn 504: inline_chem => 'Chemical reaction response uses inline preview, not pop-up',
1.3 raeburn 505: },
1.1 raeburn 506: },
507: 'grading' =>
508: { text => 'Grading',
1.44 www 509: help => 'Course_Prefs_Grading',
1.1 raeburn 510: ordered => ['grading','rndseed',
511: 'receiptalg','disablesigfigs'],
1.3 raeburn 512: itemtext => {
1.20 faziophi 513: grading => 'Grading',
514: rndseed => 'Randomization algorithm used',
515: receiptalg => 'Receipt algorithm used',
516: disablesigfigs => 'Disable checking of Significant Figures',
1.3 raeburn 517: },
518:
1.1 raeburn 519: },
520: 'printouts' =>
1.20 faziophi 521: { text => 'Printout generation',
1.44 www 522: help => 'Course_Prefs_Printouts',
1.1 raeburn 523: ordered => ['problem_stream_switch','suppress_tries',
524: 'default_paper_size','print_header_format',
1.14 raeburn 525: 'disableexampointprint','canuse_pdfforms'],
1.3 raeburn 526: itemtext => {
527: problem_stream_switch => 'Allow problems to be split over pages',
528: suppress_tries => 'Suppress number of tries in printing',
529: default_paper_size => 'Default paper type',
530: print_header_format => 'Print header format',
1.51 bisitz 531: disableexampointprint => 'Disable automatically printing point values on bubblesheet exams',
1.14 raeburn 532: canuse_pdfforms => 'Users can print problems as PDF forms and upload later for grading',
1.3 raeburn 533: },
1.1 raeburn 534: },
535: 'spreadsheet' =>
536: { text => 'Spreadsheets',
1.44 www 537: help => 'Course_Prefs_Spreadsheet',
1.1 raeburn 538: ordered => ['spreadsheet_default_classcalc',
539: 'spreadsheet_default_studentcalc',
540: 'spreadsheet_default_assesscalc','hideemptyrows'],
1.3 raeburn 541: itemtext => {
1.9 raeburn 542: spreadsheet_default_classcalc => $lt{'defc'},
543: spreadsheet_default_studentcalc => $lt{'defs'},
1.3 raeburn 544: spreadsheet_default_assesscalc => 'Default Assessment Spreadsheet',
545: hideemptyrows => 'Hide Empty Rows in Spreadsheets',
546: },
1.1 raeburn 547: },
548: 'bridgetasks' =>
549: { text => 'Bridge tasks',
1.44 www 550: help => 'Course_Prefs_Bridgetasks',
1.1 raeburn 551: ordered => ['task_messages','task_grading',
552: 'suppress_embed_prompt'],
1.3 raeburn 553: itemtext => {
1.9 raeburn 554: task_messages => $lt{'seme'},
1.3 raeburn 555: task_grading => 'Bridge Task grading by instructors and TAs in sections' ,
1.5 raeburn 556: suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio',
1.3 raeburn 557: },
1.1 raeburn 558: },
1.87 raeburn 559: 'lti' =>
560: {
561: text => 'LTI provider settings',
562: help => 'Course_Prefs_LTIProvider',
563: ordered => ['lti.override','lti.topmenu','lti.inlinemenu','lti.lcmenu'],
564: itemtext => {
565: 'lti.override' => 'Override domain defaults',
566: 'lti.topmenu' => 'Display LON-CAPA page header',
567: 'lti.inlinemenu' => 'Display LON-CAPA inline menu',
568: 'lti.lcmenu' => 'Menu items',
569: },
570: },
1.91 raeburn 571: 'menuitems' =>
572: {
573: text => 'Menu display',
574: help => 'Course_Prefs_Menus',
575: header => [{col1 => 'Default Menu',
576: col2 => 'Value',},
577: {col1 => 'Menu collections',
578: col2 => 'Settings',
579: }],
580: ordered => ['menudefault','menucollections'],
581: itemtext => {
582: menudefault => 'Choose default collection of menu items for course',
583: menucollections => 'Menu collections',
584: },
585: },
1.102 raeburn 586: 'linkprot' =>
1.93 raeburn 587: {
588: text => 'Link protection',
589: help => 'Course_Prefs_Linkprotection',
590: header => [{col1 => 'Item',
591: col2 => 'Settings',
592: }],
593: },
1.1 raeburn 594: 'other' =>
595: { text => 'Other settings',
1.44 www 596: help => 'Course_Prefs_Other',
1.1 raeburn 597: header => [ {col1 => 'Item',
598: col2 => 'Value',
599: }],
600: },
601: );
1.80 raeburn 602: if (($phase eq 'process') && ($parm_permission->{'process'})) {
1.3 raeburn 603: my @allitems = &get_allitems(%prefs);
1.1 raeburn 604: &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
1.3 raeburn 605: \@prefs_order,\%prefs,\%values,
1.80 raeburn 606: $cnum,undef,\@allitems,
607: 'coursepref',$parm_permission);
608: } elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
1.91 raeburn 609: my $noedit;
610: if (ref($parm_permission) eq 'HASH') {
611: unless ($parm_permission->{'process'}) {
612: $noedit = 1;
613: }
614: }
615: my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
1.3 raeburn 616: my @allitems = &get_allitems(%prefs);
1.1 raeburn 617: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
1.99 raeburn 618: \@prefs_order,\%prefs,\%values,$cnum,$jscript,\@allitems,$crstype,
1.80 raeburn 619: 'coursepref',$parm_permission);
1.1 raeburn 620: } else {
621: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
1.80 raeburn 622: \@prefs_order,\%prefs,
623: 'coursepref',$parm_permission);
1.1 raeburn 624: }
625: return OK;
626: }
627:
1.80 raeburn 628: sub get_permission {
629: my ($cid) = @_;
630: my %permission;
631: my $allowed = 0;
632: return (\%permission,$allowed) unless ($cid);
633: if (&Apache::lonnet::allowed('opa',$cid)) {
634: %permission= (
635: 'pickactions' => 1,
636: 'categorizecourse' => 1,
637: 'releaseinfo' => 1,
638: 'process' => 1,
639: 'display' => 1,
640: );
641: } elsif (&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) {
642: %permission = (
643: 'pickactions' => 1,
644: 'releaseinfo' => 1,
645: 'display' => 1,
646: );
647: }
648: foreach my $perm (values(%permission)) {
649: if ($perm) { $allowed=1; last; }
650: }
651: return (\%permission,$allowed);
652: }
653:
1.3 raeburn 654: sub get_allitems {
655: my (%prefs) = @_;
656: my @allitems;
657: foreach my $item (keys(%prefs)) {
658: if (ref($prefs{$item}) eq 'HASH') {
659: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
660: push(@allitems,@{$prefs{$item}{'ordered'}});
661: if ($item eq 'feedback') {
662: push(@allitems,(map { $_.'.text'; } @{$prefs{$item}{'ordered'}}));
663: }
664: }
665: }
666: }
667: return @allitems;
668: }
669:
1.1 raeburn 670: sub print_config_box {
1.99 raeburn 671: my ($r,$cdom,$cnum,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
1.1 raeburn 672: my $ordered = $item->{'ordered'};
1.3 raeburn 673: my $itemtext = $item->{'itemtext'};
1.80 raeburn 674: my $noedit;
675: if (ref($parm_permission) eq 'HASH') {
676: unless ($parm_permission->{'process'}) {
677: $noedit = 1;
678: }
679: }
1.1 raeburn 680: my $rowtotal = 0;
681: my $output =
1.45 www 682: '<table class="LC_nested_outer">
683: <tr>
684: <th align="left" valign="middle"><span class="LC_nobreak" style="font-size: larger;" >'.
1.52 raeburn 685: &mt($item->{text});
686: if ($item->{'help'}) {
1.53 raeburn 687: $output .= ' '.
1.52 raeburn 688: &Apache::loncommon::help_open_topic($item->{'help'});
689: }
690: $output .= '</span></th>'."\n".
691: '</tr>';
1.91 raeburn 692: if (($action eq 'feedback') || ($action eq 'classlists') || ($action eq 'menuitems')) {
1.1 raeburn 693: $output .= '
1.45 www 694: <tr>
695: <td>
1.18 faziophi 696: <table class="LC_nested">';
697: if (exists $item->{'header'}->[0]->{'col1'} ||
698: exists $item->{'header'}->[0]->{'col2'}) {
699: $output .= '
700: <tr class="LC_info_row">
1.56 raeburn 701: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
702: if ($action eq 'feedback') {
703: $output .= '
704: <td class="LC_right_item" colspan="2">';
705: } else {
706: $output .= '
707: <td class="LC_right_item">';
708: }
709: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 710: </tr>';
711: }
1.1 raeburn 712: $rowtotal ++;
713: if ($action eq 'feedback') {
1.80 raeburn 714: $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 715: } elsif ($action eq 'classlists') {
1.80 raeburn 716: $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.91 raeburn 717: } elsif ($action eq 'menuitems') {
718: $output .= &print_menuitems('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 719: }
720: $output .= '
721: </table>
1.45 www 722: </td>
723: </tr>
724: <tr>
725: <td>
1.1 raeburn 726: <table class="LC_nested">
727: <tr class="LC_info_row">
728: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
1.56 raeburn 729: if ($action eq 'classlists') {
730: $output .= '
731: <td class="LC_right_item" colspan="2">';
732: } else {
733: $output .= '
734: <td class="LC_right_item">';
735: }
736: $output .= &mt($item->{'header'}->[1]->{'col2'}).'</td>
1.1 raeburn 737: </tr>';
738: if ($action eq 'classlists') {
1.80 raeburn 739: $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit).
1.1 raeburn 740: '
741: </table>
1.45 www 742: </td>
743: </tr>
744: <tr>
745: <td>
1.18 faziophi 746: <table class="LC_nested">';
1.43 www 747: if (exists $item->{'header'}->[2]->{'col1'} ||
748: exists $item->{'header'}->[2]->{'col2'}) {
1.18 faziophi 749: $output .= '
750: <tr class="LC_info_row">
1.43 www 751: <td class="LC_left_item">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
752: <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
1.18 faziophi 753: </tr>';
754: }
1.1 raeburn 755: }
756: } else {
757: $output .= '
1.45 www 758: <tr>
759: <td>
1.18 faziophi 760: <table class="LC_nested">';
761: if (exists $item->{'header'}->[0]->{'col1'} ||
762: exists $item->{'header'}->[0]->{'col2'}) {
763: $output .= '
764: <tr class="LC_info_row">
1.56 raeburn 765: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>';
766: if (($action eq 'courseinfo') || ($action eq 'localization') ||
767: ($action eq 'print_discussion')) {
768: $output .= '<td class="LC_right_item" valign="top" colspan="2">';
769: } else {
770: $output .= '<td class="LC_right_item" valign="top">';
771: }
772: $output .= &mt($item->{'header'}->[0]->{'col2'}).'</td>
1.18 faziophi 773: </tr>';
774: }
1.1 raeburn 775: }
776: $rowtotal ++;
777: if ($action eq 'courseinfo') {
1.80 raeburn 778: $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 779: } elsif ($action eq 'localization') {
1.80 raeburn 780: $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 781: } elsif ($action eq 'feedback') {
1.80 raeburn 782: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.1 raeburn 783: } elsif ($action eq 'discussion') {
1.80 raeburn 784: $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit);
1.52 raeburn 785: } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) {
1.80 raeburn 786: $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 787: } elsif ($action eq 'appearance') {
1.80 raeburn 788: $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 789: } elsif ($action eq 'grading') {
1.80 raeburn 790: $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 791: } elsif ($action eq 'printouts') {
1.80 raeburn 792: $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 793: } elsif ($action eq 'spreadsheet') {
1.80 raeburn 794: $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.1 raeburn 795: } elsif ($action eq 'bridgetasks') {
1.80 raeburn 796: $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.87 raeburn 797: } elsif ($action eq 'lti') {
798: $output .= &print_lti($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
1.91 raeburn 799: } elsif ($action eq 'menuitems') {
800: $output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit);
1.102 raeburn 801: } elsif ($action eq 'linkprot') {
802: $output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit,'course');
1.1 raeburn 803: } elsif ($action eq 'other') {
1.80 raeburn 804: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit);
1.1 raeburn 805: }
806: $output .= '
807: </table>
1.45 www 808: </td>
809: </tr>
810: </table><br />';
1.1 raeburn 811: return ($output,$rowtotal);
812: }
813:
814: sub process_changes {
1.93 raeburn 815: my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_;
1.102 raeburn 816: my (%newvalues,$errors);
1.3 raeburn 817: if (ref($item) eq 'HASH') {
818: if (ref($changes) eq 'HASH') {
819: my @ordered;
820: if ($action eq 'other') {
821: @ordered = &get_other_items($cdom,$values,$allitems);
822: if ($env{'form.newp_name'} ne '') {
823: my $newp = $env{'form.newp_name'};
824: if ($env{'form.newp_value'} ne '') {
825: if (ref($allitems) eq 'ARRAY') {
826: unless ((grep(/^\Q$newp\E$/,@ordered)) ||
827: (grep(/^\Q$newp\E$/,@{$allitems}))) {
828: $changes->{$newp} = $env{'form.newp_value'};
829: }
830: }
831: }
832: }
1.102 raeburn 833: } elsif ($action eq 'linkprot') {
1.99 raeburn 834: if (ref($values->{$action}) eq 'HASH') {
835: foreach my $id (keys(%{$values->{$action}})) {
1.93 raeburn 836: if ($id =~ /^\d+$/) {
837: push(@ordered,$id);
838: }
839: }
840: }
841: @ordered = sort { $a <=> $b } @ordered;
842: if (($env{'form.linkprot_add'}) && ($env{'form.linkprot_maxnum'} =~ /^\d+$/)) {
843: push(@ordered,$env{'form.linkprot_maxnum'});
844: }
1.3 raeburn 845: } elsif (ref($item->{'ordered'}) eq 'ARRAY') {
1.49 raeburn 846: if ($action eq 'courseinfo') {
847: my ($can_toggle_cat,$can_categorize) =
848: &can_modify_catsettings($cdom,$crstype);
849: foreach my $entry (@{$item->{'ordered'}}) {
850: next if (($entry eq 'hidefromcat') &&
851: (!$can_toggle_cat));
852: next if (($entry eq 'categories') &&
853: (!$can_categorize));
854: next if (($entry eq 'loncaparev') ||
1.63 raeburn 855: ($entry eq 'owner') ||
1.88 raeburn 856: ($entry eq 'clonedfrom') ||
857: ($entry eq 'syllabus'));
1.49 raeburn 858: push(@ordered,$entry);
859: }
1.55 raeburn 860: } elsif ($action eq 'classlists') {
861: foreach my $entry (@{$item->{'ordered'}}) {
862: next if ($entry eq 'defaultcredits');
863: push(@ordered,$entry);
864: }
1.49 raeburn 865: } else {
866: @ordered = @{$item->{'ordered'}};
867: }
1.3 raeburn 868: }
869: if (@ordered > 0) {
870: if ($action eq 'feedback') {
871: foreach my $entry (@ordered) {
872: my $userstr = '';
873: my $total = $env{'form.'.$entry.'_total'};
874: if ($total) {
875: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
876: for (my $i=0; $i<$total; $i++) {
877: unless (grep(/^$i$/,@deletes)) {
878: $userstr .= $env{'form.'.$entry.'_user_'.$i}.
879: &get_sec_str($entry,$i).',';
880: }
881: }
882: } else {
883: $total = 0;
884: }
885: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
886: my $uname = $env{'form.'.$entry.'_uname_'.$total};
887: my $udom = $env{'form.'.$entry.'_udom_'.$total};
888: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
889: $userstr =~ s/,$//;
890: $disallowed->{'feedback'}{$entry} = $uname.':'.$udom;
891: } else {
892: $userstr .= $uname.':'.$udom.&get_sec_str($entry,$total);
893: }
894: } else {
895: $userstr =~ s/,$//;
896: }
897: $newvalues{$entry} = $userstr;
898: if ($newvalues{$entry} ne $values->{$entry}) {
899: $changes->{$entry} = $newvalues{$entry};
900: }
901: my $ext_entry = $entry.'.text';
902: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
903: if ($newvalues{$ext_entry} ne $values->{$ext_entry}) {
904: $changes->{$ext_entry} = $newvalues{$ext_entry};
905: }
906: }
1.91 raeburn 907: } elsif ($action eq 'menuitems') {
908: my (%current,@colls);
909: my $next = 1;
910: if ($values->{'menucollections'}) {
911: foreach my $item (split(/;/,$values->{'menucollections'})) {
912: my ($num,$value) = split(/\%/,$item);
913: if ($num =~ /^\d+$/) {
914: unless (grep(/^$num$/,@colls)) {
915: push(@colls,$num);
916: }
917: my @entries = split(/\&/,$value);
918: foreach my $entry (@entries) {
919: my ($name,$fields) = split(/=/,$entry);
920: $current{$num}{$name} = $fields;
921: }
922: }
923: }
924: }
925: if (@colls) {
926: @colls = sort { $a <=> $b } @colls;
927: $next += $colls[-1];
928: }
929: if ($env{'form.menucollections_add'} eq $next) {
930: push(@colls,$next);
931: }
932: my $currdef = $values->{'menudefault'};
933: my $possdef = $env{'form.menudefault'};
934: if (($possdef =~ /^\d+$/) && (grep(/^$possdef$/,@colls))) {
1.92 raeburn 935: if ($currdef ne $possdef) {
1.91 raeburn 936: $changes->{'menudefault'} = $possdef;
937: }
1.92 raeburn 938: } elsif ($currdef) {
1.91 raeburn 939: $changes->{'menudefault'} = '';
940: }
941: my $menucoll;
942: if (@colls) {
943: my ($ordered,$cats) = &menuitems_categories();
944: my %shortcats = &menuitems_abbreviations();
945: foreach my $num (@colls) {
946: my ($entry,%include);
947: map { $include{$_}= 1; } &Apache::loncommon::get_env_multiple('form.menucollections_'.$num);
948: foreach my $item (@{$ordered}) {
949: if ($item eq 'shown') {
950: foreach my $type (@{$cats->{$item}}) {
951: $entry .= $type.'=';
952: if ($include{$type}) {
953: $entry .= 'y';
954: } else {
955: $entry .= 'n';
956: }
957: $entry .= '&';
958: }
959: } else {
960: $entry .= $shortcats{$item}.'=';
961: foreach my $type (@{$cats->{$item}}) {
962: if ($include{$type}) {
963: $entry .= $type.',';
964: }
965: }
966: $entry =~ s/,$//;
967: $entry .= '&';
968: }
969: }
970: $entry =~ s/\&$//;
971: if ($menucoll) {
972: $menucoll .= ';';
973: }
974: $menucoll .= $num.'%'.$entry;
975: }
976: if ($menucoll ne $values->{'menucollections'}) {
977: $changes->{'menucollections'} = $menucoll;
978: }
979: } elsif ($values->{'menucollections'}) {
980: $changes->{'menucollections'} = '';
981: }
1.102 raeburn 982: } elsif ($action eq 'linkprot') {
983: if (ref($values) eq 'HASH') {
984: $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course');
1.93 raeburn 985: }
1.3 raeburn 986: } else {
987: foreach my $entry (@ordered) {
988: if ($entry eq 'cloners') {
989: if ($env{'form.cloners_all'}) {
990: $newvalues{$entry} = '*';
991: } else {
992: my @clonedoms;
993: if (exists($env{'form.cloners_activate'})) {
994: my $actnum = $env{'form.cloners_activate'};
1.71 raeburn 995: if ($actnum ne '-1') {
1.33 raeburn 996: if ($env{'form.cloners_dom_'.$actnum} ne '') {
997: my $clonedom = $env{'form.cloners_dom_'.$actnum};
1.3 raeburn 998: if (&check_clone($clonedom,$disallowed) eq 'ok') {
999: $newvalues{$entry} = '*:'.$clonedom;
1000: push(@clonedoms,$newvalues{$entry});
1001: }
1002: }
1003: }
1004: } else {
1005: my $num = $env{'form.cloners_total'};
1006: my @deletes =
1007: &Apache::loncommon::get_env_multiple('form.cloners_delete');
1008: for (my $i=0; $i<$num; $i++) {
1009: if (!grep(/^$i$/,@deletes)) {
1010: my $clonedom = $env{'form.cloners_dom_'.$i};
1011: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1012: if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) {
1.71 raeburn 1013: push(@clonedoms,'*:'.$clonedom);
1.3 raeburn 1014: }
1015: }
1016: }
1017: }
1018: if (@clonedoms) {
1019: $newvalues{$entry}=join(',',@clonedoms);
1020: }
1021: }
1022: if ($env{'form.cloners_newdom'} ne '') {
1023: my $clonedom = $env{'form.cloners_newdom'};
1024: if (&check_clone($clonedom,$disallowed) eq 'ok') {
1025: my $newdom = '*:'.$env{'form.cloners_newdom'};
1.93 raeburn 1026: if (@clonedoms) {
1.3 raeburn 1027: if (!grep(/^\Q$newdom\E$/,@clonedoms)) {
1028: $newvalues{$entry} .= ','.$newdom;
1029: }
1030: } else {
1031: $newvalues{$entry} = $newdom;
1032: }
1033: }
1034: }
1035: if ($env{'form.'.$entry} ne '') {
1036: my @cloners = split(',',$env{'form.'.$entry});
1037: my @okcloners;
1038: foreach my $cloner (@cloners) {
1.23 raeburn 1039: $cloner =~ s/^\s+//;
1040: $cloner =~ s/\s+$//;
1041: unless ($cloner eq '') {
1042: my ($uname,$udom) = split(':',$cloner);
1043: if (&check_clone($udom,$disallowed,$uname) eq 'ok') {
1044: if (!grep(/^\Q$cloner\E$/,@okcloners)) {
1045: push(@okcloners,$cloner);
1046: }
1.3 raeburn 1047: }
1048: }
1049: }
1050: if (@okcloners) {
1051: my $okclonestr = join(',',@okcloners);
1052: if ($newvalues{$entry} ne '') {
1053: $newvalues{$entry} .= ','.$okclonestr;
1054: } else {
1055: $newvalues{$entry} = $okclonestr;
1056: }
1057: }
1058: }
1.71 raeburn 1059: if (ref($values) eq 'HASH') {
1060: my (@code_order,%codedefaults);
1061: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
1062: \@code_order);
1063: my $clonebycode;
1064: if ($env{'form.cloners_instcode'}) {
1065: if (@code_order > 0) {
1066: my @standardnames = &Apache::loncommon::get_standard_codeitems();
1067: my %local_to_standard;
1068: for (my $i=0; $i<@code_order; $i++) {
1069: $local_to_standard{$code_order[$i]} = $standardnames[$i];
1070: }
1071: foreach my $item (@code_order) {
1072: my $key = $local_to_standard{$item};
1073: if ($key ne '') {
1074: if ($env{'form.'.$key}) {
1075: $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&';
1076: }
1077: }
1078: }
1079: $clonebycode =~ s/\&$//;
1080: }
1081: }
1082: if ($clonebycode) {
1083: if ($newvalues{$entry}) {
1084: $newvalues{$entry} .= ','.$clonebycode;
1085: } else {
1086: $newvalues{$entry} = $clonebycode;
1087: }
1088: }
1089: }
1.3 raeburn 1090: }
1091: if (ref($disallowed) eq 'HASH') {
1092: if (ref($disallowed->{'cloners'}) eq 'HASH') {
1093: foreach my $key (keys(%{$disallowed->{'cloners'}})) {
1094: $disallowed->{'cloners'}{$key} =~ s/,$//;
1095: }
1096: }
1097: }
1.25 raeburn 1098: } elsif ($entry eq 'co-owners') {
1099: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1100: my $coowners = $values->{'internal.co-owners'};
1101: my @currcoown;
1102: if ($coowners) {
1103: @currcoown = split(',',$coowners);
1104: }
1105: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1106: my $autocoowner;
1107: if (($crstype eq 'Course') &&
1108: ($values->{'internal.coursecode'})) {
1109: my %domconf =
1110: &Apache::lonnet::get_dom('configuration',['autoenroll'],$cdom);
1111: if (ref($domconf{'autoenroll'}) eq 'HASH') {
1112: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
1113: }
1114: }
1.96 raeburn 1115: if ($autocoowner) {
1116: $newvalues{'co-owners'} = $values->{'internal.co-owners'};
1117: } else {
1.25 raeburn 1118: my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
1119: my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
1120: my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
1121: if (@invitecoowners) {
1122: push(@pendingcoowners,@invitecoowners);
1123: }
1124: $newvalues{'pendingco-owners'} = join(',',sort(@pendingcoowners));
1125: $newvalues{'co-owners'} = join(',',sort(@keepcoowners));
1126: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1127: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1128: push(@{$changes->{$entry}{'changed'}},'co-owners');
1129: }
1130: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1131: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1132: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1133: }
1134: }
1135: } else {
1136: my (@newpending,@newcoown);
1137: my $uname = $env{'user.name'};
1138: my $udom = $env{'user.domain'};
1139: my $pendingcoowners = $values->{'internal.pendingco-owners'};
1140: my @pendingcoown = split(',',$pendingcoowners);
1.90 raeburn 1141: if ($env{'form.pending_coowner'}) {
1.25 raeburn 1142: foreach my $item (@pendingcoown) {
1143: unless ($item eq $uname.':'.$udom) {
1144: push(@newpending,$item);
1145: }
1146: }
1147: @newcoown = @currcoown;
1.90 raeburn 1148: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 1149: unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
1150: push(@newcoown,$uname.':'.$udom);
1151: }
1152: }
1.90 raeburn 1153: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 1154: foreach my $item (@currcoown) {
1155: unless ($item eq $uname.':'.$udom) {
1156: push(@newcoown,$item);
1157: }
1158: }
1159: if ($pendingcoowners ne '') {
1160: @newpending = @pendingcoown;
1161: }
1.96 raeburn 1162: } else {
1163: @newcoown = @currcoown;
1.25 raeburn 1164: }
1165: $newvalues{'pendingco-owners'} = join(',',sort(@newpending));
1166: $newvalues{'co-owners'} = join(',',sort(@newcoown));
1167: if ($newvalues{'co-owners'} ne $values->{'internal.co-owners'}) {
1168: $changes->{$entry}{'co-owners'} = $newvalues{'co-owners'};
1169: push(@{$changes->{$entry}{'changed'}},'co-owners');
1170: }
1171: if ($newvalues{'pendingco-owners'} ne $values->{'internal.pendingco-owners'}) {
1172: $changes->{$entry}{'pendingco-owners'} = $newvalues{'pendingco-owners'};
1173: push(@{$changes->{$entry}{'changed'}},'pendingco-owners');
1174: }
1175: }
1.3 raeburn 1176: } elsif ($entry =~ /^default_enrollment_(start|end)_date$/) {
1177: $newvalues{$entry}=&Apache::lonhtmlcommon::get_date_from_form($entry);
1178: } elsif ($entry eq 'rolenames') {
1179: my %adv_roles =
1180: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
1.9 raeburn 1181: my @stds;
1182: if ($crstype eq 'Community') {
1183: @stds = ('co');
1184: } else {
1185: @stds = ('cc');
1186: }
1187: push(@stds,('in','ta','ep','ad','st'));
1.3 raeburn 1188: my (@replacements,@regulars);
1189: foreach my $role (@stds) {
1190: if ($values->{$role.'.plaintext'} ne '') {
1.9 raeburn 1191: push(@replacements,$role);
1.3 raeburn 1192: } else {
1193: push(@regulars,$role);
1194: }
1.9 raeburn 1195: }
1.3 raeburn 1196: foreach my $stdrole (@stds) {
1197: my $ext_entry = $entry.'_'.$stdrole;
1198: my $stdname = &Apache::lonnet::plaintext($stdrole,$crstype,
1199: $env{'request.course.id'},1);
1200: if ($env{'form.'.$ext_entry} eq $stdname) {
1201: $newvalues{$ext_entry} = '';
1202: } else {
1203: $newvalues{$ext_entry} = $env{'form.'.$ext_entry};
1204: }
1205: if ($newvalues{$ext_entry} ne $values->{$stdrole.'.plaintext'}) {
1206: my $dupname = 0;
1207: if ($newvalues{$ext_entry} ne '') {
1208: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@replacements)) {
1209: $dupname = 1;
1210: push(@{$disallowed->{'rolenames'}{'replacements'}},$newvalues{$ext_entry});
1211: }
1212: if (!$dupname) {
1213: if (grep(/^\Q$newvalues{$ext_entry}\E$/,@regulars)) {
1214: $dupname = 1;
1215: push(@{$disallowed->{rolenames}{'regulars'}},$newvalues{$ext_entry});
1216: }
1217: }
1218: if (!$dupname) {
1219: foreach my $role (keys(%adv_roles)) {
1220: if ($role =~ m{^cr/$match_domain/$match_name/\Q$newvalues{$ext_entry}\E$}) {
1221: $dupname = 1;
1222: push(@{$disallowed->{rolenames}{'customrole'}},$newvalues{$ext_entry});
1223: last;
1224: }
1225: }
1226: }
1227: }
1228: if (!$dupname) {
1229: $changes->{$ext_entry} = $newvalues{$ext_entry};
1230: }
1231: }
1232: }
1.77 raeburn 1233: } elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied') ||
1234: ($entry eq 'pac.roles.denied')) {
1.3 raeburn 1235: my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry);
1236: @denied = sort(@denied);
1237: my $deniedstr = '';
1238: if (@denied > 0) {
1239: $deniedstr = join(',',@denied);
1240: }
1241: $newvalues{$entry} = $deniedstr;
1.77 raeburn 1242: } elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied') ||
1243: ($entry eq 'pac.users.denied')) {
1.3 raeburn 1244: my $total = $env{'form.'.$entry.'_total'};
1245: my $userstr = '';
1246: my @denied;
1247: if ($total > 0) {
1248: my @deletes =
1249: &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1250: for (my $i=0; $i<$total; $i++) {
1251: unless (grep(/^$i$/,@deletes)) {
1252: $userstr .= $env{'form.'.$entry.'_user_'.$i}.',';
1253: push(@denied,$env{'form.'.$entry.'_user_'.$i});
1254: }
1255: }
1256: } else {
1257: $total = 0;
1258: }
1259: if ($env{'form.'.$entry.'_uname_'.$total} ne '') {
1260: my $uname = $env{'form.'.$entry.'_uname_'.$total};
1261: my $udom = $env{'form.'.$entry.'_udom_'.$total};
1262: if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
1263: $userstr =~ s/,$//;
1264: $disallowed->{'discussion'}{$entry} = $uname.':'.$udom;
1265: } else {
1266: my $newuser .= $uname.':'.$udom;
1267: if (grep(/^\Q$newuser\E$/,@denied)) {
1268: $userstr =~ s/,$//;
1269: } else {
1270: $userstr .= $newuser;
1271: }
1272: }
1273: } else {
1274: $userstr =~ s/,$//;
1275: }
1276: $newvalues{$entry} = $userstr;
1277: } elsif ($entry eq 'allow_discussion_post_editing') {
1278: my @canedit = &Apache::loncommon::get_env_multiple('form.'.$entry);
1279: @canedit = sort(@canedit);
1280: foreach my $role (@canedit) {
1281: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$role);
1282: if ((grep(/^\s*$/,@secs)) || (@secs == 0)) {
1283: $newvalues{$entry} .= $role.',';
1284: } else {
1285: foreach my $sec (@secs) {
1286: $newvalues{$entry} .= $role.':'.$sec.',';
1287: }
1288: }
1289: }
1290: $newvalues{$entry} =~ s/,$//;
1.50 raeburn 1291: } elsif ($entry eq 'discussion_post_fonts') {
1292: my ($classorder,$classtitles) = &discussion_vote_classes();
1293: my $fontchange = 0;
1294: foreach my $class (@{$classorder}) {
1295: my $ext_entry = $entry.'_'.$class;
1296: my $size = $env{'form.'.$ext_entry.'_size'};
1297: my $unit = $env{'form.'.$ext_entry.'_unit'};
1298: my $weight = $env{'form.'.$ext_entry.'_weight'};
1299: my $style = $env{'form.'.$ext_entry.'_style'};
1300: my $other = $env{'form.'.$ext_entry.'_other'};
1301: $size =~ s/,//g;
1302: $unit =~ s/,//g;
1303: $weight =~ s/,//g;
1304: $style =~ s/,//g;
1305: $other =~ s/[^\w;:\s\-\%.]//g;
1306: $other =~ s/(^\s+|\s+$)//g;
1307: $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other));
1308: my $current = $values->{$ext_entry};
1309: if ($values->{$ext_entry} eq '') {
1310: $current = ',,,';
1311: }
1312: if ($newvalues{$ext_entry} ne $current) {
1313: $changes->{$ext_entry} = $newvalues{$ext_entry};
1314: $fontchange ++;
1315: }
1316: }
1317: if ($fontchange) {
1318: $changes->{$entry} = 1;
1319: }
1.3 raeburn 1320: } elsif ($entry eq 'nothideprivileged') {
1321: my @curr_nothide;
1322: my @new_nothide;
1323: if ($values->{$entry} ne '') {
1324: foreach my $user (split(/\s*\,\s*/,$values->{$entry})) {
1325: my $nothide;
1326: if ($user !~ /:/) {
1327: $nothide = join(':',split(/[\@]/,$user));
1328: } else {
1329: $nothide = $user;
1330: }
1331: if ((defined($nothide)) &&
1332: (!grep(/^\Q$nothide\E$/,@curr_nothide))) {
1333: push(@curr_nothide,$nothide);
1334: }
1335: }
1336: }
1337: foreach my $key (keys(%env)) {
1338: if ($key =~ /^form\.\Q$entry\E_($match_username:$match_domain)$/) {
1.7 raeburn 1339: if ($env{$key}) {
1.3 raeburn 1340: my $nothide = $1;
1341: if (!grep(/^\Q$nothide\E$/,@new_nothide)) {
1342: push(@new_nothide,$nothide);
1343: }
1344: }
1345: }
1346: }
1347: @new_nothide = sort(@new_nothide);
1348: my @differences =
1349: &Apache::loncommon::compare_arrays(\@curr_nothide,
1350: \@new_nothide);
1351: if (@differences > 0) {
1352: if (@new_nothide > 0) {
1353: $newvalues{$entry} = join(',',@new_nothide);
1354: } else {
1355: $newvalues{$entry} = '';
1356: }
1357: } else {
1358: $newvalues{$entry} = $values->{$entry};
1359: }
1360: } elsif ($entry eq 'print_header_format') {
1361: my $maxnum = $env{'form.printfmthdr_maxnum'};
1362: my @newhdr;
1363: if ($maxnum > 2) {
1364: for (my $i=0; $i<$maxnum-2; $i++) {
1365: if ($env{'form.printfmthdr_del_'.$i}) {
1366: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = '';
1367: } else {
1368: my $hdr;
1369: if ($env{'form.printfmthdr_sub_'.$i} =~ /^[nca]$/) {
1370: $hdr = '%';
1371: if ($env{'form.printfmthdr_limit_'.$i} =~ /^\d+$/) {
1372: $hdr .= $env{'form.printfmthdr_limit_'.$i};
1373: }
1374: $hdr .= $env{'form.printfmthdr_sub_'.$i};
1.29 raeburn 1375: } elsif ($env{'form.printfmthdr_text_'.$i} ne '') {
1376: $hdr = $env{'form.printfmthdr_text_'.$i};
1.3 raeburn 1377: }
1378: $newhdr[$env{'form.printfmthdr_pos_'.$i}] = $hdr;
1379: }
1380: }
1381: }
1382: my $newsub = $maxnum-2;
1383: if ($env{'form.printfmthdr_sub_'.$newsub} =~ /^[nca]$/) {
1384: my $hdr = '%';
1385: if ($env{'form.printfmthdr_limit_'.$newsub} =~ /^\d+$/) {
1386: $hdr .= $env{'form.printfmthdr_limit_'.$newsub};
1387: }
1388: $hdr .= $env{'form.printfmthdr_sub_'.$newsub};
1389: $newhdr[$env{'form.printfmthdr_pos_'.$newsub}] = $hdr;
1390: }
1391: my $newtext = $maxnum-1;
1392: $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext};
1393: $newvalues{$entry} = join('',@newhdr);
1.56 raeburn 1394: } elsif (($entry eq 'languages') ||
1395: ($entry eq 'checkforpriv')) {
1396: my $settings;
1.3 raeburn 1397: my $total = $env{'form.'.$entry.'_total'};
1398: if ($total) {
1399: my @deletes = &Apache::loncommon::get_env_multiple('form.'.$entry.'_delete');
1400: for (my $i=0; $i<$total; $i++) {
1401: unless (grep(/^$i$/,@deletes)) {
1.56 raeburn 1402: $settings .= $env{'form.'.$entry.'_'.$i}.',';
1.3 raeburn 1403: }
1404: }
1405: } else {
1406: $total = 0;
1407: }
1408: if ($env{'form.'.$entry.'_'.$total} ne '') {
1.56 raeburn 1409: my $new = $env{'form.'.$entry.'_'.$total};
1410: if ($entry eq 'languages') {
1411: my %langchoices = &get_lang_choices();
1412: if ($langchoices{$new}) {
1413: $settings .= $new;
1414: } else {
1415: $settings =~ s/,$//;
1416: $disallowed->{'localization'}{$entry} = $new;
1417: }
1.3 raeburn 1418: } else {
1.56 raeburn 1419: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
1420: if ($domains{$new}) {
1421: $settings .= $new;
1422: } else {
1423: $settings =~ s/,$//;
1424: $disallowed->{'classlists'}{$entry} = $new;
1425: }
1.3 raeburn 1426: }
1427: } else {
1.56 raeburn 1428: $settings =~ s/,$//;
1.3 raeburn 1429: }
1.56 raeburn 1430: $newvalues{$entry} = $settings;
1.87 raeburn 1431: } elsif ($action eq 'lti') {
1432: if ($entry eq 'lti.override') {
1433: $newvalues{$entry} = $env{'form.'.$entry};
1434: } elsif (($entry eq 'lti.topmenu') || ($entry eq 'lti.inlinemenu')) {
1435: if ($env{'form.lti.override'}) {
1436: $newvalues{$entry} = $env{'form.'.$entry};
1437: } else {
1438: $newvalues{$entry} = '';
1439: }
1440: } elsif ($entry eq 'lti.lcmenu') {
1441: if (($env{'form.lti.override'}) &&
1442: (($env{'form.lti.topmenu'}) || ($env{'form.lti.inlinemenu'}))) {
1443: my @lcmenu = &Apache::loncommon::get_env_multiple('form.lti.lcmenu');
1444: my @newlcmenu;
1445: if (@lcmenu) {
1446: my @menuitems = ('fullname','coursetitle','role','logout','grades');
1447: foreach my $item (@menuitems) {
1448: next if (($item eq 'grades') && (!$newvalues{'lti.inlinemenu'}));
1449: if (grep(/^\Q$item\E$/,@lcmenu)) {
1450: push(@newlcmenu,$item);
1451: }
1452: }
1453: }
1454: if (@newlcmenu) {
1455: $newvalues{$entry} = join(',',@newlcmenu);
1456: } else {
1457: $newvalues{$entry} = 'none';
1458: }
1459: } else {
1460: $newvalues{$entry} = '';
1461: }
1462: }
1.3 raeburn 1463: } else {
1464: $newvalues{$entry} = $env{'form.'.$entry};
1465: }
1.50 raeburn 1466: unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts')) {
1.25 raeburn 1467: if ($newvalues{$entry} ne $values->{$entry}) {
1468: $changes->{$entry} = $newvalues{$entry};
1469: }
1.3 raeburn 1470: }
1471: }
1472: }
1473: }
1474: }
1475: }
1.93 raeburn 1476: return $errors;
1477: }
1478:
1.102 raeburn 1479: sub process_linkprot {
1480: my ($cdom,$cnum,$values,$changes,$context) = @_;
1.103 ! raeburn 1481: my ($home,$dest,$ltiauth,$privkey,$privnum,$cipher,$errors,%linkprot);
1.102 raeburn 1482: if (ref($values) eq 'HASH') {
1483: foreach my $id (keys(%{$values})) {
1484: if ($id =~ /^\d+$/) {
1485: unless (ref($values->{$id}) eq 'HASH') {
1486: $linkprot{$id} = '';
1487: }
1488: }
1489: }
1490: }
1.103 ! raeburn 1491: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
! 1492: my @ids=&Apache::lonnet::current_machine_ids();
! 1493: if ($context eq 'domain') {
! 1494: $home = &Apache::lonnet::domain($cdom,'primary');
! 1495: } else {
! 1496: $home = &Apache::lonnet::homeserver($cnum,$cdom);
! 1497: }
! 1498: if ((($context eq 'domain') && ($domdefs{'linkprotenc_dom'})) ||
! 1499: (($context eq 'course') && ($domdefs{'linkprotenc_crs'}))) {
! 1500: unless (($home eq 'no_host') || ($home eq '')) {
! 1501: if (grep(/^\Q$home\E$/,@ids)) {
! 1502: if (ref($domdefs{'privhosts'}) eq 'ARRAY') {
! 1503: if (grep(/^\Q$home\E$/,@{$domdefs{'privhosts'}})) {
! 1504: my %privhash = &Apache::lonnet::restore_dom('lti','private',$cdom,$home,1);
! 1505: $privkey = $privhash{'key'};
! 1506: $privnum = $privhash{'version'};
! 1507: if (($privnum) && ($privkey ne '')) {
! 1508: $cipher = Crypt::CBC->new({'key' => $privkey,
! 1509: 'cipher' => 'DES'});
! 1510: }
! 1511: }
! 1512: }
! 1513: }
! 1514: }
! 1515: }
1.102 raeburn 1516: if ($context eq 'domain') {
1517: $dest = '/adm/domainprefs';
1518: $ltiauth = 1;
1519: } else {
1520: $dest = '/adm/courseprefs';
1521: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
1522: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
1523: } else {
1524: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
1525: $ltiauth = $domdefs{'crsltiauth'};
1526: }
1527: }
1528: my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
1529: my (@items,%deletions,%itemids,%haschanges);
1530: if ($env{'form.linkprot_add'}) {
1531: my $name = $env{'form.linkprot_name_add'};
1532: $name =~ s/(`)/'/g;
1533: my ($newid,$error) = &get_linkprot_id($cdom,$cnum,$name,$context);
1534: if ($newid) {
1535: $itemids{'add'} = $newid;
1536: push(@items,'add');
1537: $haschanges{$newid} = 1;
1538: } else {
1539: $errors .= '<span class="LC_error">'.
1540: &mt('Failed to acquire unique ID for link protection').
1541: '</span>';
1542: }
1543: }
1544: if (ref($values) eq 'HASH') {
1545: my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_del');
1546: my $maxnum = $env{'form.linkprot_maxnum'};
1547: for (my $i=0; $i<=$maxnum; $i++) {
1548: my $itemid = $env{'form.linkprot_id_'.$i};
1549: $itemid =~ s/\D+//g;
1550: if ($itemid) {
1551: if (ref($values->{$itemid}) eq 'HASH') {
1552: push(@items,$i);
1553: $itemids{$i} = $itemid;
1554: if ((@todelete > 0) && (grep(/^$i$/,@todelete))) {
1555: $deletions{$itemid} = $values->{$itemid}->{'name'};
1556: }
1557: }
1558: }
1559: }
1560: }
1561: foreach my $idx (@items) {
1562: my $itemid = $itemids{$idx};
1563: next unless ($itemid);
1564: if (exists($deletions{$itemid})) {
1565: $linkprot{$itemid} = $deletions{$itemid};
1566: $haschanges{$itemid} = 1;
1567: next;
1568: }
1569: my %current;
1570: if (ref($values) eq 'HASH') {
1571: if (ref($values->{$itemid}) eq 'HASH') {
1572: foreach my $key (keys(%{$values->{$itemid}})) {
1573: $current{$key} = $values->{$itemid}->{$key};
1574: }
1575: }
1576: }
1577: foreach my $inner ('name','lifetime','version') {
1578: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1579: $env{$formitem} =~ s/(`)/'/g;
1580: if ($inner eq 'lifetime') {
1581: $env{$formitem} =~ s/[^\d.]//g;
1582: }
1583: unless ($idx eq 'add') {
1584: if ($current{$inner} ne $env{$formitem}) {
1585: $haschanges{$itemid} = 1;
1586: }
1587: }
1588: if ($env{$formitem} ne '') {
1589: $linkprot{$itemid}{$inner} = $env{$formitem};
1590: }
1591: }
1592: if ($ltiauth) {
1593: my $reqitem = 'form.linkprot_requser_'.$idx;
1594: $env{$reqitem} =~ s/(`)/'/g;
1595: unless ($idx eq 'add') {
1596: if ($current{'requser'} ne $env{$reqitem}) {
1597: $haschanges{$itemid} = 1;
1598: }
1599: }
1600: if ($env{$reqitem} == 1) {
1601: $linkprot{$itemid}{'requser'} = $env{$reqitem};
1602: foreach my $inner ('mapuser','notstudent') {
1603: my $formitem = 'form.linkprot_'.$inner.'_'.$idx;
1604: $env{$formitem} =~ s/(`)/'/g;
1605: if ($inner eq 'mapuser') {
1606: if ($env{$formitem} eq 'other') {
1607: my $mapuser = $env{'form.linkprot_customuser_'.$idx};
1608: $mapuser =~ s/(`)/'/g;
1609: $mapuser =~ s/^\s+|\s+$//g;
1610: if ($mapuser ne '') {
1611: $linkprot{$itemid}{$inner} = $mapuser;
1612: } else {
1613: delete($linkprot{$itemid}{'requser'});
1614: last;
1615: }
1616: } elsif ($env{$formitem} eq 'sourcedid') {
1617: $linkprot{$itemid}{$inner} = 'lis_person_sourcedid';
1618: } elsif ($env{$formitem} eq 'email') {
1619: $linkprot{$itemid}{$inner} = 'lis_person_contact_email_primary';
1620: }
1621: } else {
1622: $linkprot{$itemid}{$inner} = $env{$formitem};
1623: }
1624: unless ($idx eq 'add') {
1625: if ($current{$inner} ne $linkprot{$itemid}{$inner}) {
1626: $haschanges{$itemid} = 1;
1627: }
1628: }
1629: }
1630: }
1631: }
1632: unless ($switchserver) {
1633: my $keyitem = 'form.linkprot_key_'.$idx;
1634: $env{$keyitem} =~ s/(`)/'/g;
1635: unless ($idx eq 'add') {
1636: if ($current{'key'} ne $env{$keyitem}) {
1637: $haschanges{$itemid} = 1;
1638: }
1639: }
1640: if ($env{$keyitem} ne '') {
1641: $linkprot{$itemid}{'key'} = $env{$keyitem};
1642: }
1643: my $secretitem = 'form.linkprot_secret_'.$idx;
1644: $env{$secretitem} =~ s/(`)/'/g;
1645: if ($current{'usable'}) {
1646: if ($env{'form.linkprot_changesecret_'.$idx}) {
1647: if ($env{$secretitem} ne '') {
1.103 ! raeburn 1648: if ($privnum && $cipher) {
! 1649: $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
! 1650: $linkprot{$itemid}{'cipher'} = $privnum;
! 1651: } else {
! 1652: $linkprot{$itemid}{'secret'} = $env{$secretitem};
! 1653: }
1.102 raeburn 1654: $haschanges{$itemid} = 1;
1655: }
1656: } else {
1657: $linkprot{$itemid}{'secret'} = $current{'secret'};
1658: }
1659: } elsif ($env{$secretitem} ne '') {
1.103 ! raeburn 1660: if ($privnum && $cipher) {
! 1661: $linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem});
! 1662: $linkprot{$itemid}{'cipher'} = $privnum;
! 1663: } else {
! 1664: $linkprot{$itemid}{'secret'} = $env{$secretitem};
! 1665: }
1.102 raeburn 1666: $haschanges{$itemid} = 1;
1667: }
1668: }
1669: }
1670: if (keys(%haschanges)) {
1671: foreach my $entry (keys(%haschanges)) {
1672: $changes->{$entry} = $linkprot{$entry};
1673: }
1674: }
1675: return $errors;
1676: }
1677:
1678: sub get_linkprot_id {
1679: my ($cdom,$cnum,$name,$context) = @_;
1680: # get lock on lti db in course or linkprot db in domain
1.93 raeburn 1681: my $lockhash = {
1682: lock => $env{'user.name'}.
1683: ':'.$env{'user.domain'},
1684: };
1685: my $tries = 0;
1.102 raeburn 1686: my $gotlock;
1687: if ($context eq 'domain') {
1688: $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1689: } else {
1690: $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1691: }
1.93 raeburn 1692: my ($id,$error);
1693: while (($gotlock ne 'ok') && ($tries<10)) {
1694: $tries ++;
1695: sleep (0.1);
1.102 raeburn 1696: if ($context eq 'domain') {
1697: $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom);
1698: } else {
1699: $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum);
1700: }
1.93 raeburn 1701: }
1702: if ($gotlock eq 'ok') {
1.102 raeburn 1703: my %currids;
1704: if ($context eq 'domain') {
1705: %currids = &Apache::lonnet::dump_dom('linkprot',$cdom);
1706: } else {
1707: %currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1);
1708: }
1.93 raeburn 1709: if ($currids{'lock'}) {
1710: delete($currids{'lock'});
1711: if (keys(%currids)) {
1712: my @curr = sort { $a <=> $b } keys(%currids);
1713: if ($curr[-1] =~ /^\d+$/) {
1714: $id = 1 + $curr[-1];
1715: } else {
1716: $id = 1;
1717: }
1718: } else {
1719: $id = 1;
1720: }
1721: if ($id) {
1.102 raeburn 1722: if ($context eq 'domain') {
1723: unless (&Apache::lonnet::newput_dom('linkprot',{ $id => $name },$cdom) eq 'ok') {
1724: $error = 'nostore';
1725: }
1726: } else {
1727: unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') {
1728: $error = 'nostore';
1729: }
1.93 raeburn 1730: }
1731: } else {
1732: $error = 'nonumber';
1733: }
1734: }
1.102 raeburn 1735: my $dellockoutcome;
1736: if ($context eq 'domain') {
1737: $dellockoutcome = &Apache::lonnet::del_dom('linkprot',['lock'],$cdom);
1738: } else {
1739: $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum);
1740: }
1.93 raeburn 1741: } else {
1742: $error = 'nolock';
1743: }
1744: return ($id,$error);
1.3 raeburn 1745: }
1746:
1747: sub get_sec_str {
1748: my ($entry,$num) = @_;
1749: my @secs = &Apache::loncommon::get_env_multiple('form.'.$entry.'_sections_'.$num);
1750: my $secstr;
1751: if (grep(/^\s*$/,@secs)) {
1752: $secstr = '';
1753: } elsif (@secs > 0) {
1754: $secstr = join(';',@secs);
1755: }
1756: if ($secstr ne '') {
1757: return '('.$secstr.')';
1758: }
1759: return;
1760: }
1761:
1762: sub check_clone {
1763: my ($clonedom,$disallowed,$clonename) = @_;
1764: return if (ref($disallowed) ne 'HASH');
1765: if ($clonedom !~ /^$match_domain$/) {
1766: $disallowed->{'cloners'}{'format'} .= $clonedom.',';
1767: return;
1768: } elsif (!&Apache::lonnet::domain($clonedom)) {
1769: $disallowed->{'cloners'}{'domain'} .= $clonedom.',';
1770: return;
1771: }
1772: if ($clonename ne '') {
1773: if ($clonename !~ /^$match_username$/) {
1774: $disallowed->{'cloners'}{'format'} .= $clonename.':'.$clonedom.',';
1775: return;
1776: } else {
1777: if (&Apache::lonnet::homeserver($clonename,$clonedom) eq 'no_host') {
1778: $disallowed->{'cloners'}{'newuser'} .= $clonename.':'.$clonedom.',';
1779: return;
1780: }
1781: }
1782: }
1783: return 'ok';
1784: }
1785:
1786: sub store_changes {
1.9 raeburn 1787: my ($cdom,$cnum,$prefs_order,$actions,$prefs,$values,$changes,$crstype) = @_;
1.3 raeburn 1788: my ($chome,$output);
1.93 raeburn 1789: my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot);
1.3 raeburn 1790: if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) {
1.102 raeburn 1791: if (ref($values->{'linkprot'}) eq 'HASH') {
1792: %oldlinkprot = %{$values->{'linkprot'}};
1.93 raeburn 1793: }
1.102 raeburn 1794: delete($values->{'linkprot'});
1.3 raeburn 1795: %storehash = %{$values};
1796: } else {
1.9 raeburn 1797: if ($crstype eq 'Community') {
1798: $output = &mt('No changes made to community settings.');
1799: } else {
1800: $output = &mt('No changes made to course settings.');
1801: }
1802: return $output;
1.3 raeburn 1803: }
1.93 raeburn 1804: my ($numchanges,$skipstore);
1805: if (ref($changes) eq 'HASH') {
1806: $numchanges = scalar(keys(%{$changes}));
1.102 raeburn 1807: if (($numchanges == 1) && (exists($changes->{'linkprot'}))) {
1.93 raeburn 1808: $skipstore = 1;
1809: } elsif (!$numchanges) {
1810: if ($crstype eq 'Community') {
1811: $output = &mt('No changes made to community settings.');
1812: } else {
1813: $output = &mt('No changes made to course settings.');
1814: }
1815: return $output;
1816: }
1817: }
1.3 raeburn 1818: my %yesno = (
1819: hidefromcat => '1',
1820: problem_stream_switch => '1',
1821: suppress_tries => '1',
1822: disableexampointprint => '1',
1823: hideemptyrows => '1',
1824: suppress_embed_prompt => '1',
1825: );
1826: foreach my $item (@{$prefs_order}) {
1827: if (grep(/^\Q$item\E$/,@{$actions})) {
1828: $output .= '<h3>'.&mt($prefs->{$item}{'text'}).'</h3>';
1829: if (ref($changes->{$item}) eq 'HASH') {
1.99 raeburn 1830: if (keys(%{$changes->{$item}}) > 0) {
1.22 wenzelju 1831: $output .= &mt('Changes made:').'<ul style="list-style:none;">';
1.3 raeburn 1832: if ($item eq 'other') {
1833: foreach my $key (sort(keys(%{$changes->{$item}}))) {
1834: $storehash{$key} = $changes->{$item}{$key};
1835: if ($changes->{$item}{$key} eq '') {
1836: push(@delkeys,$key);
1.22 wenzelju 1837: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'.$key.'</i>')).'</li>';
1.3 raeburn 1838: } else {
1.22 wenzelju 1839: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$key.'</i>',
1840: "'$storehash{$key}'")).'</li>';
1.3 raeburn 1841: }
1842: }
1.102 raeburn 1843: } elsif ($item eq 'linkprot') {
1844: $output .= &store_linkprot($cdom,$cnum,'course',$changes->{$item},\%oldlinkprot);
1.3 raeburn 1845: } else {
1846: if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') {
1847: my @settings = @{$prefs->{$item}->{'ordered'}};
1848: if ($item eq 'feedback') {
1849: push(@settings,(map { $_.'.text'; } @settings));
1850: }
1851: foreach my $key (@settings) {
1852: if ($key eq 'rolenames') {
1853: my $displayname = $prefs->{$item}->{'itemtext'}{$key};
1854: my $msg;
1.9 raeburn 1855: my @roles;
1856: if ($crstype eq 'Community') {
1857: @roles = ('co');
1858: } else {
1859: @roles = ('cc');
1860: }
1861: push(@roles,('in','ta','ep','ad','st'));
1862: foreach my $role (@roles) {
1.3 raeburn 1863: next if (!exists($changes->{$item}{$key.'_'.$role}));
1864: my $stdname = &Apache::lonnet::plaintext($role,$crstype,undef,1);
1865: my $newname = $changes->{$item}{$key.'_'.$role};
1866: $storehash{$role.'.plaintext'} = $newname;
1867: if ($newname eq '') {
1868: $newname = $stdname;
1869: }
1870: $msg .= '<li>'.&mt('[_1] set to [_2]','<i>'.$stdname.'</i>',
1871: "'<b>".$newname."</b>'").'</li>';
1872: }
1873: if ($msg ne '') {
1.22 wenzelju 1874: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt($displayname)).'<ul class="LC_success">'.$msg.'</ul></li>';
1.3 raeburn 1875: }
1876: } else {
1877: next if (!exists($changes->{$item}{$key}));
1878: my ($displayname,$text);
1879: $text = $prefs->{$item}->{'itemtext'}{$key};
1.25 raeburn 1880: my $displayval;
1.50 raeburn 1881: unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) {
1.25 raeburn 1882: $displayval = $changes->{$item}{$key};
1883: }
1.3 raeburn 1884: if ($item eq 'feedback') {
1885: if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
1886: $text = $prefs->{$item}->{'itemtext'}{$1.$2};
1887: $displayname = &mt('Custom text for '.$text.' questions');
1888: } else {
1889: $displayname = &mt('Recipients of '.$text.' questions');
1890: }
1891: } elsif ($item eq 'discussion') {
1892: if ($key =~ /^p(lc|ch)\.roles\.denied/) {
1893: $displayname = &mt("$text (role-based)");
1894: if ($displayval ne '') {
1895: my @roles = split(',',$displayval);
1896: @roles = map { &Apache::lonnet::plaintext($_); } @roles;
1897: $displayval = join(', ',@roles);
1898: }
1899: } elsif ($key =~ /^p(lc|ch)\.users\.denied/) {
1900: $displayname = &mt("$text (specific user(s))");
1901: } else {
1902: if ($key eq 'allow_discussion_post_editing') {
1903: if ($displayval ne '') {
1904: my @roles = split(',',$displayval);
1905: my @longroles;
1906: foreach my $role (@roles) {
1907: my ($trole,$sec) = split(':',$role);
1908: my $rolename =
1909: &Apache::lonnet::plaintext($trole);
1910: if ($sec ne '') {
1911: $rolename .= ':'.$sec;
1912: }
1913: push(@longroles,$rolename);
1914: }
1915: $displayval = join(', ',@longroles);
1916: }
1.50 raeburn 1917: } elsif ($key eq 'discussion_post_fonts') {
1918: my ($classorder,$classtitles)=&discussion_vote_classes();
1919: my ($styleorder,$styleitems)=&discussion_vote_styles();
1920: my $count = 1;
1921: my $total = scalar(keys(%{$changes->{$item}}));
1922: foreach my $class (@{$classorder}) {
1923: $count ++;
1924: next unless ($changes->{$item}{$key.'_'.$class});
1925: my @vals = split(/,/,$changes->{$item}{$key.'_'.$class});
1926: my $showval = '';
1927: for (my $i=0; $i<@{$styleorder}; $i++) {
1928: if ($vals[$i] ne '') {
1929: $showval .= 'font-'.$styleorder->[$i].': '.$vals[$i].'; ';
1930: }
1931: }
1932: if ($vals[3] ne '') {
1933: $showval .= $vals[3];
1934: }
1935: if ($showval ne '') {
1936: $displayval .= $classtitles->{$class}.':{ '.
1937: $showval.'}';
1938: $storehash{$key.'_'.$class} = $changes->{$item}{$key.'_'.$class};
1939: } else {
1940: $displayval .= $classtitles->{$class}.': '.&mt('None');
1941: push(@delkeys,$key.'_'.$class);
1942: }
1943: unless ($count == $total) {
1944: $displayval .= (' 'x2);
1945: }
1946: }
1.3 raeburn 1947: }
1948: $displayname = &mt($text);
1949: }
1950: } elsif ($item eq 'spreadsheet') {
1951: if ($key =~ /^spreadsheet_default_(studentcalc|assesscalc)$/x) {
1952: my $sheettype = $1;
1953: if ($sheettype eq 'studentcalc') {
1954: &Apache::lonnet::expirespread('','','studentcalc');
1955: } else {
1956: &Apache::lonnet::expirespread('','','assesscalc');
1957: &Apache::lonnet::expirespread('','','studentcalc');
1958: }
1959: }
1960: $displayname = &mt($text);
1.87 raeburn 1961: } elsif ($item eq 'lti') {
1962: if ($key eq 'lti.lcmenu') {
1963: if ($changes->{$item}{$key} eq 'none') {
1964: $displayval = &mt('None of the configurable menu items displayed');
1965: } else {
1966: my %ltititles = <imenu_titles();
1967: $displayval = join(', ', map { $ltititles{$_}; } split(/,/,$changes->{$item}{$key}));
1968: }
1969: } else {
1970: if ($changes->{$item}{$key} eq '1') {
1971: $displayval = &mt('Yes');
1972: } elsif ($changes->{$item}{$key} eq '') {
1973: $displayval = &mt('No');
1974: }
1975: }
1976: $displayname = &mt($text);
1.91 raeburn 1977: } elsif ($item eq 'menuitems') {
1978: unless ($changes->{$item}{$key} eq '') {
1979: if ($key eq 'menudefault') {
1980: $displayname = &mt('Default collection of menu items');
1981: $displayval = &mt('Collection: [_1]',
1982: $changes->{$item}{$key});
1983: } elsif ($key eq 'menucollections') {
1984: $displayval = &menucollections_display($changes->{$item}{$key});
1985: }
1986: }
1.3 raeburn 1987: } else {
1988: $displayname = &mt($text);
1989: }
1990: if (defined($yesno{$key})) {
1.14 raeburn 1991: $displayval = &mt('No');
1.3 raeburn 1992: if ($changes->{$item}{$key} eq 'yes') {
1.14 raeburn 1993: $displayval = &mt('Yes');
1.3 raeburn 1994: }
1995: } elsif (($key =~ /^default_enrollment_(start|end)_date$/) && ($displayval)) {
1996: $displayval = &Apache::lonlocal::locallocaltime($displayval);
1997: } elsif ($key eq 'categories') {
1998: $displayval = $env{'form.categories_display'};
1.95 raeburn 1999: } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') ||
2000: ($key eq 'uselcmath') || ($key eq 'inline_chem')) {
1.14 raeburn 2001: if ($changes->{$item}{$key} eq '1') {
2002: $displayval = &mt('Yes');
2003: } elsif ($changes->{$item}{$key} eq '0') {
2004: $displayval = &mt('No');
2005: }
2006: }
1.25 raeburn 2007: if ($key eq 'co-owners') {
2008: if (ref($changes->{$item}{$key}) eq 'HASH') {
2009: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2010: foreach my $type ('co-owners','pendingco-owners') {
2011: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2012: if ($type eq 'pendingco-owners') {
2013: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2014: $displayname = &mt('Invited as co-owners, pending acceptance');
2015: }
2016: }
2017: if ($changes->{$item}{$key}{$type} eq '') {
2018: push(@delkeys,'internal.'.$type);
2019: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2020: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2021: '<i>'.$displayname.'</i>')).'</li>';
2022: }
2023: } elsif (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
2024: $displayval = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } split(',',$changes->{$item}{$key}{$type}));
2025: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2026: '<i>'.$displayname.'</i>',
2027: "'<b>$displayval</b>'")).'</li>';
2028: }
2029: }
2030: }
2031: unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
1.90 raeburn 2032: if ($env{'form.pending_coowner'} eq 'accept') {
1.25 raeburn 2033: $displayval = &mt('on');
1.90 raeburn 2034: } elsif ($env{'form.pending_coowner'} eq 'decline') {
1.25 raeburn 2035: $displayval = '';
2036: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'</li>';
1.90 raeburn 2037: } elsif ($env{'form.remove_coowner'}) {
1.25 raeburn 2038: $displayval = &mt('off');
2039: }
2040: if ($displayval) {
2041: $displayname = &mt('Your co-ownership status');
2042: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2043: '<i>'.$displayname.'</i>',
2044: "'<b>$displayval</b>'")).'</li>';
2045: }
2046: }
2047: }
2048: } elsif ($changes->{$item}{$key} eq '') {
1.3 raeburn 2049: push(@delkeys,$key);
1.87 raeburn 2050: if ($item eq 'lti') {
2051: if (($key eq 'lti.override') || (($key ne 'lti.override') && ($env{'form.lti.override'} ne ''))) {
2052: if (($key eq 'lti.lcmenu') &&
2053: ((!$env{'form.lti.topmenu'}) && (!$env{'form.lti.inlinemenu'}))) {
2054: $output .= '<li>'.&mt('LTI settings for menu items only saved if page header and/or inline menu is set to be displayed').'</li>';
2055: } else {
2056: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
2057: '<i>'.$displayname.'</i>',
2058: "'<b>$displayval</b>'")).'</li>';
2059: }
2060: } elsif (!exists($changes->{$item}{'lti.override'})) {
2061: $output .= '<li>'.&mt('LTI settings only saved if Override is set to "Yes"').'</li>';
2062: }
1.91 raeburn 2063: } elsif ($item eq 'menuitems') {
2064: if ($key eq 'menudefault') {
2065: $output .= '<li>'.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'</li>';
2066: } elsif ($key eq 'menucollections') {
2067: $output .= '<li>'.&mt('Specific collections of menus no longer available').'</li>';
2068: }
1.87 raeburn 2069: } else {
2070: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',
2071: '<i>'.$displayname.'</i>')).'</li>';
2072: }
1.91 raeburn 2073: } elsif ($key eq 'menucollections') {
2074: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).'<br />'.
2075: $displayval.'</li>';
1.3 raeburn 2076: } else {
1.22 wenzelju 2077: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',
1.3 raeburn 2078: '<i>'.$displayname.'</i>',
1.22 wenzelju 2079: "'<b>$displayval</b>'"));
1.3 raeburn 2080: if ($key eq 'url') {
2081: my $bkuptime=time;
2082: $output .= (' 'x2).&mt('(Previous URL backed up)').': '.
1.32 raeburn 2083: $storehash{'top level map backup '.$bkuptime} = $values->{$key};
1.3 raeburn 2084: }
2085: $output .= '</li>';
2086: }
1.25 raeburn 2087: if ($key eq 'co-owners') {
2088: if (ref($changes->{$item}{$key}) eq 'HASH') {
2089: if (ref($changes->{$item}{$key}{'changed'}) eq 'ARRAY') {
2090: foreach my $type ('co-owners','pendingco-owners') {
2091: next unless (grep(/^\Q$type\E$/,@{$changes->{$item}{$key}{'changed'}}));
2092: $storehash{'internal.'.$type} = $changes->{$item}{$key}{$type};
2093: }
2094: }
2095: }
2096: } else {
1.50 raeburn 2097: unless ($key eq 'discussion_post_fonts') {
2098: $storehash{$key} = $changes->{$item}{$key};
2099: }
1.25 raeburn 2100: }
1.3 raeburn 2101: }
1.23 raeburn 2102: if ($key eq 'cloners') {
2103: # Get existing cloners
2104: my %clonenames =
2105: &Apache::lonnet::dump('environment',$cdom,$cnum,'cloners');
2106: if ($clonenames{'cloners'} =~ /,/) {
2107: @oldcloner = split(/\s*\,\s*/,$clonenames{'cloners'});
2108: } else {
2109: $oldcloner[0] = $clonenames{'cloners'};
2110: }
2111: }
1.3 raeburn 2112: if (($key eq 'description') || ($key eq 'cloners') ||
1.25 raeburn 2113: ($key eq 'hidefromcat') || ($key eq 'categories') ||
1.87 raeburn 2114: ($key eq 'co-owners') || ($key eq 'lti.override') ||
2115: ($key eq 'lti.topmenu') || ($key eq 'lti.inlinemenu') ||
2116: ($key eq 'lti.lcmenu')) {
1.3 raeburn 2117: push(@need_env_update,$key);
2118: }
2119: }
2120: }
2121: }
2122: $output .= '</ul>';
2123: } else {
1.9 raeburn 2124: if ($crstype eq 'Community') {
1.46 raeburn 2125: $output .= &mt('No changes made to community settings.');
1.9 raeburn 2126: } else {
1.46 raeburn 2127: $output .= &mt('No changes made to course settings.');
1.9 raeburn 2128: }
1.3 raeburn 2129: }
2130: }
2131: }
2132: }
1.93 raeburn 2133: if ($skipstore) {
2134: return $output;
2135: }
1.3 raeburn 2136: if (&Apache::lonnet::put('environment',\%storehash,$cdom,$cnum) eq 'ok') {
1.23 raeburn 2137: if (ref($changes) eq 'HASH') {
2138: if (ref($changes->{'courseinfo'}) eq 'HASH') {
2139: if (exists($changes->{'courseinfo'}{'cloners'})) {
2140: &change_clone($cdom,$cnum,$changes->{'courseinfo'}{'cloners'},
2141: \@oldcloner);
2142: }
2143: }
2144: }
1.3 raeburn 2145: if (@delkeys) {
2146: if (&Apache::lonnet::del('environment',\@delkeys,$cdom,$cnum) ne 'ok') {
1.9 raeburn 2147: $output .= '<br /><span class="LC_error">';
2148: if ($crstype eq 'Community') {
2149: $output .= &mt('An error occurred when removing community settings which are no longer in use.');
2150: } else {
2151: $output .= &mt('An error occurred when removing course settings which are no longer in use.');
2152: }
2153: $output .= '</span>';
1.14 raeburn 2154: } else {
2155: foreach my $key (@delkeys) {
2156: &Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.'.$key);
2157: }
1.3 raeburn 2158: }
2159: }
2160: if (@need_env_update) {
2161: $chome = &Apache::lonnet::homeserver($cnum,$cdom);
2162: &update_env($cnum,$cdom,$chome,\@need_env_update,\%storehash);
2163: }
2164: &Apache::lonnet::coursedescription($env{'request.course.id'},
2165: {'freshen_cache' => 1});
2166: } else {
1.9 raeburn 2167: $output = '<span class="LC_error">';
2168: if ($crstype eq 'Community') {
2169: $output .= &mt('An error occurred when saving changes to community settings, which remain unchanged.');
2170: } else {
2171: $output .= &mt('An error occurred when saving changes to course settings, which remain unchanged.');
2172: }
2173: $output .= '</span>';
1.3 raeburn 2174: }
2175: return $output;
2176: }
2177:
1.102 raeburn 2178: sub store_linkprot {
2179: my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_;
1.103 ! raeburn 2180: my ($ltiauth,$home,$lti_save_error,$output,$error,%ltienc,@deletions);
1.102 raeburn 2181: if ($context eq 'domain') {
2182: $ltiauth = 1;
1.103 ! raeburn 2183: $home = &Apache::lonnet::domain($cdom,'primary');
1.102 raeburn 2184: } else {
1.103 ! raeburn 2185: $home = &Apache::lonnet::homeserver($cnum,$cdom);
1.102 raeburn 2186: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
2187: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
2188: } else {
2189: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
2190: $ltiauth = $domdefs{'crsltiauth'};
2191: }
2192: }
2193: if (ref($changes) eq 'HASH') {
2194: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
2195: if (ref($changes->{$id}) eq 'HASH') {
2196: if (exists($changes->{$id}->{'key'})) {
2197: $ltienc{$id}{'key'} = $changes->{$id}->{'key'};
2198: delete($changes->{$id}->{'key'});
2199: }
2200: if (exists($changes->{$id}->{'secret'})) {
2201: $ltienc{$id}{'secret'} = $changes->{$id}->{'secret'};
2202: delete($changes->{$id}->{'secret'});
2203: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
2204: if (exists($oldlinkprot->{$id}{'usable'})) {
2205: $changes->{$id}->{'usable'} = 1;
2206: }
2207: }
2208: }
2209: }
2210: }
2211: my @ids=&Apache::lonnet::current_machine_ids();
2212: if (keys(%ltienc) > 0) {
2213: if ($context eq 'domain') {
2214: foreach my $id (keys(%ltienc)) {
2215: if (exists($ltienc{$id}{'secret'})) {
2216: $changes->{$id}->{'usable'} = 1;
2217: }
2218: }
2219: } else {
1.103 ! raeburn 2220: unless (($home eq 'no_host') || ($home eq '')) {
1.102 raeburn 2221: my $allowed;
2222: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
2223: if ($allowed) {
2224: if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') {
2225: foreach my $id (keys(%ltienc)) {
2226: if (exists($ltienc{$id}{'secret'})) {
2227: $changes->{$id}->{'usable'} = 1;
2228: }
2229: }
2230: } else {
2231: $lti_save_error = 1;
2232: }
2233: }
2234: }
2235: }
2236: }
2237: unless ($lti_save_error) {
2238: if ($context eq 'course') {
2239: if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') {
2240: my $hashid=$cdom.'_'.$cnum;
2241: &Apache::lonnet::devalidate_cache_new('courselti',$hashid);
1.103 ! raeburn 2242: unless (($home eq 'no_host') || ($home eq '')) {
! 2243: if (grep(/^\Q$home\E$/,@ids)) {
1.102 raeburn 2244: &Apache::lonnet::devalidate_cache_new('courseltienc',$hashid);
2245: }
2246: }
2247: } else {
2248: $lti_save_error = 1;
2249: }
2250: }
2251: unless ($lti_save_error) {
2252: foreach my $id (sort { $a <=> $b } %{$changes}) {
2253: if (ref($changes->{$id}) eq 'HASH') {
2254: my %values = %{$changes->{$id}};
2255: my %desc = &linkprot_names();
2256: my $display;
2257: foreach my $title ('name','lifetime','version','key','secret') {
2258: if (($title eq 'key') || ($title eq 'secret')) {
2259: if (ref($ltienc{$id}) eq 'HASH') {
2260: if (exists($ltienc{$id}{$title})) {
2261: if ($title eq 'secret') {
2262: my $length = length($ltienc{$id}{$title});
1.103 ! raeburn 2263: $display .= $desc{$title}.': ['.&mt('not shown').'], ';
1.102 raeburn 2264: } else {
2265: $display .= $desc{$title}.': '.$ltienc{$id}{$title}.', ';
2266: }
2267: }
2268: }
2269: } elsif ($title eq 'version') {
2270: if ($values{$title} eq 'LTI-1p0') {
2271: $display .= $desc{$title}.': 1.1, ';
2272: }
2273: } else {
2274: $display .= $desc{$title}.': '.$values{$title}.', ';
2275: }
2276: }
2277: if ($ltiauth) {
2278: if (($values{'requser'}) && ($values{'mapuser'} ne '')) {
2279: if ($values{'mapuser'} eq 'lis_person_contact_email_primary') {
2280: $display .= &mt('Source of username: Email address [_1]',
2281: '(lis_person_contact_email_primary)').', ';
2282: } elsif ($values{'mapuser'} eq 'lis_person_sourcedid') {
2283: $display .= &mt('Source of username: User ID [_1]',
2284: '(lis_person_sourcedid)').', ';
2285: } else {
2286: $display .= &mt('Source of username: [_1]',$values{'mapuser'}).', ';
2287: }
2288: if ($values{'notstudent'} eq 'auth') {
2289: $display .= &mt('Display LON-CAPA login page if no match').', ';
2290: } elsif ($values{'notstudent'} eq 'reject') {
2291: $display .= &mt('Discontinue launch if no match').', ';
2292: }
2293: }
2294: }
2295: $display =~ s/, $//;
2296: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$id.'</i>',
2297: "'$display'")).'</li>';
2298: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
2299: my $oldname = $oldlinkprot->{$id}{'name'};
2300: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'."$id ($oldname)".'</i>')).'</li>';
2301: }
2302: }
2303: } else {
2304: $lti_save_error = 1;
2305: }
2306: }
2307: unless ($lti_save_error) {
2308: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
2309: unless (ref($changes->{$id}) eq 'HASH') {
2310: push(@deletions,$id);
2311: }
2312: }
2313: if (@deletions) {
2314: if ($context eq 'course') {
2315: &Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum);
2316: }
2317: }
2318: }
2319: if ($lti_save_error) {
2320: $output .= '<li>'.
2321: '<span class="LC_error">'.
2322: &mt('An error occurred when saving changes to link protection settings, which remain unchanged.').
2323: '</span>'.
2324: '</li>';
2325: }
2326: return $output;
2327: }
2328:
1.3 raeburn 2329: sub update_env {
2330: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
2331: my $count = 0;
2332: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
2333: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
2334: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2335: foreach my $key (@{$need_env_update}) {
2336: if ($key eq 'description' && defined($storehash->{$key})) {
2337: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
2338: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
2339: $count ++;
2340: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
2341: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
2342: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
2343: $count ++;
1.25 raeburn 2344: } elsif ($key eq 'co-owners') {
2345: if ($storehash->{'internal.co-owners'} ne '') {
2346: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
2347: }
2348: if ($storehash->{'internal.pendingco-owners'} ne '') {
2349: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
2350: }
2351: my @coowners = split(',',$storehash->{'internal.'.$key});
2352: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
2353: $count ++;
1.87 raeburn 2354: } elsif ($key =~ /^lti\./) {
2355: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1.3 raeburn 2356: }
2357: }
2358: if ($count) {
2359: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2360: }
2361: }
2362: }
2363: return;
2364: }
2365:
2366: sub display_disallowed {
1.9 raeburn 2367: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 2368: my $output;
2369: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
2370: if (keys(%{$disallowed})) {
2371: if ($item eq 'cloners') {
2372: my @fails;
2373: my %lt = &Apache::lonlocal::texthash (
2374: format => 'Invalid format',
2375: domain => 'Domain does not exist',
2376: newuser => 'LON-CAPA user(s) do(es) not exist.',
2377: );
2378: foreach my $error ('format','domain','newuser') {
2379: if (defined($disallowed->{$error})) {
2380: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
2381: $lt{$error};
2382: if ($error eq 'newuser') {
1.9 raeburn 2383: $msg .= '<br />'.&mt("Please [_1]add the user(s)[_2] before returning to the [_3]$crstype Configuration[_2] to add as potential cloners.",'<a href="/adm/createuser">','</a>','<a href="/adm/courseprefs">');
1.3 raeburn 2384: }
2385: push(@fails,$msg);
2386: }
2387: }
2388: if (@fails) {
2389: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
2390: '</span>'.join('; ',@fails).'.<br />';
2391: }
2392: } elsif ($item eq 'rolenames') {
2393: my %lt = &Apache::lonlocal::texthash (
2394: replacements => 'Name already used to replace a different standard role name',
2395: regulars => 'Name already used as a standard role name',
2396: customrole => 'Name already used as the name of a custom role',
2397: );
2398: my @fails;
2399: foreach my $error ('replacements','regulars','customrole') {
2400: if (ref($disallowed->{$error}) eq 'ARRAY') {
2401: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
2402: '</b>, '.&mt('reason').' - '.$lt{'error'});
2403: }
2404: }
2405: if (@fails) {
2406: $output .= '<span class="LC_warning">'.
2407: &mt('Unable to include amongst replacements for role names: ').
2408: '</span>'.join('; ',@fails).'.<br />';
2409: }
2410:
2411: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
2412: $output .= '<span class="LC_warning">';
2413: if ($item eq 'feedback') {
1.9 raeburn 2414: if ($crstype eq 'Community') {
2415: $output .= &mt('Unable to include as a recipient of community feedback for:');
2416: } else {
2417: $output .= &mt('Unable to include as a recipient of course feedback for:');
2418: }
1.3 raeburn 2419: } elsif ($item eq 'discussion') {
2420: $output .= &mt('Unable to include in user-based access control for:');
2421: } elsif ($item eq 'localization') {
1.9 raeburn 2422: if ($crstype eq 'Community') {
2423: $output .= &mt('Unable to include in community localization:');
2424: } else {
2425: $output .= &mt('Unable to include in course localization:');
2426: }
1.3 raeburn 2427: }
2428: $output .= '</span><ul>';
2429: foreach my $key (sort(keys(%{$disallowed}))) {
2430: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
2431: $output .= '<li><i>'.$itemtext.'</i> - ';
2432: if ($item eq 'localization') {
2433: $output .= &mt('reason - unsupported language: [_1]',
2434: '<b>'.$disallowed->{$key}.'</b>');
2435: } else {
2436: $output .= &mt('reason - invalid user: [_1]',
2437: '<b>'.$disallowed->{$key}.'</b>').'</li>';
2438: }
2439: }
2440: $output .= '</ul><br />';
2441: }
2442: }
1.1 raeburn 2443: }
1.3 raeburn 2444: return $output;
1.1 raeburn 2445: }
2446:
2447: sub get_course {
2448: my ($courseid) = @_;
2449: if (!defined($courseid)) {
2450: $courseid = $env{'request.course.id'};
2451: }
2452: my $cdom=$env{'course.'.$courseid.'.domain'};
2453: my $cnum=$env{'course.'.$courseid.'.num'};
1.66 raeburn 2454: my $chome=$env{'course.'.$courseid.'.home'};
2455: return ($cnum,$cdom,$chome);
1.1 raeburn 2456: }
2457:
2458: sub get_jscript {
1.91 raeburn 2459: my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
1.12 raeburn 2460: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.71 raeburn 2461: my ($jscript,$categorize_js,$loncaparev_js,$instcode_js);
1.1 raeburn 2462: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
2463: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 2464: my $cloners_js = &cloners_javascript($phase);
1.71 raeburn 2465: my @code_order;
2466: if ($crstype ne 'Community') {
2467: if (ref($settings) eq 'HASH') {
2468: my %codedefaults;
2469: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
2470: \@code_order);
2471: if (@code_order > 0) {
2472: if ($phase eq 'display') {
2473: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
2474: if (grep(/^courseinfo$/,@actions)) {
2475: if ($settings->{'cloners'} ne '') {
2476: unless ($settings->{'cloners'} eq '*') {
2477: my @cloners = split(/,/,$settings->{'cloners'});
2478: my @standardnames = &Apache::loncommon::get_standard_codeitems();
2479: my %local_to_standard;
2480: for (my $i=0; $i<@code_order; $i++) {
2481: $local_to_standard{$code_order[$i]} = $standardnames[$i];
2482: }
2483: foreach my $cloner (@cloners) {
2484: if (($cloner !~ /^\Q*:\E$match_domain$/) &&
2485: ($cloner !~ /^$match_username\:$match_domain$/)) {
2486: foreach my $item (split(/\&/,$cloner)) {
2487: my ($key,$val) = split(/\=/,$item);
2488: $val = &unescape($val);
2489: foreach my $code (@code_order) {
2490: if ($key eq $local_to_standard{$code}) {
2491: $env{'form.'.$key} = $val;
2492: }
2493: }
2494: }
2495: }
2496: }
2497: }
2498: }
2499: }
2500: }
2501: my @codetitles;
2502: (undef,$instcode_js) =
2503: &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
2504: \@codetitles);
2505: $instcode_js .= <<ENDSCRIPT;
2506: function toggleCloners(callerradio) {
2507: if (document.getElementById('LC_cloners_instcode')) {
2508: if (callerradio.value == 1) {
2509: document.getElementById('LC_cloners_instcode').style.display = "block";
2510: } else {
2511: uncheckOfficialLists();
2512: document.getElementById('LC_cloners_instcode').style.display = "none";
2513: }
2514: }
2515: }
2516:
2517: if (!document.getElementsByClassName) {
2518: function getElementsByClassName(node, classname) {
2519: var a = [];
2520: var re = new RegExp('(^| )'+classname+'( |$)');
2521: var els = node.getElementsByTagName("*");
2522: for(var i=0,j=els.length; i<j; i++)
2523: if(re.test(els[i].className))a.push(els[i]);
2524: return a;
2525: }
2526: }
2527:
2528: function uncheckOfficialLists() {
2529: var codepicks;
2530: if (document.getElementsByClassName) {
2531: codepicks = document.getElementsByClassName('LC_cloners_instcodes');
2532: } else {
2533: codepicks = getElementsByClassName(document.body,'LC_cloners_instcodes');
2534: }
2535: if (codepicks.length) {
2536: for (var i=0; i<codepicks.length; i++) {
2537: codepicks[i].selectedIndex = 0;
2538: }
2539: }
2540: }
2541:
2542: ENDSCRIPT
2543: }
2544: }
2545: }
1.1 raeburn 2546: if ($can_categorize) {
2547: $categorize_js = <<ENDSCRIPT;
2548: function catsbrowser() {
2549: var catswin = null;
2550: var url = '/adm/courseprefs?phase=categorizecourse';
2551: if (!catswin || catswin.closed) {
2552: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2553: } else {
2554: catswin.focus();
2555: }
2556: }
2557: ENDSCRIPT
2558: }
1.36 raeburn 2559: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
2560: if ($loncaparev) {
2561: $loncaparev_js = <<ENDSCRIPT;
2562: function loncaparevinfo() {
2563: var lcrevwin = null;
2564: var url = '/adm/courseprefs?phase=releaseinfo';
2565: if (!lcrevwin || lcrevwin.closed) {
2566: lcrevwin=window.open(url,'releasewin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2567: } else {
2568: lcrevwin.focus();
2569: }
2570: }
2571: ENDSCRIPT
2572: }
1.60 raeburn 2573: my $cnum = $env{'course.'.$cid.'.num'};
2574: my $syllabus_js = <<ENDSCRIPT;
2575: function syllabusinfo() {
2576: var syllwin = null;
2577: var url = '/public/$cdom/$cnum/syllabus?only_body=1';
2578: if (!syllwin || syllwin.closed) {
2579: syllwin=window.open(url,'syllabuswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2580: } else {
2581: syllwin.focus();
2582: }
2583: }
2584: ENDSCRIPT
1.91 raeburn 2585: my $menuitems_js;
2586: unless ($noedit) {
2587: my $collections;
2588: my $next = 1;
2589: if (ref($settings) eq 'HASH') {
2590: if ($settings->{'menucollections'} ne '') {
2591: my @current;
2592: foreach my $item (split(/;/,$settings->{'menucollections'})) {
2593: my ($num) = split(/\%/,$item);
2594: if ($num =~ /^\d+$/) {
2595: push(@current,$num);
2596: }
2597: }
2598: $collections = join("','",sort { $a <=> $b } @current);
2599: if ($collections) {
2600: $collections = "'$collections'";
2601: }
2602: $next += $current[-1];
2603: }
2604: }
2605: my $deftext = &mt('Standard (all menus shown)');
2606: $menuitems_js = <<ENDSCRIPT;
2607: function toggleAddmenucoll() {
2608: if (document.getElementById('menucollections_add')) {
2609: var state = 'none';
2610: var add = document.getElementById('menucollections_add').checked;
2611: if (add) {
2612: state = 'inline-block';
2613: }
2614: var fieldsets = new Array('shown','text','links','list','inline');
2615: for (var i=0; i<fieldsets.length; i++) {
2616: if (document.getElementById('addmenucoll_'+fieldsets[i])) {
2617: document.getElementById('addmenucoll_'+fieldsets[i]).style.display = state;
2618: }
2619: }
2620: var box = document.getElementsByClassName('LC_menucoll_add');
2621: if (box.length) {
2622: for (var i=0; i<box.length; i++) {
2623: if (add) {
2624: box[i].checked = true;
2625: } else {
2626: box[i].checked = false;
2627: }
2628: }
2629: }
2630: if (document.getElementById('menudefault')) {
2631: var menudef = document.getElementById('menudefault');
2632: var currsel = menudef.selectedIndex;
2633: var colls = new Array($collections);
2634: menudef.options.length = 0;
2635: if (!add) {
2636: if (currsel == 1 + colls.length) {
2637: currsel = 0;
2638: }
2639: }
2640: if (currsel == 0) {
2641: menudef.options[0] = new Option('$deftext','',true,true);
2642: } else {
2643: menudef.options[0] = new Option('$deftext','',false,false);
2644: }
2645: if (colls.length) {
2646: for (var i=0; i<colls.length; i++) {
2647: var idx = i+1;
2648: if (currsel == colls[i]) {
2649: menudef.options[idx] = new Option(colls[i],colls[i],true,true);
2650: } else {
2651: menudef.options[idx] = new Option(colls[i],colls[i],false,false);
2652: }
2653: }
2654: }
2655: if (add) {
2656: var addidx = 1 + colls.length;
2657: if (currsel == addidx) {
2658: menudef.options[addidx] = new Option('$next','$next',true,true);
2659: } else {
2660: menudef.options[addidx] = new Option('$next','$next',false,false);
2661: }
2662: }
2663: }
2664: }
2665: }
2666: ENDSCRIPT
2667: }
1.1 raeburn 2668: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.56 raeburn 2669: '// <![CDATA['."\n".
1.36 raeburn 2670: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
1.71 raeburn 2671: $cloners_js."\n".$instcode_js.
1.99 raeburn 2672: $syllabus_js."\n".$menuitems_js."\n".
1.102 raeburn 2673: &linkprot_javascript()."\n".'//]]>'."\n".
1.56 raeburn 2674: '</script>'."\n".$stubrowse_js."\n";
1.1 raeburn 2675: return $jscript;
2676: }
2677:
1.3 raeburn 2678: sub cloners_javascript {
2679: my ($formname) = @_;
2680: return <<"ENDSCRIPT";
2681:
2682: function update_cloners(caller,num) {
2683: var delidx = getIndexByName('cloners_delete');
2684: var actidx = getIndexByName('cloners_activate');
2685: if (caller == 'cloners_all') {
2686: var selall;
2687: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2688: if (document.$formname.cloners_all[i].checked) {
2689: selall = document.$formname.cloners_all[i].value;
2690: }
2691: }
2692: if (selall == 1) {
2693: if (delidx != -1) {
2694: if (document.$formname.cloners_delete.length) {
2695: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
2696: document.$formname.cloners_delete[j].checked = true;
2697: }
2698: } else {
2699: document.$formname.elements[delidx].checked = true;
2700: }
2701: }
2702: if (actidx != -1) {
2703: if (document.$formname.cloners_activate.length) {
2704: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
2705: if (document.$formname.cloners_activate[i].value == '0') {
2706: document.$formname.cloners_activate[i].checked = false;
2707: }
1.71 raeburn 2708: if (document.$formname.cloners_activate[i].value == '-1') {
1.3 raeburn 2709: document.$formname.cloners_activate[i].checked = true;
2710: }
2711: }
2712: }
2713: }
2714: document.$formname.cloners_newdom.selectedIndex = 0;
2715: }
2716: }
2717: if (caller == 'cloners_activate') {
2718: if (document.$formname.cloners_activate.length) {
2719: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
2720: if (document.$formname.cloners_activate[j].value == num) {
2721: if (document.$formname.cloners_activate[j].checked) {
2722: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2723: if (document.$formname.cloners_all[i].value == '1') {
2724: document.$formname.cloners_all[i].checked = false;
2725: }
2726: if (document.$formname.cloners_all[i].value == '0') {
2727: document.$formname.cloners_all[i].checked = true;
2728: }
2729: }
2730: }
2731: }
2732: }
2733: } else {
2734: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2735: if (document.$formname.cloners_all[i].value == '1') {
2736: document.$formname.cloners_all[i].checked = false;
2737: }
2738: if (document.$formname.cloners_all[i].value == '0') {
2739: document.$formname.cloners_all[i].checked = true;
2740: }
2741: }
2742: }
2743: }
2744: return;
2745: }
2746:
2747: function getIndexByName(item) {
2748: for (var i=0;i<document.$formname.elements.length;i++) {
2749: if (document.$formname.elements[i].name == item) {
2750: return i;
2751: }
2752: }
2753: return -1;
2754: }
2755:
2756: ENDSCRIPT
2757: }
2758:
1.102 raeburn 2759: sub linkprot_javascript {
2760: return <<"ENDSCRIPT";
2761: function toggleLinkProt(form,num,item) {
2762: var radioname = '';
2763: var currdivid = '';
2764: var newdivid = '';
2765: if ((document.getElementById('linkprot_divcurr'+item+'_'+num)) &&
2766: (document.getElementById('linkprot_divchg'+item+'_'+num))) {
2767: currdivid = document.getElementById('linkprot_divcurr'+item+'_'+num);
2768: newdivid = document.getElementById('linkprot_divchg'+item+'_'+num);
2769: radioname = form.elements['linkprot_change'+item+'_'+num];
2770: if (radioname) {
2771: if (radioname.length > 0) {
2772: var setvis;
2773: for (var i=0; i<radioname.length; i++) {
2774: if (radioname[i].checked == true) {
2775: if (radioname[i].value == 1) {
2776: newdivid.style.display = 'inline-block';
2777: currdivid.style.display = 'none';
2778: setvis = 1;
2779: }
2780: break;
2781: }
2782: }
2783: if (!setvis) {
2784: newdivid.style.display = 'none';
2785: currdivid.style.display = 'inline-block';
2786: }
2787: }
2788: }
2789: }
2790: return;
2791: }
2792:
2793: function toggleLinkProtReqUser(form,item,extra,valon,styleon,num) {
2794: if (document.getElementById('linkprot_'+extra+'_'+num)) {
2795: var extraid = document.getElementById('linkprot_'+extra+'_'+num);
2796: var itemname = form.elements['linkprot_'+item+'_'+num];
2797: if (itemname) {
2798: if (itemname.length > 0) {
2799: var setvis;
2800: for (var i=0; i<itemname.length; i++) {
2801: if (itemname[i].checked == true) {
2802: if (itemname[i].value == valon) {
2803: extraid.style.display = styleon;
2804: setvis = 1;
2805: }
2806: break;
2807: }
2808: }
2809: if (!setvis) {
2810: extraid.style.display = 'none';
2811: }
2812: }
2813: }
2814: }
2815: return;
2816: }
2817: ENDSCRIPT
2818:
2819: }
2820:
1.3 raeburn 2821:
1.1 raeburn 2822: sub print_courseinfo {
1.80 raeburn 2823: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 2824: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2825: return;
2826: }
1.83 raeburn 2827: my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
2828: if ($noedit) {
2829: $disabled = ' disabled="disabled"';
2830: }
1.1 raeburn 2831: my %domconf =
1.71 raeburn 2832: &Apache::lonnet::get_dom('configuration',
2833: ['coursecategories','autoenroll','coursedefaults'],$cdom);
1.1 raeburn 2834: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2835: $cathash = $domconf{'coursecategories'}{'cats'};
2836: if (ref($cathash) eq 'HASH') {
2837: $categoriesform =
2838: &Apache::loncommon::assign_categories_table($cathash,
1.83 raeburn 2839: $settings->{'categories'},$crstype,$disabled)."\n";
1.1 raeburn 2840: }
2841: }
1.25 raeburn 2842: if (ref($domconf{'autoenroll'}) eq 'HASH') {
2843: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
2844: }
1.71 raeburn 2845: my ($currcanclone,@code_order,$cloner_instcode);
2846: my %codedefaults;
2847: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
2848: \@code_order);
2849: if ($settings->{'cloners'}) {
2850: unless ($settings->{'cloners'} eq '*') {
2851: my @currclone = split(/,/,$settings->{'cloners'});
2852: foreach my $item (@currclone) {
2853: unless ($item eq '*') {
2854: if (($item !~ /\:/) && ($item =~ /=/)) {
2855: $cloner_instcode = 1;
2856: }
2857: }
2858: }
2859: }
2860: }
2861: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
2862: my $canclone = $domconf{'coursedefaults'}{'canclone'};
2863: if (ref($canclone) eq 'HASH') {
2864: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
2865: if ($settings->{'internal.coursecode'}) {
2866: my @posscodes;
2867: if (@code_order > 0) {
2868: $currcanclone = 'instcode';
2869: foreach my $item (@{$canclone->{'instcode'}}) {
2870: if (grep(/^\Q$item\E$/,@code_order)) {
2871: push(@posscodes,$item);
2872: }
2873: }
2874: my $codestr = join(' + ',@posscodes);
2875: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
2876: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
2877: }
2878: }
2879: }
2880: } elsif ($canclone eq 'domain') {
2881: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
2882: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
2883: $currcanclone = 'domain';
2884: }
2885: if ($clonedefaults) {
2886: if ($settings->{'cloners'} ne '') {
2887: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
2888: } else {
2889: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
2890: }
2891: $clonedefaults = '<br /><br />'.$clonedefaults;
2892: }
2893: }
1.1 raeburn 2894: if (!defined($categoriesform)) {
1.15 raeburn 2895: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 2896: }
1.12 raeburn 2897: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.60 raeburn 2898: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 2899:
1.9 raeburn 2900: my $replace;
2901: if ($crstype eq 'Community') {
2902: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2903: } else {
2904: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2905: }
1.84 raeburn 2906: my ($editmap,$editsyllabus);
2907: unless ($noedit) {
2908: $editmap = (' 'x2).
2909: '<a href="javascript:openbrowser'.
2910: "('display','url','sequence')\">".
2911: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
2912: &mt('Modification may make assessment data inaccessible!').
2913: '</span>';
2914: $editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
2915: '</a>');
2916: }
1.1 raeburn 2917: my %items = (
1.3 raeburn 2918: 'url' => {
1.84 raeburn 2919: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.$editmap,
1.1 raeburn 2920: input => 'textbox',
1.55 raeburn 2921: size => '55',
1.19 faziophi 2922: advanced => 1
1.1 raeburn 2923: },
2924: 'description' => {
1.3 raeburn 2925: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 2926: input => 'textbox',
1.55 raeburn 2927: size => '55',
1.1 raeburn 2928: },
1.24 raeburn 2929: 'owner' => {
2930: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
2931: },
1.25 raeburn 2932: 'co-owners' => {
2933: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
2934: },
1.63 raeburn 2935: 'clonedfrom' => {
2936: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
2937: },
1.1 raeburn 2938: 'courseid' => {
1.3 raeburn 2939: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
2940: &mt('internal, optional').')',
1.1 raeburn 2941: input => 'textbox',
2942: size => '25',
2943: },
1.64 raeburn 2944: 'uniquecode' => {
2945: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
2946: },
1.1 raeburn 2947: 'cloners' => {
1.3 raeburn 2948: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.71 raeburn 2949: &mt('Owner and Coordinators included automatically').
2950: $clonedefaults,
1.1 raeburn 2951: input => 'textbox',
1.41 www 2952: size => '40'
1.1 raeburn 2953: },
2954: 'rolenames' => {
1.3 raeburn 2955: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 2956: '('.$replace.')',
1.1 raeburn 2957: input => 'textbox',
2958: size => '20',
1.19 faziophi 2959: advanced => 1
1.1 raeburn 2960: },
1.88 raeburn 2961: 'syllabus' => {
2962: text => '<b>'.&mt($itemtext->{'syllabus'}).'</b><br />'.
1.60 raeburn 2963: &mt('(Syllabus type in use)').(' ' x2).
1.84 raeburn 2964: $editsyllabus,
1.1 raeburn 2965: },
2966: 'hidefromcat' => {
1.3 raeburn 2967: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 2968: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
2969: input => 'radio',
2970: },
2971: 'categories' => {
1.3 raeburn 2972: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 2973: &mt('Display Categories').'</a>',
2974: input => 'textbox',
2975: size => '25',
2976: },
1.35 raeburn 2977: 'loncaparev' => {
2978: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
2979: },
1.55 raeburn 2980: 'defaultcredits' => {
2981: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
2982: },
1.1 raeburn 2983: );
2984: my $datatable;
2985: my $count = 0;
2986: foreach my $item (@{$ordered}) {
1.56 raeburn 2987: my $colspan;
1.1 raeburn 2988: if ($item eq 'hidefromcat') {
2989: next if (!$can_toggle_cat);
2990: } elsif ($item eq 'categories') {
2991: next if (!$can_categorize);
1.64 raeburn 2992: } elsif ($item eq 'uniquecode') {
2993: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 2994: }
1.56 raeburn 2995: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
2996: $colspan = 2;
2997: }
1.1 raeburn 2998: $count ++;
1.19 faziophi 2999: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1.56 raeburn 3000: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 3001: } else {
1.56 raeburn 3002: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.19 faziophi 3003: }
1.1 raeburn 3004: if ($items{$item}{input} eq 'radio') {
1.80 raeburn 3005: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 3006: } elsif ($item eq 'cloners') {
3007: my $includeempty = 1;
3008: my $num = 0;
1.56 raeburn 3009: $datatable .= '</td><td align="right">'.
3010: &Apache::loncommon::start_data_table().
1.1 raeburn 3011: &Apache::loncommon::start_data_table_row().
3012: '<td><span class="LC_nobreak"><label>'.
3013: &mt('Any user in any domain:').
3014: ' <input type="radio" name="cloners_all" value="1" ';
3015: if ($settings->{$item} eq '*') {
3016: $datatable .= ' checked="checked" ';
3017: }
3018: $datatable .= 'onchange="javascript:update_cloners('.
1.80 raeburn 3019: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 3020: (' 'x2).'<label>'.
3021: '<input type="radio" name="cloners_all" value="0" ';
1.1 raeburn 3022: if ($settings->{$item} ne '*') {
3023: $datatable .= ' checked="checked" ';
3024: }
3025: $datatable .= ' onchange="javascript:update_cloners('.
1.80 raeburn 3026: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
1.1 raeburn 3027: &Apache::loncommon::end_data_table_row().
3028: &Apache::loncommon::end_data_table().
1.56 raeburn 3029: '<table><tr><td align="left"><b>'.&mt('Or').
3030: '</b></td></tr></table>'.
1.1 raeburn 3031: &Apache::loncommon::start_data_table();
3032: my @cloners;
3033: if ($settings->{$item} eq '') {
1.80 raeburn 3034: unless ($noedit) {
3035: my $default;
3036: if ($currcanclone eq 'domain') {
3037: $default = '0';
3038: }
3039: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
1.71 raeburn 3040: }
1.1 raeburn 3041: } elsif ($settings->{$item} ne '*') {
3042: my @entries = split(/,/,$settings->{$item});
3043: if (@entries > 0) {
3044: foreach my $entry (@entries) {
3045: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 3046: if ($udom =~ /^$match_domain$/) {
3047: unless (&Apache::lonnet::domain($udom)) {
3048: next;
3049: }
3050: } else {
3051: next;
3052: }
1.1 raeburn 3053: if ($uname eq '*') {
3054: $datatable .=
3055: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3056: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 3057: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 3058: '</b><input type="hidden" name="cloners_dom_'.$num.
3059: '" value="'.$udom.'" /></span><br />'.
3060: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 3061: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
1.1 raeburn 3062: &mt('Delete').'</label></span></td>'.
3063: &Apache::loncommon::end_data_table_row();
3064: $num ++;
1.23 raeburn 3065: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3066: unless (grep(/^\Q$entry\E$/,@cloners)) {
3067: push(@cloners,$entry);
3068: }
1.1 raeburn 3069: }
3070: }
3071: }
3072: }
3073: my $add_domtitle = &mt('Any user in additional domain:');
3074: if ($settings->{$item} eq '*') {
3075: $add_domtitle = &mt('Any user in specific domain:');
3076: } elsif ($settings->{$item} eq '') {
3077: $add_domtitle = &mt('Any user in other domain:');
3078: }
3079: my $cloners_str = join(',',@cloners);
3080: $datatable .= &Apache::loncommon::start_data_table_row().
3081: '<td align="left"><span class="LC_nobreak">'.
3082: $add_domtitle.'</span><br />'.
3083: &Apache::loncommon::select_dom_form('','cloners_newdom',
1.80 raeburn 3084: $includeempty,undef,undef,
3085: undef,undef,$noedit).
1.1 raeburn 3086: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
3087: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 3088: &Apache::loncommon::end_data_table().
1.56 raeburn 3089: '<table><tr><td align="left"><b>'.&mt('And').
3090: '</b></td></tr></table>'.
1.1 raeburn 3091: &Apache::loncommon::start_data_table().
3092: &Apache::loncommon::start_data_table_row().
3093: '<td align="left">'.
3094: &mt('Specific users').' (<tt>'.
3095: &mt('user:domain,user:domain').'</tt>)<br />'.
3096: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1.80 raeburn 3097: $items{$item}{'size'},$disabled).
1.1 raeburn 3098: '</td>'.&Apache::loncommon::end_data_table_row().
3099: &Apache::loncommon::end_data_table();
1.71 raeburn 3100: if (@code_order > 0) {
3101: my (%cat_items,@codetitles,%cat_titles,%cat_order);
3102: my ($jscript,$totcodes,$numtitles,$lasttitle) =
3103: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
3104: \%cat_items,\@codetitles,
3105: \%cat_titles,\%cat_order);
3106: my $showncodes = 'off';
3107: my $checkedoff = ' checked="checked"';
3108: my $checkedon = '';
3109: if ($cloner_instcode) {
3110: $checkedon = $checkedoff;
3111: $checkedoff = '';
3112: $showncodes = 'on';
3113: }
3114: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
3115: '</b></td></tr></table>'.
3116: &Apache::loncommon::start_data_table().
3117: &Apache::loncommon::start_data_table_row().
3118: '<td align="left"><span class="LC_nobreak">'.
3119: &mt('Cloning by official course(s) based on course category').(' 'x2).
3120: '<label>'.
1.80 raeburn 3121: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 3122: (' ').
3123: '<label>'.
1.80 raeburn 3124: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
1.71 raeburn 3125: &Apache::courseclassifier::build_instcode_selectors($numtitles,
3126: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1.80 raeburn 3127: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
1.71 raeburn 3128: '</td>'.&Apache::loncommon::end_data_table_row().
3129: &Apache::loncommon::end_data_table();
3130: }
1.1 raeburn 3131: } elsif ($item eq 'rolenames') {
1.56 raeburn 3132: $datatable .= '</td><td align="right">'.
3133: &Apache::loncommon::start_data_table();
1.9 raeburn 3134: my @roles;
3135: if ($crstype eq 'Community') {
3136: @roles = ('co');
3137: } else {
3138: @roles = ('cc');
3139: }
3140: push (@roles,('in','ta','ep','ad','st'));
3141: foreach my $role (@roles) {
1.1 raeburn 3142: $datatable .= &Apache::loncommon::start_data_table_row().
3143: '<td align="left"><span class="LC_nobreak">'.
3144: &Apache::lonnet::plaintext($role,$crstype,undef,1).
3145: '</span></td><td align="left">'.
3146: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
3147: $settings->{$role.'.plaintext'},
1.80 raeburn 3148: $items{$item}{size},$disabled).'</td>'.
1.1 raeburn 3149: &Apache::loncommon::end_data_table_row();
3150: }
3151: $datatable .= &Apache::loncommon::end_data_table().'</td>';
3152: } elsif ($item eq 'categories') {
1.80 raeburn 3153: my $launcher;
3154: if ($noedit) {
3155: $launcher = $disabled;
3156: } else {
3157: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
3158: }
1.3 raeburn 3159: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
3160: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
3161: $items{$item}{size},$launcher);
1.24 raeburn 3162: } elsif ($item eq 'owner') {
3163: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
3164: if ($owner =~ /:/) {
3165: my ($ownername,$ownerdom) = split(':',$owner);
3166: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
3167: } elsif ($owner ne '') {
3168: $owner = &Apache::loncommon::plainname($owner,$cdom);
3169: } else {
3170: $owner = &mt('None specified');
3171: }
3172: $datatable .= $owner;
1.63 raeburn 3173: } elsif ($item eq 'clonedfrom') {
3174: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
3175: my $clonedfrom = &mt('None');
3176: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
1.65 raeburn 3177: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.63 raeburn 3178: if ($clonesrcinfo{'description'}) {
3179: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
3180: }
3181: }
3182: $datatable .= $clonedfrom;
1.64 raeburn 3183: } elsif ($item eq 'uniquecode') {
3184: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
3185: if ($code) {
3186: $datatable .= $code;
3187: }
1.25 raeburn 3188: } elsif ($item eq 'co-owners') {
3189: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
3190: my @currcoown;
3191: if ($coowners) {
3192: @currcoown = split(',',$coowners);
3193: }
3194: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
3195: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
3196: $datatable .= &show_autocoowners(@currcoown);
3197: } else {
1.80 raeburn 3198: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 3199: }
3200: } else {
3201: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
3202: $datatable .= &show_autocoowners(@currcoown);
3203: } else {
1.80 raeburn 3204: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 3205: }
3206: }
1.88 raeburn 3207: } elsif ($item eq 'syllabus') {
1.60 raeburn 3208: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
3209: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
3210: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
3211: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
3212: if ($minimal =~/\w/) {
3213: if ($external =~ m{\Q$minimal\E$}) {
3214: undef($external);
3215: }
3216: } elsif ($uploaded =~/\w/) {
3217: if ($external =~ m{\Q$uploaded\E$}) {
3218: undef($external);
3219: }
3220: }
3221: } elsif ($external!~/\w/) {
3222: undef($external);
3223: }
3224: if ($external) {
3225: $datatable .= &mt('External URL');
3226: } elsif ($minimal) {
3227: $datatable .= &mt('Minimal template');
3228: } elsif ($uploaded) {
3229: $datatable .= &mt('Uploaded file');
3230: } else {
3231: $datatable .= &mt('Standard template');
3232: }
3233: $datatable .= (' ' x 2).
3234: &mt('[_1]View[_2]',
3235: '<a href="javascript:syllabusinfo();">',
3236: '</a>');
1.35 raeburn 3237: } elsif ($item eq 'loncaparev') {
3238: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
3239: my $showreqd;
3240: if ($loncaparev) {
1.36 raeburn 3241: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 3242: &mt('Details').'</a>';
1.35 raeburn 3243: } else {
3244: $showreqd = &mt('No specific version required');
3245: }
3246: $datatable .= $showreqd;
1.1 raeburn 3247: } else {
1.80 raeburn 3248: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
1.1 raeburn 3249: }
3250: $datatable .= &item_table_row_end();
3251: }
3252: $$rowtotal += scalar(@{$ordered});
3253: return $datatable;
3254: }
3255:
3256: sub new_cloners_dom_row {
1.71 raeburn 3257: my ($newdom,$num,$default) = @_;
3258: my ($output,$checkedon,$checkedoff);
1.1 raeburn 3259: if ($newdom ne '') {
1.71 raeburn 3260: if ($num eq $default) {
3261: $checkedon = 'checked="checked" ';
3262: } else {
3263: $checkedoff = 'checked="checked" ';
3264: }
1.1 raeburn 3265: $output .= &Apache::loncommon::start_data_table_row().
3266: '<td valign="top"><span class="LC_nobreak">'.
3267: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
3268: (' 'x2).'<label><input type="radio" '.
1.71 raeburn 3269: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
1.3 raeburn 3270: 'onchange="javascript:update_cloners('.
1.1 raeburn 3271: "'cloners_activate','$num'".');" />'.
3272: &mt('Yes').'</label>'.(' 'x2).
3273: '<label><input type="radio" '.
1.71 raeburn 3274: 'name="cloners_activate" value="-1" '.$checkedoff.
1.3 raeburn 3275: 'onchange="javascript:update_cloners('.
1.1 raeburn 3276: "'cloners_activate','$num'".');" />'.
1.3 raeburn 3277: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
3278: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 3279: &Apache::loncommon::end_data_table_row();
3280: }
3281: return $output;
3282: }
3283:
3284: sub can_modify_catsettings {
1.12 raeburn 3285: my ($dom,$crstype) = @_;
1.1 raeburn 3286: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
3287: my ($can_toggle_cat,$can_categorize);
3288: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 3289: if ($crstype eq 'Community') {
3290: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
3291: $can_toggle_cat = 1;
3292: }
3293: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
3294: $can_categorize = 1;
3295: }
3296: } else {
3297: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
3298: $can_toggle_cat = 1;
3299: }
3300: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
3301: $can_categorize = 1;
3302: }
1.1 raeburn 3303: }
3304: }
3305: return ($can_toggle_cat,$can_categorize);
3306: }
3307:
3308: sub assign_course_categories {
1.9 raeburn 3309: my ($r,$crstype) = @_;
1.1 raeburn 3310: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3311: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3312: my $hascats = 0;
3313: my $cathash;
3314: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
3315: if (ref($domconf{'coursecategories'}) eq 'HASH') {
3316: $cathash = $domconf{'coursecategories'}{'cats'};
3317: if (ref($cathash) eq 'HASH') {
1.12 raeburn 3318: foreach my $cat (keys(%{$cathash})) {
3319: next if ($cat eq 'instcode::0');
3320: unless ($crstype eq 'Community') {
3321: next if ($cat eq 'communities::0');
3322: }
3323: $hascats ++;
3324: }
1.1 raeburn 3325: }
3326: }
3327: my $catwin_js;
3328: if ($hascats) {
1.9 raeburn 3329: my $alert;
3330: if ($crstype eq 'Community') {
3331: $alert = &mt("Use 'Save' in the main window to save community categories");
3332: } else {
3333: $alert = &mt("Use 'Save' in the main window to save course categories");
3334: }
1.72 damieng 3335: &js_escape(\$alert);
1.1 raeburn 3336: $catwin_js = <<ENDSCRIPT;
3337: <script type="text/javascript">
3338:
3339: function updateCategories() {
3340: var newcategories = '';
3341: var unescapedcats = '';
3342: if (document.chgcats.usecategory.length) {
3343: for (var i=0; i<document.chgcats.usecategory.length; i++) {
3344: if (document.chgcats.usecategory[i].checked == true) {
3345: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
3346: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
3347: }
3348: }
3349: if (newcategories.length > 0) {
3350: newcategories = newcategories.slice(0,-1);
3351: }
3352: if (unescapedcats.length > 0) {
3353: unescapedcats = unescapedcats.slice(0,-3);
3354: }
3355: } else {
3356: if (document.chgcats.usecategory.checked == true) {
3357: newcategories = document.chgcats.usecategory.value;
3358: unescapedcats = document.chgcats.catname.value;
3359: }
3360: }
3361: opener.document.display.categories.value = newcategories;
3362: opener.document.display.categories_display.value = unescapedcats;
3363: alert("$alert");
3364: self.close();
3365: return;
3366: }
3367:
3368: </script>
3369: ENDSCRIPT
3370: } else {
3371: my $onload;
3372: }
1.9 raeburn 3373: my ($crscat,$catcrs,$assign);
3374: if ($crstype eq 'Community') {
3375: $crscat = 'Community Categories';
3376: $catcrs = &mt('Categorize Community');
3377: $assign = &mt('Assign one or more categories to this community.')
3378: } else {
3379: $crscat = 'Course Categories';
3380: $catcrs = &mt('Categorize Course');
3381: $assign = &mt('Assign one or more categories to this course.')
3382: }
1.1 raeburn 3383: my $start_page =
1.9 raeburn 3384: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 3385: {'only_body' => 1,});
3386: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 3387: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 3388: if ($hascats) {
3389: my %currsettings =
3390: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 3391: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
3392: $currsettings{'categories'},$crstype);
3393: if ($cattable eq '') {
3394: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
3395: } else {
3396: $categoriesform .= $assign.'<br /><br />'.
3397: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
3398: $cattable."\n".
3399: '<br /><input type="button" name="changes" value="'.
3400: &mt('Copy to main window').'" '.
3401: 'onclick="javascript:updateCategories()" /></form><br />';
3402: }
1.1 raeburn 3403: } else {
1.12 raeburn 3404: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 3405: }
3406: $r->print($start_page.$categoriesform.$end_page);
3407: return;
3408: }
3409:
1.36 raeburn 3410: sub display_loncaparev_constraints {
3411: my ($r,$navmap,$loncaparev,$crstype) = @_;
1.66 raeburn 3412: my ($reqdmajor,$reqdminor);
1.36 raeburn 3413: my $cid = $env{'request.course.id'};
3414: my $cdom = $env{'course.'.$cid.'.domain'};
3415: my $cnum = $env{'course.'.$cid.'.num'};
3416: my $output;
1.39 raeburn 3417: my %lt = &Apache::lonlocal::texthash (
3418: 'all' => 'all',
3419: 'section/group' => 'section/group',
3420: 'user' => 'user',
3421: );
1.66 raeburn 3422: &Apache::lonrelrequtils::init_global_hashes();
3423: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
3424: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
1.36 raeburn 3425: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
1.66 raeburn 3426: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 3427: }
3428: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.85 raeburn 3429: %byresponsetype,%bysubmission,%fromblocks,%bycrsrestype);
1.39 raeburn 3430: @scopeorder = ('all','section/group','user');
1.67 raeburn 3431: my $now = time;
1.36 raeburn 3432: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
3433: if (ref($resourcedata) eq 'HASH') {
3434: foreach my $key (keys(%{$resourcedata})) {
1.70 raeburn 3435: my %found;
1.66 raeburn 3436: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 3437: if ($key =~ /(\Q$item\E)$/) {
1.70 raeburn 3438: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
3439: my $value = $resourcedata->{$key};
3440: if ($item eq 'examcode') {
3441: if (&Apache::lonnet::validCODE($value)) {
3442: $value = 'valid';
3443: } else {
3444: $value = '';
3445: }
3446: } elsif ($item eq 'printstartdate') {
1.67 raeburn 3447: if ($value =~ /^\d+$/) {
1.70 raeburn 3448: if ($value > $now) {
3449: $value = 'future';
3450: }
3451: }
3452: } elsif ($item eq 'printenddate') {
3453: if ($value =~ /^\d+$/) {
3454: if ($value < $now) {
3455: $value = 'past';
3456: }
3457: }
3458: }
3459: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
3460: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
3461: $found{$item}{'valname'} = &get_param_description($stdtype,$value);
1.76 raeburn 3462: $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'};
1.70 raeburn 3463: }
3464: }
3465: }
3466: }
1.79 raeburn 3467: foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) {
3468: if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') {
1.70 raeburn 3469: my $value = $resourcedata->{$key};
1.79 raeburn 3470: foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) {
1.70 raeburn 3471: if ($value =~ /$valuematch/) {
3472: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
1.74 raeburn 3473: $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
1.70 raeburn 3474: $found{$item}{'rev'} =
1.76 raeburn 3475: $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'};
1.70 raeburn 3476: last;
3477: }
3478: }
3479: }
3480: }
1.76 raeburn 3481: foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) {
3482: my $regexp;
3483: if ($item eq 'maplevelrecurse') {
3484: $regexp = '\.(?:sequence|page)___\(rec\)\.';
3485: }
3486: if ($regexp ne '') {
3487: if ($key =~ /$regexp.*\.(\w+)$/) {
3488: my $name = $1;
3489: my $value = $resourcedata->{$key};
3490: if ($name eq 'type') {
3491: last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') ||
3492: ($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') ||
3493: ($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library'));
3494: }
3495: my $stdtype = &Apache::lonparmset::standard_parameter_types($name);
3496: $found{$name}{'valname'} = &get_param_description($stdtype,$value);
3497: $found{$name}{'extra'} = &mt('Recursive into sub-folders');
3498: $found{$name}{'rev'} =
3499: $Apache::lonnet::needsrelease{'parameter::::'.$item};
3500: }
3501: }
3502: }
1.70 raeburn 3503: foreach my $item (keys(%found)) {
3504: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
3505: my $rev = $found{$item}{'rev'};
3506: my $valname = $found{$item}{'valname'};
1.76 raeburn 3507: my $extra = $found{$item}{'extra'};
1.70 raeburn 3508: my ($middle,$scope,$which,$level,$map,$resource);
3509: my $start = $cid.'.';
3510: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
3511: $middle = $1;
3512: $which = $2;
3513: $scope = 'user';
3514: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
3515: $middle = $1;
3516: $which = $2;
3517: $scope = 'section/group';
3518: } else {
3519: $scope = 'all';
3520: }
3521: my $what="$stdname=$valname";
1.76 raeburn 3522: if ($extra) {
3523: $what .= "<br/>$extra<br />";
3524: }
1.70 raeburn 3525: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
3526: $level = 'general';
3527: if ($scope eq 'all') {
3528: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
3529: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
3530: push(@{$fromparam{$rev}{$scope}},$what);
3531: }
3532: } else {
3533: push(@{$fromparam{$rev}{$scope}},$what);
3534: }
3535: } else {
3536: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
3537: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
3538: push(@{$fromparam{$rev}{$scope}{$which}},$what);
3539: }
3540: } else {
3541: push(@{$fromparam{$rev}{$scope}{$which}},$what);
3542: }
3543: }
3544: $rowspan{$rev} ++;
1.76 raeburn 3545: } elsif ($key =~ /^\Q$start$middle\E(.+)___\((all|rec)\).\w+\.\Q$item\E$/) {
1.70 raeburn 3546: $level = 'folder';
3547: $map = $1;
3548: if ($scope eq 'all') {
3549: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
3550: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
3551: push(@{$bymap{$map}{$rev}{$scope}},$what);
3552: }
3553: } else {
3554: push(@{$bymap{$map}{$rev}{$scope}},$what);
3555: }
3556: } else {
3557: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
3558: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
3559: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
3560: }
3561: } else {
3562: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
3563: }
3564: }
3565: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
3566: $level = 'resource';
3567: $resource = $1;
3568: if ($scope eq 'all') {
3569: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
3570: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
3571: push(@{$byresource{$resource}{$rev}{$scope}},$what);
3572: }
3573: } else {
3574: push(@{$byresource{$resource}{$rev}{$scope}},$what);
3575: }
3576: } else {
3577: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
3578: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
3579: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
3580: }
3581: } else {
3582: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
1.36 raeburn 3583: }
3584: }
3585: }
3586: }
3587: }
3588: if (keys(%fromparam)) {
3589: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
3590: &Apache::loncommon::start_data_table().
3591: &Apache::loncommon::start_data_table_header_row().
3592: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
3593: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
3594: &Apache::loncommon::end_data_table_header_row();
3595: foreach my $rev (keys(%fromparam)) {
1.66 raeburn 3596: my ($major,$minor) = split(/\./,$rev);
3597: ($reqdmajor,$reqdminor) =
3598: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 3599: $output .= &Apache::loncommon::start_data_table_row().
3600: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
3601: my $newrow;
3602: foreach my $scope (@scopeorder) {
3603: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
3604: if ($newrow) {
3605: $output .= &Apache::loncommon::continue_data_table_row();
3606: }
1.39 raeburn 3607: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 3608: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
3609: $output .= '<td>'.$which.'</td><td>'.
3610: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
3611: }
3612: $output .= &Apache::loncommon::end_data_table_row();
3613: $newrow = 1;
3614: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
3615: if ($newrow) {
3616: $output .= &Apache::loncommon::continue_data_table_row();
3617: }
1.39 raeburn 3618: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 3619: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
3620: &Apache::loncommon::end_data_table_row();
3621: $newrow = 1;
3622: }
3623: }
3624: }
3625: $output .= &Apache::loncommon::end_data_table().'<br />';
3626: }
3627: }
3628:
1.66 raeburn 3629: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
3630: my $now = time;
3631: if (keys(%comm_blocks) > 0) {
3632: foreach my $block (keys(%comm_blocks)) {
3633: if ($block =~ /^firstaccess____(.+)$/) {
1.78 raeburn 3634: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
1.66 raeburn 3635: if (ref($comm_blocks{$block}) eq 'HASH') {
3636: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3637: ' '.&mt('set by [_1]',
3638: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3639: }
3640: next;
3641: } elsif ($block =~ /^(\d+)____(\d+)$/) {
3642: my ($start,$end) = ($1,$2);
3643: next if ($end < $now);
3644: }
3645: if (ref($comm_blocks{$block}) eq 'HASH') {
3646: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
3647: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
3648: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
1.78 raeburn 3649: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
1.66 raeburn 3650: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3651: ' '.
3652: &mt('set by [_1]',
3653: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3654: }
3655: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
1.78 raeburn 3656: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
1.66 raeburn 3657: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3658: ' '.
3659: &mt('set by [_1]',
3660: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3661:
3662: }
3663: }
3664: }
3665: }
3666: if (keys(%fromblocks)) {
3667: my %lt = (
3668: docs => 'Content blocking',
3669: printout => 'Printout generation',
3670: timer => 'Timed quiz trigger',
3671: );
3672: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
3673: &Apache::loncommon::start_data_table().
3674: &Apache::loncommon::start_data_table_header_row().
3675: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
3676: '<th>'.&mt('Event(s)').'</th>'.
3677: &Apache::loncommon::end_data_table_header_row();
3678: foreach my $type ('docs','printout','timer') {
3679: if (ref($fromblocks{$type}) eq 'HASH') {
3680: foreach my $rev (keys(%{$fromblocks{$type}})) {
3681: my ($major,$minor) = split(/\./,$rev);
3682: ($reqdmajor,$reqdminor) =
3683: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
3684: $output .= &Apache::loncommon::start_data_table_row().
3685: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
3686: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
3687: $output .= $event.'<br />';
3688: }
3689: $output =~ s{\Q<br />\E$}{};
3690: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3691: }
3692: }
3693: }
3694: $output .= &Apache::loncommon::end_data_table().'<br />';
3695: }
3696: }
3697:
1.36 raeburn 3698: if (defined($navmap)) {
3699: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
1.76 raeburn 3700: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey::'};
1.36 raeburn 3701: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
1.76 raeburn 3702: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry::'};
1.85 raeburn 3703: my $rev_exttool=$Apache::lonnet::needsrelease{'course:courserestype:exttool'};
1.36 raeburn 3704: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
3705: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
3706: my $valanon=&get_param_description($stdtype,'anonsurvey');
3707: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.66 raeburn 3708: my %checkedrev;
1.85 raeburn 3709: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0)) {
1.36 raeburn 3710: my @parts = @{$res->parts()};
3711: my $symb = $res->symb();
3712: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
1.85 raeburn 3713: if ($res->is_tool()) {
3714: my $rev = $rev_exttool;
3715: $bycrsrestype{$symb}{$rev} = &mt('External Tool');
3716: $allmaps{$enclosing_map} = 1;
3717: next;
3718: }
1.36 raeburn 3719: foreach my $part (@parts) {
3720: if (exists($anonsubms{$symb."\0".$part})) {
3721: my $rev = $rev_anonsurv;
3722: my $what="$stdname=$valanon";
3723: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
3724: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
3725: push(@{$bysubmission{$symb}{$rev}},$what);
3726: }
3727: } else {
3728: push(@{$bysubmission{$symb}{$rev}},$what);
3729: }
3730: $allmaps{$enclosing_map} = 1;
1.66 raeburn 3731: unless ($checkedrev{'anonsurvey'}) {
3732: my ($major,$minor) = split(/\./,$rev);
3733: ($reqdmajor,$reqdminor) =
3734: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3735: $reqdmajor,$reqdminor);
3736: $checkedrev{'anonsurvey'} = 1;
3737: }
1.36 raeburn 3738: }
3739: if (exists($randtrysubms{$symb."\0".$part})) {
3740: my $rev = $rev_randtry;
3741: my $what="$stdname=$valrandtry";
3742: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
3743: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
3744: push(@{$bysubmission{$symb}{$rev}},$what);
3745: }
3746: } else {
3747: push(@{$bysubmission{$symb}{$rev}},$what);
3748: }
3749: $allmaps{$enclosing_map} = 1;
1.66 raeburn 3750: unless ($checkedrev{'randomizetry'}) {
3751: my ($major,$minor) = split(/\./,$rev);
3752: ($reqdmajor,$reqdminor) =
3753: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3754: $reqdmajor,$reqdminor);
3755: $checkedrev{'randomizetry'} = 1;
3756: }
1.36 raeburn 3757: }
3758: }
3759: my %responses = $res->responseTypes();
3760: foreach my $key (keys(%responses)) {
1.66 raeburn 3761: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
3762: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
3763: unless ($checkedrev{$key}) {
3764: my ($major,$minor) = split(/\./,$rev);
3765: ($reqdmajor,$reqdminor) =
3766: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3767: $reqdmajor,$reqdminor);
3768: $checkedrev{$key} = 1;
3769: }
3770: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 3771: $allmaps{$enclosing_map} = 1;
3772: }
3773: }
3774: }
3775: if (keys(%byresource) > 0) {
3776: foreach my $symb (keys(%byresource)) {
3777: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
3778: $allmaps{$map} = 1;
3779: }
3780: }
3781: if (keys(%bymap) > 0) {
3782: foreach my $map (keys(%bymap)) {
3783: $allmaps{$map} = 1;
3784: }
3785: }
3786: foreach my $map (keys(%allmaps)) {
3787: my $mapres = $navmap->getResourceByUrl($map);
3788: if (ref($mapres)) {
1.68 raeburn 3789: my $mapsymb = $mapres->symb();
3790: $toshow{$mapsymb} = 1;
1.36 raeburn 3791: my $pcslist = $mapres->map_hierarchy();
3792: if ($pcslist ne '') {
3793: foreach my $pc (split(/,/,$pcslist)) {
3794: my $res = $navmap->getByMapPc($pc);
3795: if (ref($res)) {
3796: my $symb = $res->symb();
3797: unless ($symb eq '______') {
3798: $toshow{$symb} = 1;
3799: }
3800: }
3801: }
3802: }
3803: }
3804: }
3805: }
1.86 raeburn 3806: my $suppmap = 'supplemental.sequence';
3807: my ($suppcount,$supptools,$errors) = (0,0,0);
3808: ($suppcount,$supptools,$errors) = &Apache::loncommon::recurse_supplemental($cnum,$cdom,
3809: $suppmap,$suppcount,$supptools,$errors);
1.36 raeburn 3810: my $mapres_header = '<h4>'.
3811: &mt('Requirements for specific folders or resources').
3812: '</h4>';
3813: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
3814: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
3815: $output .= $mapres_header;
3816: }
3817: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
3818: my $title = 'Version Constraints';
3819: my $start_page =
3820: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
3821: $r->print($start_page.$top_header);
3822: if ($output) {
3823: $r->print($output);
1.86 raeburn 3824: if (defined($navmap) || $supptools) {
1.36 raeburn 3825: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.86 raeburn 3826: \%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt,$supptools);
1.36 raeburn 3827: }
3828: $r->print('<br /><br />');
3829: } else {
3830: $r->print('<p class="LC_info">'.
3831: &mt('No version requirements from resource content or settings.').
3832: '</p>');
3833: }
3834: $r->print(&Apache::loncommon::end_page());
1.66 raeburn 3835: my ($currmajor,$currminor) = split(/\./,$loncaparev);
3836: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
3837: return 1;
3838: }
1.36 raeburn 3839: return;
3840: }
3841:
3842: sub show_contents_view {
1.39 raeburn 3843: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
1.86 raeburn 3844: $bycrsrestype,$scopeorder,$lt,$supptools) = @_;
3845: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
3846: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
3847: my $showmaincontent;
3848: if ((ref($navmap)) &&
3849: ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
3850: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0) ||
3851: (keys(%{$bycrsrestype}) > 0))) {
3852: $showmaincontent = 1;
3853: }
3854: if ($showmaincontent || $supptools) {
3855: $r->print(&Apache::loncommon::start_data_table());
3856: }
3857: if ($showmaincontent) {
3858: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
1.36 raeburn 3859: my $topmap = $env{'course.'.$cid.'.url'};
1.86 raeburn 3860: $r->print(&Apache::loncommon::start_data_table_header_row().
1.36 raeburn 3861: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
3862: '<th>'.&mt('Attribute/Setting').'</th>'.
3863: &Apache::loncommon::end_data_table_header_row().
3864: &Apache::loncommon::start_data_table_row().
1.58 raeburn 3865: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.86 raeburn 3866: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
3867: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 3868: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
3869: my $curRes;
3870: my $depth = 0;
3871: my %parent = ();
3872: my $startcount = 5;
3873: my $lastcontainer = $startcount;
3874: while ($curRes = $it->next()) {
3875: if ($curRes == $it->BEGIN_MAP()) {
3876: $depth++;
3877: $parent{$depth}= $lastcontainer;
3878: }
3879: if ($curRes == $it->END_MAP()) {
3880: $depth--;
3881: $lastcontainer = $parent{$depth};
3882: }
3883: my $indent;
3884: for (my $i=0; $i<$depth; $i++) {
3885: $indent.= $whitespace;
3886: }
3887: if (ref($curRes)) {
3888: my $symb = $curRes->symb();
3889: my $ressymb = $symb;
3890: my $srcf = $curRes->src();
3891: my $title = &Apache::lonnet::gettitle($srcf);
3892: if (($curRes->is_sequence()) || ($curRes->is_page())) {
3893: next unless($toshow->{$symb});
3894: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
3895: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3896: if ($curRes->is_page()) {
3897: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
3898: }
3899: my $rowspan = 1;
3900: if (ref($bymap->{$url}) eq 'HASH') {
3901: $rowspan = scalar(keys(%{$bymap->{$url}}));
3902: }
3903: $r->print(&Apache::loncommon::start_data_table_row().
3904: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 3905: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 3906: $r->print(&Apache::loncommon::end_data_table_row());
3907: } else {
3908: my $rowspan;
3909: if (ref($byresource->{$symb}) eq 'HASH') {
3910: $rowspan += scalar(keys(%{$byresource->{$symb}}));
3911: }
3912: if (ref($bysubmission->{$symb}) eq 'HASH') {
3913: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
3914: }
3915: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3916: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
3917: }
1.85 raeburn 3918: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
3919: $rowspan += scalar(keys(%{$bycrsrestype->{$symb}}));
3920: }
1.36 raeburn 3921: next if (!$rowspan);
3922: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
3923: &mt('Problem').'" />';
3924: $r->print(&Apache::loncommon::start_data_table_row().
3925: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
3926: my $newrow;
3927: if (ref($byresource->{$symb}) eq 'HASH') {
3928: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
3929: if ($newrow) {
3930: $r->print(&Apache::loncommon::continue_data_table_row());
3931: }
3932: $r->print('<td valign="middle">'.$rev.'</td><td>');
3933: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
3934: $r->print('<table border="0">');
3935: foreach my $scope (@{$scopeorder}) {
3936: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3937: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3938: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
3939: $r->print('<td>'.$which.'</td><td>'.
3940: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
3941: '</td>');
3942: }
3943: $r->print('</tr>');
3944: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3945: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 3946: '<td> </td><td>'.
3947: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
3948: }
3949: }
3950: $r->print('</table>');
3951: }
3952: $r->print('</td>');
3953: $r->print(&Apache::loncommon::end_data_table_row());
3954: $newrow = 1;
3955: }
3956: }
3957: if (ref($bysubmission->{$symb}) eq 'HASH') {
3958: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
3959: if ($newrow) {
3960: $r->print(&Apache::loncommon::continue_data_table_row());
3961: }
3962: $r->print('<td>'.$rev.'</td><td>');
3963: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
3964: $r->print(&mt('Submissions to: ').' '.
3965: join(', ',@{$bysubmission->{$symb}{$rev}}));
3966: }
3967: $r->print('</td>');
3968: $r->print(&Apache::loncommon::end_data_table_row());
3969: $newrow = 1;
3970: }
3971: }
3972: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3973: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
3974: if ($newrow) {
3975: $r->print(&Apache::loncommon::continue_data_table_row());
3976: }
3977: $r->print('<td>'.$rev.'</td><td>');
3978: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
3979: $r->print(&mt('Response Type(s): ').' '.
3980: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
3981: }
3982: $r->print('</td>');
3983: }
3984: $r->print(&Apache::loncommon::end_data_table_row());
1.85 raeburn 3985: $newrow = 1;
3986: }
3987: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
3988: foreach my $rev (sort(keys(%{$bycrsrestype->{$symb}}))) {
3989: if ($newrow) {
3990: $r->print(&Apache::loncommon::continue_data_table_row());
3991: }
3992: $r->print('<td>'.$rev.'</td><td>'.$bycrsrestype->{$symb}{$rev}.'</td>');
3993: }
1.86 raeburn 3994: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 3995: }
3996: }
3997: }
3998: }
1.86 raeburn 3999: }
4000: if ($supptools) {
4001: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
4002: $r->print(&Apache::loncommon::start_data_table_header_row().
4003: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
4004: '<th>'.&mt('Resource Type').'</th>'.
4005: &Apache::loncommon::end_data_table_header_row().
4006: &Apache::loncommon::start_data_table_row().
4007: '<td> '.$icon.' '.&mt('Supplemental Content').'</td>'.
4008: '<td valign="middle">'.
4009: $Apache::lonrelrequtils::exttool{'major'}.'.'.
4010: $Apache::lonrelrequtils::exttool{'minor'}.
4011: '</td><td>'.&mt('[quant,_1,External Tool,External Tools]',
4012: $supptools).'</td>'.
4013: &Apache::loncommon::end_data_table_row());
4014: }
4015: if ($showmaincontent || $supptools) {
1.36 raeburn 4016: $r->print(&Apache::loncommon::end_data_table());
4017: }
1.66 raeburn 4018: return;
1.36 raeburn 4019: }
4020:
4021: sub releases_by_map {
1.39 raeburn 4022: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 4023: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.73 raeburn 4024: my $newrow = 0;
1.36 raeburn 4025: if (ref($bymap->{$url}) eq 'HASH') {
4026: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.73 raeburn 4027: if ($newrow) {
4028: $r->print(&Apache::loncommon::end_data_table_row().
4029: &Apache::loncommon::continue_data_table_row());
4030: }
1.36 raeburn 4031: $r->print('<td valign="middle">'.$rev.'</td><td>');
4032: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
4033: $r->print('<table border="0">');
4034: foreach my $scope (@{$scopeorder}) {
4035: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 4036: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 4037: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
4038: $r->print('<td>'.$which.'</td><td>'.
4039: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
4040: '</td>');
4041: }
4042: $r->print('</tr>');
4043: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 4044: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 4045: '</td><td> </td><td>'.
4046: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
4047: }
4048: }
4049: $r->print('</table>');
4050: }
4051: $r->print('</td>');
1.73 raeburn 4052: $newrow = 1;
1.36 raeburn 4053: }
4054: } else {
4055: $r->print('<td colspan="2"> </td>');
4056: }
4057: return;
4058: }
4059:
4060: sub get_param_description {
1.70 raeburn 4061: my ($stdtype,$value,$regexp) = @_;
4062: my ($name,$parammatches,$paramstrings,@possibles);
1.74 raeburn 4063: if ($stdtype =~ /^string/) {
4064: $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
4065: } elsif ($stdtype eq 'date_interval') {
4066: $paramstrings = &Apache::lonparmset::standard_interval_options($stdtype);
4067: }
1.70 raeburn 4068: if ($regexp) {
1.74 raeburn 4069: if ($stdtype =~ /^string/) {
4070: $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
4071: } elsif ($stdtype eq 'date_interval') {
4072: $parammatches = &Apache::lonparmset::standard_interval_matches($stdtype);
4073: }
1.70 raeburn 4074: if (ref($parammatches) eq 'ARRAY') {
4075: @possibles = @{$parammatches};
4076: } else {
4077: undef($regexp);
4078: $name = $value;
4079: }
4080: }
4081: unless ($regexp) {
4082: $name = $value;
4083: if (ref($paramstrings) eq 'ARRAY') {
4084: @possibles = @{$paramstrings};
4085: } else {
1.76 raeburn 4086: if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) {
4087: if ($name == 0) {
4088: $name = &mt('Never');
4089: } elsif (($name ne '') && ($name !~ /\D/)) {
4090: $name = &Apache::lonlocal::locallocaltime($name);
4091: }
4092: }
1.70 raeburn 4093: return $name;
4094: }
1.36 raeburn 4095: }
1.70 raeburn 4096: foreach my $possibilities (@possibles) {
1.36 raeburn 4097: next unless (ref($possibilities) eq 'ARRAY');
1.70 raeburn 4098: my $gotregexmatch = '';
4099: if ($regexp) {
4100: last if ($gotregexmatch);
4101: my ($item,$pattern) = @{ $possibilities };
4102: if ($value =~ /$pattern/) {
4103: if (ref($paramstrings) eq 'ARRAY') {
4104: foreach my $possibles (@{$paramstrings}) {
4105: next unless (ref($possibles) eq 'ARRAY');
4106: my ($thing,$description) = @{$possibles};
4107: if ($thing eq $item) {
4108: $name = $description;
4109: $gotregexmatch = 1;
4110: last;
4111: }
4112: }
4113: last if ($gotregexmatch);
4114: }
4115: }
4116: } else {
4117: my ($thing,$description) = @{ $possibilities };
4118: if ($thing eq $value) {
4119: $name = $description;
4120: last;
4121: }
1.36 raeburn 4122: }
4123: }
4124: return $name;
4125: }
4126:
1.66 raeburn 4127: sub update_releasereq {
4128: my $readmap = 1;
4129: my $getrelreq = 1;
4130: if (ref($modified_courses) eq 'ARRAY') {
4131: foreach my $item (@{$modified_courses}) {
4132: if (ref($item) eq 'ARRAY') {
4133: my ($cdom,$cnum,$chome,$crstype) = @{$item};
4134: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
4135: $chome,$crstype,$cdom.'_'.$cnum,
4136: $readmap,$getrelreq);
4137: }
4138: }
4139: $modified_courses = [];
4140: }
4141: undef($registered_cleanup);
4142: return;
4143: }
4144:
1.25 raeburn 4145: sub show_autocoowners {
4146: my (@currcoown) = @_;
1.56 raeburn 4147: my $output = '<i><span class="LC_nobreak">'.&mt('Co-ownership is set automatically when a Course Coordinator role[_1] is assigned to official course personnel (from institutional data).','</span><br /><span class="LC_nobreak">').'</span></i>';
1.25 raeburn 4148: if (@currcoown > 0) {
4149: $output .= '<br />'.&mt('Current co-owners are:').' '.
4150: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
4151: } else {
4152: $output .= '<br />'.&mt('Currently no co-owners.');
4153: }
4154: return $output;
4155: }
4156:
4157: sub coowner_invitations {
1.80 raeburn 4158: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
4159: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 4160: my $pendingcoowners =
4161: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
4162: if ($pendingcoowners) {
4163: @pendingcoown = split(',',$pendingcoowners);
4164: }
1.80 raeburn 4165: if (ref($currcoownref) eq 'ARRAY') {
1.97 raeburn 4166: @currcoown = @{$currcoownref};
1.80 raeburn 4167: }
4168: my $disabled;
4169: if ($noedit) {
4170: $disabled = ' disabled="disabled"';
4171: }
1.25 raeburn 4172: my $ccrole = 'cc';
4173: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
4174: foreach my $key (sort(keys(%ccroles))) {
4175: my ($ccname,$ccdom,$role) = split(':',$key);
4176: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
4177: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
4178: push(@othercoords,$ccname.':'.$ccdom);
4179: }
4180: }
4181: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
4182: if ($coowner_rows) {
4183: $output .= &Apache::loncommon::start_data_table();
4184: if (@currcoown) {
4185: $output .= &Apache::loncommon::start_data_table_row().
4186: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
4187: foreach my $person (@currcoown) {
4188: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 4189: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="coowners" checked="checked" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
1.25 raeburn 4190: }
4191: $output .= '</td>'.
4192: &Apache::loncommon::end_data_table_row();
4193: }
4194: if ($pendingcoowners) {
4195: $output .= &Apache::loncommon::start_data_table_row().
4196: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
4197: foreach my $person (@pendingcoown) {
4198: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 4199: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="pendingcoowners" checked="checked" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
1.25 raeburn 4200: }
4201: $output .= '</td>'.
4202: &Apache::loncommon::end_data_table_row();
4203: }
4204: if (@othercoords) {
4205: $output .= &Apache::loncommon::start_data_table_row().
4206: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
4207: foreach my $person (@othercoords) {
4208: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 4209: $output .= '<span class="LC_nobreak"><label><input type="checkbox" name="invitecoowners" value="'.$person.'"'.$disabled.' />'.&Apache::loncommon::plainname($co_uname,$co_dom).'</label></span>'.(' 'x2).' ';
1.25 raeburn 4210: }
4211: $output .= '</td>'.
4212: &Apache::loncommon::end_data_table_row();
4213: }
4214: $output .= &Apache::loncommon::end_data_table();
4215: } else {
4216: $output = &mt('There are no coordinators to select as co-owners');
4217: }
4218: return $output;
4219: }
4220:
4221: sub manage_coownership {
1.80 raeburn 4222: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
4223: my (@pendingcoown,@currcoown);
1.25 raeburn 4224: my $pendingcoowners =
4225: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
4226: if ($pendingcoowners) {
4227: @pendingcoown = split(',',$pendingcoowners);
4228: }
1.80 raeburn 4229: if (ref($currcoownref) eq 'ARRAY') {
1.97 raeburn 4230: @currcoown = @{$currcoownref};
1.80 raeburn 4231: }
4232: my $disabled;
4233: if ($noedit) {
4234: $disabled = ' disabled="disabled"';
4235: }
1.25 raeburn 4236: my ($is_coowner,$is_pending,$output);
4237: my $uname = $env{'user.name'};
4238: my $udom = $env{'user.domain'};
4239: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
4240: $is_coowner = 1;
4241: }
4242: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
4243: $is_pending = 1;
4244: }
4245: if (@currcoown && ($is_coowner || $is_pending)) {
4246: $output = &Apache::loncommon::start_data_table();
4247: }
4248: if (@currcoown) {
4249: if ($is_coowner || $is_pending) {
4250: $output .= &Apache::loncommon::start_data_table().
4251: &Apache::loncommon::start_data_table_row().'<td>';
4252: }
4253: $output .= &mt('Current co-owners are:').' '.
4254: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
4255: if ($is_coowner || $is_pending) {
4256: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4257: }
4258: }
4259: if ($is_coowner || $is_pending) {
4260: if (@currcoown) {
4261: $output .= &Apache::loncommon::start_data_table_row().'<td>';
4262: }
4263: $output .= '<span class="LC_nobreak">';
4264: if ($is_coowner) {
1.90 raeburn 4265: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
1.25 raeburn 4266: } else {
1.90 raeburn 4267: $output .= &mt('The course owner has invited you to become a co-owner:').' <label><input type="radio" name="pending_coowner" value="accept"'.$disabled.' />'.&mt('Accept?').'</label>'.(' 'x2).
4268: '<label><input type="radio" name=pending_coowner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 4269: }
4270: $output .= '</span>';
4271: if (@currcoown) {
4272: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4273: }
4274: }
4275: if (@currcoown && ($is_coowner || $is_pending)) {
4276: $output .= &Apache::loncommon::end_data_table();
4277: }
4278: return $output;
4279: }
4280:
1.1 raeburn 4281: sub print_localization {
1.80 raeburn 4282: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 4283: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4284: return;
4285: }
4286: my %items = (
4287: languages => {
1.17 faziophi 4288: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
4289: &mt("(overrides individual user preference)"),
1.1 raeburn 4290: input => 'selectbox',
4291: },
4292: timezone => {
1.17 faziophi 4293: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 4294: input => 'selectbox',
4295: },
4296: datelocale => {
1.17 faziophi 4297: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 4298: input => 'selectbox',
4299: },
4300: );
1.80 raeburn 4301: my ($datatable,$disabled);
1.1 raeburn 4302: my $count = 0;
1.80 raeburn 4303: if ($noedit) {
4304: $disabled = ' disabled="disabled"';
4305: }
1.1 raeburn 4306: foreach my $item (@{$ordered}) {
4307: $count ++;
1.56 raeburn 4308: my $colspan;
4309: unless ($item eq 'languages') {
1.80 raeburn 4310: $colspan = 2;
1.56 raeburn 4311: }
4312: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 4313: if ($item eq 'timezone') {
4314: my $includeempty = 1;
4315: my $timezone = &Apache::lonlocal::gettimezone();
4316: $datatable .=
4317: &Apache::loncommon::select_timezone($item,$timezone,undef,
1.80 raeburn 4318: $includeempty,$disabled);
1.1 raeburn 4319: } elsif ($item eq 'datelocale') {
4320: my $includeempty = 1;
4321: my $locale_obj = &Apache::lonlocal::getdatelocale();
4322: my $currdatelocale;
4323: if (ref($locale_obj)) {
4324: $currdatelocale = $locale_obj->id();
4325: }
4326: $datatable .=
4327: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.80 raeburn 4328: undef,$includeempty,$disabled);
1.1 raeburn 4329: } else {
4330: if ($settings->{$item} eq '') {
1.80 raeburn 4331: unless ($noedit) {
4332: $datatable .= '</td><td align="right">'.
4333: &Apache::loncommon::select_language('languages_0','',1);
4334: }
1.1 raeburn 4335: } else {
4336: my $num = 0;
1.3 raeburn 4337: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.56 raeburn 4338: $datatable .= '</td><td align="right"><br />'.
4339: &Apache::loncommon::start_data_table();
1.1 raeburn 4340: if (@languages > 0) {
1.3 raeburn 4341: my %langchoices = &get_lang_choices();
1.1 raeburn 4342: foreach my $lang (@languages) {
4343: my $showlang = $lang;
1.3 raeburn 4344: if (exists($langchoices{$lang})) {
4345: $showlang = $langchoices{$lang};
1.1 raeburn 4346: }
4347: $datatable .=
4348: &Apache::loncommon::start_data_table_row().
1.3 raeburn 4349: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 4350: &mt('Language:').'<b> '.$showlang.
4351: '</b><input type="hidden" name="languages_'.$num.
4352: '" value="'.$lang.'" /></span><br />'.
4353: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 4354: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 4355: &mt('Delete').'</label></span></td>'.
1.3 raeburn 4356: &Apache::loncommon::end_data_table_row();
1.1 raeburn 4357: $num ++;
4358: }
4359: }
1.80 raeburn 4360: unless ($noedit) {
4361: $datatable .=
4362: &Apache::loncommon::start_data_table_row().
1.3 raeburn 4363: '<td align="left"><span class="LC_nobreak">'.
4364: &mt('Additional language:'). '</span><br />'.
4365: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 4366: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.80 raeburn 4367: '</td>'.&Apache::loncommon::end_data_table_row();
4368: }
4369: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 4370: }
4371: }
4372: $datatable .= &item_table_row_end();
4373: }
4374: $$rowtotal += scalar(@{$ordered});
4375: return $datatable;
4376: }
4377:
1.3 raeburn 4378: sub get_lang_choices {
4379: my %langchoices;
4380: foreach my $id (&Apache::loncommon::languageids()) {
4381: my $code = &Apache::loncommon::supportedlanguagecode($id);
4382: if ($code) {
4383: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
4384: }
4385: }
4386: return %langchoices;
4387: }
4388:
1.1 raeburn 4389: sub print_feedback {
1.80 raeburn 4390: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 4391: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4392: return;
4393: }
4394: my %items = (
1.3 raeburn 4395: 'question.email' => {
4396: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 4397: input => 'textbox',
4398: size => '50',
4399: },
4400:
1.3 raeburn 4401: 'comment.email' => {
4402: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 4403: input => 'textbox',
4404: size => '50',
4405: },
4406:
1.3 raeburn 4407: 'policy.email' => {
4408: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 4409: input => 'textbox',
4410: size => '50',
4411: },
4412: );
4413: my $datatable;
4414: my $count = 0;
4415: my ($cnum) = &get_course();
4416: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4417: my @sections = sort( { $a <=> $b } keys(%sections));
4418: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 4419: currone => 'Current recipient:',
4420: currmult => 'Current recipients:',
4421: add => 'Additional recipient:',
4422: del => 'Delete?',
4423: sec => 'Sections:',
1.1 raeburn 4424: );
1.80 raeburn 4425: my $disabled;
4426: if ($noedit) {
4427: $disabled = ' disabled="disabled"';
4428: }
1.1 raeburn 4429: foreach my $item (@{$ordered}) {
4430: $count ++;
1.20 faziophi 4431: if ($position eq 'top') {
4432: $datatable .= &item_table_row_start($items{$item}{text},$count);
4433: } else {
1.56 raeburn 4434: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 4435: }
1.1 raeburn 4436: if ($position eq 'top') {
4437: my $includeempty = 0;
1.94 raeburn 4438: $datatable .= '</td><td align="right">'.
4439: &user_table($cdom,$item,\@sections,
1.80 raeburn 4440: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4441: } else {
1.3 raeburn 4442: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.80 raeburn 4443: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 4444: }
4445: $datatable .= &item_table_row_end();
4446: }
4447: $$rowtotal += scalar(@{$ordered});
4448: return $datatable;
4449: }
4450:
4451: sub user_table {
1.80 raeburn 4452: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 4453: my $output;
4454: if ($currvalue eq '') {
1.80 raeburn 4455: unless ($noedit) {
4456: $output .= &select_recipient($item,'0',$cdom,$sections);
4457: }
1.1 raeburn 4458: } else {
4459: my $num = 0;
4460: my @curr = split(/,/,$currvalue);
1.56 raeburn 4461: $output .= '<table class="LC_data_table">';
1.1 raeburn 4462: my ($currusers);
1.80 raeburn 4463: my $disabled;
4464: if ($noedit) {
4465: $disabled = ' disabled="disabled"';
4466: }
1.1 raeburn 4467: foreach my $val (@curr) {
4468: next if ($val eq '');
4469: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
4470: my @selsec;
4471: if ($seclist) {
4472: $seclist =~ s/(^\(|\)$)//g;
4473: @selsec = split(/\s*;\s*/,$seclist);
4474: }
4475: $currusers .= '<tr>'.
4476: '<td valign="top"><span class="LC_nobreak">'.
4477: '<label><input type="checkbox" '.
1.80 raeburn 4478: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 4479: $lt->{'del'}.'</label>'.
4480: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 4481: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 4482: &Apache::loncommon::aboutmewrapper(
4483: &Apache::loncommon::plainname($uname,$udom,'firstname'),
4484: $uname,$udom,'aboutuser');
4485: if (ref($sections) eq 'ARRAY') {
4486: if (@{$sections}) {
4487: $currusers.= (' 'x3).$lt->{'sec'}.' '.
4488: &select_sections($item,$num,$sections,
1.80 raeburn 4489: \@selsec,$noedit);
1.1 raeburn 4490: }
4491: }
4492: $currusers .= '</span></td></tr>';
4493: $num ++;
4494: }
4495: if ($num) {
1.10 raeburn 4496: $output .= '<tr>'.
1.1 raeburn 4497: '<td align="left"><i>';
1.20 faziophi 4498: if ($num == 1) {
1.1 raeburn 4499: $output .= $lt->{'currone'};
4500: } else {
1.21 raeburn 4501: $output .= $lt->{'currmult'};
1.1 raeburn 4502: }
4503: $output .= '</i><br />'.
4504: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 4505: '</tr>';
1.1 raeburn 4506: }
1.80 raeburn 4507: unless ($noedit) {
4508: $output .=
4509: '<tr>'.
1.1 raeburn 4510: '<td align="left"><span class="LC_nobreak"><i>'.
4511: $lt->{'add'}.'</i></span><br />'.
4512: &select_recipient($item,$num,$cdom,$sections).
4513: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.80 raeburn 4514: '</td></tr>';
4515: }
4516: $output .= '</table>';
1.1 raeburn 4517: }
4518: return $output;
4519: }
4520:
4521: sub select_recipient {
4522: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
4523: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
4524: my $selectlink =
4525: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1.89 raeburn 4526: $item.'_udom_'.$num,'only');
1.1 raeburn 4527: my $output =
1.10 raeburn 4528: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 4529: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
4530: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
4531: if (ref($sections) eq 'ARRAY') {
4532: if (@{$sections}) {
4533: $output .= '<td align="center">'.&mt('Sections').'<br />'.
4534: &select_sections($item,$num,$sections,$selected).'</td>';
4535: }
4536: }
4537: $output .= '<td valign="top">'.
4538: $selectlink.'</td></tr></table>';
4539: return $output;
4540: }
4541:
4542: sub select_sections {
1.80 raeburn 4543: my ($item,$num,$sections,$selected,$noedit) = @_;
4544: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 4545: if (ref($selected) eq 'ARRAY') {
4546: @currsecs = @{$selected};
4547: }
4548: if (!@currsecs) {
4549: $allsec = ' selected="selected"';
4550: }
1.80 raeburn 4551: if ($noedit) {
4552: $disabled = ' disabled="disabled"';
4553: }
1.1 raeburn 4554: if (ref($sections) eq 'ARRAY') {
4555: if (@{$sections}) {
4556: my $mult;
4557: if (@{$sections} > 1) {
4558: $mult = ' multiple="multiple"';
4559: if (@{$sections} > 3) {
4560: $mult .= ' size="4"';
4561: }
4562: }
1.80 raeburn 4563: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.$disabled.'>'.
1.1 raeburn 4564: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
4565: foreach my $sec (@{$sections}) {
4566: my $is_sel;
4567: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
4568: $is_sel = 'selected="selected"';
4569: }
4570: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
4571: }
4572: $output .= '</select>';
4573: }
4574: }
4575: return $output;
4576: }
4577:
4578: sub print_discussion {
1.80 raeburn 4579: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 4580: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4581: return;
4582: }
4583: my %items = (
4584: 'plc.roles.denied' => {
1.10 raeburn 4585: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
4586: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 4587: &mt('(role-based)'),
1.1 raeburn 4588: input => 'checkbox',
4589: },
4590:
4591: 'plc.users.denied' => {
1.3 raeburn 4592: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
4593: &mt('(specific user(s))'),
1.1 raeburn 4594: input => 'checkbox',
4595: },
4596:
4597: 'pch.roles.denied' => {
1.10 raeburn 4598: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
4599: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 4600: &mt('(role-based)'),
1.1 raeburn 4601: input => 'checkbox',
4602: },
4603:
4604: 'pch.users.denied' => {
1.3 raeburn 4605: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
4606: &mt('(specific user(s))'),
1.1 raeburn 4607: input => 'checkbox',
4608: },
1.77 raeburn 4609:
4610: 'pac.roles.denied' => {
4611: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.roles.denied'}).'</b>'.
4612: &Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'</span><br />'.
4613: &mt('(role-based)'),
4614: input => 'checkbox',
4615: },
4616:
4617: 'pac.users.denied' => {
4618: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.users.denied'}).'</b><br />'.
4619: &mt('(specific user(s))'),
4620: input => 'checkbox',
4621: },
4622:
1.1 raeburn 4623: 'allow_limited_html_in_feedback' => {
1.3 raeburn 4624: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 4625: input => 'radio',
4626: },
4627:
4628: 'allow_discussion_post_editing' => {
1.3 raeburn 4629: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 4630: input => 'checkbox',
4631: },
1.50 raeburn 4632: 'discussion_post_fonts' => {
4633: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
4634: input => 'textbox',
4635: size => '20',
4636: },
1.1 raeburn 4637: );
4638: my $datatable;
4639: my $count;
4640: my ($cnum) = &get_course();
4641: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4642: my @sections = sort( { $a <=> $b } keys(%sections));
4643: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 4644: currone => 'Disallowed:',
4645: currmult => 'Disallowed:',
4646: add => 'Disallow more:',
4647: del => 'Delete?',
4648: sec => 'Sections:',
1.1 raeburn 4649: );
4650: foreach my $item (@{$ordered}) {
4651: $count ++;
1.56 raeburn 4652: my $colspan;
4653: if ($item eq 'allow_limited_html_in_feedback') {
4654: $colspan = 2;
4655: }
4656: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 4657: if ($item eq 'plc.roles.denied') {
1.56 raeburn 4658: $datatable .= '</td><td align="right">'.
1.80 raeburn 4659: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 4660: '</table>';
4661: } elsif ($item eq 'plc.users.denied') {
1.94 raeburn 4662: $datatable .= '</td><td align="right">'.
4663: &user_table($cdom,$item,undef,
1.80 raeburn 4664: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4665: } elsif ($item eq 'pch.roles.denied') {
1.56 raeburn 4666: $datatable .= '</td><td align="right">'.
1.80 raeburn 4667: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 4668: '</table>';
4669: } elsif ($item eq 'pch.users.denied') {
1.56 raeburn 4670: $datatable .= '</td><td align="right">'.
4671: &user_table($cdom,$item,undef,
1.80 raeburn 4672: $settings->{$item},\%lt,$noedit);
1.77 raeburn 4673: } elsif ($item eq 'pac.roles.denied') {
4674: $datatable .= '</td><td align="right">'.
1.80 raeburn 4675: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.77 raeburn 4676: '</table>';
4677: } elsif ($item eq 'pac.users.denied') {
4678: $datatable .= '</td><td align="right">'.
4679: &user_table($cdom,$item,undef,
1.80 raeburn 4680: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4681: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.80 raeburn 4682: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 4683: } elsif ($item eq 'allow_discussion_post_editing') {
1.56 raeburn 4684: $datatable .= '</td><td align="right"><br />'.
4685: &Apache::loncommon::start_data_table().
1.1 raeburn 4686: &Apache::loncommon::start_data_table_row().
4687: '<th align="left">'.&mt('Role').'</th><th>'.
4688: &mt('Sections').'</th>'.
4689: &Apache::loncommon::end_data_table_row().
1.80 raeburn 4690: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.56 raeburn 4691: &Apache::loncommon::end_data_table().'<br />';
1.50 raeburn 4692: } elsif ($item eq 'discussion_post_fonts') {
1.56 raeburn 4693: $datatable .= '</td><td align="right"><br />'.
4694: &Apache::loncommon::start_data_table().
1.50 raeburn 4695: &Apache::loncommon::start_data_table_row().
4696: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
4697: '<th align="center">'.&mt('font-size').'</th>'.
4698: '<th align="center">'.&mt('font-weight').'</th>'.
4699: '<th align="center">'.&mt('font-style').'</th>'.
4700: '<th align="center">'.&mt('Other css').'</th>'.
4701: &Apache::loncommon::end_data_table_row().
1.80 raeburn 4702: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.56 raeburn 4703: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 4704: }
4705: $datatable .= &item_table_row_end();
4706: }
4707: $$rowtotal += scalar(@{$ordered});
4708: return $datatable;
4709: }
4710:
4711: sub role_checkboxes {
1.80 raeburn 4712: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 4713: my @roles = ('st','ad','ta','ep','in');
4714: if ($crstype eq 'Community') {
4715: push(@roles,'co');
4716: } else {
4717: push(@roles,'cc');
4718: }
1.1 raeburn 4719: my $output;
4720: my (@current,@curr_roles,%currsec,@sections);
4721: if ($showsections) {
4722: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4723: @sections = sort( { $a <=> $b } keys(%sections));
4724: }
4725: if (ref($settings) eq 'HASH') {
4726: if ($settings->{$item}) {
4727: @current = split(',',$settings->{$item});
4728: if ($showsections) {
4729: foreach my $role (@current) {
4730: if ($role =~ /:/) {
4731: my ($trole,$sec) = split(':',$role);
4732: push(@curr_roles,$trole);
4733: if (ref($currsec{$trole}) eq 'ARRAY') {
4734: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
4735: push(@{$currsec{$trole}},$sec);
4736: }
1.3 raeburn 4737: } else {
4738: $currsec{$trole} = [$sec];
1.1 raeburn 4739: }
4740: } else {
4741: push(@curr_roles,$role);
4742: }
4743: }
4744: @current = @curr_roles;
4745: }
4746: }
4747: }
4748: my $numinrow = 3;
4749: my $count = 0;
1.80 raeburn 4750: my $disabled;
4751: if ($noedit) {
4752: $disabled = ' disabled="disabled"';
4753: }
1.1 raeburn 4754: foreach my $role (@roles) {
4755: my $checked = '';
4756: if (grep(/^\Q$role\E$/,@current)) {
4757: $checked = ' checked="checked" ';
4758: }
1.9 raeburn 4759: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 4760: if ($showsections) {
4761: $output .= &Apache::loncommon::start_data_table_row();
4762: } else {
4763: my $rem = $count%($numinrow);
4764: if ($rem == 0) {
4765: if ($count > 0) {
4766: $output .= '</tr>';
4767: }
4768: $output .= '<tr>';
4769: }
4770: }
1.30 raeburn 4771: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 4772: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 4773: $plrole.'</label></span></td>';
4774: if ($showsections) {
4775: $output .= '<td align="left">'.
1.80 raeburn 4776: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 4777: '</td></tr>';
4778: }
4779: $count ++;
4780: }
4781: my %adv_roles =
4782: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
4783: my $total = @roles;
4784: foreach my $role (sort(keys(%adv_roles))) {
4785: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
4786: my $rolename = $3;
4787: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
4788: my $checked = '';
4789: if (grep(/^\Q$value\E$/,@current)) {
4790: $checked = ' checked="checked" ';
4791: }
4792: if ($showsections) {
4793: $output .= &Apache::loncommon::start_data_table_row();
4794: } else {
4795: my $rem = $count%($numinrow);
4796: if ($rem == 0) {
4797: if ($count > 0) {
4798: $output .= '</tr>';
4799: }
4800: $output .= '<tr>';
4801: }
4802: }
1.30 raeburn 4803: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 4804: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 4805: '</label></span></td>';
4806: if ($showsections) {
4807: $output .= '<td>'.
1.80 raeburn 4808: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 4809: '</td>'.&Apache::loncommon::end_data_table_row();
4810: }
4811: $total ++;
4812: $count ++;
4813: }
4814: }
4815: if (!$showsections) {
4816: my $rem = $total%($numinrow);
4817: my $colsleft = $numinrow - $rem;
4818: if ($colsleft > 1 ) {
4819: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
4820: ' </td>';
4821: } elsif ($colsleft == 1) {
4822: $output .= '<td class="LC_left_item"> </td>';
4823: }
4824: $output .= '</tr>';
4825: }
4826: return $output;
4827: }
4828:
1.50 raeburn 4829: sub set_discussion_fonts {
1.80 raeburn 4830: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.50 raeburn 4831: my ($classorder,$classtitles) = &discussion_vote_classes();
4832: my ($styleorder,$styleitems) = &discussion_vote_styles();
4833: my $output;
4834: if (ref($classorder) eq 'ARRAY') {
1.80 raeburn 4835: my $disabled;
4836: if ($noedit) {
4837: $disabled = ' disabled="disabled"';
4838: }
1.50 raeburn 4839: foreach my $cat (@{$classorder}) {
4840: my %curr = ();
4841: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
4842: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
4843: $output .= &Apache::loncommon::start_data_table_row().
4844: '<td>'.$classtitles->{$cat}.'</td>';
4845: if (ref($styleorder) eq 'ARRAY') {
4846: foreach my $item (@{$styleorder}) {
4847: $output .= '<td><span class="LC_nobreak">';
4848: my $selitem = $item;
4849: if ($item eq 'size') {
4850: my ($currsize,$currunit);
4851: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
4852: ($currsize,$currunit) = ($1,$2);
4853: $curr{'size'} = $currunit;
4854: }
1.81 raeburn 4855: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.50 raeburn 4856: ' ';
4857: $selitem = 'unit';
4858: }
4859: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.80 raeburn 4860: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.50 raeburn 4861: foreach my $val (@{$styleitems->{$item}}) {
4862: my $sel;
4863: if ($val eq $curr{$item}) {
4864: $sel = ' selected="selected"';
4865: }
4866: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
4867: }
4868: }
4869: }
4870: }
1.80 raeburn 4871: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
1.50 raeburn 4872: }
4873: $output .= &Apache::loncommon::end_data_table_row();
4874: }
4875: return $output;
4876: }
4877:
4878: sub discussion_vote_classes {
4879: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
4880: my %classtitles = &Apache::lonlocal::texthash(
4881: 'twoplus' => 'Two sigma above mean',
4882: 'oneplus' => 'One sigma above mean',
4883: 'zero' => 'Within one sigma of mean',
4884: 'oneminus' => 'One sigma below mean',
4885: 'twominus' => 'Two sigma below mean',
4886: );
4887: return ($classorder,\%classtitles);
4888: }
4889:
4890: sub discussion_vote_styles {
4891: my $styleorder = ['size','weight','style'];
4892: my $styleitems = {
4893: size => ['','px','%','xx-small','x-small','small','medium','large',
4894: 'x-large','xx-large','smaller','larger'],
4895: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
4896: '500','600','700','800','900'],
4897: style => ['','normal','italic','oblique'],
4898: };
4899: return ($styleorder,$styleitems);
4900: }
4901:
1.1 raeburn 4902: sub print_classlists {
1.80 raeburn 4903: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 4904: my @ordered;
4905: if ($position eq 'top') {
4906: @ordered = ('default_enrollment_start_date',
4907: 'default_enrollment_end_date');
1.55 raeburn 4908: if ($crstype eq 'Course') {
4909: push(@ordered,'defaultcredits');
4910: }
1.1 raeburn 4911: } elsif ($position eq 'middle') {
1.56 raeburn 4912: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 4913: } else {
4914: @ordered = ('student_classlist_view',
1.26 raeburn 4915: 'student_classlist_opt_in',
4916: 'student_classlist_portfiles');
1.1 raeburn 4917: }
1.9 raeburn 4918: my %lt;
4919:
4920: if ($crstype eq 'Community') {
4921: %lt = &Apache::lonlocal::texthash (
4922: disabled => 'No viewable membership list',
4923: section => "Membership of viewer's section",
4924: all => 'List of all members',
4925: );
4926: } else {
4927: %lt = &Apache::lonlocal::texthash (
4928: disabled => 'No viewable classlist',
4929: section => "Classlist of viewer's section",
4930: all => 'Classlist of all students',
4931: );
4932: }
4933:
1.1 raeburn 4934: my %items = (
4935: 'default_enrollment_start_date' => {
1.3 raeburn 4936: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 4937: input => 'dates',
4938: },
4939: 'default_enrollment_end_date' => {
1.3 raeburn 4940: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 4941: input => 'dates',
4942: },
1.55 raeburn 4943: 'defaultcredits' => {
4944: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4945: },
4946:
1.1 raeburn 4947: 'nothideprivileged' => {
1.3 raeburn 4948: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 4949: input => 'checkbox',
4950: },
4951:
1.56 raeburn 4952: 'checkforpriv' => {
4953: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
4954: input => 'selectbox',
4955: },
4956:
1.1 raeburn 4957: 'student_classlist_view' => {
1.3 raeburn 4958: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 4959: input => 'selectbox',
1.9 raeburn 4960: options => \%lt,
1.1 raeburn 4961: order => ['disabled','all','section'],
4962: },
1.26 raeburn 4963: 'student_classlist_opt_in' => {
4964: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 4965: input => 'radio',
4966: },
4967:
4968: 'student_classlist_portfiles' => {
1.3 raeburn 4969: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 4970: input => 'radio',
4971: },
4972: );
4973: unless (($settings->{'student_classlist_view'} eq 'all') ||
4974: ($settings->{'student_classlist_view'} eq 'section')) {
4975: $settings->{'student_classlist_view'} = 'disabled';
4976: }
1.80 raeburn 4977: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 4978: }
4979:
4980: sub print_appearance {
1.80 raeburn 4981: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4982: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4983: return;
4984: }
1.9 raeburn 4985: my $mathdef;
4986: if ($crstype eq 'Community') {
4987: $mathdef = &mt("None specified - use member's choice");
4988: } else {
4989: $mathdef = &mt("None specified - use student's choice");
4990: }
1.1 raeburn 4991: my %items = (
4992: 'default_xml_style' => {
1.3 raeburn 4993: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 4994: '<a href="javascript:openbrowser'.
4995: "('display','default_xml_style'".
4996: ",'sty')".'">'.&mt('Select Style File').'</a>',
4997: input => 'textbox',
4998: size => 35,
4999: },
5000:
5001: 'pageseparators' => {
1.3 raeburn 5002: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 5003: input => 'radio',
5004: },
5005: 'disable_receipt_display' => {
1.3 raeburn 5006: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 5007: input => 'radio',
5008: },
5009: 'texengine' => {
1.3 raeburn 5010: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 5011: input => 'selectbox',
5012: options => {
1.61 raeburn 5013: MathJax => 'MathJax',
1.1 raeburn 5014: mimetex => &mt('Convert to Images'),
5015: tth => &mt('TeX to HTML'),
5016: },
1.75 raeburn 5017: order => ['MathJax','mimetex','tth'],
1.9 raeburn 5018: nullval => $mathdef,
1.1 raeburn 5019: },
5020: 'tthoptions' => {
1.3 raeburn 5021: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 5022: input => 'textbox',
5023: size => 40,
5024: },
1.69 raeburn 5025: 'uselcmath' => {
5026: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
5027: input => 'radio',
5028: },
5029: 'usejsme' => {
5030: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
5031: input => 'radio',
5032: },
1.95 raeburn 5033: 'inline_chem' => {
5034: text => '<b>'.&mt($itemtext->{'inline_chem'}).'</b>',
5035: input => 'radio',
5036: },
1.1 raeburn 5037: );
1.80 raeburn 5038: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 5039: }
5040:
5041: sub print_grading {
1.80 raeburn 5042: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5043: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5044: return;
5045: }
5046: my %items = (
5047: 'grading' => {
1.3 raeburn 5048: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 5049: &Apache::loncommon::help_open_topic('GradingOptions'),
5050: input => 'selectbox',
5051: options => {
5052: standard => &mt('Standard: shows points'),
1.34 www 5053: categories => &mt('Categories: shows points according to categories'),
1.11 www 5054: external => &mt('External: shows number of completed parts and totals'),
5055: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 5056: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
5057: },
1.34 www 5058: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 5059: },
5060: 'rndseed' => {
1.3 raeburn 5061: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 5062: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 5063: &mt('Modifying this will make problems have different numbers and answers!').
5064: '</span>',
5065: input => 'selectbox',
5066: options => {
5067: '32bit' => '32bit',
5068: '64bit' => '64bit',
5069: '64bit2' => '64bit2',
5070: '64bit3' => '64bit3',
5071: '64bit4' => '64bit4',
5072: '64bit5' => '64bit5',
5073: },
5074: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 5075: advanced => 1
1.1 raeburn 5076: },
5077: 'receiptalg' => {
1.3 raeburn 5078: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 5079: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 5080: input => 'selectbox',
5081: options => {
5082: receipt => 'receipt',
5083: receipt2 => 'receipt2',
5084: receipt3 => 'receipt3',
5085: },
5086: order => ['receipt','receipt2','receipt3'],
1.41 www 5087: advanced => 1
1.1 raeburn 5088: },
5089: 'disablesigfigs' => {
1.3 raeburn 5090: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 5091: input => 'radio',
5092: },
5093: );
1.80 raeburn 5094: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit);
1.1 raeburn 5095: }
5096:
5097: sub print_printouts {
1.80 raeburn 5098: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5099: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5100: return;
5101: }
5102: my %items = (
5103: problem_stream_switch => {
1.3 raeburn 5104: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 5105: input => 'radio',
5106: },
5107: suppress_tries => {
1.3 raeburn 5108: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 5109: input => 'radio',
5110: },
5111: default_paper_size => {
1.3 raeburn 5112: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 5113: input => 'selectbox',
5114: options => {
5115: Letter => &mt('Letter').' [8 1/2x11 in]',
5116: Legal => &mt('Legal').' [8 1/2x14 in]',
5117: Tabloid => &mt('Tabloid').' [11x17 in]',
5118: Executive => &mt('Executive').' [7 1/2x10 in]',
5119: A2 => &mt('A2').' [420x594 mm]',
5120: A3 => &mt('A3').' [297x420 mm]',
5121: A4 => &mt('A4').' [210x297 mm]',
5122: A5 => &mt('A5').' [148x210 mm]',
5123: A6 => &mt('A6').' [105x148 mm]',
5124: },
5125: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.54 bisitz 5126: nullval => &mt('None specified'),
1.1 raeburn 5127: },
5128: print_header_format => {
1.3 raeburn 5129: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 5130: input => 'checkbox',
5131: },
5132: disableexampointprint => {
1.3 raeburn 5133: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 5134: input => 'radio',
5135: },
1.14 raeburn 5136: canuse_pdfforms => {
5137: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
5138: input => 'selectbox',
5139: options => {
5140: 1 => &mt('Yes'),
5141: 0 => &mt('No'),
5142: },
5143: order => ['1','0'],
1.54 bisitz 5144: nullval => &mt('None specified - use domain default'),
1.14 raeburn 5145: }
1.1 raeburn 5146: );
1.80 raeburn 5147: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 5148: }
5149:
5150: sub print_spreadsheet {
1.80 raeburn 5151: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5152: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5153: return;
5154: }
5155: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
5156: my %items = (
5157: spreadsheet_default_classcalc => {
1.3 raeburn 5158: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 5159: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
5160: "('display','spreadsheet_default_classcalc'".
5161: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
5162: input => 'textbox',
5163: },
5164: spreadsheet_default_studentcalc => {
1.3 raeburn 5165: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 5166: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
5167: "('display','spreadsheet_default_calc'".
5168: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
5169: input => 'textbox',
5170: },
5171: spreadsheet_default_assesscalc => {
1.3 raeburn 5172: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 5173: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
5174: "('display','spreadsheet_default_assesscalc'".
5175: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
5176: input => 'textbox',
5177: },
5178: hideemptyrows => {
1.3 raeburn 5179: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 5180: input => 'radio',
5181: },
5182: );
1.80 raeburn 5183: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 5184: }
1.1 raeburn 5185:
5186: sub print_bridgetasks {
1.80 raeburn 5187: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5188: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5189: return;
5190: }
1.9 raeburn 5191: my ($stumsg,$msgnote);
5192: if ($crstype eq 'Community') {
5193: $stumsg = &mt('Send message to member');
5194: $msgnote = &mt('Message to member and add to user notes');
5195: } else {
5196: $stumsg = &mt('Send message to student');
5197: $msgnote = &mt('Message to student and add to user notes');
5198: }
1.1 raeburn 5199: my %items = (
5200: task_messages => {
1.3 raeburn 5201: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 5202: input => 'selectbox',
5203: options => {
1.9 raeburn 5204: only_student => $stumsg,
5205: student_and_user_notes_screen => $msgnote,
1.1 raeburn 5206: },
5207: order => ['only_student','student_and_user_notes_screen'],
5208: nullval => &mt('No message or record in user notes'),
5209: },
5210: task_grading => {
1.3 raeburn 5211: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 5212: input => 'selectbox',
5213: options => {
5214: any => &mt('Grade BTs in any section'),
5215: section => &mt('Grade BTs only in own section')
5216: },
5217: order => ['any','section'],
5218: },
5219: suppress_embed_prompt => {
1.3 raeburn 5220: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
5221: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 5222: input => 'radio',
5223: },
5224: );
1.80 raeburn 5225: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 5226: }
5227:
1.87 raeburn 5228: sub print_lti {
5229: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
5230: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
5231: return;
5232: }
5233: my @menuitems = ('fullname','coursetitle','role','logout','grades');
5234: my %menutitles = <imenu_titles();
5235: my ($domdefs,$displaydefs);
5236: if ($env{'request.lti.login'}) {
5237: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
5238: my @domdefsmenu;
5239: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
5240: if ($lti{$env{'request.lti.login'}}{'topmenu'}) {
5241: $domdefs = &mt('Header shown').', ';
5242: }
5243: if ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
5244: $domdefs .= &mt('Inline menu shown');
5245: }
5246: $domdefs =~ s/,\s$//;
5247: if (!$domdefs) {
5248: $domdefs = &mt('No header or inline menu shown');
5249: }
5250: $domdefs = ' ('.&mt('Domain default').': '.$domdefs.')';
5251: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
5252: @domdefsmenu = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
5253: }
5254: }
5255: $displaydefs = &mt('Domain defaults');
5256: if (@domdefsmenu) {
5257: my @diffs = &Apache::loncommon::compare_arrays(\@menuitems,\@domdefsmenu);
5258: if (@diffs) {
5259: my $missing;
5260: foreach my $item (@menuitems) {
5261: unless (grep(/^\Q$item\E$/,@domdefsmenu)) {
5262: $missing .= ' '.$menutitles{$item}.',';
5263: }
5264: }
5265: $missing =~ s/,$//;
5266: $displaydefs .= ': '.&mt('Not shown').' --'.$missing;
5267: } else {
5268: $displaydefs .= ': '.&mt('All shown');
5269: }
5270: } else {
5271: $displaydefs .= ': '.&mt('Not shown').' -- '.join(', ', map { $menutitles{$_}; } @menuitems);
5272: }
5273: } else {
5274: $displaydefs = &mt('Domain defaults only available in LTI context');
5275: }
5276: my %items = (
5277: 'lti.override' => {
5278: text => '<b>'.&mt($itemtext->{'lti.override'}).'</b>'.$domdefs,
5279: input => 'radio',
5280: },
5281: 'lti.topmenu' => {
5282: text => '<b>'.&mt($itemtext->{'lti.topmenu'}).'</b>',
5283: input => 'radio',
5284: },
5285: 'lti.inlinemenu' => {
5286: text => '<b>'.&mt($itemtext->{'lti.inlinemenu'}).'</b>',
5287: input => 'radio',
5288: },
5289: 'lti.lcmenu' => {
5290: text => '<b>'.&mt($itemtext->{'lti.lcmenu'}).'</b><br />'.$displaydefs,
5291: input => 'custom',
5292: },
5293: );
5294: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'lti',$noedit);
5295: }
5296:
5297: sub lcmenu_checkboxes {
5298: my ($cdom,$caller,$settings,$crstype,$noedit) = @_;
5299: my @menuitems = ('fullname','coursetitle','role','logout','grades');
5300: my %menutitles = <imenu_titles();
5301: my (@current,@domdefs);
5302: if ($env{'request.lti.login'}) {
5303: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
5304: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
5305: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
5306: @domdefs = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
5307: }
5308: }
5309: }
5310: if (ref($settings) eq 'HASH') {
5311: if ($settings->{'lti.lcmenu'}) {
5312: unless ($settings->{'lti.lcmenu'} eq 'none') {
5313: @current = split(',',$settings->{'lti.lcmenu'});
5314: }
5315: } else {
5316: @current = @domdefs;
5317: }
5318: } else {
5319: @current = @domdefs;
5320: }
5321: my $numinrow = 3;
5322: my $count = 0;
5323: my $disabled;
5324: if ($noedit) {
5325: $disabled = ' disabled="disabled"';
5326: }
5327: my $output = '<table>';
5328: foreach my $item (@menuitems) {
5329: my $checked = '';
5330: if (grep(/^\Q$item\E$/,@current)) {
5331: $checked = ' checked="checked" ';
5332: }
5333: my $rem = $count%($numinrow);
5334: if ($rem == 0) {
5335: if ($count > 0) {
5336: $output .= '</tr>';
5337: }
5338: $output .= '<tr>';
5339: }
5340: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" '.
5341: 'name="lti.lcmenu" value="'.$item.'"'.$checked.$disabled.'/> '.
5342: $menutitles{$item}.'</label></span></td>';
5343: $count ++;
5344: }
5345: my $rem = $count%($numinrow);
5346: my $colsleft = $numinrow - $rem;
5347: if ($colsleft > 1 ) {
5348: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
5349: ' </td>';
5350: } elsif ($colsleft == 1) {
5351: $output .= '<td class="LC_left_item"> </td>';
5352: }
5353: $output .= '</tr></table>';
5354: }
5355:
5356: sub ltimenu_titles {
5357: return &Apache::lonlocal::texthash(
5358: fullname => 'Full name',
5359: coursetitle => 'Course title',
5360: role => 'Role',
5361: logout => 'Logout',
5362: grades => 'Grades',
5363: );
5364: }
5365:
1.91 raeburn 5366: sub print_menuitems {
5367: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
5368: unless ((ref($settings) eq 'HASH') && (ref($itemtext) eq 'HASH')) {
5369: return;
5370: }
5371: if ($position eq 'top') {
5372: my (%defaultmenu_options,@defaultmenu_order,$addcollection);
5373: if ($settings->{'menucollections'} ne '') {
5374: foreach my $item (split(/;/,$settings->{'menucollections'})) {
5375: my ($num,$value) = split(/\%/,$item);
5376: if ($num =~ /^\d+$/) {
5377: $defaultmenu_options{$num} = $num;
5378: }
5379: }
5380: @defaultmenu_order = sort { $a <=> $b } keys(%defaultmenu_options);
5381: $addcollection = $defaultmenu_order[-1] + 1;
5382: } else {
5383: $addcollection = 1;
5384: }
5385: $defaultmenu_options{$addcollection} = $addcollection;
5386: my %items = (
5387: 'menudefault' => {
5388: text => '<b>'.&mt($itemtext->{'menudefault'}).'</b><br />'.
5389: &mt("(can be overriden in deep-link context)"),
5390: input => 'selectbox',
5391: options => \%defaultmenu_options,
5392: order => \@defaultmenu_order,
5393: nullval => &mt('Standard (all menus shown)'),
5394: },
5395: );
5396: return &make_item_rows($cdom,\%items,['menudefault'],$settings,$rowtotal,$crstype,'menuitems',$noedit);
5397: } else {
5398: my %menu;
5399: my $count = 0;
5400: my $next = 1;
5401: my ($datatable,$disabled);
5402: if ($noedit) {
5403: $disabled = ' disabled="disabled"';
5404: }
5405:
5406: my ($ordered,$cats) = &menuitems_categories();
5407: my @order = @{$ordered};
5408: my %categories = %{$cats};
5409: my %menutitles = &menuitems_titles();
5410: my %menufields = &menuitems_fields();
5411:
5412: if ($settings->{'menucollections'} ne '') {
5413: foreach my $item (split(/;/,$settings->{'menucollections'})) {
5414: my ($num,$value) = split(/\%/,$item);
5415: if ($num =~ /^\d+$/) {
5416: my @entries = split(/\&/,$value);
5417: foreach my $entry (@entries) {
5418: my ($name,$fields) = split(/=/,$entry);
5419: $menu{$num}{$name} = $fields;
5420: }
5421: }
5422: }
5423: if (keys(%menu)) {
5424: my @current = sort { $a <=> $b } keys(%menu);
5425: $next += $current[-1];
5426: foreach my $num (@current) {
5427: my %checked;
5428: my $on = ' checked="checked"';
5429: foreach my $key (keys(%{$menu{$num}})) {
1.94 raeburn 5430: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
1.91 raeburn 5431: if ($menu{$num}{$key} eq 'y') {
5432: $checked{$key} = $on;
5433: }
5434: } else {
5435: foreach my $field (split(/,/,$menu{$num}{$key})) {
5436: if (exists($menufields{$field})) {
5437: $checked{$field} = $on;
5438: }
5439: }
5440: }
5441: }
5442: if (ref($menu{$num}) eq 'HASH') {
5443: $datatable .= &item_table_row_start('<em class="LC_nav_bar">'.$num.'</em>',$count,'','','','LC_left_item');
5444: foreach my $category (@order) {
5445: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
5446: $datatable .= '<fieldset style="vertical-align:top; display:inline-block"><legend>'.$menutitles{$category}.'</legend>'."\n";
1.94 raeburn 5447: if ($category eq 'text') {
5448: $datatable .= '<i>'.&mt('Header').'</i><br />';
5449: }
1.91 raeburn 5450: foreach my $field (@{$categories{$category}}) {
1.94 raeburn 5451: if ($field eq 'disc') {
5452: $datatable .= '<br /><i>'.&mt('Footer').'</i><br />';
5453: }
1.91 raeburn 5454: $datatable .= '<label><input type="checkbox" name="menucollections_'.$num.'" value="'.$field.'"'.$checked{$field}.$disabled.' />'.
5455: $menufields{$field}.'</label><br />';
5456: }
5457: $datatable .= '</fieldset>';
5458: }
5459: }
5460: $datatable .= &item_table_row_end();
5461: $count ++;
5462: }
5463: }
5464: }
5465: } elsif ($noedit) {
5466: my $text = &mt('No menu collections defined for this course.');
5467: $datatable .= &item_table_row_start($text,$count);
5468: }
5469: unless ($noedit) {
5470: my $add = '<label><input type="checkbox" name="menucollections_add" id="menucollections_add" value="'.$next.'" '.
5471: 'onclick="javascript:toggleAddmenucoll();" />'.&mt('Add').'</label>';
5472: $datatable .= &item_table_row_start($add,$count,'','','','LC_left_item');
5473: foreach my $category (@order) {
5474: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
5475: $datatable .= '<fieldset id="addmenucoll_'.$category.'" style="display:none; vertical-align:top;"><legend>'.$menutitles{$category}.'</legend>'."\n";
5476: foreach my $field (@{$categories{$category}}) {
5477: $datatable .= '<label><input type="checkbox" class="LC_menucoll_add" name="menucollections_'.$next.'" value="'.$field.'"'.$disabled.' />'.
5478: $menufields{$field}.'</label><br />';
5479: }
5480: $datatable .= '</fieldset>';
5481: }
5482: }
5483: $datatable .= &item_table_row_end();
5484: $count ++;
5485: }
5486: return $datatable;
5487: }
5488: }
5489:
5490: sub menuitems_abbreviations {
5491: my %briefcats = (
5492: text => 'pt',
5493: links => 'p',
5494: list => 'ps',
5495: inline => 's',
5496: );
5497: return %briefcats;
5498: }
5499:
5500: sub menuitems_categories {
5501: my @order = ('shown','text','links','list','inline');
5502: my %categories = (
1.94 raeburn 5503: shown => ['top','inline','foot','main'],
5504: text => ['name','role','crs','disc','fdbk'],
1.92 raeburn 5505: links => ['pers','logo','menu','comm','roles','help','logout'],
1.91 raeburn 5506: list => ['about','prefs','port','wish','anno','rss'],
5507: inline => ['cont','grades','chat','people','groups','resv','syll','feeds'],
5508: );
5509: return (\@order,\%categories);
5510: }
5511:
5512: sub menuitems_titles {
5513: return &Apache::lonlocal::texthash (
5514: shown => 'Hierarchy',
1.94 raeburn 5515: text => 'Text',
1.91 raeburn 5516: links => 'Header links',
5517: list => 'Drop-down list',
5518: inline => 'Inline links',
5519: );
5520: }
5521:
5522: sub menuitems_fields {
5523: return &Apache::lonlocal::texthash (
5524: top => 'Display header',
5525: inline => 'Display inline menu',
1.94 raeburn 5526: foot => 'Display footer',
1.91 raeburn 5527: main => 'Access to main menu',
1.92 raeburn 5528: pers => 'Personal',
5529: logo => 'LON-CAPA',
1.91 raeburn 5530: menu => 'Home',
5531: comm => 'Messages',
5532: roles => 'Roles/Courses',
5533: help => 'Help',
5534: logout => 'Logout',
5535: name => 'Fullname',
5536: crs => 'Course Title',
5537: role => 'Current Role',
1.94 raeburn 5538: disc => 'Discussion',
5539: fdbk => 'Feedback',
1.91 raeburn 5540: about => 'Information',
5541: prefs => 'Preferences',
5542: port => 'Portfolio',
5543: wish => 'Stored Links',
5544: anno => 'Calendar',
5545: rss => 'RSS Feeds',
5546: cont => 'Contents',
5547: grades => 'Grades',
5548: chat => 'Chat',
5549: people => 'People',
5550: groups => 'Groups',
5551: resv => 'Reservations',
5552: syll => 'Syllabus',
5553: feeds => 'Feeds',
5554: );
5555: }
5556:
5557: sub menucollections_display {
5558: my ($collections) = @_;
5559: my %menu;
5560: my ($ordered,$cats) = &menuitems_categories();
5561: my @order = @{$ordered};
5562: my %categories = %{$cats};
5563: my %menutitles = &menuitems_titles();
5564: my %menufields = &menuitems_fields();
5565: foreach my $item (split(/;/,$collections)) {
5566: my ($num,$value) = split(/\%/,$item);
5567: if ($num =~ /^\d+$/) {
5568: my @entries = split(/\&/,$value);
5569: foreach my $entry (@entries) {
5570: my ($name,$fields) = split(/=/,$entry);
5571: $menu{$num}{$name} = $fields;
5572: }
5573: }
5574: }
5575: my $output = '';
5576: if (keys(%menu)) {
5577: my @current = sort { $a <=> $b } keys(%menu);
5578: foreach my $num (@current) {
5579: my %checked;
5580: foreach my $key (keys(%{$menu{$num}})) {
1.94 raeburn 5581: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
1.91 raeburn 5582: if ($menu{$num}{$key} eq 'y') {
5583: $checked{$key} = 1;
5584: }
5585: } else {
5586: foreach my $field (split(/,/,$menu{$num}{$key})) {
5587: if (exists($menufields{$field})) {
5588: $checked{$field} = 1;
5589: }
5590: }
5591: }
5592: }
5593: if (ref($menu{$num}) eq 'HASH') {
5594: $output .= '<fieldset><legend>'.&mt('Collection [_1]',$num).'</legend>';
5595: foreach my $category (@order) {
5596: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
5597: $output .= '<fieldset style="vertical-align:top; display:inline-block">'.
5598: '<legend>'.$menutitles{$category}.'</legend>'."\n";
1.94 raeburn 5599: if ($category eq 'text') {
5600: $output .= '<b>'.&mt('Header Text').'</b><br /><br />';
5601: }
1.91 raeburn 5602: foreach my $field (@{$categories{$category}}) {
1.94 raeburn 5603: if ($field eq 'disc') {
5604: $output .= '<br /><b>'.&mt('Footer Text').'</b><br /><br />';
5605: }
1.91 raeburn 5606: if ($checked{$field}) {
5607: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field});
5608: } else {
5609: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field},1);
5610: }
5611: $output .= '<br />';
5612: }
5613: $output .= '</fieldset>';
5614: }
5615: }
5616: $output .= '</fieldset>';
5617: }
5618: }
5619: }
5620: return $output;
5621: }
5622:
1.93 raeburn 5623: sub print_linkprotection {
1.102 raeburn 5624: my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
1.93 raeburn 5625: unless (ref($settings) eq 'HASH') {
5626: return;
5627: }
5628:
5629: my %linkprotection;
5630: my $count = 0;
5631: my $next = 1;
1.102 raeburn 5632: my ($datatable,$disabled,$css_class,$dest);
1.93 raeburn 5633: if ($noedit) {
5634: $disabled = ' disabled="disabled"';
5635: }
1.100 raeburn 5636: my %desc = &linkprot_names();
5637: my %lt = &Apache::lonlocal::texthash (
5638: 'requ' => 'Required settings',
5639: 'opti' => 'Optional settings',
5640: );
1.93 raeburn 5641: my $itemcount = 0;
5642:
1.100 raeburn 5643: my $ltiauth;
1.102 raeburn 5644: if ($context eq 'domain') {
5645: $ltiauth = 1;
5646: } else {
5647: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
5648: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
5649: } else {
5650: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
5651: $ltiauth = $domdefs{'crsltiauth'};
5652: }
5653: }
5654: if ($context eq 'domain') {
5655: $dest = '/adm/domainprefs';
1.100 raeburn 5656: } else {
1.102 raeburn 5657: $dest = '/adm/courseprefs';
5658: }
5659:
5660: my ($switchserver,$switchmessage);
5661: $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
5662: if ($switchserver) {
5663: if ($context eq 'domain') {
5664: $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
5665: } elsif ($crstype eq 'Community') {
5666: $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
5667: } else {
5668: $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
5669: }
1.100 raeburn 5670: }
1.99 raeburn 5671:
1.102 raeburn 5672: if (ref($settings->{'linkprot'}) eq 'HASH') {
5673: if (keys(%{$settings->{'linkprot'}})) {
5674: my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}});
1.93 raeburn 5675: $next += $current[-1];
5676: for (my $i=0; $i<@current; $i++) {
5677: my $num = $current[$i];
5678: my %values;
1.102 raeburn 5679: if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') {
5680: %values = %{$settings->{'linkprot'}->{$num}};
1.93 raeburn 5681: } else {
5682: next;
5683: }
5684: my $selected;
5685: if (($values{'version'} eq 'LTI-1p0') || ($values{'version'} eq '')) {
5686: $selected = ' selected="selected"';
5687: }
5688: $css_class = $itemcount%2?' class="LC_odd_row"':'';
5689: $datatable .=
5690: '<tr '.$css_class.'><td><span class="LC_nobreak">'.
5691: '<label><input type="checkbox" name="linkprot_del" value="'.$i.'"'.$disabled.' />'.
1.100 raeburn 5692: &mt('Delete?').'</label></span></td><td>';
5693: my ($usersty,$onclickrequser,%checkedrequser);
5694: if ($ltiauth) {
5695: $usersty = 'display:none';
1.102 raeburn 5696: $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','$i'".');"';
1.100 raeburn 5697: %checkedrequser = (
5698: no => ' checked="checked"',
5699: yes => '',
5700: );
5701: if ($values{'requser'}) {
5702: $checkedrequser{'yes'} = $checkedrequser{'no'};
5703: $checkedrequser{'no'} = '';
5704: }
5705: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
5706: if ($values{'requser'}) {
5707: $usersty = 'display:inline-block';
5708: }
5709: }
5710: $datatable .=
5711: '<span class="LC_nobreak">'.$desc{'name'}.
1.98 raeburn 5712: ':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '.
1.93 raeburn 5713: (' 'x2).
1.100 raeburn 5714: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_'.$i.'"'.$disabled.'>'.
1.93 raeburn 5715: '<option value="LTI-1p0" '.$selected.'>1.1</option></select></span> '."\n".
5716: (' 'x2).
1.100 raeburn 5717: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" name="linkprot_lifetime_'.$i.'"'.
5718: ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' /></span>';
5719: if ($ltiauth) {
5720: $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
5721: '<label><input type="radio" name="linkprot_requser_'.$i.'" value="0"'.
5722: $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
5723: '<label><input type="radio" name="linkprot_requser_'.$i.'" value="1"'.
1.101 raeburn 5724: $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>';
1.100 raeburn 5725: }
1.101 raeburn 5726: $datatable .= '<br /><br />';
1.99 raeburn 5727: if ($values{'key'} ne '') {
1.100 raeburn 5728: $datatable .= '<span class="LC_nobreak">'.$desc{'key'};
1.99 raeburn 5729: if ($noedit) {
5730: $datatable .= ': ['.&mt('not shown').']';
5731: } elsif ($switchserver) {
5732: $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
5733: } else {
5734: $datatable .= ':<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />';
5735: }
5736: $datatable .= '</span> '.(' 'x2);
5737: } elsif (!$switchserver) {
1.100 raeburn 5738: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':'.
1.99 raeburn 5739: '<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />'.
5740: '</span> '.(' 'x2);
5741: }
5742: if ($switchserver) {
5743: if ($values{'usable'} ne '') {
5744: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
1.100 raeburn 5745: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
1.99 raeburn 5746: '<span class="LC_nobreak">'.&mt('Change secret?').
1.102 raeburn 5747: '<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
1.99 raeburn 5748: (' 'x2).
1.102 raeburn 5749: '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2).
1.99 raeburn 5750: '</span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
1.102 raeburn 5751: '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
1.99 raeburn 5752: '</div>';
5753: } elsif ($values{'key'} eq '') {
1.102 raeburn 5754: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 5755: } else {
1.102 raeburn 5756: $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 5757: }
5758: } else {
5759: if ($values{'usable'} ne '') {
5760: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
1.100 raeburn 5761: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
1.99 raeburn 5762: '<span class="LC_nobreak">'.&mt('Change?').
1.102 raeburn 5763: '<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
1.99 raeburn 5764: (' 'x2).
1.102 raeburn 5765: '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');"'.$disabled.' />'.&mt('Yes').
1.99 raeburn 5766: '</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
5767: '<span class="LC_nobreak">'.&mt('New Secret').':'.
5768: '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'.
5769: '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
5770: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>';
5771: } else {
5772: $datatable .=
1.100 raeburn 5773: '<span class="LC_nobreak">'.$desc{'secret'}.':'.
1.99 raeburn 5774: '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'.
5775: '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'.
5776: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>';
5777: }
5778: }
1.100 raeburn 5779: if ($ltiauth) {
5780: $datatable .=
5781: '</fieldset>'.
5782: '<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
5783: &linkprot_options($i,$itemcount,$disabled,\%values,\%desc).
5784: '</fieldset>';
5785: }
1.99 raeburn 5786: $datatable .= '</td></tr>';
1.93 raeburn 5787: $itemcount ++;
5788: }
5789: }
5790: }
5791: $css_class = $itemcount%2?' class="LC_odd_row"':'';
5792: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
5793: '<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n".
1.98 raeburn 5794: '<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n".
1.100 raeburn 5795: '<td>';
5796: my ($usersty,$onclickrequser,%checkedrequser);
5797: if ($ltiauth) {
5798: $usersty = 'display:none';
1.102 raeburn 5799: $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','add'".');"';
1.100 raeburn 5800: %checkedrequser = (
5801: no => ' checked="checked"',
5802: yes => '',
5803: );
5804: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
5805: }
5806: $datatable .= '<span class="LC_nobreak">'.$desc{'name'}.
1.98 raeburn 5807: ':<input type="text" size="15" name="linkprot_name_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
1.93 raeburn 5808: (' 'x2).
1.100 raeburn 5809: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_add"'.$disabled.'>'.
1.93 raeburn 5810: '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
5811: (' 'x2).
1.100 raeburn 5812: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" size="3" name="linkprot_lifetime_add" value="300"'.$disabled.' /></span> '."\n";
5813: if ($ltiauth) {
5814: $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
5815: '<label><input type="radio" name="linkprot_requser_add" value="0"'.
5816: $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
5817: '<label><input type="radio" name="linkprot_requser_add" value="1"'.
5818: $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>';
5819: }
5820: $datatable .= '<br /><br />';
1.99 raeburn 5821: if ($switchserver) {
1.102 raeburn 5822: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 5823: } else {
1.100 raeburn 5824: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
1.99 raeburn 5825: (' 'x2).
1.100 raeburn 5826: '<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'.
1.99 raeburn 5827: '<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n";
5828: }
1.100 raeburn 5829: if ($ltiauth) {
5830: $datatable .= '</fieldset>'.
5831: '<fieldset id="linkprot_optional_add" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
5832: &linkprot_options('add',$itemcount,$disabled,{},\%desc).
5833: '</fieldset>';
5834: }
1.99 raeburn 5835: $datatable .= '</td></tr>';
1.93 raeburn 5836: $$rowtotal ++;
1.101 raeburn 5837: return $datatable;
1.93 raeburn 5838: }
5839:
5840: sub linkprot_names {
1.100 raeburn 5841: return &Apache::lonlocal::texthash(
1.93 raeburn 5842: 'version' => 'LTI Version',
5843: 'key' => 'Key',
5844: 'lifetime' => 'Nonce lifetime (s)',
1.100 raeburn 5845: 'name' => 'Launcher Application',
1.93 raeburn 5846: 'secret' => 'Secret',
1.100 raeburn 5847: 'requser' => 'Use identity',
5848: 'email' => 'Email address',
5849: 'sourcedid' => 'User ID',
5850: 'other' => 'Other',
5851: 'auth' => 'Display LON-CAPA login page',
5852: 'reject' => 'Discontinue launch process',
1.93 raeburn 5853: );
5854: }
5855:
1.99 raeburn 5856: sub check_switchserver {
1.102 raeburn 5857: my ($cdom,$cnum,$context,$dest) = @_;
5858: my ($allowed,$switchserver,$home);
5859: if ($context eq 'domain') {
5860: $home = &Apache::lonnet::domain($cdom,'primary');
5861: } else {
5862: $home = &Apache::lonnet::homeserver($cnum,$cdom);
5863: }
5864: unless (($home eq 'no_host') || ($home eq '')) {
1.99 raeburn 5865: my @ids=&Apache::lonnet::current_machine_ids();
5866: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
5867: if (!$allowed) {
5868: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role='.
5869: &HTML::Entities::encode($env{'request.role'},'\'<>"&').
1.102 raeburn 5870: '&destinationurl='.$dest.'">'.&mt('Switch Server').'</a>';
1.99 raeburn 5871: }
5872: }
5873: return $switchserver;
5874: }
5875:
1.100 raeburn 5876: sub linkprot_options {
5877: my ($num,$itemcount,$disabled,$current,$desc) = @_;
5878: my %lt;
5879: if (ref($desc) eq 'HASH') {
5880: %lt = %{$desc};
5881: }
5882: my $userfieldsty = 'none';
5883: my (%checked,$userfield);
5884: $checked{'sourcedid'} = ' checked="checked"';
5885: $checked{'reject'} = ' checked="checked"';
5886: if (ref($current) eq 'HASH') {
5887: if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
5888: $checked{'sourcedid'} = '';
5889: if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
5890: $checked{'email'} = ' checked="checked"';
5891: } else {
5892: $checked{'other'} = ' checked="checked"';
5893: $userfield = $current->{'mapuser'};
5894: $userfieldsty = 'inline-block';
5895: }
5896: }
5897: if (($current->{'notstudent'} ne '') && ($current->{'notstudent'} ne 'reject')) {
5898: $checked{'reject'} = '';
5899: $checked{'auth'} = ' checked="checked"';
5900: }
5901: }
1.102 raeburn 5902: my $onclickuser = ' onclick="toggleLinkProtReqUser(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
1.100 raeburn 5903: my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'.
5904: &mt('Source of LON-CAPA username in LTI request').': ';
5905: foreach my $option ('sourcedid','email','other') {
5906: $output .= '<label><input type="radio" name="linkprot_mapuser_'.$num.'" value="'.$option.'"'.
5907: $checked{$option}.$onclickuser.$disabled.' />'.$lt{$option}.'</label>'.
5908: ($option eq 'other' ? '' : (' 'x2) );
5909: }
5910: $output .= '</span></div>'.
5911: '<div class="LC_floatleft" style="display:'.$userfieldsty.';" id="linkprot_userfield_'.$num.'">'.
5912: '<input type="text" name="linkprot_customuser_'.$num.'" '.
5913: 'value="'.$userfield.'"'.$disabled.' /></div>';
5914: $output .= '<br />'.
5915: '<div class="LC_floatleft"><span class="LC_nobreak">'.
5916: &mt('Action when username is not for an enrolled student').': ';
5917: foreach my $option ('reject','auth') {
5918: $output .= '<label><input type="radio" name="linkprot_notstudent_'.$num.'" value="'.$option.'"'.
5919: $checked{$option}.$disabled.' />'.$lt{$option}.'</label>'.
5920: ($option eq 'auth' ? '' : (' 'x2) );
5921: }
5922: $output .= '</span></div>';
5923: return $output;
5924: }
5925:
1.1 raeburn 5926: sub print_other {
1.80 raeburn 5927: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 5928: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
5929: return;
5930: }
1.3 raeburn 5931: my @ordered = &get_other_items($cdom,$settings,$allitems);
5932: my %items;
5933: foreach my $parameter (@ordered) {
5934: $items{$parameter} = {
5935: text => '<b>'.$parameter.'</b>',
5936: input => 'textbox',
5937: size => '15',
5938: },
5939: }
5940: push (@ordered,'newp_value');
5941: $items{'newp_value'} = {
5942: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
5943: '<input type="textbox" name="newp_name"'.
5944: ' value="" size="30" />',
5945: input => 'textbox',
5946: size => '30',
5947: };
1.93 raeburn 5948: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 5949: }
5950:
5951: sub get_other_items {
5952: my ($cdom,$settings,$allitems) = @_;
5953: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
5954: return;
5955: }
1.1 raeburn 5956: my @ordered;
5957: if (ref($settings) eq 'HASH') {
5958: foreach my $parameter (sort(keys(%{$settings}))) {
5959: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 5960: next if (($parameter eq 'course.helper.not.run') &&
5961: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 5962: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
5963: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
5964: || ($parameter eq 'type') ||
1.50 raeburn 5965: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.62 raeburn 5966: || ($parameter =~ m/^discussion_post_fonts/) ||
1.63 raeburn 5967: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
5968: ($parameter eq 'clonedfrom')) {
1.1 raeburn 5969: push(@ordered,$parameter);
5970: }
5971: }
5972: }
1.3 raeburn 5973: return @ordered;
1.1 raeburn 5974: }
5975:
5976: sub item_table_row_start {
1.91 raeburn 5977: my ($text,$count,$add_class,$colspan,$leftclass,$rightclass) = @_;
1.1 raeburn 5978: my $output;
1.56 raeburn 5979: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
5980: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.91 raeburn 5981: if ($leftclass eq '') {
5982: $leftclass = 'LC_left_item';
5983: }
5984: if ($rightclass eq '') {
5985: $rightclass = 'LC_right_item';
5986: }
1.56 raeburn 5987: $output .= '<tr class="'.$css_class.'">'."\n".
1.91 raeburn 5988: '<td class="'.$leftclass.'">'.$text.
1.56 raeburn 5989: '</td>';
1.91 raeburn 5990: if ($colspan > 1) {
5991: $output .= '<td class="'.$rightclass.'" colspan="'.$colspan.'">';
1.56 raeburn 5992: } else {
1.91 raeburn 5993: $output .= '<td class="'.$rightclass.'">';
1.56 raeburn 5994: }
1.1 raeburn 5995: return $output;
5996: }
5997:
5998: sub item_table_row_end {
5999: return '</td></tr>';
6000: }
6001:
6002: sub yesno_radio {
1.80 raeburn 6003: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_;
1.1 raeburn 6004: my $itemon = ' ';
6005: my $itemoff = ' checked="checked" ';
1.69 raeburn 6006: if (($valueyes eq '') && ($valueno eq '')) {
6007: $valueyes = 'yes';
6008: $valueno = '';
6009: }
1.1 raeburn 6010: if (ref($settings) eq 'HASH') {
1.69 raeburn 6011: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 6012: $itemon = $itemoff;
6013: $itemoff = ' ';
6014: }
1.69 raeburn 6015: unless (exists($settings->{$item})) {
6016: if ($unsetdefault eq $valueyes) {
6017: $itemon = $itemoff;
6018: $itemoff = ' ';
6019: }
6020: }
1.1 raeburn 6021: }
1.80 raeburn 6022: my $disabled;
6023: if ($noedit) {
6024: $disabled = ' disabled="disabled"';
6025: }
1.1 raeburn 6026: return '<span class="LC_nobreak"><label>'.
6027: '<input type="radio" name="'.$item.'"'.
1.80 raeburn 6028: $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').'</label> '.
1.1 raeburn 6029: '<label><input type="radio" name="'.$item.'"'.
1.80 raeburn 6030: $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').'</label></span>';
1.1 raeburn 6031: }
6032:
6033: sub select_from_options {
1.91 raeburn 6034: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit,$id) = @_;
1.1 raeburn 6035: my $output;
1.80 raeburn 6036: my $disabled;
6037: if ($noedit) {
6038: $disabled = ' disabled=disabled"';
6039: }
1.1 raeburn 6040: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
6041: $output='<select name="'.$item.'" '.$onchange;
6042: if ($multiple) {
6043: $output .= ' multiple="multiple"';
6044: my $num = @{$order};
6045: $num ++ if ($nullval ne '');
6046: if (($maxsize) && ($maxsize < $num)) {
6047: $output .= ' size="'.$maxsize.'"';
6048: }
6049: }
1.91 raeburn 6050: if ($id ne '') {
6051: $output .= ' id="'.$id.'"';
6052: }
1.80 raeburn 6053: $output .= $disabled.'>'."\n";
1.1 raeburn 6054: if ($nullval ne '') {
6055: $output .= '<option value=""';
6056: if (ref($curr) eq 'ARRAY') {
6057: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
6058: $output .= ' selected="selected" ';
6059: }
6060: } else {
6061: if ($curr eq '') {
6062: $output .= ' selected="selected" ';
6063: }
6064: }
6065: $output .= '>'.$nullval.'</option>';
6066: }
6067: foreach my $option (@{$order}) {
6068: $output.= '<option value="'.$option.'"';
6069: if (ref($curr) eq 'ARRAY') {
6070: if (grep(/^\Q$option\E$/,@{$curr})) {
6071: $output .= ' selected="selected" ';
6072: }
6073: } else {
6074: if ($option eq $curr) {
6075: $output.=' selected="selected"';
6076: }
6077: }
6078: $output.=">$options->{$option}</option>\n";
6079: }
6080: $output.="</select>";
6081: }
6082: return $output;
6083: }
6084:
6085: sub make_item_rows {
1.80 raeburn 6086: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit) = @_;
1.1 raeburn 6087: my $datatable;
6088: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
6089: my $count = 0;
6090: foreach my $item (@{$ordered}) {
6091: $count ++;
1.56 raeburn 6092: my $colspan;
6093: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
6094: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
6095: $colspan = 2;
6096: }
1.41 www 6097: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.56 raeburn 6098: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
1.41 www 6099: } else {
1.56 raeburn 6100: $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
1.41 www 6101: }
1.55 raeburn 6102: if ($item eq 'defaultcredits') {
6103: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
6104: my $showcredits;
6105: if ($defaultcredits ne '') {
6106: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
6107: } else {
6108: $showcredits = &mt('No default set');
6109: }
6110: $datatable .= $showcredits;
6111: } elsif ($item eq 'nothideprivileged') {
1.80 raeburn 6112: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.56 raeburn 6113: } elsif ($item eq 'checkforpriv') {
1.80 raeburn 6114: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 6115: } elsif ($item eq 'print_header_format') {
1.80 raeburn 6116: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.87 raeburn 6117: } elsif ($item eq 'lti.lcmenu') {
6118: $datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 6119: } elsif ($items->{$item}{input} eq 'dates') {
1.80 raeburn 6120: my $disabled;
6121: if ($noedit) {
6122: $disabled = ' disabled="disabled"';
6123: }
1.1 raeburn 6124: $datatable .=
6125: &Apache::lonhtmlcommon::date_setter('display',$item,
1.80 raeburn 6126: $settings->{$item},$disabled);
1.1 raeburn 6127: } elsif ($items->{$item}{input} eq 'radio') {
1.69 raeburn 6128: my ($unsetdefault,$valueyes,$valueno);
1.95 raeburn 6129: if (($item eq 'usejsme') || ($item eq 'uselcmath') || ($item eq 'inline_chem')) {
1.69 raeburn 6130: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
6131: unless ($domdefs{$item} eq '0') {
6132: $unsetdefault = 1;
6133: }
6134: $valueyes = "1";
6135: $valueno = "0";
1.87 raeburn 6136: } elsif (($item eq 'lti.topmenu') || ($item eq 'lti.inlinemenu')) {
6137: $valueyes = '1';
1.69 raeburn 6138: }
1.80 raeburn 6139: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 6140: } elsif ($items->{$item}{input} eq 'selectbox') {
1.91 raeburn 6141: my $id;
6142: if ($caller eq 'menuitems') {
6143: $id = $item;
6144: }
1.1 raeburn 6145: my $curr = $settings->{$item};
6146: $datatable .=
6147: &select_from_options($item,$items->{$item}{'order'},
6148: $items->{$item}{'options'},$curr,
1.80 raeburn 6149: $items->{$item}{'nullval'},
1.91 raeburn 6150: undef,undef,undef,$noedit,$id);
1.1 raeburn 6151: } elsif ($items->{$item}{input} eq 'textbox') {
1.80 raeburn 6152: my $disabled;
6153: if ($noedit) {
6154: $disabled = ' disabled=disabled"';
6155: }
1.1 raeburn 6156: $datatable .=
6157: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.80 raeburn 6158: $items->{$item}{size},
6159: $disabled);
1.1 raeburn 6160: }
6161: $datatable .= &item_table_row_end();
6162: }
6163: if (ref($rowtotal)) {
6164: $$rowtotal += scalar(@{$ordered});
6165: }
6166: }
6167: return $datatable;
6168: }
6169:
6170: sub nothidepriv_row {
1.80 raeburn 6171: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 6172: my ($cnum) = &get_course();
1.56 raeburn 6173: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 6174: if (ref($settings) eq 'HASH') {
6175: if ($settings->{$item} ne '') {
6176: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
6177: if ($user !~ /:/) {
6178: $nothide{join(':',split(/[\@]/,$user))}=1;
6179: } else {
6180: $nothide{$user} = 1;
6181: }
6182: }
6183: }
1.56 raeburn 6184: if ($settings->{'checkforpriv'}) {
6185: @checkdoms = split(/,/,$settings->{'checkforpriv'});
6186: }
1.1 raeburn 6187: }
1.56 raeburn 6188: push(@checkdoms,$cdom);
6189: my %coursepersonnel =
6190: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 6191: my @privusers;
6192: foreach my $person (keys(%coursepersonnel)) {
1.56 raeburn 6193: my ($uname,$udom,$role) = split(/:/,$person);
6194: my $user = $uname.':'.$udom;
6195: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 6196: if ($end == -1 || $start == -1) {
6197: next;
6198: }
1.56 raeburn 6199: foreach my $dom (@checkdoms) {
6200: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
6201: unless (grep(/^\Q$user\E$/,@privusers)) {
6202: push(@privusers,$user);
1.3 raeburn 6203: }
6204: }
6205: }
1.1 raeburn 6206: }
1.56 raeburn 6207: if (@privusers > 0) {
1.80 raeburn 6208: my $disabled;
6209: if ($noedit) {
6210: $disabled = ' disabled="disabled"';
6211: }
1.1 raeburn 6212: $datatable .= '<table align="right">';
6213: foreach my $user (sort(@privusers)) {
6214: my $hideon = ' checked="checked" ';
6215: my $hideoff = '';
6216: if ($nothide{$user}) {
6217: $hideoff = $hideon;
6218: $hideon = '';
6219: }
6220: my ($uname,$udom) = split(':',$user);
6221: $datatable .= '<tr><td align="left">'.
6222: &Apache::loncommon::aboutmewrapper(
6223: &Apache::loncommon::plainname($uname,$udom,'firstname'),
6224: $uname,$udom,'aboutuser').
6225: '</td><td align="left">'.
6226: '<span class="LC_nobreak"><label>'.
6227: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 6228: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.69 raeburn 6229: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 6230: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 6231: '</tr>';
6232: }
6233: $datatable .= '</table>';
6234: } else {
1.9 raeburn 6235: if ($crstype eq 'Community') {
6236: $datatable .= &mt('No Domain Coordinators have community roles');
6237: } else {
6238: $datatable .= &mt('No Domain Coordinators have course roles');
6239: }
1.1 raeburn 6240: }
6241: return $datatable;
6242: }
6243:
1.56 raeburn 6244: sub checkforpriv_row {
1.80 raeburn 6245: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.56 raeburn 6246: my $datatable;
6247: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
6248: if (keys(%domains) == 1) {
6249: $datatable = '</td><td align="right">'.
6250: &mt("Course's domain is only domain");
6251: return $datatable;
6252: }
6253: my @excdoms = ($cdom);
6254: my $num = 0;
6255: if ($settings->{$item} eq '') {
6256: $datatable = '</td><td align="right">'.
6257: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.80 raeburn 6258: 1,1,undef,undef,\@excdoms,
6259: $noedit);
1.56 raeburn 6260: } else {
6261: my @privdoms = split(/,/,$settings->{$item});
6262: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
6263: $datatable = '</td><td align="right"><br />'.
6264: &Apache::loncommon::start_data_table();
1.80 raeburn 6265: my $disabled;
6266: if ($noedit) {
6267: $disabled = ' disabled="disabled"';
6268: }
1.56 raeburn 6269: if (@privdoms > 0) {
6270: foreach my $currdom (@privdoms) {
6271: next unless ($domains{$currdom});
6272: my $domdesc = &Apache::lonnet::domain($currdom,'description');
6273: if ($domdesc eq '') {
6274: $domdesc = $currdom;
6275: }
6276: $datatable .=
6277: &Apache::loncommon::start_data_table_row().
6278: '<td align="left"><span class="LC_nobreak">'.
6279: &mt('Domain:').'<b> '.$domdesc.
6280: '</b><input type="hidden" name="checkforpriv_'.$num.
6281: '" value="'.$currdom.'" /></span><br />'.
6282: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.82 raeburn 6283: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
6284: &mt('Delete').'</label></span></td>'.
1.56 raeburn 6285: &Apache::loncommon::end_data_table_row();
6286: $num ++;
6287: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
6288: push(@excdoms,$currdom);
6289: }
6290: }
6291: }
6292: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
6293: $datatable .=
6294: &Apache::loncommon::start_data_table_row().
6295: '<td align="left"><span class="LC_nobreak">'.
6296: &mt('Additional domain:'). '</span><br />'.
6297: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.80 raeburn 6298: 1,undef,undef,\@excdoms,$noedit).
1.56 raeburn 6299: '</td>'.&Apache::loncommon::end_data_table_row();
6300: }
6301: $datatable .= &Apache::loncommon::end_data_table().
6302: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
6303: '<br />';
6304: }
6305: return $datatable;
6306: }
6307:
1.1 raeburn 6308: sub print_hdrfmt_row {
1.80 raeburn 6309: my ($item,$settings,$noedit) = @_;
1.1 raeburn 6310: my @curr;
6311: my $currnum = 0;
6312: my $maxnum = 2;
6313: my $currstr;
6314: if ($settings->{$item} ne '') {
6315: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
6316: $settings->{$item}.'</tt></span></b><br />';
6317: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 6318: foreach my $val (@current) {
6319: unless ($val eq '') {
6320: push(@curr,$val);
1.1 raeburn 6321: }
6322: }
6323: $currnum = @curr;
6324: $maxnum += $currnum;
6325: }
6326:
6327: my $output = <<ENDJS;
6328:
6329: <script type="text/javascript" language="Javascript">
6330:
6331: function reOrder(chgnum) {
6332: var maxnum = $maxnum;
6333: var oldidx = 'printfmthdr_oldpos_'+chgnum;
6334: var newidx = 'printfmthdr_pos_'+chgnum;
6335: oldidx = getIndexByName(oldidx);
6336: newidx = getIndexByName(newidx);
6337: var oldpos = document.display.elements[oldidx].value;
6338: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6339: document.display.elements[oldidx].value = newpos;
6340: var chgtype = 'up';
6341: if (newpos < oldpos) {
6342: chgtype = 'down';
6343: }
6344: for (var j=0; j<maxnum; j++) {
6345: if (j != chgnum) {
6346: oldidx = 'printfmthdr_oldpos_'+j;
6347: newidx = 'printfmthdr_pos_'+j;
6348: oldidx = getIndexByName(oldidx);
6349: newidx = getIndexByName(newidx);
6350: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6351: var currsel = document.display.elements[newidx].selectedIndex;
6352: if (chgtype == 'up') {
6353: if ((currpos > oldpos) && (currpos <= newpos)) {
6354: document.display.elements[newidx].selectedIndex = currsel-1;
6355: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6356: }
6357: } else {
6358: if ((currpos >= newpos) && (currpos < oldpos)) {
6359: document.display.elements[newidx].selectedIndex = currsel+1;
6360: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6361: }
6362: }
6363: }
6364: }
6365: return;
6366: }
6367:
6368: function getIndexByName(item) {
6369: for (var i=0;i<document.display.elements.length;i++) {
6370: if (document.display.elements[i].name == item) {
6371: return i;
6372: }
6373: }
6374: return -1;
6375: }
6376:
6377: </script>
6378:
6379: ENDJS
1.56 raeburn 6380: $output .= '</td><td align="right"><br />'.
6381: $currstr.'<table class="LC_data_table">';
1.80 raeburn 6382: my $disabled;
6383: if ($noedit) {
6384: $disabled = ' disabled="disabled"';
6385: }
1.1 raeburn 6386: if (@curr > 0) {
6387: for (my $i=0; $i<@curr; $i++) {
6388: my $pos = $i+1;
1.10 raeburn 6389: $output .= '<tr>'.
1.1 raeburn 6390: '<td align="left"><span class="LC_nobreak">'.
1.80 raeburn 6391: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 6392: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.80 raeburn 6393: '"'.$disabled.' /></span></td>';
1.1 raeburn 6394: if ($curr[$i] =~ /^%\d*[nca]$/) {
6395: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
6396: $output .= '<td align="left">'.
1.80 raeburn 6397: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 6398: } else {
6399: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
6400: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.80 raeburn 6401: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 6402: }
1.10 raeburn 6403: $output .= '</tr>';
1.1 raeburn 6404: }
6405: }
1.80 raeburn 6406: my $pos = $currnum+1;
6407: unless ($noedit) {
6408: $output .=
6409: '<tr>'.
1.1 raeburn 6410: '<td align="left"><span class="LC_nobreak">'.
6411: &position_selector($pos,$currnum,$maxnum).
6412: '<b>'.&mt('New').'</b></span></td><td align="left">'.
6413: &substitution_selector($currnum).'</td>'.
1.10 raeburn 6414: '</tr>';
1.80 raeburn 6415: $pos ++;
1.82 raeburn 6416: $currnum ++;
6417: $output .=
1.80 raeburn 6418: '<tr>'.
1.1 raeburn 6419: '<td align="left"><span class="LC_nobreak">'.
6420: &position_selector($pos,$currnum,$maxnum).
6421: '<b>'.&mt('New').'</b></span></td>'.
6422: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
6423: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 6424: '" value="" size ="25" />'.
6425: '<input type="hidden" name="printfmthdr_maxnum" value="'.
6426: $maxnum.'" /></td>'.
1.80 raeburn 6427: '</tr>';
6428: }
6429: $output .= '</table><br />';
1.1 raeburn 6430: return $output;
6431: }
6432:
6433: sub position_selector {
1.80 raeburn 6434: my ($pos,$num,$maxnum,$disabled) = @_;
6435: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 6436: for (my $j=1; $j<=$maxnum; $j++) {
6437: my $sel = '';
6438: if ($pos == $j) {
6439: $sel = ' selected="selected"';
6440: }
6441: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
6442: }
6443: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
6444: '" value="'.$pos.'" />';
6445: return $output;
6446: }
6447:
6448: sub substitution_selector {
1.80 raeburn 6449: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 6450: my ($stunametxt,$crsidtxt);
6451: if ($crstype eq 'Community') {
6452: $stunametxt = 'member name';
6453: $crsidtxt = 'community ID',
6454: } else {
6455: $stunametxt = 'student name';
6456: $crsidtxt = 'course ID',
6457: }
1.1 raeburn 6458: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 6459: n => $stunametxt,
6460: c => $crsidtxt,
1.1 raeburn 6461: a => 'assignment note',
6462: );
6463: my $output .= &mt('Substitution').'<br />'.
1.80 raeburn 6464: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 6465: if ($subst eq '') {
6466: $output .= '<option value="" selected="selected"> </option>';
6467: }
6468: foreach my $field ('n','c','a') {
6469: my $sel ='';
6470: if ($subst eq $field) {
6471: $sel = ' selected="selected"';
6472: }
6473: $output .= '<option value="'.$field.'"'.$sel.'>'.
6474: $lt{$field}.'</option>';
6475: }
6476: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
6477: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.82 raeburn 6478: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 6479: return $output;
6480: }
6481:
1.23 raeburn 6482: sub change_clone {
6483: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
6484: my $clone_crs = $cnum.':'.$cdom;
6485: if ($cnum && $cdom) {
6486: my $clone_crs = $cnum.':'.$cdom;
6487: my @allowclone;
6488: if ($clonelist =~ /,/) {
6489: @allowclone = split(',',$clonelist);
6490: } else {
6491: $allowclone[0] = $clonelist;
6492: }
6493: foreach my $currclone (@allowclone) {
6494: if (!grep(/^$currclone$/,@$oldcloner)) {
6495: if ($currclone ne '*') {
1.71 raeburn 6496: if ($currclone =~ /:/) {
6497: my ($uname,$udom) = split(/:/,$currclone);
6498: if ($uname && $udom && $uname ne '*') {
6499: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
6500: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
6501: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
6502: if ($currclonecrs{'cloneable'} eq '') {
6503: $currclonecrs{'cloneable'} = $clone_crs;
6504: } else {
6505: $currclonecrs{'cloneable'} .= ','.$clone_crs;
6506: }
6507: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 6508: }
6509: }
6510: }
6511: }
6512: }
6513: }
6514: }
6515: foreach my $oldclone (@$oldcloner) {
6516: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
6517: if ($oldclone ne '*') {
1.71 raeburn 6518: if ($oldclone =~ /:/) {
6519: my ($uname,$udom) = split(/:/,$oldclone);
6520: if ($uname && $udom && $uname ne '*' ) {
6521: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
6522: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
6523: my %newclonecrs = ();
6524: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
6525: if ($currclonecrs{'cloneable'} =~ /,/) {
6526: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
6527: foreach my $crs (@currclonecrs) {
6528: if ($crs ne $clone_crs) {
6529: $newclonecrs{'cloneable'} .= $crs.',';
6530: }
1.23 raeburn 6531: }
1.71 raeburn 6532: $newclonecrs{'cloneable'} =~ s/,$//;
6533: } else {
6534: $newclonecrs{'cloneable'} = '';
1.23 raeburn 6535: }
1.71 raeburn 6536: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 6537: }
6538: }
6539: }
6540: }
6541: }
6542: }
6543: }
6544: }
6545: return;
6546: }
6547:
1.1 raeburn 6548: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>