Annotation of loncom/interface/courseprefs.pm, revision 1.1
1.1 ! raeburn 1: # The LearningOnline Network with CAPA
! 2: # Handler to set domain-wide configuration settings
! 3: #
! 4: # $Id: courseprefs.pm,v 1.1 2009/04/26 01:02:32 raeburn Exp $
! 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:
! 31: package Apache::courseprefs;
! 32:
! 33: use strict;
! 34: use Apache::Constants qw(:common :http);
! 35: use Apache::lonnet;
! 36: use Apache::loncommon();
! 37: use Apache::lonhtmlcommon();
! 38: use Apache::lonconfigsettings;
! 39: use Apache::lonlocal;
! 40: use LONCAPA qw(:DEFAULT :match);
! 41:
! 42: sub handler {
! 43: my $r=shift;
! 44: if ($r->header_only) {
! 45: &Apache::loncommon::content_type($r,'text/html');
! 46: $r->send_http_header;
! 47: return OK;
! 48: }
! 49: my $context = 'course';
! 50: my $cid = $env{'request.course.id'};
! 51: my ($cnum,$cdom) = &get_course($cid);
! 52: my $crstype = &Apache::loncommon::course_type();
! 53: my $parm_permission = &Apache::lonnet::allowed('opa',$cid);
! 54: my $navmap = Apache::lonnavmaps::navmap->new();
! 55: if ($parm_permission && $navmap) {
! 56: &Apache::loncommon::content_type($r,'text/html');
! 57: $r->send_http_header;
! 58: } else {
! 59: if ($navmap) {
! 60: $env{'user.error.msg'}=
! 61: "/adm/courseprefs:mau:0:0:Cannot modify course settings";
! 62: } else {
! 63: $env{'user.error.msg'}=
! 64: "/adm/courseprefs::0:1:Course environment gone, reinitialize the course";
! 65: }
! 66: return HTTP_NOT_ACCEPTABLE;
! 67: }
! 68:
! 69: &Apache::lonhtmlcommon::clear_breadcrumbs();
! 70: &Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/courseprefs',
! 71: text=>"Course Configuration"});
! 72: my $breadcrumbs =
! 73: &Apache::lonhtmlcommon::breadcrumbs('Edit Course Configuration');
! 74:
! 75: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
! 76: ['phase','actions']);
! 77:
! 78: my $phase = 'pickactions';
! 79: if ( exists($env{'form.phase'}) ) {
! 80: $phase = $env{'form.phase'};
! 81: }
! 82:
! 83: if ($phase eq 'categorizecourse') {
! 84: &assign_course_categories($r);
! 85: return OK;
! 86: }
! 87:
! 88: my %values=&Apache::lonnet::dump('environment',$cdom,$cnum);
! 89: my @prefs_order = ('courseinfo','localization','feedback','discussion',
! 90: 'classlists','appearance','grading','printouts',
! 91: 'spreadsheet','bridgetasks','other');
! 92:
! 93: my %prefs = (
! 94: 'courseinfo' =>
! 95: { text => 'General course settings',
! 96: help => 'Course_Environment',
! 97: header => [{col1 => 'Setting',
! 98: col2 => 'Value'}],
! 99: ordered => ['description','courseid','categories',
! 100: 'hidefromcat','cloners','externalsyllabus',
! 101: 'url','rolenames'],
! 102: },
! 103: 'localization' =>
! 104: { text => 'Language/TimeZone/Locale',
! 105: help => 'Course_Environment',
! 106: header => [{col1 => 'Setting',
! 107: col2 => 'Value',}],
! 108: ordered => ['languages','timezone','datelocale'],
! 109: },
! 110: 'feedback' =>
! 111: { text => 'Feedback messages',
! 112: help => 'Course_Environment',
! 113: header => [{col1 => 'Questions about:',
! 114: col2 => 'Recipients'},
! 115: {col1 => 'Questions about:',
! 116: col2 => 'Custom Text'}],
! 117: ordered => ['question','comment','policy'],
! 118: },
! 119: 'discussion' =>
! 120: { text => 'Discussion and Chat',
! 121: help => 'Course_Environment',
! 122: header => [{col1 => 'Setting',
! 123: col2 => 'Value',}],
! 124: ordered => ['plc.roles.denied','plc.users.denied',
! 125: 'pch.roles.denied','pch.users.denied',
! 126: 'allow_limited_html_in_feedback',
! 127: 'allow_discussion_post_editing'],
! 128: },
! 129: 'classlists' =>
! 130: { text => 'Classlists and Staff Listing',
! 131: help => 'Course_Environment',
! 132: header => [{col1 => 'Type',
! 133: col2 => 'Default dates for student access'},
! 134: {col1 => 'Setting',
! 135: col2 => 'Privileged users (Domain Coordinators) in staff listing'},
! 136: {col1 => 'Setting',
! 137: col2 => 'Student-viewable classlist options'}],
! 138: ordered => ['default_enrollment_start_date',
! 139: 'default_enrollment_end_date',
! 140: 'nothideprivileged','student_classlist_view',
! 141: 'student_opt_in','student_classlist_portfiles'],
! 142: },
! 143: 'appearance' =>
! 144: { text => 'Display of resources ',
! 145: help => 'Course_Environment',
! 146: header => [{col1 => 'Setting',
! 147: col2 => 'Value'}],
! 148: ordered => ['default_xml_style','pageseparators',
! 149: 'disable_receipt_display','texengine',
! 150: 'tthoptions'],
! 151: },
! 152: 'grading' =>
! 153: { text => 'Grading',
! 154: help => 'Course_Environment',
! 155: header => [{col1 => 'Setting',
! 156: col2 => 'Value',}],
! 157: ordered => ['grading','rndseed',
! 158: 'receiptalg','disablesigfigs'],
! 159: },
! 160: 'printouts' =>
! 161: { text => 'Printout generation',
! 162: help => 'Course_Environment',
! 163: header => [{col1 => 'Setting',
! 164: col2 => 'Value',}],
! 165: ordered => ['problem_stream_switch','suppress_tries',
! 166: 'default_paper_size','print_header_format',
! 167: 'disableexampointprint'],
! 168: },
! 169: 'spreadsheet' =>
! 170: { text => 'Spreadsheets',
! 171: help => 'Course_Environment',
! 172: header => [{col1 => 'Setting',
! 173: col2 => 'Value'}],
! 174: ordered => ['spreadsheet_default_classcalc',
! 175: 'spreadsheet_default_studentcalc',
! 176: 'spreadsheet_default_assesscalc','hideemptyrows'],
! 177: },
! 178: 'bridgetasks' =>
! 179: { text => 'Bridge tasks',
! 180: help => 'Course_Environment',
! 181: header => [{col1 => 'Setting',
! 182: col2 => 'Value'}],
! 183: ordered => ['task_messages','task_grading',
! 184: 'suppress_embed_prompt'],
! 185: },
! 186: 'other' =>
! 187: { text => 'Other settings',
! 188: help => 'Course_Environment',
! 189: header => [ {col1 => 'Item',
! 190: col2 => 'Value',
! 191: }],
! 192: },
! 193: );
! 194: if ($phase eq 'process') {
! 195: &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context,
! 196: \@prefs_order,\%prefs,\%values);
! 197: } elsif ($phase eq 'display') {
! 198: my $jscript = &get_jscript($cdom);
! 199: my @allitems;
! 200: foreach my $item (keys(%prefs)) {
! 201: if (ref($prefs{$item}) eq 'HASH') {
! 202: if (ref($prefs{$item}{'ordered'}) eq 'ARRAY') {
! 203: push(@allitems,@{$prefs{$item}{'ordered'}});
! 204: if ($item eq 'feedback') {
! 205: push(@allitems,(map { $_.'.email'; } @{$prefs{$item}{'ordered'}}));
! 206: }
! 207: }
! 208: }
! 209: }
! 210: &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
! 211: \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems);
! 212: } else {
! 213: &Apache::lonconfigsettings::display_choices($r,$phase,$context,
! 214: \@prefs_order,\%prefs);
! 215: }
! 216: return OK;
! 217: }
! 218:
! 219: sub print_config_box {
! 220: my ($r,$cdom,$phase,$action,$item,$settings,$allitems) = @_;
! 221: my $ordered = $item->{'ordered'};
! 222: my $rowtotal = 0;
! 223: my $output =
! 224: '<table class="LC_nested_outer">
! 225: <tr>
! 226: <th align="left" valign="middle"><span class="LC_font_larger">'.
! 227: &mt($item->{text}).' '.
! 228: &Apache::loncommon::help_open_topic($item->{'help'}).'</span></th>'."\n".
! 229: '</tr>';
! 230: if (($action eq 'feedback') || ($action eq 'classlists')) {
! 231: $output .= '
! 232: <tr>
! 233: <td>
! 234: <table class="LC_nested">
! 235: <tr class="LC_info_row">
! 236: <td class="LC_left_item">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
! 237: <td class="LC_right_item">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
! 238: </tr>';
! 239: $rowtotal ++;
! 240: if ($action eq 'feedback') {
! 241: $output .= &print_feedback('top',$cdom,$settings,$ordered,\$rowtotal);
! 242: } elsif ($action eq 'classlists') {
! 243: $output .= &print_classlists('top',$cdom,$settings,\$rowtotal);
! 244: }
! 245: $output .= '
! 246: </table>
! 247: </td>
! 248: </tr>
! 249: <tr>
! 250: <td>
! 251: <table class="LC_nested">
! 252: <tr class="LC_info_row">
! 253: <td class="LC_left_item">'.&mt($item->{'header'}->[1]->{'col1'}).'</td>';
! 254: $output .= '
! 255: <td class="LC_right_item">'.&mt($item->{'header'}->[1]->{'col2'}).'</td>
! 256: </tr>';
! 257: if ($action eq 'classlists') {
! 258: $output .= &print_classlists('middle',$cdom,$settings,\$rowtotal).
! 259: '
! 260: </table>
! 261: </td>
! 262: </tr>
! 263: <tr>
! 264: <td>
! 265: <table class="LC_nested">
! 266: <tr class="LC_info_row">
! 267: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
! 268: <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>
! 269: </tr>';
! 270: }
! 271: } else {
! 272: $output .= '
! 273: <tr>
! 274: <td>
! 275: <table class="LC_nested">
! 276: <tr class="LC_info_row">
! 277: <td class="LC_left_item" valign="top">'.&mt($item->{'header'}->[0]->{'col1'}).'</td>
! 278: <td class="LC_right_item" valign="top">'.&mt($item->{'header'}->[0]->{'col2'}).'</td>
! 279: </tr>';
! 280: }
! 281: $rowtotal ++;
! 282: if ($action eq 'courseinfo') {
! 283: $output .= &print_courseinfo($cdom,$settings,$ordered,\$rowtotal);
! 284: } elsif ($action eq 'localization') {
! 285: $output .= &print_localization($cdom,$settings,$ordered,\$rowtotal);
! 286: } elsif ($action eq 'feedback') {
! 287: $output .= &print_feedback('bottom',$cdom,$settings,$ordered,\$rowtotal);
! 288: } elsif ($action eq 'discussion') {
! 289: $output .= &print_discussion($cdom,$settings,$ordered,\$rowtotal);
! 290: } elsif ($action eq 'classlists') {
! 291: $output .= &print_classlists('bottom',$cdom,$settings,\$rowtotal);
! 292: } elsif ($action eq 'appearance') {
! 293: $output .= &print_appearance($cdom,$settings,$ordered,\$rowtotal);
! 294: } elsif ($action eq 'grading') {
! 295: $output .= &print_grading($cdom,$settings,$ordered,\$rowtotal);
! 296: } elsif ($action eq 'printouts') {
! 297: $output .= &print_printouts($cdom,$settings,$ordered,\$rowtotal);
! 298: } elsif ($action eq 'spreadsheet') {
! 299: $output .= &print_spreadsheet($cdom,$settings,$ordered,\$rowtotal);
! 300: } elsif ($action eq 'bridgetasks') {
! 301: $output .= &print_bridgetasks($cdom,$settings,$ordered,\$rowtotal);
! 302: } elsif ($action eq 'other') {
! 303: $output .= &print_other($cdom,$settings,$allitems,\$rowtotal);
! 304: }
! 305: $output .= '
! 306: </table>
! 307: </td>
! 308: </tr>
! 309: </table><br />';
! 310: return ($output,$rowtotal);
! 311: }
! 312:
! 313: sub process_changes {
! 314: my ($r,$cdom,$action,$values) = @_;
! 315: my %domconfig;
! 316: if (ref($values) eq 'HASH') {
! 317: %domconfig = %{$values};
! 318: }
! 319: return &modify_crsenv($action,$cdom,%domconfig);
! 320: }
! 321:
! 322: sub get_course {
! 323: my ($courseid) = @_;
! 324: if (!defined($courseid)) {
! 325: $courseid = $env{'request.course.id'};
! 326: }
! 327: my $cdom=$env{'course.'.$courseid.'.domain'};
! 328: my $cnum=$env{'course.'.$courseid.'.num'};
! 329: return ($cnum,$cdom);
! 330: }
! 331:
! 332: sub get_jscript {
! 333: my ($cdom) = @_;
! 334: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom);
! 335: my ($jscript,$categorize_js);
! 336: my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
! 337: my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset');
! 338: if ($can_categorize) {
! 339: $categorize_js = <<ENDSCRIPT;
! 340: function catsbrowser() {
! 341: var catswin = null;
! 342: var url = '/adm/courseprefs?phase=categorizecourse';
! 343: if (!catswin || catswin.closed) {
! 344: catswin=window.open(url,'categorieswin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
! 345: } else {
! 346: catswin.focus();
! 347: }
! 348: }
! 349: ENDSCRIPT
! 350: }
! 351: $jscript = '<script type="text/javascript" language="Javascript">'."\n".
! 352: $browse_js."\n".$categorize_js."\n".'</script>'."\n".$stubrowse_js."\n";
! 353: return $jscript;
! 354: }
! 355:
! 356: sub print_courseinfo {
! 357: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 358: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 359: return;
! 360: }
! 361: my ($cathash,$categoriesform);
! 362: my $crstype = &Apache::loncommon::course_type();
! 363: my %domconf =
! 364: &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
! 365: if (ref($domconf{'coursecategories'}) eq 'HASH') {
! 366: $cathash = $domconf{'coursecategories'}{'cats'};
! 367: if (ref($cathash) eq 'HASH') {
! 368: $categoriesform =
! 369: &Apache::loncommon::assign_categories_table($cathash,
! 370: $settings->{'categories'})."\n";
! 371: }
! 372: }
! 373: if (!defined($categoriesform)) {
! 374: $categoriesform = &mt('No categories defined for this domain');
! 375: }
! 376:
! 377: my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom);
! 378:
! 379: my %items = (
! 380: 'url' => {
! 381: text => '<b>'.&mt('Top Level Map').'</b>'.(' 'x2).
! 382: '<a href="javascript:openbrowser'.
! 383: "('display','url','sequence')\">".
! 384: &mt('Select Map').'</a><br /><span class="LC_warning"> '.
! 385: &mt('Modification may make assessment data inaccessible!').
! 386: '</span>',
! 387: input => 'textbox',
! 388: size => '40',
! 389: },
! 390: 'description' => {
! 391: text => '<b>'.&mt('Course Description').'</b>',
! 392: input => 'textbox',
! 393: size => '25',
! 394: },
! 395: 'courseid' => {
! 396: text => '<b>'.&mt('Course ID or number').
! 397: '</b><br />'.
! 398: '('.&mt('internal, optional').')',
! 399: input => 'textbox',
! 400: size => '25',
! 401: },
! 402: 'cloners' => {
! 403: text => '<b>'.&mt('Users allowed to clone course').'</b><br />'.
! 404: &mt('Course Coordinators included automatically'),
! 405: input => 'textbox',
! 406: size => '40',
! 407: },
! 408: 'rolenames' => {
! 409: text => '<b>'.&mt('Replacement titles for standard course roles').'</b><br />'.
! 410: '('.&mt('To replace the standard title for a course role, enter a title, otherwise leave blank').')',
! 411: input => 'textbox',
! 412: size => '20',
! 413: },
! 414: 'externalsyllabus' => {
! 415: text => '<b>'.&mt('URL of Syllabus').'</b><br />('.&mt('not using internal handler)'),
! 416: input => 'textbox',
! 417: size => '40',
! 418: },
! 419: 'hidefromcat' => {
! 420: text => '<b>'.&mt('Exclude from course catalog').'</b><br />'.
! 421: ' ('.&mt('included by default if assigned institutional code, or categorized').')',
! 422: input => 'radio',
! 423: },
! 424: 'categories' => {
! 425: text => '<b>'.&mt('Categorize course').'</b> <a href="javascript:catsbrowser()">'.
! 426: &mt('Display Categories').'</a>',
! 427: input => 'textbox',
! 428: size => '25',
! 429: },
! 430: );
! 431: my $datatable;
! 432: my $count = 0;
! 433: foreach my $item (@{$ordered}) {
! 434: if ($item eq 'hidefromcat') {
! 435: next if (!$can_toggle_cat);
! 436: } elsif ($item eq 'categories') {
! 437: next if (!$can_categorize);
! 438: }
! 439: $count ++;
! 440: $datatable .= &item_table_row_start($items{$item}{text},$count);
! 441: if ($items{$item}{input} eq 'radio') {
! 442: $datatable .= &yesno_radio($item,$settings);
! 443: } elsif ($item eq 'cloners') {
! 444: my $includeempty = 1;
! 445: my $num = 0;
! 446: $datatable .= &Apache::loncommon::start_data_table().
! 447: &Apache::loncommon::start_data_table_row().
! 448: '<td><span class="LC_nobreak"><label>'.
! 449: &mt('Any user in any domain:').
! 450: ' <input type="radio" name="cloners_all" value="1" ';
! 451: if ($settings->{$item} eq '*') {
! 452: $datatable .= ' checked="checked" ';
! 453: }
! 454: $datatable .= 'onchange="javascript:update_cloners('.
! 455: "'cloners_all'".');" />'.&mt('Yes').'</label>'.
! 456: (' 'x2).'<input type="radio" name="cloners_all" value="0" ';
! 457: if ($settings->{$item} ne '*') {
! 458: $datatable .= ' checked="checked" ';
! 459: }
! 460: $datatable .= ' onchange="javascript:update_cloners('.
! 461: "'cloners_all'".');"/>'.&mt('No').'</label></td>'.
! 462: &Apache::loncommon::end_data_table_row().
! 463: &Apache::loncommon::end_data_table().
! 464: '<table><tr><td align="left">'.&mt('Or').
! 465: '</td></tr></table>'.
! 466: &Apache::loncommon::start_data_table();
! 467: my @cloners;
! 468: if ($settings->{$item} eq '') {
! 469: $datatable .= &new_cloners_dom_row($cdom,'0');
! 470: } elsif ($settings->{$item} ne '*') {
! 471: my @entries = split(/,/,$settings->{$item});
! 472: if (@entries > 0) {
! 473: foreach my $entry (@entries) {
! 474: my ($uname,$udom) = split(/:/,$entry);
! 475: if ($uname eq '*') {
! 476: $datatable .=
! 477: &Apache::loncommon::start_data_table_row().
! 478: '<td valign="top"><span class="LC_nobreak">'.
! 479: &mt('Domain:').'<b> '.$udom.
! 480: '</b><input type="hidden" name="cloners_dom_'.$num.
! 481: '" value="'.$udom.'" /></span><br />'.
! 482: '<span class="LC_nobreak"><label><input type="checkbox" '.
! 483: 'name="cloners_delete" value="'.$num.'" onchange="javascript:update_types('."'cloners_delete','$num'".');" />'.
! 484: &mt('Delete').'</label></span></td>'.
! 485: &Apache::loncommon::end_data_table_row();
! 486: $num ++;
! 487: } else {
! 488: push(@cloners,$entry);
! 489: }
! 490: }
! 491: }
! 492: }
! 493: my $add_domtitle = &mt('Any user in additional domain:');
! 494: if ($settings->{$item} eq '*') {
! 495: $add_domtitle = &mt('Any user in specific domain:');
! 496: } elsif ($settings->{$item} eq '') {
! 497: $add_domtitle = &mt('Any user in other domain:');
! 498: }
! 499: my $cloners_str = join(',',@cloners);
! 500: $datatable .= &Apache::loncommon::start_data_table_row().
! 501: '<td align="left"><span class="LC_nobreak">'.
! 502: $add_domtitle.'</span><br />'.
! 503: &Apache::loncommon::select_dom_form('','cloners_newdom',
! 504: $includeempty).
! 505: '<input type="hidden" name="cloners_total" value="'.$num.'" />'.
! 506: '</td>'.&Apache::loncommon::end_data_table_row().
! 507: &Apache::loncommon::end_data_table().'<br />'.
! 508: &Apache::loncommon::start_data_table().
! 509: &Apache::loncommon::start_data_table_row().
! 510: '<td align="left">'.
! 511: &mt('Specific users').' (<tt>'.
! 512: &mt('user:domain,user:domain').'</tt>)<br />'.
! 513: &Apache::lonhtmlcommon::textbox($item,$cloners_str,
! 514: $items{$item}{'size'}).
! 515: '</td>'.&Apache::loncommon::end_data_table_row().
! 516: &Apache::loncommon::end_data_table();
! 517: } elsif ($item eq 'rolenames') {
! 518: $datatable .= &Apache::loncommon::start_data_table();
! 519: foreach my $role ('cc','in','ta','ep','ad','st') {
! 520: $datatable .= &Apache::loncommon::start_data_table_row().
! 521: '<td align="left"><span class="LC_nobreak">'.
! 522: &Apache::lonnet::plaintext($role,$crstype,undef,1).
! 523: '</span></td><td align="left">'.
! 524: &Apache::lonhtmlcommon::textbox('rolenames_'.$role,
! 525: $settings->{$role.'.plaintext'},
! 526: $items{$item}{size}).'</td>'.
! 527: &Apache::loncommon::end_data_table_row();
! 528: }
! 529: $datatable .= &Apache::loncommon::end_data_table().'</td>';
! 530: } elsif ($item eq 'categories') {
! 531: $datatable .= '<input type="hidden" name="categories" value="'.$settings->{$item}.'" />'.&Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item},$items{$item}{size});
! 532: } else {
! 533: $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size});
! 534: }
! 535: $datatable .= &item_table_row_end();
! 536: }
! 537: $$rowtotal += scalar(@{$ordered});
! 538: return $datatable;
! 539: }
! 540:
! 541: sub new_cloners_dom_row {
! 542: my ($newdom,$num) = @_;
! 543: my $output;
! 544: if ($newdom ne '') {
! 545: $output .= &Apache::loncommon::start_data_table_row().
! 546: '<td valign="top"><span class="LC_nobreak">'.
! 547: &mt('Any user in domain:').' <b>'.$newdom.'</b>'.
! 548: (' 'x2).'<label><input type="radio" '.
! 549: 'name="cloners_activate" value="'.$num.'" '.
! 550: 'onchange="javascript:update_types('.
! 551: "'cloners_activate','$num'".');" />'.
! 552: &mt('Yes').'</label>'.(' 'x2).
! 553: '<label><input type="radio" '.
! 554: 'name="cloners_activate" value="" checked="checked" '.
! 555: 'onchange="javascript:update_types('.
! 556: "'cloners_activate','$num'".');" />'.
! 557: &mt('No').'</label></span></td>'.
! 558: &Apache::loncommon::end_data_table_row();
! 559: }
! 560: return $output;
! 561: }
! 562:
! 563: sub can_modify_catsettings {
! 564: my ($dom) = @_;
! 565: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
! 566: my ($can_toggle_cat,$can_categorize);
! 567: if (ref($domconf{'coursecategories'}) eq 'HASH') {
! 568: if ($domconf{'coursecategories'}{'togglecats'} eq 'crs') {
! 569: $can_toggle_cat = 1;
! 570: }
! 571: if ($domconf{'coursecategories'}{'categorize'} eq 'crs') {
! 572: $can_categorize = 1;
! 573: }
! 574: }
! 575: return ($can_toggle_cat,$can_categorize);
! 576: }
! 577:
! 578: sub assign_course_categories {
! 579: my ($r) = @_;
! 580: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
! 581: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
! 582: my $hascats = 0;
! 583: my $cathash;
! 584: my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
! 585: if (ref($domconf{'coursecategories'}) eq 'HASH') {
! 586: $cathash = $domconf{'coursecategories'}{'cats'};
! 587: if (ref($cathash) eq 'HASH') {
! 588: $hascats = 1;
! 589: }
! 590: }
! 591: my $catwin_js;
! 592: if ($hascats) {
! 593: my $alert = &mt('Use \"Save\" in the main window to save course categories');
! 594: $catwin_js = <<ENDSCRIPT;
! 595: <script type="text/javascript">
! 596:
! 597: function updateCategories() {
! 598: var newcategories = '';
! 599: var unescapedcats = '';
! 600: if (document.chgcats.usecategory.length) {
! 601: for (var i=0; i<document.chgcats.usecategory.length; i++) {
! 602: if (document.chgcats.usecategory[i].checked == true) {
! 603: newcategories = newcategories + document.chgcats.usecategory[i].value + '&';
! 604: unescapedcats = unescapedcats + document.chgcats.catname[i].value + ' & ';
! 605: }
! 606: }
! 607: if (newcategories.length > 0) {
! 608: newcategories = newcategories.slice(0,-1);
! 609: }
! 610: if (unescapedcats.length > 0) {
! 611: unescapedcats = unescapedcats.slice(0,-3);
! 612: }
! 613: } else {
! 614: if (document.chgcats.usecategory.checked == true) {
! 615: newcategories = document.chgcats.usecategory.value;
! 616: unescapedcats = document.chgcats.catname.value;
! 617: }
! 618: }
! 619: opener.document.display.categories.value = newcategories;
! 620: opener.document.display.categories_display.value = unescapedcats;
! 621: alert("$alert");
! 622: self.close();
! 623: return;
! 624: }
! 625:
! 626: </script>
! 627: ENDSCRIPT
! 628: } else {
! 629: my $onload;
! 630: }
! 631: my $start_page =
! 632: &Apache::loncommon::start_page('Course Categories',$catwin_js,
! 633: {'only_body' => 1,});
! 634: my $end_page = &Apache::loncommon::end_page();
! 635: my $categoriesform = '<h3>'.&mt('Categorize Course').'</h3>';
! 636: if ($hascats) {
! 637: my %currsettings =
! 638: &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
! 639: $categoriesform .= &mt('Assign one or more categories to this course.').'<br /><br />'.
! 640: '<form name="chgcats" action="/adm/courseprefs" method="post">'."\n".
! 641: &Apache::loncommon::assign_categories_table($cathash,
! 642: $currsettings{'categories'})."\n".
! 643: '<br /><input type="button" name="changes" value="'.
! 644: &mt('Copy to main window').'" '.
! 645: 'onclick="javascript:updateCategories()" /></form><br />';
! 646: } else {
! 647: $categoriesform .= &mt('No categories defined for this domain');
! 648: }
! 649: $r->print($start_page.$categoriesform.$end_page);
! 650: return;
! 651: }
! 652:
! 653: sub print_localization {
! 654: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 655: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 656: return;
! 657: }
! 658: my %items = (
! 659: languages => {
! 660: text => &mt('Languages used').'<br />'.&mt("(will override user's preference)"),
! 661: input => 'selectbox',
! 662: },
! 663: timezone => {
! 664: text => &mt('Timezone in which the course takes place'),
! 665: input => 'selectbox',
! 666: },
! 667: datelocale => {
! 668: text => &mt('Locale used for course calendar'),
! 669: input => 'selectbox',
! 670: },
! 671: );
! 672: my $datatable;
! 673: my $count = 0;
! 674: foreach my $item (@{$ordered}) {
! 675: $count ++;
! 676: $datatable .= &item_table_row_start($items{$item}{text},$count);
! 677: if ($item eq 'timezone') {
! 678: my $includeempty = 1;
! 679: my $timezone = &Apache::lonlocal::gettimezone();
! 680: $datatable .=
! 681: &Apache::loncommon::select_timezone($item,$timezone,undef,
! 682: $includeempty);
! 683: } elsif ($item eq 'datelocale') {
! 684: my $includeempty = 1;
! 685: my $locale_obj = &Apache::lonlocal::getdatelocale();
! 686: my $currdatelocale;
! 687: if (ref($locale_obj)) {
! 688: $currdatelocale = $locale_obj->id();
! 689: }
! 690: $datatable .=
! 691: &Apache::loncommon::select_datelocale($item,$currdatelocale,
! 692: undef,$includeempty);
! 693: } else {
! 694: if ($settings->{$item} eq '') {
! 695: $datatable .=
! 696: &Apache::loncommon::select_language('language_0','',1);
! 697: } else {
! 698: my $num = 0;
! 699: my @languages = split(/\s*(\,|\;|\:)\s*/,$settings->{$item});
! 700: $datatable .= &Apache::loncommon::start_data_table();
! 701: if (@languages > 0) {
! 702: foreach my $lang (@languages) {
! 703: my $showlang = $lang;
! 704: my $code = &Apache::loncommon::supportedlanguagecode($lang);
! 705: if ($code) {
! 706: $showlang = &plainlanguagedescription($lang);
! 707: }
! 708: $datatable .=
! 709: &Apache::loncommon::start_data_table_row().
! 710: '<td valign="top"><span class="LC_nobreak">'.
! 711: &mt('Language:').'<b> '.$showlang.
! 712: '</b><input type="hidden" name="languages_'.$num.
! 713: '" value="'.$lang.'" /></span><br />'.
! 714: '<span class="LC_nobreak"><label><input type="checkbox" '.
! 715: 'name="languages_delete" value="'.$num.'" />'.
! 716: &mt('Delete').'</label></span></td>'.
! 717: &Apache::loncommon::end_data_table_row().'</td>';
! 718: $num ++;
! 719: }
! 720: }
! 721: $datatable .= &Apache::loncommon::start_data_table_row().
! 722: '<td><span class="LC_nobreak">'.
! 723: &mt('Additional language:').'</span><br />'.
! 724: &Apache::loncommon::select_language($item);
! 725: '<input type="hidden" name="languages_total" value="'.$num.'" />'.
! 726: '</td>'.&Apache::loncommon::end_data_table_row().
! 727: &Apache::loncommon::end_data_table();
! 728: }
! 729: }
! 730: $datatable .= &item_table_row_end();
! 731: }
! 732: $$rowtotal += scalar(@{$ordered});
! 733: return $datatable;
! 734: }
! 735:
! 736: sub print_feedback {
! 737: my ($position,$cdom,$settings,$ordered,$rowtotal) = @_;
! 738: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 739: return;
! 740: }
! 741: my %items = (
! 742: 'question' => {
! 743: text => '<b>'.&mt('Resource Content').'</b>',
! 744: input => 'textbox',
! 745: size => '50',
! 746: },
! 747:
! 748: 'comment' => {
! 749: text => '<b>'.&mt('Course Content').'</b>',
! 750: input => 'textbox',
! 751: size => '50',
! 752: },
! 753:
! 754: 'policy' => {
! 755: text => '<b>'.&mt('Course Policy').'</b>',
! 756: input => 'textbox',
! 757: size => '50',
! 758: },
! 759: );
! 760: my $datatable;
! 761: my $count = 0;
! 762: my ($cnum) = &get_course();
! 763: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
! 764: my @sections = sort( { $a <=> $b } keys(%sections));
! 765: my %lt = &Apache::lonlocal::texthash (
! 766: currone => 'Current recipient:',
! 767: curmult => 'Current recipients:',
! 768: add => 'Additional recipient:',
! 769: del => 'Delete?',
! 770: sec => 'Sections:',
! 771: );
! 772:
! 773: foreach my $item (@{$ordered}) {
! 774: $count ++;
! 775: $datatable .= &item_table_row_start($items{$item}{text},$count);
! 776: if ($position eq 'top') {
! 777: my $includeempty = 0;
! 778: $datatable .= &user_table($cdom,$item,\@sections,
! 779: $settings->{$item.'.email'},\%lt);
! 780: } else {
! 781: $datatable .= &Apache::lonhtmlcommon::textbox($item.'_text',
! 782: $settings->{$item},$items{$item}{size});
! 783: }
! 784: $datatable .= &item_table_row_end();
! 785: }
! 786: $$rowtotal += scalar(@{$ordered});
! 787: return $datatable;
! 788: }
! 789:
! 790: sub user_table {
! 791: my ($cdom,$item,$sections,$currvalue,$lt) = @_;
! 792: my $output;
! 793: if ($currvalue eq '') {
! 794: $output .= &select_recipient($item,'0',$cdom,$sections);
! 795: } else {
! 796: my $num = 0;
! 797: my @curr = split(/,/,$currvalue);
! 798: $output .= &Apache::loncommon::start_data_table();
! 799: my ($currusers);
! 800: foreach my $val (@curr) {
! 801: next if ($val eq '');
! 802: my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/);
! 803: my @selsec;
! 804: if ($seclist) {
! 805: $seclist =~ s/(^\(|\)$)//g;
! 806: @selsec = split(/\s*;\s*/,$seclist);
! 807: }
! 808: $currusers .= '<tr>'.
! 809: '<td valign="top"><span class="LC_nobreak">'.
! 810: '<label><input type="checkbox" '.
! 811: 'name="'.$item.'_delete" value="'.$num.'" />'.
! 812: $lt->{'del'}.'</label>'.
! 813: '<input type="hidden" name="'.$item.'_user_'.
! 814: $num.'" value="'.$val.'" />'.(' 'x2).
! 815: &Apache::loncommon::aboutmewrapper(
! 816: &Apache::loncommon::plainname($uname,$udom,'firstname'),
! 817: $uname,$udom,'aboutuser');
! 818: if (ref($sections) eq 'ARRAY') {
! 819: if (@{$sections}) {
! 820: $currusers.= (' 'x3).$lt->{'sec'}.' '.
! 821: &select_sections($item,$num,$sections,
! 822: \@selsec);
! 823: }
! 824: }
! 825: $currusers .= '</span></td></tr>';
! 826: $num ++;
! 827: }
! 828: if ($num) {
! 829: $output .= &Apache::loncommon::start_data_table_row().
! 830: '<td align="left"><i>';
! 831: if ($num > 1) {
! 832: $output .= $lt->{'currone'};
! 833: } else {
! 834: $output .= $lt->{'currmult'};
! 835: }
! 836: $output .= '</i><br />'.
! 837: '<table>'.$currusers.'</table></td>'.
! 838: &Apache::loncommon::end_data_table_row();
! 839: }
! 840: $output .= &Apache::loncommon::start_data_table_row().
! 841: '<td align="left"><span class="LC_nobreak"><i>'.
! 842: $lt->{'add'}.'</i></span><br />'.
! 843: &select_recipient($item,$num,$cdom,$sections).
! 844: '<input type="hidden" name="'.$item.'_total" value="'.$num.'" />'.
! 845: '</td>'.&Apache::loncommon::end_data_table_row().
! 846: &Apache::loncommon::end_data_table();
! 847: }
! 848: return $output;
! 849: }
! 850:
! 851: sub select_recipient {
! 852: my ($item,$num,$cdom,$sections,$selected,$includeempty) = @_;
! 853: my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
! 854: my $selectlink =
! 855: &Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
! 856: $item.'_udom_'.$num,1);
! 857: my $output =
! 858: '<table><tr><td align="center">'.&mt('Username').'<br />'.
! 859: '<input type="text" name="'.$item.'_uname_'.$num.'" value="" /></td>'.
! 860: '<td align="center">'.&mt('Domain').'<br />'.$domform.'</td>';
! 861: if (ref($sections) eq 'ARRAY') {
! 862: if (@{$sections}) {
! 863: $output .= '<td align="center">'.&mt('Sections').'<br />'.
! 864: &select_sections($item,$num,$sections,$selected).'</td>';
! 865: }
! 866: }
! 867: $output .= '<td valign="top">'.
! 868: $selectlink.'</td></tr></table>';
! 869: return $output;
! 870: }
! 871:
! 872: sub select_sections {
! 873: my ($item,$num,$sections,$selected) = @_;
! 874: my ($output,@currsecs,$allsec);
! 875: if (ref($selected) eq 'ARRAY') {
! 876: @currsecs = @{$selected};
! 877: }
! 878: if (!@currsecs) {
! 879: $allsec = ' selected="selected"';
! 880: }
! 881: if (ref($sections) eq 'ARRAY') {
! 882: if (@{$sections}) {
! 883: my $mult;
! 884: if (@{$sections} > 1) {
! 885: $mult = ' multiple="multiple"';
! 886: if (@{$sections} > 3) {
! 887: $mult .= ' size="4"';
! 888: }
! 889: }
! 890: $output = '<select name="'.$item.'_sections_'.$num.'"'.$mult.'>'.
! 891: ' <option value=""'.$allsec.'>'.&mt('All').'</option>';
! 892: foreach my $sec (@{$sections}) {
! 893: my $is_sel;
! 894: if ((@currsecs) && (grep(/^\Q$sec\E$/,@currsecs))) {
! 895: $is_sel = 'selected="selected"';
! 896: }
! 897: $output .= '<option value="'.$sec.'"'.$is_sel.'>'.$sec.'</option>';
! 898: }
! 899: $output .= '</select>';
! 900: }
! 901: }
! 902: return $output;
! 903: }
! 904:
! 905: sub print_discussion {
! 906: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 907: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 908: return;
! 909: }
! 910: my %items = (
! 911: 'plc.roles.denied' => {
! 912: text => '<b>'.&mt('No Chat room use').'</b>'.
! 913: &Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
! 914: input => 'checkbox',
! 915: },
! 916:
! 917: 'plc.users.denied' => {
! 918: text => '<b>'.&mt('No Chat room use').'</b>',
! 919: input => 'checkbox',
! 920: },
! 921:
! 922: 'pch.roles.denied' => {
! 923: text => '<b>'.&mt('No Resource Discussion').'</b>'.
! 924: &Apache::loncommon::help_open_topic("Course_Disable_Discussion"),
! 925: input => 'checkbox',
! 926: },
! 927:
! 928: 'pch.users.denied' => {
! 929: text => '<b>'.&mt('No Resource Discussion').'</b>',
! 930: input => 'checkbox',
! 931: },
! 932: 'allow_limited_html_in_feedback' => {
! 933: text => '<b>'.&mt('Allow limited HTML in discussion posts').'</b>',
! 934: input => 'radio',
! 935: },
! 936:
! 937: 'allow_discussion_post_editing' => {
! 938: text => '<b>'.&mt('Users can edit/delete own discussion posts').'</b>',
! 939: input => 'checkbox',
! 940: },
! 941: );
! 942: my $datatable;
! 943: my $count;
! 944: my ($cnum) = &get_course();
! 945: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
! 946: my @sections = sort( { $a <=> $b } keys(%sections));
! 947: my %lt = &Apache::lonlocal::texthash (
! 948: currone => 'Disallowed:',
! 949: curmult => 'Disallowed:',
! 950: add => 'Disallow more:',
! 951: del => 'Delete?',
! 952: sec => 'Sections:',
! 953: );
! 954:
! 955: foreach my $item (@{$ordered}) {
! 956: $count ++;
! 957: $datatable .= &item_table_row_start($items{$item}{text},$count);
! 958: if ($item eq 'plc.roles.denied') {
! 959: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
! 960: '</table>';
! 961: } elsif ($item eq 'plc.users.denied') {
! 962: $datatable .= &user_table($cdom,$item,undef,
! 963: $settings->{$item},\%lt);
! 964: } elsif ($item eq 'pch.roles.denied') {
! 965: $datatable .= '<table>'.&role_checkboxes($cdom,$cnum,$item,$settings).
! 966: '</table>';
! 967: } elsif ($item eq 'pch.users.denied') {
! 968: $datatable .= &user_table($cdom,$item,undef,
! 969: $settings->{$item},\%lt);
! 970: } elsif ($item eq 'allow_limited_html_in_feedback') {
! 971: $datatable .= &yesno_radio($item,$settings);
! 972: } elsif ($item eq 'allow_discussion_post_editing') {
! 973: $datatable .= &Apache::loncommon::start_data_table().
! 974: &Apache::loncommon::start_data_table_row().
! 975: '<th align="left">'.&mt('Role').'</th><th>'.
! 976: &mt('Sections').'</th>'.
! 977: &Apache::loncommon::end_data_table_row().
! 978: &role_checkboxes($cdom,$cnum,$item,$settings,1).
! 979: &Apache::loncommon::end_data_table();
! 980: }
! 981: $datatable .= &item_table_row_end();
! 982: }
! 983: $$rowtotal += scalar(@{$ordered});
! 984: return $datatable;
! 985: }
! 986:
! 987: sub role_checkboxes {
! 988: my ($cdom,$cnum,$item,$settings,$showsections) = @_;
! 989: my @roles = ('st','ad','ta','ep','in','cc');
! 990: my $output;
! 991: my (@current,@curr_roles,%currsec,@sections);
! 992: if ($showsections) {
! 993: my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
! 994: @sections = sort( { $a <=> $b } keys(%sections));
! 995: }
! 996: if (ref($settings) eq 'HASH') {
! 997: if ($settings->{$item}) {
! 998: @current = split(',',$settings->{$item});
! 999: if ($showsections) {
! 1000: foreach my $role (@current) {
! 1001: if ($role =~ /:/) {
! 1002: my ($trole,$sec) = split(':',$role);
! 1003: push(@curr_roles,$trole);
! 1004: if (ref($currsec{$trole}) eq 'ARRAY') {
! 1005: if (!grep(/^\Q$sec\E/,@{$currsec{$trole}})) {
! 1006: push(@{$currsec{$trole}},$sec);
! 1007: }
! 1008: }
! 1009: } else {
! 1010: push(@curr_roles,$role);
! 1011: }
! 1012: }
! 1013: @current = @curr_roles;
! 1014: }
! 1015: }
! 1016: }
! 1017: my $numinrow = 3;
! 1018: my $count = 0;
! 1019: foreach my $role (@roles) {
! 1020: my $checked = '';
! 1021: if (grep(/^\Q$role\E$/,@current)) {
! 1022: $checked = ' checked="checked" ';
! 1023: }
! 1024: my $plrole=&Apache::lonnet::plaintext($role);
! 1025: if ($showsections) {
! 1026: $output .= &Apache::loncommon::start_data_table_row();
! 1027: } else {
! 1028: my $rem = $count%($numinrow);
! 1029: if ($rem == 0) {
! 1030: if ($count > 0) {
! 1031: $output .= '</tr>';
! 1032: }
! 1033: $output .= '<tr>';
! 1034: }
! 1035: }
! 1036: $output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" name='.
! 1037: $item.'" value="'.$role.'"'.$checked.'/> '.
! 1038: $plrole.'</label></span></td>';
! 1039: if ($showsections) {
! 1040: $output .= '<td align="left">'.
! 1041: &select_sections($item,$role,\@sections,$currsec{$role}).
! 1042: '</td></tr>';
! 1043: }
! 1044: $count ++;
! 1045: }
! 1046: my %adv_roles =
! 1047: &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
! 1048: my $total = @roles;
! 1049: foreach my $role (sort(keys(%adv_roles))) {
! 1050: if ($role =~ m{^cr/($match_domain)/($match_name)/\w$}) {
! 1051: my $rolename = $3;
! 1052: my $value = 'cr_'.$1.'_'.$2.'_'.$rolename;
! 1053: my $checked = '';
! 1054: if (grep(/^\Q$value\E$/,@current)) {
! 1055: $checked = ' checked="checked" ';
! 1056: }
! 1057: if ($showsections) {
! 1058: $output .= &Apache::loncommon::start_data_table_row();
! 1059: } else {
! 1060: my $rem = $count%($numinrow);
! 1061: if ($rem == 0) {
! 1062: if ($count > 0) {
! 1063: $output .= '</tr>';
! 1064: }
! 1065: $output .= '<tr>';
! 1066: }
! 1067: }
! 1068: $output .= '<td><span class="LC_nobreak"><label><input type="checkbox" name='.
! 1069: $item.'" value="'.$value.'"'.$checked.' /> '.$rolename.
! 1070: '</label></span></td>';
! 1071: if ($showsections) {
! 1072: $output .= '<td>'.
! 1073: &select_sections($item,$role,\@sections,$currsec{$role}).
! 1074: '</td>'.&Apache::loncommon::end_data_table_row();
! 1075: }
! 1076: $total ++;
! 1077: $count ++;
! 1078: }
! 1079: }
! 1080: if (!$showsections) {
! 1081: my $rem = $total%($numinrow);
! 1082: my $colsleft = $numinrow - $rem;
! 1083: if ($colsleft > 1 ) {
! 1084: $output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
! 1085: ' </td>';
! 1086: } elsif ($colsleft == 1) {
! 1087: $output .= '<td class="LC_left_item"> </td>';
! 1088: }
! 1089: $output .= '</tr>';
! 1090: }
! 1091: return $output;
! 1092: }
! 1093:
! 1094: sub print_classlists {
! 1095: my ($position,$cdom,$settings,$rowtotal) = @_;
! 1096: my @ordered;
! 1097: if ($position eq 'top') {
! 1098: @ordered = ('default_enrollment_start_date',
! 1099: 'default_enrollment_end_date');
! 1100: } elsif ($position eq 'middle') {
! 1101: @ordered = ('nothideprivileged');
! 1102: } else {
! 1103: @ordered = ('student_classlist_view',
! 1104: 'student_opt_in','student_classlist_portfiles');
! 1105: }
! 1106: my %items = (
! 1107: 'default_enrollment_start_date' => {
! 1108: text => '<b>'.&mt('Start date').'</b>',
! 1109: input => 'dates',
! 1110: },
! 1111: 'default_enrollment_end_date' => {
! 1112: text => '<b>'.&mt('End date').'</b>',
! 1113: input => 'dates',
! 1114: },
! 1115:
! 1116: 'nothideprivileged' => {
! 1117: text => '<b>'.&mt('Domain Coodinators in course').'</b>',
! 1118: input => 'checkbox',
! 1119: },
! 1120:
! 1121: 'student_classlist_view' => {
! 1122: text => '<b>'.&mt('Student-viewable classlist').'</b>',
! 1123: input => 'selectbox',
! 1124: options => {
! 1125: disabled => &mt('No viewable classlist'),
! 1126: section => &mt("Classlist of viewer's section"),
! 1127: all => &mt('Classlist of all students'),
! 1128: },
! 1129: order => ['disabled','all','section'],
! 1130: },
! 1131: 'student_opt_in' => {
! 1132: text => '<b>'.&mt('Student agreement needed to be listed').'</b>',
! 1133: input => 'radio',
! 1134: },
! 1135:
! 1136: 'student_classlist_portfiles' => {
! 1137: text => '<b>'.&mt('Include link to accessible portfolio files').'</b>',
! 1138: input => 'radio',
! 1139: },
! 1140: );
! 1141: unless (($settings->{'student_classlist_view'} eq 'all') ||
! 1142: ($settings->{'student_classlist_view'} eq 'section')) {
! 1143: $settings->{'student_classlist_view'} = 'disabled';
! 1144: }
! 1145: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal);
! 1146: }
! 1147:
! 1148: sub print_appearance {
! 1149: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 1150: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 1151: return;
! 1152: }
! 1153: my %items = (
! 1154: 'default_xml_style' => {
! 1155: text => '<b>'.&mt('Default XML Style File').'</b> '.
! 1156: '<a href="javascript:openbrowser'.
! 1157: "('display','default_xml_style'".
! 1158: ",'sty')".'">'.&mt('Select Style File').'</a>',
! 1159: input => 'textbox',
! 1160: size => 35,
! 1161: },
! 1162:
! 1163: 'pageseparators' => {
! 1164: text => '<b>'.&mt('Visibly Separate Items on Pages').'</b>',
! 1165: input => 'radio',
! 1166: },
! 1167: 'disable_receipt_display' => {
! 1168: text => '<b>'.&mt('Disable display of problem receipts').'</b>',
! 1169: input => 'radio',
! 1170: },
! 1171: 'texengine' => {
! 1172: text => '<b>'.&mt('Force use of a specific math rendering engine.').'</b>',
! 1173: input => 'selectbox',
! 1174: options => {
! 1175: jsMath => 'jsMath',
! 1176: mimetex => &mt('Convert to Images'),
! 1177: tth => &mt('TeX to HTML'),
! 1178: },
! 1179: order => ['jsMath','mimetex','tth'],
! 1180: nullval => &mt("None specified - use student's choice"),
! 1181: },
! 1182: 'tthoptions' => {
! 1183: text => '<b>'.&mt('Default set of options to pass to tth/m when converting TeX').'</b>',
! 1184: input => 'textbox',
! 1185: size => 40,
! 1186: },
! 1187: );
! 1188: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal);
! 1189: }
! 1190:
! 1191: sub print_grading {
! 1192: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 1193: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 1194: return;
! 1195: }
! 1196: my %items = (
! 1197: 'grading' => {
! 1198: text => '<b>'.&mt('Grading').'</b>'.
! 1199: &Apache::loncommon::help_open_topic('GradingOptions'),
! 1200: input => 'selectbox',
! 1201: options => {
! 1202: standard => &mt('Standard: shows points'),
! 1203: external => &mt('External: shows number of completed parts'),
! 1204: spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'),
! 1205: },
! 1206: order => ['standard','external','spreadsheet'],
! 1207: },
! 1208: 'rndseed' => {
! 1209: text => '<b>'.&mt('Randomization algorithm used').'</b>'.
! 1210: '<span class="LC_error">'.'<br />'.
! 1211: &mt('Modifying this will make problems have different numbers and answers!').
! 1212: '</span>',
! 1213: input => 'selectbox',
! 1214: options => {
! 1215: '32bit' => '32bit',
! 1216: '64bit' => '64bit',
! 1217: '64bit2' => '64bit2',
! 1218: '64bit3' => '64bit3',
! 1219: '64bit4' => '64bit4',
! 1220: '64bit5' => '64bit5',
! 1221: },
! 1222: order => ['32bit','64bit','64bit2','64bit3','64bit4','64bit5'],
! 1223: },
! 1224: 'receiptalg' => {
! 1225: text => '<b>'.&mt('Receipt algorithm used').'</b><br />'.
! 1226: &mt('This controls how receipt numbers are generated.'),
! 1227: input => 'selectbox',
! 1228: options => {
! 1229: receipt => 'receipt',
! 1230: receipt2 => 'receipt2',
! 1231: receipt3 => 'receipt3',
! 1232: },
! 1233: order => ['receipt','receipt2','receipt3'],
! 1234: },
! 1235: 'disablesigfigs' => {
! 1236: text => '<b>'.&mt('Disable checking of Significant Figures').'</b>',
! 1237: input => 'radio',
! 1238: },
! 1239: );
! 1240: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal);
! 1241: }
! 1242:
! 1243: sub print_printouts {
! 1244: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 1245: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 1246: return;
! 1247: }
! 1248: my %items = (
! 1249: problem_stream_switch => {
! 1250: text => '<b>'.&mt('Allow problems to be split over pages').'</b>',
! 1251: input => 'radio',
! 1252: },
! 1253: suppress_tries => {
! 1254: text => '<b>'.&mt('Suppress number of tries in printing').'</b>',
! 1255: input => 'radio',
! 1256: },
! 1257: default_paper_size => {
! 1258: text => '<b>'.&mt('Default paper type').'</b>',
! 1259: input => 'selectbox',
! 1260: options => {
! 1261: Letter => &mt('Letter').' [8 1/2x11 in]',
! 1262: Legal => &mt('Legal').' [8 1/2x14 in]',
! 1263: Tabloid => &mt('Tabloid').' [11x17 in]',
! 1264: Executive => &mt('Executive').' [7 1/2x10 in]',
! 1265: A2 => &mt('A2').' [420x594 mm]',
! 1266: A3 => &mt('A3').' [297x420 mm]',
! 1267: A4 => &mt('A4').' [210x297 mm]',
! 1268: A5 => &mt('A5').' [148x210 mm]',
! 1269: A6 => &mt('A6').' [105x148 mm]',
! 1270: },
! 1271: order => ['Letter','Legal','Tabloid','Executive','A2','A3','A4','A5','A6'],
! 1272: nullval => 'None specified',
! 1273: },
! 1274: print_header_format => {
! 1275: text => '<b>'.&mt('Print header format').'</b>',
! 1276: input => 'checkbox',
! 1277: },
! 1278: disableexampointprint => {
! 1279: text => '<b>'.&mt('Disable automatically printing point values on exams').'</b>',
! 1280: input => 'radio',
! 1281: },
! 1282: );
! 1283: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal);
! 1284: }
! 1285:
! 1286: sub print_spreadsheet {
! 1287: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 1288: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 1289: return;
! 1290: }
! 1291: my $SelectSpreadsheetFile=&mt('Select Spreadsheet File');
! 1292: my %items = (
! 1293: spreadsheet_default_classcalc => {
! 1294: text => '<b>'.&mt('Default Course Spreadsheet').'</b> '.
! 1295: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
! 1296: "('display','spreadsheet_default_classcalc'".
! 1297: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
! 1298: input => 'textbox',
! 1299: },
! 1300: spreadsheet_default_studentcalc => {
! 1301: text => '<b>'.&mt('Default Student Spreadsheet').'</b> '.
! 1302: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
! 1303: "('display','spreadsheet_default_calc'".
! 1304: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
! 1305: input => 'textbox',
! 1306: },
! 1307: spreadsheet_default_assesscalc => {
! 1308: text => '<b>'.&mt('Default Assessment Spreadsheet').'</b> '.
! 1309: '<span class="LC_nobreak"><a href="javascript:openbrowser'.
! 1310: "('display','spreadsheet_default_assesscalc'".
! 1311: ",'spreadsheet')".'">'.$SelectSpreadsheetFile.'</a></span>',
! 1312: input => 'textbox',
! 1313: },
! 1314: hideemptyrows => {
! 1315: text => '<b>'.&mt('Hide Empty Rows in Spreadsheets').'</b>',
! 1316: input => 'radio',
! 1317: },
! 1318: );
! 1319: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal);
! 1320: }
! 1321:
! 1322: sub print_bridgetasks {
! 1323: my ($cdom,$settings,$ordered,$rowtotal) = @_;
! 1324: unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 1325: return;
! 1326: }
! 1327: my %items = (
! 1328: task_messages => {
! 1329: text => '<b>'.&mt('Send message to student when clicking Done on Tasks').'</b>',
! 1330: input => 'selectbox',
! 1331: options => {
! 1332: only_student => &mt('Send message to student'),
! 1333: student_and_user_notes_screen => &mt('Message to student and add to user notes'),
! 1334: },
! 1335: order => ['only_student','student_and_user_notes_screen'],
! 1336: nullval => &mt('No message or record in user notes'),
! 1337: },
! 1338: task_grading => {
! 1339: text => '<b>'.&mt('Bridge Task grading by instructors and TAs in sections').'</b>',
! 1340: input => 'selectbox',
! 1341: options => {
! 1342: any => &mt('Grade BTs in any section'),
! 1343: section => &mt('Grade BTs only in own section')
! 1344: },
! 1345: order => ['any','section'],
! 1346: },
! 1347: suppress_embed_prompt => {
! 1348: text => '<b>'.&mt('Hi$de upload references prompt if uploading file to portfolio').'</b><span class="LC_nobreak"> '.
! 1349: &mt('(applies when current role is student)').'</span>',
! 1350: input => 'radio',
! 1351: },
! 1352: );
! 1353: return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal);
! 1354: }
! 1355:
! 1356: sub print_other {
! 1357: my ($cdom,$settings,$allitems,$rowtotal) = @_;
! 1358: unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) {
! 1359: return;
! 1360: }
! 1361: my @ordered;
! 1362: my %items;
! 1363: if (ref($settings) eq 'HASH') {
! 1364: foreach my $parameter (sort(keys(%{$settings}))) {
! 1365: next if (grep/^\Q$parameter\E$/,@{$allitems});
! 1366: next if (($parameter eq 'course.helper.not.run') &&
! 1367: (!exists($env{'user.role.dc./'.$env{'request.role.domain'}.'/'})));
! 1368: unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./) ||
! 1369: ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/)
! 1370: || ($parameter eq 'type') ||
! 1371: ($parameter =~ m/^(cc|in|ta|ep|ad|st)\.plaintext$/)) {
! 1372: push(@ordered,$parameter);
! 1373: $items{$parameter} = {
! 1374: text => $parameter,
! 1375: input => 'textbox',
! 1376: size => '15',
! 1377: },
! 1378: }
! 1379: }
! 1380: }
! 1381: return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal);
! 1382: }
! 1383:
! 1384: sub item_table_row_start {
! 1385: my ($text,$count) = @_;
! 1386: my $output;
! 1387: if ($count%2) {
! 1388: $output .= '<tr class="LC_odd_row">';
! 1389: } else {
! 1390: $output .= '<tr>';
! 1391: }
! 1392: $output .= '<td class="LC_left_item">'.$text.
! 1393: '</td><td class="LC_right_item">';
! 1394: return $output;
! 1395: }
! 1396:
! 1397: sub item_table_row_end {
! 1398: return '</td></tr>';
! 1399: }
! 1400:
! 1401: sub yesno_radio {
! 1402: my ($item,$settings) = @_;
! 1403: my $itemon = ' ';
! 1404: my $itemoff = ' checked="checked" ';
! 1405: if (ref($settings) eq 'HASH') {
! 1406: if ($settings->{$item} eq 'yes') {
! 1407: $itemon = $itemoff;
! 1408: $itemoff = ' ';
! 1409: }
! 1410: }
! 1411: return '<span class="LC_nobreak"><label>'.
! 1412: '<input type="radio" name="'.$item.'"'.
! 1413: $itemon.' value="yes" />'.&mt('Yes').'</label> '.
! 1414: '<label><input type="radio" name="'.$item.'"'.
! 1415: $itemoff.' value="" />'.&mt('No').'</label></span>';
! 1416: }
! 1417:
! 1418: sub select_from_options {
! 1419: my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange) = @_;
! 1420: my $output;
! 1421: if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) {
! 1422: $output='<select name="'.$item.'" '.$onchange;
! 1423: if ($multiple) {
! 1424: $output .= ' multiple="multiple"';
! 1425: my $num = @{$order};
! 1426: $num ++ if ($nullval ne '');
! 1427: if (($maxsize) && ($maxsize < $num)) {
! 1428: $output .= ' size="'.$maxsize.'"';
! 1429: }
! 1430: }
! 1431: $output .= '>'."\n";
! 1432: if ($nullval ne '') {
! 1433: $output .= '<option value=""';
! 1434: if (ref($curr) eq 'ARRAY') {
! 1435: if ((@{$curr} == 0) || (grep(/^$/,@{$curr}))) {
! 1436: $output .= ' selected="selected" ';
! 1437: }
! 1438: } else {
! 1439: if ($curr eq '') {
! 1440: $output .= ' selected="selected" ';
! 1441: }
! 1442: }
! 1443: $output .= '>'.$nullval.'</option>';
! 1444: }
! 1445: foreach my $option (@{$order}) {
! 1446: $output.= '<option value="'.$option.'"';
! 1447: if (ref($curr) eq 'ARRAY') {
! 1448: if (grep(/^\Q$option\E$/,@{$curr})) {
! 1449: $output .= ' selected="selected" ';
! 1450: }
! 1451: } else {
! 1452: if ($option eq $curr) {
! 1453: $output.=' selected="selected"';
! 1454: }
! 1455: }
! 1456: $output.=">$options->{$option}</option>\n";
! 1457: }
! 1458: $output.="</select>";
! 1459: }
! 1460: return $output;
! 1461: }
! 1462:
! 1463: sub make_item_rows {
! 1464: my ($cdom,$items,$ordered,$settings,$rowtotal) = @_;
! 1465: my $datatable;
! 1466: if ((ref($items) eq 'HASH') && (ref($ordered) eq 'ARRAY')) {
! 1467: my $count = 0;
! 1468: foreach my $item (@{$ordered}) {
! 1469: $count ++;
! 1470: $datatable .= &item_table_row_start($items->{$item}{text},$count);
! 1471: if ($item eq 'nothideprivileged') {
! 1472: $datatable .= ¬hidepriv_row($cdom,$item,$settings);
! 1473: } elsif ($item eq 'print_header_format') {
! 1474: $datatable .= &print_hdrfmt_row($item,$settings);
! 1475: } elsif ($items->{$item}{input} eq 'dates') {
! 1476: $datatable .=
! 1477: &Apache::lonhtmlcommon::date_setter('display',$item,
! 1478: $settings->{$item});
! 1479: } elsif ($items->{$item}{input} eq 'radio') {
! 1480: $datatable .= &yesno_radio($item,$settings);
! 1481: } elsif ($items->{$item}{input} eq 'selectbox') {
! 1482: my $curr = $settings->{$item};
! 1483: $datatable .=
! 1484: &select_from_options($item,$items->{$item}{'order'},
! 1485: $items->{$item}{'options'},$curr,
! 1486: $items->{$item}{'nullval'});
! 1487: } elsif ($items->{$item}{input} eq 'textbox') {
! 1488: $datatable .=
! 1489: &Apache::lonhtmlcommon::textbox($item,$settings->{$item},
! 1490: $items->{$item}{size});
! 1491: }
! 1492: $datatable .= &item_table_row_end();
! 1493: }
! 1494: if (ref($rowtotal)) {
! 1495: $$rowtotal += scalar(@{$ordered});
! 1496: }
! 1497: }
! 1498: return $datatable;
! 1499: }
! 1500:
! 1501: sub nothidepriv_row {
! 1502: my ($cdom,$item,$settings) = @_;
! 1503: my ($cnum) = &get_course();
! 1504: my %nothide;
! 1505: my $datatable;
! 1506: if (ref($settings) eq 'HASH') {
! 1507: if ($settings->{$item} ne '') {
! 1508: foreach my $user (split(/\s*\,\s*/,$settings->{$item})) {
! 1509: if ($user !~ /:/) {
! 1510: $nothide{join(':',split(/[\@]/,$user))}=1;
! 1511: } else {
! 1512: $nothide{$user} = 1;
! 1513: }
! 1514: }
! 1515: }
! 1516: }
! 1517: my %coursepersonnel = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
! 1518: my $now = time;
! 1519: my @privusers;
! 1520: foreach my $person (keys(%coursepersonnel)) {
! 1521: my ($role,$user,$usec) = ($person =~ /^([^:]*):([^:]+:[^:]+):([^:]*)/);
! 1522: $user =~ s/:$//;
! 1523: my ($end,$start) = split(/:/,$coursepersonnel{$person});
! 1524: if ($end == -1 || $start == -1) {
! 1525: next;
! 1526: }
! 1527: my ($uname,$udom) = split(':',$user);
! 1528: if (&Apache::lonnet::privileged($uname,$udom)) {
! 1529: push(@privusers,$user);
! 1530: }
! 1531: }
! 1532: if (@privusers) {
! 1533: $datatable .= '<table align="right">';
! 1534: foreach my $user (sort(@privusers)) {
! 1535: my $hideon = ' checked="checked" ';
! 1536: my $hideoff = '';
! 1537: if ($nothide{$user}) {
! 1538: $hideoff = $hideon;
! 1539: $hideon = '';
! 1540: }
! 1541: my ($uname,$udom) = split(':',$user);
! 1542: $datatable .= '<tr><td align="left">'.
! 1543: &Apache::loncommon::aboutmewrapper(
! 1544: &Apache::loncommon::plainname($uname,$udom,'firstname'),
! 1545: $uname,$udom,'aboutuser').
! 1546: '</td><td align="left">'.
! 1547: '<span class="LC_nobreak"><label>'.
! 1548: '<input type="radio" name="'.$item.'_'.$user.'"'.
! 1549: $hideon.' value="yes" />'.&mt('Hidden').'</label> '.
! 1550: '<label><input type="radio" name="'.$item.'_'.$user.'"'. $hideoff.' value="" />'.&mt('Shown').'</label></span></td>'.
! 1551: '</tr>';
! 1552: }
! 1553: $datatable .= '</table>';
! 1554: } else {
! 1555: $datatable .= &mt('No Domain Coordinators have course roles');
! 1556: }
! 1557: return $datatable;
! 1558: }
! 1559:
! 1560: sub print_hdrfmt_row {
! 1561: my ($item,$settings) = @_;
! 1562: my @curr;
! 1563: my $currnum = 0;
! 1564: my $maxnum = 2;
! 1565: my $currstr;
! 1566: if ($settings->{$item} ne '') {
! 1567: $currstr .= '<b>'.&mt('Current print header:').' <span class="LC_warning"><tt>'.
! 1568: $settings->{$item}.'</tt></span></b><br />';
! 1569: my @current = split(/(%\d*[nca])/,$settings->{$item});
! 1570: foreach my $item (@current) {
! 1571: unless ($item eq '') {
! 1572: push(@curr,$item);
! 1573: }
! 1574: }
! 1575: $currnum = @curr;
! 1576: $maxnum += $currnum;
! 1577: }
! 1578:
! 1579: my $output = <<ENDJS;
! 1580:
! 1581: <script type="text/javascript" language="Javascript">
! 1582:
! 1583: function reOrder(chgnum) {
! 1584: var maxnum = $maxnum;
! 1585: var oldidx = 'printfmthdr_oldpos_'+chgnum;
! 1586: var newidx = 'printfmthdr_pos_'+chgnum;
! 1587: oldidx = getIndexByName(oldidx);
! 1588: newidx = getIndexByName(newidx);
! 1589: var oldpos = document.display.elements[oldidx].value;
! 1590: var newpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
! 1591: document.display.elements[oldidx].value = newpos;
! 1592: var chgtype = 'up';
! 1593: if (newpos < oldpos) {
! 1594: chgtype = 'down';
! 1595: }
! 1596: for (var j=0; j<maxnum; j++) {
! 1597: if (j != chgnum) {
! 1598: oldidx = 'printfmthdr_oldpos_'+j;
! 1599: newidx = 'printfmthdr_pos_'+j;
! 1600: oldidx = getIndexByName(oldidx);
! 1601: newidx = getIndexByName(newidx);
! 1602: var currpos = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
! 1603: var currsel = document.display.elements[newidx].selectedIndex;
! 1604: if (chgtype == 'up') {
! 1605: if ((currpos > oldpos) && (currpos <= newpos)) {
! 1606: document.display.elements[newidx].selectedIndex = currsel-1;
! 1607: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
! 1608: }
! 1609: } else {
! 1610: if ((currpos >= newpos) && (currpos < oldpos)) {
! 1611: document.display.elements[newidx].selectedIndex = currsel+1;
! 1612: document.display.elements[oldidx].value = document.display.elements[newidx].options[document.display.elements[newidx].selectedIndex].value;
! 1613: }
! 1614: }
! 1615: }
! 1616: }
! 1617: return;
! 1618: }
! 1619:
! 1620: function getIndexByName(item) {
! 1621: for (var i=0;i<document.display.elements.length;i++) {
! 1622: if (document.display.elements[i].name == item) {
! 1623: return i;
! 1624: }
! 1625: }
! 1626: return -1;
! 1627: }
! 1628:
! 1629: </script>
! 1630:
! 1631: ENDJS
! 1632: $output .= $currstr.&Apache::loncommon::start_data_table();
! 1633: if (@curr > 0) {
! 1634: for (my $i=0; $i<@curr; $i++) {
! 1635: my $pos = $i+1;
! 1636: $output .= &Apache::loncommon::start_data_table_row().
! 1637: '<td align="left"><span class="LC_nobreak">'.
! 1638: &position_selector($pos,$i,$maxnum).&mt('Delete:').
! 1639: '<input type="checkbox" name="printfmthdr_del_'.$i.
! 1640: '" /></span></td>';
! 1641: if ($curr[$i] =~ /^%\d*[nca]$/) {
! 1642: my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/);
! 1643: $output .= '<td align="left">'.
! 1644: &substitution_selector($i,$subst,$limit).'</td>';
! 1645: } else {
! 1646: $output .= '<td colspan="2" align="left">'.&mt('Text').'<br />'.
! 1647: '<input type="textbox" name="printfmthdr_text_'.$i.'"'.
! 1648: ' value="'.$curr[$i].'" size="25" /></td>';
! 1649: }
! 1650: $output .= &Apache::loncommon::end_data_table_row();
! 1651: }
! 1652: }
! 1653: my $pos = $currnum+1;
! 1654: $output .= &Apache::loncommon::start_data_table_row().
! 1655: '<td align="left"><span class="LC_nobreak">'.
! 1656: &position_selector($pos,$currnum,$maxnum).
! 1657: '<b>'.&mt('New').'</b></span></td><td align="left">'.
! 1658: &substitution_selector($currnum).'</td>'.
! 1659: &Apache::loncommon::end_data_table_row();
! 1660: $pos ++;
! 1661: $currnum ++;
! 1662: $output .= &Apache::loncommon::start_data_table_row().
! 1663: '<td align="left"><span class="LC_nobreak">'.
! 1664: &position_selector($pos,$currnum,$maxnum).
! 1665: '<b>'.&mt('New').'</b></span></td>'.
! 1666: '<td colspan="2" align="left">'.&mt('Text').'<br />'.
! 1667: '<input type="textbox" name="printfmthdr_text_'.$currnum.
! 1668: '" value="" size ="25" /></td>'.
! 1669: &Apache::loncommon::end_data_table_row().
! 1670: &Apache::loncommon::end_data_table();
! 1671: return $output;
! 1672: }
! 1673:
! 1674: sub position_selector {
! 1675: my ($pos,$num,$maxnum) = @_;
! 1676: my $output = '<select name="printfmthdr_pos_'.$num.'" onchange="reOrder('."'$num'".');">';
! 1677: for (my $j=1; $j<=$maxnum; $j++) {
! 1678: my $sel = '';
! 1679: if ($pos == $j) {
! 1680: $sel = ' selected="selected"';
! 1681: }
! 1682: $output .= '<option value="'.$j.'"'.$sel.'">'.$j.'</option>';
! 1683: }
! 1684: $output .= '</select><input type="hidden" name="printfmthdr_oldpos_'.$num.
! 1685: '" value="'.$pos.'" />';
! 1686: return $output;
! 1687: }
! 1688:
! 1689: sub substitution_selector {
! 1690: my ($num,$subst,$limit) = @_;
! 1691: my %lt = &Apache::lonlocal::texthash(
! 1692: n => 'student name',
! 1693: c => 'course ID',
! 1694: a => 'assignment note',
! 1695: );
! 1696: my $output .= &mt('Substitution').'<br />'.
! 1697: '<select name=""printfmthdr_sub__'.$num.'">';
! 1698: if ($subst eq '') {
! 1699: $output .= '<option value="" selected="selected"> </option>';
! 1700: }
! 1701: foreach my $field ('n','c','a') {
! 1702: my $sel ='';
! 1703: if ($subst eq $field) {
! 1704: $sel = ' selected="selected"';
! 1705: }
! 1706: $output .= '<option value="'.$field.'"'.$sel.'>'.
! 1707: $lt{$field}.'</option>';
! 1708: }
! 1709: $output .= '</select></td><td align="left">'.&mt('Size limit').'<br />'.
! 1710: '<input type="textbox" name="printfmthdr_limit_'.$num.
! 1711: '" value="'.$limit.'" size="5" /></span>';
! 1712: return $output;
! 1713: }
! 1714:
! 1715: sub modify_crsenv {
! 1716: my ($action,$cdom,%domconfig) = @_;
! 1717: return;
! 1718: }
! 1719:
! 1720: 1;
! 1721:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>