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