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