Annotation of loncom/interface/courseprefs.pm, revision 1.86
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.86 ! raeburn 4: # $Id: courseprefs.pm,v 1.85 2018/01/02 14:43:17 raeburn Exp $
1.1 raeburn 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: #
28: ###############################################################
29: ##############################################################
30:
1.23 raeburn 31: =pod
32:
33: =head1 NAME
34:
35: courseprefs- Handler to set/modify course configuration
36:
37: =head1 SYNOPSIS
38:
39: courseprefs provides an interface for setting general course configuration
40:
41: =head1 DESCRIPTION
42:
43: This module is used for configuration of a course
44:
45: =head1 INTERNAL SUBROUTINES
46:
47: =over
48:
49: =item get_allitems()
50:
51: =item print_config_box()
52:
53: =item process_changes()
54:
55: =item get_sec_str()
56:
57: =item check_clone()
58:
59: =item store_changes()
60:
61: =item update_env()
62:
63: =item display_disallowed()
64:
65: =item get_course()
66:
67: =item get_jscript()
68:
69: =item cloners_javascript()
70:
71: =item print_courseinfo()
72:
73: =item new_cloners_dom_row()
74:
75: =item can_modify_catsettings()
76:
77: =item assign_course_categories()
78:
79: =item print_localization()
80:
81: =item get_lang_choices()
82:
83: =item print_feedback()
84:
85: =item user_table()
86:
87: =item select_recipient()
88:
89: =item select_sections()
90:
91: =item print_discussion()
92:
93: =item role_checkboxes()
94:
95: =item print_classlists()
96:
97: =item print_appearance()
98:
99: =item print_grading()
100:
101: =item print_printouts()
102:
103: =item print_spreadsheet()
104:
105: =item print_bridgetasks()
106:
107: =item print_other()
108:
109: =item get_other_items()
110:
111: =item item_table_row_start()
112:
113: =item item_table_row_end()
114:
115: =item yes_no_radio()
116:
117: =item select_from_options()
118:
119: =item make_item_rows()
120:
121: Creates table used to display and set course configuration items.
122:
123: Inputs: $cdom,$items,$ordered,$settings,$rowtotal,$crstype
124: where $cdom is course's domain, $items is HASH ref for current config
125: item, $ordered is ARRAY ref of items to include in row in
126: display order, $settings is HASH ref of current values forrow,
127: $rowtotal is SCALAR ref used to accumulate row count, $crstype is
128: course type.
129:
130: Returns: $datatable
131: HTML mark-up of data table which accumulates individual rows.
132:
133: =item nothidepriv_row()
134:
135: Creates row containing form elements used to display and set
136: whether Domain coordinators who are currently included in
137: advanced course user .db file for a course are to be hidden (e.g.,
138: in syllabus, or from course user lists).
139:
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.85 raeburn 2583: %byresponsetype,%bysubmission,%fromblocks,%bycrsrestype);
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.85 raeburn 2857: my $rev_exttool=$Apache::lonnet::needsrelease{'course:courserestype:exttool'};
1.36 raeburn 2858: my $stdtype=&Apache::lonparmset::standard_parameter_types('type');
2859: my $stdname=&Apache::lonparmset::standard_parameter_names('type');
2860: my $valanon=&get_param_description($stdtype,'anonsurvey');
2861: my $valrandtry=&get_param_description($stdtype,'randomizetry');
1.66 raeburn 2862: my %checkedrev;
1.85 raeburn 2863: foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0)) {
1.36 raeburn 2864: my @parts = @{$res->parts()};
2865: my $symb = $res->symb();
2866: my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src());
1.85 raeburn 2867: if ($res->is_tool()) {
2868: my $rev = $rev_exttool;
2869: $bycrsrestype{$symb}{$rev} = &mt('External Tool');
2870: $allmaps{$enclosing_map} = 1;
2871: next;
2872: }
1.36 raeburn 2873: foreach my $part (@parts) {
2874: if (exists($anonsubms{$symb."\0".$part})) {
2875: my $rev = $rev_anonsurv;
2876: my $what="$stdname=$valanon";
2877: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2878: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2879: push(@{$bysubmission{$symb}{$rev}},$what);
2880: }
2881: } else {
2882: push(@{$bysubmission{$symb}{$rev}},$what);
2883: }
2884: $allmaps{$enclosing_map} = 1;
1.66 raeburn 2885: unless ($checkedrev{'anonsurvey'}) {
2886: my ($major,$minor) = split(/\./,$rev);
2887: ($reqdmajor,$reqdminor) =
2888: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2889: $reqdmajor,$reqdminor);
2890: $checkedrev{'anonsurvey'} = 1;
2891: }
1.36 raeburn 2892: }
2893: if (exists($randtrysubms{$symb."\0".$part})) {
2894: my $rev = $rev_randtry;
2895: my $what="$stdname=$valrandtry";
2896: if (ref($bysubmission{$symb}{$rev}) eq 'ARRAY') {
2897: unless (grep(/^\Q$what\E/,@{$bysubmission{$symb}{$rev}})) {
2898: push(@{$bysubmission{$symb}{$rev}},$what);
2899: }
2900: } else {
2901: push(@{$bysubmission{$symb}{$rev}},$what);
2902: }
2903: $allmaps{$enclosing_map} = 1;
1.66 raeburn 2904: unless ($checkedrev{'randomizetry'}) {
2905: my ($major,$minor) = split(/\./,$rev);
2906: ($reqdmajor,$reqdminor) =
2907: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2908: $reqdmajor,$reqdminor);
2909: $checkedrev{'randomizetry'} = 1;
2910: }
1.36 raeburn 2911: }
2912: }
2913: my %responses = $res->responseTypes();
2914: foreach my $key (keys(%responses)) {
1.66 raeburn 2915: if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) {
2916: my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key};
2917: unless ($checkedrev{$key}) {
2918: my ($major,$minor) = split(/\./,$rev);
2919: ($reqdmajor,$reqdminor) =
2920: &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,
2921: $reqdmajor,$reqdminor);
2922: $checkedrev{$key} = 1;
2923: }
2924: push(@{$byresponsetype{$symb}{$rev}},$key);
1.36 raeburn 2925: $allmaps{$enclosing_map} = 1;
2926: }
2927: }
2928: }
2929: if (keys(%byresource) > 0) {
2930: foreach my $symb (keys(%byresource)) {
2931: my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
2932: $allmaps{$map} = 1;
2933: }
2934: }
2935: if (keys(%bymap) > 0) {
2936: foreach my $map (keys(%bymap)) {
2937: $allmaps{$map} = 1;
2938: }
2939: }
2940: foreach my $map (keys(%allmaps)) {
2941: my $mapres = $navmap->getResourceByUrl($map);
2942: if (ref($mapres)) {
1.68 raeburn 2943: my $mapsymb = $mapres->symb();
2944: $toshow{$mapsymb} = 1;
1.36 raeburn 2945: my $pcslist = $mapres->map_hierarchy();
2946: if ($pcslist ne '') {
2947: foreach my $pc (split(/,/,$pcslist)) {
2948: my $res = $navmap->getByMapPc($pc);
2949: if (ref($res)) {
2950: my $symb = $res->symb();
2951: unless ($symb eq '______') {
2952: $toshow{$symb} = 1;
2953: }
2954: }
2955: }
2956: }
2957: }
2958: }
2959: }
1.86 ! raeburn 2960: my $suppmap = 'supplemental.sequence';
! 2961: my ($suppcount,$supptools,$errors) = (0,0,0);
! 2962: ($suppcount,$supptools,$errors) = &Apache::loncommon::recurse_supplemental($cnum,$cdom,
! 2963: $suppmap,$suppcount,$supptools,$errors);
1.36 raeburn 2964: my $mapres_header = '<h4>'.
2965: &mt('Requirements for specific folders or resources').
2966: '</h4>';
2967: if ((keys(%toshow) > 0) || (keys(%byresource) > 0) ||
2968: (keys(%bysubmission) > 0) || (keys(%byresponsetype))) {
2969: $output .= $mapres_header;
2970: }
2971: my $top_header = '<h3>'.&mt('LON-CAPA version dependencies').'</h3>';
2972: my $title = 'Version Constraints';
2973: my $start_page =
2974: &Apache::loncommon::start_page($title,undef,{'only_body' => 1,});
2975: $r->print($start_page.$top_header);
2976: if ($output) {
2977: $r->print($output);
1.86 ! raeburn 2978: if (defined($navmap) || $supptools) {
1.36 raeburn 2979: &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission,
1.86 ! raeburn 2980: \%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt,$supptools);
1.36 raeburn 2981: }
2982: $r->print('<br /><br />');
2983: } else {
2984: $r->print('<p class="LC_info">'.
2985: &mt('No version requirements from resource content or settings.').
2986: '</p>');
2987: }
2988: $r->print(&Apache::loncommon::end_page());
1.66 raeburn 2989: my ($currmajor,$currminor) = split(/\./,$loncaparev);
2990: if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) {
2991: return 1;
2992: }
1.36 raeburn 2993: return;
2994: }
2995:
2996: sub show_contents_view {
1.39 raeburn 2997: my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype,
1.86 ! raeburn 2998: $bycrsrestype,$scopeorder,$lt,$supptools) = @_;
! 2999: my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons");
! 3000: my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />';
! 3001: my $showmaincontent;
! 3002: if ((ref($navmap)) &&
! 3003: ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) ||
! 3004: (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0) ||
! 3005: (keys(%{$bycrsrestype}) > 0))) {
! 3006: $showmaincontent = 1;
! 3007: }
! 3008: if ($showmaincontent || $supptools) {
! 3009: $r->print(&Apache::loncommon::start_data_table());
! 3010: }
! 3011: if ($showmaincontent) {
! 3012: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
1.36 raeburn 3013: my $topmap = $env{'course.'.$cid.'.url'};
1.86 ! raeburn 3014: $r->print(&Apache::loncommon::start_data_table_header_row().
1.36 raeburn 3015: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
3016: '<th>'.&mt('Attribute/Setting').'</th>'.
3017: &Apache::loncommon::end_data_table_header_row().
3018: &Apache::loncommon::start_data_table_row().
1.58 raeburn 3019: '<td> '.$icon.' '.&mt('Main Content').'</td>');
1.86 ! raeburn 3020: &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt);
! 3021: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 3022: my $it=$navmap->getIterator(undef,undef,undef,1,1,undef);
3023: my $curRes;
3024: my $depth = 0;
3025: my %parent = ();
3026: my $startcount = 5;
3027: my $lastcontainer = $startcount;
3028: while ($curRes = $it->next()) {
3029: if ($curRes == $it->BEGIN_MAP()) {
3030: $depth++;
3031: $parent{$depth}= $lastcontainer;
3032: }
3033: if ($curRes == $it->END_MAP()) {
3034: $depth--;
3035: $lastcontainer = $parent{$depth};
3036: }
3037: my $indent;
3038: for (my $i=0; $i<$depth; $i++) {
3039: $indent.= $whitespace;
3040: }
3041: if (ref($curRes)) {
3042: my $symb = $curRes->symb();
3043: my $ressymb = $symb;
3044: my $srcf = $curRes->src();
3045: my $title = &Apache::lonnet::gettitle($srcf);
3046: if (($curRes->is_sequence()) || ($curRes->is_page())) {
3047: next unless($toshow->{$symb});
3048: my ($parent,$ind,$url) = &Apache::lonnet::decode_symb($symb);
3049: $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
3050: if ($curRes->is_page()) {
3051: $icon = '<img src="'.$location.'/navmap.page.open.gif" alt="" />';
3052: }
3053: my $rowspan = 1;
3054: if (ref($bymap->{$url}) eq 'HASH') {
3055: $rowspan = scalar(keys(%{$bymap->{$url}}));
3056: }
3057: $r->print(&Apache::loncommon::start_data_table_row().
3058: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
1.48 raeburn 3059: &releases_by_map($r,$bymap,$url,$scopeorder,$lt);
1.36 raeburn 3060: $r->print(&Apache::loncommon::end_data_table_row());
3061: } else {
3062: my $rowspan;
3063: if (ref($byresource->{$symb}) eq 'HASH') {
3064: $rowspan += scalar(keys(%{$byresource->{$symb}}));
3065: }
3066: if (ref($bysubmission->{$symb}) eq 'HASH') {
3067: $rowspan += scalar(keys(%{$bysubmission->{$symb}}));
3068: }
3069: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3070: $rowspan += scalar(keys(%{$byresponsetype->{$symb}}));
3071: }
1.85 raeburn 3072: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
3073: $rowspan += scalar(keys(%{$bycrsrestype->{$symb}}));
3074: }
1.36 raeburn 3075: next if (!$rowspan);
3076: $icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'.
3077: &mt('Problem').'" />';
3078: $r->print(&Apache::loncommon::start_data_table_row().
3079: '<td rowspan="'.$rowspan.'">'.$indent.$icon.' '.$title.'</td>');
3080: my $newrow;
3081: if (ref($byresource->{$symb}) eq 'HASH') {
3082: foreach my $rev (sort(keys(%{$byresource->{$symb}}))) {
3083: if ($newrow) {
3084: $r->print(&Apache::loncommon::continue_data_table_row());
3085: }
3086: $r->print('<td valign="middle">'.$rev.'</td><td>');
3087: if (ref($byresource->{$symb}{$rev}) eq 'HASH') {
3088: $r->print('<table border="0">');
3089: foreach my $scope (@{$scopeorder}) {
3090: if (ref($byresource->{$symb}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3091: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3092: foreach my $which (sort(keys(%{$byresource->{$symb}{$rev}{$scope}}))) {
3093: $r->print('<td>'.$which.'</td><td>'.
3094: join('<br />',@{$byresource->{$symb}{$rev}{$scope}{$which}}).
3095: '</td>');
3096: }
3097: $r->print('</tr>');
3098: } elsif (ref($byresource->{$symb}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3099: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>'.
1.36 raeburn 3100: '<td> </td><td>'.
3101: join('<br />',@{$byresource->{$symb}{$rev}{$scope}}).'</td></tr>');
3102: }
3103: }
3104: $r->print('</table>');
3105: }
3106: $r->print('</td>');
3107: $r->print(&Apache::loncommon::end_data_table_row());
3108: $newrow = 1;
3109: }
3110: }
3111: if (ref($bysubmission->{$symb}) eq 'HASH') {
3112: foreach my $rev (sort(keys(%{$bysubmission->{$symb}}))) {
3113: if ($newrow) {
3114: $r->print(&Apache::loncommon::continue_data_table_row());
3115: }
3116: $r->print('<td>'.$rev.'</td><td>');
3117: if (ref($bysubmission->{$symb}{$rev}) eq 'ARRAY') {
3118: $r->print(&mt('Submissions to: ').' '.
3119: join(', ',@{$bysubmission->{$symb}{$rev}}));
3120: }
3121: $r->print('</td>');
3122: $r->print(&Apache::loncommon::end_data_table_row());
3123: $newrow = 1;
3124: }
3125: }
3126: if (ref($byresponsetype->{$symb}) eq 'HASH') {
3127: foreach my $rev (sort(keys(%{$byresponsetype->{$symb}}))) {
3128: if ($newrow) {
3129: $r->print(&Apache::loncommon::continue_data_table_row());
3130: }
3131: $r->print('<td>'.$rev.'</td><td>');
3132: if (ref($byresponsetype->{$symb}{$rev}) eq 'ARRAY') {
3133: $r->print(&mt('Response Type(s): ').' '.
3134: join('<br />',@{$byresponsetype->{$symb}{$rev}}));
3135: }
3136: $r->print('</td>');
3137: }
3138: $r->print(&Apache::loncommon::end_data_table_row());
1.85 raeburn 3139: $newrow = 1;
3140: }
3141: if (ref($bycrsrestype->{$symb}) eq 'HASH') {
3142: foreach my $rev (sort(keys(%{$bycrsrestype->{$symb}}))) {
3143: if ($newrow) {
3144: $r->print(&Apache::loncommon::continue_data_table_row());
3145: }
3146: $r->print('<td>'.$rev.'</td><td>'.$bycrsrestype->{$symb}{$rev}.'</td>');
3147: }
1.86 ! raeburn 3148: $r->print(&Apache::loncommon::end_data_table_row());
1.36 raeburn 3149: }
3150: }
3151: }
3152: }
1.86 ! raeburn 3153: }
! 3154: if ($supptools) {
! 3155: my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />';
! 3156: $r->print(&Apache::loncommon::start_data_table_header_row().
! 3157: '<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'.
! 3158: '<th>'.&mt('Resource Type').'</th>'.
! 3159: &Apache::loncommon::end_data_table_header_row().
! 3160: &Apache::loncommon::start_data_table_row().
! 3161: '<td> '.$icon.' '.&mt('Supplemental Content').'</td>'.
! 3162: '<td valign="middle">'.
! 3163: $Apache::lonrelrequtils::exttool{'major'}.'.'.
! 3164: $Apache::lonrelrequtils::exttool{'minor'}.
! 3165: '</td><td>'.&mt('[quant,_1,External Tool,External Tools]',
! 3166: $supptools).'</td>'.
! 3167: &Apache::loncommon::end_data_table_row());
! 3168: }
! 3169: if ($showmaincontent || $supptools) {
1.36 raeburn 3170: $r->print(&Apache::loncommon::end_data_table());
3171: }
1.66 raeburn 3172: return;
1.36 raeburn 3173: }
3174:
3175: sub releases_by_map {
1.39 raeburn 3176: my ($r,$bymap,$url,$scopeorder,$lt) = @_;
1.36 raeburn 3177: return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY'));
1.73 raeburn 3178: my $newrow = 0;
1.36 raeburn 3179: if (ref($bymap->{$url}) eq 'HASH') {
3180: foreach my $rev (sort(keys(%{$bymap->{$url}}))) {
1.73 raeburn 3181: if ($newrow) {
3182: $r->print(&Apache::loncommon::end_data_table_row().
3183: &Apache::loncommon::continue_data_table_row());
3184: }
1.36 raeburn 3185: $r->print('<td valign="middle">'.$rev.'</td><td>');
3186: if (ref($bymap->{$url}{$rev}) eq 'HASH') {
3187: $r->print('<table border="0">');
3188: foreach my $scope (@{$scopeorder}) {
3189: if (ref($bymap->{$url}{$rev}{$scope}) eq 'HASH') {
1.39 raeburn 3190: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).'</td>');
1.36 raeburn 3191: foreach my $which (sort(keys(%{$bymap->{$url}{$rev}{$scope}}))) {
3192: $r->print('<td>'.$which.'</td><td>'.
3193: join('<br />',@{$bymap->{$url}{$rev}{$scope}{$which}}).
3194: '</td>');
3195: }
3196: $r->print('</tr>');
3197: } elsif (ref($bymap->{$url}{$rev}{$scope}) eq 'ARRAY') {
1.39 raeburn 3198: $r->print('<tr><td>'.&mt('Setting - scope: [_1]',$lt->{$scope}).
1.36 raeburn 3199: '</td><td> </td><td>'.
3200: join('<br />',@{$bymap->{$url}{$rev}{$scope}}).'</td></tr>');
3201: }
3202: }
3203: $r->print('</table>');
3204: }
3205: $r->print('</td>');
1.73 raeburn 3206: $newrow = 1;
1.36 raeburn 3207: }
3208: } else {
3209: $r->print('<td colspan="2"> </td>');
3210: }
3211: return;
3212: }
3213:
3214: sub get_param_description {
1.70 raeburn 3215: my ($stdtype,$value,$regexp) = @_;
3216: my ($name,$parammatches,$paramstrings,@possibles);
1.74 raeburn 3217: if ($stdtype =~ /^string/) {
3218: $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
3219: } elsif ($stdtype eq 'date_interval') {
3220: $paramstrings = &Apache::lonparmset::standard_interval_options($stdtype);
3221: }
1.70 raeburn 3222: if ($regexp) {
1.74 raeburn 3223: if ($stdtype =~ /^string/) {
3224: $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
3225: } elsif ($stdtype eq 'date_interval') {
3226: $parammatches = &Apache::lonparmset::standard_interval_matches($stdtype);
3227: }
1.70 raeburn 3228: if (ref($parammatches) eq 'ARRAY') {
3229: @possibles = @{$parammatches};
3230: } else {
3231: undef($regexp);
3232: $name = $value;
3233: }
3234: }
3235: unless ($regexp) {
3236: $name = $value;
3237: if (ref($paramstrings) eq 'ARRAY') {
3238: @possibles = @{$paramstrings};
3239: } else {
1.76 raeburn 3240: if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) {
3241: if ($name == 0) {
3242: $name = &mt('Never');
3243: } elsif (($name ne '') && ($name !~ /\D/)) {
3244: $name = &Apache::lonlocal::locallocaltime($name);
3245: }
3246: }
1.70 raeburn 3247: return $name;
3248: }
1.36 raeburn 3249: }
1.70 raeburn 3250: foreach my $possibilities (@possibles) {
1.36 raeburn 3251: next unless (ref($possibilities) eq 'ARRAY');
1.70 raeburn 3252: my $gotregexmatch = '';
3253: if ($regexp) {
3254: last if ($gotregexmatch);
3255: my ($item,$pattern) = @{ $possibilities };
3256: if ($value =~ /$pattern/) {
3257: if (ref($paramstrings) eq 'ARRAY') {
3258: foreach my $possibles (@{$paramstrings}) {
3259: next unless (ref($possibles) eq 'ARRAY');
3260: my ($thing,$description) = @{$possibles};
3261: if ($thing eq $item) {
3262: $name = $description;
3263: $gotregexmatch = 1;
3264: last;
3265: }
3266: }
3267: last if ($gotregexmatch);
3268: }
3269: }
3270: } else {
3271: my ($thing,$description) = @{ $possibilities };
3272: if ($thing eq $value) {
3273: $name = $description;
3274: last;
3275: }
1.36 raeburn 3276: }
3277: }
3278: return $name;
3279: }
3280:
1.66 raeburn 3281: sub update_releasereq {
3282: my $readmap = 1;
3283: my $getrelreq = 1;
3284: if (ref($modified_courses) eq 'ARRAY') {
3285: foreach my $item (@{$modified_courses}) {
3286: if (ref($item) eq 'ARRAY') {
3287: my ($cdom,$cnum,$chome,$crstype) = @{$item};
3288: &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom,
3289: $chome,$crstype,$cdom.'_'.$cnum,
3290: $readmap,$getrelreq);
3291: }
3292: }
3293: $modified_courses = [];
3294: }
3295: undef($registered_cleanup);
3296: return;
3297: }
3298:
1.25 raeburn 3299: sub show_autocoowners {
3300: my (@currcoown) = @_;
1.56 raeburn 3301: 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 3302: if (@currcoown > 0) {
3303: $output .= '<br />'.&mt('Current co-owners are:').' '.
3304: join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3305: } else {
3306: $output .= '<br />'.&mt('Currently no co-owners.');
3307: }
3308: return $output;
3309: }
3310:
3311: sub coowner_invitations {
1.80 raeburn 3312: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3313: my ($output,@pendingcoown,@othercoords,@currcoown);
1.25 raeburn 3314: my $pendingcoowners =
3315: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3316: if ($pendingcoowners) {
3317: @pendingcoown = split(',',$pendingcoowners);
3318: }
1.80 raeburn 3319: if (ref($currcoownref) eq 'ARRAY') {
3320: @currcoown == @{$currcoownref};
3321: }
3322: my $disabled;
3323: if ($noedit) {
3324: $disabled = ' disabled="disabled"';
3325: }
1.25 raeburn 3326: my $ccrole = 'cc';
3327: my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]);
3328: foreach my $key (sort(keys(%ccroles))) {
3329: my ($ccname,$ccdom,$role) = split(':',$key);
3330: next if ($key eq $env{'user.name'}.':'.$env{'user.domain'}.':'.$ccrole);
3331: unless (grep(/^\Q$ccname\E:\Q$ccdom\E$/,@currcoown,@pendingcoown)) {
3332: push(@othercoords,$ccname.':'.$ccdom);
3333: }
3334: }
3335: my $coowner_rows = @currcoown + @pendingcoown + @othercoords;
3336: if ($coowner_rows) {
3337: $output .= &Apache::loncommon::start_data_table();
3338: if (@currcoown) {
3339: $output .= &Apache::loncommon::start_data_table_row().
3340: '<td><i>'.&mt('Current co-owners').'</i></td><td>';
3341: foreach my $person (@currcoown) {
3342: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3343: $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 3344: }
3345: $output .= '</td>'.
3346: &Apache::loncommon::end_data_table_row();
3347: }
3348: if ($pendingcoowners) {
3349: $output .= &Apache::loncommon::start_data_table_row().
3350: '<td><i>'.&mt('Invited as co-owners [_1](agreement pending)','<br />').'</i></td><td>';
3351: foreach my $person (@pendingcoown) {
3352: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3353: $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 3354: }
3355: $output .= '</td>'.
3356: &Apache::loncommon::end_data_table_row();
3357: }
3358: if (@othercoords) {
3359: $output .= &Apache::loncommon::start_data_table_row().
3360: '<td><i>'.&mt('Invite other Coordinators [_1]to become co-owners','<br />').'</i></td><td>';
3361: foreach my $person (@othercoords) {
3362: my ($co_uname,$co_dom) = split(':',$person);
1.80 raeburn 3363: $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 3364: }
3365: $output .= '</td>'.
3366: &Apache::loncommon::end_data_table_row();
3367: }
3368: $output .= &Apache::loncommon::end_data_table();
3369: } else {
3370: $output = &mt('There are no coordinators to select as co-owners');
3371: }
3372: return $output;
3373: }
3374:
3375: sub manage_coownership {
1.80 raeburn 3376: my ($cnum,$cdom,$currcoownref,$noedit) = @_;
3377: my (@pendingcoown,@currcoown);
1.25 raeburn 3378: my $pendingcoowners =
3379: $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'};
3380: if ($pendingcoowners) {
3381: @pendingcoown = split(',',$pendingcoowners);
3382: }
1.80 raeburn 3383: if (ref($currcoownref) eq 'ARRAY') {
3384: @currcoown == @{$currcoownref};
3385: }
3386: my $disabled;
3387: if ($noedit) {
3388: $disabled = ' disabled="disabled"';
3389: }
1.25 raeburn 3390: my ($is_coowner,$is_pending,$output);
3391: my $uname = $env{'user.name'};
3392: my $udom = $env{'user.domain'};
3393: if (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
3394: $is_coowner = 1;
3395: }
3396: if (grep(/^\Q$uname\E:\Q$udom\E$/,@pendingcoown)) {
3397: $is_pending = 1;
3398: }
3399: if (@currcoown && ($is_coowner || $is_pending)) {
3400: $output = &Apache::loncommon::start_data_table();
3401: }
3402: if (@currcoown) {
3403: if ($is_coowner || $is_pending) {
3404: $output .= &Apache::loncommon::start_data_table().
3405: &Apache::loncommon::start_data_table_row().'<td>';
3406: }
3407: $output .= &mt('Current co-owners are:').' '.
3408: join(', ', map { &Apache::loncommon::plainname(split(':',$_)); } (@currcoown));
3409: if ($is_coowner || $is_pending) {
3410: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3411: }
3412: }
3413: if ($is_coowner || $is_pending) {
3414: if (@currcoown) {
3415: $output .= &Apache::loncommon::start_data_table_row().'<td>';
3416: }
3417: $output .= '<span class="LC_nobreak">';
3418: if ($is_coowner) {
3419: $output .= &mt('You are currently a co-owner:').' <label><input type="checkbox" name="remove_coowoner" value="'.$uname.':'.$udom.'" />'.&mt('Discontinue?').'</label>';
3420: } else {
1.80 raeburn 3421: $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).
3422: '<label><input type="radio" name=pending_coowoner" value="decline"'.$disabled.' />'.&mt('Decline?').'</label>';
1.25 raeburn 3423: }
3424: $output .= '</span>';
3425: if (@currcoown) {
3426: $output .= '</td>'.&Apache::loncommon::end_data_table_row();
3427: }
3428: }
3429: if (@currcoown && ($is_coowner || $is_pending)) {
3430: $output .= &Apache::loncommon::end_data_table();
3431: }
3432: return $output;
3433: }
3434:
1.1 raeburn 3435: sub print_localization {
1.80 raeburn 3436: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3437: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3438: return;
3439: }
3440: my %items = (
3441: languages => {
1.17 faziophi 3442: text => '<b>'.&mt($itemtext->{'languages'}).'</b><br />'.
3443: &mt("(overrides individual user preference)"),
1.1 raeburn 3444: input => 'selectbox',
3445: },
3446: timezone => {
1.17 faziophi 3447: text => '<b>'.&mt($itemtext->{'timezone'}).'</b>',
1.1 raeburn 3448: input => 'selectbox',
3449: },
3450: datelocale => {
1.17 faziophi 3451: text => '<b>'.&mt($itemtext->{'datelocale'}).'</b>',
1.1 raeburn 3452: input => 'selectbox',
3453: },
3454: );
1.80 raeburn 3455: my ($datatable,$disabled);
1.1 raeburn 3456: my $count = 0;
1.80 raeburn 3457: if ($noedit) {
3458: $disabled = ' disabled="disabled"';
3459: }
1.1 raeburn 3460: foreach my $item (@{$ordered}) {
3461: $count ++;
1.56 raeburn 3462: my $colspan;
3463: unless ($item eq 'languages') {
1.80 raeburn 3464: $colspan = 2;
1.56 raeburn 3465: }
3466: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 3467: if ($item eq 'timezone') {
3468: my $includeempty = 1;
3469: my $timezone = &Apache::lonlocal::gettimezone();
3470: $datatable .=
3471: &Apache::loncommon::select_timezone($item,$timezone,undef,
1.80 raeburn 3472: $includeempty,$disabled);
1.1 raeburn 3473: } elsif ($item eq 'datelocale') {
3474: my $includeempty = 1;
3475: my $locale_obj = &Apache::lonlocal::getdatelocale();
3476: my $currdatelocale;
3477: if (ref($locale_obj)) {
3478: $currdatelocale = $locale_obj->id();
3479: }
3480: $datatable .=
3481: &Apache::loncommon::select_datelocale($item,$currdatelocale,
1.80 raeburn 3482: undef,$includeempty,$disabled);
1.1 raeburn 3483: } else {
3484: if ($settings->{$item} eq '') {
1.80 raeburn 3485: unless ($noedit) {
3486: $datatable .= '</td><td align="right">'.
3487: &Apache::loncommon::select_language('languages_0','',1);
3488: }
1.1 raeburn 3489: } else {
3490: my $num = 0;
1.3 raeburn 3491: my @languages = split(/\s*[,;:]\s*/,$settings->{$item});
1.56 raeburn 3492: $datatable .= '</td><td align="right"><br />'.
3493: &Apache::loncommon::start_data_table();
1.1 raeburn 3494: if (@languages > 0) {
1.3 raeburn 3495: my %langchoices = &get_lang_choices();
1.1 raeburn 3496: foreach my $lang (@languages) {
3497: my $showlang = $lang;
1.3 raeburn 3498: if (exists($langchoices{$lang})) {
3499: $showlang = $langchoices{$lang};
1.1 raeburn 3500: }
3501: $datatable .=
3502: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3503: '<td align="left"><span class="LC_nobreak">'.
1.1 raeburn 3504: &mt('Language:').'<b> '.$showlang.
3505: '</b><input type="hidden" name="languages_'.$num.
3506: '" value="'.$lang.'" /></span><br />'.
3507: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.80 raeburn 3508: 'name="languages_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 3509: &mt('Delete').'</label></span></td>'.
1.3 raeburn 3510: &Apache::loncommon::end_data_table_row();
1.1 raeburn 3511: $num ++;
3512: }
3513: }
1.80 raeburn 3514: unless ($noedit) {
3515: $datatable .=
3516: &Apache::loncommon::start_data_table_row().
1.3 raeburn 3517: '<td align="left"><span class="LC_nobreak">'.
3518: &mt('Additional language:'). '</span><br />'.
3519: &Apache::loncommon::select_language('languages_'.$num,'',1).
1.1 raeburn 3520: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
1.80 raeburn 3521: '</td>'.&Apache::loncommon::end_data_table_row();
3522: }
3523: $datatable .= &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 3524: }
3525: }
3526: $datatable .= &item_table_row_end();
3527: }
3528: $$rowtotal += scalar(@{$ordered});
3529: return $datatable;
3530: }
3531:
1.3 raeburn 3532: sub get_lang_choices {
3533: my %langchoices;
3534: foreach my $id (&Apache::loncommon::languageids()) {
3535: my $code = &Apache::loncommon::supportedlanguagecode($id);
3536: if ($code) {
3537: $langchoices{$code} = &Apache::loncommon::plainlanguagedescription($id);
3538: }
3539: }
3540: return %langchoices;
3541: }
3542:
1.1 raeburn 3543: sub print_feedback {
1.80 raeburn 3544: my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3545: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3546: return;
3547: }
3548: my %items = (
1.3 raeburn 3549: 'question.email' => {
3550: text => '<b>'.&mt($itemtext->{'question.email'}).'</b>',
1.1 raeburn 3551: input => 'textbox',
3552: size => '50',
3553: },
3554:
1.3 raeburn 3555: 'comment.email' => {
3556: text => '<b>'.&mt($itemtext->{'comment.email'}).'</b>',
1.1 raeburn 3557: input => 'textbox',
3558: size => '50',
3559: },
3560:
1.3 raeburn 3561: 'policy.email' => {
3562: text => '<b>'.&mt($itemtext->{'policy.email'}).'</b>',
1.1 raeburn 3563: input => 'textbox',
3564: size => '50',
3565: },
3566: );
3567: my $datatable;
3568: my $count = 0;
3569: my ($cnum) = &get_course();
3570: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3571: my @sections = sort( { $a <=> $b } keys(%sections));
3572: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 3573: currone => 'Current recipient:',
3574: currmult => 'Current recipients:',
3575: add => 'Additional recipient:',
3576: del => 'Delete?',
3577: sec => 'Sections:',
1.1 raeburn 3578: );
1.80 raeburn 3579: my $disabled;
3580: if ($noedit) {
3581: $disabled = ' disabled="disabled"';
3582: }
1.1 raeburn 3583: foreach my $item (@{$ordered}) {
3584: $count ++;
1.20 faziophi 3585: if ($position eq 'top') {
3586: $datatable .= &item_table_row_start($items{$item}{text},$count);
3587: } else {
1.56 raeburn 3588: $datatable .= &item_table_row_start($items{$item}{text}."<br/>(Custom text)",$count, "advanced",2);
1.20 faziophi 3589: }
1.1 raeburn 3590: if ($position eq 'top') {
3591: my $includeempty = 0;
1.56 raeburn 3592: $datatable .= '</td><td align="right">'.
3593: &user_table($cdom,$item,\@sections,
1.80 raeburn 3594: $settings->{$item},\%lt,$noedit);
1.1 raeburn 3595: } else {
1.3 raeburn 3596: $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text',
1.80 raeburn 3597: $settings->{$item.'.text'},$items{$item}{size},$disabled);
1.1 raeburn 3598: }
3599: $datatable .= &item_table_row_end();
3600: }
3601: $$rowtotal += scalar(@{$ordered});
3602: return $datatable;
3603: }
3604:
3605: sub user_table {
1.80 raeburn 3606: my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_;
1.1 raeburn 3607: my $output;
3608: if ($currvalue eq '') {
1.80 raeburn 3609: unless ($noedit) {
3610: $output .= &select_recipient($item,'0',$cdom,$sections);
3611: }
1.1 raeburn 3612: } else {
3613: my $num = 0;
3614: my @curr = split(/,/,$currvalue);
1.56 raeburn 3615: $output .= '<table class="LC_data_table">';
1.1 raeburn 3616: my ($currusers);
1.80 raeburn 3617: my $disabled;
3618: if ($noedit) {
3619: $disabled = ' disabled="disabled"';
3620: }
1.1 raeburn 3621: foreach my $val (@curr) {
3622: next if ($val eq '');
3623: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
3624: my @selsec;
3625: if ($seclist) {
3626: $seclist =~ s/(^\(|\)$)//g;
3627: @selsec = split(/\s*;\s*/,$seclist);
3628: }
3629: $currusers .= '<tr>'.
3630: '<td valign="top"><span class="LC_nobreak">'.
3631: '<label><input type="checkbox" '.
1.80 raeburn 3632: 'name="'.$item.'_delete" value="'.$num.'"'.$disabled.' />'.
1.1 raeburn 3633: $lt->{'del'}.'</label>'.
3634: '<input type="hidden" name="'.$item.'_user_'.
1.3 raeburn 3635: $num.'" value="'.$uname.':'.$udom.'" />'.(' 'x2).
1.1 raeburn 3636: &Apache::loncommon::aboutmewrapper(
3637: &Apache::loncommon::plainname($uname,$udom,'firstname'),
3638: $uname,$udom,'aboutuser');
3639: if (ref($sections) eq 'ARRAY') {
3640: if (@{$sections}) {
3641: $currusers.= (' 'x3).$lt->{'sec'}.' '.
3642: &select_sections($item,$num,$sections,
1.80 raeburn 3643: \@selsec,$noedit);
1.1 raeburn 3644: }
3645: }
3646: $currusers .= '</span></td></tr>';
3647: $num ++;
3648: }
3649: if ($num) {
1.10 raeburn 3650: $output .= '<tr>'.
1.1 raeburn 3651: '<td align="left"><i>';
1.20 faziophi 3652: if ($num == 1) {
1.1 raeburn 3653: $output .= $lt->{'currone'};
3654: } else {
1.21 raeburn 3655: $output .= $lt->{'currmult'};
1.1 raeburn 3656: }
3657: $output .= '</i><br />'.
3658: '<table>'.$currusers.'</table></td>'.
1.10 raeburn 3659: '</tr>';
1.1 raeburn 3660: }
1.80 raeburn 3661: unless ($noedit) {
3662: $output .=
3663: '<tr>'.
1.1 raeburn 3664: '<td align="left"><span class="LC_nobreak"><i>'.
3665: $lt->{'add'}.'</i></span><br />'.
3666: &select_recipient($item,$num,$cdom,$sections).
3667: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
1.80 raeburn 3668: '</td></tr>';
3669: }
3670: $output .= '</table>';
1.1 raeburn 3671: }
3672: return $output;
3673: }
3674:
3675: sub select_recipient {
3676: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
3677: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
3678: my $selectlink =
3679: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
3680: $item.'_udom_'.$num,1);
3681: my $output =
1.10 raeburn 3682: '<table><tr><td align="center">'.&mt('Username').'<br />'.
1.1 raeburn 3683: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
3684: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
3685: if (ref($sections) eq 'ARRAY') {
3686: if (@{$sections}) {
3687: $output .= '<td align="center">'.&mt('Sections').'<br />'.
3688: &select_sections($item,$num,$sections,$selected).'</td>';
3689: }
3690: }
3691: $output .= '<td valign="top">'.
3692: $selectlink.'</td></tr></table>';
3693: return $output;
3694: }
3695:
3696: sub select_sections {
1.80 raeburn 3697: my ($item,$num,$sections,$selected,$noedit) = @_;
3698: my ($output,@currsecs,$allsec,$disabled);
1.1 raeburn 3699: if (ref($selected) eq 'ARRAY') {
3700: @currsecs = @{$selected};
3701: }
3702: if (!@currsecs) {
3703: $allsec = ' selected="selected"';
3704: }
1.80 raeburn 3705: if ($noedit) {
3706: $disabled = ' disabled="disabled"';
3707: }
1.1 raeburn 3708: if (ref($sections) eq 'ARRAY') {
3709: if (@{$sections}) {
3710: my $mult;
3711: if (@{$sections} > 1) {
3712: $mult = ' multiple="multiple"';
3713: if (@{$sections} > 3) {
3714: $mult .= ' size="4"';
3715: }
3716: }
1.80 raeburn 3717: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.$disabled.'>'.
1.1 raeburn 3718: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
3719: foreach my $sec (@{$sections}) {
3720: my $is_sel;
3721: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
3722: $is_sel = 'selected="selected"';
3723: }
3724: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
3725: }
3726: $output .= '</select>';
3727: }
3728: }
3729: return $output;
3730: }
3731:
3732: sub print_discussion {
1.80 raeburn 3733: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_;
1.3 raeburn 3734: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 3735: return;
3736: }
3737: my %items = (
3738: 'plc.roles.denied' => {
1.10 raeburn 3739: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'plc.roles.denied'}).'</b>'.
3740: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.5 raeburn 3741: &mt('(role-based)'),
1.1 raeburn 3742: input => 'checkbox',
3743: },
3744:
3745: 'plc.users.denied' => {
1.3 raeburn 3746: text => '<b>'.&mt($itemtext->{'plc.users.denied'}).'</b><br />'.
3747: &mt('(specific user(s))'),
1.1 raeburn 3748: input => 'checkbox',
3749: },
3750:
3751: 'pch.roles.denied' => {
1.10 raeburn 3752: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pch.roles.denied'}).'</b>'.
3753: &Apache::loncommon::help_open_topic("Course_Disable_Discussion").'</span><br />'.
1.3 raeburn 3754: &mt('(role-based)'),
1.1 raeburn 3755: input => 'checkbox',
3756: },
3757:
3758: 'pch.users.denied' => {
1.3 raeburn 3759: text => '<b>'.&mt($itemtext->{'pch.users.denied'}).'</b><br />'.
3760: &mt('(specific user(s))'),
1.1 raeburn 3761: input => 'checkbox',
3762: },
1.77 raeburn 3763:
3764: 'pac.roles.denied' => {
3765: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.roles.denied'}).'</b>'.
3766: &Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'</span><br />'.
3767: &mt('(role-based)'),
3768: input => 'checkbox',
3769: },
3770:
3771: 'pac.users.denied' => {
3772: text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.users.denied'}).'</b><br />'.
3773: &mt('(specific user(s))'),
3774: input => 'checkbox',
3775: },
3776:
1.1 raeburn 3777: 'allow_limited_html_in_feedback' => {
1.3 raeburn 3778: text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>',
1.1 raeburn 3779: input => 'radio',
3780: },
3781:
3782: 'allow_discussion_post_editing' => {
1.3 raeburn 3783: text => '<b>'.&mt($itemtext->{'allow_discussion_post_editing'}).'</b>',
1.1 raeburn 3784: input => 'checkbox',
3785: },
1.50 raeburn 3786: 'discussion_post_fonts' => {
3787: text => '<b>'.&mt($itemtext->{'discussion_post_fonts'}).'</b>',
3788: input => 'textbox',
3789: size => '20',
3790: },
1.1 raeburn 3791: );
3792: my $datatable;
3793: my $count;
3794: my ($cnum) = &get_course();
3795: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3796: my @sections = sort( { $a <=> $b } keys(%sections));
3797: my %lt = &Apache::lonlocal::texthash (
1.21 raeburn 3798: currone => 'Disallowed:',
3799: currmult => 'Disallowed:',
3800: add => 'Disallow more:',
3801: del => 'Delete?',
3802: sec => 'Sections:',
1.1 raeburn 3803: );
3804: foreach my $item (@{$ordered}) {
3805: $count ++;
1.56 raeburn 3806: my $colspan;
3807: if ($item eq 'allow_limited_html_in_feedback') {
3808: $colspan = 2;
3809: }
3810: $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan);
1.1 raeburn 3811: if ($item eq 'plc.roles.denied') {
1.56 raeburn 3812: $datatable .= '</td><td align="right">'.
1.80 raeburn 3813: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 3814: '</table>';
3815: } elsif ($item eq 'plc.users.denied') {
1.56 raeburn 3816: $datatable .= '</td><td align="right">'.
3817: &user_table($cdom,$item,undef,
1.80 raeburn 3818: $settings->{$item},\%lt,$noedit);
1.1 raeburn 3819: } elsif ($item eq 'pch.roles.denied') {
1.56 raeburn 3820: $datatable .= '</td><td align="right">'.
1.80 raeburn 3821: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.1 raeburn 3822: '</table>';
3823: } elsif ($item eq 'pch.users.denied') {
1.56 raeburn 3824: $datatable .= '</td><td align="right">'.
3825: &user_table($cdom,$item,undef,
1.80 raeburn 3826: $settings->{$item},\%lt,$noedit);
1.77 raeburn 3827: } elsif ($item eq 'pac.roles.denied') {
3828: $datatable .= '</td><td align="right">'.
1.80 raeburn 3829: '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit).
1.77 raeburn 3830: '</table>';
3831: } elsif ($item eq 'pac.users.denied') {
3832: $datatable .= '</td><td align="right">'.
3833: &user_table($cdom,$item,undef,
1.80 raeburn 3834: $settings->{$item},\%lt,$noedit);
1.1 raeburn 3835: } elsif ($item eq 'allow_limited_html_in_feedback') {
1.80 raeburn 3836: $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit);
1.1 raeburn 3837: } elsif ($item eq 'allow_discussion_post_editing') {
1.56 raeburn 3838: $datatable .= '</td><td align="right"><br />'.
3839: &Apache::loncommon::start_data_table().
1.1 raeburn 3840: &Apache::loncommon::start_data_table_row().
3841: '<th align="left">'.&mt('Role').'</th><th>'.
3842: &mt('Sections').'</th>'.
3843: &Apache::loncommon::end_data_table_row().
1.80 raeburn 3844: &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit).
1.56 raeburn 3845: &Apache::loncommon::end_data_table().'<br />';
1.50 raeburn 3846: } elsif ($item eq 'discussion_post_fonts') {
1.56 raeburn 3847: $datatable .= '</td><td align="right"><br />'.
3848: &Apache::loncommon::start_data_table().
1.50 raeburn 3849: &Apache::loncommon::start_data_table_row().
3850: '<th align="center">'.&mt('Sum of likes/dislikes').'</th>'.
3851: '<th align="center">'.&mt('font-size').'</th>'.
3852: '<th align="center">'.&mt('font-weight').'</th>'.
3853: '<th align="center">'.&mt('font-style').'</th>'.
3854: '<th align="center">'.&mt('Other css').'</th>'.
3855: &Apache::loncommon::end_data_table_row().
1.80 raeburn 3856: &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit).
1.56 raeburn 3857: &Apache::loncommon::end_data_table().'<br />';
1.1 raeburn 3858: }
3859: $datatable .= &item_table_row_end();
3860: }
3861: $$rowtotal += scalar(@{$ordered});
3862: return $datatable;
3863: }
3864:
3865: sub role_checkboxes {
1.80 raeburn 3866: my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_;
1.9 raeburn 3867: my @roles = ('st','ad','ta','ep','in');
3868: if ($crstype eq 'Community') {
3869: push(@roles,'co');
3870: } else {
3871: push(@roles,'cc');
3872: }
1.1 raeburn 3873: my $output;
3874: my (@current,@curr_roles,%currsec,@sections);
3875: if ($showsections) {
3876: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
3877: @sections = sort( { $a <=> $b } keys(%sections));
3878: }
3879: if (ref($settings) eq 'HASH') {
3880: if ($settings->{$item}) {
3881: @current = split(',',$settings->{$item});
3882: if ($showsections) {
3883: foreach my $role (@current) {
3884: if ($role =~ /:/) {
3885: my ($trole,$sec) = split(':',$role);
3886: push(@curr_roles,$trole);
3887: if (ref($currsec{$trole}) eq 'ARRAY') {
3888: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
3889: push(@{$currsec{$trole}},$sec);
3890: }
1.3 raeburn 3891: } else {
3892: $currsec{$trole} = [$sec];
1.1 raeburn 3893: }
3894: } else {
3895: push(@curr_roles,$role);
3896: }
3897: }
3898: @current = @curr_roles;
3899: }
3900: }
3901: }
3902: my $numinrow = 3;
3903: my $count = 0;
1.80 raeburn 3904: my $disabled;
3905: if ($noedit) {
3906: $disabled = ' disabled="disabled"';
3907: }
1.1 raeburn 3908: foreach my $role (@roles) {
3909: my $checked = '';
3910: if (grep(/^\Q$role\E$/,@current)) {
3911: $checked = ' checked="checked" ';
3912: }
1.9 raeburn 3913: my $plrole=&Apache::lonnet::plaintext($role,$crstype);
1.1 raeburn 3914: if ($showsections) {
3915: $output .= &Apache::loncommon::start_data_table_row();
3916: } else {
3917: my $rem = $count%($numinrow);
3918: if ($rem == 0) {
3919: if ($count > 0) {
3920: $output .= '</tr>';
3921: }
3922: $output .= '<tr>';
3923: }
3924: }
1.30 raeburn 3925: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 3926: $item.'" value="'.$role.'"'.$checked.$disabled.'/> '.
1.1 raeburn 3927: $plrole.'</label></span></td>';
3928: if ($showsections) {
3929: $output .= '<td align="left">'.
1.80 raeburn 3930: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 3931: '</td></tr>';
3932: }
3933: $count ++;
3934: }
3935: my %adv_roles =
3936: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
3937: my $total = @roles;
3938: foreach my $role (sort(keys(%adv_roles))) {
3939: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
3940: my $rolename = $3;
3941: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
3942: my $checked = '';
3943: if (grep(/^\Q$value\E$/,@current)) {
3944: $checked = ' checked="checked" ';
3945: }
3946: if ($showsections) {
3947: $output .= &Apache::loncommon::start_data_table_row();
3948: } else {
3949: my $rem = $count%($numinrow);
3950: if ($rem == 0) {
3951: if ($count > 0) {
3952: $output .= '</tr>';
3953: }
3954: $output .= '<tr>';
3955: }
3956: }
1.30 raeburn 3957: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="'.
1.80 raeburn 3958: $item.'" value="'.$value.'"'.$checked.$disabled.' /> '.$rolename.
1.1 raeburn 3959: '</label></span></td>';
3960: if ($showsections) {
3961: $output .= '<td>'.
1.80 raeburn 3962: &select_sections($item,$role,\@sections,$currsec{$role},$noedit).
1.1 raeburn 3963: '</td>'.&Apache::loncommon::end_data_table_row();
3964: }
3965: $total ++;
3966: $count ++;
3967: }
3968: }
3969: if (!$showsections) {
3970: my $rem = $total%($numinrow);
3971: my $colsleft = $numinrow - $rem;
3972: if ($colsleft > 1 ) {
3973: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
3974: ' </td>';
3975: } elsif ($colsleft == 1) {
3976: $output .= '<td class="LC_left_item"> </td>';
3977: }
3978: $output .= '</tr>';
3979: }
3980: return $output;
3981: }
3982:
1.50 raeburn 3983: sub set_discussion_fonts {
1.80 raeburn 3984: my ($cdom,$cnum,$item,$settings,$noedit) = @_;
1.50 raeburn 3985: my ($classorder,$classtitles) = &discussion_vote_classes();
3986: my ($styleorder,$styleitems) = &discussion_vote_styles();
3987: my $output;
3988: if (ref($classorder) eq 'ARRAY') {
1.80 raeburn 3989: my $disabled;
3990: if ($noedit) {
3991: $disabled = ' disabled="disabled"';
3992: }
1.50 raeburn 3993: foreach my $cat (@{$classorder}) {
3994: my %curr = ();
3995: ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) =
3996: split(/,/,$settings->{'discussion_post_fonts_'.$cat});
3997: $output .= &Apache::loncommon::start_data_table_row().
3998: '<td>'.$classtitles->{$cat}.'</td>';
3999: if (ref($styleorder) eq 'ARRAY') {
4000: foreach my $item (@{$styleorder}) {
4001: $output .= '<td><span class="LC_nobreak">';
4002: my $selitem = $item;
4003: if ($item eq 'size') {
4004: my ($currsize,$currunit);
4005: if ($curr{'size'} =~ /^(\d+)(px|%)$/) {
4006: ($currsize,$currunit) = ($1,$2);
4007: $curr{'size'} = $currunit;
4008: }
1.81 raeburn 4009: $output .= '<input type="textbox" name="discussion_post_fonts_'.$cat.'_'.$item.'" value="'.$currsize.'" size="5"'.$disabled.' />'.
1.50 raeburn 4010: ' ';
4011: $selitem = 'unit';
4012: }
4013: if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) {
1.80 raeburn 4014: $output .= '<select name="discussion_post_fonts_'.$cat.'_'.$selitem.'"'.$disabled.'>';
1.50 raeburn 4015: foreach my $val (@{$styleitems->{$item}}) {
4016: my $sel;
4017: if ($val eq $curr{$item}) {
4018: $sel = ' selected="selected"';
4019: }
4020: $output .= '<option value="'.$val.'"'.$sel.'>'.$val.'</option>';
4021: }
4022: }
4023: }
4024: }
1.80 raeburn 4025: $output .= '</span></td><td><input type="textbox" size="10" name="discussion_post_fonts_'.$cat.'_other" value="'.$curr{'other'}.'"'.$disabled.' /></td>';
1.50 raeburn 4026: }
4027: $output .= &Apache::loncommon::end_data_table_row();
4028: }
4029: return $output;
4030: }
4031:
4032: sub discussion_vote_classes {
4033: my $classorder = ['twoplus','oneplus','zero','oneminus','twominus'];
4034: my %classtitles = &Apache::lonlocal::texthash(
4035: 'twoplus' => 'Two sigma above mean',
4036: 'oneplus' => 'One sigma above mean',
4037: 'zero' => 'Within one sigma of mean',
4038: 'oneminus' => 'One sigma below mean',
4039: 'twominus' => 'Two sigma below mean',
4040: );
4041: return ($classorder,\%classtitles);
4042: }
4043:
4044: sub discussion_vote_styles {
4045: my $styleorder = ['size','weight','style'];
4046: my $styleitems = {
4047: size => ['','px','%','xx-small','x-small','small','medium','large',
4048: 'x-large','xx-large','smaller','larger'],
4049: weight => ['','normal','bold','bolder','lighter','100','200','300','400',
4050: '500','600','700','800','900'],
4051: style => ['','normal','italic','oblique'],
4052: };
4053: return ($styleorder,$styleitems);
4054: }
4055:
1.1 raeburn 4056: sub print_classlists {
1.80 raeburn 4057: my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 4058: my @ordered;
4059: if ($position eq 'top') {
4060: @ordered = ('default_enrollment_start_date',
4061: 'default_enrollment_end_date');
1.55 raeburn 4062: if ($crstype eq 'Course') {
4063: push(@ordered,'defaultcredits');
4064: }
1.1 raeburn 4065: } elsif ($position eq 'middle') {
1.56 raeburn 4066: @ordered = ('nothideprivileged','checkforpriv');
1.1 raeburn 4067: } else {
4068: @ordered = ('student_classlist_view',
1.26 raeburn 4069: 'student_classlist_opt_in',
4070: 'student_classlist_portfiles');
1.1 raeburn 4071: }
1.9 raeburn 4072: my %lt;
4073:
4074: if ($crstype eq 'Community') {
4075: %lt = &Apache::lonlocal::texthash (
4076: disabled => 'No viewable membership list',
4077: section => "Membership of viewer's section",
4078: all => 'List of all members',
4079: );
4080: } else {
4081: %lt = &Apache::lonlocal::texthash (
4082: disabled => 'No viewable classlist',
4083: section => "Classlist of viewer's section",
4084: all => 'Classlist of all students',
4085: );
4086: }
4087:
1.1 raeburn 4088: my %items = (
4089: 'default_enrollment_start_date' => {
1.3 raeburn 4090: text => '<b>'.&mt($itemtext->{'default_enrollment_start_date'}).'</b>',
1.1 raeburn 4091: input => 'dates',
4092: },
4093: 'default_enrollment_end_date' => {
1.3 raeburn 4094: text => '<b>'.&mt($itemtext->{'default_enrollment_end_date'}).'</b>',
1.1 raeburn 4095: input => 'dates',
4096: },
1.55 raeburn 4097: 'defaultcredits' => {
4098: text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>',
4099: },
4100:
1.1 raeburn 4101: 'nothideprivileged' => {
1.3 raeburn 4102: text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>',
1.1 raeburn 4103: input => 'checkbox',
4104: },
4105:
1.56 raeburn 4106: 'checkforpriv' => {
4107: text => '<b>'.&mt($itemtext->{'checkforpriv'}).'</b>',
4108: input => 'selectbox',
4109: },
4110:
1.1 raeburn 4111: 'student_classlist_view' => {
1.3 raeburn 4112: text => '<b>'.&mt($itemtext->{'student_classlist_view'}).'</b>',
1.1 raeburn 4113: input => 'selectbox',
1.9 raeburn 4114: options => \%lt,
1.1 raeburn 4115: order => ['disabled','all','section'],
4116: },
1.26 raeburn 4117: 'student_classlist_opt_in' => {
4118: text => '<b>'.&mt($itemtext->{'student_classlist_opt_in'}).'</b>',
1.1 raeburn 4119: input => 'radio',
4120: },
4121:
4122: 'student_classlist_portfiles' => {
1.3 raeburn 4123: text => '<b>'.&mt($itemtext->{'student_classlist_portfiles'}).'</b>',
1.1 raeburn 4124: input => 'radio',
4125: },
4126: );
4127: unless (($settings->{'student_classlist_view'} eq 'all') ||
4128: ($settings->{'student_classlist_view'} eq 'section')) {
4129: $settings->{'student_classlist_view'} = 'disabled';
4130: }
1.80 raeburn 4131: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit);
1.1 raeburn 4132: }
4133:
4134: sub print_appearance {
1.80 raeburn 4135: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4136: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4137: return;
4138: }
1.9 raeburn 4139: my $mathdef;
4140: if ($crstype eq 'Community') {
4141: $mathdef = &mt("None specified - use member's choice");
4142: } else {
4143: $mathdef = &mt("None specified - use student's choice");
4144: }
1.1 raeburn 4145: my %items = (
4146: 'default_xml_style' => {
1.3 raeburn 4147: text => '<b>'.&mt($itemtext->{'default_xml_style'}).'</b> '.
1.1 raeburn 4148: '<a href="javascript:openbrowser'.
4149: "('display','default_xml_style'".
4150: ",'sty')".'">'.&mt('Select Style File').'</a>',
4151: input => 'textbox',
4152: size => 35,
4153: },
4154:
4155: 'pageseparators' => {
1.3 raeburn 4156: text => '<b>'.&mt($itemtext->{'pageseparators'}).'</b>',
1.1 raeburn 4157: input => 'radio',
4158: },
4159: 'disable_receipt_display' => {
1.3 raeburn 4160: text => '<b>'.&mt($itemtext->{'disable_receipt_display'}).'</b>',
1.1 raeburn 4161: input => 'radio',
4162: },
4163: 'texengine' => {
1.3 raeburn 4164: text => '<b>'.&mt($itemtext->{'texengine'}).'</b>',
1.1 raeburn 4165: input => 'selectbox',
4166: options => {
1.61 raeburn 4167: MathJax => 'MathJax',
1.1 raeburn 4168: mimetex => &mt('Convert to Images'),
4169: tth => &mt('TeX to HTML'),
4170: },
1.75 raeburn 4171: order => ['MathJax','mimetex','tth'],
1.9 raeburn 4172: nullval => $mathdef,
1.1 raeburn 4173: },
4174: 'tthoptions' => {
1.3 raeburn 4175: text => '<b>'.&mt($itemtext->{'tthoptions'}).'</b>',
1.1 raeburn 4176: input => 'textbox',
4177: size => 40,
4178: },
1.69 raeburn 4179: 'uselcmath' => {
4180: text => '<b>'.&mt($itemtext->{'uselcmath'}).'</b>',
4181: input => 'radio',
4182: },
4183: 'usejsme' => {
4184: text => '<b>'.&mt($itemtext->{'usejsme'}).'</b>',
4185: input => 'radio',
4186: },
1.1 raeburn 4187: );
1.80 raeburn 4188: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit);
1.1 raeburn 4189: }
4190:
4191: sub print_grading {
1.80 raeburn 4192: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4193: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4194: return;
4195: }
4196: my %items = (
4197: 'grading' => {
1.3 raeburn 4198: text => '<b>'.&mt($itemtext->{'grading'}).'</b>'.
1.1 raeburn 4199: &Apache::loncommon::help_open_topic('GradingOptions'),
4200: input => 'selectbox',
4201: options => {
4202: standard => &mt('Standard: shows points'),
1.34 www 4203: categories => &mt('Categories: shows points according to categories'),
1.11 www 4204: external => &mt('External: shows number of completed parts and totals'),
4205: externalnototals => &mt('External: shows only number of completed parts'),
1.1 raeburn 4206: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
4207: },
1.34 www 4208: order => ['standard','categories','external','externalnototals','spreadsheet'],
1.1 raeburn 4209: },
4210: 'rndseed' => {
1.3 raeburn 4211: text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'.
1.17 faziophi 4212: '<span class="LC_warning">'.'<br />'.
1.1 raeburn 4213: &mt('Modifying this will make problems have different numbers and answers!').
4214: '</span>',
4215: input => 'selectbox',
4216: options => {
4217: '32bit' => '32bit',
4218: '64bit' => '64bit',
4219: '64bit2' => '64bit2',
4220: '64bit3' => '64bit3',
4221: '64bit4' => '64bit4',
4222: '64bit5' => '64bit5',
4223: },
4224: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
1.41 www 4225: advanced => 1
1.1 raeburn 4226: },
4227: 'receiptalg' => {
1.3 raeburn 4228: text => '<b>'.&mt($itemtext->{'receiptalg'}).'</b><br />'.
1.5 raeburn 4229: &mt('This controls how receipt numbers are generated'),
1.1 raeburn 4230: input => 'selectbox',
4231: options => {
4232: receipt => 'receipt',
4233: receipt2 => 'receipt2',
4234: receipt3 => 'receipt3',
4235: },
4236: order => ['receipt','receipt2','receipt3'],
1.41 www 4237: advanced => 1
1.1 raeburn 4238: },
4239: 'disablesigfigs' => {
1.3 raeburn 4240: text => '<b>'.&mt($itemtext->{'disablesigfigs'}).'</b>',
1.1 raeburn 4241: input => 'radio',
4242: },
4243: );
1.80 raeburn 4244: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit);
1.1 raeburn 4245: }
4246:
4247: sub print_printouts {
1.80 raeburn 4248: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4249: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4250: return;
4251: }
4252: my %items = (
4253: problem_stream_switch => {
1.3 raeburn 4254: text => '<b>'.&mt($itemtext->{'problem_stream_switch'}).'</b>',
1.1 raeburn 4255: input => 'radio',
4256: },
4257: suppress_tries => {
1.3 raeburn 4258: text => '<b>'.&mt($itemtext->{'suppress_tries'}).'</b>',
1.1 raeburn 4259: input => 'radio',
4260: },
4261: default_paper_size => {
1.3 raeburn 4262: text => '<b>'.&mt($itemtext->{'default_paper_size'}).'</b>',
1.1 raeburn 4263: input => 'selectbox',
4264: options => {
4265: Letter => &mt('Letter').' [8 1/2x11 in]',
4266: Legal => &mt('Legal').' [8 1/2x14 in]',
4267: Tabloid => &mt('Tabloid').' [11x17 in]',
4268: Executive => &mt('Executive').' [7 1/2x10 in]',
4269: A2 => &mt('A2').' [420x594 mm]',
4270: A3 => &mt('A3').' [297x420 mm]',
4271: A4 => &mt('A4').' [210x297 mm]',
4272: A5 => &mt('A5').' [148x210 mm]',
4273: A6 => &mt('A6').' [105x148 mm]',
4274: },
4275: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
1.54 bisitz 4276: nullval => &mt('None specified'),
1.1 raeburn 4277: },
4278: print_header_format => {
1.3 raeburn 4279: text => '<b>'.&mt($itemtext->{'print_header_format'}).'</b>',
1.1 raeburn 4280: input => 'checkbox',
4281: },
4282: disableexampointprint => {
1.3 raeburn 4283: text => '<b>'.&mt($itemtext->{'disableexampointprint'}).'</b>',
1.1 raeburn 4284: input => 'radio',
4285: },
1.14 raeburn 4286: canuse_pdfforms => {
4287: text => '<b>'.&mt($itemtext->{'canuse_pdfforms'}).'</b>',
4288: input => 'selectbox',
4289: options => {
4290: 1 => &mt('Yes'),
4291: 0 => &mt('No'),
4292: },
4293: order => ['1','0'],
1.54 bisitz 4294: nullval => &mt('None specified - use domain default'),
1.14 raeburn 4295: }
1.1 raeburn 4296: );
1.80 raeburn 4297: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit);
1.1 raeburn 4298: }
4299:
4300: sub print_spreadsheet {
1.80 raeburn 4301: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4302: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4303: return;
4304: }
4305: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
4306: my %items = (
4307: spreadsheet_default_classcalc => {
1.3 raeburn 4308: text => '<b>'.&mt($itemtext->{'spreadsheet_default_classcalc'}).'</b> '.
1.1 raeburn 4309: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4310: "('display','spreadsheet_default_classcalc'".
4311: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4312: input => 'textbox',
4313: },
4314: spreadsheet_default_studentcalc => {
1.3 raeburn 4315: text => '<b>'.&mt($itemtext->{'spreadsheet_default_studentcalc'}).'</b> '.
1.1 raeburn 4316: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4317: "('display','spreadsheet_default_calc'".
4318: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4319: input => 'textbox',
4320: },
4321: spreadsheet_default_assesscalc => {
1.3 raeburn 4322: text => '<b>'.&mt($itemtext->{'spreadsheet_default_assesscalc'}).'</b> '.
1.1 raeburn 4323: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
4324: "('display','spreadsheet_default_assesscalc'".
4325: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
4326: input => 'textbox',
4327: },
4328: hideemptyrows => {
1.3 raeburn 4329: text => '<b>'.&mt($itemtext->{'hideemptyrows'}).'</b>',
1.1 raeburn 4330: input => 'radio',
4331: },
4332: );
1.80 raeburn 4333: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit);
1.9 raeburn 4334: }
1.1 raeburn 4335:
4336: sub print_bridgetasks {
1.80 raeburn 4337: my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_;
1.3 raeburn 4338: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
1.1 raeburn 4339: return;
4340: }
1.9 raeburn 4341: my ($stumsg,$msgnote);
4342: if ($crstype eq 'Community') {
4343: $stumsg = &mt('Send message to member');
4344: $msgnote = &mt('Message to member and add to user notes');
4345: } else {
4346: $stumsg = &mt('Send message to student');
4347: $msgnote = &mt('Message to student and add to user notes');
4348: }
1.1 raeburn 4349: my %items = (
4350: task_messages => {
1.3 raeburn 4351: text => '<b>'.&mt($itemtext->{'task_messages'}).'</b>',
1.1 raeburn 4352: input => 'selectbox',
4353: options => {
1.9 raeburn 4354: only_student => $stumsg,
4355: student_and_user_notes_screen => $msgnote,
1.1 raeburn 4356: },
4357: order => ['only_student','student_and_user_notes_screen'],
4358: nullval => &mt('No message or record in user notes'),
4359: },
4360: task_grading => {
1.3 raeburn 4361: text => '<b>'.&mt($itemtext->{'task_grading'}).'</b>',
1.1 raeburn 4362: input => 'selectbox',
4363: options => {
4364: any => &mt('Grade BTs in any section'),
4365: section => &mt('Grade BTs only in own section')
4366: },
4367: order => ['any','section'],
4368: },
4369: suppress_embed_prompt => {
1.3 raeburn 4370: text => '<b>'.&mt($itemtext->{'suppress_embed_prompt'}).'</b><span class="LC_nobreak">'.
4371: ' '.&mt('(applies when current role is student)').'</span>',
1.1 raeburn 4372: input => 'radio',
4373: },
4374: );
1.80 raeburn 4375: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit);
1.1 raeburn 4376: }
4377:
4378: sub print_other {
1.80 raeburn 4379: my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_;
1.1 raeburn 4380: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
4381: return;
4382: }
1.3 raeburn 4383: my @ordered = &get_other_items($cdom,$settings,$allitems);
4384: my %items;
4385: foreach my $parameter (@ordered) {
4386: $items{$parameter} = {
4387: text => '<b>'.$parameter.'</b>',
4388: input => 'textbox',
4389: size => '15',
4390: },
4391: }
4392: push (@ordered,'newp_value');
4393: $items{'newp_value'} = {
4394: text => '<b>'.&mt('Create New Environment Variable').'</b><br />'.
4395: '<input type="textbox" name="newp_name"'.
4396: ' value="" size="30" />',
4397: input => 'textbox',
4398: size => '30',
4399: };
1.80 raeburn 4400: my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit);
1.3 raeburn 4401: }
4402:
4403: sub get_other_items {
4404: my ($cdom,$settings,$allitems) = @_;
4405: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
4406: return;
4407: }
1.1 raeburn 4408: my @ordered;
4409: if (ref($settings) eq 'HASH') {
4410: foreach my $parameter (sort(keys(%{$settings}))) {
4411: next if (grep/^\Q$parameter\E$/,@{$allitems});
1.3 raeburn 4412: next if (($parameter eq 'course.helper.not.run') &&
4413: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
1.1 raeburn 4414: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
4415: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
4416: || ($parameter eq 'type') ||
1.50 raeburn 4417: ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/)
1.62 raeburn 4418: || ($parameter =~ m/^discussion_post_fonts/) ||
1.63 raeburn 4419: ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) ||
4420: ($parameter eq 'clonedfrom')) {
1.1 raeburn 4421: push(@ordered,$parameter);
4422: }
4423: }
4424: }
1.3 raeburn 4425: return @ordered;
1.1 raeburn 4426: }
4427:
4428: sub item_table_row_start {
1.56 raeburn 4429: my ($text,$count,$add_class,$colspan) = @_;
1.1 raeburn 4430: my $output;
1.56 raeburn 4431: my $css_class = ($count % 2) ? 'LC_odd_row' : 'LC_even_row';
4432: $css_class = (join(' ',$css_class,$add_class)) unless ($add_class eq '');
4433: $output .= '<tr class="'.$css_class.'">'."\n".
4434: '<td class="LC_left_item">'.$text.
4435: '</td>';
4436: if ($colspan) {
4437: $output .= '<td class="LC_right_item" colspan="'.$colspan.'">';
4438: } else {
4439: $output .= '<td class="LC_right_item">';
4440: }
1.1 raeburn 4441: return $output;
4442: }
4443:
4444: sub item_table_row_end {
4445: return '</td></tr>';
4446: }
4447:
4448: sub yesno_radio {
1.80 raeburn 4449: my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_;
1.1 raeburn 4450: my $itemon = ' ';
4451: my $itemoff = ' checked="checked" ';
1.69 raeburn 4452: if (($valueyes eq '') && ($valueno eq '')) {
4453: $valueyes = 'yes';
4454: $valueno = '';
4455: }
1.1 raeburn 4456: if (ref($settings) eq 'HASH') {
1.69 raeburn 4457: if ($settings->{$item} eq $valueyes) {
1.1 raeburn 4458: $itemon = $itemoff;
4459: $itemoff = ' ';
4460: }
1.69 raeburn 4461: unless (exists($settings->{$item})) {
4462: if ($unsetdefault eq $valueyes) {
4463: $itemon = $itemoff;
4464: $itemoff = ' ';
4465: }
4466: }
1.1 raeburn 4467: }
1.80 raeburn 4468: my $disabled;
4469: if ($noedit) {
4470: $disabled = ' disabled="disabled"';
4471: }
1.1 raeburn 4472: return '<span class="LC_nobreak"><label>'.
4473: '<input type="radio" name="'.$item.'"'.
1.80 raeburn 4474: $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').'</label> '.
1.1 raeburn 4475: '<label><input type="radio" name="'.$item.'"'.
1.80 raeburn 4476: $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').'</label></span>';
1.1 raeburn 4477: }
4478:
4479: sub select_from_options {
1.80 raeburn 4480: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit) = @_;
1.1 raeburn 4481: my $output;
1.80 raeburn 4482: my $disabled;
4483: if ($noedit) {
4484: $disabled = ' disabled=disabled"';
4485: }
1.1 raeburn 4486: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
4487: $output='<select name="'.$item.'" '.$onchange;
4488: if ($multiple) {
4489: $output .= ' multiple="multiple"';
4490: my $num = @{$order};
4491: $num ++ if ($nullval ne '');
4492: if (($maxsize) && ($maxsize < $num)) {
4493: $output .= ' size="'.$maxsize.'"';
4494: }
4495: }
1.80 raeburn 4496: $output .= $disabled.'>'."\n";
1.1 raeburn 4497: if ($nullval ne '') {
4498: $output .= '<option value=""';
4499: if (ref($curr) eq 'ARRAY') {
4500: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
4501: $output .= ' selected="selected" ';
4502: }
4503: } else {
4504: if ($curr eq '') {
4505: $output .= ' selected="selected" ';
4506: }
4507: }
4508: $output .= '>'.$nullval.'</option>';
4509: }
4510: foreach my $option (@{$order}) {
4511: $output.= '<option value="'.$option.'"';
4512: if (ref($curr) eq 'ARRAY') {
4513: if (grep(/^\Q$option\E$/,@{$curr})) {
4514: $output .= ' selected="selected" ';
4515: }
4516: } else {
4517: if ($option eq $curr) {
4518: $output.=' selected="selected"';
4519: }
4520: }
4521: $output.=">$options->{$option}</option>\n";
4522: }
4523: $output.="</select>";
4524: }
4525: return $output;
4526: }
4527:
4528: sub make_item_rows {
1.80 raeburn 4529: my ($cdom,$items,$ordered,$settings,$rowtotal,$crstype,$caller,$noedit) = @_;
1.1 raeburn 4530: my $datatable;
4531: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
4532: my $count = 0;
4533: foreach my $item (@{$ordered}) {
4534: $count ++;
1.56 raeburn 4535: my $colspan;
4536: if ((($caller eq 'classlists') && ($item eq 'nothideprivileged')) ||
4537: (($caller eq 'printouts') && ($item ne 'print_header_format'))) {
4538: $colspan = 2;
4539: }
1.41 www 4540: if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) {
1.56 raeburn 4541: $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan);
1.41 www 4542: } else {
1.56 raeburn 4543: $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan);
1.41 www 4544: }
1.55 raeburn 4545: if ($item eq 'defaultcredits') {
4546: my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'};
4547: my $showcredits;
4548: if ($defaultcredits ne '') {
4549: $showcredits = &mt('Default is [quant,_1,credit]',$defaultcredits);
4550: } else {
4551: $showcredits = &mt('No default set');
4552: }
4553: $datatable .= $showcredits;
4554: } elsif ($item eq 'nothideprivileged') {
1.80 raeburn 4555: $datatable .= ¬hidepriv_row($cdom,$item,$settings,$crstype,$noedit);
1.56 raeburn 4556: } elsif ($item eq 'checkforpriv') {
1.80 raeburn 4557: $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit);
1.1 raeburn 4558: } elsif ($item eq 'print_header_format') {
1.80 raeburn 4559: $datatable .= &print_hdrfmt_row($item,$settings,$noedit);
1.1 raeburn 4560: } elsif ($items->{$item}{input} eq 'dates') {
1.80 raeburn 4561: my $disabled;
4562: if ($noedit) {
4563: $disabled = ' disabled="disabled"';
4564: }
1.1 raeburn 4565: $datatable .=
4566: &Apache::lonhtmlcommon::date_setter('display',$item,
1.80 raeburn 4567: $settings->{$item},$disabled);
1.1 raeburn 4568: } elsif ($items->{$item}{input} eq 'radio') {
1.69 raeburn 4569: my ($unsetdefault,$valueyes,$valueno);
4570: if (($item eq 'usejsme') || ($item eq 'uselcmath')) {
4571: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
4572: unless ($domdefs{$item} eq '0') {
4573: $unsetdefault = 1;
4574: }
4575: $valueyes = "1";
4576: $valueno = "0";
4577: }
1.80 raeburn 4578: $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit);
1.1 raeburn 4579: } elsif ($items->{$item}{input} eq 'selectbox') {
4580: my $curr = $settings->{$item};
4581: $datatable .=
4582: &select_from_options($item,$items->{$item}{'order'},
4583: $items->{$item}{'options'},$curr,
1.80 raeburn 4584: $items->{$item}{'nullval'},
4585: undef,undef,undef,$noedit);
1.1 raeburn 4586: } elsif ($items->{$item}{input} eq 'textbox') {
1.80 raeburn 4587: my $disabled;
4588: if ($noedit) {
4589: $disabled = ' disabled=disabled"';
4590: }
1.1 raeburn 4591: $datatable .=
4592: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
1.80 raeburn 4593: $items->{$item}{size},
4594: $disabled);
1.1 raeburn 4595: }
4596: $datatable .= &item_table_row_end();
4597: }
4598: if (ref($rowtotal)) {
4599: $$rowtotal += scalar(@{$ordered});
4600: }
4601: }
4602: return $datatable;
4603: }
4604:
4605: sub nothidepriv_row {
1.80 raeburn 4606: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.1 raeburn 4607: my ($cnum) = &get_course();
1.56 raeburn 4608: my ($datatable,%nothide,@checkdoms);
1.1 raeburn 4609: if (ref($settings) eq 'HASH') {
4610: if ($settings->{$item} ne '') {
4611: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
4612: if ($user !~ /:/) {
4613: $nothide{join(':',split(/[\@]/,$user))}=1;
4614: } else {
4615: $nothide{$user} = 1;
4616: }
4617: }
4618: }
1.56 raeburn 4619: if ($settings->{'checkforpriv'}) {
4620: @checkdoms = split(/,/,$settings->{'checkforpriv'});
4621: }
1.1 raeburn 4622: }
1.56 raeburn 4623: push(@checkdoms,$cdom);
4624: my %coursepersonnel =
4625: &Apache::lonnet::get_my_roles($cnum,$cdom,'',['previous','future','active']);
1.1 raeburn 4626: my @privusers;
4627: foreach my $person (keys(%coursepersonnel)) {
1.56 raeburn 4628: my ($uname,$udom,$role) = split(/:/,$person);
4629: my $user = $uname.':'.$udom;
4630: my ($start,$end) = split(/:/,$coursepersonnel{$person});
1.1 raeburn 4631: if ($end == -1 || $start == -1) {
4632: next;
4633: }
1.56 raeburn 4634: foreach my $dom (@checkdoms) {
4635: if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) {
4636: unless (grep(/^\Q$user\E$/,@privusers)) {
4637: push(@privusers,$user);
1.3 raeburn 4638: }
4639: }
4640: }
1.1 raeburn 4641: }
1.56 raeburn 4642: if (@privusers > 0) {
1.80 raeburn 4643: my $disabled;
4644: if ($noedit) {
4645: $disabled = ' disabled="disabled"';
4646: }
1.1 raeburn 4647: $datatable .= '<table align="right">';
4648: foreach my $user (sort(@privusers)) {
4649: my $hideon = ' checked="checked" ';
4650: my $hideoff = '';
4651: if ($nothide{$user}) {
4652: $hideoff = $hideon;
4653: $hideon = '';
4654: }
4655: my ($uname,$udom) = split(':',$user);
4656: $datatable .= '<tr><td align="left">'.
4657: &Apache::loncommon::aboutmewrapper(
4658: &Apache::loncommon::plainname($uname,$udom,'firstname'),
4659: $uname,$udom,'aboutuser').
4660: '</td><td align="left">'.
4661: '<span class="LC_nobreak"><label>'.
4662: '<input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 4663: $hideon.' value=""'.$disabled.' />'.&mt('Hidden').'</label> '.
1.69 raeburn 4664: '<label><input type="radio" name="'.$item.'_'.$user.'"'.
1.80 raeburn 4665: $hideoff.' value="yes"'.$disabled.' />'.&mt('Shown').'</label></span></td>'.
1.1 raeburn 4666: '</tr>';
4667: }
4668: $datatable .= '</table>';
4669: } else {
1.9 raeburn 4670: if ($crstype eq 'Community') {
4671: $datatable .= &mt('No Domain Coordinators have community roles');
4672: } else {
4673: $datatable .= &mt('No Domain Coordinators have course roles');
4674: }
1.1 raeburn 4675: }
4676: return $datatable;
4677: }
4678:
1.56 raeburn 4679: sub checkforpriv_row {
1.80 raeburn 4680: my ($cdom,$item,$settings,$crstype,$noedit) = @_;
1.56 raeburn 4681: my $datatable;
4682: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
4683: if (keys(%domains) == 1) {
4684: $datatable = '</td><td align="right">'.
4685: &mt("Course's domain is only domain");
4686: return $datatable;
4687: }
4688: my @excdoms = ($cdom);
4689: my $num = 0;
4690: if ($settings->{$item} eq '') {
4691: $datatable = '</td><td align="right">'.
4692: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,
1.80 raeburn 4693: 1,1,undef,undef,\@excdoms,
4694: $noedit);
1.56 raeburn 4695: } else {
4696: my @privdoms = split(/,/,$settings->{$item});
4697: my %domains=map { $_ => 1; } &Apache::lonnet::all_domains();
4698: $datatable = '</td><td align="right"><br />'.
4699: &Apache::loncommon::start_data_table();
1.80 raeburn 4700: my $disabled;
4701: if ($noedit) {
4702: $disabled = ' disabled="disabled"';
4703: }
1.56 raeburn 4704: if (@privdoms > 0) {
4705: foreach my $currdom (@privdoms) {
4706: next unless ($domains{$currdom});
4707: my $domdesc = &Apache::lonnet::domain($currdom,'description');
4708: if ($domdesc eq '') {
4709: $domdesc = $currdom;
4710: }
4711: $datatable .=
4712: &Apache::loncommon::start_data_table_row().
4713: '<td align="left"><span class="LC_nobreak">'.
4714: &mt('Domain:').'<b> '.$domdesc.
4715: '</b><input type="hidden" name="checkforpriv_'.$num.
4716: '" value="'.$currdom.'" /></span><br />'.
4717: '<span class="LC_nobreak"><label><input type="checkbox" '.
1.82 raeburn 4718: 'name="checkforpriv_delete" value="'.$num.'"'.$disabled.' />'.
4719: &mt('Delete').'</label></span></td>'.
1.56 raeburn 4720: &Apache::loncommon::end_data_table_row();
4721: $num ++;
4722: unless (grep(/^\Q$currdom\E$/,@excdoms)) {
4723: push(@excdoms,$currdom);
4724: }
4725: }
4726: }
4727: if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) {
4728: $datatable .=
4729: &Apache::loncommon::start_data_table_row().
4730: '<td align="left"><span class="LC_nobreak">'.
4731: &mt('Additional domain:'). '</span><br />'.
4732: &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1,
1.80 raeburn 4733: 1,undef,undef,\@excdoms,$noedit).
1.56 raeburn 4734: '</td>'.&Apache::loncommon::end_data_table_row();
4735: }
4736: $datatable .= &Apache::loncommon::end_data_table().
4737: '<input type="hidden" name="checkforpriv_total" value="'.$num.'" />'.
4738: '<br />';
4739: }
4740: return $datatable;
4741: }
4742:
1.1 raeburn 4743: sub print_hdrfmt_row {
1.80 raeburn 4744: my ($item,$settings,$noedit) = @_;
1.1 raeburn 4745: my @curr;
4746: my $currnum = 0;
4747: my $maxnum = 2;
4748: my $currstr;
4749: if ($settings->{$item} ne '') {
4750: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
4751: $settings->{$item}.'</tt></span></b><br />';
4752: my @current = split(/(%\d*[nca])/,$settings->{$item});
1.23 raeburn 4753: foreach my $val (@current) {
4754: unless ($val eq '') {
4755: push(@curr,$val);
1.1 raeburn 4756: }
4757: }
4758: $currnum = @curr;
4759: $maxnum += $currnum;
4760: }
4761:
4762: my $output = <<ENDJS;
4763:
4764: <script type="text/javascript" language="Javascript">
4765:
4766: function reOrder(chgnum) {
4767: var maxnum = $maxnum;
4768: var oldidx = 'printfmthdr_oldpos_'+chgnum;
4769: var newidx = 'printfmthdr_pos_'+chgnum;
4770: oldidx = getIndexByName(oldidx);
4771: newidx = getIndexByName(newidx);
4772: var oldpos = document.display.elements[oldidx].value;
4773: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4774: document.display.elements[oldidx].value = newpos;
4775: var chgtype = 'up';
4776: if (newpos < oldpos) {
4777: chgtype = 'down';
4778: }
4779: for (var j=0; j<maxnum; j++) {
4780: if (j != chgnum) {
4781: oldidx = 'printfmthdr_oldpos_'+j;
4782: newidx = 'printfmthdr_pos_'+j;
4783: oldidx = getIndexByName(oldidx);
4784: newidx = getIndexByName(newidx);
4785: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4786: var currsel = document.display.elements[newidx].selectedIndex;
4787: if (chgtype == 'up') {
4788: if ((currpos > oldpos) && (currpos <= newpos)) {
4789: document.display.elements[newidx].selectedIndex = currsel-1;
4790: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4791: }
4792: } else {
4793: if ((currpos >= newpos) && (currpos < oldpos)) {
4794: document.display.elements[newidx].selectedIndex = currsel+1;
4795: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
4796: }
4797: }
4798: }
4799: }
4800: return;
4801: }
4802:
4803: function getIndexByName(item) {
4804: for (var i=0;i<document.display.elements.length;i++) {
4805: if (document.display.elements[i].name == item) {
4806: return i;
4807: }
4808: }
4809: return -1;
4810: }
4811:
4812: </script>
4813:
4814: ENDJS
1.56 raeburn 4815: $output .= '</td><td align="right"><br />'.
4816: $currstr.'<table class="LC_data_table">';
1.80 raeburn 4817: my $disabled;
4818: if ($noedit) {
4819: $disabled = ' disabled="disabled"';
4820: }
1.1 raeburn 4821: if (@curr > 0) {
4822: for (my $i=0; $i<@curr; $i++) {
4823: my $pos = $i+1;
1.10 raeburn 4824: $output .= '<tr>'.
1.1 raeburn 4825: '<td align="left"><span class="LC_nobreak">'.
1.80 raeburn 4826: &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:').
1.1 raeburn 4827: '<input type="checkbox" name="printfmthdr_del_'.$i.
1.80 raeburn 4828: '"'.$disabled.' /></span></td>';
1.1 raeburn 4829: if ($curr[$i] =~ /^%\d*[nca]$/) {
4830: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
4831: $output .= '<td align="left">'.
1.80 raeburn 4832: &substitution_selector($i,$subst,$limit,$disabled).'</td>';
1.1 raeburn 4833: } else {
4834: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
4835: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
1.80 raeburn 4836: ' value="'.$curr[$i].'" size="25"'.$disabled.' /></td>';
1.1 raeburn 4837: }
1.10 raeburn 4838: $output .= '</tr>';
1.1 raeburn 4839: }
4840: }
1.80 raeburn 4841: my $pos = $currnum+1;
4842: unless ($noedit) {
4843: $output .=
4844: '<tr>'.
1.1 raeburn 4845: '<td align="left"><span class="LC_nobreak">'.
4846: &position_selector($pos,$currnum,$maxnum).
4847: '<b>'.&mt('New').'</b></span></td><td align="left">'.
4848: &substitution_selector($currnum).'</td>'.
1.10 raeburn 4849: '</tr>';
1.80 raeburn 4850: $pos ++;
1.82 raeburn 4851: $currnum ++;
4852: $output .=
1.80 raeburn 4853: '<tr>'.
1.1 raeburn 4854: '<td align="left"><span class="LC_nobreak">'.
4855: &position_selector($pos,$currnum,$maxnum).
4856: '<b>'.&mt('New').'</b></span></td>'.
4857: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
4858: '<input type="textbox" name="printfmthdr_text_'.$currnum.
1.3 raeburn 4859: '" value="" size ="25" />'.
4860: '<input type="hidden" name="printfmthdr_maxnum" value="'.
4861: $maxnum.'" /></td>'.
1.80 raeburn 4862: '</tr>';
4863: }
4864: $output .= '</table><br />';
1.1 raeburn 4865: return $output;
4866: }
4867:
4868: sub position_selector {
1.80 raeburn 4869: my ($pos,$num,$maxnum,$disabled) = @_;
4870: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');"'.$disabled.'>';
1.1 raeburn 4871: for (my $j=1; $j<=$maxnum; $j++) {
4872: my $sel = '';
4873: if ($pos == $j) {
4874: $sel = ' selected="selected"';
4875: }
4876: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
4877: }
4878: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
4879: '" value="'.$pos.'" />';
4880: return $output;
4881: }
4882:
4883: sub substitution_selector {
1.80 raeburn 4884: my ($num,$subst,$limit,$crstype,$disabled) = @_;
1.9 raeburn 4885: my ($stunametxt,$crsidtxt);
4886: if ($crstype eq 'Community') {
4887: $stunametxt = 'member name';
4888: $crsidtxt = 'community ID',
4889: } else {
4890: $stunametxt = 'student name';
4891: $crsidtxt = 'course ID',
4892: }
1.1 raeburn 4893: my %lt = &Apache::lonlocal::texthash(
1.9 raeburn 4894: n => $stunametxt,
4895: c => $crsidtxt,
1.1 raeburn 4896: a => 'assignment note',
4897: );
4898: my $output .= &mt('Substitution').'<br />'.
1.80 raeburn 4899: '<select name="printfmthdr_sub_'.$num.'"'.$disabled.'>';
1.1 raeburn 4900: if ($subst eq '') {
4901: $output .= '<option value="" selected="selected"> </option>';
4902: }
4903: foreach my $field ('n','c','a') {
4904: my $sel ='';
4905: if ($subst eq $field) {
4906: $sel = ' selected="selected"';
4907: }
4908: $output .= '<option value="'.$field.'"'.$sel.'>'.
4909: $lt{$field}.'</option>';
4910: }
4911: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
4912: '<input type="textbox" name="printfmthdr_limit_'.$num.
1.82 raeburn 4913: '" value="'.$limit.'" size="5"'.$disabled.' /></span>';
1.1 raeburn 4914: return $output;
4915: }
4916:
1.23 raeburn 4917: sub change_clone {
4918: my ($cdom,$cnum,$clonelist,$oldcloner) = @_;
4919: my $clone_crs = $cnum.':'.$cdom;
4920: if ($cnum && $cdom) {
4921: my $clone_crs = $cnum.':'.$cdom;
4922: my @allowclone;
4923: if ($clonelist =~ /,/) {
4924: @allowclone = split(',',$clonelist);
4925: } else {
4926: $allowclone[0] = $clonelist;
4927: }
4928: foreach my $currclone (@allowclone) {
4929: if (!grep(/^$currclone$/,@$oldcloner)) {
4930: if ($currclone ne '*') {
1.71 raeburn 4931: if ($currclone =~ /:/) {
4932: my ($uname,$udom) = split(/:/,$currclone);
4933: if ($uname && $udom && $uname ne '*') {
4934: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4935: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4936: if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {
4937: if ($currclonecrs{'cloneable'} eq '') {
4938: $currclonecrs{'cloneable'} = $clone_crs;
4939: } else {
4940: $currclonecrs{'cloneable'} .= ','.$clone_crs;
4941: }
4942: &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);
1.23 raeburn 4943: }
4944: }
4945: }
4946: }
4947: }
4948: }
4949: }
4950: foreach my $oldclone (@$oldcloner) {
4951: if (!grep(/^\Q$oldclone\E$/,@allowclone)) {
4952: if ($oldclone ne '*') {
1.71 raeburn 4953: if ($oldclone =~ /:/) {
4954: my ($uname,$udom) = split(/:/,$oldclone);
4955: if ($uname && $udom && $uname ne '*' ) {
4956: if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {
4957: my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');
4958: my %newclonecrs = ();
4959: if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {
4960: if ($currclonecrs{'cloneable'} =~ /,/) {
4961: my @currclonecrs = split/,/,$currclonecrs{'cloneable'};
4962: foreach my $crs (@currclonecrs) {
4963: if ($crs ne $clone_crs) {
4964: $newclonecrs{'cloneable'} .= $crs.',';
4965: }
1.23 raeburn 4966: }
1.71 raeburn 4967: $newclonecrs{'cloneable'} =~ s/,$//;
4968: } else {
4969: $newclonecrs{'cloneable'} = '';
1.23 raeburn 4970: }
1.71 raeburn 4971: &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);
1.23 raeburn 4972: }
4973: }
4974: }
4975: }
4976: }
4977: }
4978: }
4979: }
4980: return;
4981: }
4982:
1.1 raeburn 4983: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>