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