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