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