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