Annotation of loncom/interface/lonpickcourse.pm, revision 1.122
1.1 www 1: # The LearningOnline Network
2: # Pick a course
3: #
1.122 ! raeburn 4: # $Id: lonpickcourse.pm,v 1.121 2016/11/01 15:47:11 raeburn Exp $
1.1 www 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: #
28:
29: package Apache::lonpickcourse;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::loncommon;
1.106 raeburn 34: use Apache::lonhtmlcommon;
1.1 www 35: use Apache::loncoursedata;
36: use Apache::lonnet;
1.8 www 37: use Apache::lonlocal;
1.46 raeburn 38: use Apache::longroup;
1.85 raeburn 39: use LONCAPA qw(:DEFAULT :match);
1.1 www 40:
41: sub handler {
42: my $r = shift;
1.8 www 43: &Apache::loncommon::content_type($r,'text/html');
1.1 www 44: $r->send_http_header;
45: return OK if $r->header_only;
46:
47: # ------------------------------------------------------------ Print the screen
1.40 albertel 48:
1.55 raeburn 49: # Get parameters from query string
1.1 www 50: &Apache::loncommon::get_unprocessed_cgi
1.55 raeburn 51: ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement',
1.19 raeburn 52: 'cdomelement','cnameelement','roleelement',
1.116 raeburn 53: 'multiple','type','setroles','fixeddom','cloner',
54: 'crscode','crsdom']);
1.90 raeburn 55: my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement,
1.116 raeburn 56: $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom,$crscode,$crsdom);
1.55 raeburn 57:
1.117 raeburn 58: # Get course type - Course, Community or Placement.
1.54 raeburn 59: $type = $env{'form.type'};
60: if (!defined($env{'form.type'})) {
61: $type = 'Course';
62: }
1.82 bisitz 63: $title = 'Selecting a '.$type;
1.54 raeburn 64:
65: # Setup for multiple course selections, if flag for multiples set.
1.55 raeburn 66: $multiple = $env{'form.multiple'};
67: if ($multiple) {
68: ($jscript,$multelement) = &multiples_tag();
1.82 bisitz 69: $title = 'Selecting '.$type.'(s)';
1.54 raeburn 70: }
71:
1.120 raeburn 72: # if called when a DC or DH is selecting a course
73: my ($roledom,$rolename) = split(/:/,$env{'form.roleelement'});
1.54 raeburn 74: if ($roledom) {
1.120 raeburn 75: $roleelement = '<input type="hidden" name="roleelement" value="'.$env{'form.roleelement'}.'" />';
1.66 raeburn 76: $submitopener = &processpick();
1.120 raeburn 77: $autosubmit = 'process_pick("'.$roledom.'","'.$rolename.'")';
1.54 raeburn 78: }
1.90 raeburn 79: if ($env{'form.typeelement'} ne '') {
80: $typeelement = '<input type="hidden" name="typeelement" value="'.$env{'form.typeelement'}.'" />';
81: }
1.54 raeburn 82:
1.92 raeburn 83: # if called when a DC is creating a course for another user.
1.85 raeburn 84: if ($env{'form.form'} eq 'ccrs') {
85: ($cloneruname,$clonerudom) = ($env{'form.cloner'} =~ /^($match_username):($match_domain)$/);
1.116 raeburn 86: $crscode = $env{'form.crscode'};
87: $crsdom = $env{'request.role.domain'};
1.85 raeburn 88: }
89:
90: # if called when requesting a course
91: if ($env{'form.form'} eq 'requestcrs') {
92: $cloneruname = $env{'user.name'};
93: $clonerudom = $env{'user.domain'};
1.116 raeburn 94: $crscode = $env{'form.crscode'};
95: $crsdom = $env{'form.crsdom'};
1.85 raeburn 96: }
97:
1.54 raeburn 98: my $onlyown = 0;
1.55 raeburn 99: # if called to assign course-based portfolio access control
1.59 raeburn 100: if ((($env{'form.form'} eq 'portform') && (!$env{'user.adv'}))) {
1.54 raeburn 101: $onlyown = 1;
1.49 raeburn 102: }
1.55 raeburn 103:
104: my %loaditem;
1.84 raeburn 105: if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) {
106: if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) {
107: $loaditem{'onload'} = 'setElements(document.filterpicker); ';
108: }
1.78 raeburn 109: }
110:
1.66 raeburn 111: if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) &&
112: ($env{'form.pickedcourse'})) {
1.115 raeburn 113: if ($type ne 'Community') {
114: my %coursedescription =
115: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},
116: {'one_time' => '1'});
117: my $cdom = $coursedescription{'domain'};
118: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
119: if (($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'})) {
120: $loaditem{'onload'} .= 'setDefaultCredits();';
121: }
122: }
123: $loaditem{'onload'} .= 'setRoles();setSections();';
1.30 raeburn 124: }
1.113 raeburn 125: if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) && (!$onlyown)) {
126: $loaditem{'onload'} .= 'hideSearching(); ';
127: }
1.112 raeburn 128: my $js = &Apache::loncommon::js_changer();
1.107 raeburn 129: $r->print(&Apache::loncommon::start_page($title,$js,
1.42 albertel 130: {'add_entries' => \%loaditem,
1.41 albertel 131: 'no_nav_bar' => 1, }));
1.55 raeburn 132:
133: if ($env{'form.form'} eq 'portform') {
134: $lastaction = 'document.courselist.submit()';
1.67 raeburn 135: } elsif ($env{'form.form'} eq 'cu' || ($env{'form.form'} eq 'studentform' &&
136: !$multiple)) {
1.55 raeburn 137: $lastaction =
138: 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n".
139: 'document.courselist.submit();';
1.34 albertel 140: } else {
1.55 raeburn 141: $lastaction = 'self.close()';
1.1 www 142: }
1.19 raeburn 143:
1.55 raeburn 144: # if called to assign a role in a course to a user via CUSR
1.66 raeburn 145: if ($env{'form.form'} eq 'cu' || $env{'form.form'} eq 'studentform') {
1.68 raeburn 146: $r->print(&create_user_javascript($type));
1.55 raeburn 147: }
1.54 raeburn 148:
1.55 raeburn 149: # print javascript functions for choosing a course
1.85 raeburn 150: if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) ||
151: $onlyown) {
1.58 raeburn 152: $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction));
1.55 raeburn 153: }
1.105 bisitz 154: $r->print(&Apache::lonhtmlcommon::scripttag($jscript));
1.55 raeburn 155: $r->print($submitopener);
1.54 raeburn 156:
1.55 raeburn 157: # ------------------------------------------ Display of filters to limit search
1.57 raeburn 158: my $filter = {};
159: my $action = '/adm/pickcourse';
1.99 raeburn 160: my ($numtitles,$showroles,$nohost,@codetitles);
1.112 raeburn 161: unless ($onlyown) {
1.111 raeburn 162: my $filterlist = ['domainfilter','sincefilter'];
1.94 raeburn 163: # created filter for DCs only
164: if ($env{'user.adv'} && $env{'form.domainfilter'} &&
1.95 raeburn 165: exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})
166: && $env{'form.form'} ne 'portform') {
1.94 raeburn 167: my $loncaparev = &Apache::lonnet::get_server_loncaparev($env{'form.domainfilter'});
168: if ($loncaparev ne 'unknown_cmd') {
169: push(@{$filterlist},'createdfilter');
170: }
171: }
172: push(@{$filterlist},('descriptfilter','instcodefilter'));
1.79 raeburn 173: if ($env{'form.form'} eq 'rules') {
1.111 raeburn 174: push(@{$filterlist},('personfilter','persondomfilter'));
175: if ($env{'form.persondomfilter'} eq '') {
176: unless ($env{'form.gosearch'}) {
177: $filter->{'persondomfilter'} = $env{'request.role.domain'};
178: }
179: } else {
180: $filter->{'persondomfilter'} =
181: &LONCAPA::clean_domain($env{'form.persondomfilter'});
182: }
1.79 raeburn 183: if (($env{'form.personfilter'} ne '') && ($env{'form.persondomfilter'} ne '')) {
184: if (&Apache::lonnet::homeserver($env{'form.personfilter'},
185: $env{'form.persondomfilter'}) eq 'no_host') {
186: $nohost = 1;
187: } else {
188: $showroles = 1;
189: }
190: }
191: } else {
1.111 raeburn 192: push(@{$filterlist},('ownerfilter','ownerdomfilter'));
1.79 raeburn 193: }
1.55 raeburn 194: # course ID filter for DCs only
195: if ($env{'user.adv'} && $env{'form.domainfilter'} &&
196: exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})) {
197: push(@{$filterlist},'coursefilter');
198: }
1.85 raeburn 199: if ($cloneruname ne '' && $clonerudom ne '') {
200: push(@{$filterlist},'cloneableonly');
201: }
1.111 raeburn 202: if ((ref($filterlist) eq 'ARRAY') && (ref($filter) eq 'HASH')) {
203: foreach my $item (@{$filterlist}) {
204: $filter->{$item} = $env{'form.'.$item};
205: }
206: }
207: if ($env{'form.form'} eq 'portform') {
208: $filter->{'domainfilter'} ||= $env{'user.domain'};
209: } elsif ($env{'form.form'} eq 'studentform') {
210: $filter->{'domainfilter'} ||= $env{'request.role.domain'};
211: }
212: my $codedom;
213: if ($env{'form.fixeddom'}) {
214: $codedom = $env{'request.role.domain'};
215: } else {
216: $codedom = $filter->{'domainfilter'};
217: }
218: my ($clonetext,$clonewarning);
219: if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
220: (my $coord_cloneable,$clonewarning) =
221: &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
222: if ($env{'form.form'} eq 'ccrs') {
223: $clonetext = '<input type="hidden" name="cloner" value="'.$env{'form.cloner'}.'" />'."\n";
224: }
225: if ($coord_cloneable) {
226: $clonetext .= '<input type="hidden" name="cc_clone" value="'.$coord_cloneable.'" />';
227: }
1.116 raeburn 228: if ($crscode ne '') {
229: $clonetext .= '<input type="hidden" name="crscode" value="'.$crscode.'" />';
230: }
231: if ($crsdom ne '') {
232: $clonetext .= '<input type="hidden" name="crsdom" value="'.$crsdom.'" />';
233: }
1.111 raeburn 234: }
235: $r->print(&Apache::loncommon::build_filters($filterlist,$type,$roleelement,$multelement,
236: $filter,$action,\$numtitles,undef,$cloneruname,
237: $clonerudom,$typeelement,\@codetitles,$codedom,
238: $env{'form.form'},$env{'form.fixeddom'},
239: $env{'form.prevphase'},$env{'form.cnameelement'},
240: $env{'form.cnumelement'},$env{'form.cdomelement'},
241: $env{'form.setroles'},$clonetext,$clonewarning));
1.55 raeburn 242: }
1.54 raeburn 243:
244: # ---------------------------------------------------------------- Get the data
1.85 raeburn 245: if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) ||
246: $onlyown) {
1.98 raeburn 247: my $domcloner;
248: if ($env{'form.form'} eq 'ccrs') {
249: if (($env{'request.role.domain'} eq $env{'form.domainfilter'}) &&
250: (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
251: $domcloner = 1;
252: }
253: }
1.112 raeburn 254: my %courses;
255: if (!$onlyown) {
256: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
257: $r->rflush();
258: my $srchdom = $filter->{'domainfilter'};
259: %courses = &Apache::loncommon::search_courses($srchdom,$type,$filter,$numtitles,
260: $cloneruname,$clonerudom,$domcloner,
1.116 raeburn 261: \@codetitles,$env{'form.cc_clone'},
262: $crsdom,$crscode);
1.112 raeburn 263: } else {
264: $r->print('<br />');
265: my %coursehash = &Apache::loncommon::findallcourses();
266: foreach my $cid (sort(keys(%coursehash))) {
267: $courses{$cid}{'description'} = $env{'course.'.$cid.'.description'};
268: }
269: }
1.79 raeburn 270: if ($nohost) {
271: $r->print ('<span class="LC_warning">'.
272: &mt('User does not exist - username: [_1], domain: [_2].',
273: '<b>'.$filter->{'personfilter'}.'</b>',
274: '<b>'.$filter->{'persondomfilter'}.'</b>').'</span>');
275: } else {
1.85 raeburn 276: &display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,
1.116 raeburn 277: $clonerudom,$crsdom,$crscode,%courses);
1.79 raeburn 278: }
1.54 raeburn 279: }
280: $r->print(&Apache::loncommon::end_page());
281: return OK;
282: }
283:
1.66 raeburn 284: sub processpick {
285: my $openerform = 'rolechoice';
286: if ($env{'form.form'} eq 'studentform') {
287: $openerform = $env{'form.form'};
288: }
289: my $process_pick = <<"ENDONE";
290: <script type="text/javascript">
1.120 raeburn 291: function process_pick(dom,rolename) {
1.66 raeburn 292: var pickedCourse=opener.document.$openerform.$env{'form.cnumelement'}.value;
293: var pickedDomain=opener.document.$openerform.$env{'form.cdomelement'}.value;
294: var okDomain = 0;
295: ENDONE
296: if ($openerform eq 'rolechoice') {
297: $process_pick .= <<"ENDTWO";
298: if (pickedDomain == dom) {
299: if (pickedCourse != '') {
1.120 raeburn 300: var courseTarget;
301: if (rolename == 'cc') {
302: var ccrole = "cc";
303: var pickedType = "$env{'form.type'}";
304: if (pickedType == "Community") {
305: ccrole = "co";
306: }
307: courseTarget = ccrole+"./"+pickedDomain+"/"+pickedCourse;
308: } else {
309: if (!/\\W/.test(rolename)) {
310: courseTarget = "cr/"+pickedDomain+"/"+pickedDomain+"-domainconfig/"+rolename+"./"+pickedDomain+"/"+pickedCourse;
311: }
312: }
313: if ((courseTarget != '') && (courseTarget != undefined)) {
314: opener.document.title='Role selected. Please stand by.';
315: opener.status='Role selected. Please stand by.';
316: opener.document.rolechoice.newrole.value=courseTarget;
317: opener.document.rolechoice.submit();
318: } else {
319: alert("Invalid role selection");
320: return;
321: }
1.66 raeburn 322: }
1.120 raeburn 323: }
1.66 raeburn 324: else {
325: alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
326: }
327: ENDTWO
328: } else {
329: $process_pick .= <<"ENDTHREE";
330: if (pickedDomain != dom) {
331: alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
332: return;
333: }
334: ENDTHREE
335: }
336: $process_pick .= "
337: }
338:
339: </script>
340: ";
341: return $process_pick;
342: }
343:
1.55 raeburn 344: sub create_user_javascript {
345: my ($type) = @_;
346: my $output;
347: #javascript for reporting sections and groups then closing
348: if ($env{'form.pickedcourse'}) {
1.87 raeburn 349: my %coursedescription =
350: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},
351: {'one_time' => '1'});
352: my $cdom = $coursedescription{'domain'};
353: my $cnum = $coursedescription{'num'};
354: my $crstype = $coursedescription{'type'};
1.106 raeburn 355: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
356: my ($showcredits,$credits);
357: if (($crstype ne 'Community') &&
1.109 raeburn 358: (($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'}))) {
1.106 raeburn 359: $showcredits = 1;
360: $credits = $coursedescription{'internal.defaultcredits'};
361: }
1.55 raeburn 362: my $sec_element = 'currsec';
363: my $grplist_element = 'groups';
364: my ($sections,$groups) =
365: &Apache::loncommon::get_secgrprole_info($cdom,$cnum,'',$type);
366: my $num_sections = scalar(@{$sections});
367: my $seclist = join(',',@{$sections});
368: my $num_groups = scalar(@{$groups});
369: my $groupslist = join(',',@{$groups});
370: $output = qq|
371: <script type="text/javascript">
1.106 raeburn 372: // <![CDATA[
1.55 raeburn 373: function setSections() {
374: opener.document.$env{"form.form"}.$grplist_element.value='$groupslist';
375: window.opener.setSect('$seclist');
1.87 raeburn 376: self.close();
377: }
378: function setRoles() {
379: window.opener.setRole('$crstype');
1.55 raeburn 380: }
1.106 raeburn 381: |;
382: if ($showcredits) {
383: $output .= qq|
384: function setDefaultCredits() {
385: window.opener.setCredits('$credits');
386: }
387: |;
388: }
389: $output .= qq|
390: // ]]>
1.55 raeburn 391: </script>
392: |;
393: }
394: return $output;
395: }
396:
1.54 raeburn 397: sub display_matched_courses {
1.116 raeburn 398: my ($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,$crsdom,$crscode,%courses) = @_;
1.55 raeburn 399: if ($env{'form.form'} eq 'portform') {
400: $action = '/adm/portfolio';
401: }
1.68 raeburn 402: my $numcourses = keys(%courses);
1.55 raeburn 403: $r->print('<form name="courselist" method="post" action="'.$action.'">');
1.68 raeburn 404: if ($env{'form.form'} eq 'modifycourse') {
405: if ($numcourses > 0) {
1.89 raeburn 406: my $ccrole = 'cc';
407: if ($type eq 'Community') {
408: $ccrole = 'co';
409: }
410: my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.68 raeburn 411: my $dctitle = &Apache::lonnet::plaintext('dc');
1.93 raeburn 412: my $ccrolechk = ' ';
1.122 ! raeburn 413: my $possrole;
1.93 raeburn 414: my $menuchk = ' checked="checked" ';
1.68 raeburn 415: $r->print(
1.106 raeburn 416: '<div class="LC_left_float">'
417: .'<fieldset>'
1.122 ! raeburn 418: .'<legend>'.&mt('Pick action').'</legend>');
! 419: my $roleradio = '<span class="LC_nobreak"><label>'.
! 420: '<input type="radio" name="phase" value="adhocrole"'.$ccrolechk.'/>'.' ';
1.119 raeburn 421: if (&Apache::lonnet::allowed('ccc',$crsdom)) {
1.122 ! raeburn 422: $possrole = 1;
! 423: $r->print($roleradio);
1.119 raeburn 424: if ($type eq 'Community') {
425: $r->print(&mt('Enter the community with the role of [_1].',$cctitle));
426: } elsif ($type eq 'Placement') {
427: $r->print(&mt('Enter the placement test with the role of [_1].',$cctitle));
428: } else {
429: $r->print(&mt('Enter the course with the role of [_1].',$cctitle));
430: }
431: } elsif (&Apache::lonnet::allowed('rar',$crsdom)) {
432: my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
433: 'adhocroles.'.$crsdom);
1.122 ! raeburn 434: if ($adhocroles{'adhocroles.'.$crsdom} ne '') {
! 435: $possrole = 1;
! 436: $r->print($roleradio);
1.119 raeburn 437: my @adhoc = split(/,/,$adhocroles{'adhocroles.'.$crsdom});
438: if (@adhoc > 1) {
439: my %adhochash;
440: map { $adhochash{$_} = $_; } @adhoc;
441: my $selector = &Apache::loncommon::select_form($adhoc[0],'adhocrole',\%adhochash);
442: if ($type eq 'Community') {
443: $r->print(&mt('Enter the community with one of the available ad hoc roles: [_1].',
444: $selector));
445: } elsif ($type eq 'Placement') {
446: $r->print(&mt('Enter the placement test with one of the available ad hoc roles: [_1].',
447: $selector));
448: } else {
449: $r->print(&mt('Enter the course with one of the available ad hoc roles: [_1].',
450: $selector));
451: }
452: } else {
453: if ($type eq 'Community') {
454: $r->print(&mt('Enter the community with the ad hoc role of: [_1]',$adhoc[0]));
455: } elsif ($type eq 'Placement') {
456: $r->print(&mt('Enter the placement test with the ad hoc role of: [_1]',$adhoc[0]));
457: } else {
458: $r->print(&mt('Enter the course with the ad hoc role of: [_1]',$adhoc[0]));
459: }
1.121 raeburn 460: $r->print('<input type="hidden" name="adhocrole" value="'.$adhoc[0].'" />');
1.119 raeburn 461: }
462: }
1.89 raeburn 463: }
1.122 ! raeburn 464: if ($possrole) {
! 465: $r->print('</label></span><br />');
! 466: }
! 467: $r->print('<span class="LC_nobreak"><label>'
! 468: .'<input type="radio" name="phase" value="menu"'.$menuchk.'/> ');
1.119 raeburn 469: if (&Apache::lonnet::allowed('ccc',$crsdom)) {
470: if ($type eq 'Community') {
471: $r->print(&mt('View or modify community settings which only a [_1] may modify.',$dctitle));
472: } elsif ($type eq 'Placement') {
473: $r->print(&mt('View or modify placement test settings which only a [_1] may modify.',$dctitle));
474: } else {
475: $r->print(&mt('View or modify course settings which only a [_1] may modify.',$dctitle));
476: }
477: } elsif (&Apache::lonnet::allowed('rar',$crsdom)) {
478: if ($type eq 'Community') {
479: $r->print(&mt('View community settings which only a [_1] may modify.',$dctitle));
480: } elsif ($type eq 'Placement') {
481: $r->print(&mt('View placement test settings which only a [_1] may modify.',$dctitle));
482: } else {
483: $r->print(&mt('View course settings which only a [_1] may modify.',$dctitle));
484: }
1.89 raeburn 485: }
1.106 raeburn 486: $r->print('</label></span>'
1.119 raeburn 487: .'</fieldset></div>'
488: .'<br clear="all" />'
489: );
1.68 raeburn 490: }
491: }
1.54 raeburn 492: my %by_descrip;
493: foreach my $course (keys(%courses)) {
494: my $descr;
1.64 raeburn 495: if (ref($courses{$course}) eq 'HASH') {
1.65 raeburn 496: $descr = $courses{$course}{'description'};
1.64 raeburn 497: } elsif ($courses{$course} =~ m/^([^:]*):/i) {
1.54 raeburn 498: $descr = &unescape($1);
1.34 albertel 499: } else {
1.54 raeburn 500: $descr = &unescape($courses{$course});
501: }
502: my $description = $descr;
503: push (@{$by_descrip{$description}}, $course);
504: }
1.71 bisitz 505:
1.54 raeburn 506: if ($numcourses > 1 && $multiple) {
1.104 bisitz 507: $r->print('<input type="button" value="'.&mt('check all').'"
1.54 raeburn 508: onclick="javascript:checkAll(document.courselist.course_id)" />
1.104 bisitz 509: <input type="button" value="'.&mt('uncheck all').'"
1.54 raeburn 510: onclick="javascript:uncheckAll(document.courselist.course_id)" />
511: <br /><br />');
512: }
1.71 bisitz 513:
514: if (%courses) {
515: $r->print(&Apache::loncommon::start_data_table());
516: $r->print(&Apache::loncommon::start_data_table_header_row());
1.89 raeburn 517: my $titlehdr = &mt('Course Title');
518: if ($type eq 'Community') {
519: $titlehdr = &mt('Community Title');
520: }
1.71 bisitz 521: $r->print('<th>'.&mt('Select').'</th>'
1.89 raeburn 522: .'<th>'.$titlehdr.'</th>'
523: .'<th>'.&mt('Domain').'</th>');
1.117 raeburn 524: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.89 raeburn 525: $r->print('<th>'.&mt('Course Code').'</th>');
526: }
527: $r->print('<th>'.&mt('Owner/Co-owner(s)').'</th>');
1.79 raeburn 528: if ($showroles) {
529: $r->print('<th>'.&mt("Role(s) for [_1]",
530: &Apache::loncommon::plainname($env{'form.personfilter'},
531: $env{'form.persondomfilter'},'firstname')).'</th>');
532: }
1.71 bisitz 533: $r->print(&Apache::loncommon::end_data_table_header_row());
534: }
1.92 raeburn 535: my %cc_cloneable;
536: if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
537: my ($coord_cloneable,$warning) =
538: &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
539: if ($coord_cloneable) {
540: map {$cc_cloneable{$_} = 1;} split('&',$coord_cloneable);
541: }
542: }
1.116 raeburn 543: my (%gotdomdefaults,%gotcodedefaults);
1.54 raeburn 544: foreach my $description (sort { lc($a) cmp lc($b) } (keys(%by_descrip))) {
545: foreach my $course (@{$by_descrip{$description}}) {
1.72 raeburn 546: $r->print(&Apache::loncommon::start_data_table_row());
1.54 raeburn 547: my $cleandesc=&HTML::Entities::encode($description,'<>&"');
548: $cleandesc=~s/'/\\'/g;
549: my ($cdom,$cnum)=split(/\_/,$course);
1.85 raeburn 550: my ($descr,$instcode,$ttype,$canclone,@owners);
1.64 raeburn 551: if (ref($courses{$course}) eq 'HASH') {
552: $descr = $courses{$course}{'description'};
1.85 raeburn 553: $instcode = $courses{$course}{'inst_code'};
554: $ttype = $courses{$course}{'type'};
555: if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
1.98 raeburn 556: if ($env{'form.form'} eq 'ccrs') {
557: if (($env{'request.role.domain'} eq $cdom) &&
558: (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
559: $canclone = 1;
560: }
561: }
562: unless ($canclone) {
563: if ($cc_cloneable{$cnum.':'.$cdom}) {
564: $canclone = 1;
565: }
1.92 raeburn 566: }
567: unless ($canclone) {
568: my $cloners = $courses{$course}{'cloners'};
1.116 raeburn 569: if ($cloners ne '') {
1.92 raeburn 570: my @cloneable = split(',',$cloners);
571: if (grep(/^\*$/,@cloneable)) {
572: $canclone = 1;
573: }
1.97 raeburn 574: if (grep(/^\*:\Q$clonerudom\E$/,@cloneable)) {
1.92 raeburn 575: $canclone = 1;
576: }
577: if (grep(/^\Q$cloneruname\E:\Q$clonerudom\E$/,@cloneable)) {
578: $canclone = 1;
579: }
1.116 raeburn 580: unless ($canclone) {
581: if (($instcode) && ($crscode) && ($cdom eq $crsdom)) {
582: foreach my $cloner (@cloneable) {
583: if (($cloner ne '*') && ($cloner !~ /^\*\:$match_domain$/) &&
584: ($cloner !~ /^$match_username\:$match_domain$/) && ($cloner ne '')) {
585: if ($cloner =~ /\=/) {
586: my (%codedefaults,@code_order);
587: if (ref($gotcodedefaults{$cdom}) eq 'HASH') {
588: if (ref($gotcodedefaults{$cdom}{'defaults'}) eq 'HASH') {
589: %codedefaults = %{$gotcodedefaults{$cdom}{'defaults'}};
590: }
591: if (ref($gotcodedefaults{$cdom}{'order'}) eq 'ARRAY') {
592: @code_order = @{$gotcodedefaults{$cdom}{'order'}};
593: }
594: } else {
595: &Apache::lonnet::auto_instcode_defaults($cdom,
596: \%codedefaults,
597: \@code_order);
598: $gotcodedefaults{$cdom}{'defaults'} = \%codedefaults;
599: $gotcodedefaults{$cdom}{'order'} = \@code_order;
600: }
601: if (@code_order > 0) {
602: if (&Apache::lonnet::check_instcode_cloning(\%codedefaults,\@code_order,
603: $cloner,$instcode,$crscode)) {
604: $canclone = 1;
605: last;
606: }
607: }
608: }
609: }
610: }
611: }
612: }
613: } else {
614: my %domdefs;
615: if (ref($gotdomdefaults{$cdom}) eq 'HASH') {
616: %domdefs = %{$gotdomdefaults{$cdom}};
617: } else {
618: %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
619: $gotdomdefaults{$cdom} = \%domdefs;
620: }
621: if ($domdefs{'canclone'}) {
622: unless ($domdefs{'canclone'} eq 'none') {
623: if ($domdefs{'canclone'} eq 'domain') {
624: if ($clonerudom eq $cdom) {
625: $canclone = 1;
626: }
627: } elsif (($instcode) && ($crscode) &&
628: ($cdom eq $crsdom)) {
629: my (%codedefaults,@code_order);
630: if (ref($gotcodedefaults{$cdom}) eq 'HASH') {
631: if (ref($gotcodedefaults{$cdom}{'defaults'}) eq 'HASH') {
632: %codedefaults = %{$gotcodedefaults{$cdom}{'defaults'}};
633: }
634: if (ref($gotcodedefaults{$cdom}{'order'}) eq 'ARRAY') {
635: @code_order = @{$gotcodedefaults{$cdom}{'order'}};
636: }
637: } else {
638: &Apache::lonnet::auto_instcode_defaults($cdom,
639: \%codedefaults,
640: \@code_order);
641: $gotcodedefaults{$cdom}{'defaults'} = \%codedefaults;
642: $gotcodedefaults{$cdom}{'order'} = \@code_order;
643: }
644: if (@code_order > 0) {
645: if (&Apache::lonnet::default_instcode_cloning($cdom,$domdefs{'canclone'},
646: $instcode,$crscode,\%codedefaults,
647: \@code_order)) {
648: $canclone = 1;
649: }
650: }
651: }
652: }
653: }
1.85 raeburn 654: }
655: }
656: }
1.101 raeburn 657: push(@owners,$courses{$course}{'owner'});
658: if ($courses{$course}{'co-owners'} ne '') {
659: foreach my $item (split(/,/,$courses{$course}{'co-owners'})) {
660: push(@owners,$item);
1.64 raeburn 661: }
662: }
663: } else {
664: my $singleowner;
665: ($descr,$instcode,$singleowner,$ttype)=split(/:/,$courses{$course});
666: push(@owners,&unescape($singleowner));
667: }
1.93 raeburn 668: my $ownerstr = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } @owners);
1.85 raeburn 669: $r->print('<td>'.&course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone).'</td>');
1.71 bisitz 670: $r->print('<td>'.$description.'</td>');
671: $r->print('<td>');
672: $r->print(&Apache::lonnet::domain($cdom,'description')?
673: $cdom.' ('.&Apache::lonnet::domain($cdom,'description').')':$cdom);
674: $r->print('</td>');
1.117 raeburn 675: unless (($type eq 'Community') || ($type eq 'Placement')) {
1.89 raeburn 676: $r->print('<td>');
677: if ($instcode ne '') {
678: $r->print(&unescape($instcode));
679: } else {
680: $r->print(' ');
681: }
682: $r->print('</td>');
1.54 raeburn 683: }
1.72 raeburn 684: $r->print('<td>'.$ownerstr.'</td>');
1.79 raeburn 685: if ($showroles) {
686: $r->print('<td>');
687: my $rolestr;
688: if (ref($courses{$course}{'roles'}) eq 'ARRAY') {
689: my @roles = sort(@{$courses{$course}{'roles'}});
690: foreach my $role (@roles) {
691: if ($role =~ /^cr/) {
692: my (undef,$crdom,$crname,$crtitle) = split('/',$role);
693: $rolestr .= $crtitle.', ';
694: } else {
1.89 raeburn 695: $rolestr .= &Apache::lonnet::plaintext($role,$type).', ';
1.79 raeburn 696: }
697: }
698: $rolestr =~ s/\, $//;
699: }
700: $r->print($rolestr.'</td>');
701: }
1.54 raeburn 702: if ($multiple) { $r->print("</label>\n"); }
1.72 raeburn 703: $r->print(&Apache::loncommon::end_data_table_row());
1.71 bisitz 704: # $r->print("<br />\n");
1.19 raeburn 705: }
706: }
1.72 raeburn 707: if (%courses) {
708: $r->print(&Apache::loncommon::end_data_table());
709: }
1.71 bisitz 710:
1.54 raeburn 711: if (!%courses) {
1.104 bisitz 712: $r->print('<p class="LC_info">'.&mt('None found').'</p>');
1.54 raeburn 713: } elsif ($multiple) {
1.108 bisitz 714: $r->print('<input type="button" value="'.&mt('Submit').'" onclick="gochoose('."'','','')".'" />');
1.54 raeburn 715: }
716: $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'.
717: "\n".'<input type="hidden" name="pickedcourse" value="" />'."\n".
718: '<input type="hidden" name="type" value="'.$type.'" />'."\n");
719: if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) {
720: $r->print('<input type="hidden" name="roleelement" value="'.
721: $env{'form.roleelement'}.'" />'."\n");
722: }
1.55 raeburn 723: if ($env{'form.form'} eq 'portform') {
724: $r->print('<input type="hidden" name="cnum" value="" />');
725: $r->print('<input type="hidden" name="cdom" value="" />');
726: $r->print('<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />');
727: $r->print('<input type="hidden" name="action" value="rolepicker" />');
1.57 raeburn 728: } elsif ($env{'form.form'} eq 'modifycourse') {
1.85 raeburn 729: $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state']));
1.57 raeburn 730: } else {
731: $r->print('<input type="hidden" name="cnumelement" value="'.
732: $env{'form.cnumelement'}.'" />'."\n".
733: '<input type="hidden" name="cdomelement" value="'.
734: $env{'form.cdomelement'}.'" />'."\n");
1.90 raeburn 735: if ($env{'form.typeelement'} ne '') {
736: $r->print('<input type="hidden" name="typeelement" value="'.
737: $env{'form.typeelement'}.'" />'."\n");
738:
739: }
1.55 raeburn 740: }
1.78 raeburn 741: if ((exists($env{'form.fixeddom'})) && ($env{'form.form'} eq 'rules')) {
742: $r->print('<input type="hidden" name="fixeddom" value="'.
743: $env{'form.fixeddom'}.'" />');
744: }
745: if ($env{'form.numtitles'}) {
746: $r->print('<input type="hidden" name="numtitles" value="'.
747: $env{'form.numtitles'}.'" />');
748: }
1.54 raeburn 749: $r->print("</form>\n");
750: return;
751: }
752:
753: sub multiples_tag {
1.55 raeburn 754: my $jscript = &Apache::loncommon::check_uncheck_jscript();
755: my $multelement = '<input type="hidden" name="multiple" value="1" />';
756: return ($jscript,$multelement);
1.1 www 757: }
1.30 raeburn 758:
1.92 raeburn 759: sub get_coordinator_cloneable {
760: my ($cloneruname,$clonerudom,$type) = @_;
1.100 www 761: if (($cloneruname!~/\w/) || ($clonerudom!~/\w/)) {
762: my $warning = '<div class="LC_warning">'.&mt('Intended course owner not specified').
763: '</div>';
764: return ('',$warning);
765: } elsif (&Apache::lonnet::homeserver($cloneruname,$clonerudom) eq 'no_host') {
1.92 raeburn 766: my $warning = '<div class="LC_error">'.&mt('Intended course owner does not exist').
767: '</div>';
768: return ('',$warning);
769: } else {
770: my ($cc_clone,$ccrole);
771: if ($type eq 'Community') {
772: $ccrole = 'co';
1.117 raeburn 773: } else {
1.92 raeburn 774: $ccrole = 'cc';
775: }
776: my %ccroles = &Apache::lonnet::get_my_roles($cloneruname,$clonerudom,
777: 'userroles',['active'], [$ccrole]);
778: foreach my $key (sort(keys(%ccroles))) {
779: my ($cnum,$cdom,$role) = split(':',$key);
780: $cc_clone .= $cdom.':'.$cnum.'&';
781: }
782: $cc_clone =~ s/\&$//;
783: return ($cc_clone);
784: }
785: }
786:
1.30 raeburn 787: sub course_chooser {
1.85 raeburn 788: my ($multiple,$cdom,$cnum,$cleandesc,$canclone) = @_;
1.30 raeburn 789: my $output;
1.35 raeburn 790: if ($multiple) {
1.32 albertel 791: $output = '<label><input type="checkbox" name="course_id" value="'.$cdom.'_'.$cnum.'" />'."\n";
1.85 raeburn 792: } elsif ((($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) && (!$canclone)) {
793: if ($env{'form.form'} eq 'ccrs') {
1.114 bisitz 794: $output = &mt('No cloning for [_1]',$env{'form.cloner'})."\n";
1.85 raeburn 795: } else {
796: $output = &mt('No rights to clone')."\n";
797: }
1.30 raeburn 798: } else {
1.108 bisitz 799: $output = '<input type="button" value="'.&mt('Select').'" onclick="gochoose('.
1.30 raeburn 800: "'".$cnum."','".$cdom."','".$cleandesc."')".'" />'."\n";
801: }
802: return $output;
1.49 raeburn 803: }
804:
1.55 raeburn 805: sub gochoose_javascript {
1.57 raeburn 806: my ($type,$multiple,$autosubmit,$lastaction) = @_;
1.55 raeburn 807: my %elements = (
808: 'Course' => {
809: name => 'coursepick',
810: total => 'coursetotal',
811: list => 'courselist',
812: },
1.83 raeburn 813: 'Community' => {
1.88 raeburn 814: name => 'coursepick',
815: total => 'coursetotal',
816: list => 'courselist',
1.55 raeburn 817: },
1.117 raeburn 818: 'Placement' => {
819: name => 'coursepick',
820: total => 'coursetotal',
821: list => 'courselist',
822: },
1.55 raeburn 823: );
1.107 raeburn 824: my $output = qq|
1.57 raeburn 825: function gochoose(cname,cdom,cdesc) {
1.55 raeburn 826: var openerForm = "$env{'form.form'}";
827: courseCount = 0;
828: var courses = '';
1.57 raeburn 829: |;
830: if ($multiple) {
831: $output .= <<"ENDSCRIPT";
832: courseCount = 0;
833: var courses = '';
834: if (typeof(document.courselist.course_id.length) == 'undefined') {
835: // only 1 course checkbox was created
836: if (document.courselist.course_id.checked) {
837: courses = courses + document.courselist.course_id.value + "&&";
838: courseCount ++;
839: }
840: } else {
841: for (var j=0; j<document.courselist.course_id.length; j++) {
842: if (document.courselist.course_id[j].checked) {
843: courses = courses + document.courselist.course_id[j].value + "&&";
1.55 raeburn 844: courseCount ++;
845: }
1.57 raeburn 846: }
847: }
848: opener.document.$env{'form.form'}.$elements{$type}{'total'}.value = courseCount;
849: if (typeof(opener.document.$env{'form.form'}.$elements{$type}{'name'}.length) ==
850: 'undefined') {
851: if (opener.document.$env{'form.form'}.$elements{$type}{'name'}.value == 'specific') {
852: opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = true;
1.55 raeburn 853: } else {
1.57 raeburn 854: opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = false;
1.55 raeburn 855: }
1.57 raeburn 856: } else {
857: for (var j=0; j<opener.document.$env{'form.form'}.$elements{$type}{'name'}.length; j++) {
858: if (opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].value == 'specific') {
859: opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = true;
1.55 raeburn 860: } else {
1.57 raeburn 861: opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = false;
1.54 raeburn 862: }
1.55 raeburn 863: }
1.57 raeburn 864: }
865: if (courseCount > 0) {
866: courses = courses.substr(0,courses.length-2);
867: opener.document.$env{'form.form'}.$elements{$type}{'list'}.value = courses;
868: }
869: ENDSCRIPT
870: } else {
1.90 raeburn 871: my ($name_code,$type_code);
1.57 raeburn 872: if ($env{'form.cnameelement'} ne '') {
1.103 raeburn 873: $name_code = <<ENDNAMECODE;
874: var showcdesc = cdesc;
875: if (cdesc.length > 25) {
876: showcdesc = cdesc.substr(0,25)+' ...';
877: }
878: opener.document.$env{'form.form'}.$env{'form.cnameelement'}.value=showcdesc;
879: ENDNAMECODE
1.55 raeburn 880: }
1.90 raeburn 881: if ($env{'form.typeelement'} ne '') {
882: $type_code = 'opener.document.'.$env{'form.form'}.'.'.
883: $env{'form.typeelement'}.'.value=document.courselist.type;';
884: }
885:
1.57 raeburn 886: $output .= qq|
1.55 raeburn 887: $name_code
1.90 raeburn 888: $type_code
1.55 raeburn 889: opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname;
890: var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
891: if (slct.options == undefined) {
892: opener.document.$env{'form.form'}.$env{'form.cdomelement'}.value=cdom;
893: }
894: else {
895: var i;
896: for (i=0;i<slct.length;i++) {
897: if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
1.54 raeburn 898: }
899: }
1.57 raeburn 900: |;
1.54 raeburn 901: }
1.57 raeburn 902: $output .= qq|
1.55 raeburn 903: if (openerForm == 'portform') {
904: document.courselist.cnum.value = cname;
905: document.courselist.cdom.value = cdom;
906: }
907: $autosubmit
908: $lastaction
1.54 raeburn 909: }
1.57 raeburn 910: |;
1.105 bisitz 911: return &Apache::lonhtmlcommon::scripttag($output);
1.54 raeburn 912: }
913:
1.55 raeburn 914: 1;
915: __END__
916:
917: =pod
918:
919: =head1 NAME
920:
921: Apache::lonpickcourse - Search for course(s) based on user-specified criteria.
922:
923: =head1 SYNOPSIS
924:
925: Invoked by other LON-CAPA modules, when course(s) need to be selected by the user.
926:
927: =head1 OVERVIEW
928:
929: Two screens are typically displayed to the user. The first is a set of criteria which are used to constrain the search for courses.
930:
931: =head2 Search Criteria (Screen One)
932:
933: =head3 Criteria:
934:
935: =over 4
936:
937: =item *
938: Course Activity - how recently was course last visited by anyone.
939:
940: =item *
941: Course Domain - the domain of the course
942:
943: =item *
1.117 raeburn 944: Type - Course, Community or Placement
1.55 raeburn 945:
946: =item *
947: Course Institutional Code - the institutional identifier assigned to the course
948:
949: =item *
950: Course Owner's Username - the username of the owner of the course (assigned by the Domain Coordinator and/or when the course was created).
951:
952: =item *
953: Course Owner's Domain - the domain of the owner of the course
954:
955: =item *
1.76 bisitz 956: Course Title - text which appears in the Course Title, as set in the Course Parameters.
1.55 raeburn 957:
958: =item *
959: Course ID - the internal course number (course ID part after initial 'domain_') used by LON-CAPA (this criterion is only displayed to Domain Coordinators selecting a course in the same domain as their DC role).
960:
961: =back
962:
963: The criteria setting screen is not displayed if course picking is done by a user who does not have advanced privileges (as defined by $env{'user.adv'}).
964:
965: =head2 Course Display (Screen Two)
966:
967: A list of courses matching the search criteria is displayed. If the user is not an advanced user, screen one will have been skipped and the courses displayed will be all courses in which the user has currently active roles. The information displayed for each course is:
968:
969: =over 4
970:
971: =item *
972: Course description
973:
974: =item *
975: Domain description of course domain
976:
977: =item *
978: Course institutional code
979:
980: =item *
981: Course owner (username:domain)
982:
983: =back
984:
985: Depending on context, the display may include a single select box for each course, allowing selection of only a single course, or may include checkboxes allowing selection of more than one course.
986:
987: Following selection, and/or submission, the course description, number and domain are transferred to the browser window from which the course picker window was opened. In most cases, the child window containing the course picker screens will be closed. However, in some cases closure will be delayed until a third screen has been displayed (e.g., setting of course-based conditional access controls for portfolio files). In this case the page is generated via /adm/portfolio and the page features select boxes to allow the user to select roles, access types, sections and groups.
988:
989: =head1 SUBROUTINES
990:
991: =over 4
992:
993: =item *
994: X<create_user_javascript()>
995: B<create_user_javascript($type)>:
996:
1.117 raeburn 997: Input: 1 - $type - the course type - Course, Community, or Placement
1.55 raeburn 998:
999: Output: 1 - $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
1000:
1001: Side Effects: None
1002:
1003: javascript code for reporting selected sections (as a string of comma separated sections) and groups in the selected course (as a comma separated list) then calling setSect() javscript function in the opener window (to populate section select box) then closing current window.
1004:
1005:
1006: =item *
1007: X<display_matched_courses()>
1.116 raeburn 1008: B<display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,$crsdom,$crscode,%courses)>:
1.55 raeburn 1009:
1.116 raeburn 1010: Input: 8 - request object, course type, multiple (0 or 1), form action, whether to show roles (for course personnel filter), username of new course owner, domain of new course owner, domain of new course, institutional code of new course, hash of courses.
1.55 raeburn 1011:
1012: Output: 0
1013:
1014: Side Effects: prints select buttons (multiple = 0) or checkboxes (multiple = 1) and hidden form elements for selection of one or more courses which met search criteria.
1015:
1016: =item *
1017: X<multiples_tag()>
1018: B<multiples_tag()>:
1019:
1020:
1021: Input: 0
1022:
1023: Output: 2 - $jscript - javascript for check all/uncheck all checkboxes; $multelement - hidden form element with multiple set to 1.
1024:
1025: Side Effects: None
1026:
1027:
1028: =item *
1029: X<course_chooser()>
1.85 raeburn 1030: B<course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone)>:
1.55 raeburn 1031:
1.85 raeburn 1032: Input: 5 - single (0) or multiple (1) courses; course domain, course number; course description; can clone course (1 if new course owner has cloning rights).
1.55 raeburn 1033:
1.85 raeburn 1034: Output: 1 - HTML for either checkbox (multiple=1) or select button (multiple=0) for user to indicate course selection.
1.55 raeburn 1035:
1036: Side Effects: None
1037:
1038:
1039: =item *
1040: X<gochoose_javascript()>
1.57 raeburn 1041: B<gochoose_javascript($type,$multiple,$autosubmit,$lastaction)>:
1.55 raeburn 1042:
1.66 raeburn 1043: Input: 4 - course type; single (0) or multiple courses (1); in context of DC selecting a CC role in a course: javascript code from &processpick(); final action to take after user chooses course(s): either close window, or submit form for display of next page etc.
1.55 raeburn 1044:
1045: Output: 1 $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
1046:
1047: Side Effects: None
1048:
1049: javascript functions used when user selects a course(s). Different behavior depending on context:
1050:
1051: =back
1052:
1053: =over 8
1054:
1055: =item
1056:
1057: (a) Domain Coordinator using MAIL to select recipients of broadcast e-mail - && separated list of selected courses written to hidden form element in opener window. Child window closes.
1058:
1059: =item
1060:
1061: (b) Domain Coordinator choosing a course for adoption of a CC role from roles screen - write course identifying information to hidden form elements in opener window and automatically submit role selection form in opener window. Child window closes.
1062:
1063: =item
1064:
1065: (c) Domain Coordinator creating a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
1066:
1067: =item
1.54 raeburn 1068:
1.55 raeburn 1069: (d) User selecting a course for course-based conditional access control for a portfolio file - form is submitted, and new page is displayed for selection of roles, access types, sections and groups to be used in conditional ACL. New page is generated by /adm/portfolio.
1.54 raeburn 1070:
1.55 raeburn 1071: =item
1.54 raeburn 1072:
1.55 raeburn 1073: (e) Domain Coordinator assigning a role to a user - form is submitted, and new page does an onload call to a javascript function to (a) write lists of sections and groups to hidden elements in opener window, (b) call function in opener window to dynamically populate select box showing current sections.
1.54 raeburn 1074:
1.55 raeburn 1075: =item
1.54 raeburn 1076:
1.55 raeburn 1077: (f) Author modifying a rights entry in a .rights file - selected course number and domain are witten to visible form elements in opener window. Child window closes.
1.54 raeburn 1078:
1.55 raeburn 1079: =item
1.49 raeburn 1080:
1.102 bisitz 1081: (g) Bubblesheet Scanning Operator uploading a bubblesheet file to a course - course number is written to visible form element in opener window. Child window closes.
1.30 raeburn 1082:
1.84 raeburn 1083: =item
1084:
1085: (h) User requesting creation of a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
1086:
1.55 raeburn 1087: =back
1088:
1089: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>