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