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