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