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