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