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