Annotation of loncom/interface/loncreatecourse.pm, revision 1.148
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.148 ! bisitz 4: # $Id: loncreatecourse.pm,v 1.147 2013/03/01 04:37:39 raeburn Exp $
1.5 albertel 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: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.48 www 28: ###
29:
1.111 jms 30: =head1 NAME
31:
32: Apache::loncreatecourse.pm
33:
34: =head1 SYNOPSIS
35:
36: Allows domain coordinators to create new
37: courses and assign course coordinators.
38:
39: This is part of the LearningOnline Network with CAPA project
40: described at http://www.lon-capa.org.
41:
1.112 jms 42: =head1 SUBROUTINES
1.111 jms 43:
44: =over
45:
1.112 jms 46: =item handler()
1.111 jms 47:
1.112 jms 48: =item print_course_creation_page()
1.111 jms 49:
1.112 jms 50: =item create_course()
1.111 jms 51:
1.112 jms 52: =item print_intro_page()
1.111 jms 53:
1.112 jms 54: =item upload_batchfile()
1.111 jms 55:
1.112 jms 56: =item process_batchfile()
1.111 jms 57:
1.127 raeburn 58: =item courserequestbrowser_javascript()
59:
60: =item print_creation_logs()
61:
62: =item creation_display_filter()
63:
64: =item context_names()
65:
66: =item instcode_srchstr()
67:
68: =item syllabuslink_javascript()
69:
1.111 jms 70: =back
71:
72: =cut
73:
1.1 www 74: package Apache::loncreatecourse;
75:
76: use strict;
77: use Apache::Constants qw(:common :http);
78: use Apache::lonnet;
1.12 www 79: use Apache::loncommon;
1.13 www 80: use Apache::londocs;
1.38 www 81: use Apache::lonlocal;
1.105 raeburn 82: use Apache::lonuserutils;
1.96 albertel 83: use Apache::lonclonecourse;
1.90 raeburn 84: use LONCAPA::batchcreatecourse;
1.89 www 85: use LONCAPA;
1.28 www 86:
1.2 www 87: # ===================================================== Phase one: fill-in form
88:
1.10 matthew 89: sub print_course_creation_page {
1.2 www 90: my $r=shift;
1.123 raeburn 91: my $crstype = 'Community';
1.90 raeburn 92: if ($env{'form.phase'} eq 'courseone') {
93: $crstype = 'Course';
94: }
1.78 albertel 95: my $defdom=$env{'request.role.domain'};
1.147 raeburn 96: my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom);
1.101 albertel 97: my %host_servers = &Apache::lonnet::get_servers($defdom,'library');
1.10 matthew 98: my $course_home = '<select name="course_home" size="1">'."\n";
99: foreach my $server (sort(keys(%host_servers))) {
1.14 matthew 100: $course_home .= qq{<option value="$server"};
101: if ($server eq $Apache::lonnet::perlvar{'lonHostID'}) {
102: $course_home .= " selected ";
103: }
104: $course_home .= qq{>$server $host_servers{$server}</option>};
1.10 matthew 105: }
106: $course_home .= "\n</select>\n";
1.9 matthew 107: my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
1.32 www 108: my $cloneform=&Apache::loncommon::select_dom_form
1.78 albertel 109: ($env{'request.role.domain'},'clonedomain').
1.32 www 110: &Apache::loncommon::selectcourse_link
1.90 raeburn 111: ('ccrs','clonecourse','clonedomain',undef,undef,undef,$crstype);
1.78 albertel 112: my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});
1.134 raeburn 113: my ($enroll_table,$krbdef,$krbdefdom,$krbform,$intform,$locform,
1.90 raeburn 114: $javascript_validations);
1.134 raeburn 115: my $starttime = time;
116: my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
117: my $access_table = &Apache::lonuserutils::date_setting_table($starttime,
118: $endtime,'create_defaultdates');
1.90 raeburn 119: if ($crstype eq 'Course') {
1.105 raeburn 120: $enroll_table = &Apache::lonuserutils::date_setting_table($starttime,
121: $endtime,'create_enrolldates');
1.90 raeburn 122: ($krbdef,$krbdefdom) =
123: &Apache::loncommon::get_kerberos_defaults($defdom);
1.105 raeburn 124: $javascript_validations=&Apache::lonuserutils::javascript_validations(
1.90 raeburn 125: 'createcourse',$krbdefdom);
126: my %param = ( formname => 'document.ccrs',
127: kerb_def_dom => $krbdefdom,
128: kerb_def_auth => $krbdef
129: );
130: $krbform = &Apache::loncommon::authform_kerberos(%param);
131: $intform = &Apache::loncommon::authform_internal(%param);
132: $locform = &Apache::loncommon::authform_local(%param);
133: } else {
1.123 raeburn 134: my $title_alert = &mt('A Community title is required');
135: my $coord_alert = &mt('The username of the Coordinator is required');
1.90 raeburn 136: $javascript_validations = qq|
137: function validate(formname) {
138: if (formname.title == '') {
1.123 raeburn 139: alert("$title_alert");
1.90 raeburn 140: return;
141: }
142: if (formname.ccuname == '') {
1.123 raeburn 143: alert("$coord_alert");
1.90 raeburn 144: }
145: formname.submit();
146: }
147: |;
148: }
1.46 sakharuk 149: my %lt=&Apache::lonlocal::texthash(
150: 'cinf' => "Course Information",
151: 'ctit' => "Course Title",
152: 'chsr' => "Course Home Server",
153: 'cidn' => "Course ID/Number",
154: 'opt' => "optional",
155: 'iinf' => "Institutional Information",
156: 'stat' => "The following entries will be used to identify the course according to the naming scheme adopted by your institution. Your choices will be used to map an internal LON-CAPA course ID to the corresponding course section ID(s) used by the office responsible for providing official class lists for courses at your institution. This mapping is required if you choose to employ automatic population of class lists.",
157: 'ccod' => "Course Code",
158: 'toin' => "to interface with institutional data, e.g., fs03glg231 for Fall 2003 Geology 231",
1.90 raeburn 159: 'snid' => "Section Numbers and corresponding LON-CAPA section IDs",
160: 'csli' => "a comma separated list of institutional section numbers, each separated by a colon from the (optional) corresponding section ID to be used in LON-CAPA e.g., 001:1,002:2",
1.46 sakharuk 161: 'crcs' => "Crosslisted courses",
1.90 raeburn 162: 'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) sectionID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2",
1.147 raeburn 163: 'ccre' => "Course credits",
164: 'cred' => "the number of institutional credits students will earn by completing this course",
1.46 sakharuk 165: 'crco' => "Course Content",
166: 'cncr' => "Completely new course",
167: 'cecr' => "Clone an existing course",
168: 'map' => "Map",
169: 'smap' => "Select Map",
170: 'sacr' => "Do NOT generate as standard course",
171: 'ocik' => "only check if you know what you are doing",
172: 'fres' => "First Resource",
173: 'stco' => "standard courses only",
174: 'blnk' => "Blank",
175: 'sllb' => "Syllabus",
1.132 raeburn 176: 'navi' => "Course Contents",
1.46 sakharuk 177: 'cid' => "Course ID",
178: 'dmn' => "Domain",
1.110 bisitz 179: 'dsh' => "Date Shift",
1.46 sakharuk 180: 'asov' => "Additional settings, if specified below, will override cloned settings",
1.106 www 181: 'ncd' => "Do not clone date parameters",
182: 'prd' => 'Clone date parameters as-is',
183: 'shd' => 'Shift date parameters by number of days',
1.46 sakharuk 184: 'assp' => "Assessment Parameters",
185: 'oaas' => "Open all assessments",
186: 'mssg' => "Messaging",
187: 'scpf' => "Set course policy feedback to Course Coordinator",
188: 'scfc' => "Set content feedback to Course Coordinator",
189: 'cmmn' => "Communication",
190: 'dsrd' => "Disable student resource discussion",
1.117 hauer 191: 'dsuc' => "Disable student use of chat rooms",
1.46 sakharuk 192: 'acco' => "Access Control",
193: 'snak' => "Students need access key to enter course",
1.124 raeburn 194: 'ow' => "Course Owner",
195: 'cc' => "(will be assigned Course Coordinator role)",
1.46 sakharuk 196: 'user' => "Username",
197: 'aens' => "Automated enrollment settings",
198: 'aesc' => "The following settings control automatic enrollment of students in this class based on information available for this specific course from your institution's official classlists.",
199: 'aadd' => "Automated adds",
200: 'yes' => "Yes",
201: 'no' => "No",
202: 'audr' => "Automated drops",
203: 'dacu' => "Duration of automated classlist updates",
1.119 bisitz 204: 'dads' => 'Default Access Dates for Students',
1.60 raeburn 205: 'dacc' => "Default start and end dates for student access",
1.134 raeburn 206: 'psam' => "Authentication mechanism",
207: 'pcda' => "Default authentication method for new users added to this domain by the automated enrollment process",
1.46 sakharuk 208: 'nech' => "Notification of enrollment changes",
209: 'nccl' => "Notification to course coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.77 raeburn 210: 'ndcl' => "Notification to domain coordinator via LON-CAPA message when enrollment changes occur during the automated update?",
1.46 sakharuk 211: 'irsp' => "Include retrieval of student photographs?",
1.55 www 212: 'rshm' => 'Resource Space Home',
1.93 raeburn 213: 'cgrs' => "Course Group Settings",
1.119 bisitz 214: 'cgrq' => 'Set a quota for the total disk space available for storage of course group portfolio files',
1.133 raeburn 215: 'opco' => 'Open Course',
216: 'opcm' => 'Open Community',
217: );
218: $lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than course','<tt>','</tt>');
219:
220: if ($crstype eq 'Community') {
221: $lt{'cinf'} = &mt('Community Information');
222: $lt{'ctit'} = &mt('Community Title');
223: $lt{'chsr'} = &mt('Community Home Server');
224: $lt{'cidn'} = &mt('Community ID/Number');
225: $lt{'crco'} = &mt('Community Content');
226: $lt{'cncr'} = &mt('Completely new community');
227: $lt{'cecr'} = &mt('Clone an existing community');
228: $lt{'sacr'} = &mt('Do NOT generate as standard community');
229: $lt{'stco'} = &mt('standard communities only');
230: $lt{'navi'} = &mt('Community Contents');
231: $lt{'cid'} = &mt('Community ID');
232: $lt{'scpf'} = &mt('Set community policy feedback to Coordinator');
233: $lt{'scfc'} = &mt('Set content feedback to Coordinator');
234: $lt{'dsrd'} = &mt('Disable member resource discussion');
235: $lt{'dsuc'} = &mt('Disable member use of chat rooms');
236: $lt{'dads'} = &mt('Default Access Dates for Members');
237: $lt{'dacc'} = &mt('Default start and end dates for member access');
238: $lt{'snak'} = &mt('Members need access key to enter course');
239: $lt{'kaut'} = &mt('Key authority ([_1]id:domain[_2]) if other than community','<tt>','</tt>');
240: $lt{'ow'} = &mt('Community Owner');
241: $lt{'cc'} = &mt('(will be assigned Coordinator role)');
242: $lt{'cgrs'} = &mt('Community Group Settings');
243: $lt{'cgrq'} = &mt('Set a quota for the total disk space available for storage of community group portfolio files');
244: }
1.86 albertel 245: my $js = <<END;
246: <script type="text/javascript">
1.6 matthew 247: var editbrowser = null;
248: function openbrowser(formname,elementname) {
249: var url = '/res/?';
250: if (editbrowser == null) {
251: url += 'launch=1&';
252: }
253: url += 'catalogmode=interactive&';
254: url += 'mode=edit&';
255: url += 'form=' + formname + '&';
1.7 matthew 256: url += 'element=' + elementname + '&';
257: url += 'only=sequence' + '';
1.6 matthew 258: var title = 'Browser';
259: var options = 'scrollbars=1,resizable=1,menubar=0';
260: options += ',width=700,height=600';
261: editbrowser = open(url,title,options,'1');
262: editbrowser.focus();
263: }
1.41 raeburn 264: $javascript_validations
1.6 matthew 265: </script>
1.32 www 266: $coursebrowserjs
1.86 albertel 267: END
268:
1.90 raeburn 269: my %titles = &Apache::lonlocal::texthash(
270: courseone => 'Create a New Course',
1.123 raeburn 271: groupone => 'Create a New Community',
1.90 raeburn 272: );
1.86 albertel 273: my $start_page =
1.90 raeburn 274: &Apache::loncommon::start_page($titles{$env{'form.phase'}},$js);
1.86 albertel 275: my $end_page =
276: &Apache::loncommon::end_page();
1.91 albertel 277: my $crumbs =
278: &Apache::lonhtmlcommon::breadcrumbs($crstype.' Information',
279: 'Create_Course',undef,
280: 'Create_Courses');
1.90 raeburn 281: $r->print($start_page.$crumbs);
1.110 bisitz 282:
1.133 raeburn 283: $r->print('<form action="/adm/createcourse" method="post" name="ccrs"><div class="LC_createcourse">'
284: .&Apache::lonhtmlcommon::start_pick_box()
285:
286: .&Apache::lonhtmlcommon::row_headline()
287: .'<h3>'.$lt{'ow'}.' '.$lt{'cc'}.'</h3>'
288: .&Apache::lonhtmlcommon::row_closure()
289:
290: .&Apache::lonhtmlcommon::row_title($lt{'user'})
291: .'<input type="text" size="15" name="ccuname" />'
292: .&Apache::loncommon::studentbrowser_javascript()
293: .&Apache::loncommon::selectstudent_link('ccrs','ccuname','ccdomain')
294: .&Apache::lonhtmlcommon::row_closure()
295:
296: .&Apache::lonhtmlcommon::row_title($lt{'dmn'},"","LC_odd_row_value")
297: .$domform
298: .&Apache::lonhtmlcommon::row_closure()
299:
300: .&Apache::lonhtmlcommon::row_headline()
301: .'<h3>'.$lt{'cinf'}.'</h3>'
302: .&Apache::lonhtmlcommon::row_closure()
303:
304: .&Apache::lonhtmlcommon::row_title($lt{'ctit'})
1.145 www 305: .'<input type="text" size="80" name="title" />'
1.133 raeburn 306: .&Apache::lonhtmlcommon::row_closure()
307:
308: .&Apache::lonhtmlcommon::row_title($lt{'chsr'})
309: .$course_home
310: .&Apache::lonhtmlcommon::row_closure()
311:
312: .&Apache::lonhtmlcommon::row_title($lt{'cidn'}.' ('.$lt{'opt'}.')')
313: .'<input type="text" size="30" name="crsid" />'
314: .&Apache::lonhtmlcommon::row_closure()
315: );
1.90 raeburn 316: if ($crstype eq 'Course') {
1.133 raeburn 317: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 318: .'<h3>'.$lt{'iinf'}.'</h3>'
1.147 raeburn 319: .$lt{'stat'}.' '
320: .&mt('Default credits can also be specified, if different from the domain defaults (official courses: [_1]; unofficial courses: [_2]).',
321: $domdefaults{'officialcredits'},$domdefaults{'unofficialcredits'})
1.109 bisitz 322: .&Apache::lonhtmlcommon::row_closure()
323:
324: .&Apache::lonhtmlcommon::row_title($lt{'ccod'})
325: .'<input type="text" size="30" name="crscode" />'
326: .'<br />('.$lt{'toin'}.')'
327: .&Apache::lonhtmlcommon::row_closure()
328:
329: .&Apache::lonhtmlcommon::row_title($lt{'snid'})
330: .'<input type="text" size="30" name="crssections" />'
331: .'<br />('.$lt{'csli'}.')'
332: .&Apache::lonhtmlcommon::row_closure()
333:
334: .&Apache::lonhtmlcommon::row_title($lt{'crcs'})
335: .'<input type="text" size="30" name="crsxlist" />'
336: .'<br />('.$lt{'cscs'}.')'
337: .&Apache::lonhtmlcommon::row_closure()
1.110 bisitz 338: );
1.147 raeburn 339: if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) {
340: $r->print(&Apache::lonhtmlcommon::row_title($lt{'ccre'})
341: .'<input type="text" size="3" name="defaultcredits" />'
342: .'<br />('.$lt{'cred'}.')'
343: .&Apache::lonhtmlcommon::row_closure()
344: );
345: }
1.133 raeburn 346: }
347: # Table: New Course / Clone Course
348: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 349: .'<h3>'.$lt{'crco'}.'</h3>'
1.110 bisitz 350: .&Apache::loncommon::start_data_table()
351: .&Apache::loncommon::start_data_table_header_row()
352: .'<th>'.$lt{'cncr'}.'</th>'
353: .'<th> '.&mt('or').' </th>'
354: .'<th>'.$lt{'cecr'}.'</th>'
355: .&Apache::loncommon::end_data_table_header_row()
356: .&Apache::loncommon::start_data_table_row()
357:
358: # New Course:
359: .'<td>'
360: .&Apache::lonhtmlcommon::start_pick_box()
361: .&Apache::lonhtmlcommon::row_title($lt{'map'})
362: .'<input type="text" size="50" name="topmap" />'
363: .'<a href="javascript:openbrowser(\'ccrs\',\'topmap\')">'.$lt{'smap'}.'</a>'
364: .&Apache::lonhtmlcommon::row_closure()
365: .&Apache::lonhtmlcommon::row_title('<label for="nonstd">'.$lt{'sacr'}.'</label>')
366: .'<input id="nonstd" type="checkbox" name="nonstandard" />'
367: .'<br />('.$lt{'ocik'}.')'
368: .&Apache::lonhtmlcommon::row_closure()
369: .&Apache::lonhtmlcommon::row_title($lt{'fres'})
370: .'<label>'
371: .'<input type="radio" name="firstres" value="blank" />'.$lt{'blnk'}
372: .'</label>'
1.139 raeburn 373: .' ');
374: if ($crstype eq 'Community') {
375: $r->print('<label>'
376: .'<input type="radio" name="firstres" value="nav" checked="checked" />'.$lt{'navi'}
377: .'</label>');
378: } else {
379: $r->print('<label>'
1.110 bisitz 380: .'<input type="radio" name="firstres" value="syl" checked="checked" />'.$lt{'sllb'}
381: .'</label>'
382: .' '
383: .'<label>'
384: .'<input type="radio" name="firstres" value="nav" />'.$lt{'navi'}
1.139 raeburn 385: .'</label>');
386: }
387: $r->print('<br />('.$lt{'stco'}.')'
1.110 bisitz 388: .&Apache::lonhtmlcommon::row_closure(1)
389: .&Apache::lonhtmlcommon::end_pick_box()
1.109 bisitz 390:
1.110 bisitz 391: .'<td> </td>'
1.109 bisitz 392:
1.110 bisitz 393: # Clone Course:
394: .'<td>'
395: .&Apache::lonhtmlcommon::start_pick_box()
396: .&Apache::lonhtmlcommon::row_title($lt{'cid'})
397: .'<label>'
398: .'<input type="text" size="25" name="clonecourse" value="" />'
399: .'</label>'
400: .&Apache::lonhtmlcommon::row_closure(1)
401: .&Apache::lonhtmlcommon::row_title($lt{'dmn'})
402: .'<label>'
403: .$cloneform
404: .'</label>'
405: .&Apache::lonhtmlcommon::row_closure()
406: .&Apache::lonhtmlcommon::row_title($lt{'dsh'})
407: .'<label>'
408: .'<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}
409: .'</label><br />'
410: .'<label>'
411: .'<input type="radio" name="datemode" value="preserve" /> '.$lt{'prd'}
412: .'</label><br />'
413: .'<label>'
414: .'<input type="radio" name="datemode" value="shift" checked="checked" /> '.$lt{'shd'}
415: .'</label>'
416: .' <input type="text" size="5" name="dateshift" value="365" />'
417: .&Apache::lonhtmlcommon::row_closure()
418: .&Apache::lonhtmlcommon::row_headline()
1.146 bisitz 419: .'<span class="LC_info">'.$lt{'asov'}.'</span>'
1.110 bisitz 420: .&Apache::lonhtmlcommon::row_closure(1)
421: .&Apache::lonhtmlcommon::end_pick_box()
422: .'</td>'
423: .&Apache::loncommon::end_data_table_row()
424: .&Apache::loncommon::end_data_table()
1.109 bisitz 425: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 426: );
1.109 bisitz 427:
1.133 raeburn 428: $r->print(&Apache::lonhtmlcommon::row_headline()
1.119 bisitz 429: .'<h3>'.$lt{'dads'}.'</h3>'
430: .&Apache::lonhtmlcommon::row_closure()
431: .&Apache::lonhtmlcommon::row_title($lt{'dacc'})
432: .$access_table
433: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 434: );
1.119 bisitz 435:
1.133 raeburn 436: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 437: .'<h3>'.$lt{'assp'}.'</h3>'
438: .&Apache::lonhtmlcommon::row_closure()
439:
440: .&Apache::lonhtmlcommon::row_title($lt{'oaas'})
441: .'<input type="checkbox" name="openall" />'
442: .&Apache::lonhtmlcommon::row_closure()
443:
444: .&Apache::lonhtmlcommon::row_headline()
445: .'<h3>'.$lt{'mssg'}.'</h3>'
446: .&Apache::lonhtmlcommon::row_closure()
447:
448: .&Apache::lonhtmlcommon::row_title($lt{'scpf'})
449: .'<input type="checkbox" name="setpolicy" checked="checked" />'
450: .&Apache::lonhtmlcommon::row_closure()
451:
452: .&Apache::lonhtmlcommon::row_title($lt{'scfc'})
453: .'<input type="checkbox" name="setcontent" checked="checked" />'
454: .&Apache::lonhtmlcommon::row_closure()
455:
456: .&Apache::lonhtmlcommon::row_headline()
457: .'<h3>'.$lt{'cmmn'}.'</h3>'
458: .&Apache::lonhtmlcommon::row_closure()
459:
460: .&Apache::lonhtmlcommon::row_title($lt{'dsrd'})
461: .'<input type="checkbox" name="disresdis" />'
462: .&Apache::lonhtmlcommon::row_closure()
463:
464: .&Apache::lonhtmlcommon::row_title($lt{'dsuc'})
1.120 bisitz 465: .'<input type="checkbox" name="disablechat" />'
1.109 bisitz 466: .&Apache::lonhtmlcommon::row_closure()
467:
468: .&Apache::lonhtmlcommon::row_headline()
469: .'<h3>'.$lt{'acco'}.'</h3>'
470: .&Apache::lonhtmlcommon::row_closure()
471:
472: .&Apache::lonhtmlcommon::row_title($lt{'snak'})
473: .'<input type="checkbox" name="setkeys" />'
474: .&Apache::lonhtmlcommon::row_closure()
475:
476: .&Apache::lonhtmlcommon::row_title($lt{'kaut'})
477: .'<input type="text" size="30" name="keyauth" />'
478: .&Apache::lonhtmlcommon::row_closure()
479:
480: .&Apache::lonhtmlcommon::row_headline()
481: .'<h3>'.$lt{'rshm'}.'</h3>'
482: .&Apache::lonhtmlcommon::row_closure()
483:
484: .&Apache::lonhtmlcommon::row_title($lt{'rshm'})
485: .'<input type="text" name="reshome" size="30" value="/res/'.$defdom.'/" />'
486: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 487: );
488: if ($crstype eq 'Course') {
489: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 490: .'<h3>'.$lt{'aens'}.'</h3>'
491: .&Apache::lonhtmlcommon::row_closure()
492:
493: .&Apache::lonhtmlcommon::row_title($lt{'aadd'})
494: .'<label><input type="radio" name="autoadds" value="1" />'.$lt{'yes'}.'</label>'
495: .'<label><input type="radio" name="autoadds" value="0" checked="checked" />'.$lt{'no'}.'</label>'
496: .&Apache::lonhtmlcommon::row_closure()
497:
498: .&Apache::lonhtmlcommon::row_title($lt{'audr'})
499: .'<label><input type="radio" name="autodrops" value="1" />'.$lt{'yes'}.'</label>'
500: .'<label><input type="radio" name="autodrops" value="0" checked="checked" />'.$lt{'no'}.'</label>'
501: .&Apache::lonhtmlcommon::row_closure()
502:
503: .&Apache::lonhtmlcommon::row_title($lt{'dacu'})
504: .$enroll_table
505: .&Apache::lonhtmlcommon::row_closure()
506:
507: .&Apache::lonhtmlcommon::row_title($lt{'psam'})
508: .$lt{'pcda'}.'<br />'
509: .$krbform.'<br />'
510: .$intform.'<br />'
511: .$locform
512: .&Apache::lonhtmlcommon::row_closure()
513:
514: .&Apache::lonhtmlcommon::row_title($lt{'nech'})
515: .$lt{'nccl'}.'<br/>'
516: .'<label><input type="radio" name="notify_owner" value="1" />'.$lt{'yes'}.'</label>'
517: .'<label><input type="radio" name="notify_owner" value="0" checked="checked" />'.$lt{'no'}.'</label>'
518: .'<br />'
519: .$lt{'ndcl'}.'<br/>'
520: .'<label><input type="radio" name="notify_dc" value="1" />'.$lt{'yes'}.'</label>'
521: .'<label><input type="radio" name="notify_dc" value="0" checked="checked" />'.$lt{'no'}.'</label>'
522: .&Apache::lonhtmlcommon::row_closure()
523:
524: .&Apache::lonhtmlcommon::row_title($lt{'irsp'})
525: .'<label>'
526: .'<input type="radio" name="showphotos" value="1" />'.$lt{'yes'}
527: .'</label> '
528: .'<label>'
529: .'<input type="radio" name="showphotos" value="0" checked="checked" />'.$lt{'no'}
530: .'</label> '
531: .&Apache::lonhtmlcommon::row_closure()
1.133 raeburn 532: );
533: }
534:
535: $r->print(&Apache::lonhtmlcommon::row_headline()
1.109 bisitz 536: .'<h3>'.$lt{'cgrs'}.'</h3>'
537: .&Apache::lonhtmlcommon::row_closure()
538:
539: .&Apache::lonhtmlcommon::row_title($lt{'cgrq'})
540: .'<input type="text" name="crsquota" value="20" size="6" />Mb'
541: .&Apache::lonhtmlcommon::row_closure(1)
542:
543: .&Apache::lonhtmlcommon::end_pick_box()
1.133 raeburn 544: .'</div>'
545: );
546: if ($crstype eq 'Course') {
547: $r->print('
1.55 www 548: <p>
1.90 raeburn 549: <input type="hidden" name="prevphase" value="courseone" />
550: <input type="hidden" name="phase" value="coursetwo" />
1.148 ! bisitz 551: <input type="button" onclick="verify_message(this.form)" value="'.$lt{'opco'}.'" />'
1.133 raeburn 552: );
1.123 raeburn 553: } elsif ($crstype eq 'Community') {
1.133 raeburn 554: $r->print('
1.90 raeburn 555: <p>
556: <input type="hidden" name="prevphase" value="groupone" />
557: <input type="hidden" name="phase" value="grouptwo" />
1.133 raeburn 558: <input type="submit" value="'.$lt{'opcm'}.'" />
559: </p>'
560: );
1.90 raeburn 561: }
1.133 raeburn 562: $r->print('</form>'.
563: $end_page);
1.40 raeburn 564: }
565:
1.2 www 566: # ====================================================== Phase two: make course
567:
1.10 matthew 568: sub create_course {
1.2 www 569: my $r=shift;
1.99 albertel 570: my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
571: my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
1.123 raeburn 572: my $crstype = 'Community';
1.90 raeburn 573: my ($enrollstart,$enrollend,$startaccess,$endaccess);
1.147 raeburn 574: my %domdefaults =
575: &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
1.74 raeburn 576:
1.90 raeburn 577: if ($env{'form.phase'} eq 'coursetwo') {
578: $crstype='Course';
579: $enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
580: $enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
581: }
582: $startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
583: $endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
1.74 raeburn 584:
585: my $autharg;
586: my $authtype;
587:
1.78 albertel 588: if ($env{'form.login'} eq 'krb') {
1.74 raeburn 589: $authtype = 'krb';
1.78 albertel 590: $authtype .=$env{'form.krbver'};
591: $autharg = $env{'form.krbarg'};
592: } elsif ($env{'form.login'} eq 'int') {
1.74 raeburn 593: $authtype ='internal';
1.78 albertel 594: if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
595: $autharg = $env{'form.intarg'};
1.74 raeburn 596: }
1.78 albertel 597: } elsif ($env{'form.login'} eq 'loc') {
1.74 raeburn 598: $authtype = 'localauth';
1.78 albertel 599: if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
600: $autharg = $env{'form.locarg'};
1.74 raeburn 601: }
602: }
1.90 raeburn 603: my $logmsg;
1.91 albertel 604: my $start_page=&Apache::loncommon::start_page('Create a New '.$crstype);
1.90 raeburn 605: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
1.74 raeburn 606:
1.90 raeburn 607: $r->print($start_page.$crumbs);
1.74 raeburn 608:
609: my $args = {
1.90 raeburn 610: crstype => $crstype,
1.74 raeburn 611: ccuname => $ccuname,
612: ccdomain => $ccdomain,
1.78 albertel 613: cdescr => $env{'form.title'},
614: curl => $env{'form.topmap'},
615: course_domain => $env{'request.role.domain'},
616: course_home => $env{'form.course_home'},
617: nonstandard => $env{'form.nonstandard'},
618: crscode => $env{'form.crscode'},
1.93 raeburn 619: crsquota => $env{'form.crsquota'},
1.103 raeburn 620: clonecourse => $env{'form.clonecourse'},
621: clonedomain => $env{'form.clonedomain'},
1.106 www 622: datemode => $env{'form.datemode'},
623: dateshift => $env{'form.dateshift'},
1.78 albertel 624: crsid => $env{'form.crsid'},
1.94 raeburn 625: curruser => $env{'user.name'}.':'.$env{'user.domain'},
1.78 albertel 626: crssections => $env{'form.crssections'},
627: crsxlist => $env{'form.crsxlist'},
628: autoadds => $env{'form.autoadds'},
629: autodrops => $env{'form.autodrops'},
630: notify_owner => $env{'form.notify_owner'},
631: notify_dc => $env{'form.notify_dc'},
632: no_end_date => $env{'form.no_end_date'},
633: showphotos => $env{'form.showphotos'},
1.74 raeburn 634: authtype => $authtype,
635: autharg => $autharg,
636: enrollstart => $enrollstart,
637: enrollend => $enrollend,
638: startaccess => $startaccess,
639: endaccess => $endaccess,
1.78 albertel 640: setpolicy => $env{'form.setpolicy'},
641: setcontent => $env{'form.setcontent'},
642: reshome => $env{'form.reshome'},
643: setkeys => $env{'form.setkeys'},
644: keyauth => $env{'form.keyauth'},
645: disresdis => $env{'form.disresdis'},
646: disablechat => $env{'form.disablechat'},
647: openall => $env{'form.openall'},
648: firstres => $env{'form.firstres'}
1.74 raeburn 649: };
650:
1.147 raeburn 651: if (($crstype eq 'Course') &&
652: ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'})) {
653: $args->{'defaultcredits'} = $env{'form.defaultcredits'};
654: }
655:
1.10 matthew 656: #
657: # Verify data
658: #
659: # Check the veracity of the course coordinator
1.2 www 660: if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
1.52 albertel 661: $r->print('<form action="/adm/createuser" method="post" name="crtuser">');
1.108 bisitz 662: $r->print('<div class="LC_warning">'
663: .&mt('No such user [_1] at domain [_2].','<tt>'.$ccuname.'</tt>','<tt>'.$ccdomain.'</tt>')
664: .'</div>');
665: $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
666: , '<input type="hidden" name="phase" value="get_user_info" />'
667: .'<input type="hidden" name="ccuname" value="'.$ccuname.'" />'
668: .'<input type="hidden" name="ccdomain" value="'.$ccdomain.'" />'
669: .'<input name="userrole" type="submit" value="'
670: , '" />'
671: )
672: .'</form>'.&Apache::loncommon::end_page()
673: );
1.2 www 674: return;
675: }
1.10 matthew 676: # Check the proposed home server for the course
1.101 albertel 677: my %host_servers =
678: &Apache::lonnet::get_servers($env{'request.role.domain'},'library');
1.78 albertel 679: if (! exists($host_servers{$env{'form.course_home'}})) {
1.108 bisitz 680: $r->print(&mt('Invalid home server for course: [_1]'
681: ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
1.10 matthew 682: return;
683: }
1.74 raeburn 684: my ($courseid,$crsudom,$crsunum);
1.104 albertel 685: my ($success,$output) =
686: &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
687: \$crsudom,\$crsunum,
688: $env{'user.domain'},
1.127 raeburn 689: $env{'user.name'},'dc_create');
1.104 albertel 690: $r->print($output);
691: if ($success) {
692: #
693: # Make the requested user a course coordinator or group coordinator
694: #
695: if (($ccdomain) && ($ccuname)) {
1.130 raeburn 696: my $ccrole = 'cc';
697: if ($crstype eq 'Community') {
698: $ccrole = 'co';
699: }
1.114 bisitz 700: $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
701: ,'<i>'.$ccuname.':'.$ccdomain.'</i>')
702: .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
1.130 raeburn 703: $ccrole,'','','','','createcourse').'<p>');
1.104 albertel 704: }
705: if ($env{'form.setkeys'}) {
706: $r->print(
707: '<p><a href="/adm/managekeys?cid='.$crsudom.'_'.$crsunum.'">'.&mt('Manage Access Keys').'</a></p>');
708: }
709: # Flush the course logs so reverse user roles immediately updated
1.144 raeburn 710: $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
1.104 albertel 711: $r->print('<p>'.&mt('Roles will be active at next login').'.</p>');
712: }
713: $r->print('<p><a href="/adm/createcourse?phase='.lc($crstype).'one">'.
1.114 bisitz 714: &mt("Create Another $crstype").'</a></p>'.
1.86 albertel 715: &Apache::loncommon::end_page());
1.74 raeburn 716: }
717:
1.90 raeburn 718: sub print_intro_page {
1.137 raeburn 719: my ($r,$show_all_choices) = @_;
1.90 raeburn 720: my $start_page =
1.123 raeburn 721: &Apache::loncommon::start_page('Create a New Course or Community');
1.90 raeburn 722: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
723: my $end_page =
724: &Apache::loncommon::end_page();
1.123 raeburn 725: my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
1.138 bisitz 726:
727: # Create menu
728: my @menu;
729: @menu =
730: ({ categorytitle => 'Course/Community Creation',
731: items => [
732: {
733: linktext => 'Create a single course',
734: url => '/adm/createcourse?phase=courseone',
735: permission => 1,
736: #help => '',
1.140 bisitz 737: icon => 'crsnew.png',
1.138 bisitz 738: linktitle => 'Create a new course by completing an online form.'
739: },
740: {
741: linktext => 'Create a single community',
742: url => '/adm/createcourse?phase=groupone',
743: permission => $show_all_choices,
744: #help => '',
1.140 bisitz 745: icon => 'crsnew.png',
1.138 bisitz 746: linktitle => 'Create a new collaborative community by completing an online form.'
747: },
748: {
749: linktext => 'Create courses/communities by uploading an attributes file',
750: url => '/adm/createcourse?phase=batchone',
751: permission => 1,
752: help => 'Batch_Creation',
1.140 bisitz 753: icon => 'uplcrs.png',
1.138 bisitz 754: linktitle => 'Upload an attributes file containing specifications for one or more courses or communities in XML format.'
755: },
756: ]
757: },
758: { categorytitle => 'Course/Community Requests',
759: items => [
760: {
761: linktext => 'Approve or reject requests',
762: url => '/adm/createcourse?phase=requestdisplay',
763: permission => $show_all_choices,
764: #help => '',
1.140 bisitz 765: icon => 'rcrs.png',
1.138 bisitz 766: linktitle => 'Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'
767: },
768: {
1.142 raeburn 769: linktext => 'View pending official course requests',
1.138 bisitz 770: url => '/adm/createcourse?phase=pendingdisplay',
771: permission => $show_all_choices,
772: #help => '',
1.142 raeburn 773: icon => 'edit-find.png',
1.140 bisitz 774: alttext => '',
1.138 bisitz 775: linktitle => 'Display official course requests submitted by authorized users, held pending validation of instructor status.'
776: },
777: ]
778: },
779: { categorytitle => 'Administration',
780: items => [
781: {
782: linktext => 'View creation log',
783: url => '/adm/createcourse?phase=creationlog',
784: permission => $show_all_choices,
785: #help => '',
786: icon => 'document-properties.png',
787: linktitle => 'Display information about when, how and by whom courses and communities were created in this domain.'
788: },
789: ]
790: },
791: );
792:
793: $r->print(
794: $start_page
795: .$crumbs
796: .&Apache::lonhtmlcommon::generate_menu(@menu)
797: .$end_page
798: );
1.90 raeburn 799: }
800:
801: sub upload_batchfile {
802: my $r = shift;
803: my $start_page =
1.123 raeburn 804: &Apache::loncommon::start_page('Create a New Course or Community');
805: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses');
1.90 raeburn 806: my $end_page =
807: &Apache::loncommon::end_page();
808: $r->print($start_page.$crumbs);
1.127 raeburn 809: $r->print('<h3>'.&mt('Upload a courses or communities attributes file').'</h3>');
1.90 raeburn 810: $r->print('<form name="batchcreate" method="post" '.
811: 'enctype="multipart/form-data" action="/adm/createcourse">'.
812: '<input type="file" name="coursecreatorxml" />'.
1.121 bisitz 813: '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90 raeburn 814: '<input type="submit" name="batchsubmit" '.
1.138 bisitz 815: 'value="'.&mt('Create Courses/Communities').'" /></form>');
1.90 raeburn 816: $r->print($end_page);
817: return;
818: }
819:
820: sub process_batchfile {
821: my $r = shift;
822: my $start_page =
1.123 raeburn 823: &Apache::loncommon::start_page('Create a New Course or Community');
1.90 raeburn 824: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
825: my $end_page =
826: &Apache::loncommon::end_page();
827: my $defdom=$env{'request.role.domain'};
828: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
829: 'batchupload',undef,undef,
830: undef,undef,$defdom);
831: my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
832: my ($result,$logmsg);
833: if (-e "$batchfilepath") {
834: open(FILE,"<$batchfilepath");
835: my @buffer = <FILE>;
836: close(FILE);
837: if ((defined($filename)) && (defined($batchdir))) {
838: my @requests = ($filename);
839: my %courseids = ();
840: ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
841: \@requests,\%courseids,'web',$defdom,
842: $env{'user.name'},$env{'user.domain'});
843: if ($result) {
844: if (!-e "$batchdir/processed") {
845: mkdir("$batchdir/processed", 0755);
846: open(FILE,">$batchdir/processed/$filename");
847: print FILE @buffer;
848: close(FILE);
849: if (-e "$batchdir/processed/$filename") {
850: unlink("$batchdir/pending/$filename");
851: }
852: }
853: }
854: }
855: }
1.103 raeburn 856: $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
857: &mt('Creation options menu').'</a>'.$end_page);
1.90 raeburn 858:
859: }
860:
1.126 raeburn 861: sub courserequestbrowser_javascript {
862: return <<"ENDREQBRW";
863: <script type="text/javascript">
864: // <![CDATA[
865: var steditbrowser;
1.136 raeburn 866: function opencoursereqdisplay(cdom,cnum,queue) {
1.126 raeburn 867: var url = '/adm/requestcourse?action=display';
1.136 raeburn 868: url += '&showdom='+cdom+'&cnum='+cnum+'&queue='+queue;
1.126 raeburn 869: var title = 'Course_Request_Browser';
870: var options = 'scrollbars=1,resizable=1,menubar=0';
871: options += ',width=700,height=600';
872: var stdeditbrowser = open(url,title,options,'1');
873: stdeditbrowser.focus();
874: }
1.136 raeburn 875:
1.126 raeburn 876: // ]]>
877: </script>
878: ENDREQBRW
879: }
880:
1.127 raeburn 881: sub print_creation_logs {
882: my ($r) = @_;
883: my $formname = 'creationlog';
884: my $dom = $env{'request.role.domain'};
885: $r->print('<form action="/adm/createcourse" method="post" name="'.$formname.'">');
886: # set defaults
887: my $now = time();
888: my $defstart = $now - (7*24*3600); #7 days ago
889: my %defaults = (
890: page => '1',
891: show => '10',
892: type => 'any',
893: context => 'any',
894: created_before_date => $now,
895: created_after_date => $defstart,
896: );
897: my ($contexts,$contextnames) = &context_names();
898: my $more_records = 0;
899: my %curr;
900: foreach my $item ('show','page','type','context') {
901: $curr{$item} = $env{'form.'.$item};
902: }
903: $curr{'created_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
904: $curr{'created_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
905: foreach my $key (keys(%defaults)) {
906: if ($curr{$key} eq '') {
907: $curr{$key} = $defaults{$key};
908: }
909: }
1.135 raeburn 910: my %whodunit;
911: $r->print(&creation_display_filter($formname,\%curr));
1.127 raeburn 912: my $showntablehdr = 0;
913: my $tablehdr = &Apache::loncommon::start_data_table().
914: &Apache::loncommon::start_data_table_header_row().
915: '<th> </th><th>'.&mt('Creation Date').'</th>'.
916: '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
1.131 raeburn 917: '<th>'.&mt('Owner(s)').'</th>';
1.127 raeburn 918: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
919: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
1.128 raeburn 920: }
921: if ($curr{'type'} eq 'any') {
922: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
923: }
1.129 raeburn 924: if ($curr{'context'} eq 'any') {
1.128 raeburn 925: $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
926: }
927: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
1.127 raeburn 928: my ($minshown,$maxshown);
929: $minshown = 1;
930: my $count = 0;
931: if ($curr{'show'} ne &mt('all')) {
932: $maxshown = $curr{'page'} * $curr{'show'};
933: if ($curr{'page'} > 1) {
934: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
935: }
936: }
937: my $crstype = 'Course';
938: if ($curr{'type'} eq 'any') {
939: $crstype = '.';
940: } elsif ($curr{'type'} eq 'community') {
941: $crstype = 'Community';
942: }
943:
944: my ($instcodefilter,$regexpok);
945: my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
946: my ($jscript,$totcodes,$numtitles,$lasttitle) =
947: &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
948: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
949: $officialjs);
950: if ($numtitles) {
951: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
952: $instcodefilter = &instcode_srchstr($dom,$numtitles);
1.141 raeburn 953: &Apache::courseclassifier::instcode_search_str($dom,$numtitles,\@codetitles);
1.127 raeburn 954: if ($curr{'type'} eq 'official') {
955: $regexpok = 1;
956: } else {
957: unless ($instcodefilter eq '') {
958: $regexpok = -1;
959: }
960: }
961: }
962: }
963: if ($instcodefilter eq '') { $instcodefilter = '.'; }
964:
965: my $creationcontext = '.';
966: my $context_regexp = join('|',@{$contexts});
967: if ($curr{'context'} =~ /^($context_regexp)$/) {
968: $creationcontext = $curr{'context'};
969: }
970: my %courses =
971: &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
972: $crstype,$regexpok,undef,undef,'1','creationlog',
973: undef,undef,undef,$curr{'created_before_date'},
974: $curr{'created_after_date'},$creationcontext);
975: foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
1.136 raeburn 976: if ($curr{'show'} ne &mt('all')) {
977: if ($count >= $curr{'page'} * $curr{'show'}) {
978: $more_records = 1;
979: last;
980: }
981: }
1.127 raeburn 982: $count ++;
983: next if ($count < $minshown);
984: if (!$showntablehdr) {
985: $r->print($tablehdr);
986: $showntablehdr = 1;
987: }
988: if ($courses{$cid}{'creator'} ne '') {
989: if ($whodunit{$courses{$cid}{'creator'}} eq '') {
990: my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
991: $whodunit{$courses{$cid}{'creator'}} =
992: &Apache::loncommon::plainname($uname,$udom);
993: }
994: }
995: my $description = $courses{$cid}{'description'};
996: my @owners;
997: my $singleowner = $courses{$cid}{'owner'};
998: push(@owners,$singleowner);
999: if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
1000: foreach my $item (@{$courses{$cid}{'co-owners'}}) {
1001: push(@owners,$item);
1002: }
1003: }
1004: my %ownernames;
1005: foreach my $owner (@owners) {
1006: my ($ownername,$ownerdom);
1007: if ($owner =~ /:/) {
1008: ($ownername,$ownerdom) = split(/:/,$owner);
1009: } else {
1010: $ownername = $owner;
1011: if ($owner ne '') {
1012: $ownerdom = $dom;
1013: }
1014: }
1015: if ($ownername ne '' && $ownerdom ne '') {
1016: unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') {
1017: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
1018: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
1019: }
1020: }
1021: }
1022: my @lastnames;
1023: foreach my $owner (keys(%ownernames)) {
1024: if (ref($ownernames{$owner}) eq 'HASH') {
1025: push(@lastnames,$ownernames{$owner}{'lastname'});
1026: }
1027: }
1028: my $ownerlastnames = join(', ',sort(@lastnames));
1029: my $showtype;
1030: if ($courses{$cid}{type} eq 'Community') {
1031: $showtype = &mt('community');
1032: } else {
1033: my $instcode = $courses{$cid}{inst_code};
1034: if ($instcode ne '') {
1035: $showtype = &mt('official');
1036: } else {
1037: $showtype = &mt('unofficial');
1038: }
1039: }
1040: my $showcontext;
1041:
1042: if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
1043: $showcontext = $contextnames->{$courses{$cid}{context}};
1044: }
1045: my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
1046: my ($cdom,$cnum) = split('_',$cid);
1047: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1048: '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
1049: '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
1050: '<td>'.$description.' <a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
1051: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1052: $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
1053: }
1.128 raeburn 1054: if ($curr{'type'} eq 'any') {
1055: $r->print('<td>'.$showtype.'</td>');
1056: }
1057: if ($curr{'context'} eq 'any') {
1058: $r->print('<td>'.$showcontext.'</td>');
1059: }
1060: $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
1.127 raeburn 1061: }
1062: if ($showntablehdr) {
1063: $r->print(&Apache::loncommon::end_data_table().'<br />');
1064: if (($curr{'page'} > 1) || ($more_records)) {
1065: $r->print('<table><tr>');
1066: if ($curr{'page'} > 1) {
1067: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
1068: }
1069: if ($more_records) {
1070: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
1071: }
1072: $r->print('</tr></table>');
1073: $r->print(<<"ENDSCRIPT");
1074: <script type="text/javascript">
1075: // <![CDATA[
1076: function chgPage(caller) {
1077: if (caller == 'previous') {
1078: document.$formname.page.value --;
1079: }
1080: if (caller == 'next') {
1081: document.$formname.page.value ++;
1082: }
1083: document.$formname.submit();
1084: return;
1085: }
1086: // ]]>
1087: </script>
1088: ENDSCRIPT
1089: }
1090: } else {
1091: $r->print('<p class="LC_info">'.
1092: &mt('There are no records to display').
1093: '</p>');
1094: }
1095: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
1096: '<input type="hidden" name="phase" value="creationlog" /></form>');
1097: return;
1098: }
1099:
1100: sub creation_display_filter {
1.135 raeburn 1101: my ($formname,$curr) = @_;
1.127 raeburn 1102: my $nolink = 1;
1103: my ($contexts,$contextnames) = &context_names();
1104: my $output = '<table><tr><td valign="top">'.
1105: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
1106: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
1107: (&mt('all'),5,10,20,50,100,1000,10000)).
1108: '</td><td> </td>';
1109: my $startform =
1110: &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
1111: $curr->{'created_after_date'},undef,
1112: undef,undef,undef,undef,undef,undef,$nolink);
1113: my $endform =
1114: &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
1115: $curr->{'created_before_date'},undef,
1116: undef,undef,undef,undef,undef,undef,$nolink);
1.136 raeburn 1117: $output .= '<td valign="top"><b>'.&mt('Window during which course/community was created:').'</b><br />'.
1.127 raeburn 1118: '<table><tr><td>'.&mt('After:').
1119: '</td><td>'.$startform.'</td></tr>'.
1120: '<tr><td>'.&mt('Before:').'</td>'.
1121: '<td>'.$endform.'</td></tr></table>'.
1122: '</td>'.
1123: '<td> </td>';
1.136 raeburn 1124: my ($types,$typenames) = &Apache::loncommon::course_types();
1.127 raeburn 1125: if (ref($types) eq 'ARRAY') {
1126: if (@{$types} > 1) {
1127: $output .= '<td valign="top"><b>'.
1128: &mt('Course Type:').'</b><br /><select name="type">';
1129: my $selstr = '';
1130: if ($curr->{'type'} eq 'any') {
1131: $selstr = ' selected="selected"';
1132: }
1133: $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
1134: foreach my $type (@{$types}) {
1135: my $selstr = '';
1136: if ($curr->{'type'} eq $type) {
1137: $selstr = ' selected="selected"';
1138: }
1139: my $typename = $type;
1140: if (ref($typenames) eq 'HASH') {
1141: if ($typenames->{$type} ne '') {
1142: $typename = $typenames->{$type};
1143: }
1144: }
1145: $output .= '<option value="'.$type.'"'.$selstr.'>'.$typename.'</option>'."\n";
1146: }
1147: $output .= '</select></td>';
1148: }
1149: }
1150: $output .= '<td> </td>'.
1151: '<td valign="top"><b>'.
1152: &mt('Creation Context:').'</b><br /><select name="context">';
1153: foreach my $context ('any',@{$contexts}) {
1154: my $selstr = '';
1155: if ($curr->{'context'} eq $context) {
1156: $selstr = ' selected="selected"';
1157: }
1158: $output .= '<option value="'.$context.'"'.$selstr.'>';
1159: if ($context eq 'any') {
1160: $output .= &mt('Any');
1161: } else {
1162: $output .= $contextnames->{$context};
1163: }
1164: $output .= '</option>'."\n";
1165: }
1166: $output .= '</select></td>'.
1167: '</tr></table>';
1168:
1169: # Update Display button
1170: $output .= '<p>'.
1171: '<input type="submit" value="'.&mt('Update Display').'" />'.
1.135 raeburn 1172: '</p><hr />';
1.127 raeburn 1173: return $output;
1174: }
1175:
1176: sub context_names {
1.128 raeburn 1177: my @contexts = qw(auto web dc_create requestcourses);
1.127 raeburn 1178: my %contextnames =
1179: &Apache::lonlocal::texthash (
1.128 raeburn 1180: auto => 'Automated creation from batch file',
1181: web => 'Batch creation from uploaded file',
1.131 raeburn 1182: dc_create => 'Course or community created by Dom. Coord.',
1.128 raeburn 1183: requestcourses => 'Processing of submitted course request',
1.127 raeburn 1184: );
1185: return (\@contexts,\%contextnames);
1186: }
1187:
1188: sub instcode_srchstr {
1189: my ($domain,$numtitles) = @_;
1190: my $instcode;
1191: if (defined($numtitles) && $numtitles == 0) {
1192: $instcode = '.+';
1193: } else {
1194: my (%codedefaults,@code_order);
1195: my $defaults_result =
1196: &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
1197: \@code_order);
1198: if ($defaults_result eq 'ok') {
1199: $instcode ='^';
1200: foreach my $item (@code_order) {
1201: $instcode .= $codedefaults{$item};
1202: }
1203: $instcode .= '$';
1204: } else {
1205: $instcode = '.+';
1206: }
1207: }
1208: return $instcode;
1209: }
1210:
1211: sub syllabuslink_javascript {
1212: return <<"ENDJS";
1213:
1214: function ToSyllabus(cdom,cnum) {
1215: if (cdom == '' || cdom == null) {
1216: return;
1217: }
1218: if (cnum == '' || cnum == null) {
1219: return;
1220: }
1221: var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
1222: var url = "/public/"+cdom+"/"+cnum+"/syllabus";
1223: syllwin = window.open(url,'',options,1);
1224: syllwin.focus();
1225: return;
1226: }
1227:
1228: ENDJS
1229:
1230: }
1.126 raeburn 1231:
1.2 www 1232: # ===================================================================== Handler
1.1 www 1233: sub handler {
1234: my $r = shift;
1235:
1236: if ($r->header_only) {
1.38 www 1237: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1238: $r->send_http_header;
1239: return OK;
1240: }
1241:
1.137 raeburn 1242: my $show_all_choices = 0;
1243: my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'});
1244: if (($primary_rev ne 'refused') && ($primary_rev ne 'error') &&
1245: ($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) {
1246: $show_all_choices = 1;
1247: }
1248:
1.78 albertel 1249: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 1250: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1251: $r->send_http_header;
1252:
1.90 raeburn 1253: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1254: ['phase']);
1255: &Apache::lonhtmlcommon::clear_breadcrumbs();
1256: &Apache::lonhtmlcommon::add_breadcrumb
1257: ({href=>"/adm/createcourse",
1258: text=>"Creation Options",
1259: faq=>79,bug=>'Dom Coord Interface',});
1260: if (($env{'form.phase'} eq 'coursetwo') ||
1.137 raeburn 1261: (($env{'form.phase'} eq 'grouptwo') &&
1262: ($show_all_choices))) {
1.90 raeburn 1263: &Apache::lonhtmlcommon::add_breadcrumb
1264: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1265: text=>&mt('[_1] Creation Settings',),
1266: faq=>9,bug=>'Dom Coord Interface',});
1267: &Apache::lonhtmlcommon::add_breadcrumb
1268: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1269: text=>"Creation Outcome",
1270: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 1271: &create_course($r);
1.90 raeburn 1272: } elsif (($env{'form.phase'} eq 'courseone') ||
1.137 raeburn 1273: (($env{'form.phase'} eq 'groupone') &&
1274: ($show_all_choices))) {
1.90 raeburn 1275: &Apache::lonhtmlcommon::add_breadcrumb
1276: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1277: text=>&mt('[_1] Creation Settings',),
1278: faq=>9,bug=>'Dom Coord Interface',});
1279: &print_course_creation_page($r);
1280: } elsif ($env{'form.phase'} eq 'batchone') {
1281: &Apache::lonhtmlcommon::add_breadcrumb
1282: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1283: text=>"Upload Description File",
1284: faq=>9,bug=>'Dom Coord Interface',});
1285: &upload_batchfile($r);
1286: } elsif ($env{'form.phase'} eq 'batchtwo') {
1287: &Apache::lonhtmlcommon::add_breadcrumb
1288: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1289: text=>"Upload Description File",
1290: faq=>9,bug=>'Dom Coord Interface',});
1291: &Apache::lonhtmlcommon::add_breadcrumb
1292: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1293: text=>"Creation Outcome",
1294: faq=>9,bug=>'Dom Coord Interface',});
1295: &process_batchfile($r);
1.137 raeburn 1296: } elsif (($env{'form.phase'} eq 'requestdisplay') && ($show_all_choices)) {
1.125 raeburn 1297: &Apache::lonhtmlcommon::add_breadcrumb
1298: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1299: text=>&mt('[_1] Display Request Queue',),
1300: faq=>9,bug=>'Dom Coord Interface',});
1.126 raeburn 1301: my $js = &courserequestbrowser_javascript();
1302: my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
1.125 raeburn 1303: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request');
1304: $r->print($start_page.$crumbs."\n".'<div>'.
1305: &Apache::loncoursequeueadmin::display_queued_requests(
1306: 'domain',$env{'request.role.domain'}).'</div>'.
1307: &Apache::loncommon::end_page());
1.137 raeburn 1308: } elsif (($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) {
1.136 raeburn 1309: if ($env{'form.queue'} eq 'pending') {
1310: &Apache::lonhtmlcommon::add_breadcrumb
1311: ({href=>"/adm/createcourse?phase=pendingdisplay",
1312: text=>&mt('Display Pending Queue',),
1313: faq=>9,bug=>'Dom Coord Interface',});
1314: } else {
1315: &Apache::lonhtmlcommon::add_breadcrumb
1316: ({href=>"/adm/createcourse?phase=requestdisplay",
1317: text=>&mt('[_1] Display Request Queue',),
1318: faq=>9,bug=>'Dom Coord Interface',});
1319: }
1.125 raeburn 1320: &Apache::lonhtmlcommon::add_breadcrumb
1.136 raeburn 1321: ({href=>"/adm/createcourse?phase=requestchange",
1322: text=>&mt('[_1] Requests Updated',),
1323: faq=>9,bug=>'Dom Coord Interface',},);
1.125 raeburn 1324: my $start_page=&Apache::loncommon::start_page('Update Requests Result');
1325: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Request',undef,'Course_Request');
1326: $r->print($start_page.$crumbs."\n".'<div>'.
1327: &Apache::loncoursequeueadmin::update_request_queue(
1328: 'domain',$env{'request.role.domain'}).'</div>'.
1329: &Apache::loncommon::end_page());
1.137 raeburn 1330: } elsif (($env{'form.phase'} eq 'pendingdisplay') && ($show_all_choices)) {
1.136 raeburn 1331: &Apache::lonhtmlcommon::add_breadcrumb
1332: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1333: text=>&mt('Display Pending Queue',),
1334: faq=>9,bug=>'Dom Coord Interface',});
1335: my $js = &courserequestbrowser_javascript();
1336: my $start_page=&Apache::loncommon::start_page('Display Pending Queue',$js);
1337: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Request',undef,'Course_Request');
1338: $r->print($start_page.$crumbs."\n".'<div>'.
1339: &Apache::loncoursequeueadmin::display_queued_requests(
1340: 'pending',$env{'request.role.domain'}).'</div>'.
1341: &Apache::loncommon::end_page());
1.137 raeburn 1342: } elsif (($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) {
1.136 raeburn 1343: my $js = &courserequestbrowser_javascript();
1344: &Apache::lonhtmlcommon::add_breadcrumb
1345: ({href=>"/adm/createcourse?phase=pendingdisplay",
1346: text=>&mt('Display Pending Queue'),},
1347: {href=>"/adm/createcourse?phase=requestvalidation",
1348: text=>&mt('Validation Attempted'),},);
1349: my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js);
1350: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Request',undef,'Course_Request');
1351: $r->print($start_page.$crumbs."\n".'<div>'.
1352: &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'.
1353: &Apache::loncommon::end_page());
1.137 raeburn 1354: } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) {
1.127 raeburn 1355: &Apache::lonhtmlcommon::add_breadcrumb
1356: ({href=>"/adm/createcourse?phase=creationlog",
1357: text=>&mt('[_1] Display Creation History',),});
1358: my $js = '<script type="text/javascript">'."\n".
1359: '// <![CDATA['."\n".
1360: &syllabuslink_javascript()."\n".
1361: '// ]]>'."\n".
1362: '</script>';
1.131 raeburn 1363: my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
1364: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Creation_Log',undef,'Creation_Log');
1.127 raeburn 1365: $r->print($start_page.$crumbs."\n".'<div>');
1366: &print_creation_logs($r);
1367: $r->print('</div>'.&Apache::loncommon::end_page());
1.2 www 1368: } else {
1.137 raeburn 1369: &print_intro_page($r,$show_all_choices);
1.2 www 1370: }
1.1 www 1371: } else {
1.78 albertel 1372: $env{'user.error.msg'}=
1.127 raeburn 1373: "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
1.1 www 1374: return HTTP_NOT_ACCEPTABLE;
1375: }
1376: return OK;
1.90 raeburn 1377: }
1.1 www 1378:
1379: 1;
1380: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>