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