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