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