Annotation of loncom/interface/loncreatecourse.pm, revision 1.134
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.134 ! raeburn 4: # $Id: loncreatecourse.pm,v 1.133 2009/11/04 14:12:19 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: }
862: my (%whodunit,$version);
863: ($version) = ($r->dir_config('lonVersion') =~ /^([\d\.]+)\-/);
864: $r->print(&creation_display_filter($formname,\%curr,$version));
865: my $showntablehdr = 0;
866: my $tablehdr = &Apache::loncommon::start_data_table().
867: &Apache::loncommon::start_data_table_header_row().
868: '<th> </th><th>'.&mt('Creation Date').'</th>'.
869: '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
1.131 raeburn 870: '<th>'.&mt('Owner(s)').'</th>';
1.127 raeburn 871: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
872: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
1.128 raeburn 873: }
874: if ($curr{'type'} eq 'any') {
875: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
876: }
1.129 raeburn 877: if ($curr{'context'} eq 'any') {
1.128 raeburn 878: $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
879: }
880: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
1.127 raeburn 881: my ($minshown,$maxshown);
882: $minshown = 1;
883: my $count = 0;
884: if ($curr{'show'} ne &mt('all')) {
885: $maxshown = $curr{'page'} * $curr{'show'};
886: if ($curr{'page'} > 1) {
887: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
888: }
889: }
890: my $crstype = 'Course';
891: if ($curr{'type'} eq 'any') {
892: $crstype = '.';
893: } elsif ($curr{'type'} eq 'community') {
894: $crstype = 'Community';
895: }
896:
897: my ($instcodefilter,$regexpok);
898: my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
899: my ($jscript,$totcodes,$numtitles,$lasttitle) =
900: &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
901: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
902: $officialjs);
903: if ($numtitles) {
904: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
905: $instcodefilter = &instcode_srchstr($dom,$numtitles);
906: &Apache::courseclassifier::instcode_search_str($dom,$numtitles);
907: if ($curr{'type'} eq 'official') {
908: $regexpok = 1;
909: } else {
910: unless ($instcodefilter eq '') {
911: $regexpok = -1;
912: }
913: }
914: }
915: }
916: if ($instcodefilter eq '') { $instcodefilter = '.'; }
917:
918: my $creationcontext = '.';
919: my $context_regexp = join('|',@{$contexts});
920: if ($curr{'context'} =~ /^($context_regexp)$/) {
921: $creationcontext = $curr{'context'};
922: }
923: my %courses =
924: &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
925: $crstype,$regexpok,undef,undef,'1','creationlog',
926: undef,undef,undef,$curr{'created_before_date'},
927: $curr{'created_after_date'},$creationcontext);
928: foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
929: $count ++;
930: next if ($count < $minshown);
931: if (!$showntablehdr) {
932: $r->print($tablehdr);
933: $showntablehdr = 1;
934: }
935: if ($courses{$cid}{'creator'} ne '') {
936: if ($whodunit{$courses{$cid}{'creator'}} eq '') {
937: my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
938: $whodunit{$courses{$cid}{'creator'}} =
939: &Apache::loncommon::plainname($uname,$udom);
940: }
941: }
942: my $description = $courses{$cid}{'description'};
943: my @owners;
944: my $singleowner = $courses{$cid}{'owner'};
945: push(@owners,$singleowner);
946: if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
947: foreach my $item (@{$courses{$cid}{'co-owners'}}) {
948: push(@owners,$item);
949: }
950: }
951: my %ownernames;
952: foreach my $owner (@owners) {
953: my ($ownername,$ownerdom);
954: if ($owner =~ /:/) {
955: ($ownername,$ownerdom) = split(/:/,$owner);
956: } else {
957: $ownername = $owner;
958: if ($owner ne '') {
959: $ownerdom = $dom;
960: }
961: }
962: if ($ownername ne '' && $ownerdom ne '') {
963: unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') {
964: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
965: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
966: }
967: }
968: }
969: my @lastnames;
970: foreach my $owner (keys(%ownernames)) {
971: if (ref($ownernames{$owner}) eq 'HASH') {
972: push(@lastnames,$ownernames{$owner}{'lastname'});
973: }
974: }
975: my $ownerlastnames = join(', ',sort(@lastnames));
976: my $showtype;
977: if ($courses{$cid}{type} eq 'Community') {
978: $showtype = &mt('community');
979: } else {
980: my $instcode = $courses{$cid}{inst_code};
981: if ($instcode ne '') {
982: $showtype = &mt('official');
983: } else {
984: $showtype = &mt('unofficial');
985: }
986: }
987: my $showcontext;
988:
989: if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
990: $showcontext = $contextnames->{$courses{$cid}{context}};
991: }
992: my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
993: my ($cdom,$cnum) = split('_',$cid);
994: $r->print(&Apache::loncommon::start_data_table_row()."\n".
995: '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
996: '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
997: '<td>'.$description.' <a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
998: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
999: $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
1000: }
1.128 raeburn 1001: if ($curr{'type'} eq 'any') {
1002: $r->print('<td>'.$showtype.'</td>');
1003: }
1004: if ($curr{'context'} eq 'any') {
1005: $r->print('<td>'.$showcontext.'</td>');
1006: }
1007: $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
1.127 raeburn 1008: }
1009: if ($showntablehdr) {
1010: $r->print(&Apache::loncommon::end_data_table().'<br />');
1011: if (($curr{'page'} > 1) || ($more_records)) {
1012: $r->print('<table><tr>');
1013: if ($curr{'page'} > 1) {
1014: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
1015: }
1016: if ($more_records) {
1017: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
1018: }
1019: $r->print('</tr></table>');
1020: $r->print(<<"ENDSCRIPT");
1021: <script type="text/javascript">
1022: // <![CDATA[
1023: function chgPage(caller) {
1024: if (caller == 'previous') {
1025: document.$formname.page.value --;
1026: }
1027: if (caller == 'next') {
1028: document.$formname.page.value ++;
1029: }
1030: document.$formname.submit();
1031: return;
1032: }
1033: // ]]>
1034: </script>
1035: ENDSCRIPT
1036: }
1037: } else {
1038: $r->print('<p class="LC_info">'.
1039: &mt('There are no records to display').
1040: '</p>');
1041: }
1042: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
1043: '<input type="hidden" name="phase" value="creationlog" /></form>');
1044: return;
1045: }
1046:
1047: sub creation_display_filter {
1048: my ($formname,$curr,$version) = @_;
1049: my $nolink = 1;
1050: my ($contexts,$contextnames) = &context_names();
1051: my $output = '<table><tr><td valign="top">'.
1052: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
1053: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
1054: (&mt('all'),5,10,20,50,100,1000,10000)).
1055: '</td><td> </td>';
1056: my $startform =
1057: &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
1058: $curr->{'created_after_date'},undef,
1059: undef,undef,undef,undef,undef,undef,$nolink);
1060: my $endform =
1061: &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
1062: $curr->{'created_before_date'},undef,
1063: undef,undef,undef,undef,undef,undef,$nolink);
1064: $output .= '<td valign="top"><b>'.&mt('Window during which course was created:').'</b><br />'.
1065: '<table><tr><td>'.&mt('After:').
1066: '</td><td>'.$startform.'</td></tr>'.
1067: '<tr><td>'.&mt('Before:').'</td>'.
1068: '<td>'.$endform.'</td></tr></table>'.
1069: '</td>'.
1070: '<td> </td>';
1071: my ($types,$typenames) = &course_types();
1072: if (ref($types) eq 'ARRAY') {
1073: if (@{$types} > 1) {
1074: $output .= '<td valign="top"><b>'.
1075: &mt('Course Type:').'</b><br /><select name="type">';
1076: my $selstr = '';
1077: if ($curr->{'type'} eq 'any') {
1078: $selstr = ' selected="selected"';
1079: }
1080: $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
1081: foreach my $type (@{$types}) {
1082: my $selstr = '';
1083: if ($curr->{'type'} eq $type) {
1084: $selstr = ' selected="selected"';
1085: }
1086: my $typename = $type;
1087: if (ref($typenames) eq 'HASH') {
1088: if ($typenames->{$type} ne '') {
1089: $typename = $typenames->{$type};
1090: }
1091: }
1092: $output .= '<option value="'.$type.'"'.$selstr.'>'.$typename.'</option>'."\n";
1093: }
1094: $output .= '</select></td>';
1095: }
1096: }
1097: $output .= '<td> </td>'.
1098: '<td valign="top"><b>'.
1099: &mt('Creation Context:').'</b><br /><select name="context">';
1100: foreach my $context ('any',@{$contexts}) {
1101: my $selstr = '';
1102: if ($curr->{'context'} eq $context) {
1103: $selstr = ' selected="selected"';
1104: }
1105: $output .= '<option value="'.$context.'"'.$selstr.'>';
1106: if ($context eq 'any') {
1107: $output .= &mt('Any');
1108: } else {
1109: $output .= $contextnames->{$context};
1110: }
1111: $output .= '</option>'."\n";
1112: }
1113: $output .= '</select></td>'.
1114: '</tr></table>';
1115:
1116: # Update Display button
1117: $output .= '<p>'.
1118: '<input type="submit" value="'.&mt('Update Display').'" />'.
1119: '</p>';
1120:
1121: # Server version info
1122: $output .= '<p class="LC_info">'.
1.131 raeburn 1123: &mt('Only courses and communities created from servers running LON-CAPA [_1] or later are displayed.','2.9.0');
1.127 raeburn 1124: if ($version) {
1125: $output .= ' '.&mt('This LON-CAPA server is version [_1]',$version);
1126: }
1127: $output .= '</p><hr />';
1128: return $output;
1129: }
1130:
1131: sub course_types {
1132: my @types = qw(official unofficial community);
1133: my %typename = (
1134: official => 'Official course',
1135: unofficial => 'Unofficial course',
1136: community => 'Community',
1137: );
1138: return (\@types,\%typename);
1139: }
1140:
1141: sub context_names {
1.128 raeburn 1142: my @contexts = qw(auto web dc_create requestcourses);
1.127 raeburn 1143: my %contextnames =
1144: &Apache::lonlocal::texthash (
1.128 raeburn 1145: auto => 'Automated creation from batch file',
1146: web => 'Batch creation from uploaded file',
1.131 raeburn 1147: dc_create => 'Course or community created by Dom. Coord.',
1.128 raeburn 1148: requestcourses => 'Processing of submitted course request',
1.127 raeburn 1149: );
1150: return (\@contexts,\%contextnames);
1151: }
1152:
1153: sub instcode_srchstr {
1154: my ($domain,$numtitles) = @_;
1155: my $instcode;
1156: if (defined($numtitles) && $numtitles == 0) {
1157: $instcode = '.+';
1158: } else {
1159: my (%codedefaults,@code_order);
1160: my $defaults_result =
1161: &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
1162: \@code_order);
1163: if ($defaults_result eq 'ok') {
1164: $instcode ='^';
1165: foreach my $item (@code_order) {
1166: $instcode .= $codedefaults{$item};
1167: }
1168: $instcode .= '$';
1169: } else {
1170: $instcode = '.+';
1171: }
1172: }
1173: return $instcode;
1174: }
1175:
1176: sub syllabuslink_javascript {
1177: return <<"ENDJS";
1178:
1179: function ToSyllabus(cdom,cnum) {
1180: if (cdom == '' || cdom == null) {
1181: return;
1182: }
1183: if (cnum == '' || cnum == null) {
1184: return;
1185: }
1186: var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
1187: var url = "/public/"+cdom+"/"+cnum+"/syllabus";
1188: syllwin = window.open(url,'',options,1);
1189: syllwin.focus();
1190: return;
1191: }
1192:
1193: ENDJS
1194:
1195: }
1.126 raeburn 1196:
1.2 www 1197: # ===================================================================== Handler
1.1 www 1198: sub handler {
1199: my $r = shift;
1200:
1201: if ($r->header_only) {
1.38 www 1202: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1203: $r->send_http_header;
1204: return OK;
1205: }
1206:
1.78 albertel 1207: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 1208: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1209: $r->send_http_header;
1210:
1.90 raeburn 1211: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1212: ['phase']);
1213: &Apache::lonhtmlcommon::clear_breadcrumbs();
1214: &Apache::lonhtmlcommon::add_breadcrumb
1215: ({href=>"/adm/createcourse",
1216: text=>"Creation Options",
1217: faq=>79,bug=>'Dom Coord Interface',});
1218: if (($env{'form.phase'} eq 'coursetwo') ||
1219: ($env{'form.phase'} eq 'grouptwo')) {
1220: &Apache::lonhtmlcommon::add_breadcrumb
1221: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1222: text=>&mt('[_1] Creation Settings',),
1223: faq=>9,bug=>'Dom Coord Interface',});
1224: &Apache::lonhtmlcommon::add_breadcrumb
1225: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1226: text=>"Creation Outcome",
1227: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 1228: &create_course($r);
1.90 raeburn 1229: } elsif (($env{'form.phase'} eq 'courseone') ||
1230: ($env{'form.phase'} eq 'groupone')) {
1231: &Apache::lonhtmlcommon::add_breadcrumb
1232: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1233: text=>&mt('[_1] Creation Settings',),
1234: faq=>9,bug=>'Dom Coord Interface',});
1235: &print_course_creation_page($r);
1236: } elsif ($env{'form.phase'} eq 'batchone') {
1237: &Apache::lonhtmlcommon::add_breadcrumb
1238: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1239: text=>"Upload Description File",
1240: faq=>9,bug=>'Dom Coord Interface',});
1241: &upload_batchfile($r);
1242: } elsif ($env{'form.phase'} eq 'batchtwo') {
1243: &Apache::lonhtmlcommon::add_breadcrumb
1244: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1245: text=>"Upload Description File",
1246: faq=>9,bug=>'Dom Coord Interface',});
1247: &Apache::lonhtmlcommon::add_breadcrumb
1248: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1249: text=>"Creation Outcome",
1250: faq=>9,bug=>'Dom Coord Interface',});
1251: &process_batchfile($r);
1.125 raeburn 1252: } elsif ($env{'form.phase'} eq 'requestdisplay') {
1253: &Apache::lonhtmlcommon::add_breadcrumb
1254: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1255: text=>&mt('[_1] Display Request Queue',),
1256: faq=>9,bug=>'Dom Coord Interface',});
1.126 raeburn 1257: my $js = &courserequestbrowser_javascript();
1258: my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
1.125 raeburn 1259: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request');
1260: $r->print($start_page.$crumbs."\n".'<div>'.
1261: &Apache::loncoursequeueadmin::display_queued_requests(
1262: 'domain',$env{'request.role.domain'}).'</div>'.
1263: &Apache::loncommon::end_page());
1264: } elsif ($env{'form.phase'} eq 'requestchange') {
1265: &Apache::lonhtmlcommon::add_breadcrumb
1266: ({href=>"/adm/createcourse?phase=requestdisplay",
1267: text=>&mt('[_1] Display Request Queue',),
1268: faq=>9,bug=>'Dom Coord Interface',},
1269: {href=>"/adm/createcourse?phase=requestchange",
1270: text=>&mt('[_1] Requests Updated',),
1271: faq=>9,bug=>'Dom Coord Interface',},);
1272: my $start_page=&Apache::loncommon::start_page('Update Requests Result');
1273: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Request',undef,'Course_Request');
1274: $r->print($start_page.$crumbs."\n".'<div>'.
1275: &Apache::loncoursequeueadmin::update_request_queue(
1276: 'domain',$env{'request.role.domain'}).'</div>'.
1277: &Apache::loncommon::end_page());
1.127 raeburn 1278: } elsif ($env{'form.phase'} eq 'creationlog') {
1279: &Apache::lonhtmlcommon::add_breadcrumb
1280: ({href=>"/adm/createcourse?phase=creationlog",
1281: text=>&mt('[_1] Display Creation History',),});
1282: my $js = '<script type="text/javascript">'."\n".
1283: '// <![CDATA['."\n".
1284: &syllabuslink_javascript()."\n".
1285: '// ]]>'."\n".
1286: '</script>';
1.131 raeburn 1287: my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
1288: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Creation_Log',undef,'Creation_Log');
1.127 raeburn 1289: $r->print($start_page.$crumbs."\n".'<div>');
1290: &print_creation_logs($r);
1291: $r->print('</div>'.&Apache::loncommon::end_page());
1.2 www 1292: } else {
1.90 raeburn 1293: &print_intro_page($r);
1.2 www 1294: }
1.1 www 1295: } else {
1.78 albertel 1296: $env{'user.error.msg'}=
1.127 raeburn 1297: "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
1.1 www 1298: return HTTP_NOT_ACCEPTABLE;
1299: }
1300: return OK;
1.90 raeburn 1301: }
1.1 www 1302:
1303: 1;
1304: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>