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