File:
[LON-CAPA] /
loncom /
interface /
lonpickcourse.pm
Revision
1.127:
download - view:
text,
annotated -
select for diffs
Sat Apr 8 14:28:56 2017 UTC (7 years, 4 months ago) by
raeburn
Branches:
MAIN
CVS tags:
version_2_12_X,
version_2_11_X,
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
HEAD
- Hide role selection text used in modal window until needed.
1: # The LearningOnline Network
2: # Pick a course
3: #
4: # $Id: lonpickcourse.pm,v 1.127 2017/04/08 14:28:56 raeburn Exp $
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;
34: use Apache::lonhtmlcommon;
35: use Apache::loncoursedata;
36: use Apache::lonnet;
37: use Apache::lonlocal;
38: use Apache::longroup;
39: use LONCAPA qw(:DEFAULT :match);
40: use JSON::DWIW;
41:
42: sub handler {
43: my $r = shift;
44: if ($env{'form.context'} eq 'adhoc') {
45: &Apache::loncommon::content_type($r,'application/json');
46: $r->send_http_header;
47: my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($env{'form.cid'},1);
48: if ((ref($possroles) eq 'ARRAY') && (ref($description) eq 'HASH')) {
49: my $response = [];
50: if (@{$possroles}) {
51: foreach my $role (@{$possroles}) {
52: push(@{$response},
53: { name => $role,
54: desc => $description->{$role},
55: });
56: }
57: }
58: $r->print(JSON::DWIW->to_json({roles => $response}));
59: }
60: return OK;
61: }
62: &Apache::loncommon::content_type($r,'text/html');
63: $r->send_http_header;
64: return OK if $r->header_only;
65:
66: # ------------------------------------------------------------ Print the screen
67:
68: # Get parameters from query string
69: &Apache::loncommon::get_unprocessed_cgi
70: ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement',
71: 'cdomelement','cnameelement','roleelement',
72: 'multiple','type','setroles','fixeddom','cloner',
73: 'crscode','crsdom']);
74: my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement,
75: $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom,$crscode,
76: $crsdom,$rolechooser);
77:
78: # Get course type - Course, Community or Placement.
79: $type = $env{'form.type'};
80: if (!defined($env{'form.type'})) {
81: $type = 'Course';
82: }
83: $title = 'Selecting a '.$type;
84:
85: # Setup for multiple course selections, if flag for multiples set.
86: $multiple = $env{'form.multiple'};
87: if ($multiple) {
88: ($jscript,$multelement) = &multiples_tag();
89: $title = 'Selecting '.$type.'(s)';
90: }
91:
92: # if called when a DC, DH or DA is selecting a course
93: my ($roledom,$rolename) = split(/:/,$env{'form.roleelement'});
94: if ($roledom) {
95: $roleelement = '<input type="hidden" name="roleelement" value="'.$env{'form.roleelement'}.'" />';
96: $submitopener = &processpick();
97: $autosubmit = 'process_pick("'.$roledom.'","'.$rolename.'")';
98: if (($rolename eq 'dh') || ($rolename eq 'da')) {
99: my %lt = &Apache::lonlocal::texthash(
100: title => 'Ad hoc role selection',
101: preamble => 'Please choose an ad hoc role in the course.',
102: cancel => 'Click "OK" to enter the course, or "Cancel" to choose a different course.',
103: );
104:
105: $rolechooser = <<"END";
106: <div id="LC_adhocrole_chooser" title="$lt{'title'}" style="display:none">
107: <p>$lt{'preamble'}</p>
108: <form name="LChelpdeskadhoc" id="LChelpdeskpicker" action="">
109: <div id="LC_choose_adhoc">
110: </div>
111: <input type="submit" tabindex="-1" style="position:absolute; top:-1000px" />
112: </form>
113: <p>$lt{'cancel'}</p>
114: </div>
115: END
116: }
117: }
118: if ($env{'form.typeelement'} ne '') {
119: $typeelement = '<input type="hidden" name="typeelement" value="'.$env{'form.typeelement'}.'" />';
120: }
121:
122: # if called when a DC is creating a course for another user.
123: if ($env{'form.form'} eq 'ccrs') {
124: ($cloneruname,$clonerudom) = ($env{'form.cloner'} =~ /^($match_username):($match_domain)$/);
125: $crscode = $env{'form.crscode'};
126: $crsdom = $env{'request.role.domain'};
127: }
128:
129: # if called when requesting a course
130: if ($env{'form.form'} eq 'requestcrs') {
131: $cloneruname = $env{'user.name'};
132: $clonerudom = $env{'user.domain'};
133: $crscode = $env{'form.crscode'};
134: $crsdom = $env{'form.crsdom'};
135: }
136:
137: my $onlyown = 0;
138: # if called to assign course-based portfolio access control
139: if ((($env{'form.form'} eq 'portform') && (!$env{'user.adv'}))) {
140: $onlyown = 1;
141: }
142:
143: my %loaditem;
144: if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) {
145: if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) {
146: $loaditem{'onload'} = 'setElements(document.filterpicker); ';
147: }
148: }
149:
150: if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) &&
151: ($env{'form.pickedcourse'})) {
152: if ($type ne 'Community') {
153: my %coursedescription =
154: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},
155: {'one_time' => '1'});
156: my $cdom = $coursedescription{'domain'};
157: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
158: if (($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'})) {
159: $loaditem{'onload'} .= 'setDefaultCredits();';
160: }
161: }
162: $loaditem{'onload'} .= 'setRoles();setSections();';
163: }
164: if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) && (!$onlyown)) {
165: $loaditem{'onload'} .= 'hideSearching(); ';
166: }
167: my $js = &Apache::loncommon::js_changer();
168: $r->print(&Apache::loncommon::start_page($title,$js,
169: {'add_entries' => \%loaditem,
170: 'no_nav_bar' => 1, }));
171:
172: if ($env{'form.form'} eq 'portform') {
173: $lastaction = 'document.courselist.submit()';
174: } elsif ($env{'form.form'} eq 'cu' || ($env{'form.form'} eq 'studentform' &&
175: !$multiple)) {
176: $lastaction =
177: 'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n".
178: 'document.courselist.submit();';
179: } else {
180: $lastaction = 'self.close()';
181: }
182:
183: # if called to assign a role in a course to a user via CUSR
184: if ($env{'form.form'} eq 'cu' || $env{'form.form'} eq 'studentform') {
185: $r->print(&create_user_javascript($type));
186: }
187:
188: # print javascript functions for choosing a course
189: if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) ||
190: $onlyown) {
191: $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction,
192: $rolename,$rolechooser));
193: }
194: $r->print(&Apache::lonhtmlcommon::scripttag($jscript));
195: $r->print($submitopener);
196:
197: # ------------------------------------------ Display of filters to limit search
198: my $filter = {};
199: my $action = '/adm/pickcourse';
200: my ($numtitles,$showroles,$nohost,@codetitles);
201: unless ($onlyown) {
202: my $filterlist = ['domainfilter','sincefilter'];
203: # created filter for DCs only
204: if ($env{'user.adv'} && $env{'form.domainfilter'} &&
205: exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})
206: && $env{'form.form'} ne 'portform') {
207: my $loncaparev = &Apache::lonnet::get_server_loncaparev($env{'form.domainfilter'});
208: if ($loncaparev ne 'unknown_cmd') {
209: push(@{$filterlist},'createdfilter');
210: }
211: }
212: push(@{$filterlist},('descriptfilter','instcodefilter'));
213: if ($env{'form.form'} eq 'rules') {
214: push(@{$filterlist},('personfilter','persondomfilter'));
215: if ($env{'form.persondomfilter'} eq '') {
216: unless ($env{'form.gosearch'}) {
217: $filter->{'persondomfilter'} = $env{'request.role.domain'};
218: }
219: } else {
220: $filter->{'persondomfilter'} =
221: &LONCAPA::clean_domain($env{'form.persondomfilter'});
222: }
223: if (($env{'form.personfilter'} ne '') && ($env{'form.persondomfilter'} ne '')) {
224: if (&Apache::lonnet::homeserver($env{'form.personfilter'},
225: $env{'form.persondomfilter'}) eq 'no_host') {
226: $nohost = 1;
227: } else {
228: $showroles = 1;
229: }
230: }
231: } else {
232: push(@{$filterlist},('ownerfilter','ownerdomfilter'));
233: }
234: # course ID filter for DCs only
235: if ($env{'user.adv'} && $env{'form.domainfilter'} &&
236: exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})) {
237: push(@{$filterlist},'coursefilter');
238: }
239: if ($cloneruname ne '' && $clonerudom ne '') {
240: push(@{$filterlist},'cloneableonly');
241: }
242: if ((ref($filterlist) eq 'ARRAY') && (ref($filter) eq 'HASH')) {
243: foreach my $item (@{$filterlist}) {
244: $filter->{$item} = $env{'form.'.$item};
245: }
246: }
247: if ($env{'form.form'} eq 'portform') {
248: $filter->{'domainfilter'} ||= $env{'user.domain'};
249: } elsif ($env{'form.form'} eq 'studentform') {
250: $filter->{'domainfilter'} ||= $env{'request.role.domain'};
251: }
252: my $codedom;
253: if ($env{'form.fixeddom'}) {
254: $codedom = $env{'request.role.domain'};
255: } else {
256: $codedom = $filter->{'domainfilter'};
257: }
258: my ($clonetext,$clonewarning);
259: if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
260: (my $coord_cloneable,$clonewarning) =
261: &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
262: if ($env{'form.form'} eq 'ccrs') {
263: $clonetext = '<input type="hidden" name="cloner" value="'.$env{'form.cloner'}.'" />'."\n";
264: }
265: if ($coord_cloneable) {
266: $clonetext .= '<input type="hidden" name="cc_clone" value="'.$coord_cloneable.'" />';
267: }
268: if ($crscode ne '') {
269: $clonetext .= '<input type="hidden" name="crscode" value="'.$crscode.'" />';
270: }
271: if ($crsdom ne '') {
272: $clonetext .= '<input type="hidden" name="crsdom" value="'.$crsdom.'" />';
273: }
274: }
275: $r->print(&Apache::loncommon::build_filters($filterlist,$type,$roleelement,$multelement,
276: $filter,$action,\$numtitles,undef,$cloneruname,
277: $clonerudom,$typeelement,\@codetitles,$codedom,
278: $env{'form.form'},$env{'form.fixeddom'},
279: $env{'form.prevphase'},$env{'form.cnameelement'},
280: $env{'form.cnumelement'},$env{'form.cdomelement'},
281: $env{'form.setroles'},$clonetext,$clonewarning));
282: }
283:
284: # ---------------------------------------------------------------- Get the data
285: if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) ||
286: $onlyown) {
287: my $domcloner;
288: if ($env{'form.form'} eq 'ccrs') {
289: if (($env{'request.role.domain'} eq $env{'form.domainfilter'}) &&
290: (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
291: $domcloner = 1;
292: }
293: }
294: my %courses;
295: if (!$onlyown) {
296: $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
297: $r->rflush();
298: my $srchdom = $filter->{'domainfilter'};
299: %courses = &Apache::loncommon::search_courses($srchdom,$type,$filter,$numtitles,
300: $cloneruname,$clonerudom,$domcloner,
301: \@codetitles,$env{'form.cc_clone'},
302: $crsdom,$crscode);
303: } else {
304: $r->print('<br />');
305: my %coursehash = &Apache::loncommon::findallcourses();
306: foreach my $cid (sort(keys(%coursehash))) {
307: $courses{$cid}{'description'} = $env{'course.'.$cid.'.description'};
308: }
309: }
310: if ($nohost) {
311: $r->print ('<span class="LC_warning">'.
312: &mt('User does not exist - username: [_1], domain: [_2].',
313: '<b>'.$filter->{'personfilter'}.'</b>',
314: '<b>'.$filter->{'persondomfilter'}.'</b>').'</span>');
315: } else {
316: &display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,
317: $clonerudom,$crsdom,$crscode,%courses);
318: }
319: }
320: $r->print(&Apache::loncommon::end_page());
321: return OK;
322: }
323:
324: sub processpick {
325: my $openerform = 'rolechoice';
326: if ($env{'form.form'} eq 'studentform') {
327: $openerform = $env{'form.form'};
328: }
329: my $process_pick = <<"ENDONE";
330: <script type="text/javascript">
331: function process_pick(dom,rolename) {
332: var pickedCourse=opener.document.$openerform.$env{'form.cnumelement'}.value;
333: var pickedDomain=opener.document.$openerform.$env{'form.cdomelement'}.value;
334: var okDomain = 0;
335: ENDONE
336: if ($openerform eq 'rolechoice') {
337: $process_pick .= <<"ENDTWO";
338: if (pickedDomain == dom) {
339: if (pickedCourse != '') {
340: var courseTarget;
341: if (rolename == 'cc') {
342: var ccrole = "cc";
343: var pickedType = "$env{'form.type'}";
344: if (pickedType == "Community") {
345: ccrole = "co";
346: }
347: courseTarget = ccrole+"./"+pickedDomain+"/"+pickedCourse;
348: } else {
349: if (!/\\W/.test(rolename)) {
350: courseTarget = "cr/"+pickedDomain+"/"+pickedDomain+"-domainconfig/"+rolename+"./"+pickedDomain+"/"+pickedCourse;
351: }
352: }
353: if ((courseTarget != '') && (courseTarget != undefined)) {
354: opener.document.title='Role selected. Please stand by.';
355: opener.status='Role selected. Please stand by.';
356: opener.document.rolechoice.newrole.value=courseTarget;
357: opener.document.rolechoice.submit();
358: } else {
359: alert("Invalid role selection");
360: return;
361: }
362: }
363: }
364: else {
365: 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");
366: }
367: ENDTWO
368: } else {
369: $process_pick .= <<"ENDTHREE";
370: if (pickedDomain != dom) {
371: 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");
372: return;
373: }
374: ENDTHREE
375: }
376: $process_pick .= "
377: }
378:
379: </script>
380: ";
381: return $process_pick;
382: }
383:
384: sub create_user_javascript {
385: my ($type) = @_;
386: my $output;
387: #javascript for reporting sections and groups then closing
388: if ($env{'form.pickedcourse'}) {
389: my %coursedescription =
390: &Apache::lonnet::coursedescription($env{'form.pickedcourse'},
391: {'one_time' => '1'});
392: my $cdom = $coursedescription{'domain'};
393: my $cnum = $coursedescription{'num'};
394: my $crstype = $coursedescription{'type'};
395: my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
396: my ($showcredits,$credits);
397: if (($crstype ne 'Community') &&
398: (($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'}))) {
399: $showcredits = 1;
400: $credits = $coursedescription{'internal.defaultcredits'};
401: }
402: my $sec_element = 'currsec';
403: my $grplist_element = 'groups';
404: my ($sections,$groups) =
405: &Apache::loncommon::get_secgrprole_info($cdom,$cnum,'',$type);
406: my $num_sections = scalar(@{$sections});
407: my $seclist = join(',',@{$sections});
408: my $num_groups = scalar(@{$groups});
409: my $groupslist = join(',',@{$groups});
410: $output = qq|
411: <script type="text/javascript">
412: // <![CDATA[
413: function setSections() {
414: opener.document.$env{"form.form"}.$grplist_element.value='$groupslist';
415: window.opener.setSect('$seclist');
416: self.close();
417: }
418: function setRoles() {
419: window.opener.setRole('$crstype');
420: }
421: |;
422: if ($showcredits) {
423: $output .= qq|
424: function setDefaultCredits() {
425: window.opener.setCredits('$credits');
426: }
427: |;
428: }
429: $output .= qq|
430: // ]]>
431: </script>
432: |;
433: }
434: return $output;
435: }
436:
437: sub display_matched_courses {
438: my ($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,$crsdom,$crscode,%courses) = @_;
439: if ($env{'form.form'} eq 'portform') {
440: $action = '/adm/portfolio';
441: }
442: my $numcourses = keys(%courses);
443: $r->print('<form name="courselist" method="post" action="'.$action.'" id="LCcoursepicker">');
444: if ($env{'form.form'} eq 'modifycourse') {
445: if ($numcourses > 0) {
446: my $ccrole = 'cc';
447: if ($type eq 'Community') {
448: $ccrole = 'co';
449: }
450: my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
451: my $dctitle = &Apache::lonnet::plaintext('dc');
452: my $ccrolechk = ' ';
453: my $possrole;
454: my $menuchk = ' checked="checked" ';
455: $r->print(
456: '<div class="LC_left_float">'
457: .'<fieldset>'
458: .'<legend>'.&mt('Pick action').'</legend>');
459: my $roleradio = '<span class="LC_nobreak"><label>'.
460: '<input type="radio" name="phase" value="adhocrole"'.$ccrolechk.'/>'.' ';
461: if (&Apache::lonnet::allowed('ccc',$crsdom)) {
462: $possrole = 1;
463: $r->print($roleradio);
464: if ($type eq 'Community') {
465: $r->print(&mt('Enter the community with the role of [_1].',$cctitle));
466: } elsif ($type eq 'Placement') {
467: $r->print(&mt('Enter the placement test with the role of [_1].',$cctitle));
468: } else {
469: $r->print(&mt('Enter the course with the role of [_1].',$cctitle));
470: }
471: } elsif (&Apache::lonnet::allowed('rar',$crsdom)) {
472: my ($roles_by_num,$description,$accessref,$accessinfo) = &Apache::lonnet::get_all_adhocroles($crsdom);
473: if ((ref($roles_by_num) eq 'ARRAY') && (ref($description) eq 'HASH')) {
474: if (@{$roles_by_num} > 1) {
475: $r->print($roleradio);
476: if ($type eq 'Community') {
477: $r->print(&mt('Enter the community with one of the available ad hoc roles.'));
478: } elsif ($type eq 'Placement') {
479: $r->print(&mt('Enter the placement test with one of the available ad hoc roles.'));
480: } else {
481: $r->print(&mt('Enter the course with one of the available ad hoc roles.'));
482: }
483: $possrole = 1;
484: } elsif (@{$roles_by_num} == 1) {
485: $r->print($roleradio);
486: my $rolename = $description->{$roles_by_num->[0]};
487: if ($type eq 'Community') {
488: $r->print(&mt('Enter the community with the ad hoc role of: [_1]',$rolename));
489: } elsif ($type eq 'Placement') {
490: $r->print(&mt('Enter the placement test with the ad hoc role of: [_1]',$rolename));
491: } else {
492: $r->print(&mt('Enter the course with the ad hoc role of: [_1]',$rolename));
493: }
494: $possrole = 1;
495: }
496: if ($possrole) {
497: $r->print('<input type="hidden" name="adhocrole" value="" />');
498: }
499: }
500: }
501: if ($possrole) {
502: $r->print('</label></span><br />');
503: }
504: $r->print('<span class="LC_nobreak"><label>'
505: .'<input type="radio" name="phase" value="menu"'.$menuchk.'/> ');
506: if (&Apache::lonnet::allowed('ccc',$crsdom)) {
507: if ($type eq 'Community') {
508: $r->print(&mt('View or modify community settings which only a [_1] may modify.',$dctitle));
509: } elsif ($type eq 'Placement') {
510: $r->print(&mt('View or modify placement test settings which only a [_1] may modify.',$dctitle));
511: } else {
512: $r->print(&mt('View or modify course settings which only a [_1] may modify.',$dctitle));
513: }
514: } elsif (&Apache::lonnet::allowed('rar',$crsdom)) {
515: if ($type eq 'Community') {
516: $r->print(&mt('View community settings which only a [_1] may modify.',$dctitle));
517: } elsif ($type eq 'Placement') {
518: $r->print(&mt('View placement test settings which only a [_1] may modify.',$dctitle));
519: } else {
520: $r->print(&mt('View course settings which only a [_1] may modify.',$dctitle));
521: }
522: }
523: $r->print('</label></span>'
524: .'</fieldset></div>'
525: .'<br clear="all" />'
526: );
527: }
528: }
529: my %by_descrip;
530: foreach my $course (keys(%courses)) {
531: my $descr;
532: if (ref($courses{$course}) eq 'HASH') {
533: $descr = $courses{$course}{'description'};
534: } elsif ($courses{$course} =~ m/^([^:]*):/i) {
535: $descr = &unescape($1);
536: } else {
537: $descr = &unescape($courses{$course});
538: }
539: my $description = $descr;
540: push (@{$by_descrip{$description}}, $course);
541: }
542:
543: if ($numcourses > 1 && $multiple) {
544: $r->print('<input type="button" value="'.&mt('check all').'"
545: onclick="javascript:checkAll(document.courselist.course_id)" />
546: <input type="button" value="'.&mt('uncheck all').'"
547: onclick="javascript:uncheckAll(document.courselist.course_id)" />
548: <br /><br />');
549: }
550:
551: if (%courses) {
552: $r->print(&Apache::loncommon::start_data_table());
553: $r->print(&Apache::loncommon::start_data_table_header_row());
554: my $titlehdr = &mt('Course Title');
555: if ($type eq 'Community') {
556: $titlehdr = &mt('Community Title');
557: }
558: $r->print('<th>'.&mt('Select').'</th>'
559: .'<th>'.$titlehdr.'</th>'
560: .'<th>'.&mt('Domain').'</th>');
561: unless (($type eq 'Community') || ($type eq 'Placement')) {
562: $r->print('<th>'.&mt('Course Code').'</th>');
563: }
564: $r->print('<th>'.&mt('Owner/Co-owner(s)').'</th>');
565: if ($showroles) {
566: $r->print('<th>'.&mt("Role(s) for [_1]",
567: &Apache::loncommon::plainname($env{'form.personfilter'},
568: $env{'form.persondomfilter'},'firstname')).'</th>');
569: }
570: $r->print(&Apache::loncommon::end_data_table_header_row());
571: }
572: my %cc_cloneable;
573: if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
574: my ($coord_cloneable,$warning) =
575: &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
576: if ($coord_cloneable) {
577: map {$cc_cloneable{$_} = 1;} split('&',$coord_cloneable);
578: }
579: }
580: my (%gotdomdefaults,%gotcodedefaults);
581: foreach my $description (sort { lc($a) cmp lc($b) } (keys(%by_descrip))) {
582: foreach my $course (@{$by_descrip{$description}}) {
583: $r->print(&Apache::loncommon::start_data_table_row());
584: my $cleandesc=&HTML::Entities::encode($description,'<>&"');
585: $cleandesc=~s/'/\\'/g;
586: my ($cdom,$cnum)=split(/\_/,$course);
587: my ($descr,$instcode,$ttype,$canclone,@owners);
588: if (ref($courses{$course}) eq 'HASH') {
589: $descr = $courses{$course}{'description'};
590: $instcode = $courses{$course}{'inst_code'};
591: $ttype = $courses{$course}{'type'};
592: if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
593: if ($env{'form.form'} eq 'ccrs') {
594: if (($env{'request.role.domain'} eq $cdom) &&
595: (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
596: $canclone = 1;
597: }
598: }
599: unless ($canclone) {
600: if ($cc_cloneable{$cnum.':'.$cdom}) {
601: $canclone = 1;
602: }
603: }
604: unless ($canclone) {
605: my $cloners = $courses{$course}{'cloners'};
606: if ($cloners ne '') {
607: my @cloneable = split(',',$cloners);
608: if (grep(/^\*$/,@cloneable)) {
609: $canclone = 1;
610: }
611: if (grep(/^\*:\Q$clonerudom\E$/,@cloneable)) {
612: $canclone = 1;
613: }
614: if (grep(/^\Q$cloneruname\E:\Q$clonerudom\E$/,@cloneable)) {
615: $canclone = 1;
616: }
617: unless ($canclone) {
618: if (($instcode) && ($crscode) && ($cdom eq $crsdom)) {
619: foreach my $cloner (@cloneable) {
620: if (($cloner ne '*') && ($cloner !~ /^\*\:$match_domain$/) &&
621: ($cloner !~ /^$match_username\:$match_domain$/) && ($cloner ne '')) {
622: if ($cloner =~ /\=/) {
623: my (%codedefaults,@code_order);
624: if (ref($gotcodedefaults{$cdom}) eq 'HASH') {
625: if (ref($gotcodedefaults{$cdom}{'defaults'}) eq 'HASH') {
626: %codedefaults = %{$gotcodedefaults{$cdom}{'defaults'}};
627: }
628: if (ref($gotcodedefaults{$cdom}{'order'}) eq 'ARRAY') {
629: @code_order = @{$gotcodedefaults{$cdom}{'order'}};
630: }
631: } else {
632: &Apache::lonnet::auto_instcode_defaults($cdom,
633: \%codedefaults,
634: \@code_order);
635: $gotcodedefaults{$cdom}{'defaults'} = \%codedefaults;
636: $gotcodedefaults{$cdom}{'order'} = \@code_order;
637: }
638: if (@code_order > 0) {
639: if (&Apache::lonnet::check_instcode_cloning(\%codedefaults,\@code_order,
640: $cloner,$instcode,$crscode)) {
641: $canclone = 1;
642: last;
643: }
644: }
645: }
646: }
647: }
648: }
649: }
650: } else {
651: my %domdefs;
652: if (ref($gotdomdefaults{$cdom}) eq 'HASH') {
653: %domdefs = %{$gotdomdefaults{$cdom}};
654: } else {
655: %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
656: $gotdomdefaults{$cdom} = \%domdefs;
657: }
658: if ($domdefs{'canclone'}) {
659: unless ($domdefs{'canclone'} eq 'none') {
660: if ($domdefs{'canclone'} eq 'domain') {
661: if ($clonerudom eq $cdom) {
662: $canclone = 1;
663: }
664: } elsif (($instcode) && ($crscode) &&
665: ($cdom eq $crsdom)) {
666: my (%codedefaults,@code_order);
667: if (ref($gotcodedefaults{$cdom}) eq 'HASH') {
668: if (ref($gotcodedefaults{$cdom}{'defaults'}) eq 'HASH') {
669: %codedefaults = %{$gotcodedefaults{$cdom}{'defaults'}};
670: }
671: if (ref($gotcodedefaults{$cdom}{'order'}) eq 'ARRAY') {
672: @code_order = @{$gotcodedefaults{$cdom}{'order'}};
673: }
674: } else {
675: &Apache::lonnet::auto_instcode_defaults($cdom,
676: \%codedefaults,
677: \@code_order);
678: $gotcodedefaults{$cdom}{'defaults'} = \%codedefaults;
679: $gotcodedefaults{$cdom}{'order'} = \@code_order;
680: }
681: if (@code_order > 0) {
682: if (&Apache::lonnet::default_instcode_cloning($cdom,$domdefs{'canclone'},
683: $instcode,$crscode,\%codedefaults,
684: \@code_order)) {
685: $canclone = 1;
686: }
687: }
688: }
689: }
690: }
691: }
692: }
693: }
694: push(@owners,$courses{$course}{'owner'});
695: if ($courses{$course}{'co-owners'} ne '') {
696: foreach my $item (split(/,/,$courses{$course}{'co-owners'})) {
697: push(@owners,$item);
698: }
699: }
700: } else {
701: my $singleowner;
702: ($descr,$instcode,$singleowner,$ttype)=split(/:/,$courses{$course});
703: push(@owners,&unescape($singleowner));
704: }
705: my $ownerstr = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } @owners);
706: $r->print('<td>'.&course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone).'</td>');
707: $r->print('<td>'.$description.'</td>');
708: $r->print('<td>');
709: $r->print(&Apache::lonnet::domain($cdom,'description')?
710: $cdom.' ('.&Apache::lonnet::domain($cdom,'description').')':$cdom);
711: $r->print('</td>');
712: unless (($type eq 'Community') || ($type eq 'Placement')) {
713: $r->print('<td>');
714: if ($instcode ne '') {
715: $r->print(&unescape($instcode));
716: } else {
717: $r->print(' ');
718: }
719: $r->print('</td>');
720: }
721: $r->print('<td>'.$ownerstr.'</td>');
722: if ($showroles) {
723: $r->print('<td>');
724: my $rolestr;
725: if (ref($courses{$course}{'roles'}) eq 'ARRAY') {
726: my @roles = sort(@{$courses{$course}{'roles'}});
727: foreach my $role (@roles) {
728: if ($role =~ /^cr/) {
729: my (undef,$crdom,$crname,$crtitle) = split('/',$role);
730: $rolestr .= $crtitle.', ';
731: } else {
732: $rolestr .= &Apache::lonnet::plaintext($role,$type).', ';
733: }
734: }
735: $rolestr =~ s/\, $//;
736: }
737: $r->print($rolestr.'</td>');
738: }
739: if ($multiple) { $r->print("</label>\n"); }
740: $r->print(&Apache::loncommon::end_data_table_row());
741: # $r->print("<br />\n");
742: }
743: }
744: if (%courses) {
745: $r->print(&Apache::loncommon::end_data_table());
746: }
747:
748: if (!%courses) {
749: $r->print('<p class="LC_info">'.&mt('None found').'</p>');
750: } elsif ($multiple) {
751: $r->print('<input type="button" value="'.&mt('Submit').'" onclick="gochoose('."'','','')".'" />');
752: }
753: $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'.
754: "\n".'<input type="hidden" name="pickedcourse" value="" />'."\n".
755: '<input type="hidden" name="type" value="'.$type.'" />'."\n");
756: if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) {
757: $r->print('<input type="hidden" name="roleelement" value="'.
758: $env{'form.roleelement'}.'" />'."\n");
759: }
760: if ($env{'form.form'} eq 'portform') {
761: $r->print('<input type="hidden" name="cnum" value="" />');
762: $r->print('<input type="hidden" name="cdom" value="" />');
763: $r->print('<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />');
764: $r->print('<input type="hidden" name="action" value="rolepicker" />');
765: } elsif ($env{'form.form'} eq 'modifycourse') {
766: $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state','adhocrole']));
767: } else {
768: $r->print('<input type="hidden" name="cnumelement" value="'.
769: $env{'form.cnumelement'}.'" />'."\n".
770: '<input type="hidden" name="cdomelement" value="'.
771: $env{'form.cdomelement'}.'" />'."\n");
772: if ($env{'form.typeelement'} ne '') {
773: $r->print('<input type="hidden" name="typeelement" value="'.
774: $env{'form.typeelement'}.'" />'."\n");
775:
776: }
777: }
778: if ((exists($env{'form.fixeddom'})) && ($env{'form.form'} eq 'rules')) {
779: $r->print('<input type="hidden" name="fixeddom" value="'.
780: $env{'form.fixeddom'}.'" />');
781: }
782: if ($env{'form.numtitles'}) {
783: $r->print('<input type="hidden" name="numtitles" value="'.
784: $env{'form.numtitles'}.'" />');
785: }
786: $r->print("</form>\n");
787: return;
788: }
789:
790: sub multiples_tag {
791: my $jscript = &Apache::loncommon::check_uncheck_jscript();
792: my $multelement = '<input type="hidden" name="multiple" value="1" />';
793: return ($jscript,$multelement);
794: }
795:
796: sub get_coordinator_cloneable {
797: my ($cloneruname,$clonerudom,$type) = @_;
798: if (($cloneruname!~/\w/) || ($clonerudom!~/\w/)) {
799: my $warning = '<div class="LC_warning">'.&mt('Intended course owner not specified').
800: '</div>';
801: return ('',$warning);
802: } elsif (&Apache::lonnet::homeserver($cloneruname,$clonerudom) eq 'no_host') {
803: my $warning = '<div class="LC_error">'.&mt('Intended course owner does not exist').
804: '</div>';
805: return ('',$warning);
806: } else {
807: my ($cc_clone,$ccrole);
808: if ($type eq 'Community') {
809: $ccrole = 'co';
810: } else {
811: $ccrole = 'cc';
812: }
813: my %ccroles = &Apache::lonnet::get_my_roles($cloneruname,$clonerudom,
814: 'userroles',['active'], [$ccrole]);
815: foreach my $key (sort(keys(%ccroles))) {
816: my ($cnum,$cdom,$role) = split(':',$key);
817: $cc_clone .= $cdom.':'.$cnum.'&';
818: }
819: $cc_clone =~ s/\&$//;
820: return ($cc_clone);
821: }
822: }
823:
824: sub course_chooser {
825: my ($multiple,$cdom,$cnum,$cleandesc,$canclone) = @_;
826: my $output;
827: if ($multiple) {
828: $output = '<label><input type="checkbox" name="course_id" value="'.$cdom.'_'.$cnum.'" />'."\n";
829: } elsif ((($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) && (!$canclone)) {
830: if ($env{'form.form'} eq 'ccrs') {
831: $output = &mt('No cloning for [_1]',$env{'form.cloner'})."\n";
832: } else {
833: $output = &mt('No rights to clone')."\n";
834: }
835: } else {
836: $output = '<input type="button" value="'.&mt('Select').'" onclick="gochoose('.
837: "'".$cnum."','".$cdom."','".$cleandesc."')".'" />'."\n";
838: }
839: return $output;
840: }
841:
842: sub gochoose_javascript {
843: my ($type,$multiple,$autosubmit,$lastaction,$rolename,$rolechooser) = @_;
844: my %elements = (
845: 'Course' => {
846: name => 'coursepick',
847: total => 'coursetotal',
848: list => 'courselist',
849: },
850: 'Community' => {
851: name => 'coursepick',
852: total => 'coursetotal',
853: list => 'courselist',
854: },
855: 'Placement' => {
856: name => 'coursepick',
857: total => 'coursetotal',
858: list => 'courselist',
859: },
860: );
861:
862: my %lt = &Apache::lonlocal::texthash (
863: none => 'You are not eligible to use an ad hoc role for the selected course',
864: ok => 'OK',
865: exit => 'Cancel',
866: );
867: &js_escape(\%lt);
868:
869: my $output;
870: if ($rolechooser) {
871: $output .= qq|
872: \$(document).ready(function(){
873: \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
874: });
875: |;
876: }
877: $output .= qq|
878: function gochoose(cname,cdom,cdesc) {
879: var openerForm = "$env{'form.form'}";
880: var openerRole = "$rolename";
881: courseCount = 0;
882: var courses = '';
883: |;
884: if ($multiple) {
885: $output .= <<"ENDSCRIPT";
886: courseCount = 0;
887: var courses = '';
888: if (typeof(document.courselist.course_id.length) == 'undefined') {
889: // only 1 course checkbox was created
890: if (document.courselist.course_id.checked) {
891: courses = courses + document.courselist.course_id.value + "&&";
892: courseCount ++;
893: }
894: } else {
895: for (var j=0; j<document.courselist.course_id.length; j++) {
896: if (document.courselist.course_id[j].checked) {
897: courses = courses + document.courselist.course_id[j].value + "&&";
898: courseCount ++;
899: }
900: }
901: }
902: opener.document.$env{'form.form'}.$elements{$type}{'total'}.value = courseCount;
903: if (typeof(opener.document.$env{'form.form'}.$elements{$type}{'name'}.length) ==
904: 'undefined') {
905: if (opener.document.$env{'form.form'}.$elements{$type}{'name'}.value == 'specific') {
906: opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = true;
907: } else {
908: opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = false;
909: }
910: } else {
911: for (var j=0; j<opener.document.$env{'form.form'}.$elements{$type}{'name'}.length; j++) {
912: if (opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].value == 'specific') {
913: opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = true;
914: } else {
915: opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = false;
916: }
917: }
918: }
919: if (courseCount > 0) {
920: courses = courses.substr(0,courses.length-2);
921: opener.document.$env{'form.form'}.$elements{$type}{'list'}.value = courses;
922: }
923: ENDSCRIPT
924: } else {
925: my ($name_code,$type_code);
926: if ($env{'form.cnameelement'} ne '') {
927: $name_code = <<ENDNAMECODE;
928: var showcdesc = cdesc;
929: if (cdesc.length > 25) {
930: showcdesc = cdesc.substr(0,25)+' ...';
931: }
932: opener.document.$env{'form.form'}.$env{'form.cnameelement'}.value=showcdesc;
933: ENDNAMECODE
934: }
935: if ($env{'form.typeelement'} ne '') {
936: $type_code = 'opener.document.'.$env{'form.form'}.'.'.
937: $env{'form.typeelement'}.'.value=document.courselist.type;';
938: }
939:
940: $output .= qq|
941: $name_code
942: $type_code
943: opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname;
944: var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
945: if (slct.options == undefined) {
946: opener.document.$env{'form.form'}.$env{'form.cdomelement'}.value=cdom;
947: }
948: else {
949: var i;
950: for (i=0;i<slct.length;i++) {
951: if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
952: }
953: }
954: |;
955: }
956: $output .= <<ENDJS;
957: if (openerForm == 'portform') {
958: document.courselist.cnum.value = cname;
959: document.courselist.cdom.value = cdom;
960: }
961: if ((openerForm == 'rolechoice') && ((openerRole == 'dh') || (openerRole == 'da'))) {
962: \$("#LC_choose_adhoc").empty();
963: var http = new XMLHttpRequest();
964: var url = "/adm/pickcourse";
965: var params = "cid="+cdom+"_"+cname+"&context=adhoc";
966: http.open("POST", url, true);
967: http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
968: http.onreadystatechange = function() {
969: if(http.readyState == 4 && http.status == 200) {
970: var data = \$.parseJSON(http.responseText);
971: var len = data.roles.length;
972: if (len == '' || len == null || len == 0) {
973: alert('$lt{none}');
974: } else {
975: if (len == 1) {
976: process_pick(cdom,data.roles[0].name);
977: $lastaction;
978: } else {
979: var str = '';
980: \$("#LC_choose_adhoc").empty();
981: for (var i=0; i<data.roles.length; i++) {
982: \$("<label><input type='radio' value='"+data.roles[i].name+"' name='LC_get_role' id='LC_get_role_"+i+"' />"+data.roles[i].desc+"</label><span> </span>")
983: .appendTo("#LC_choose_adhoc");
984: }
985: \$( "#LC_adhocrole_chooser" ).toggle( true );
986: \$( "#LC_get_role_0").prop("checked", true);
987: \$( "#LC_adhocrole_chooser" ).dialog({ autoOpen: false });
988: \$( "#LC_adhocrole_chooser" ).dialog("open");
989: \$( "#LC_adhocrole_chooser" ).dialog({
990: height: 400,
991: width: 500,
992: modal: true,
993: resizable: false,
994: buttons: [
995: {
996: text: "$lt{'ok'}",
997: click: function() {
998: var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val();
999: process_pick(cdom,rolename);
1000: \$("#LC_adhocrole_chooser").dialog( "close" );
1001: $lastaction;
1002: }
1003: },
1004: {
1005: text: "$lt{'exit'}",
1006: click: function() {
1007: \$("#LC_adhocrole_chooser").dialog( "close" );
1008: }
1009: }
1010: ],
1011: });
1012: \$( "#LC_adhocrole_chooser" ).find( "form" ).on( "submit", function( event ) {
1013: event.preventDefault();
1014: var rolename = \$('input[name=LC_get_role]:checked', '#LChelpdeskpicker').val()
1015: process_pick(cdom,rolename);
1016: \$("#LC_adhocrole_chooser").dialog( "close" );
1017: $lastaction;
1018: });
1019: }
1020: }
1021: }
1022: }
1023: http.send(params);
1024: } else {
1025: $autosubmit
1026: $lastaction
1027: }
1028: }
1029:
1030: ENDJS
1031: return $rolechooser.&Apache::lonhtmlcommon::scripttag($output);
1032: }
1033:
1034: 1;
1035: __END__
1036:
1037: =pod
1038:
1039: =head1 NAME
1040:
1041: Apache::lonpickcourse - Search for course(s) based on user-specified criteria.
1042:
1043: =head1 SYNOPSIS
1044:
1045: Invoked by other LON-CAPA modules, when course(s) need to be selected by the user.
1046:
1047: =head1 OVERVIEW
1048:
1049: Two screens are typically displayed to the user. The first is a set of criteria which are used to constrain the search for courses.
1050:
1051: =head2 Search Criteria (Screen One)
1052:
1053: =head3 Criteria:
1054:
1055: =over 4
1056:
1057: =item *
1058: Course Activity - how recently was course last visited by anyone.
1059:
1060: =item *
1061: Course Domain - the domain of the course
1062:
1063: =item *
1064: Type - Course, Community or Placement
1065:
1066: =item *
1067: Course Institutional Code - the institutional identifier assigned to the course
1068:
1069: =item *
1070: Course Owner's Username - the username of the owner of the course (assigned by the Domain Coordinator and/or when the course was created).
1071:
1072: =item *
1073: Course Owner's Domain - the domain of the owner of the course
1074:
1075: =item *
1076: Course Title - text which appears in the Course Title, as set in the Course Parameters.
1077:
1078: =item *
1079: 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).
1080:
1081: =back
1082:
1083: 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'}).
1084:
1085: =head2 Course Display (Screen Two)
1086:
1087: 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:
1088:
1089: =over 4
1090:
1091: =item *
1092: Course description
1093:
1094: =item *
1095: Domain description of course domain
1096:
1097: =item *
1098: Course institutional code
1099:
1100: =item *
1101: Course owner (username:domain)
1102:
1103: =back
1104:
1105: 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.
1106:
1107: 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.
1108:
1109: =head1 SUBROUTINES
1110:
1111: =over 4
1112:
1113: =item *
1114: X<create_user_javascript()>
1115: B<create_user_javascript($type)>:
1116:
1117: Input: 1 - $type - the course type - Course, Community, or Placement
1118:
1119: Output: 1 - $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
1120:
1121: Side Effects: None
1122:
1123: 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.
1124:
1125:
1126: =item *
1127: X<display_matched_courses()>
1128: B<display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,$crsdom,$crscode,%courses)>:
1129:
1130: 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.
1131:
1132: Output: 0
1133:
1134: 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.
1135:
1136: =item *
1137: X<multiples_tag()>
1138: B<multiples_tag()>:
1139:
1140:
1141: Input: 0
1142:
1143: Output: 2 - $jscript - javascript for check all/uncheck all checkboxes; $multelement - hidden form element with multiple set to 1.
1144:
1145: Side Effects: None
1146:
1147:
1148: =item *
1149: X<course_chooser()>
1150: B<course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone)>:
1151:
1152: 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).
1153:
1154: Output: 1 - HTML for either checkbox (multiple=1) or select button (multiple=0) for user to indicate course selection.
1155:
1156: Side Effects: None
1157:
1158:
1159: =item *
1160: X<gochoose_javascript()>
1161: B<gochoose_javascript($type,$multiple,$autosubmit,$lastaction,$rolename)>:
1162:
1163: Input: 5 - 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.; rolename (e.g., dh) of user's current role.
1164:
1165: Output: 1 $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
1166:
1167: Side Effects: None
1168:
1169: javascript functions used when user selects a course(s). Different behavior depending on context:
1170:
1171: =back
1172:
1173: =over 8
1174:
1175: =item
1176:
1177: (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.
1178:
1179: =item
1180:
1181: (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.
1182:
1183: =item
1184:
1185: (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.
1186:
1187: =item
1188:
1189: (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.
1190:
1191: =item
1192:
1193: (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.
1194:
1195: =item
1196:
1197: (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.
1198:
1199: =item
1200:
1201: (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.
1202:
1203: =item
1204:
1205: (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.
1206:
1207: =back
1208:
1209: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>