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