[LON-CAPA-cvs] cvs: loncom /interface lonrequestcourse.pm
raeburn
raeburn@source.lon-capa.org
Thu, 25 Feb 2010 08:18:33 -0000
raeburn Thu Feb 25 08:18:33 2010 EDT
Modified files:
/loncom/interface lonrequestcourse.pm
Log:
- Bug 6050.
- Y/N radio buttons for cloning in course request -> additional options in div
block element displayed/hidden depending on radio button state.
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.44 loncom/interface/lonrequestcourse.pm:1.45
--- loncom/interface/lonrequestcourse.pm:1.44 Sun Feb 21 23:38:51 2010
+++ loncom/interface/lonrequestcourse.pm Thu Feb 25 08:18:32 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.44 2010/02/21 23:38:51 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.45 2010/02/25 08:18:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -274,6 +274,9 @@
$jscript = &mainmenu_javascript();
} else {
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
+ if ($state eq 'courseinfo') {
+ $jscript .= &cloning_javascript();
+ }
}
}
@@ -353,6 +356,22 @@
END
}
+sub cloning_javascript {
+ return <<"END";
+function setCloneDisplay(courseForm) {
+ if (courseForm.cloning.length > 1) {
+ for (var i=0; i<courseForm.cloning.length; i++) {
+ if (courseForm.cloning[i].checked) {
+ if (courseForm.cloning[i].value == 1) {
+ document.getElementById('cloneoptions').style.display="block";;
+ }
+ }
+ }
+ }
+}
+END
+}
+
sub get_breadcrumbs {
my ($dom,$action,$state,$states,$trail) = @_;
my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description);
@@ -461,6 +480,7 @@
},
courseinfo => {
cdescr => 'text',
+ cloning => 'radio',
clonecrs => 'text',
clonedom => 'selectbox',
datemode => 'radio',
@@ -596,7 +616,10 @@
if ($state eq 'crstype') {
$loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)';
} else {
- $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
+ $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs);';
+ }
+ if ($state eq 'courseinfo') {
+ $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
}
}
return \%loaditems;
@@ -2168,7 +2191,8 @@
my %ctxt = &clone_text();
$inst_headers .= '<th>'.&mt('Clone From').'</th>';
- if (($env{'form.clonecrs'} =~ /^$match_name$/) &&
+ if (($env{'form.cloning'}) &&
+ ($env{'form.clonecrs'} =~ /^$match_name$/) &&
($env{'form.clonedom'} =~ /^$match_domain$/)) {
my $canclone = &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
$env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},
@@ -2350,6 +2374,24 @@
}
nextPage(document.$formname,'$next');
}
+
+function toggleCloning() {
+ var willclone;
+ if (document.$formname.cloning.length > 1) {
+ for (var i=0; i<document.$formname.cloning.length; i++) {
+ if (document.$formname.cloning[i].checked) {
+ willclone = document.$formname.cloning[i].value;
+ }
+ }
+ }
+ if (willclone == 1) {
+ document.getElementById('cloneoptions').style.display="block";
+ } else {
+ document.getElementById('cloneoptions').style.display="none";
+ document.$formname.clonecrs.value = '';
+ }
+}
+
// ]]
</script>
@@ -2360,7 +2402,7 @@
$title = &mt('Brief Community Description');
$clonetitle = &mt('Clone content and settings from an existing community?');
}
- my $output .= $js_validate."\n".'<div>'.&Apache::lonhtmlcommon::start_pick_box().
+ my $output .= $js_validate."\n".&Apache::lonhtmlcommon::start_pick_box().
&Apache::lonhtmlcommon::row_headline().
'<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').' '.$title.'</h3>'.
&Apache::lonhtmlcommon::row_closure(1).
@@ -2376,10 +2418,20 @@
$output .= $home_server_pick.
&Apache::lonhtmlcommon::row_closure().
&Apache::lonhtmlcommon::row_headline().
- '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').' '.$clonetitle.'</h3>'.
+ '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').' '.$clonetitle.
+ '<label><input type="radio" name="cloning" value="1" '.
+ 'onclick="javascript:toggleCloning()" />'.
+ &mt('Yes').(' 'x2).'</label><label>'.
+ '<input type="radio" name="cloning" value="0" '.
+ 'onclick="javascript:toggleCloning()" />'.&mt('No').'</label>'.
+ '</h3>'.
&Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::row_headline().
+ '<div id="cloneoptions" style="display: none" >'.
+ &Apache::lonhtmlcommon::start_pick_box().
&clone_form($dom,$formname,$crstype).
- &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
+ &Apache::lonhtmlcommon::end_pick_box().'</div>'.
+ &Apache::lonhtmlcommon::end_pick_box()."\n";
return $output;
}
@@ -2740,7 +2792,8 @@
}
my $clonecrs = '';
my $clonedom = '';
- if (($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
+ if (($env{'form.cloning'}) &&
+ ($env{'form.clonecrs'} =~ /^($match_courseid)$/) &&
($env{'form.clonedom'} =~ /^($match_domain)$/)) {
my $clonehome = &Apache::lonnet::homeserver($env{'form.clonecrs'},
$env{'form.clonedom'});