Annotation of loncom/interface/loncreatecourse.pm, revision 1.138
1.65 raeburn 1: # The LearningOnline Network
1.1 www 2: # Create a course
1.5 albertel 3: #
1.138 ! bisitz 4: # $Id: loncreatecourse.pm,v 1.137 2010/04/13 21:19:15 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 {
1.137 raeburn 695: my ($r,$show_all_choices) = @_;
1.90 raeburn 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.138 ! bisitz 702:
! 703: # Create menu
! 704: my @menu;
! 705: @menu =
! 706: ({ categorytitle => 'Course/Community Creation',
! 707: items => [
! 708: {
! 709: linktext => 'Create a single course',
! 710: url => '/adm/createcourse?phase=courseone',
! 711: permission => 1,
! 712: #help => '',
! 713: icon => 'ccrs.png',
! 714: linktitle => 'Create a new course by completing an online form.'
! 715: },
! 716: {
! 717: linktext => 'Create a single community',
! 718: url => '/adm/createcourse?phase=groupone',
! 719: permission => $show_all_choices,
! 720: #help => '',
! 721: icon => 'ccrs.png',
! 722: linktitle => 'Create a new collaborative community by completing an online form.'
! 723: },
! 724: {
! 725: linktext => 'Create courses/communities by uploading an attributes file',
! 726: url => '/adm/createcourse?phase=batchone',
! 727: permission => 1,
! 728: help => 'Batch_Creation',
! 729: icon => 'ccrs.png',
! 730: linktitle => 'Upload an attributes file containing specifications for one or more courses or communities in XML format.'
! 731: },
! 732: ]
! 733: },
! 734: { categorytitle => 'Course/Community Requests',
! 735: items => [
! 736: {
! 737: linktext => 'Approve or reject requests',
! 738: url => '/adm/createcourse?phase=requestdisplay',
! 739: permission => $show_all_choices,
! 740: #help => '',
! 741: icon => 'ccrs.png',
! 742: linktitle => 'Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'
! 743: },
! 744: {
! 745: linktext => 'Display official course requests',
! 746: url => '/adm/createcourse?phase=pendingdisplay',
! 747: permission => $show_all_choices,
! 748: #help => '',
! 749: icon => 'ccrs.png',
! 750: linktitle => 'Display official course requests submitted by authorized users, held pending validation of instructor status.'
! 751: },
! 752: ]
! 753: },
! 754: { categorytitle => 'Administration',
! 755: items => [
! 756: {
! 757: linktext => 'View creation log',
! 758: url => '/adm/createcourse?phase=creationlog',
! 759: permission => $show_all_choices,
! 760: #help => '',
! 761: icon => 'document-properties.png',
! 762: linktitle => 'Display information about when, how and by whom courses and communities were created in this domain.'
! 763: },
! 764: ]
! 765: },
! 766: );
! 767:
! 768: $r->print(
! 769: $start_page
! 770: .$crumbs
! 771: .&Apache::lonhtmlcommon::generate_menu(@menu)
! 772: .$end_page
! 773: );
1.90 raeburn 774: }
775:
776: sub upload_batchfile {
777: my $r = shift;
778: my $start_page =
1.123 raeburn 779: &Apache::loncommon::start_page('Create a New Course or Community');
780: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Upload Course/Community Attributes File','Create_Course',undef,'Create_Courses');
1.90 raeburn 781: my $end_page =
782: &Apache::loncommon::end_page();
783: $r->print($start_page.$crumbs);
1.127 raeburn 784: $r->print('<h3>'.&mt('Upload a courses or communities attributes file').'</h3>');
1.90 raeburn 785: $r->print('<form name="batchcreate" method="post" '.
786: 'enctype="multipart/form-data" action="/adm/createcourse">'.
787: '<input type="file" name="coursecreatorxml" />'.
1.121 bisitz 788: '<input type="hidden" name="phase" value="batchtwo" /><br /><br />'.
1.90 raeburn 789: '<input type="submit" name="batchsubmit" '.
1.138 ! bisitz 790: 'value="'.&mt('Create Courses/Communities').'" /></form>');
1.90 raeburn 791: $r->print($end_page);
792: return;
793: }
794:
795: sub process_batchfile {
796: my $r = shift;
797: my $start_page =
1.123 raeburn 798: &Apache::loncommon::start_page('Create a New Course or Community');
1.90 raeburn 799: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
800: my $end_page =
801: &Apache::loncommon::end_page();
802: my $defdom=$env{'request.role.domain'};
803: my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
804: 'batchupload',undef,undef,
805: undef,undef,$defdom);
806: my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
807: my ($result,$logmsg);
808: if (-e "$batchfilepath") {
809: open(FILE,"<$batchfilepath");
810: my @buffer = <FILE>;
811: close(FILE);
812: if ((defined($filename)) && (defined($batchdir))) {
813: my @requests = ($filename);
814: my %courseids = ();
815: ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
816: \@requests,\%courseids,'web',$defdom,
817: $env{'user.name'},$env{'user.domain'});
818: if ($result) {
819: if (!-e "$batchdir/processed") {
820: mkdir("$batchdir/processed", 0755);
821: open(FILE,">$batchdir/processed/$filename");
822: print FILE @buffer;
823: close(FILE);
824: if (-e "$batchdir/processed/$filename") {
825: unlink("$batchdir/pending/$filename");
826: }
827: }
828: }
829: }
830: }
1.103 raeburn 831: $r->print($start_page.$crumbs.$logmsg.$result.'<br /><a href="/adm/createcourse">'.
832: &mt('Creation options menu').'</a>'.$end_page);
1.90 raeburn 833:
834: }
835:
1.126 raeburn 836: sub courserequestbrowser_javascript {
837: return <<"ENDREQBRW";
838: <script type="text/javascript">
839: // <![CDATA[
840: var steditbrowser;
1.136 raeburn 841: function opencoursereqdisplay(cdom,cnum,queue) {
1.126 raeburn 842: var url = '/adm/requestcourse?action=display';
1.136 raeburn 843: url += '&showdom='+cdom+'&cnum='+cnum+'&queue='+queue;
1.126 raeburn 844: var title = 'Course_Request_Browser';
845: var options = 'scrollbars=1,resizable=1,menubar=0';
846: options += ',width=700,height=600';
847: var stdeditbrowser = open(url,title,options,'1');
848: stdeditbrowser.focus();
849: }
1.136 raeburn 850:
1.126 raeburn 851: // ]]>
852: </script>
853: ENDREQBRW
854: }
855:
1.127 raeburn 856: sub print_creation_logs {
857: my ($r) = @_;
858: my $formname = 'creationlog';
859: my $dom = $env{'request.role.domain'};
860: $r->print('<form action="/adm/createcourse" method="post" name="'.$formname.'">');
861: # set defaults
862: my $now = time();
863: my $defstart = $now - (7*24*3600); #7 days ago
864: my %defaults = (
865: page => '1',
866: show => '10',
867: type => 'any',
868: context => 'any',
869: created_before_date => $now,
870: created_after_date => $defstart,
871: );
872: my ($contexts,$contextnames) = &context_names();
873: my $more_records = 0;
874: my %curr;
875: foreach my $item ('show','page','type','context') {
876: $curr{$item} = $env{'form.'.$item};
877: }
878: $curr{'created_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_after_date');
879: $curr{'created_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('created_before_date');
880: foreach my $key (keys(%defaults)) {
881: if ($curr{$key} eq '') {
882: $curr{$key} = $defaults{$key};
883: }
884: }
1.135 raeburn 885: my %whodunit;
886: $r->print(&creation_display_filter($formname,\%curr));
1.127 raeburn 887: my $showntablehdr = 0;
888: my $tablehdr = &Apache::loncommon::start_data_table().
889: &Apache::loncommon::start_data_table_header_row().
890: '<th> </th><th>'.&mt('Creation Date').'</th>'.
891: '<th>'.&mt('Creator').'</th><th>'.&mt('Description').'</th>'.
1.131 raeburn 892: '<th>'.&mt('Owner(s)').'</th>';
1.127 raeburn 893: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
894: $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
1.128 raeburn 895: }
896: if ($curr{'type'} eq 'any') {
897: $tablehdr .= '<th>'.&mt('Course Type').'</th>';
898: }
1.129 raeburn 899: if ($curr{'context'} eq 'any') {
1.128 raeburn 900: $tablehdr .= '<th>'.&mt('Creation Context').'</th>';
901: }
902: $tablehdr .= &Apache::loncommon::end_data_table_header_row();
1.127 raeburn 903: my ($minshown,$maxshown);
904: $minshown = 1;
905: my $count = 0;
906: if ($curr{'show'} ne &mt('all')) {
907: $maxshown = $curr{'page'} * $curr{'show'};
908: if ($curr{'page'} > 1) {
909: $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
910: }
911: }
912: my $crstype = 'Course';
913: if ($curr{'type'} eq 'any') {
914: $crstype = '.';
915: } elsif ($curr{'type'} eq 'community') {
916: $crstype = 'Community';
917: }
918:
919: my ($instcodefilter,$regexpok);
920: my (@codetitles,%cat_titles,%cat_order,%cat_items,$officialjs);
921: my ($jscript,$totcodes,$numtitles,$lasttitle) =
922: &Apache::courseclassifier::instcode_selectors_data($dom,$formname,
923: \%cat_items,\@codetitles,\%cat_titles,\%cat_order,
924: $officialjs);
925: if ($numtitles) {
926: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'unofficial')) {
927: $instcodefilter = &instcode_srchstr($dom,$numtitles);
928: &Apache::courseclassifier::instcode_search_str($dom,$numtitles);
929: if ($curr{'type'} eq 'official') {
930: $regexpok = 1;
931: } else {
932: unless ($instcodefilter eq '') {
933: $regexpok = -1;
934: }
935: }
936: }
937: }
938: if ($instcodefilter eq '') { $instcodefilter = '.'; }
939:
940: my $creationcontext = '.';
941: my $context_regexp = join('|',@{$contexts});
942: if ($curr{'context'} =~ /^($context_regexp)$/) {
943: $creationcontext = $curr{'context'};
944: }
945: my %courses =
946: &Apache::lonnet::courseiddump($dom,'.',1,$instcodefilter,'.','.',undef,undef,
947: $crstype,$regexpok,undef,undef,'1','creationlog',
948: undef,undef,undef,$curr{'created_before_date'},
949: $curr{'created_after_date'},$creationcontext);
950: foreach my $cid (sort { $courses{$b}{'created'}<=>$courses{$a}{'created'} } (keys(%courses))) {
1.136 raeburn 951: if ($curr{'show'} ne &mt('all')) {
952: if ($count >= $curr{'page'} * $curr{'show'}) {
953: $more_records = 1;
954: last;
955: }
956: }
1.127 raeburn 957: $count ++;
958: next if ($count < $minshown);
959: if (!$showntablehdr) {
960: $r->print($tablehdr);
961: $showntablehdr = 1;
962: }
963: if ($courses{$cid}{'creator'} ne '') {
964: if ($whodunit{$courses{$cid}{'creator'}} eq '') {
965: my ($uname,$udom) = split(':',$courses{$cid}{'creator'});
966: $whodunit{$courses{$cid}{'creator'}} =
967: &Apache::loncommon::plainname($uname,$udom);
968: }
969: }
970: my $description = $courses{$cid}{'description'};
971: my @owners;
972: my $singleowner = $courses{$cid}{'owner'};
973: push(@owners,$singleowner);
974: if (ref($courses{$cid}{'co-owners'}) eq 'ARRAY') {
975: foreach my $item (@{$courses{$cid}{'co-owners'}}) {
976: push(@owners,$item);
977: }
978: }
979: my %ownernames;
980: foreach my $owner (@owners) {
981: my ($ownername,$ownerdom);
982: if ($owner =~ /:/) {
983: ($ownername,$ownerdom) = split(/:/,$owner);
984: } else {
985: $ownername = $owner;
986: if ($owner ne '') {
987: $ownerdom = $dom;
988: }
989: }
990: if ($ownername ne '' && $ownerdom ne '') {
991: unless (ref($ownernames{$ownername.':'.$ownerdom}) eq 'HASH') {
992: my %namehash=&Apache::loncommon::getnames($ownername,$ownerdom);
993: $ownernames{$ownername.':'.$ownerdom} = \%namehash;
994: }
995: }
996: }
997: my @lastnames;
998: foreach my $owner (keys(%ownernames)) {
999: if (ref($ownernames{$owner}) eq 'HASH') {
1000: push(@lastnames,$ownernames{$owner}{'lastname'});
1001: }
1002: }
1003: my $ownerlastnames = join(', ',sort(@lastnames));
1004: my $showtype;
1005: if ($courses{$cid}{type} eq 'Community') {
1006: $showtype = &mt('community');
1007: } else {
1008: my $instcode = $courses{$cid}{inst_code};
1009: if ($instcode ne '') {
1010: $showtype = &mt('official');
1011: } else {
1012: $showtype = &mt('unofficial');
1013: }
1014: }
1015: my $showcontext;
1016:
1017: if ($courses{$cid}{context} =~ /^($context_regexp)$/) {
1018: $showcontext = $contextnames->{$courses{$cid}{context}};
1019: }
1020: my $created = &Apache::lonlocal::locallocaltime($courses{$cid}{'created'});
1021: my ($cdom,$cnum) = split('_',$cid);
1022: $r->print(&Apache::loncommon::start_data_table_row()."\n".
1023: '<td>'.$count.'</td><td>'.$created.'</td>'."\n".
1024: '<td>'.$whodunit{$courses{$cid}{creator}}.'</td>'."\n".
1025: '<td>'.$description.' <a href="javascript:ToSyllabus('."'$cdom','$cnum'".')">'.&mt('Syllabus').'</a></td><td>'.$ownerlastnames.'</td>');
1026: if (($curr{'type'} eq 'official') || ($curr{'type'} eq 'any')) {
1027: $r->print('<td>'.$courses{$cid}{'inst_code'}.'</td>');
1028: }
1.128 raeburn 1029: if ($curr{'type'} eq 'any') {
1030: $r->print('<td>'.$showtype.'</td>');
1031: }
1032: if ($curr{'context'} eq 'any') {
1033: $r->print('<td>'.$showcontext.'</td>');
1034: }
1035: $r->print('<td>'.&Apache::loncommon::end_data_table_row()."\n");
1.127 raeburn 1036: }
1037: if ($showntablehdr) {
1038: $r->print(&Apache::loncommon::end_data_table().'<br />');
1039: if (($curr{'page'} > 1) || ($more_records)) {
1040: $r->print('<table><tr>');
1041: if ($curr{'page'} > 1) {
1042: $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
1043: }
1044: if ($more_records) {
1045: $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
1046: }
1047: $r->print('</tr></table>');
1048: $r->print(<<"ENDSCRIPT");
1049: <script type="text/javascript">
1050: // <![CDATA[
1051: function chgPage(caller) {
1052: if (caller == 'previous') {
1053: document.$formname.page.value --;
1054: }
1055: if (caller == 'next') {
1056: document.$formname.page.value ++;
1057: }
1058: document.$formname.submit();
1059: return;
1060: }
1061: // ]]>
1062: </script>
1063: ENDSCRIPT
1064: }
1065: } else {
1066: $r->print('<p class="LC_info">'.
1067: &mt('There are no records to display').
1068: '</p>');
1069: }
1070: $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
1071: '<input type="hidden" name="phase" value="creationlog" /></form>');
1072: return;
1073: }
1074:
1075: sub creation_display_filter {
1.135 raeburn 1076: my ($formname,$curr) = @_;
1.127 raeburn 1077: my $nolink = 1;
1078: my ($contexts,$contextnames) = &context_names();
1079: my $output = '<table><tr><td valign="top">'.
1080: '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
1081: &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
1082: (&mt('all'),5,10,20,50,100,1000,10000)).
1083: '</td><td> </td>';
1084: my $startform =
1085: &Apache::lonhtmlcommon::date_setter($formname,'created_after_date',
1086: $curr->{'created_after_date'},undef,
1087: undef,undef,undef,undef,undef,undef,$nolink);
1088: my $endform =
1089: &Apache::lonhtmlcommon::date_setter($formname,'created_before_date',
1090: $curr->{'created_before_date'},undef,
1091: undef,undef,undef,undef,undef,undef,$nolink);
1.136 raeburn 1092: $output .= '<td valign="top"><b>'.&mt('Window during which course/community was created:').'</b><br />'.
1.127 raeburn 1093: '<table><tr><td>'.&mt('After:').
1094: '</td><td>'.$startform.'</td></tr>'.
1095: '<tr><td>'.&mt('Before:').'</td>'.
1096: '<td>'.$endform.'</td></tr></table>'.
1097: '</td>'.
1098: '<td> </td>';
1.136 raeburn 1099: my ($types,$typenames) = &Apache::loncommon::course_types();
1.127 raeburn 1100: if (ref($types) eq 'ARRAY') {
1101: if (@{$types} > 1) {
1102: $output .= '<td valign="top"><b>'.
1103: &mt('Course Type:').'</b><br /><select name="type">';
1104: my $selstr = '';
1105: if ($curr->{'type'} eq 'any') {
1106: $selstr = ' selected="selected"';
1107: }
1108: $output .= '<option value="any"'.$selstr.'>'.&mt('Any').'</option>'."\n";
1109: foreach my $type (@{$types}) {
1110: my $selstr = '';
1111: if ($curr->{'type'} eq $type) {
1112: $selstr = ' selected="selected"';
1113: }
1114: my $typename = $type;
1115: if (ref($typenames) eq 'HASH') {
1116: if ($typenames->{$type} ne '') {
1117: $typename = $typenames->{$type};
1118: }
1119: }
1120: $output .= '<option value="'.$type.'"'.$selstr.'>'.$typename.'</option>'."\n";
1121: }
1122: $output .= '</select></td>';
1123: }
1124: }
1125: $output .= '<td> </td>'.
1126: '<td valign="top"><b>'.
1127: &mt('Creation Context:').'</b><br /><select name="context">';
1128: foreach my $context ('any',@{$contexts}) {
1129: my $selstr = '';
1130: if ($curr->{'context'} eq $context) {
1131: $selstr = ' selected="selected"';
1132: }
1133: $output .= '<option value="'.$context.'"'.$selstr.'>';
1134: if ($context eq 'any') {
1135: $output .= &mt('Any');
1136: } else {
1137: $output .= $contextnames->{$context};
1138: }
1139: $output .= '</option>'."\n";
1140: }
1141: $output .= '</select></td>'.
1142: '</tr></table>';
1143:
1144: # Update Display button
1145: $output .= '<p>'.
1146: '<input type="submit" value="'.&mt('Update Display').'" />'.
1.135 raeburn 1147: '</p><hr />';
1.127 raeburn 1148: return $output;
1149: }
1150:
1151: sub context_names {
1.128 raeburn 1152: my @contexts = qw(auto web dc_create requestcourses);
1.127 raeburn 1153: my %contextnames =
1154: &Apache::lonlocal::texthash (
1.128 raeburn 1155: auto => 'Automated creation from batch file',
1156: web => 'Batch creation from uploaded file',
1.131 raeburn 1157: dc_create => 'Course or community created by Dom. Coord.',
1.128 raeburn 1158: requestcourses => 'Processing of submitted course request',
1.127 raeburn 1159: );
1160: return (\@contexts,\%contextnames);
1161: }
1162:
1163: sub instcode_srchstr {
1164: my ($domain,$numtitles) = @_;
1165: my $instcode;
1166: if (defined($numtitles) && $numtitles == 0) {
1167: $instcode = '.+';
1168: } else {
1169: my (%codedefaults,@code_order);
1170: my $defaults_result =
1171: &Apache::lonnet::auto_instcode_defaults($domain,\%codedefaults,
1172: \@code_order);
1173: if ($defaults_result eq 'ok') {
1174: $instcode ='^';
1175: foreach my $item (@code_order) {
1176: $instcode .= $codedefaults{$item};
1177: }
1178: $instcode .= '$';
1179: } else {
1180: $instcode = '.+';
1181: }
1182: }
1183: return $instcode;
1184: }
1185:
1186: sub syllabuslink_javascript {
1187: return <<"ENDJS";
1188:
1189: function ToSyllabus(cdom,cnum) {
1190: if (cdom == '' || cdom == null) {
1191: return;
1192: }
1193: if (cnum == '' || cnum == null) {
1194: return;
1195: }
1196: var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
1197: var url = "/public/"+cdom+"/"+cnum+"/syllabus";
1198: syllwin = window.open(url,'',options,1);
1199: syllwin.focus();
1200: return;
1201: }
1202:
1203: ENDJS
1204:
1205: }
1.126 raeburn 1206:
1.2 www 1207: # ===================================================================== Handler
1.1 www 1208: sub handler {
1209: my $r = shift;
1210:
1211: if ($r->header_only) {
1.38 www 1212: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1213: $r->send_http_header;
1214: return OK;
1215: }
1216:
1.137 raeburn 1217: my $show_all_choices = 0;
1218: my $primary_rev = &Apache::lonnet::get_server_loncaparev($env{'request.role.domain'});
1219: if (($primary_rev ne 'refused') && ($primary_rev ne 'error') &&
1220: ($primary_rev ne 'unknown_cmd') && ($primary_rev ne 'no_such_host')) {
1221: $show_all_choices = 1;
1222: }
1223:
1.78 albertel 1224: if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
1.38 www 1225: &Apache::loncommon::content_type($r,'text/html');
1.1 www 1226: $r->send_http_header;
1227:
1.90 raeburn 1228: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1229: ['phase']);
1230: &Apache::lonhtmlcommon::clear_breadcrumbs();
1231: &Apache::lonhtmlcommon::add_breadcrumb
1232: ({href=>"/adm/createcourse",
1233: text=>"Creation Options",
1234: faq=>79,bug=>'Dom Coord Interface',});
1235: if (($env{'form.phase'} eq 'coursetwo') ||
1.137 raeburn 1236: (($env{'form.phase'} eq 'grouptwo') &&
1237: ($show_all_choices))) {
1.90 raeburn 1238: &Apache::lonhtmlcommon::add_breadcrumb
1239: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1240: text=>&mt('[_1] Creation Settings',),
1241: faq=>9,bug=>'Dom Coord Interface',});
1242: &Apache::lonhtmlcommon::add_breadcrumb
1243: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1244: text=>"Creation Outcome",
1245: faq=>9,bug=>'Dom Coord Interface',});
1.10 matthew 1246: &create_course($r);
1.90 raeburn 1247: } elsif (($env{'form.phase'} eq 'courseone') ||
1.137 raeburn 1248: (($env{'form.phase'} eq 'groupone') &&
1249: ($show_all_choices))) {
1.90 raeburn 1250: &Apache::lonhtmlcommon::add_breadcrumb
1251: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1252: text=>&mt('[_1] Creation Settings',),
1253: faq=>9,bug=>'Dom Coord Interface',});
1254: &print_course_creation_page($r);
1255: } elsif ($env{'form.phase'} eq 'batchone') {
1256: &Apache::lonhtmlcommon::add_breadcrumb
1257: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1258: text=>"Upload Description File",
1259: faq=>9,bug=>'Dom Coord Interface',});
1260: &upload_batchfile($r);
1261: } elsif ($env{'form.phase'} eq 'batchtwo') {
1262: &Apache::lonhtmlcommon::add_breadcrumb
1263: ({href=>"/adm/createcourse?phase=$env{'form.prevphase'}",
1264: text=>"Upload Description File",
1265: faq=>9,bug=>'Dom Coord Interface',});
1266: &Apache::lonhtmlcommon::add_breadcrumb
1267: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1268: text=>"Creation Outcome",
1269: faq=>9,bug=>'Dom Coord Interface',});
1270: &process_batchfile($r);
1.137 raeburn 1271: } elsif (($env{'form.phase'} eq 'requestdisplay') && ($show_all_choices)) {
1.125 raeburn 1272: &Apache::lonhtmlcommon::add_breadcrumb
1273: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1274: text=>&mt('[_1] Display Request Queue',),
1275: faq=>9,bug=>'Dom Coord Interface',});
1.126 raeburn 1276: my $js = &courserequestbrowser_javascript();
1277: my $start_page=&Apache::loncommon::start_page('Display Requests',$js);
1.125 raeburn 1278: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Requests','Course_Request',undef,'Course_Request');
1279: $r->print($start_page.$crumbs."\n".'<div>'.
1280: &Apache::loncoursequeueadmin::display_queued_requests(
1281: 'domain',$env{'request.role.domain'}).'</div>'.
1282: &Apache::loncommon::end_page());
1.137 raeburn 1283: } elsif (($env{'form.phase'} eq 'requestchange') && ($show_all_choices)) {
1.136 raeburn 1284: if ($env{'form.queue'} eq 'pending') {
1285: &Apache::lonhtmlcommon::add_breadcrumb
1286: ({href=>"/adm/createcourse?phase=pendingdisplay",
1287: text=>&mt('Display Pending Queue',),
1288: faq=>9,bug=>'Dom Coord Interface',});
1289: } else {
1290: &Apache::lonhtmlcommon::add_breadcrumb
1291: ({href=>"/adm/createcourse?phase=requestdisplay",
1292: text=>&mt('[_1] Display Request Queue',),
1293: faq=>9,bug=>'Dom Coord Interface',});
1294: }
1.125 raeburn 1295: &Apache::lonhtmlcommon::add_breadcrumb
1.136 raeburn 1296: ({href=>"/adm/createcourse?phase=requestchange",
1297: text=>&mt('[_1] Requests Updated',),
1298: faq=>9,bug=>'Dom Coord Interface',},);
1.125 raeburn 1299: my $start_page=&Apache::loncommon::start_page('Update Requests Result');
1300: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Requests Updated','Course_Request',undef,'Course_Request');
1301: $r->print($start_page.$crumbs."\n".'<div>'.
1302: &Apache::loncoursequeueadmin::update_request_queue(
1303: 'domain',$env{'request.role.domain'}).'</div>'.
1304: &Apache::loncommon::end_page());
1.137 raeburn 1305: } elsif (($env{'form.phase'} eq 'pendingdisplay') && ($show_all_choices)) {
1.136 raeburn 1306: &Apache::lonhtmlcommon::add_breadcrumb
1307: ({href=>"/adm/createcourse?phase=$env{'form.phase'}",
1308: text=>&mt('Display Pending Queue',),
1309: faq=>9,bug=>'Dom Coord Interface',});
1310: my $js = &courserequestbrowser_javascript();
1311: my $start_page=&Apache::loncommon::start_page('Display Pending Queue',$js);
1312: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Display Pending Queue','Course_Request',undef,'Course_Request');
1313: $r->print($start_page.$crumbs."\n".'<div>'.
1314: &Apache::loncoursequeueadmin::display_queued_requests(
1315: 'pending',$env{'request.role.domain'}).'</div>'.
1316: &Apache::loncommon::end_page());
1.137 raeburn 1317: } elsif (($env{'form.phase'} eq 'requestvalidation') && ($show_all_choices)) {
1.136 raeburn 1318: my $js = &courserequestbrowser_javascript();
1319: &Apache::lonhtmlcommon::add_breadcrumb
1320: ({href=>"/adm/createcourse?phase=pendingdisplay",
1321: text=>&mt('Display Pending Queue'),},
1322: {href=>"/adm/createcourse?phase=requestvalidation",
1323: text=>&mt('Validation Attempted'),},);
1324: my $start_page=&Apache::loncommon::start_page('Requests Validation Result',$js);
1325: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Validation Attempted','Course_Request',undef,'Course_Request');
1326: $r->print($start_page.$crumbs."\n".'<div>'.
1327: &Apache::loncoursequeueadmin::process_official_reqs('domain',$env{'request.role.domain'}).'</div>'.
1328: &Apache::loncommon::end_page());
1.137 raeburn 1329: } elsif (($env{'form.phase'} eq 'creationlog') && ($show_all_choices)) {
1.127 raeburn 1330: &Apache::lonhtmlcommon::add_breadcrumb
1331: ({href=>"/adm/createcourse?phase=creationlog",
1332: text=>&mt('[_1] Display Creation History',),});
1333: my $js = '<script type="text/javascript">'."\n".
1334: '// <![CDATA['."\n".
1335: &syllabuslink_javascript()."\n".
1336: '// ]]>'."\n".
1337: '</script>';
1.131 raeburn 1338: my $start_page=&Apache::loncommon::start_page('Course/Community Creation Logs',$js);
1339: my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Created Courses/Communities','Creation_Log',undef,'Creation_Log');
1.127 raeburn 1340: $r->print($start_page.$crumbs."\n".'<div>');
1341: &print_creation_logs($r);
1342: $r->print('</div>'.&Apache::loncommon::end_page());
1.2 www 1343: } else {
1.137 raeburn 1344: &print_intro_page($r,$show_all_choices);
1.2 www 1345: }
1.1 www 1346: } else {
1.78 albertel 1347: $env{'user.error.msg'}=
1.127 raeburn 1348: "/adm/createcourse:ccc:0:0:Cannot create courses or communities";
1.1 www 1349: return HTTP_NOT_ACCEPTABLE;
1350: }
1351: return OK;
1.90 raeburn 1352: }
1.1 www 1353:
1354: 1;
1355: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>