Annotation of loncom/interface/courseprefs.pm, revision 1.108
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.108 ! raeburn 4: # $Id: courseprefs.pm,v 1.107 2022/04/05 12:22:41 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'};
1551: for (my $i=0; $i<=$maxnum; $i++) {
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.107 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') {
! 1681: $lastactref->{'courselti'} = 1';
! 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: }
2216: }
2217: }
2218: }
2219: }
2220: my @ids=&Apache::lonnet::current_machine_ids();
2221: if (keys(%ltienc) > 0) {
2222: if ($context eq 'domain') {
2223: foreach my $id (keys(%ltienc)) {
2224: if (exists($ltienc{$id}{'secret'})) {
2225: $changes->{$id}->{'usable'} = 1;
2226: }
2227: }
2228: } else {
1.103 raeburn 2229: unless (($home eq 'no_host') || ($home eq '')) {
1.102 raeburn 2230: my $allowed;
2231: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
2232: if ($allowed) {
2233: if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') {
2234: foreach my $id (keys(%ltienc)) {
2235: if (exists($ltienc{$id}{'secret'})) {
2236: $changes->{$id}->{'usable'} = 1;
2237: }
2238: }
2239: } else {
2240: $lti_save_error = 1;
2241: }
2242: }
2243: }
2244: }
2245: }
2246: unless ($lti_save_error) {
2247: if ($context eq 'course') {
2248: if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') {
2249: my $hashid=$cdom.'_'.$cnum;
2250: &Apache::lonnet::devalidate_cache_new('courselti',$hashid);
1.103 raeburn 2251: unless (($home eq 'no_host') || ($home eq '')) {
2252: if (grep(/^\Q$home\E$/,@ids)) {
1.102 raeburn 2253: &Apache::lonnet::devalidate_cache_new('courseltienc',$hashid);
2254: }
2255: }
2256: } else {
2257: $lti_save_error = 1;
2258: }
2259: }
2260: unless ($lti_save_error) {
2261: foreach my $id (sort { $a <=> $b } %{$changes}) {
2262: if (ref($changes->{$id}) eq 'HASH') {
2263: my %values = %{$changes->{$id}};
2264: my %desc = &linkprot_names();
2265: my $display;
2266: foreach my $title ('name','lifetime','version','key','secret') {
2267: if (($title eq 'key') || ($title eq 'secret')) {
2268: if (ref($ltienc{$id}) eq 'HASH') {
2269: if (exists($ltienc{$id}{$title})) {
2270: if ($title eq 'secret') {
2271: my $length = length($ltienc{$id}{$title});
1.103 raeburn 2272: $display .= $desc{$title}.': ['.&mt('not shown').'], ';
1.102 raeburn 2273: } else {
2274: $display .= $desc{$title}.': '.$ltienc{$id}{$title}.', ';
2275: }
2276: }
2277: }
2278: } elsif ($title eq 'version') {
2279: if ($values{$title} eq 'LTI-1p0') {
2280: $display .= $desc{$title}.': 1.1, ';
2281: }
2282: } else {
2283: $display .= $desc{$title}.': '.$values{$title}.', ';
2284: }
2285: }
2286: if ($ltiauth) {
2287: if (($values{'requser'}) && ($values{'mapuser'} ne '')) {
2288: if ($values{'mapuser'} eq 'lis_person_contact_email_primary') {
2289: $display .= &mt('Source of username: Email address [_1]',
2290: '(lis_person_contact_email_primary)').', ';
2291: } elsif ($values{'mapuser'} eq 'lis_person_sourcedid') {
2292: $display .= &mt('Source of username: User ID [_1]',
2293: '(lis_person_sourcedid)').', ';
2294: } else {
2295: $display .= &mt('Source of username: [_1]',$values{'mapuser'}).', ';
2296: }
2297: if ($values{'notstudent'} eq 'auth') {
2298: $display .= &mt('Display LON-CAPA login page if no match').', ';
2299: } elsif ($values{'notstudent'} eq 'reject') {
2300: $display .= &mt('Discontinue launch if no match').', ';
2301: }
2302: }
2303: }
2304: $display =~ s/, $//;
2305: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$id.'</i>',
2306: "'$display'")).'</li>';
2307: } elsif (ref($oldlinkprot->{$id}) eq 'HASH') {
2308: my $oldname = $oldlinkprot->{$id}{'name'};
2309: $output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'."$id ($oldname)".'</i>')).'</li>';
2310: }
2311: }
2312: } else {
2313: $lti_save_error = 1;
2314: }
2315: }
2316: unless ($lti_save_error) {
2317: foreach my $id (sort { $a <=> $b } keys(%{$changes})) {
2318: unless (ref($changes->{$id}) eq 'HASH') {
2319: push(@deletions,$id);
2320: }
2321: }
2322: if (@deletions) {
2323: if ($context eq 'course') {
2324: &Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum);
2325: }
2326: }
2327: }
2328: if ($lti_save_error) {
2329: $output .= '<li>'.
2330: '<span class="LC_error">'.
2331: &mt('An error occurred when saving changes to link protection settings, which remain unchanged.').
2332: '</span>'.
2333: '</li>';
2334: }
2335: return $output;
2336: }
2337:
1.3 raeburn 2338: sub update_env {
2339: my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_;
2340: my $count = 0;
2341: if ((ref($need_env_update) eq 'ARRAY') && (ref($storehash) eq 'HASH')) {
2342: my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,undef,undef,'.');
2343: if (ref($crsinfo{$env{'request.course.id'}}) eq 'HASH') {
2344: foreach my $key (@{$need_env_update}) {
2345: if ($key eq 'description' && defined($storehash->{$key})) {
2346: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.description' => $storehash->{$key}});
2347: $crsinfo{$env{'request.course.id'}}{'description'} = $storehash->{$key};
2348: $count ++;
2349: } elsif (($key eq 'cloners') || ($key eq 'hidefromcat') || ($key eq 'categories')) {
2350: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
2351: $crsinfo{$env{'request.course.id'}}{$key} = $storehash->{$key};
2352: $count ++;
1.25 raeburn 2353: } elsif ($key eq 'co-owners') {
2354: if ($storehash->{'internal.co-owners'} ne '') {
2355: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.co-owners' => $storehash->{'internal.co-owners'}});
2356: }
2357: if ($storehash->{'internal.pendingco-owners'} ne '') {
2358: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.internal.pendingco-owners' => $storehash->{'internal.pendingco-owners'}});
2359: }
2360: my @coowners = split(',',$storehash->{'internal.'.$key});
2361: $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners;
2362: $count ++;
1.87 raeburn 2363: } elsif ($key =~ /^lti\./) {
2364: &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}});
1.3 raeburn 2365: }
2366: }
2367: if ($count) {
2368: my $putresult = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
2369: }
2370: }
2371: }
2372: return;
2373: }
2374:
2375: sub display_disallowed {
1.9 raeburn 2376: my ($item,$disallowed,$prefs,$crstype) = @_;
1.3 raeburn 2377: my $output;
2378: if ((ref($disallowed) eq 'HASH') && (ref($prefs) eq 'HASH')) {
2379: if (keys(%{$disallowed})) {
2380: if ($item eq 'cloners') {
2381: my @fails;
2382: my %lt = &Apache::lonlocal::texthash (
2383: format => 'Invalid format',
2384: domain => 'Domain does not exist',
2385: newuser => 'LON-CAPA user(s) do(es) not exist.',
2386: );
2387: foreach my $error ('format','domain','newuser') {
2388: if (defined($disallowed->{$error})) {
2389: my $msg = '<b>'.$disallowed->{$error}.'</b>, '.&mt('reason').' - '.
2390: $lt{$error};
2391: if ($error eq 'newuser') {
1.9 raeburn 2392: $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 2393: }
2394: push(@fails,$msg);
2395: }
2396: }
2397: if (@fails) {
2398: $output .= '<span class="LC_warning">'.&mt('Unable to add to allowed cloners: ').
2399: '</span>'.join('; ',@fails).'.<br />';
2400: }
2401: } elsif ($item eq 'rolenames') {
2402: my %lt = &Apache::lonlocal::texthash (
2403: replacements => 'Name already used to replace a different standard role name',
2404: regulars => 'Name already used as a standard role name',
2405: customrole => 'Name already used as the name of a custom role',
2406: );
2407: my @fails;
2408: foreach my $error ('replacements','regulars','customrole') {
2409: if (ref($disallowed->{$error}) eq 'ARRAY') {
2410: push(@fails,'<b>'.join(', ',@{$disallowed->{$error}}).
2411: '</b>, '.&mt('reason').' - '.$lt{'error'});
2412: }
2413: }
2414: if (@fails) {
2415: $output .= '<span class="LC_warning">'.
2416: &mt('Unable to include amongst replacements for role names: ').
2417: '</span>'.join('; ',@fails).'.<br />';
2418: }
2419:
2420: } elsif (($item eq 'feedback') || ($item eq 'discussion') || ($item eq 'localization')) {
2421: $output .= '<span class="LC_warning">';
2422: if ($item eq 'feedback') {
1.9 raeburn 2423: if ($crstype eq 'Community') {
2424: $output .= &mt('Unable to include as a recipient of community feedback for:');
2425: } else {
2426: $output .= &mt('Unable to include as a recipient of course feedback for:');
2427: }
1.3 raeburn 2428: } elsif ($item eq 'discussion') {
2429: $output .= &mt('Unable to include in user-based access control for:');
2430: } elsif ($item eq 'localization') {
1.9 raeburn 2431: if ($crstype eq 'Community') {
2432: $output .= &mt('Unable to include in community localization:');
2433: } else {
2434: $output .= &mt('Unable to include in course localization:');
2435: }
1.3 raeburn 2436: }
2437: $output .= '</span><ul>';
2438: foreach my $key (sort(keys(%{$disallowed}))) {
2439: my $itemtext = $prefs->{$item}{'itemtext'}{$key};
2440: $output .= '<li><i>'.$itemtext.'</i> - ';
2441: if ($item eq 'localization') {
2442: $output .= &mt('reason - unsupported language: [_1]',
2443: '<b>'.$disallowed->{$key}.'</b>');
2444: } else {
2445: $output .= &mt('reason - invalid user: [_1]',
2446: '<b>'.$disallowed->{$key}.'</b>').'</li>';
2447: }
2448: }
2449: $output .= '</ul><br />';
2450: }
2451: }
1.1 raeburn 2452: }
1.3 raeburn 2453: return $output;
1.1 raeburn 2454: }
2455:
2456: sub get_course {
2457: my ($courseid) = @_;
2458: if (!defined($courseid)) {
2459: $courseid = $env{'request.course.id'};
2460: }
2461: my $cdom=$env{'course.'.$courseid.'.domain'};
2462: my $cnum=$env{'course.'.$courseid.'.num'};
1.66 raeburn 2463: my $chome=$env{'course.'.$courseid.'.home'};
2464: return ($cnum,$cdom,$chome);
1.1 raeburn 2465: }
2466:
2467: sub get_jscript {
1.91 raeburn 2468: my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_;
1.12 raeburn 2469: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.71 raeburn 2470: my ($jscript,$categorize_js,$loncaparev_js,$instcode_js);
1.1 raeburn 2471: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
2472: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
1.3 raeburn 2473: my $cloners_js = &cloners_javascript($phase);
1.71 raeburn 2474: my @code_order;
2475: if ($crstype ne 'Community') {
2476: if (ref($settings) eq 'HASH') {
2477: my %codedefaults;
2478: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
2479: \@code_order);
2480: if (@code_order > 0) {
2481: if ($phase eq 'display') {
2482: my @actions = &Apache::loncommon::get_env_multiple('form.actions');
2483: if (grep(/^courseinfo$/,@actions)) {
2484: if ($settings->{'cloners'} ne '') {
2485: unless ($settings->{'cloners'} eq '*') {
2486: my @cloners = split(/,/,$settings->{'cloners'});
2487: my @standardnames = &Apache::loncommon::get_standard_codeitems();
2488: my %local_to_standard;
2489: for (my $i=0; $i<@code_order; $i++) {
2490: $local_to_standard{$code_order[$i]} = $standardnames[$i];
2491: }
2492: foreach my $cloner (@cloners) {
2493: if (($cloner !~ /^\Q*:\E$match_domain$/) &&
2494: ($cloner !~ /^$match_username\:$match_domain$/)) {
2495: foreach my $item (split(/\&/,$cloner)) {
2496: my ($key,$val) = split(/\=/,$item);
2497: $val = &unescape($val);
2498: foreach my $code (@code_order) {
2499: if ($key eq $local_to_standard{$code}) {
2500: $env{'form.'.$key} = $val;
2501: }
2502: }
2503: }
2504: }
2505: }
2506: }
2507: }
2508: }
2509: }
2510: my @codetitles;
2511: (undef,$instcode_js) =
2512: &Apache::courseclassifier::instcode_selectors($cdom,'display',undef,
2513: \@codetitles);
2514: $instcode_js .= <<ENDSCRIPT;
2515: function toggleCloners(callerradio) {
2516: if (document.getElementById('LC_cloners_instcode')) {
2517: if (callerradio.value == 1) {
2518: document.getElementById('LC_cloners_instcode').style.display = "block";
2519: } else {
2520: uncheckOfficialLists();
2521: document.getElementById('LC_cloners_instcode').style.display = "none";
2522: }
2523: }
2524: }
2525:
2526: if (!document.getElementsByClassName) {
2527: function getElementsByClassName(node, classname) {
2528: var a = [];
2529: var re = new RegExp('(^| )'+classname+'( |$)');
2530: var els = node.getElementsByTagName("*");
2531: for(var i=0,j=els.length; i<j; i++)
2532: if(re.test(els[i].className))a.push(els[i]);
2533: return a;
2534: }
2535: }
2536:
2537: function uncheckOfficialLists() {
2538: var codepicks;
2539: if (document.getElementsByClassName) {
2540: codepicks = document.getElementsByClassName('LC_cloners_instcodes');
2541: } else {
2542: codepicks = getElementsByClassName(document.body,'LC_cloners_instcodes');
2543: }
2544: if (codepicks.length) {
2545: for (var i=0; i<codepicks.length; i++) {
2546: codepicks[i].selectedIndex = 0;
2547: }
2548: }
2549: }
2550:
2551: ENDSCRIPT
2552: }
2553: }
2554: }
1.1 raeburn 2555: if ($can_categorize) {
2556: $categorize_js = <<ENDSCRIPT;
2557: function catsbrowser() {
2558: var catswin = null;
2559: var url = '/adm/courseprefs?phase=categorizecourse';
2560: if (!catswin || catswin.closed) {
2561: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2562: } else {
2563: catswin.focus();
2564: }
2565: }
2566: ENDSCRIPT
2567: }
1.36 raeburn 2568: my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'};
2569: if ($loncaparev) {
2570: $loncaparev_js = <<ENDSCRIPT;
2571: function loncaparevinfo() {
2572: var lcrevwin = null;
2573: var url = '/adm/courseprefs?phase=releaseinfo';
2574: if (!lcrevwin || lcrevwin.closed) {
2575: lcrevwin=window.open(url,'releasewin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2576: } else {
2577: lcrevwin.focus();
2578: }
2579: }
2580: ENDSCRIPT
2581: }
1.60 raeburn 2582: my $cnum = $env{'course.'.$cid.'.num'};
2583: my $syllabus_js = <<ENDSCRIPT;
2584: function syllabusinfo() {
2585: var syllwin = null;
2586: var url = '/public/$cdom/$cnum/syllabus?only_body=1';
2587: if (!syllwin || syllwin.closed) {
2588: syllwin=window.open(url,'syllabuswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
2589: } else {
2590: syllwin.focus();
2591: }
2592: }
2593: ENDSCRIPT
1.91 raeburn 2594: my $menuitems_js;
2595: unless ($noedit) {
2596: my $collections;
2597: my $next = 1;
2598: if (ref($settings) eq 'HASH') {
2599: if ($settings->{'menucollections'} ne '') {
2600: my @current;
2601: foreach my $item (split(/;/,$settings->{'menucollections'})) {
2602: my ($num) = split(/\%/,$item);
2603: if ($num =~ /^\d+$/) {
2604: push(@current,$num);
2605: }
2606: }
2607: $collections = join("','",sort { $a <=> $b } @current);
2608: if ($collections) {
2609: $collections = "'$collections'";
2610: }
2611: $next += $current[-1];
2612: }
2613: }
2614: my $deftext = &mt('Standard (all menus shown)');
2615: $menuitems_js = <<ENDSCRIPT;
2616: function toggleAddmenucoll() {
2617: if (document.getElementById('menucollections_add')) {
2618: var state = 'none';
2619: var add = document.getElementById('menucollections_add').checked;
2620: if (add) {
2621: state = 'inline-block';
2622: }
2623: var fieldsets = new Array('shown','text','links','list','inline');
2624: for (var i=0; i<fieldsets.length; i++) {
2625: if (document.getElementById('addmenucoll_'+fieldsets[i])) {
2626: document.getElementById('addmenucoll_'+fieldsets[i]).style.display = state;
2627: }
2628: }
2629: var box = document.getElementsByClassName('LC_menucoll_add');
2630: if (box.length) {
2631: for (var i=0; i<box.length; i++) {
2632: if (add) {
2633: box[i].checked = true;
2634: } else {
2635: box[i].checked = false;
2636: }
2637: }
2638: }
2639: if (document.getElementById('menudefault')) {
2640: var menudef = document.getElementById('menudefault');
2641: var currsel = menudef.selectedIndex;
2642: var colls = new Array($collections);
2643: menudef.options.length = 0;
2644: if (!add) {
2645: if (currsel == 1 + colls.length) {
2646: currsel = 0;
2647: }
2648: }
2649: if (currsel == 0) {
2650: menudef.options[0] = new Option('$deftext','',true,true);
2651: } else {
2652: menudef.options[0] = new Option('$deftext','',false,false);
2653: }
2654: if (colls.length) {
2655: for (var i=0; i<colls.length; i++) {
2656: var idx = i+1;
2657: if (currsel == colls[i]) {
2658: menudef.options[idx] = new Option(colls[i],colls[i],true,true);
2659: } else {
2660: menudef.options[idx] = new Option(colls[i],colls[i],false,false);
2661: }
2662: }
2663: }
2664: if (add) {
2665: var addidx = 1 + colls.length;
2666: if (currsel == addidx) {
2667: menudef.options[addidx] = new Option('$next','$next',true,true);
2668: } else {
2669: menudef.options[addidx] = new Option('$next','$next',false,false);
2670: }
2671: }
2672: }
2673: }
2674: }
2675: ENDSCRIPT
2676: }
1.1 raeburn 2677: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
1.56 raeburn 2678: '// <![CDATA['."\n".
1.36 raeburn 2679: $browse_js."\n".$categorize_js."\n".$loncaparev_js."\n".
1.71 raeburn 2680: $cloners_js."\n".$instcode_js.
1.99 raeburn 2681: $syllabus_js."\n".$menuitems_js."\n".
1.102 raeburn 2682: &linkprot_javascript()."\n".'//]]>'."\n".
1.56 raeburn 2683: '</script>'."\n".$stubrowse_js."\n";
1.1 raeburn 2684: return $jscript;
2685: }
2686:
1.3 raeburn 2687: sub cloners_javascript {
2688: my ($formname) = @_;
2689: return <<"ENDSCRIPT";
2690:
2691: function update_cloners(caller,num) {
2692: var delidx = getIndexByName('cloners_delete');
2693: var actidx = getIndexByName('cloners_activate');
2694: if (caller == 'cloners_all') {
2695: var selall;
2696: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2697: if (document.$formname.cloners_all[i].checked) {
2698: selall = document.$formname.cloners_all[i].value;
2699: }
2700: }
2701: if (selall == 1) {
2702: if (delidx != -1) {
2703: if (document.$formname.cloners_delete.length) {
2704: for (var j=0; j<document.$formname.cloners_delete.length; j++) {
2705: document.$formname.cloners_delete[j].checked = true;
2706: }
2707: } else {
2708: document.$formname.elements[delidx].checked = true;
2709: }
2710: }
2711: if (actidx != -1) {
2712: if (document.$formname.cloners_activate.length) {
2713: for (var i=0; i<document.$formname.cloners_activate.length; i++) {
2714: if (document.$formname.cloners_activate[i].value == '0') {
2715: document.$formname.cloners_activate[i].checked = false;
2716: }
1.71 raeburn 2717: if (document.$formname.cloners_activate[i].value == '-1') {
1.3 raeburn 2718: document.$formname.cloners_activate[i].checked = true;
2719: }
2720: }
2721: }
2722: }
2723: document.$formname.cloners_newdom.selectedIndex = 0;
2724: }
2725: }
2726: if (caller == 'cloners_activate') {
2727: if (document.$formname.cloners_activate.length) {
2728: for (var j=0; j<document.$formname.cloners_activate.length; j++) {
2729: if (document.$formname.cloners_activate[j].value == num) {
2730: if (document.$formname.cloners_activate[j].checked) {
2731: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2732: if (document.$formname.cloners_all[i].value == '1') {
2733: document.$formname.cloners_all[i].checked = false;
2734: }
2735: if (document.$formname.cloners_all[i].value == '0') {
2736: document.$formname.cloners_all[i].checked = true;
2737: }
2738: }
2739: }
2740: }
2741: }
2742: } else {
2743: for (var i=0; i<document.$formname.cloners_all.length; i++) {
2744: if (document.$formname.cloners_all[i].value == '1') {
2745: document.$formname.cloners_all[i].checked = false;
2746: }
2747: if (document.$formname.cloners_all[i].value == '0') {
2748: document.$formname.cloners_all[i].checked = true;
2749: }
2750: }
2751: }
2752: }
2753: return;
2754: }
2755:
2756: function getIndexByName(item) {
2757: for (var i=0;i<document.$formname.elements.length;i++) {
2758: if (document.$formname.elements[i].name == item) {
2759: return i;
2760: }
2761: }
2762: return -1;
2763: }
2764:
2765: ENDSCRIPT
2766: }
2767:
1.102 raeburn 2768: sub linkprot_javascript {
2769: return <<"ENDSCRIPT";
2770: function toggleLinkProt(form,num,item) {
2771: var radioname = '';
2772: var currdivid = '';
2773: var newdivid = '';
2774: if ((document.getElementById('linkprot_divcurr'+item+'_'+num)) &&
2775: (document.getElementById('linkprot_divchg'+item+'_'+num))) {
2776: currdivid = document.getElementById('linkprot_divcurr'+item+'_'+num);
2777: newdivid = document.getElementById('linkprot_divchg'+item+'_'+num);
2778: radioname = form.elements['linkprot_change'+item+'_'+num];
2779: if (radioname) {
2780: if (radioname.length > 0) {
2781: var setvis;
2782: for (var i=0; i<radioname.length; i++) {
2783: if (radioname[i].checked == true) {
2784: if (radioname[i].value == 1) {
2785: newdivid.style.display = 'inline-block';
2786: currdivid.style.display = 'none';
2787: setvis = 1;
2788: }
2789: break;
2790: }
2791: }
2792: if (!setvis) {
2793: newdivid.style.display = 'none';
2794: currdivid.style.display = 'inline-block';
2795: }
2796: }
2797: }
2798: }
2799: return;
2800: }
2801:
2802: function toggleLinkProtReqUser(form,item,extra,valon,styleon,num) {
2803: if (document.getElementById('linkprot_'+extra+'_'+num)) {
2804: var extraid = document.getElementById('linkprot_'+extra+'_'+num);
2805: var itemname = form.elements['linkprot_'+item+'_'+num];
2806: if (itemname) {
2807: if (itemname.length > 0) {
2808: var setvis;
2809: for (var i=0; i<itemname.length; i++) {
2810: if (itemname[i].checked == true) {
2811: if (itemname[i].value == valon) {
2812: extraid.style.display = styleon;
2813: setvis = 1;
2814: }
2815: break;
2816: }
2817: }
2818: if (!setvis) {
2819: extraid.style.display = 'none';
2820: }
2821: }
2822: }
2823: }
2824: return;
2825: }
1.106 raeburn 2826:
2827: function uncheckLinkProtMakeVis(item,num) {
2828: if (document.getElementById('linkprot_'+item+'_'+num)) {
2829: var currtype = document.getElementById('linkprot_'+item+'_'+num).type;
2830: if (currtype.toLowerCase() == 'checkbox') {
2831: document.getElementById('linkprot_'+item+'_'+num).checked = false;
2832: }
2833: }
2834: return;
2835: }
1.102 raeburn 2836: ENDSCRIPT
2837:
2838: }
2839:
1.3 raeburn 2840:
1.1 raeburn 2841: sub print_courseinfo {
1.80 raeburn 2842: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 2843: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 2844: return;
2845: }
1.83 raeburn 2846: my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
2847: if ($noedit) {
2848: $disabled = ' disabled="disabled"';
2849: }
1.1 raeburn 2850: my %domconf =
1.71 raeburn 2851: &Apache::lonnet::get_dom('configuration',
2852: ['coursecategories','autoenroll','coursedefaults'],$cdom);
1.1 raeburn 2853: if (ref($domconf{'coursecategories'}) eq 'HASH') {
2854: $cathash = $domconf{'coursecategories'}{'cats'};
2855: if (ref($cathash) eq 'HASH') {
2856: $categoriesform =
2857: &Apache::loncommon::assign_categories_table($cathash,
1.83 raeburn 2858: $settings->{'categories'},$crstype,$disabled)."\n";
1.1 raeburn 2859: }
2860: }
1.25 raeburn 2861: if (ref($domconf{'autoenroll'}) eq 'HASH') {
2862: $autocoowner = $domconf{'autoenroll'}{'co-owners'};
2863: }
1.71 raeburn 2864: my ($currcanclone,@code_order,$cloner_instcode);
2865: my %codedefaults;
2866: &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults,
2867: \@code_order);
2868: if ($settings->{'cloners'}) {
2869: unless ($settings->{'cloners'} eq '*') {
2870: my @currclone = split(/,/,$settings->{'cloners'});
2871: foreach my $item (@currclone) {
2872: unless ($item eq '*') {
2873: if (($item !~ /\:/) && ($item =~ /=/)) {
2874: $cloner_instcode = 1;
2875: }
2876: }
2877: }
2878: }
2879: }
2880: if (ref($domconf{'coursedefaults'}) eq 'HASH') {
2881: my $canclone = $domconf{'coursedefaults'}{'canclone'};
2882: if (ref($canclone) eq 'HASH') {
2883: if (ref($canclone->{'instcode'}) eq 'ARRAY') {
2884: if ($settings->{'internal.coursecode'}) {
2885: my @posscodes;
2886: if (@code_order > 0) {
2887: $currcanclone = 'instcode';
2888: foreach my $item (@{$canclone->{'instcode'}}) {
2889: if (grep(/^\Q$item\E$/,@code_order)) {
2890: push(@posscodes,$item);
2891: }
2892: }
2893: my $codestr = join(' + ',@posscodes);
2894: $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.',
2895: '"<span class="LC_nobreak" style="font-style:italic">'.$codestr.'</span>"').'<br />';
2896: }
2897: }
2898: }
2899: } elsif ($canclone eq 'domain') {
2900: $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.',
2901: '<span class="LC_nobreak" style="font-style:italic">'.$cdom.'</span>').'<br />';
2902: $currcanclone = 'domain';
2903: }
2904: if ($clonedefaults) {
2905: if ($settings->{'cloners'} ne '') {
2906: $clonedefaults .= '<br />'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','<b>','</b>');
2907: } else {
2908: $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','<i>','</i>');
2909: }
2910: $clonedefaults = '<br /><br />'.$clonedefaults;
2911: }
2912: }
1.1 raeburn 2913: if (!defined($categoriesform)) {
1.15 raeburn 2914: $categoriesform = &mt('No categories defined in this domain.');
1.1 raeburn 2915: }
1.12 raeburn 2916: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype);
1.60 raeburn 2917: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1.1 raeburn 2918:
1.9 raeburn 2919: my $replace;
2920: if ($crstype eq 'Community') {
2921: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2922: } else {
2923: $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank');
2924: }
1.84 raeburn 2925: my ($editmap,$editsyllabus);
2926: unless ($noedit) {
2927: $editmap = (' 'x2).
2928: '<a href="javascript:openbrowser'.
2929: "('display','url','sequence')\">".
2930: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
2931: &mt('Modification may make assessment data inaccessible!').
2932: '</span>';
2933: $editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">',
2934: '</a>');
2935: }
1.1 raeburn 2936: my %items = (
1.3 raeburn 2937: 'url' => {
1.84 raeburn 2938: text => '<b>'.&mt($itemtext->{'url'}).'</b>'.$editmap,
1.1 raeburn 2939: input => 'textbox',
1.55 raeburn 2940: size => '55',
1.19 faziophi 2941: advanced => 1
1.1 raeburn 2942: },
2943: 'description' => {
1.3 raeburn 2944: text => '<b>'.&mt($itemtext->{'description'}).'</b>',
1.1 raeburn 2945: input => 'textbox',
1.55 raeburn 2946: size => '55',
1.1 raeburn 2947: },
1.24 raeburn 2948: 'owner' => {
2949: text => '<b>'.&mt($itemtext->{'owner'}).'</b>',
2950: },
1.25 raeburn 2951: 'co-owners' => {
2952: text => '<b>'.&mt($itemtext->{'co-owners'}).'</b>',
2953: },
1.63 raeburn 2954: 'clonedfrom' => {
2955: text => '<b>'.&mt($itemtext->{'clonedfrom'}).'</b>',
2956: },
1.1 raeburn 2957: 'courseid' => {
1.3 raeburn 2958: text => '<b>'.&mt($itemtext->{'courseid'}).'</b><br />'.'('.
2959: &mt('internal, optional').')',
1.1 raeburn 2960: input => 'textbox',
2961: size => '25',
2962: },
1.64 raeburn 2963: 'uniquecode' => {
2964: text => '<b>'.&mt($itemtext->{'uniquecode'}).'</b>',
2965: },
1.1 raeburn 2966: 'cloners' => {
1.3 raeburn 2967: text => '<b>'.&mt($itemtext->{'cloners'}).'</b><br />'.
1.71 raeburn 2968: &mt('Owner and Coordinators included automatically').
2969: $clonedefaults,
1.1 raeburn 2970: input => 'textbox',
1.41 www 2971: size => '40'
1.1 raeburn 2972: },
2973: 'rolenames' => {
1.3 raeburn 2974: text => '<b>'.&mt($itemtext->{'rolenames'}).'</b><br />'.
1.9 raeburn 2975: '('.$replace.')',
1.1 raeburn 2976: input => 'textbox',
2977: size => '20',
1.19 faziophi 2978: advanced => 1
1.1 raeburn 2979: },
1.88 raeburn 2980: 'syllabus' => {
2981: text => '<b>'.&mt($itemtext->{'syllabus'}).'</b><br />'.
1.60 raeburn 2982: &mt('(Syllabus type in use)').(' ' x2).
1.84 raeburn 2983: $editsyllabus,
1.1 raeburn 2984: },
2985: 'hidefromcat' => {
1.3 raeburn 2986: text => '<b>'.&mt($itemtext->{'hidefromcat'}).'</b><br />'.
1.1 raeburn 2987: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
2988: input => 'radio',
2989: },
2990: 'categories' => {
1.3 raeburn 2991: text => '<b>'.&mt($itemtext->{'categories'}).'</b> <a href="javascript:catsbrowser()">'.
1.1 raeburn 2992: &mt('Display Categories').'</a>',
2993: input => 'textbox',
2994: size => '25',
2995: },
1.35 raeburn 2996: 'loncaparev' => {
2997: text => '<b>'.&mt($itemtext->{'loncaparev'}).'</b>',
2998: },
1.55 raeburn 2999: 'defaultcredits' => {
3000: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
3001: },
1.1 raeburn 3002: );
3003: my $datatable;
3004: my $count = 0;
3005: foreach my $item (@{$ordered}) {
1.56 raeburn 3006: my $colspan;
1.1 raeburn 3007: if ($item eq 'hidefromcat') {
3008: next if (!$can_toggle_cat);
3009: } elsif ($item eq 'categories') {
3010: next if (!$can_categorize);
1.64 raeburn 3011: } elsif ($item eq 'uniquecode') {
3012: next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'});
1.1 raeburn 3013: }
1.56 raeburn 3014: unless (($item eq 'cloners') || ($item eq 'rolenames')) {
3015: $colspan = 2;
3016: }
1.1 raeburn 3017: $count ++;
1.19 faziophi 3018: if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) {
1.56 raeburn 3019: $datatable .= &item_table_row_start($items{$item}{text},$count,"advanced",$colspan);
1.19 faziophi 3020: } else {
1.56 raeburn 3021: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.19 faziophi 3022: }
1.1 raeburn 3023: if ($items{$item}{input} eq 'radio') {
1.80 raeburn 3024: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 3025: } elsif ($item eq 'cloners') {
3026: my $includeempty = 1;
3027: my $num = 0;
1.56 raeburn 3028: $datatable .= '</td><td align="right">'.
3029: &Apache::loncommon::start_data_table().
1.1 raeburn 3030: &Apache::loncommon::start_data_table_row().
3031: '<td><span class="LC_nobreak"><label>'.
3032: &mt('Any user in any domain:').
3033: ' <input type="radio" name="cloners_all" value="1" ';
3034: if ($settings->{$item} eq '*') {
3035: $datatable .= ' checked="checked" ';
3036: }
3037: $datatable .= 'onchange="javascript:update_cloners('.
1.80 raeburn 3038: "'cloners_all'".');"'.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 3039: (' 'x2).'<label>'.
3040: '<input type="radio" name="cloners_all" value="0" ';
1.1 raeburn 3041: if ($settings->{$item} ne '*') {
3042: $datatable .= ' checked="checked" ';
3043: }
3044: $datatable .= ' onchange="javascript:update_cloners('.
1.80 raeburn 3045: "'cloners_all'".');"'.$disabled.' />'.&mt('No').'</label></td>'.
1.1 raeburn 3046: &Apache::loncommon::end_data_table_row().
3047: &Apache::loncommon::end_data_table().
1.56 raeburn 3048: '<table><tr><td align="left"><b>'.&mt('Or').
3049: '</b></td></tr></table>'.
1.1 raeburn 3050: &Apache::loncommon::start_data_table();
3051: my @cloners;
3052: if ($settings->{$item} eq '') {
1.80 raeburn 3053: unless ($noedit) {
3054: my $default;
3055: if ($currcanclone eq 'domain') {
3056: $default = '0';
3057: }
3058: $datatable .= &new_cloners_dom_row($cdom,'0',$default);
1.71 raeburn 3059: }
1.1 raeburn 3060: } elsif ($settings->{$item} ne '*') {
3061: my @entries = split(/,/,$settings->{$item});
3062: if (@entries > 0) {
3063: foreach my $entry (@entries) {
3064: my ($uname,$udom) = split(/:/,$entry);
1.23 raeburn 3065: if ($udom =~ /^$match_domain$/) {
3066: unless (&Apache::lonnet::domain($udom)) {
3067: next;
3068: }
3069: } else {
3070: next;
3071: }
1.1 raeburn 3072: if ($uname eq '*') {
3073: $datatable .=
3074: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3075: '<td valign="top" align="left"><span class="LC_nobreak">'.
1.23 raeburn 3076: &mt('Any user in domain:').'<b> '.$udom.
1.1 raeburn 3077: '</b><input type="hidden" name="cloners_dom_'.$num.
3078: '" value="'.$udom.'" /></span><br />'.
3079: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 3080: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_cloners('."'cloners_delete','$num'".');"'.$disabled.' />'.
1.1 raeburn 3081: &mt('Delete').'</label></span></td>'.
3082: &Apache::loncommon::end_data_table_row();
3083: $num ++;
1.23 raeburn 3084: } elsif (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
3085: unless (grep(/^\Q$entry\E$/,@cloners)) {
3086: push(@cloners,$entry);
3087: }
1.1 raeburn 3088: }
3089: }
3090: }
3091: }
3092: my $add_domtitle = &mt('Any user in additional domain:');
3093: if ($settings->{$item} eq '*') {
3094: $add_domtitle = &mt('Any user in specific domain:');
3095: } elsif ($settings->{$item} eq '') {
3096: $add_domtitle = &mt('Any user in other domain:');
3097: }
3098: my $cloners_str = join(',',@cloners);
3099: $datatable .= &Apache::loncommon::start_data_table_row().
3100: '<td align="left"><span class="LC_nobreak">'.
3101: $add_domtitle.'</span><br />'.
3102: &Apache::loncommon::select_dom_form('','cloners_newdom',
1.80 raeburn 3103: $includeempty,undef,undef,
3104: undef,undef,$noedit).
1.1 raeburn 3105: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
3106: '</td>'.&Apache::loncommon::end_data_table_row().
1.3 raeburn 3107: &Apache::loncommon::end_data_table().
1.56 raeburn 3108: '<table><tr><td align="left"><b>'.&mt('And').
3109: '</b></td></tr></table>'.
1.1 raeburn 3110: &Apache::loncommon::start_data_table().
3111: &Apache::loncommon::start_data_table_row().
3112: '<td align="left">'.
3113: &mt('Specific users').' (<tt>'.
3114: &mt('user:domain,user:domain').'</tt>)<br />'.
3115: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
1.80 raeburn 3116: $items{$item}{'size'},$disabled).
1.1 raeburn 3117: '</td>'.&Apache::loncommon::end_data_table_row().
3118: &Apache::loncommon::end_data_table();
1.71 raeburn 3119: if (@code_order > 0) {
3120: my (%cat_items,@codetitles,%cat_titles,%cat_order);
3121: my ($jscript,$totcodes,$numtitles,$lasttitle) =
3122: &Apache::courseclassifier::instcode_selectors_data($cdom,'display',
3123: \%cat_items,\@codetitles,
3124: \%cat_titles,\%cat_order);
3125: my $showncodes = 'off';
3126: my $checkedoff = ' checked="checked"';
3127: my $checkedon = '';
3128: if ($cloner_instcode) {
3129: $checkedon = $checkedoff;
3130: $checkedoff = '';
3131: $showncodes = 'on';
3132: }
3133: $datatable .= '<table><tr><td align="left"><b>'.&mt('And').
3134: '</b></td></tr></table>'.
3135: &Apache::loncommon::start_data_table().
3136: &Apache::loncommon::start_data_table_row().
3137: '<td align="left"><span class="LC_nobreak">'.
3138: &mt('Cloning by official course(s) based on course category').(' 'x2).
3139: '<label>'.
1.80 raeburn 3140: '<input type="radio" name="cloners_instcode" value="1" onclick="toggleCloners(this);"'.$checkedon.$disabled.' />'.&mt('Yes').'</label>'.
1.71 raeburn 3141: (' ').
3142: '<label>'.
1.80 raeburn 3143: '<input type="radio" name="cloners_instcode" value="0" onclick="toggleCloners(this);"'.$checkedoff.$disabled.' />'.&mt('No').'</label>'.
1.71 raeburn 3144: &Apache::courseclassifier::build_instcode_selectors($numtitles,
3145: $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order,
1.80 raeburn 3146: $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit).
1.71 raeburn 3147: '</td>'.&Apache::loncommon::end_data_table_row().
3148: &Apache::loncommon::end_data_table();
3149: }
1.1 raeburn 3150: } elsif ($item eq 'rolenames') {
1.56 raeburn 3151: $datatable .= '</td><td align="right">'.
3152: &Apache::loncommon::start_data_table();
1.9 raeburn 3153: my @roles;
3154: if ($crstype eq 'Community') {
3155: @roles = ('co');
3156: } else {
3157: @roles = ('cc');
3158: }
3159: push (@roles,('in','ta','ep','ad','st'));
3160: foreach my $role (@roles) {
1.1 raeburn 3161: $datatable .= &Apache::loncommon::start_data_table_row().
3162: '<td align="left"><span class="LC_nobreak">'.
3163: &Apache::lonnet::plaintext($role,$crstype,undef,1).
3164: '</span></td><td align="left">'.
3165: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
3166: $settings->{$role.'.plaintext'},
1.80 raeburn 3167: $items{$item}{size},$disabled).'</td>'.
1.1 raeburn 3168: &Apache::loncommon::end_data_table_row();
3169: }
3170: $datatable .= &Apache::loncommon::end_data_table().'</td>';
3171: } elsif ($item eq 'categories') {
1.80 raeburn 3172: my $launcher;
3173: if ($noedit) {
3174: $launcher = $disabled;
3175: } else {
3176: $launcher = 'onfocus="this.blur();javascript:catsbrowser();"';
3177: }
1.3 raeburn 3178: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.
3179: &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},
3180: $items{$item}{size},$launcher);
1.24 raeburn 3181: } elsif ($item eq 'owner') {
3182: my $owner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
3183: if ($owner =~ /:/) {
3184: my ($ownername,$ownerdom) = split(':',$owner);
3185: $owner = &Apache::loncommon::plainname($ownername,$ownerdom);
3186: } elsif ($owner ne '') {
3187: $owner = &Apache::loncommon::plainname($owner,$cdom);
3188: } else {
3189: $owner = &mt('None specified');
3190: }
3191: $datatable .= $owner;
1.63 raeburn 3192: } elsif ($item eq 'clonedfrom') {
3193: my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'};
3194: my $clonedfrom = &mt('None');
3195: if ($clonesrc =~ m{/$match_domain/$match_courseid}) {
1.65 raeburn 3196: my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc);
1.63 raeburn 3197: if ($clonesrcinfo{'description'}) {
3198: $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc);
3199: }
3200: }
3201: $datatable .= $clonedfrom;
1.64 raeburn 3202: } elsif ($item eq 'uniquecode') {
3203: my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'};
3204: if ($code) {
3205: $datatable .= $code;
3206: }
1.25 raeburn 3207: } elsif ($item eq 'co-owners') {
3208: my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'};
3209: my @currcoown;
3210: if ($coowners) {
3211: @currcoown = split(',',$coowners);
3212: }
3213: if (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
3214: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
3215: $datatable .= &show_autocoowners(@currcoown);
3216: } else {
1.80 raeburn 3217: $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 3218: }
3219: } else {
3220: if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) {
3221: $datatable .= &show_autocoowners(@currcoown);
3222: } else {
1.80 raeburn 3223: $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
1.25 raeburn 3224: }
3225: }
1.88 raeburn 3226: } elsif ($item eq 'syllabus') {
1.60 raeburn 3227: my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'};
3228: my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'};
3229: my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'};
3230: if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
3231: if ($minimal =~/\w/) {
3232: if ($external =~ m{\Q$minimal\E$}) {
3233: undef($external);
3234: }
3235: } elsif ($uploaded =~/\w/) {
3236: if ($external =~ m{\Q$uploaded\E$}) {
3237: undef($external);
3238: }
3239: }
3240: } elsif ($external!~/\w/) {
3241: undef($external);
3242: }
3243: if ($external) {
3244: $datatable .= &mt('External URL');
3245: } elsif ($minimal) {
3246: $datatable .= &mt('Minimal template');
3247: } elsif ($uploaded) {
3248: $datatable .= &mt('Uploaded file');
3249: } else {
3250: $datatable .= &mt('Standard template');
3251: }
3252: $datatable .= (' ' x 2).
3253: &mt('[_1]View[_2]',
3254: '<a href="javascript:syllabusinfo();">',
3255: '</a>');
1.35 raeburn 3256: } elsif ($item eq 'loncaparev') {
3257: my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
3258: my $showreqd;
3259: if ($loncaparev) {
1.36 raeburn 3260: $showreqd = &mt('[_1] or newer',$loncaparev).' <a href="javascript:loncaparevinfo()">'.
1.37 raeburn 3261: &mt('Details').'</a>';
1.35 raeburn 3262: } else {
3263: $showreqd = &mt('No specific version required');
3264: }
3265: $datatable .= $showreqd;
1.1 raeburn 3266: } else {
1.80 raeburn 3267: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled);
1.1 raeburn 3268: }
3269: $datatable .= &item_table_row_end();
3270: }
3271: $$rowtotal += scalar(@{$ordered});
3272: return $datatable;
3273: }
3274:
3275: sub new_cloners_dom_row {
1.71 raeburn 3276: my ($newdom,$num,$default) = @_;
3277: my ($output,$checkedon,$checkedoff);
1.1 raeburn 3278: if ($newdom ne '') {
1.71 raeburn 3279: if ($num eq $default) {
3280: $checkedon = 'checked="checked" ';
3281: } else {
3282: $checkedoff = 'checked="checked" ';
3283: }
1.1 raeburn 3284: $output .= &Apache::loncommon::start_data_table_row().
3285: '<td valign="top"><span class="LC_nobreak">'.
3286: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
3287: (' 'x2).'<label><input type="radio" '.
1.71 raeburn 3288: 'name="cloners_activate" value="'.$num.'" '.$checkedon.
1.3 raeburn 3289: 'onchange="javascript:update_cloners('.
1.1 raeburn 3290: "'cloners_activate','$num'".');" />'.
3291: &mt('Yes').'</label>'.(' 'x2).
3292: '<label><input type="radio" '.
1.71 raeburn 3293: 'name="cloners_activate" value="-1" '.$checkedoff.
1.3 raeburn 3294: 'onchange="javascript:update_cloners('.
1.1 raeburn 3295: "'cloners_activate','$num'".');" />'.
1.3 raeburn 3296: &mt('No').'</label><input type="hidden" name="cloners_dom_'.
3297: $num.'" value="'.$newdom.'" /></span></td>'.
1.1 raeburn 3298: &Apache::loncommon::end_data_table_row();
3299: }
3300: return $output;
3301: }
3302:
3303: sub can_modify_catsettings {
1.12 raeburn 3304: my ($dom,$crstype) = @_;
1.1 raeburn 3305: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
3306: my ($can_toggle_cat,$can_categorize);
3307: if (ref($domconf{'coursecategories'}) eq 'HASH') {
1.12 raeburn 3308: if ($crstype eq 'Community') {
3309: if ($domconf{'coursecategories'}{'togglecatscomm'} eq 'comm') {
3310: $can_toggle_cat = 1;
3311: }
3312: if ($domconf{'coursecategories'}{'categorizecomm'} eq 'comm') {
3313: $can_categorize = 1;
3314: }
3315: } else {
3316: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
3317: $can_toggle_cat = 1;
3318: }
3319: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
3320: $can_categorize = 1;
3321: }
1.1 raeburn 3322: }
3323: }
3324: return ($can_toggle_cat,$can_categorize);
3325: }
3326:
3327: sub assign_course_categories {
1.9 raeburn 3328: my ($r,$crstype) = @_;
1.1 raeburn 3329: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
3330: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
3331: my $hascats = 0;
3332: my $cathash;
3333: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
3334: if (ref($domconf{'coursecategories'}) eq 'HASH') {
3335: $cathash = $domconf{'coursecategories'}{'cats'};
3336: if (ref($cathash) eq 'HASH') {
1.12 raeburn 3337: foreach my $cat (keys(%{$cathash})) {
3338: next if ($cat eq 'instcode::0');
3339: unless ($crstype eq 'Community') {
3340: next if ($cat eq 'communities::0');
3341: }
3342: $hascats ++;
3343: }
1.1 raeburn 3344: }
3345: }
3346: my $catwin_js;
3347: if ($hascats) {
1.9 raeburn 3348: my $alert;
3349: if ($crstype eq 'Community') {
3350: $alert = &mt("Use 'Save' in the main window to save community categories");
3351: } else {
3352: $alert = &mt("Use 'Save' in the main window to save course categories");
3353: }
1.72 damieng 3354: &js_escape(\$alert);
1.1 raeburn 3355: $catwin_js = <<ENDSCRIPT;
3356: <script type="text/javascript">
3357:
3358: function updateCategories() {
3359: var newcategories = '';
3360: var unescapedcats = '';
3361: if (document.chgcats.usecategory.length) {
3362: for (var i=0; i<document.chgcats.usecategory.length; i++) {
3363: if (document.chgcats.usecategory[i].checked == true) {
3364: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
3365: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
3366: }
3367: }
3368: if (newcategories.length > 0) {
3369: newcategories = newcategories.slice(0,-1);
3370: }
3371: if (unescapedcats.length > 0) {
3372: unescapedcats = unescapedcats.slice(0,-3);
3373: }
3374: } else {
3375: if (document.chgcats.usecategory.checked == true) {
3376: newcategories = document.chgcats.usecategory.value;
3377: unescapedcats = document.chgcats.catname.value;
3378: }
3379: }
3380: opener.document.display.categories.value = newcategories;
3381: opener.document.display.categories_display.value = unescapedcats;
3382: alert("$alert");
3383: self.close();
3384: return;
3385: }
3386:
3387: </script>
3388: ENDSCRIPT
3389: } else {
3390: my $onload;
3391: }
1.9 raeburn 3392: my ($crscat,$catcrs,$assign);
3393: if ($crstype eq 'Community') {
3394: $crscat = 'Community Categories';
3395: $catcrs = &mt('Categorize Community');
3396: $assign = &mt('Assign one or more categories to this community.')
3397: } else {
3398: $crscat = 'Course Categories';
3399: $catcrs = &mt('Categorize Course');
3400: $assign = &mt('Assign one or more categories to this course.')
3401: }
1.1 raeburn 3402: my $start_page =
1.9 raeburn 3403: &Apache::loncommon::start_page($crscat,$catwin_js,
1.1 raeburn 3404: {'only_body' => 1,});
3405: my $end_page = &Apache::loncommon::end_page();
1.9 raeburn 3406: my $categoriesform = '<h3>'.$catcrs.'</h3>';
1.1 raeburn 3407: if ($hascats) {
3408: my %currsettings =
3409: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
1.12 raeburn 3410: my $cattable = &Apache::loncommon::assign_categories_table($cathash,
3411: $currsettings{'categories'},$crstype);
3412: if ($cattable eq '') {
3413: $categoriesform .= &mt('No suitable categories defined for this course type in this domain.');
3414: } else {
3415: $categoriesform .= $assign.'<br /><br />'.
3416: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
3417: $cattable."\n".
3418: '<br /><input type="button" name="changes" value="'.
3419: &mt('Copy to main window').'" '.
3420: 'onclick="javascript:updateCategories()" /></form><br />';
3421: }
1.1 raeburn 3422: } else {
1.12 raeburn 3423: $categoriesform .= &mt('No categories defined in this domain.');
1.1 raeburn 3424: }
3425: $r->print($start_page.$categoriesform.$end_page);
3426: return;
3427: }
3428:
1.36 raeburn 3429: sub display_loncaparev_constraints {
3430: my ($r,$navmap,$loncaparev,$crstype) = @_;
1.66 raeburn 3431: my ($reqdmajor,$reqdminor);
1.36 raeburn 3432: my $cid = $env{'request.course.id'};
3433: my $cdom = $env{'course.'.$cid.'.domain'};
3434: my $cnum = $env{'course.'.$cid.'.num'};
3435: my $output;
1.39 raeburn 3436: my %lt = &Apache::lonlocal::texthash (
3437: 'all' => 'all',
3438: 'section/group' => 'section/group',
3439: 'user' => 'user',
3440: );
1.66 raeburn 3441: &Apache::lonrelrequtils::init_global_hashes();
3442: if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) {
3443: ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype});
1.36 raeburn 3444: $output .= '<h4>'.&mt('Course type: [_1] requires [_2] or newer',$crstype,
1.66 raeburn 3445: $Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>';
1.36 raeburn 3446: }
3447: my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps,
1.85 raeburn 3448: %byresponsetype,%bysubmission,%fromblocks,%bycrsrestype);
1.39 raeburn 3449: @scopeorder = ('all','section/group','user');
1.67 raeburn 3450: my $now = time;
1.36 raeburn 3451: my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
3452: if (ref($resourcedata) eq 'HASH') {
3453: foreach my $key (keys(%{$resourcedata})) {
1.70 raeburn 3454: my %found;
1.66 raeburn 3455: foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
1.36 raeburn 3456: if ($key =~ /(\Q$item\E)$/) {
1.70 raeburn 3457: if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
3458: my $value = $resourcedata->{$key};
3459: if ($item eq 'examcode') {
3460: if (&Apache::lonnet::validCODE($value)) {
3461: $value = 'valid';
3462: } else {
3463: $value = '';
3464: }
3465: } elsif ($item eq 'printstartdate') {
1.67 raeburn 3466: if ($value =~ /^\d+$/) {
1.70 raeburn 3467: if ($value > $now) {
3468: $value = 'future';
3469: }
3470: }
3471: } elsif ($item eq 'printenddate') {
3472: if ($value =~ /^\d+$/) {
3473: if ($value < $now) {
3474: $value = 'past';
3475: }
3476: }
3477: }
3478: if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
3479: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
3480: $found{$item}{'valname'} = &get_param_description($stdtype,$value);
1.76 raeburn 3481: $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'};
1.70 raeburn 3482: }
3483: }
3484: }
3485: }
1.79 raeburn 3486: foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) {
3487: if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') {
1.70 raeburn 3488: my $value = $resourcedata->{$key};
1.79 raeburn 3489: foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) {
1.70 raeburn 3490: if ($value =~ /$valuematch/) {
3491: my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
1.74 raeburn 3492: $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
1.70 raeburn 3493: $found{$item}{'rev'} =
1.76 raeburn 3494: $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'};
1.70 raeburn 3495: last;
3496: }
3497: }
3498: }
3499: }
1.76 raeburn 3500: foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) {
3501: my $regexp;
3502: if ($item eq 'maplevelrecurse') {
3503: $regexp = '\.(?:sequence|page)___\(rec\)\.';
3504: }
3505: if ($regexp ne '') {
3506: if ($key =~ /$regexp.*\.(\w+)$/) {
3507: my $name = $1;
3508: my $value = $resourcedata->{$key};
3509: if ($name eq 'type') {
3510: last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') ||
3511: ($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') ||
3512: ($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library'));
3513: }
3514: my $stdtype = &Apache::lonparmset::standard_parameter_types($name);
3515: $found{$name}{'valname'} = &get_param_description($stdtype,$value);
3516: $found{$name}{'extra'} = &mt('Recursive into sub-folders');
3517: $found{$name}{'rev'} =
3518: $Apache::lonnet::needsrelease{'parameter::::'.$item};
3519: }
3520: }
3521: }
1.70 raeburn 3522: foreach my $item (keys(%found)) {
3523: my $stdname = &Apache::lonparmset::standard_parameter_names($item);
3524: my $rev = $found{$item}{'rev'};
3525: my $valname = $found{$item}{'valname'};
1.76 raeburn 3526: my $extra = $found{$item}{'extra'};
1.70 raeburn 3527: my ($middle,$scope,$which,$level,$map,$resource);
3528: my $start = $cid.'.';
3529: if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
3530: $middle = $1;
3531: $which = $2;
3532: $scope = 'user';
3533: } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
3534: $middle = $1;
3535: $which = $2;
3536: $scope = 'section/group';
3537: } else {
3538: $scope = 'all';
3539: }
3540: my $what="$stdname=$valname";
1.76 raeburn 3541: if ($extra) {
3542: $what .= "<br/>$extra<br />";
3543: }
1.70 raeburn 3544: if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
3545: $level = 'general';
3546: if ($scope eq 'all') {
3547: if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
3548: unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
3549: push(@{$fromparam{$rev}{$scope}},$what);
3550: }
3551: } else {
3552: push(@{$fromparam{$rev}{$scope}},$what);
3553: }
3554: } else {
3555: if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
3556: unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
3557: push(@{$fromparam{$rev}{$scope}{$which}},$what);
3558: }
3559: } else {
3560: push(@{$fromparam{$rev}{$scope}{$which}},$what);
3561: }
3562: }
3563: $rowspan{$rev} ++;
1.76 raeburn 3564: } elsif ($key =~ /^\Q$start$middle\E(.+)___\((all|rec)\).\w+\.\Q$item\E$/) {
1.70 raeburn 3565: $level = 'folder';
3566: $map = $1;
3567: if ($scope eq 'all') {
3568: if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
3569: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
3570: push(@{$bymap{$map}{$rev}{$scope}},$what);
3571: }
3572: } else {
3573: push(@{$bymap{$map}{$rev}{$scope}},$what);
3574: }
3575: } else {
3576: if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
3577: unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
3578: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
3579: }
3580: } else {
3581: push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
3582: }
3583: }
3584: } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
3585: $level = 'resource';
3586: $resource = $1;
3587: if ($scope eq 'all') {
3588: if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
3589: unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
3590: push(@{$byresource{$resource}{$rev}{$scope}},$what);
3591: }
3592: } else {
3593: push(@{$byresource{$resource}{$rev}{$scope}},$what);
3594: }
3595: } else {
3596: if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
3597: unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
3598: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
3599: }
3600: } else {
3601: push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
1.36 raeburn 3602: }
3603: }
3604: }
3605: }
3606: }
3607: if (keys(%fromparam)) {
3608: $output .= '<h4>'.&mt('Requirements from general settings').'</h4>'.
3609: &Apache::loncommon::start_data_table().
3610: &Apache::loncommon::start_data_table_header_row().
3611: '<th>'.&mt('Release').'</th><th>'.&mt('Scope').'</th>'.
3612: '<th>'.&mt('Extent').'</th><th>'.&mt('Setting').'</th>'.
3613: &Apache::loncommon::end_data_table_header_row();
3614: foreach my $rev (keys(%fromparam)) {
1.66 raeburn 3615: my ($major,$minor) = split(/\./,$rev);
3616: ($reqdmajor,$reqdminor) =
3617: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
1.36 raeburn 3618: $output .= &Apache::loncommon::start_data_table_row().
3619: '<td rowspan="'.$rowspan{$rev}.'">'.$rev.'</td>';
3620: my $newrow;
3621: foreach my $scope (@scopeorder) {
3622: if (ref($fromparam{$rev}{$scope}) eq 'HASH') {
3623: if ($newrow) {
3624: $output .= &Apache::loncommon::continue_data_table_row();
3625: }
1.39 raeburn 3626: $output .= '<td>'.$lt{$scope}.'</td>';
1.36 raeburn 3627: foreach my $which (sort(keys(%{$fromparam{$rev}{$scope}}))) {
3628: $output .= '<td>'.$which.'</td><td>'.
3629: join('<br />',@{$fromparam{$rev}{$scope}{$which}}).'</td>';
3630: }
3631: $output .= &Apache::loncommon::end_data_table_row();
3632: $newrow = 1;
3633: } elsif (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
3634: if ($newrow) {
3635: $output .= &Apache::loncommon::continue_data_table_row();
3636: }
1.39 raeburn 3637: $output .= '<td>'.$lt{$scope}.'</td><td> </td><td>'.
1.36 raeburn 3638: join('<br />',@{$fromparam{$rev}{$scope}}).'</td>'.
3639: &Apache::loncommon::end_data_table_row();
3640: $newrow = 1;
3641: }
3642: }
3643: }
3644: $output .= &Apache::loncommon::end_data_table().'<br />';
3645: }
3646: }
3647:
1.66 raeburn 3648: my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
3649: my $now = time;
3650: if (keys(%comm_blocks) > 0) {
3651: foreach my $block (keys(%comm_blocks)) {
3652: if ($block =~ /^firstaccess____(.+)$/) {
1.78 raeburn 3653: my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'};
1.66 raeburn 3654: if (ref($comm_blocks{$block}) eq 'HASH') {
3655: push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3656: ' '.&mt('set by [_1]',
3657: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3658: }
3659: next;
3660: } elsif ($block =~ /^(\d+)____(\d+)$/) {
3661: my ($start,$end) = ($1,$2);
3662: next if ($end < $now);
3663: }
3664: if (ref($comm_blocks{$block}) eq 'HASH') {
3665: if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') {
3666: if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') {
3667: if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) {
1.78 raeburn 3668: my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'};
1.66 raeburn 3669: push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3670: ' '.
3671: &mt('set by [_1]',
3672: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3673: }
3674: } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') {
1.78 raeburn 3675: my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'};
1.66 raeburn 3676: push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}).
3677: ' '.
3678: &mt('set by [_1]',
3679: &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'}))));
3680:
3681: }
3682: }
3683: }
3684: }
3685: if (keys(%fromblocks)) {
3686: my %lt = (
3687: docs => 'Content blocking',
3688: printout => 'Printout generation',
3689: timer => 'Timed quiz trigger',
3690: );
3691: $output .= '<h4>'.&mt('Requirements from exam blocking').'</h4>'.
3692: &Apache::loncommon::start_data_table().
3693: &Apache::loncommon::start_data_table_header_row().
3694: '<th>'.&mt('Release').'</th><th>'.&mt('Setting').'</th>'.
3695: '<th>'.&mt('Event(s)').'</th>'.
3696: &Apache::loncommon::end_data_table_header_row();
3697: foreach my $type ('docs','printout','timer') {
3698: if (ref($fromblocks{$type}) eq 'HASH') {
3699: foreach my $rev (keys(%{$fromblocks{$type}})) {
3700: my ($major,$minor) = split(/\./,$rev);
3701: ($reqdmajor,$reqdminor) =
3702: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
3703: $output .= &Apache::loncommon::start_data_table_row().
3704: '<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>';
3705: foreach my $event (sort(@{$fromblocks{$type}{$rev}})) {
3706: $output .= $event.'<br />';
3707: }
3708: $output =~ s{\Q<br />\E$}{};
3709: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3710: }
3711: }
3712: }
3713: $output .= &Apache::loncommon::end_data_table().'<br />';
3714: }
3715: }
3716:
1.36 raeburn 3717: if (defined($navmap)) {
3718: my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum);
1.76 raeburn 3719: my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey::'};
1.36 raeburn 3720: my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum);
1.76 raeburn 3721: my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry::'};
1.85 raeburn 3722: my $rev_exttool=$Apache::lonnet::needsrelease{'course:courserestype:exttool'};
1.36 raeburn 3723: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
3724: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
3725: my $valanon=&get_param_description($stdtype,'anonsurvey');
3726: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.66 raeburn 3727: my %checkedrev;
1.85 raeburn 3728: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0)) {
1.36 raeburn 3729: my @parts = @{$res->parts()};
3730: my $symb = $res->symb();
3731: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
1.85 raeburn 3732: if ($res->is_tool()) {
3733: my $rev = $rev_exttool;
3734: $bycrsrestype{$symb}{$rev} = &mt('External Tool');
3735: $allmaps{$enclosing_map} = 1;
3736: next;
3737: }
1.36 raeburn 3738: foreach my $part (@parts) {
3739: if (exists($anonsubms{$symb."\0".$part})) {
3740: my $rev = $rev_anonsurv;
3741: my $what="$stdname=$valanon";
3742: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
3743: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
3744: push(@{$bysubmission{$symb}{$rev}},$what);
3745: }
3746: } else {
3747: push(@{$bysubmission{$symb}{$rev}},$what);
3748: }
3749: $allmaps{$enclosing_map} = 1;
1.66 raeburn 3750: unless ($checkedrev{'anonsurvey'}) {
3751: my ($major,$minor) = split(/\./,$rev);
3752: ($reqdmajor,$reqdminor) =
3753: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3754: $reqdmajor,$reqdminor);
3755: $checkedrev{'anonsurvey'} = 1;
3756: }
1.36 raeburn 3757: }
3758: if (exists($randtrysubms{$symb."\0".$part})) {
3759: my $rev = $rev_randtry;
3760: my $what="$stdname=$valrandtry";
3761: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
3762: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
3763: push(@{$bysubmission{$symb}{$rev}},$what);
3764: }
3765: } else {
3766: push(@{$bysubmission{$symb}{$rev}},$what);
3767: }
3768: $allmaps{$enclosing_map} = 1;
1.66 raeburn 3769: unless ($checkedrev{'randomizetry'}) {
3770: my ($major,$minor) = split(/\./,$rev);
3771: ($reqdmajor,$reqdminor) =
3772: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3773: $reqdmajor,$reqdminor);
3774: $checkedrev{'randomizetry'} = 1;
3775: }
1.36 raeburn 3776: }
3777: }
3778: my %responses = $res->responseTypes();
3779: foreach my $key (keys(%responses)) {
1.66 raeburn 3780: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
3781: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
3782: unless ($checkedrev{$key}) {
3783: my ($major,$minor) = split(/\./,$rev);
3784: ($reqdmajor,$reqdminor) =
3785: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
3786: $reqdmajor,$reqdminor);
3787: $checkedrev{$key} = 1;
3788: }
3789: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 3790: $allmaps{$enclosing_map} = 1;
3791: }
3792: }
3793: }
3794: if (keys(%byresource) > 0) {
3795: foreach my $symb (keys(%byresource)) {
3796: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
3797: $allmaps{$map} = 1;
3798: }
3799: }
3800: if (keys(%bymap) > 0) {
3801: foreach my $map (keys(%bymap)) {
3802: $allmaps{$map} = 1;
3803: }
3804: }
3805: foreach my $map (keys(%allmaps)) {
3806: my $mapres = $navmap->getResourceByUrl($map);
3807: if (ref($mapres)) {
1.68 raeburn 3808: my $mapsymb = $mapres->symb();
3809: $toshow{$mapsymb} = 1;
1.36 raeburn 3810: my $pcslist = $mapres->map_hierarchy();
3811: if ($pcslist ne '') {
3812: foreach my $pc (split(/,/,$pcslist)) {
3813: my $res = $navmap->getByMapPc($pc);
3814: if (ref($res)) {
3815: my $symb = $res->symb();
3816: unless ($symb eq '______') {
3817: $toshow{$symb} = 1;
3818: }
3819: }
3820: }
3821: }
3822: }
3823: }
3824: }
1.86 raeburn 3825: my $suppmap = 'supplemental.sequence';
3826: my ($suppcount,$supptools,$errors) = (0,0,0);
3827: ($suppcount,$supptools,$errors) = &Apache::loncommon::recurse_supplemental($cnum,$cdom,
3828: $suppmap,$suppcount,$supptools,$errors);
1.36 raeburn 3829: my $mapres_header = '<h4>'.
3830: &mt('Requirements for specific folders or resources').
3831: '</h4>';
3832: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
3833: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
3834: $output .= $mapres_header;
3835: }
3836: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
3837: my $title = 'Version Constraints';
3838: my $start_page =
3839: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
3840: $r->print($start_page.$top_header);
3841: if ($output) {
3842: $r->print($output);
1.86 raeburn 3843: if (defined($navmap) || $supptools) {
1.36 raeburn 3844: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.86 raeburn 3845: \%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt,$supptools);
1.36 raeburn 3846: }
3847: $r->print('<br /><br />');
3848: } else {
3849: $r->print('<p class="LC_info">'.
3850: &mt('No version requirements from resource content or settings.').
3851: '</p>');
3852: }
3853: $r->print(&Apache::loncommon::end_page());
1.66 raeburn 3854: my ($currmajor,$currminor) = split(/\./,$loncaparev);
3855: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
3856: return 1;
3857: }
1.36 raeburn 3858: return;
3859: }
3860:
3861: sub show_contents_view {
1.39 raeburn 3862: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
1.86 raeburn 3863: $bycrsrestype,$scopeorder,$lt,$supptools) = @_;
3864: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
3865: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
3866: my $showmaincontent;
3867: if ((ref($navmap)) &&
3868: ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
3869: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0) ||
3870: (keys(%{$bycrsrestype}) > 0))) {
3871: $showmaincontent = 1;
3872: }
3873: if ($showmaincontent || $supptools) {
3874: $r->print(&Apache::loncommon::start_data_table());
3875: }
3876: if ($showmaincontent) {
3877: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
1.36 raeburn 3878: my $topmap = $env{'course.'.$cid.'.url'};
1.86 raeburn 3879: $r->print(&Apache::loncommon::start_data_table_header_row().
1.36 raeburn 3880: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
3881: '<th>'.&mt('Attribute/Setting').'</th>'.
3882: &Apache::loncommon::end_data_table_header_row().
3883: &Apache::loncommon::start_data_table_row().
1.58 raeburn 3884: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.86 raeburn 3885: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
3886: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 3887: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
3888: my $curRes;
3889: my $depth = 0;
3890: my %parent = ();
3891: my $startcount = 5;
3892: my $lastcontainer = $startcount;
3893: while ($curRes = $it->next()) {
3894: if ($curRes == $it->BEGIN_MAP()) {
3895: $depth++;
3896: $parent{$depth}= $lastcontainer;
3897: }
3898: if ($curRes == $it->END_MAP()) {
3899: $depth--;
3900: $lastcontainer = $parent{$depth};
3901: }
3902: my $indent;
3903: for (my $i=0; $i<$depth; $i++) {
3904: $indent.= $whitespace;
3905: }
3906: if (ref($curRes)) {
3907: my $symb = $curRes->symb();
3908: my $ressymb = $symb;
3909: my $srcf = $curRes->src();
3910: my $title = &Apache::lonnet::gettitle($srcf);
3911: if (($curRes->is_sequence()) || ($curRes->is_page())) {
3912: next unless($toshow->{$symb});
3913: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
3914: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3915: if ($curRes->is_page()) {
3916: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
3917: }
3918: my $rowspan = 1;
3919: if (ref($bymap->{$url}) eq 'HASH') {
3920: $rowspan = scalar(keys(%{$bymap->{$url}}));
3921: }
3922: $r->print(&Apache::loncommon::start_data_table_row().
3923: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 3924: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 3925: $r->print(&Apache::loncommon::end_data_table_row());
3926: } else {
3927: my $rowspan;
3928: if (ref($byresource->{$symb}) eq 'HASH') {
3929: $rowspan += scalar(keys(%{$byresource->{$symb}}));
3930: }
3931: if (ref($bysubmission->{$symb}) eq 'HASH') {
3932: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
3933: }
3934: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3935: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
3936: }
1.85 raeburn 3937: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
3938: $rowspan += scalar(keys(%{$bycrsrestype->{$symb}}));
3939: }
1.36 raeburn 3940: next if (!$rowspan);
3941: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
3942: &mt('Problem').'" />';
3943: $r->print(&Apache::loncommon::start_data_table_row().
3944: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
3945: my $newrow;
3946: if (ref($byresource->{$symb}) eq 'HASH') {
3947: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
3948: if ($newrow) {
3949: $r->print(&Apache::loncommon::continue_data_table_row());
3950: }
3951: $r->print('<td valign="middle">'.$rev.'</td><td>');
3952: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
3953: $r->print('<table border="0">');
3954: foreach my $scope (@{$scopeorder}) {
3955: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3956: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3957: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
3958: $r->print('<td>'.$which.'</td><td>'.
3959: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
3960: '</td>');
3961: }
3962: $r->print('</tr>');
3963: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3964: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 3965: '<td> </td><td>'.
3966: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
3967: }
3968: }
3969: $r->print('</table>');
3970: }
3971: $r->print('</td>');
3972: $r->print(&Apache::loncommon::end_data_table_row());
3973: $newrow = 1;
3974: }
3975: }
3976: if (ref($bysubmission->{$symb}) eq 'HASH') {
3977: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
3978: if ($newrow) {
3979: $r->print(&Apache::loncommon::continue_data_table_row());
3980: }
3981: $r->print('<td>'.$rev.'</td><td>');
3982: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
3983: $r->print(&mt('Submissions to: ').' '.
3984: join(', ',@{$bysubmission->{$symb}{$rev}}));
3985: }
3986: $r->print('</td>');
3987: $r->print(&Apache::loncommon::end_data_table_row());
3988: $newrow = 1;
3989: }
3990: }
3991: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3992: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
3993: if ($newrow) {
3994: $r->print(&Apache::loncommon::continue_data_table_row());
3995: }
3996: $r->print('<td>'.$rev.'</td><td>');
3997: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
3998: $r->print(&mt('Response Type(s): ').' '.
3999: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
4000: }
4001: $r->print('</td>');
4002: }
4003: $r->print(&Apache::loncommon::end_data_table_row());
1.85 raeburn 4004: $newrow = 1;
4005: }
4006: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
4007: foreach my $rev (sort(keys(%{$bycrsrestype->{$symb}}))) {
4008: if ($newrow) {
4009: $r->print(&Apache::loncommon::continue_data_table_row());
4010: }
4011: $r->print('<td>'.$rev.'</td><td>'.$bycrsrestype->{$symb}{$rev}.'</td>');
4012: }
1.86 raeburn 4013: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 4014: }
4015: }
4016: }
4017: }
1.86 raeburn 4018: }
4019: if ($supptools) {
4020: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
4021: $r->print(&Apache::loncommon::start_data_table_header_row().
4022: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
4023: '<th>'.&mt('Resource Type').'</th>'.
4024: &Apache::loncommon::end_data_table_header_row().
4025: &Apache::loncommon::start_data_table_row().
4026: '<td> '.$icon.' '.&mt('Supplemental Content').'</td>'.
4027: '<td valign="middle">'.
4028: $Apache::lonrelrequtils::exttool{'major'}.'.'.
4029: $Apache::lonrelrequtils::exttool{'minor'}.
4030: '</td><td>'.&mt('[quant,_1,External Tool,External Tools]',
4031: $supptools).'</td>'.
4032: &Apache::loncommon::end_data_table_row());
4033: }
4034: if ($showmaincontent || $supptools) {
1.36 raeburn 4035: $r->print(&Apache::loncommon::end_data_table());
4036: }
1.66 raeburn 4037: return;
1.36 raeburn 4038: }
4039:
4040: sub releases_by_map {
1.39 raeburn 4041: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 4042: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.73 raeburn 4043: my $newrow = 0;
1.36 raeburn 4044: if (ref($bymap->{$url}) eq 'HASH') {
4045: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.73 raeburn 4046: if ($newrow) {
4047: $r->print(&Apache::loncommon::end_data_table_row().
4048: &Apache::loncommon::continue_data_table_row());
4049: }
1.36 raeburn 4050: $r->print('<td valign="middle">'.$rev.'</td><td>');
4051: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
4052: $r->print('<table border="0">');
4053: foreach my $scope (@{$scopeorder}) {
4054: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 4055: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 4056: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
4057: $r->print('<td>'.$which.'</td><td>'.
4058: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
4059: '</td>');
4060: }
4061: $r->print('</tr>');
4062: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 4063: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 4064: '</td><td> </td><td>'.
4065: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
4066: }
4067: }
4068: $r->print('</table>');
4069: }
4070: $r->print('</td>');
1.73 raeburn 4071: $newrow = 1;
1.36 raeburn 4072: }
4073: } else {
4074: $r->print('<td colspan="2"> </td>');
4075: }
4076: return;
4077: }
4078:
4079: sub get_param_description {
1.70 raeburn 4080: my ($stdtype,$value,$regexp) = @_;
4081: my ($name,$parammatches,$paramstrings,@possibles);
1.74 raeburn 4082: if ($stdtype =~ /^string/) {
4083: $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
4084: } elsif ($stdtype eq 'date_interval') {
4085: $paramstrings = &Apache::lonparmset::standard_interval_options($stdtype);
4086: }
1.70 raeburn 4087: if ($regexp) {
1.74 raeburn 4088: if ($stdtype =~ /^string/) {
4089: $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
4090: } elsif ($stdtype eq 'date_interval') {
4091: $parammatches = &Apache::lonparmset::standard_interval_matches($stdtype);
4092: }
1.70 raeburn 4093: if (ref($parammatches) eq 'ARRAY') {
4094: @possibles = @{$parammatches};
4095: } else {
4096: undef($regexp);
4097: $name = $value;
4098: }
4099: }
4100: unless ($regexp) {
4101: $name = $value;
4102: if (ref($paramstrings) eq 'ARRAY') {
4103: @possibles = @{$paramstrings};
4104: } else {
1.76 raeburn 4105: if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) {
4106: if ($name == 0) {
4107: $name = &mt('Never');
4108: } elsif (($name ne '') && ($name !~ /\D/)) {
4109: $name = &Apache::lonlocal::locallocaltime($name);
4110: }
4111: }
1.70 raeburn 4112: return $name;
4113: }
1.36 raeburn 4114: }
1.70 raeburn 4115: foreach my $possibilities (@possibles) {
1.36 raeburn 4116: next unless (ref($possibilities) eq 'ARRAY');
1.70 raeburn 4117: my $gotregexmatch = '';
4118: if ($regexp) {
4119: last if ($gotregexmatch);
4120: my ($item,$pattern) = @{ $possibilities };
4121: if ($value =~ /$pattern/) {
4122: if (ref($paramstrings) eq 'ARRAY') {
4123: foreach my $possibles (@{$paramstrings}) {
4124: next unless (ref($possibles) eq 'ARRAY');
4125: my ($thing,$description) = @{$possibles};
4126: if ($thing eq $item) {
4127: $name = $description;
4128: $gotregexmatch = 1;
4129: last;
4130: }
4131: }
4132: last if ($gotregexmatch);
4133: }
4134: }
4135: } else {
4136: my ($thing,$description) = @{ $possibilities };
4137: if ($thing eq $value) {
4138: $name = $description;
4139: last;
4140: }
1.36 raeburn 4141: }
4142: }
4143: return $name;
4144: }
4145:
1.66 raeburn 4146: sub update_releasereq {
4147: my $readmap = 1;
4148: my $getrelreq = 1;
4149: if (ref($modified_courses) eq 'ARRAY') {
4150: foreach my $item (@{$modified_courses}) {
4151: if (ref($item) eq 'ARRAY') {
4152: my ($cdom,$cnum,$chome,$crstype) = @{$item};
4153: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
4154: $chome,$crstype,$cdom.'_'.$cnum,
4155: $readmap,$getrelreq);
4156: }
4157: }
4158: $modified_courses = [];
4159: }
4160: undef($registered_cleanup);
4161: return;
4162: }
4163:
1.25 raeburn 4164: sub show_autocoowners {
4165: my (@currcoown) = @_;
1.56 raeburn 4166: 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 4167: if (@currcoown > 0) {
4168: $output .= '<br />'.&mt('Current co-owners are:').' '.
4169: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
4170: } else {
4171: $output .= '<br />'.&mt('Currently no co-owners.');
4172: }
4173: return $output;
4174: }
4175:
4176: sub coowner_invitations {
1.80 raeburn 4177: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
4178: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 4179: my $pendingcoowners =
4180: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
4181: if ($pendingcoowners) {
4182: @pendingcoown = split(',',$pendingcoowners);
4183: }
1.80 raeburn 4184: if (ref($currcoownref) eq 'ARRAY') {
1.97 raeburn 4185: @currcoown = @{$currcoownref};
1.80 raeburn 4186: }
4187: my $disabled;
4188: if ($noedit) {
4189: $disabled = ' disabled="disabled"';
4190: }
1.25 raeburn 4191: my $ccrole = 'cc';
4192: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
4193: foreach my $key (sort(keys(%ccroles))) {
4194: my ($ccname,$ccdom,$role) = split(':',$key);
4195: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
4196: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
4197: push(@othercoords,$ccname.':'.$ccdom);
4198: }
4199: }
4200: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
4201: if ($coowner_rows) {
4202: $output .= &Apache::loncommon::start_data_table();
4203: if (@currcoown) {
4204: $output .= &Apache::loncommon::start_data_table_row().
4205: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
4206: foreach my $person (@currcoown) {
4207: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 4208: $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 4209: }
4210: $output .= '</td>'.
4211: &Apache::loncommon::end_data_table_row();
4212: }
4213: if ($pendingcoowners) {
4214: $output .= &Apache::loncommon::start_data_table_row().
4215: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
4216: foreach my $person (@pendingcoown) {
4217: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 4218: $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 4219: }
4220: $output .= '</td>'.
4221: &Apache::loncommon::end_data_table_row();
4222: }
4223: if (@othercoords) {
4224: $output .= &Apache::loncommon::start_data_table_row().
4225: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
4226: foreach my $person (@othercoords) {
4227: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 4228: $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 4229: }
4230: $output .= '</td>'.
4231: &Apache::loncommon::end_data_table_row();
4232: }
4233: $output .= &Apache::loncommon::end_data_table();
4234: } else {
4235: $output = &mt('There are no coordinators to select as co-owners');
4236: }
4237: return $output;
4238: }
4239:
4240: sub manage_coownership {
1.80 raeburn 4241: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
4242: my (@pendingcoown,@currcoown);
1.25 raeburn 4243: my $pendingcoowners =
4244: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
4245: if ($pendingcoowners) {
4246: @pendingcoown = split(',',$pendingcoowners);
4247: }
1.80 raeburn 4248: if (ref($currcoownref) eq 'ARRAY') {
1.97 raeburn 4249: @currcoown = @{$currcoownref};
1.80 raeburn 4250: }
4251: my $disabled;
4252: if ($noedit) {
4253: $disabled = ' disabled="disabled"';
4254: }
1.25 raeburn 4255: my ($is_coowner,$is_pending,$output);
4256: my $uname = $env{'user.name'};
4257: my $udom = $env{'user.domain'};
4258: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
4259: $is_coowner = 1;
4260: }
4261: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
4262: $is_pending = 1;
4263: }
4264: if (@currcoown && ($is_coowner || $is_pending)) {
4265: $output = &Apache::loncommon::start_data_table();
4266: }
4267: if (@currcoown) {
4268: if ($is_coowner || $is_pending) {
4269: $output .= &Apache::loncommon::start_data_table().
4270: &Apache::loncommon::start_data_table_row().'<td>';
4271: }
4272: $output .= &mt('Current co-owners are:').' '.
4273: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
4274: if ($is_coowner || $is_pending) {
4275: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4276: }
4277: }
4278: if ($is_coowner || $is_pending) {
4279: if (@currcoown) {
4280: $output .= &Apache::loncommon::start_data_table_row().'<td>';
4281: }
4282: $output .= '<span class="LC_nobreak">';
4283: if ($is_coowner) {
1.90 raeburn 4284: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
1.25 raeburn 4285: } else {
1.90 raeburn 4286: $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).
4287: '<label><input type="radio" name=pending_coowner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 4288: }
4289: $output .= '</span>';
4290: if (@currcoown) {
4291: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
4292: }
4293: }
4294: if (@currcoown && ($is_coowner || $is_pending)) {
4295: $output .= &Apache::loncommon::end_data_table();
4296: }
4297: return $output;
4298: }
4299:
1.1 raeburn 4300: sub print_localization {
1.80 raeburn 4301: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 4302: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4303: return;
4304: }
4305: my %items = (
4306: languages => {
1.17 faziophi 4307: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
4308: &mt("(overrides individual user preference)"),
1.1 raeburn 4309: input => 'selectbox',
4310: },
4311: timezone => {
1.17 faziophi 4312: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 4313: input => 'selectbox',
4314: },
4315: datelocale => {
1.17 faziophi 4316: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 4317: input => 'selectbox',
4318: },
4319: );
1.80 raeburn 4320: my ($datatable,$disabled);
1.1 raeburn 4321: my $count = 0;
1.80 raeburn 4322: if ($noedit) {
4323: $disabled = ' disabled="disabled"';
4324: }
1.1 raeburn 4325: foreach my $item (@{$ordered}) {
4326: $count ++;
1.56 raeburn 4327: my $colspan;
4328: unless ($item eq 'languages') {
1.80 raeburn 4329: $colspan = 2;
1.56 raeburn 4330: }
4331: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 4332: if ($item eq 'timezone') {
4333: my $includeempty = 1;
4334: my $timezone = &Apache::lonlocal::gettimezone();
4335: $datatable .=
4336: &Apache::loncommon::select_timezone($item,$timezone,undef,
1.80 raeburn 4337: $includeempty,$disabled);
1.1 raeburn 4338: } elsif ($item eq 'datelocale') {
4339: my $includeempty = 1;
4340: my $locale_obj = &Apache::lonlocal::getdatelocale();
4341: my $currdatelocale;
4342: if (ref($locale_obj)) {
4343: $currdatelocale = $locale_obj->id();
4344: }
4345: $datatable .=
4346: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.80 raeburn 4347: undef,$includeempty,$disabled);
1.1 raeburn 4348: } else {
4349: if ($settings->{$item} eq '') {
1.80 raeburn 4350: unless ($noedit) {
4351: $datatable .= '</td><td align="right">'.
4352: &Apache::loncommon::select_language('languages_0','',1);
4353: }
1.1 raeburn 4354: } else {
4355: my $num = 0;
1.3 raeburn 4356: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.56 raeburn 4357: $datatable .= '</td><td align="right"><br />'.
4358: &Apache::loncommon::start_data_table();
1.1 raeburn 4359: if (@languages > 0) {
1.3 raeburn 4360: my %langchoices = &get_lang_choices();
1.1 raeburn 4361: foreach my $lang (@languages) {
4362: my $showlang = $lang;
1.3 raeburn 4363: if (exists($langchoices{$lang})) {
4364: $showlang = $langchoices{$lang};
1.1 raeburn 4365: }
4366: $datatable .=
4367: &Apache::loncommon::start_data_table_row().
1.3 raeburn 4368: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 4369: &mt('Language:').'<b> '.$showlang.
4370: '</b><input type="hidden" name="languages_'.$num.
4371: '" value="'.$lang.'" /></span><br />'.
4372: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 4373: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 4374: &mt('Delete').'</label></span></td>'.
1.3 raeburn 4375: &Apache::loncommon::end_data_table_row();
1.1 raeburn 4376: $num ++;
4377: }
4378: }
1.80 raeburn 4379: unless ($noedit) {
4380: $datatable .=
4381: &Apache::loncommon::start_data_table_row().
1.3 raeburn 4382: '<td align="left"><span class="LC_nobreak">'.
4383: &mt('Additional language:'). '</span><br />'.
4384: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 4385: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.80 raeburn 4386: '</td>'.&Apache::loncommon::end_data_table_row();
4387: }
4388: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 4389: }
4390: }
4391: $datatable .= &item_table_row_end();
4392: }
4393: $$rowtotal += scalar(@{$ordered});
4394: return $datatable;
4395: }
4396:
1.3 raeburn 4397: sub get_lang_choices {
4398: my %langchoices;
4399: foreach my $id (&Apache::loncommon::languageids()) {
4400: my $code = &Apache::loncommon::supportedlanguagecode($id);
4401: if ($code) {
4402: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
4403: }
4404: }
4405: return %langchoices;
4406: }
4407:
1.1 raeburn 4408: sub print_feedback {
1.80 raeburn 4409: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 4410: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4411: return;
4412: }
4413: my %items = (
1.3 raeburn 4414: 'question.email' => {
4415: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 4416: input => 'textbox',
4417: size => '50',
4418: },
4419:
1.3 raeburn 4420: 'comment.email' => {
4421: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 4422: input => 'textbox',
4423: size => '50',
4424: },
4425:
1.3 raeburn 4426: 'policy.email' => {
4427: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 4428: input => 'textbox',
4429: size => '50',
4430: },
4431: );
4432: my $datatable;
4433: my $count = 0;
4434: my ($cnum) = &get_course();
4435: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4436: my @sections = sort( { $a <=> $b } keys(%sections));
4437: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 4438: currone => 'Current recipient:',
4439: currmult => 'Current recipients:',
4440: add => 'Additional recipient:',
4441: del => 'Delete?',
4442: sec => 'Sections:',
1.1 raeburn 4443: );
1.80 raeburn 4444: my $disabled;
4445: if ($noedit) {
4446: $disabled = ' disabled="disabled"';
4447: }
1.1 raeburn 4448: foreach my $item (@{$ordered}) {
4449: $count ++;
1.20 faziophi 4450: if ($position eq 'top') {
4451: $datatable .= &item_table_row_start($items{$item}{text},$count);
4452: } else {
1.56 raeburn 4453: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 4454: }
1.1 raeburn 4455: if ($position eq 'top') {
4456: my $includeempty = 0;
1.94 raeburn 4457: $datatable .= '</td><td align="right">'.
4458: &user_table($cdom,$item,\@sections,
1.80 raeburn 4459: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4460: } else {
1.3 raeburn 4461: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.80 raeburn 4462: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 4463: }
4464: $datatable .= &item_table_row_end();
4465: }
4466: $$rowtotal += scalar(@{$ordered});
4467: return $datatable;
4468: }
4469:
4470: sub user_table {
1.80 raeburn 4471: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 4472: my $output;
4473: if ($currvalue eq '') {
1.80 raeburn 4474: unless ($noedit) {
4475: $output .= &select_recipient($item,'0',$cdom,$sections);
4476: }
1.1 raeburn 4477: } else {
4478: my $num = 0;
4479: my @curr = split(/,/,$currvalue);
1.56 raeburn 4480: $output .= '<table class="LC_data_table">';
1.1 raeburn 4481: my ($currusers);
1.80 raeburn 4482: my $disabled;
4483: if ($noedit) {
4484: $disabled = ' disabled="disabled"';
4485: }
1.1 raeburn 4486: foreach my $val (@curr) {
4487: next if ($val eq '');
4488: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
4489: my @selsec;
4490: if ($seclist) {
4491: $seclist =~ s/(^\(|\)$)//g;
4492: @selsec = split(/\s*;\s*/,$seclist);
4493: }
4494: $currusers .= '<tr>'.
4495: '<td valign="top"><span class="LC_nobreak">'.
4496: '<label><input type="checkbox" '.
1.80 raeburn 4497: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 4498: $lt->{'del'}.'</label>'.
4499: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 4500: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 4501: &Apache::loncommon::aboutmewrapper(
4502: &Apache::loncommon::plainname($uname,$udom,'firstname'),
4503: $uname,$udom,'aboutuser');
4504: if (ref($sections) eq 'ARRAY') {
4505: if (@{$sections}) {
4506: $currusers.= (' 'x3).$lt->{'sec'}.' '.
4507: &select_sections($item,$num,$sections,
1.80 raeburn 4508: \@selsec,$noedit);
1.1 raeburn 4509: }
4510: }
4511: $currusers .= '</span></td></tr>';
4512: $num ++;
4513: }
4514: if ($num) {
1.10 raeburn 4515: $output .= '<tr>'.
1.1 raeburn 4516: '<td align="left"><i>';
1.20 faziophi 4517: if ($num == 1) {
1.1 raeburn 4518: $output .= $lt->{'currone'};
4519: } else {
1.21 raeburn 4520: $output .= $lt->{'currmult'};
1.1 raeburn 4521: }
4522: $output .= '</i><br />'.
4523: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 4524: '</tr>';
1.1 raeburn 4525: }
1.80 raeburn 4526: unless ($noedit) {
4527: $output .=
4528: '<tr>'.
1.1 raeburn 4529: '<td align="left"><span class="LC_nobreak"><i>'.
4530: $lt->{'add'}.'</i></span><br />'.
4531: &select_recipient($item,$num,$cdom,$sections).
4532: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.80 raeburn 4533: '</td></tr>';
4534: }
4535: $output .= '</table>';
1.1 raeburn 4536: }
4537: return $output;
4538: }
4539:
4540: sub select_recipient {
4541: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
4542: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
4543: my $selectlink =
4544: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
1.89 raeburn 4545: $item.'_udom_'.$num,'only');
1.1 raeburn 4546: my $output =
1.10 raeburn 4547: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 4548: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
4549: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
4550: if (ref($sections) eq 'ARRAY') {
4551: if (@{$sections}) {
4552: $output .= '<td align="center">'.&mt('Sections').'<br />'.
4553: &select_sections($item,$num,$sections,$selected).'</td>';
4554: }
4555: }
4556: $output .= '<td valign="top">'.
4557: $selectlink.'</td></tr></table>';
4558: return $output;
4559: }
4560:
4561: sub select_sections {
1.80 raeburn 4562: my ($item,$num,$sections,$selected,$noedit) = @_;
4563: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 4564: if (ref($selected) eq 'ARRAY') {
4565: @currsecs = @{$selected};
4566: }
4567: if (!@currsecs) {
4568: $allsec = ' selected="selected"';
4569: }
1.80 raeburn 4570: if ($noedit) {
4571: $disabled = ' disabled="disabled"';
4572: }
1.1 raeburn 4573: if (ref($sections) eq 'ARRAY') {
4574: if (@{$sections}) {
4575: my $mult;
4576: if (@{$sections} > 1) {
4577: $mult = ' multiple="multiple"';
4578: if (@{$sections} > 3) {
4579: $mult .= ' size="4"';
4580: }
4581: }
1.80 raeburn 4582: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.$disabled.'>'.
1.1 raeburn 4583: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
4584: foreach my $sec (@{$sections}) {
4585: my $is_sel;
4586: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
4587: $is_sel = 'selected="selected"';
4588: }
4589: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
4590: }
4591: $output .= '</select>';
4592: }
4593: }
4594: return $output;
4595: }
4596:
4597: sub print_discussion {
1.80 raeburn 4598: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 4599: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4600: return;
4601: }
4602: my %items = (
4603: 'plc.roles.denied' => {
1.10 raeburn 4604: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
4605: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 4606: &mt('(role-based)'),
1.1 raeburn 4607: input => 'checkbox',
4608: },
4609:
4610: 'plc.users.denied' => {
1.3 raeburn 4611: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
4612: &mt('(specific user(s))'),
1.1 raeburn 4613: input => 'checkbox',
4614: },
4615:
4616: 'pch.roles.denied' => {
1.10 raeburn 4617: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
4618: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 4619: &mt('(role-based)'),
1.1 raeburn 4620: input => 'checkbox',
4621: },
4622:
4623: 'pch.users.denied' => {
1.3 raeburn 4624: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
4625: &mt('(specific user(s))'),
1.1 raeburn 4626: input => 'checkbox',
4627: },
1.77 raeburn 4628:
4629: 'pac.roles.denied' => {
4630: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.roles.denied'}).'</b>'.
4631: &Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'</span><br />'.
4632: &mt('(role-based)'),
4633: input => 'checkbox',
4634: },
4635:
4636: 'pac.users.denied' => {
4637: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.users.denied'}).'</b><br />'.
4638: &mt('(specific user(s))'),
4639: input => 'checkbox',
4640: },
4641:
1.1 raeburn 4642: 'allow_limited_html_in_feedback' => {
1.3 raeburn 4643: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 4644: input => 'radio',
4645: },
4646:
4647: 'allow_discussion_post_editing' => {
1.3 raeburn 4648: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 4649: input => 'checkbox',
4650: },
1.50 raeburn 4651: 'discussion_post_fonts' => {
4652: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
4653: input => 'textbox',
4654: size => '20',
4655: },
1.1 raeburn 4656: );
4657: my $datatable;
4658: my $count;
4659: my ($cnum) = &get_course();
4660: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4661: my @sections = sort( { $a <=> $b } keys(%sections));
4662: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 4663: currone => 'Disallowed:',
4664: currmult => 'Disallowed:',
4665: add => 'Disallow more:',
4666: del => 'Delete?',
4667: sec => 'Sections:',
1.1 raeburn 4668: );
4669: foreach my $item (@{$ordered}) {
4670: $count ++;
1.56 raeburn 4671: my $colspan;
4672: if ($item eq 'allow_limited_html_in_feedback') {
4673: $colspan = 2;
4674: }
4675: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 4676: if ($item eq 'plc.roles.denied') {
1.56 raeburn 4677: $datatable .= '</td><td align="right">'.
1.80 raeburn 4678: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 4679: '</table>';
4680: } elsif ($item eq 'plc.users.denied') {
1.94 raeburn 4681: $datatable .= '</td><td align="right">'.
4682: &user_table($cdom,$item,undef,
1.80 raeburn 4683: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4684: } elsif ($item eq 'pch.roles.denied') {
1.56 raeburn 4685: $datatable .= '</td><td align="right">'.
1.80 raeburn 4686: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 4687: '</table>';
4688: } elsif ($item eq 'pch.users.denied') {
1.56 raeburn 4689: $datatable .= '</td><td align="right">'.
4690: &user_table($cdom,$item,undef,
1.80 raeburn 4691: $settings->{$item},\%lt,$noedit);
1.77 raeburn 4692: } elsif ($item eq 'pac.roles.denied') {
4693: $datatable .= '</td><td align="right">'.
1.80 raeburn 4694: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.77 raeburn 4695: '</table>';
4696: } elsif ($item eq 'pac.users.denied') {
4697: $datatable .= '</td><td align="right">'.
4698: &user_table($cdom,$item,undef,
1.80 raeburn 4699: $settings->{$item},\%lt,$noedit);
1.1 raeburn 4700: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.80 raeburn 4701: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 4702: } elsif ($item eq 'allow_discussion_post_editing') {
1.56 raeburn 4703: $datatable .= '</td><td align="right"><br />'.
4704: &Apache::loncommon::start_data_table().
1.1 raeburn 4705: &Apache::loncommon::start_data_table_row().
4706: '<th align="left">'.&mt('Role').'</th><th>'.
4707: &mt('Sections').'</th>'.
4708: &Apache::loncommon::end_data_table_row().
1.80 raeburn 4709: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.56 raeburn 4710: &Apache::loncommon::end_data_table().'<br />';
1.50 raeburn 4711: } elsif ($item eq 'discussion_post_fonts') {
1.56 raeburn 4712: $datatable .= '</td><td align="right"><br />'.
4713: &Apache::loncommon::start_data_table().
1.50 raeburn 4714: &Apache::loncommon::start_data_table_row().
4715: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
4716: '<th align="center">'.&mt('font-size').'</th>'.
4717: '<th align="center">'.&mt('font-weight').'</th>'.
4718: '<th align="center">'.&mt('font-style').'</th>'.
4719: '<th align="center">'.&mt('Other css').'</th>'.
4720: &Apache::loncommon::end_data_table_row().
1.80 raeburn 4721: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.56 raeburn 4722: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 4723: }
4724: $datatable .= &item_table_row_end();
4725: }
4726: $$rowtotal += scalar(@{$ordered});
4727: return $datatable;
4728: }
4729:
4730: sub role_checkboxes {
1.80 raeburn 4731: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 4732: my @roles = ('st','ad','ta','ep','in');
4733: if ($crstype eq 'Community') {
4734: push(@roles,'co');
4735: } else {
4736: push(@roles,'cc');
4737: }
1.1 raeburn 4738: my $output;
4739: my (@current,@curr_roles,%currsec,@sections);
4740: if ($showsections) {
4741: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
4742: @sections = sort( { $a <=> $b } keys(%sections));
4743: }
4744: if (ref($settings) eq 'HASH') {
4745: if ($settings->{$item}) {
4746: @current = split(',',$settings->{$item});
4747: if ($showsections) {
4748: foreach my $role (@current) {
4749: if ($role =~ /:/) {
4750: my ($trole,$sec) = split(':',$role);
4751: push(@curr_roles,$trole);
4752: if (ref($currsec{$trole}) eq 'ARRAY') {
4753: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
4754: push(@{$currsec{$trole}},$sec);
4755: }
1.3 raeburn 4756: } else {
4757: $currsec{$trole} = [$sec];
1.1 raeburn 4758: }
4759: } else {
4760: push(@curr_roles,$role);
4761: }
4762: }
4763: @current = @curr_roles;
4764: }
4765: }
4766: }
4767: my $numinrow = 3;
4768: my $count = 0;
1.80 raeburn 4769: my $disabled;
4770: if ($noedit) {
4771: $disabled = ' disabled="disabled"';
4772: }
1.1 raeburn 4773: foreach my $role (@roles) {
4774: my $checked = '';
4775: if (grep(/^\Q$role\E$/,@current)) {
4776: $checked = ' checked="checked" ';
4777: }
1.9 raeburn 4778: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 4779: if ($showsections) {
4780: $output .= &Apache::loncommon::start_data_table_row();
4781: } else {
4782: my $rem = $count%($numinrow);
4783: if ($rem == 0) {
4784: if ($count > 0) {
4785: $output .= '</tr>';
4786: }
4787: $output .= '<tr>';
4788: }
4789: }
1.30 raeburn 4790: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 4791: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 4792: $plrole.'</label></span></td>';
4793: if ($showsections) {
4794: $output .= '<td align="left">'.
1.80 raeburn 4795: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 4796: '</td></tr>';
4797: }
4798: $count ++;
4799: }
4800: my %adv_roles =
4801: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
4802: my $total = @roles;
4803: foreach my $role (sort(keys(%adv_roles))) {
4804: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
4805: my $rolename = $3;
4806: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
4807: my $checked = '';
4808: if (grep(/^\Q$value\E$/,@current)) {
4809: $checked = ' checked="checked" ';
4810: }
4811: if ($showsections) {
4812: $output .= &Apache::loncommon::start_data_table_row();
4813: } else {
4814: my $rem = $count%($numinrow);
4815: if ($rem == 0) {
4816: if ($count > 0) {
4817: $output .= '</tr>';
4818: }
4819: $output .= '<tr>';
4820: }
4821: }
1.30 raeburn 4822: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 4823: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 4824: '</label></span></td>';
4825: if ($showsections) {
4826: $output .= '<td>'.
1.80 raeburn 4827: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 4828: '</td>'.&Apache::loncommon::end_data_table_row();
4829: }
4830: $total ++;
4831: $count ++;
4832: }
4833: }
4834: if (!$showsections) {
4835: my $rem = $total%($numinrow);
4836: my $colsleft = $numinrow - $rem;
4837: if ($colsleft > 1 ) {
4838: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
4839: ' </td>';
4840: } elsif ($colsleft == 1) {
4841: $output .= '<td class="LC_left_item"> </td>';
4842: }
4843: $output .= '</tr>';
4844: }
4845: return $output;
4846: }
4847:
1.50 raeburn 4848: sub set_discussion_fonts {
1.80 raeburn 4849: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.50 raeburn 4850: my ($classorder,$classtitles) = &discussion_vote_classes();
4851: my ($styleorder,$styleitems) = &discussion_vote_styles();
4852: my $output;
4853: if (ref($classorder) eq 'ARRAY') {
1.80 raeburn 4854: my $disabled;
4855: if ($noedit) {
4856: $disabled = ' disabled="disabled"';
4857: }
1.50 raeburn 4858: foreach my $cat (@{$classorder}) {
4859: my %curr = ();
4860: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
4861: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
4862: $output .= &Apache::loncommon::start_data_table_row().
4863: '<td>'.$classtitles->{$cat}.'</td>';
4864: if (ref($styleorder) eq 'ARRAY') {
4865: foreach my $item (@{$styleorder}) {
4866: $output .= '<td><span class="LC_nobreak">';
4867: my $selitem = $item;
4868: if ($item eq 'size') {
4869: my ($currsize,$currunit);
4870: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
4871: ($currsize,$currunit) = ($1,$2);
4872: $curr{'size'} = $currunit;
4873: }
1.81 raeburn 4874: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.50 raeburn 4875: ' ';
4876: $selitem = 'unit';
4877: }
4878: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.80 raeburn 4879: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.50 raeburn 4880: foreach my $val (@{$styleitems->{$item}}) {
4881: my $sel;
4882: if ($val eq $curr{$item}) {
4883: $sel = ' selected="selected"';
4884: }
4885: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
4886: }
4887: }
4888: }
4889: }
1.80 raeburn 4890: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
1.50 raeburn 4891: }
4892: $output .= &Apache::loncommon::end_data_table_row();
4893: }
4894: return $output;
4895: }
4896:
4897: sub discussion_vote_classes {
4898: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
4899: my %classtitles = &Apache::lonlocal::texthash(
4900: 'twoplus' => 'Two sigma above mean',
4901: 'oneplus' => 'One sigma above mean',
4902: 'zero' => 'Within one sigma of mean',
4903: 'oneminus' => 'One sigma below mean',
4904: 'twominus' => 'Two sigma below mean',
4905: );
4906: return ($classorder,\%classtitles);
4907: }
4908:
4909: sub discussion_vote_styles {
4910: my $styleorder = ['size','weight','style'];
4911: my $styleitems = {
4912: size => ['','px','%','xx-small','x-small','small','medium','large',
4913: 'x-large','xx-large','smaller','larger'],
4914: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
4915: '500','600','700','800','900'],
4916: style => ['','normal','italic','oblique'],
4917: };
4918: return ($styleorder,$styleitems);
4919: }
4920:
1.1 raeburn 4921: sub print_classlists {
1.80 raeburn 4922: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 4923: my @ordered;
4924: if ($position eq 'top') {
4925: @ordered = ('default_enrollment_start_date',
4926: 'default_enrollment_end_date');
1.55 raeburn 4927: if ($crstype eq 'Course') {
4928: push(@ordered,'defaultcredits');
4929: }
1.1 raeburn 4930: } elsif ($position eq 'middle') {
1.56 raeburn 4931: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 4932: } else {
4933: @ordered = ('student_classlist_view',
1.26 raeburn 4934: 'student_classlist_opt_in',
4935: 'student_classlist_portfiles');
1.1 raeburn 4936: }
1.9 raeburn 4937: my %lt;
4938:
4939: if ($crstype eq 'Community') {
4940: %lt = &Apache::lonlocal::texthash (
4941: disabled => 'No viewable membership list',
4942: section => "Membership of viewer's section",
4943: all => 'List of all members',
4944: );
4945: } else {
4946: %lt = &Apache::lonlocal::texthash (
4947: disabled => 'No viewable classlist',
4948: section => "Classlist of viewer's section",
4949: all => 'Classlist of all students',
4950: );
4951: }
4952:
1.1 raeburn 4953: my %items = (
4954: 'default_enrollment_start_date' => {
1.3 raeburn 4955: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 4956: input => 'dates',
4957: },
4958: 'default_enrollment_end_date' => {
1.3 raeburn 4959: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 4960: input => 'dates',
4961: },
1.55 raeburn 4962: 'defaultcredits' => {
4963: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4964: },
4965:
1.1 raeburn 4966: 'nothideprivileged' => {
1.3 raeburn 4967: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 4968: input => 'checkbox',
4969: },
4970:
1.56 raeburn 4971: 'checkforpriv' => {
4972: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
4973: input => 'selectbox',
4974: },
4975:
1.1 raeburn 4976: 'student_classlist_view' => {
1.3 raeburn 4977: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 4978: input => 'selectbox',
1.9 raeburn 4979: options => \%lt,
1.1 raeburn 4980: order => ['disabled','all','section'],
4981: },
1.26 raeburn 4982: 'student_classlist_opt_in' => {
4983: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 4984: input => 'radio',
4985: },
4986:
4987: 'student_classlist_portfiles' => {
1.3 raeburn 4988: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 4989: input => 'radio',
4990: },
4991: );
4992: unless (($settings->{'student_classlist_view'} eq 'all') ||
4993: ($settings->{'student_classlist_view'} eq 'section')) {
4994: $settings->{'student_classlist_view'} = 'disabled';
4995: }
1.80 raeburn 4996: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 4997: }
4998:
4999: sub print_appearance {
1.80 raeburn 5000: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5001: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5002: return;
5003: }
1.9 raeburn 5004: my $mathdef;
5005: if ($crstype eq 'Community') {
5006: $mathdef = &mt("None specified - use member's choice");
5007: } else {
5008: $mathdef = &mt("None specified - use student's choice");
5009: }
1.1 raeburn 5010: my %items = (
5011: 'default_xml_style' => {
1.3 raeburn 5012: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 5013: '<a href="javascript:openbrowser'.
5014: "('display','default_xml_style'".
5015: ",'sty')".'">'.&mt('Select Style File').'</a>',
5016: input => 'textbox',
5017: size => 35,
5018: },
5019:
5020: 'pageseparators' => {
1.3 raeburn 5021: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 5022: input => 'radio',
5023: },
5024: 'disable_receipt_display' => {
1.3 raeburn 5025: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 5026: input => 'radio',
5027: },
5028: 'texengine' => {
1.3 raeburn 5029: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 5030: input => 'selectbox',
5031: options => {
1.61 raeburn 5032: MathJax => 'MathJax',
1.1 raeburn 5033: mimetex => &mt('Convert to Images'),
5034: tth => &mt('TeX to HTML'),
5035: },
1.75 raeburn 5036: order => ['MathJax','mimetex','tth'],
1.9 raeburn 5037: nullval => $mathdef,
1.1 raeburn 5038: },
5039: 'tthoptions' => {
1.3 raeburn 5040: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 5041: input => 'textbox',
5042: size => 40,
5043: },
1.69 raeburn 5044: 'uselcmath' => {
5045: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
5046: input => 'radio',
5047: },
5048: 'usejsme' => {
5049: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
5050: input => 'radio',
5051: },
1.95 raeburn 5052: 'inline_chem' => {
5053: text => '<b>'.&mt($itemtext->{'inline_chem'}).'</b>',
5054: input => 'radio',
5055: },
1.1 raeburn 5056: );
1.80 raeburn 5057: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 5058: }
5059:
5060: sub print_grading {
1.80 raeburn 5061: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5062: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5063: return;
5064: }
5065: my %items = (
5066: 'grading' => {
1.3 raeburn 5067: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 5068: &Apache::loncommon::help_open_topic('GradingOptions'),
5069: input => 'selectbox',
5070: options => {
5071: standard => &mt('Standard: shows points'),
1.34 www 5072: categories => &mt('Categories: shows points according to categories'),
1.11 www 5073: external => &mt('External: shows number of completed parts and totals'),
5074: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 5075: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
5076: },
1.34 www 5077: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 5078: },
5079: 'rndseed' => {
1.3 raeburn 5080: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 5081: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 5082: &mt('Modifying this will make problems have different numbers and answers!').
5083: '</span>',
5084: input => 'selectbox',
5085: options => {
5086: '32bit' => '32bit',
5087: '64bit' => '64bit',
5088: '64bit2' => '64bit2',
5089: '64bit3' => '64bit3',
5090: '64bit4' => '64bit4',
5091: '64bit5' => '64bit5',
5092: },
5093: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 5094: advanced => 1
1.1 raeburn 5095: },
5096: 'receiptalg' => {
1.3 raeburn 5097: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 5098: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 5099: input => 'selectbox',
5100: options => {
5101: receipt => 'receipt',
5102: receipt2 => 'receipt2',
5103: receipt3 => 'receipt3',
5104: },
5105: order => ['receipt','receipt2','receipt3'],
1.41 www 5106: advanced => 1
1.1 raeburn 5107: },
5108: 'disablesigfigs' => {
1.3 raeburn 5109: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 5110: input => 'radio',
5111: },
5112: );
1.80 raeburn 5113: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit);
1.1 raeburn 5114: }
5115:
5116: sub print_printouts {
1.80 raeburn 5117: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5118: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5119: return;
5120: }
5121: my %items = (
5122: problem_stream_switch => {
1.3 raeburn 5123: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 5124: input => 'radio',
5125: },
5126: suppress_tries => {
1.3 raeburn 5127: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 5128: input => 'radio',
5129: },
5130: default_paper_size => {
1.3 raeburn 5131: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 5132: input => 'selectbox',
5133: options => {
5134: Letter => &mt('Letter').' [8 1/2x11 in]',
5135: Legal => &mt('Legal').' [8 1/2x14 in]',
5136: Tabloid => &mt('Tabloid').' [11x17 in]',
5137: Executive => &mt('Executive').' [7 1/2x10 in]',
5138: A2 => &mt('A2').' [420x594 mm]',
5139: A3 => &mt('A3').' [297x420 mm]',
5140: A4 => &mt('A4').' [210x297 mm]',
5141: A5 => &mt('A5').' [148x210 mm]',
5142: A6 => &mt('A6').' [105x148 mm]',
5143: },
5144: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.54 bisitz 5145: nullval => &mt('None specified'),
1.1 raeburn 5146: },
5147: print_header_format => {
1.3 raeburn 5148: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 5149: input => 'checkbox',
5150: },
5151: disableexampointprint => {
1.3 raeburn 5152: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 5153: input => 'radio',
5154: },
1.14 raeburn 5155: canuse_pdfforms => {
5156: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
5157: input => 'selectbox',
5158: options => {
5159: 1 => &mt('Yes'),
5160: 0 => &mt('No'),
5161: },
5162: order => ['1','0'],
1.54 bisitz 5163: nullval => &mt('None specified - use domain default'),
1.14 raeburn 5164: }
1.1 raeburn 5165: );
1.80 raeburn 5166: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 5167: }
5168:
5169: sub print_spreadsheet {
1.80 raeburn 5170: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5171: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5172: return;
5173: }
5174: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
5175: my %items = (
5176: spreadsheet_default_classcalc => {
1.3 raeburn 5177: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 5178: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
5179: "('display','spreadsheet_default_classcalc'".
5180: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
5181: input => 'textbox',
5182: },
5183: spreadsheet_default_studentcalc => {
1.3 raeburn 5184: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 5185: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
5186: "('display','spreadsheet_default_calc'".
5187: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
5188: input => 'textbox',
5189: },
5190: spreadsheet_default_assesscalc => {
1.3 raeburn 5191: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 5192: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
5193: "('display','spreadsheet_default_assesscalc'".
5194: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
5195: input => 'textbox',
5196: },
5197: hideemptyrows => {
1.3 raeburn 5198: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 5199: input => 'radio',
5200: },
5201: );
1.80 raeburn 5202: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 5203: }
1.1 raeburn 5204:
5205: sub print_bridgetasks {
1.80 raeburn 5206: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 5207: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 5208: return;
5209: }
1.9 raeburn 5210: my ($stumsg,$msgnote);
5211: if ($crstype eq 'Community') {
5212: $stumsg = &mt('Send message to member');
5213: $msgnote = &mt('Message to member and add to user notes');
5214: } else {
5215: $stumsg = &mt('Send message to student');
5216: $msgnote = &mt('Message to student and add to user notes');
5217: }
1.1 raeburn 5218: my %items = (
5219: task_messages => {
1.3 raeburn 5220: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 5221: input => 'selectbox',
5222: options => {
1.9 raeburn 5223: only_student => $stumsg,
5224: student_and_user_notes_screen => $msgnote,
1.1 raeburn 5225: },
5226: order => ['only_student','student_and_user_notes_screen'],
5227: nullval => &mt('No message or record in user notes'),
5228: },
5229: task_grading => {
1.3 raeburn 5230: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 5231: input => 'selectbox',
5232: options => {
5233: any => &mt('Grade BTs in any section'),
5234: section => &mt('Grade BTs only in own section')
5235: },
5236: order => ['any','section'],
5237: },
5238: suppress_embed_prompt => {
1.3 raeburn 5239: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
5240: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 5241: input => 'radio',
5242: },
5243: );
1.80 raeburn 5244: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 5245: }
5246:
1.87 raeburn 5247: sub print_lti {
5248: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
5249: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
5250: return;
5251: }
5252: my @menuitems = ('fullname','coursetitle','role','logout','grades');
5253: my %menutitles = <imenu_titles();
5254: my ($domdefs,$displaydefs);
5255: if ($env{'request.lti.login'}) {
5256: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
5257: my @domdefsmenu;
5258: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
5259: if ($lti{$env{'request.lti.login'}}{'topmenu'}) {
5260: $domdefs = &mt('Header shown').', ';
5261: }
5262: if ($lti{$env{'request.lti.login'}}{'inlinemenu'}) {
5263: $domdefs .= &mt('Inline menu shown');
5264: }
5265: $domdefs =~ s/,\s$//;
5266: if (!$domdefs) {
5267: $domdefs = &mt('No header or inline menu shown');
5268: }
5269: $domdefs = ' ('.&mt('Domain default').': '.$domdefs.')';
5270: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
5271: @domdefsmenu = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
5272: }
5273: }
5274: $displaydefs = &mt('Domain defaults');
5275: if (@domdefsmenu) {
5276: my @diffs = &Apache::loncommon::compare_arrays(\@menuitems,\@domdefsmenu);
5277: if (@diffs) {
5278: my $missing;
5279: foreach my $item (@menuitems) {
5280: unless (grep(/^\Q$item\E$/,@domdefsmenu)) {
5281: $missing .= ' '.$menutitles{$item}.',';
5282: }
5283: }
5284: $missing =~ s/,$//;
5285: $displaydefs .= ': '.&mt('Not shown').' --'.$missing;
5286: } else {
5287: $displaydefs .= ': '.&mt('All shown');
5288: }
5289: } else {
5290: $displaydefs .= ': '.&mt('Not shown').' -- '.join(', ', map { $menutitles{$_}; } @menuitems);
5291: }
5292: } else {
5293: $displaydefs = &mt('Domain defaults only available in LTI context');
5294: }
5295: my %items = (
5296: 'lti.override' => {
5297: text => '<b>'.&mt($itemtext->{'lti.override'}).'</b>'.$domdefs,
5298: input => 'radio',
5299: },
5300: 'lti.topmenu' => {
5301: text => '<b>'.&mt($itemtext->{'lti.topmenu'}).'</b>',
5302: input => 'radio',
5303: },
5304: 'lti.inlinemenu' => {
5305: text => '<b>'.&mt($itemtext->{'lti.inlinemenu'}).'</b>',
5306: input => 'radio',
5307: },
5308: 'lti.lcmenu' => {
5309: text => '<b>'.&mt($itemtext->{'lti.lcmenu'}).'</b><br />'.$displaydefs,
5310: input => 'custom',
5311: },
5312: );
5313: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'lti',$noedit);
5314: }
5315:
5316: sub lcmenu_checkboxes {
5317: my ($cdom,$caller,$settings,$crstype,$noedit) = @_;
5318: my @menuitems = ('fullname','coursetitle','role','logout','grades');
5319: my %menutitles = <imenu_titles();
5320: my (@current,@domdefs);
5321: if ($env{'request.lti.login'}) {
5322: my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
5323: if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') {
5324: if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') {
5325: @domdefs = @{$lti{$env{'request.lti.login'}}{'lcmenu'}};
5326: }
5327: }
5328: }
5329: if (ref($settings) eq 'HASH') {
5330: if ($settings->{'lti.lcmenu'}) {
5331: unless ($settings->{'lti.lcmenu'} eq 'none') {
5332: @current = split(',',$settings->{'lti.lcmenu'});
5333: }
5334: } else {
5335: @current = @domdefs;
5336: }
5337: } else {
5338: @current = @domdefs;
5339: }
5340: my $numinrow = 3;
5341: my $count = 0;
5342: my $disabled;
5343: if ($noedit) {
5344: $disabled = ' disabled="disabled"';
5345: }
5346: my $output = '<table>';
5347: foreach my $item (@menuitems) {
5348: my $checked = '';
5349: if (grep(/^\Q$item\E$/,@current)) {
5350: $checked = ' checked="checked" ';
5351: }
5352: my $rem = $count%($numinrow);
5353: if ($rem == 0) {
5354: if ($count > 0) {
5355: $output .= '</tr>';
5356: }
5357: $output .= '<tr>';
5358: }
5359: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" '.
5360: 'name="lti.lcmenu" value="'.$item.'"'.$checked.$disabled.'/> '.
5361: $menutitles{$item}.'</label></span></td>';
5362: $count ++;
5363: }
5364: my $rem = $count%($numinrow);
5365: my $colsleft = $numinrow - $rem;
5366: if ($colsleft > 1 ) {
5367: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
5368: ' </td>';
5369: } elsif ($colsleft == 1) {
5370: $output .= '<td class="LC_left_item"> </td>';
5371: }
5372: $output .= '</tr></table>';
5373: }
5374:
5375: sub ltimenu_titles {
5376: return &Apache::lonlocal::texthash(
5377: fullname => 'Full name',
5378: coursetitle => 'Course title',
5379: role => 'Role',
5380: logout => 'Logout',
5381: grades => 'Grades',
5382: );
5383: }
5384:
1.91 raeburn 5385: sub print_menuitems {
5386: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
5387: unless ((ref($settings) eq 'HASH') && (ref($itemtext) eq 'HASH')) {
5388: return;
5389: }
5390: if ($position eq 'top') {
5391: my (%defaultmenu_options,@defaultmenu_order,$addcollection);
5392: if ($settings->{'menucollections'} ne '') {
5393: foreach my $item (split(/;/,$settings->{'menucollections'})) {
5394: my ($num,$value) = split(/\%/,$item);
5395: if ($num =~ /^\d+$/) {
5396: $defaultmenu_options{$num} = $num;
5397: }
5398: }
5399: @defaultmenu_order = sort { $a <=> $b } keys(%defaultmenu_options);
5400: $addcollection = $defaultmenu_order[-1] + 1;
5401: } else {
5402: $addcollection = 1;
5403: }
5404: $defaultmenu_options{$addcollection} = $addcollection;
5405: my %items = (
5406: 'menudefault' => {
5407: text => '<b>'.&mt($itemtext->{'menudefault'}).'</b><br />'.
5408: &mt("(can be overriden in deep-link context)"),
5409: input => 'selectbox',
5410: options => \%defaultmenu_options,
5411: order => \@defaultmenu_order,
5412: nullval => &mt('Standard (all menus shown)'),
5413: },
5414: );
5415: return &make_item_rows($cdom,\%items,['menudefault'],$settings,$rowtotal,$crstype,'menuitems',$noedit);
5416: } else {
5417: my %menu;
5418: my $count = 0;
5419: my $next = 1;
5420: my ($datatable,$disabled);
5421: if ($noedit) {
5422: $disabled = ' disabled="disabled"';
5423: }
5424:
5425: my ($ordered,$cats) = &menuitems_categories();
5426: my @order = @{$ordered};
5427: my %categories = %{$cats};
5428: my %menutitles = &menuitems_titles();
5429: my %menufields = &menuitems_fields();
5430:
5431: if ($settings->{'menucollections'} ne '') {
5432: foreach my $item (split(/;/,$settings->{'menucollections'})) {
5433: my ($num,$value) = split(/\%/,$item);
5434: if ($num =~ /^\d+$/) {
5435: my @entries = split(/\&/,$value);
5436: foreach my $entry (@entries) {
5437: my ($name,$fields) = split(/=/,$entry);
5438: $menu{$num}{$name} = $fields;
5439: }
5440: }
5441: }
5442: if (keys(%menu)) {
5443: my @current = sort { $a <=> $b } keys(%menu);
5444: $next += $current[-1];
5445: foreach my $num (@current) {
5446: my %checked;
5447: my $on = ' checked="checked"';
5448: foreach my $key (keys(%{$menu{$num}})) {
1.94 raeburn 5449: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
1.91 raeburn 5450: if ($menu{$num}{$key} eq 'y') {
5451: $checked{$key} = $on;
5452: }
5453: } else {
5454: foreach my $field (split(/,/,$menu{$num}{$key})) {
5455: if (exists($menufields{$field})) {
5456: $checked{$field} = $on;
5457: }
5458: }
5459: }
5460: }
5461: if (ref($menu{$num}) eq 'HASH') {
5462: $datatable .= &item_table_row_start('<em class="LC_nav_bar">'.$num.'</em>',$count,'','','','LC_left_item');
5463: foreach my $category (@order) {
5464: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
5465: $datatable .= '<fieldset style="vertical-align:top; display:inline-block"><legend>'.$menutitles{$category}.'</legend>'."\n";
1.94 raeburn 5466: if ($category eq 'text') {
5467: $datatable .= '<i>'.&mt('Header').'</i><br />';
5468: }
1.91 raeburn 5469: foreach my $field (@{$categories{$category}}) {
1.94 raeburn 5470: if ($field eq 'disc') {
5471: $datatable .= '<br /><i>'.&mt('Footer').'</i><br />';
5472: }
1.91 raeburn 5473: $datatable .= '<label><input type="checkbox" name="menucollections_'.$num.'" value="'.$field.'"'.$checked{$field}.$disabled.' />'.
5474: $menufields{$field}.'</label><br />';
5475: }
5476: $datatable .= '</fieldset>';
5477: }
5478: }
5479: $datatable .= &item_table_row_end();
5480: $count ++;
5481: }
5482: }
5483: }
5484: } elsif ($noedit) {
5485: my $text = &mt('No menu collections defined for this course.');
5486: $datatable .= &item_table_row_start($text,$count);
5487: }
5488: unless ($noedit) {
5489: my $add = '<label><input type="checkbox" name="menucollections_add" id="menucollections_add" value="'.$next.'" '.
5490: 'onclick="javascript:toggleAddmenucoll();" />'.&mt('Add').'</label>';
5491: $datatable .= &item_table_row_start($add,$count,'','','','LC_left_item');
5492: foreach my $category (@order) {
5493: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
5494: $datatable .= '<fieldset id="addmenucoll_'.$category.'" style="display:none; vertical-align:top;"><legend>'.$menutitles{$category}.'</legend>'."\n";
5495: foreach my $field (@{$categories{$category}}) {
5496: $datatable .= '<label><input type="checkbox" class="LC_menucoll_add" name="menucollections_'.$next.'" value="'.$field.'"'.$disabled.' />'.
5497: $menufields{$field}.'</label><br />';
5498: }
5499: $datatable .= '</fieldset>';
5500: }
5501: }
5502: $datatable .= &item_table_row_end();
5503: $count ++;
5504: }
5505: return $datatable;
5506: }
5507: }
5508:
5509: sub menuitems_abbreviations {
5510: my %briefcats = (
5511: text => 'pt',
5512: links => 'p',
5513: list => 'ps',
5514: inline => 's',
5515: );
5516: return %briefcats;
5517: }
5518:
5519: sub menuitems_categories {
5520: my @order = ('shown','text','links','list','inline');
5521: my %categories = (
1.94 raeburn 5522: shown => ['top','inline','foot','main'],
5523: text => ['name','role','crs','disc','fdbk'],
1.92 raeburn 5524: links => ['pers','logo','menu','comm','roles','help','logout'],
1.91 raeburn 5525: list => ['about','prefs','port','wish','anno','rss'],
5526: inline => ['cont','grades','chat','people','groups','resv','syll','feeds'],
5527: );
5528: return (\@order,\%categories);
5529: }
5530:
5531: sub menuitems_titles {
5532: return &Apache::lonlocal::texthash (
5533: shown => 'Hierarchy',
1.94 raeburn 5534: text => 'Text',
1.91 raeburn 5535: links => 'Header links',
5536: list => 'Drop-down list',
5537: inline => 'Inline links',
5538: );
5539: }
5540:
5541: sub menuitems_fields {
5542: return &Apache::lonlocal::texthash (
5543: top => 'Display header',
5544: inline => 'Display inline menu',
1.94 raeburn 5545: foot => 'Display footer',
1.91 raeburn 5546: main => 'Access to main menu',
1.92 raeburn 5547: pers => 'Personal',
5548: logo => 'LON-CAPA',
1.91 raeburn 5549: menu => 'Home',
5550: comm => 'Messages',
5551: roles => 'Roles/Courses',
5552: help => 'Help',
5553: logout => 'Logout',
5554: name => 'Fullname',
5555: crs => 'Course Title',
5556: role => 'Current Role',
1.94 raeburn 5557: disc => 'Discussion',
5558: fdbk => 'Feedback',
1.91 raeburn 5559: about => 'Information',
5560: prefs => 'Preferences',
5561: port => 'Portfolio',
5562: wish => 'Stored Links',
5563: anno => 'Calendar',
5564: rss => 'RSS Feeds',
5565: cont => 'Contents',
5566: grades => 'Grades',
5567: chat => 'Chat',
5568: people => 'People',
5569: groups => 'Groups',
5570: resv => 'Reservations',
5571: syll => 'Syllabus',
5572: feeds => 'Feeds',
5573: );
5574: }
5575:
5576: sub menucollections_display {
5577: my ($collections) = @_;
5578: my %menu;
5579: my ($ordered,$cats) = &menuitems_categories();
5580: my @order = @{$ordered};
5581: my %categories = %{$cats};
5582: my %menutitles = &menuitems_titles();
5583: my %menufields = &menuitems_fields();
5584: foreach my $item (split(/;/,$collections)) {
5585: my ($num,$value) = split(/\%/,$item);
5586: if ($num =~ /^\d+$/) {
5587: my @entries = split(/\&/,$value);
5588: foreach my $entry (@entries) {
5589: my ($name,$fields) = split(/=/,$entry);
5590: $menu{$num}{$name} = $fields;
5591: }
5592: }
5593: }
5594: my $output = '';
5595: if (keys(%menu)) {
5596: my @current = sort { $a <=> $b } keys(%menu);
5597: foreach my $num (@current) {
5598: my %checked;
5599: foreach my $key (keys(%{$menu{$num}})) {
1.94 raeburn 5600: if (($key eq 'top') || ($key eq 'inline') || ($key eq 'foot') || ($key eq 'main')) {
1.91 raeburn 5601: if ($menu{$num}{$key} eq 'y') {
5602: $checked{$key} = 1;
5603: }
5604: } else {
5605: foreach my $field (split(/,/,$menu{$num}{$key})) {
5606: if (exists($menufields{$field})) {
5607: $checked{$field} = 1;
5608: }
5609: }
5610: }
5611: }
5612: if (ref($menu{$num}) eq 'HASH') {
5613: $output .= '<fieldset><legend>'.&mt('Collection [_1]',$num).'</legend>';
5614: foreach my $category (@order) {
5615: if ((ref($categories{$category}) eq 'ARRAY') && (@{$categories{$category}} > 0)) {
5616: $output .= '<fieldset style="vertical-align:top; display:inline-block">'.
5617: '<legend>'.$menutitles{$category}.'</legend>'."\n";
1.94 raeburn 5618: if ($category eq 'text') {
5619: $output .= '<b>'.&mt('Header Text').'</b><br /><br />';
5620: }
1.91 raeburn 5621: foreach my $field (@{$categories{$category}}) {
1.94 raeburn 5622: if ($field eq 'disc') {
5623: $output .= '<br /><b>'.&mt('Footer Text').'</b><br /><br />';
5624: }
1.91 raeburn 5625: if ($checked{$field}) {
5626: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field});
5627: } else {
5628: $output .= &Apache::lonhtmlcommon::confirm_success($menufields{$field},1);
5629: }
5630: $output .= '<br />';
5631: }
5632: $output .= '</fieldset>';
5633: }
5634: }
5635: $output .= '</fieldset>';
5636: }
5637: }
5638: }
5639: return $output;
5640: }
5641:
1.93 raeburn 5642: sub print_linkprotection {
1.102 raeburn 5643: my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_;
1.93 raeburn 5644:
5645: my %linkprotection;
5646: my $count = 0;
5647: my $next = 1;
1.102 raeburn 5648: my ($datatable,$disabled,$css_class,$dest);
1.93 raeburn 5649: if ($noedit) {
5650: $disabled = ' disabled="disabled"';
5651: }
1.100 raeburn 5652: my %desc = &linkprot_names();
5653: my %lt = &Apache::lonlocal::texthash (
5654: 'requ' => 'Required settings',
5655: 'opti' => 'Optional settings',
5656: );
1.93 raeburn 5657: my $itemcount = 0;
5658:
1.100 raeburn 5659: my $ltiauth;
1.102 raeburn 5660: if ($context eq 'domain') {
5661: $ltiauth = 1;
5662: } else {
5663: if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) {
5664: $ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'};
5665: } else {
5666: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
5667: $ltiauth = $domdefs{'crsltiauth'};
5668: }
5669: }
5670: if ($context eq 'domain') {
5671: $dest = '/adm/domainprefs';
1.100 raeburn 5672: } else {
1.102 raeburn 5673: $dest = '/adm/courseprefs';
5674: }
5675:
5676: my ($switchserver,$switchmessage);
5677: $switchserver = &check_switchserver($cdom,$cnum,$context,$dest);
5678: if ($switchserver) {
5679: if ($context eq 'domain') {
5680: $switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver);
5681: } elsif ($crstype eq 'Community') {
5682: $switchmessage = &mt("submit from community's home server: [_1].",$switchserver);
5683: } else {
5684: $switchmessage = &mt("submit from course's home server: [_1].",$switchserver);
5685: }
1.100 raeburn 5686: }
1.99 raeburn 5687:
1.105 raeburn 5688: if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) {
1.102 raeburn 5689: if (keys(%{$settings->{'linkprot'}})) {
5690: my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}});
1.93 raeburn 5691: $next += $current[-1];
5692: for (my $i=0; $i<@current; $i++) {
5693: my $num = $current[$i];
5694: my %values;
1.102 raeburn 5695: if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') {
5696: %values = %{$settings->{'linkprot'}->{$num}};
1.93 raeburn 5697: } else {
5698: next;
5699: }
5700: my $selected;
5701: if (($values{'version'} eq 'LTI-1p0') || ($values{'version'} eq '')) {
5702: $selected = ' selected="selected"';
5703: }
5704: $css_class = $itemcount%2?' class="LC_odd_row"':'';
5705: $datatable .=
5706: '<tr '.$css_class.'><td><span class="LC_nobreak">'.
5707: '<label><input type="checkbox" name="linkprot_del" value="'.$i.'"'.$disabled.' />'.
1.100 raeburn 5708: &mt('Delete?').'</label></span></td><td>';
5709: my ($usersty,$onclickrequser,%checkedrequser);
5710: if ($ltiauth) {
5711: $usersty = 'display:none';
1.102 raeburn 5712: $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','$i'".');"';
1.100 raeburn 5713: %checkedrequser = (
5714: no => ' checked="checked"',
5715: yes => '',
5716: );
5717: if ($values{'requser'}) {
5718: $checkedrequser{'yes'} = $checkedrequser{'no'};
5719: $checkedrequser{'no'} = '';
5720: }
5721: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
5722: if ($values{'requser'}) {
5723: $usersty = 'display:inline-block';
5724: }
5725: }
5726: $datatable .=
5727: '<span class="LC_nobreak">'.$desc{'name'}.
1.98 raeburn 5728: ':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '.
1.93 raeburn 5729: (' 'x2).
1.100 raeburn 5730: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_'.$i.'"'.$disabled.'>'.
1.93 raeburn 5731: '<option value="LTI-1p0" '.$selected.'>1.1</option></select></span> '."\n".
5732: (' 'x2).
1.100 raeburn 5733: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" name="linkprot_lifetime_'.$i.'"'.
5734: ' value="'.$values{'lifetime'}.'" size="3"'.$disabled.' /></span>';
5735: if ($ltiauth) {
5736: $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
5737: '<label><input type="radio" name="linkprot_requser_'.$i.'" value="0"'.
5738: $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
5739: '<label><input type="radio" name="linkprot_requser_'.$i.'" value="1"'.
1.101 raeburn 5740: $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>';
1.100 raeburn 5741: }
1.101 raeburn 5742: $datatable .= '<br /><br />';
1.99 raeburn 5743: if ($values{'key'} ne '') {
1.100 raeburn 5744: $datatable .= '<span class="LC_nobreak">'.$desc{'key'};
1.99 raeburn 5745: if ($noedit) {
5746: $datatable .= ': ['.&mt('not shown').']';
5747: } elsif ($switchserver) {
5748: $datatable .= ': ['.&mt('[_1] to view/edit',$switchserver).']';
5749: } else {
5750: $datatable .= ':<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />';
5751: }
5752: $datatable .= '</span> '.(' 'x2);
5753: } elsif (!$switchserver) {
1.100 raeburn 5754: $datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':'.
1.99 raeburn 5755: '<input type="text" size="25" name="linkprot_key_'.$i.'" value="'.$values{'key'}.'" autocomplete="off"'.$disabled.' />'.
5756: '</span> '.(' 'x2);
5757: }
5758: if ($switchserver) {
5759: if ($values{'usable'} ne '') {
5760: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
1.100 raeburn 5761: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
1.99 raeburn 5762: '<span class="LC_nobreak">'.&mt('Change secret?').
1.102 raeburn 5763: '<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'.
1.99 raeburn 5764: (' 'x2).
1.102 raeburn 5765: '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2).
1.99 raeburn 5766: '</span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
1.102 raeburn 5767: '<span class="LC_nobreak"> - '.$switchmessage.'</span>'.
1.99 raeburn 5768: '</div>';
5769: } elsif ($values{'key'} eq '') {
1.102 raeburn 5770: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 5771: } else {
1.102 raeburn 5772: $datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 5773: }
5774: } else {
5775: if ($values{'usable'} ne '') {
5776: $datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'.
1.100 raeburn 5777: $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'.
1.99 raeburn 5778: '<span class="LC_nobreak">'.&mt('Change?').
1.102 raeburn 5779: '<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 5780: (' 'x2).
1.102 raeburn 5781: '<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');"'.$disabled.' />'.&mt('Yes').
1.99 raeburn 5782: '</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'.
5783: '<span class="LC_nobreak">'.&mt('New Secret').':'.
5784: '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'.
1.106 raeburn 5785: '<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 5786: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>';
5787: } else {
5788: $datatable .=
1.100 raeburn 5789: '<span class="LC_nobreak">'.$desc{'secret'}.':'.
1.99 raeburn 5790: '<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'.
1.106 raeburn 5791: '<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 5792: '<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>';
5793: }
5794: }
1.100 raeburn 5795: if ($ltiauth) {
5796: $datatable .=
5797: '</fieldset>'.
5798: '<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
5799: &linkprot_options($i,$itemcount,$disabled,\%values,\%desc).
5800: '</fieldset>';
5801: }
1.99 raeburn 5802: $datatable .= '</td></tr>';
1.93 raeburn 5803: $itemcount ++;
5804: }
5805: }
5806: }
5807: $css_class = $itemcount%2?' class="LC_odd_row"':'';
5808: $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".
5809: '<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n".
1.98 raeburn 5810: '<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n".
1.105 raeburn 5811: '<td width="100%">';
1.100 raeburn 5812: my ($usersty,$onclickrequser,%checkedrequser);
5813: if ($ltiauth) {
5814: $usersty = 'display:none';
1.102 raeburn 5815: $onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','add'".');"';
1.100 raeburn 5816: %checkedrequser = (
5817: no => ' checked="checked"',
5818: yes => '',
5819: );
5820: $datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>';
5821: }
5822: $datatable .= '<span class="LC_nobreak">'.$desc{'name'}.
1.98 raeburn 5823: ':<input type="text" size="15" name="linkprot_name_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n".
1.93 raeburn 5824: (' 'x2).
1.100 raeburn 5825: '<span class="LC_nobreak">'.$desc{'version'}.':<select name="linkprot_version_add"'.$disabled.'>'.
1.93 raeburn 5826: '<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n".
5827: (' 'x2).
1.100 raeburn 5828: '<span class="LC_nobreak">'.$desc{'lifetime'}.':<input type="text" size="3" name="linkprot_lifetime_add" value="300"'.$disabled.' /></span> '."\n";
5829: if ($ltiauth) {
5830: $datatable .= (' 'x2).'<span class="LC_nobreak">'.$desc{'requser'}.'?'.
5831: '<label><input type="radio" name="linkprot_requser_add" value="0"'.
5832: $onclickrequser.$checkedrequser{'no'}.$disabled.' />'.&mt('No').'</label> '.
5833: '<label><input type="radio" name="linkprot_requser_add" value="1"'.
5834: $onclickrequser.$checkedrequser{'yes'}.$disabled.' />'.&mt('Yes').'</label></span>';
5835: }
5836: $datatable .= '<br /><br />';
1.99 raeburn 5837: if ($switchserver) {
1.102 raeburn 5838: $datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n";
1.99 raeburn 5839: } else {
1.100 raeburn 5840: $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 5841: (' 'x2).
1.100 raeburn 5842: '<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'.
1.106 raeburn 5843: '<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 5844: }
1.100 raeburn 5845: if ($ltiauth) {
5846: $datatable .= '</fieldset>'.
5847: '<fieldset id="linkprot_optional_add" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'.
5848: &linkprot_options('add',$itemcount,$disabled,{},\%desc).
5849: '</fieldset>';
5850: }
1.99 raeburn 5851: $datatable .= '</td></tr>';
1.93 raeburn 5852: $$rowtotal ++;
1.101 raeburn 5853: return $datatable;
1.93 raeburn 5854: }
5855:
5856: sub linkprot_names {
1.100 raeburn 5857: return &Apache::lonlocal::texthash(
1.93 raeburn 5858: 'version' => 'LTI Version',
5859: 'key' => 'Key',
5860: 'lifetime' => 'Nonce lifetime (s)',
1.100 raeburn 5861: 'name' => 'Launcher Application',
1.93 raeburn 5862: 'secret' => 'Secret',
1.100 raeburn 5863: 'requser' => 'Use identity',
5864: 'email' => 'Email address',
5865: 'sourcedid' => 'User ID',
5866: 'other' => 'Other',
5867: 'auth' => 'Display LON-CAPA login page',
5868: 'reject' => 'Discontinue launch process',
1.93 raeburn 5869: );
5870: }
5871:
1.99 raeburn 5872: sub check_switchserver {
1.102 raeburn 5873: my ($cdom,$cnum,$context,$dest) = @_;
5874: my ($allowed,$switchserver,$home);
5875: if ($context eq 'domain') {
5876: $home = &Apache::lonnet::domain($cdom,'primary');
5877: } else {
5878: $home = &Apache::lonnet::homeserver($cnum,$cdom);
5879: }
5880: unless (($home eq 'no_host') || ($home eq '')) {
1.99 raeburn 5881: my @ids=&Apache::lonnet::current_machine_ids();
5882: foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
5883: if (!$allowed) {
5884: $switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role='.
5885: &HTML::Entities::encode($env{'request.role'},'\'<>"&').
1.102 raeburn 5886: '&destinationurl='.$dest.'">'.&mt('Switch Server').'</a>';
1.99 raeburn 5887: }
5888: }
5889: return $switchserver;
5890: }
5891:
1.100 raeburn 5892: sub linkprot_options {
5893: my ($num,$itemcount,$disabled,$current,$desc) = @_;
5894: my %lt;
5895: if (ref($desc) eq 'HASH') {
5896: %lt = %{$desc};
5897: }
5898: my $userfieldsty = 'none';
5899: my (%checked,$userfield);
5900: $checked{'sourcedid'} = ' checked="checked"';
5901: $checked{'reject'} = ' checked="checked"';
5902: if (ref($current) eq 'HASH') {
5903: if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) {
5904: $checked{'sourcedid'} = '';
5905: if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') {
5906: $checked{'email'} = ' checked="checked"';
5907: } else {
5908: $checked{'other'} = ' checked="checked"';
5909: $userfield = $current->{'mapuser'};
5910: $userfieldsty = 'inline-block';
5911: }
5912: }
5913: if (($current->{'notstudent'} ne '') && ($current->{'notstudent'} ne 'reject')) {
5914: $checked{'reject'} = '';
5915: $checked{'auth'} = ' checked="checked"';
5916: }
5917: }
1.102 raeburn 5918: my $onclickuser = ' onclick="toggleLinkProtReqUser(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"';
1.100 raeburn 5919: my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'.
5920: &mt('Source of LON-CAPA username in LTI request').': ';
5921: foreach my $option ('sourcedid','email','other') {
5922: $output .= '<label><input type="radio" name="linkprot_mapuser_'.$num.'" value="'.$option.'"'.
5923: $checked{$option}.$onclickuser.$disabled.' />'.$lt{$option}.'</label>'.
5924: ($option eq 'other' ? '' : (' 'x2) );
5925: }
5926: $output .= '</span></div>'.
5927: '<div class="LC_floatleft" style="display:'.$userfieldsty.';" id="linkprot_userfield_'.$num.'">'.
5928: '<input type="text" name="linkprot_customuser_'.$num.'" '.
5929: 'value="'.$userfield.'"'.$disabled.' /></div>';
5930: $output .= '<br />'.
5931: '<div class="LC_floatleft"><span class="LC_nobreak">'.
5932: &mt('Action when username is not for an enrolled student').': ';
5933: foreach my $option ('reject','auth') {
5934: $output .= '<label><input type="radio" name="linkprot_notstudent_'.$num.'" value="'.$option.'"'.
5935: $checked{$option}.$disabled.' />'.$lt{$option}.'</label>'.
5936: ($option eq 'auth' ? '' : (' 'x2) );
5937: }
5938: $output .= '</span></div>';
5939: return $output;
5940: }
5941:
1.1 raeburn 5942: sub print_other {
1.80 raeburn 5943: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 5944: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
5945: return;
5946: }
1.3 raeburn 5947: my @ordered = &get_other_items($cdom,$settings,$allitems);
5948: my %items;
5949: foreach my $parameter (@ordered) {
5950: $items{$parameter} = {
5951: text => '<b>'.$parameter.'</b>',
5952: input => 'textbox',
5953: size => '15',
5954: },
5955: }
5956: push (@ordered,'newp_value');
5957: $items{'newp_value'} = {
5958: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
5959: '<input type="textbox" name="newp_name"'.
5960: ' value="" size="30" />',
5961: input => 'textbox',
5962: size => '30',
5963: };
1.93 raeburn 5964: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 5965: }
5966:
5967: sub get_other_items {
5968: my ($cdom,$settings,$allitems) = @_;
5969: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
5970: return;
5971: }
1.1 raeburn 5972: my @ordered;
5973: if (ref($settings) eq 'HASH') {
5974: foreach my $parameter (sort(keys(%{$settings}))) {
5975: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 5976: next if (($parameter eq 'course.helper.not.run') &&
5977: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 5978: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
5979: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
5980: || ($parameter eq 'type') ||
1.50 raeburn 5981: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.62 raeburn 5982: || ($parameter =~ m/^discussion_post_fonts/) ||
1.63 raeburn 5983: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
5984: ($parameter eq 'clonedfrom')) {
1.1 raeburn 5985: push(@ordered,$parameter);
5986: }
5987: }
5988: }
1.3 raeburn 5989: return @ordered;
1.1 raeburn 5990: }
5991:
5992: sub item_table_row_start {
1.91 raeburn 5993: my ($text,$count,$add_class,$colspan,$leftclass,$rightclass) = @_;
1.1 raeburn 5994: my $output;
1.56 raeburn 5995: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
5996: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
1.91 raeburn 5997: if ($leftclass eq '') {
5998: $leftclass = 'LC_left_item';
5999: }
6000: if ($rightclass eq '') {
6001: $rightclass = 'LC_right_item';
6002: }
1.56 raeburn 6003: $output .= '<tr class="'.$css_class.'">'."\n".
1.91 raeburn 6004: '<td class="'.$leftclass.'">'.$text.
1.56 raeburn 6005: '</td>';
1.91 raeburn 6006: if ($colspan > 1) {
6007: $output .= '<td class="'.$rightclass.'" colspan="'.$colspan.'">';
1.56 raeburn 6008: } else {
1.91 raeburn 6009: $output .= '<td class="'.$rightclass.'">';
1.56 raeburn 6010: }
1.1 raeburn 6011: return $output;
6012: }
6013:
6014: sub item_table_row_end {
6015: return '</td></tr>';
6016: }
6017:
6018: sub yesno_radio {
1.80 raeburn 6019: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_;
1.1 raeburn 6020: my $itemon = ' ';
6021: my $itemoff = ' checked="checked" ';
1.69 raeburn 6022: if (($valueyes eq '') && ($valueno eq '')) {
6023: $valueyes = 'yes';
6024: $valueno = '';
6025: }
1.1 raeburn 6026: if (ref($settings) eq 'HASH') {
1.69 raeburn 6027: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 6028: $itemon = $itemoff;
6029: $itemoff = ' ';
6030: }
1.69 raeburn 6031: unless (exists($settings->{$item})) {
6032: if ($unsetdefault eq $valueyes) {
6033: $itemon = $itemoff;
6034: $itemoff = ' ';
6035: }
6036: }
1.1 raeburn 6037: }
1.80 raeburn 6038: my $disabled;
6039: if ($noedit) {
6040: $disabled = ' disabled="disabled"';
6041: }
1.1 raeburn 6042: return '<span class="LC_nobreak"><label>'.
6043: '<input type="radio" name="'.$item.'"'.
1.80 raeburn 6044: $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').'</label> '.
1.1 raeburn 6045: '<label><input type="radio" name="'.$item.'"'.
1.80 raeburn 6046: $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').'</label></span>';
1.1 raeburn 6047: }
6048:
6049: sub select_from_options {
1.91 raeburn 6050: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit,$id) = @_;
1.1 raeburn 6051: my $output;
1.80 raeburn 6052: my $disabled;
6053: if ($noedit) {
6054: $disabled = ' disabled=disabled"';
6055: }
1.1 raeburn 6056: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
6057: $output='<select name="'.$item.'" '.$onchange;
6058: if ($multiple) {
6059: $output .= ' multiple="multiple"';
6060: my $num = @{$order};
6061: $num ++ if ($nullval ne '');
6062: if (($maxsize) && ($maxsize < $num)) {
6063: $output .= ' size="'.$maxsize.'"';
6064: }
6065: }
1.91 raeburn 6066: if ($id ne '') {
6067: $output .= ' id="'.$id.'"';
6068: }
1.80 raeburn 6069: $output .= $disabled.'>'."\n";
1.1 raeburn 6070: if ($nullval ne '') {
6071: $output .= '<option value=""';
6072: if (ref($curr) eq 'ARRAY') {
6073: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
6074: $output .= ' selected="selected" ';
6075: }
6076: } else {
6077: if ($curr eq '') {
6078: $output .= ' selected="selected" ';
6079: }
6080: }
6081: $output .= '>'.$nullval.'</option>';
6082: }
6083: foreach my $option (@{$order}) {
6084: $output.= '<option value="'.$option.'"';
6085: if (ref($curr) eq 'ARRAY') {
6086: if (grep(/^\Q$option\E$/,@{$curr})) {
6087: $output .= ' selected="selected" ';
6088: }
6089: } else {
6090: if ($option eq $curr) {
6091: $output.=' selected="selected"';
6092: }
6093: }
6094: $output.=">$options->{$option}</option>\n";
6095: }
6096: $output.="</select>";
6097: }
6098: return $output;
6099: }
6100:
6101: sub make_item_rows {
1.80 raeburn 6102: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit) = @_;
1.1 raeburn 6103: my $datatable;
6104: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
6105: my $count = 0;
6106: foreach my $item (@{$ordered}) {
6107: $count ++;
1.56 raeburn 6108: my $colspan;
6109: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
6110: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
6111: $colspan = 2;
6112: }
1.41 www 6113: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.56 raeburn 6114: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
1.41 www 6115: } else {
1.56 raeburn 6116: $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
1.41 www 6117: }
1.55 raeburn 6118: if ($item eq 'defaultcredits') {
6119: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
6120: my $showcredits;
6121: if ($defaultcredits ne '') {
6122: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
6123: } else {
6124: $showcredits = &mt('No default set');
6125: }
6126: $datatable .= $showcredits;
6127: } elsif ($item eq 'nothideprivileged') {
1.80 raeburn 6128: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.56 raeburn 6129: } elsif ($item eq 'checkforpriv') {
1.80 raeburn 6130: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 6131: } elsif ($item eq 'print_header_format') {
1.80 raeburn 6132: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.87 raeburn 6133: } elsif ($item eq 'lti.lcmenu') {
6134: $datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 6135: } elsif ($items->{$item}{input} eq 'dates') {
1.80 raeburn 6136: my $disabled;
6137: if ($noedit) {
6138: $disabled = ' disabled="disabled"';
6139: }
1.1 raeburn 6140: $datatable .=
6141: &Apache::lonhtmlcommon::date_setter('display',$item,
1.80 raeburn 6142: $settings->{$item},$disabled);
1.1 raeburn 6143: } elsif ($items->{$item}{input} eq 'radio') {
1.69 raeburn 6144: my ($unsetdefault,$valueyes,$valueno);
1.95 raeburn 6145: if (($item eq 'usejsme') || ($item eq 'uselcmath') || ($item eq 'inline_chem')) {
1.69 raeburn 6146: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
6147: unless ($domdefs{$item} eq '0') {
6148: $unsetdefault = 1;
6149: }
6150: $valueyes = "1";
6151: $valueno = "0";
1.87 raeburn 6152: } elsif (($item eq 'lti.topmenu') || ($item eq 'lti.inlinemenu')) {
6153: $valueyes = '1';
1.69 raeburn 6154: }
1.80 raeburn 6155: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 6156: } elsif ($items->{$item}{input} eq 'selectbox') {
1.91 raeburn 6157: my $id;
6158: if ($caller eq 'menuitems') {
6159: $id = $item;
6160: }
1.1 raeburn 6161: my $curr = $settings->{$item};
6162: $datatable .=
6163: &select_from_options($item,$items->{$item}{'order'},
6164: $items->{$item}{'options'},$curr,
1.80 raeburn 6165: $items->{$item}{'nullval'},
1.91 raeburn 6166: undef,undef,undef,$noedit,$id);
1.1 raeburn 6167: } elsif ($items->{$item}{input} eq 'textbox') {
1.80 raeburn 6168: my $disabled;
6169: if ($noedit) {
6170: $disabled = ' disabled=disabled"';
6171: }
1.1 raeburn 6172: $datatable .=
6173: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.80 raeburn 6174: $items->{$item}{size},
6175: $disabled);
1.1 raeburn 6176: }
6177: $datatable .= &item_table_row_end();
6178: }
6179: if (ref($rowtotal)) {
6180: $$rowtotal += scalar(@{$ordered});
6181: }
6182: }
6183: return $datatable;
6184: }
6185:
6186: sub nothidepriv_row {
1.80 raeburn 6187: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 6188: my ($cnum) = &get_course();
1.56 raeburn 6189: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 6190: if (ref($settings) eq 'HASH') {
6191: if ($settings->{$item} ne '') {
6192: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
6193: if ($user !~ /:/) {
6194: $nothide{join(':',split(/[\@]/,$user))}=1;
6195: } else {
6196: $nothide{$user} = 1;
6197: }
6198: }
6199: }
1.56 raeburn 6200: if ($settings->{'checkforpriv'}) {
6201: @checkdoms = split(/,/,$settings->{'checkforpriv'});
6202: }
1.1 raeburn 6203: }
1.56 raeburn 6204: push(@checkdoms,$cdom);
6205: my %coursepersonnel =
6206: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 6207: my @privusers;
6208: foreach my $person (keys(%coursepersonnel)) {
1.56 raeburn 6209: my ($uname,$udom,$role) = split(/:/,$person);
6210: my $user = $uname.':'.$udom;
6211: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 6212: if ($end == -1 || $start == -1) {
6213: next;
6214: }
1.56 raeburn 6215: foreach my $dom (@checkdoms) {
6216: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
6217: unless (grep(/^\Q$user\E$/,@privusers)) {
6218: push(@privusers,$user);
1.3 raeburn 6219: }
6220: }
6221: }
1.1 raeburn 6222: }
1.56 raeburn 6223: if (@privusers > 0) {
1.80 raeburn 6224: my $disabled;
6225: if ($noedit) {
6226: $disabled = ' disabled="disabled"';
6227: }
1.1 raeburn 6228: $datatable .= '<table align="right">';
6229: foreach my $user (sort(@privusers)) {
6230: my $hideon = ' checked="checked" ';
6231: my $hideoff = '';
6232: if ($nothide{$user}) {
6233: $hideoff = $hideon;
6234: $hideon = '';
6235: }
6236: my ($uname,$udom) = split(':',$user);
6237: $datatable .= '<tr><td align="left">'.
6238: &Apache::loncommon::aboutmewrapper(
6239: &Apache::loncommon::plainname($uname,$udom,'firstname'),
6240: $uname,$udom,'aboutuser').
6241: '</td><td align="left">'.
6242: '<span class="LC_nobreak"><label>'.
6243: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 6244: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.69 raeburn 6245: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 6246: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 6247: '</tr>';
6248: }
6249: $datatable .= '</table>';
6250: } else {
1.9 raeburn 6251: if ($crstype eq 'Community') {
6252: $datatable .= &mt('No Domain Coordinators have community roles');
6253: } else {
6254: $datatable .= &mt('No Domain Coordinators have course roles');
6255: }
1.1 raeburn 6256: }
6257: return $datatable;
6258: }
6259:
1.56 raeburn 6260: sub checkforpriv_row {
1.80 raeburn 6261: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.56 raeburn 6262: my $datatable;
6263: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
6264: if (keys(%domains) == 1) {
6265: $datatable = '</td><td align="right">'.
6266: &mt("Course's domain is only domain");
6267: return $datatable;
6268: }
6269: my @excdoms = ($cdom);
6270: my $num = 0;
6271: if ($settings->{$item} eq '') {
6272: $datatable = '</td><td align="right">'.
6273: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.80 raeburn 6274: 1,1,undef,undef,\@excdoms,
6275: $noedit);
1.56 raeburn 6276: } else {
6277: my @privdoms = split(/,/,$settings->{$item});
6278: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
6279: $datatable = '</td><td align="right"><br />'.
6280: &Apache::loncommon::start_data_table();
1.80 raeburn 6281: my $disabled;
6282: if ($noedit) {
6283: $disabled = ' disabled="disabled"';
6284: }
1.56 raeburn 6285: if (@privdoms > 0) {
6286: foreach my $currdom (@privdoms) {
6287: next unless ($domains{$currdom});
6288: my $domdesc = &Apache::lonnet::domain($currdom,'description');
6289: if ($domdesc eq '') {
6290: $domdesc = $currdom;
6291: }
6292: $datatable .=
6293: &Apache::loncommon::start_data_table_row().
6294: '<td align="left"><span class="LC_nobreak">'.
6295: &mt('Domain:').'<b> '.$domdesc.
6296: '</b><input type="hidden" name="checkforpriv_'.$num.
6297: '" value="'.$currdom.'" /></span><br />'.
6298: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.82 raeburn 6299: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
6300: &mt('Delete').'</label></span></td>'.
1.56 raeburn 6301: &Apache::loncommon::end_data_table_row();
6302: $num ++;
6303: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
6304: push(@excdoms,$currdom);
6305: }
6306: }
6307: }
6308: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
6309: $datatable .=
6310: &Apache::loncommon::start_data_table_row().
6311: '<td align="left"><span class="LC_nobreak">'.
6312: &mt('Additional domain:'). '</span><br />'.
6313: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.80 raeburn 6314: 1,undef,undef,\@excdoms,$noedit).
1.56 raeburn 6315: '</td>'.&Apache::loncommon::end_data_table_row();
6316: }
6317: $datatable .= &Apache::loncommon::end_data_table().
6318: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
6319: '<br />';
6320: }
6321: return $datatable;
6322: }
6323:
1.1 raeburn 6324: sub print_hdrfmt_row {
1.80 raeburn 6325: my ($item,$settings,$noedit) = @_;
1.1 raeburn 6326: my @curr;
6327: my $currnum = 0;
6328: my $maxnum = 2;
6329: my $currstr;
6330: if ($settings->{$item} ne '') {
6331: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
6332: $settings->{$item}.'</tt></span></b><br />';
6333: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 6334: foreach my $val (@current) {
6335: unless ($val eq '') {
6336: push(@curr,$val);
1.1 raeburn 6337: }
6338: }
6339: $currnum = @curr;
6340: $maxnum += $currnum;
6341: }
6342:
6343: my $output = <<ENDJS;
6344:
6345: <script type="text/javascript" language="Javascript">
6346:
6347: function reOrder(chgnum) {
6348: var maxnum = $maxnum;
6349: var oldidx = 'printfmthdr_oldpos_'+chgnum;
6350: var newidx = 'printfmthdr_pos_'+chgnum;
6351: oldidx = getIndexByName(oldidx);
6352: newidx = getIndexByName(newidx);
6353: var oldpos = document.display.elements[oldidx].value;
6354: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6355: document.display.elements[oldidx].value = newpos;
6356: var chgtype = 'up';
6357: if (newpos < oldpos) {
6358: chgtype = 'down';
6359: }
6360: for (var j=0; j<maxnum; j++) {
6361: if (j != chgnum) {
6362: oldidx = 'printfmthdr_oldpos_'+j;
6363: newidx = 'printfmthdr_pos_'+j;
6364: oldidx = getIndexByName(oldidx);
6365: newidx = getIndexByName(newidx);
6366: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6367: var currsel = document.display.elements[newidx].selectedIndex;
6368: if (chgtype == 'up') {
6369: if ((currpos > oldpos) && (currpos <= newpos)) {
6370: document.display.elements[newidx].selectedIndex = currsel-1;
6371: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6372: }
6373: } else {
6374: if ((currpos >= newpos) && (currpos < oldpos)) {
6375: document.display.elements[newidx].selectedIndex = currsel+1;
6376: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
6377: }
6378: }
6379: }
6380: }
6381: return;
6382: }
6383:
6384: function getIndexByName(item) {
6385: for (var i=0;i<document.display.elements.length;i++) {
6386: if (document.display.elements[i].name == item) {
6387: return i;
6388: }
6389: }
6390: return -1;
6391: }
6392:
6393: </script>
6394:
6395: ENDJS
1.56 raeburn 6396: $output .= '</td><td align="right"><br />'.
6397: $currstr.'<table class="LC_data_table">';
1.80 raeburn 6398: my $disabled;
6399: if ($noedit) {
6400: $disabled = ' disabled="disabled"';
6401: }
1.1 raeburn 6402: if (@curr > 0) {
6403: for (my $i=0; $i<@curr; $i++) {
6404: my $pos = $i+1;
1.10 raeburn 6405: $output .= '<tr>'.
1.1 raeburn 6406: '<td align="left"><span class="LC_nobreak">'.
1.80 raeburn 6407: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 6408: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.80 raeburn 6409: '"'.$disabled.' /></span></td>';
1.1 raeburn 6410: if ($curr[$i] =~ /^%\d*[nca]$/) {
6411: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
6412: $output .= '<td align="left">'.
1.80 raeburn 6413: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 6414: } else {
6415: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
6416: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.80 raeburn 6417: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 6418: }
1.10 raeburn 6419: $output .= '</tr>';
1.1 raeburn 6420: }
6421: }
1.80 raeburn 6422: my $pos = $currnum+1;
6423: unless ($noedit) {
6424: $output .=
6425: '<tr>'.
1.1 raeburn 6426: '<td align="left"><span class="LC_nobreak">'.
6427: &position_selector($pos,$currnum,$maxnum).
6428: '<b>'.&mt('New').'</b></span></td><td align="left">'.
6429: &substitution_selector($currnum).'</td>'.
1.10 raeburn 6430: '</tr>';
1.80 raeburn 6431: $pos ++;
1.82 raeburn 6432: $currnum ++;
6433: $output .=
1.80 raeburn 6434: '<tr>'.
1.1 raeburn 6435: '<td align="left"><span class="LC_nobreak">'.
6436: &position_selector($pos,$currnum,$maxnum).
6437: '<b>'.&mt('New').'</b></span></td>'.
6438: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
6439: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 6440: '" value="" size ="25" />'.
6441: '<input type="hidden" name="printfmthdr_maxnum" value="'.
6442: $maxnum.'" /></td>'.
1.80 raeburn 6443: '</tr>';
6444: }
6445: $output .= '</table><br />';
1.1 raeburn 6446: return $output;
6447: }
6448:
6449: sub position_selector {
1.80 raeburn 6450: my ($pos,$num,$maxnum,$disabled) = @_;
6451: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 6452: for (my $j=1; $j<=$maxnum; $j++) {
6453: my $sel = '';
6454: if ($pos == $j) {
6455: $sel = ' selected="selected"';
6456: }
6457: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
6458: }
6459: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
6460: '" value="'.$pos.'" />';
6461: return $output;
6462: }
6463:
6464: sub substitution_selector {
1.80 raeburn 6465: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 6466: my ($stunametxt,$crsidtxt);
6467: if ($crstype eq 'Community') {
6468: $stunametxt = 'member name';
6469: $crsidtxt = 'community ID',
6470: } else {
6471: $stunametxt = 'student name';
6472: $crsidtxt = 'course ID',
6473: }
1.1 raeburn 6474: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 6475: n => $stunametxt,
6476: c => $crsidtxt,
1.1 raeburn 6477: a => 'assignment note',
6478: );
6479: my $output .= &mt('Substitution').'<br />'.
1.80 raeburn 6480: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 6481: if ($subst eq '') {
6482: $output .= '<option value="" selected="selected"> </option>';
6483: }
6484: foreach my $field ('n','c','a') {
6485: my $sel ='';
6486: if ($subst eq $field) {
6487: $sel = ' selected="selected"';
6488: }
6489: $output .= '<option value="'.$field.'"'.$sel.'>'.
6490: $lt{$field}.'</option>';
6491: }
6492: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
6493: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.82 raeburn 6494: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 6495: return $output;
6496: }
6497:
1.23 raeburn 6498: sub change_clone {
6499: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
6500: my $clone_crs = $cnum.':'.$cdom;
6501: if ($cnum && $cdom) {
6502: my $clone_crs = $cnum.':'.$cdom;
6503: my @allowclone;
6504: if ($clonelist =~ /,/) {
6505: @allowclone = split(',',$clonelist);
6506: } else {
6507: $allowclone[0] = $clonelist;
6508: }
6509: foreach my $currclone (@allowclone) {
6510: if (!grep(/^$currclone$/,@$oldcloner)) {
6511: if ($currclone ne '*') {
1.71 raeburn 6512: if ($currclone =~ /:/) {
6513: my ($uname,$udom) = split(/:/,$currclone);
6514: if ($uname && $udom && $uname ne '*') {
6515: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
6516: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
6517: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
6518: if ($currclonecrs{'cloneable'} eq '') {
6519: $currclonecrs{'cloneable'} = $clone_crs;
6520: } else {
6521: $currclonecrs{'cloneable'} .= ','.$clone_crs;
6522: }
6523: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 6524: }
6525: }
6526: }
6527: }
6528: }
6529: }
6530: }
6531: foreach my $oldclone (@$oldcloner) {
6532: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
6533: if ($oldclone ne '*') {
1.71 raeburn 6534: if ($oldclone =~ /:/) {
6535: my ($uname,$udom) = split(/:/,$oldclone);
6536: if ($uname && $udom && $uname ne '*' ) {
6537: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
6538: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
6539: my %newclonecrs = ();
6540: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
6541: if ($currclonecrs{'cloneable'} =~ /,/) {
6542: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
6543: foreach my $crs (@currclonecrs) {
6544: if ($crs ne $clone_crs) {
6545: $newclonecrs{'cloneable'} .= $crs.',';
6546: }
1.23 raeburn 6547: }
1.71 raeburn 6548: $newclonecrs{'cloneable'} =~ s/,$//;
6549: } else {
6550: $newclonecrs{'cloneable'} = '';
1.23 raeburn 6551: }
1.71 raeburn 6552: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 6553: }
6554: }
6555: }
6556: }
6557: }
6558: }
6559: }
6560: }
6561: return;
6562: }
6563:
1.108 ! raeburn 6564: sub devalidate_remote_courseprefs {
! 6565: my ($cdom,$cnum,$cachekeys) = @_;
! 6566: return unless (ref($cachekeys) eq 'HASH');
! 6567: my %servers = &Apache::lonnet::internet_dom_servers($cdom);
! 6568: my %thismachine;
! 6569: map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids();
! 6570: my @posscached = ('courselti');
! 6571: if (keys(%servers)) {
! 6572: foreach my $server (keys(%servers)) {
! 6573: next if ($thismachine{$server});
! 6574: my @cached;
! 6575: foreach my $name (@posscached) {
! 6576: if ($cachekeys->{$name}) {
! 6577: push(@cached,&escape($name).':'.&escape($cdom.'_'.$cnum));
! 6578: }
! 6579: }
! 6580: if (@cached) {
! 6581: &Apache::lonnet::remote_devalidate_cache($server,\@cached);
! 6582: }
! 6583: }
! 6584: }
! 6585: return;
! 6586: }
! 6587:
1.1 raeburn 6588: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>