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