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