File tree Expand file tree Collapse file tree
templates/ContentGenerator/CourseAdmin Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11( ( ) => {
22 const addOnConfSelect = document . getElementById ( 'add_on_conf' ) ;
3- const addOnConfOptgroups = [ ...addOnConfSelect . querySelectorAll ( 'optgroup' ) ] ;
3+ if ( ! addOnConfSelect ) return ;
4+
5+ const addOnConfOptgroups = addOnConfSelect . querySelectorAll ( 'optgroup' ) ;
46
57 // Track previously selected options to identify the newly clicked option
68 let previousSelection = [ ] ;
79
8- addOnConfSelect . addEventListener ( 'change' , ( event ) => {
9- const currentSelection = Array . from ( addOnConfSelect . selectedOptions ) ;
10-
10+ addOnConfSelect . addEventListener ( 'change' , ( ) => {
1111 // Find the option the user just clicked/selected
12- const newlySelected = currentSelection . find ( ( option ) => ! previousSelection . includes ( option ) ) ;
12+ const newlySelected = Array . from ( addOnConfSelect . selectedOptions ) . find (
13+ ( option ) => ! previousSelection . includes ( option )
14+ ) ;
1315
1416 if ( newlySelected ) {
1517 // Find the parent optgroup
1618 const parent = newlySelected . closest ( 'optgroup' ) ;
1719
1820 // Loop through all options in the other groups and unselect them as appropriate
19- addOnConfOptgroups . forEach ( ( group ) => {
20- Array . from ( group . children ) . forEach ( ( option ) => {
21+ for ( const group of addOnConfOptgroups ) {
22+ for ( const option of group . children ) {
2123 if (
2224 option !== newlySelected &&
2325 ( parent . dataset . single || ( ! parent . dataset . single && group . dataset . single ) )
2426 ) {
2527 option . selected = false ;
2628 }
27- } ) ;
28- } ) ;
29+ }
30+ }
2931 }
3032
3133 // Update tracking variable for the next change event
Original file line number Diff line number Diff line change @@ -1179,9 +1179,10 @@ sub protectQString {
11791179
11801180=item writeCourseConf($fh, $addOnConf)
11811181
1182- Writes an essentially empty course.conf file to $fh, a file handle. System
1183- administrators can use this file to override global settings for a course.
1184- $addOnConf should be an array reference of config files to tack on at the end.
1182+ Writes the course.conf file to C<$fh > , a file handle. System administrators can
1183+ use this file to override global settings for a course. If C<$addOnConf > is
1184+ provided, then it should be a reference to an array of config files to be
1185+ included at the end of the course.conf file.
11851186
11861187=back
11871188
@@ -1197,12 +1198,9 @@ sub writeCourseConf {
11971198
11981199EOF
11991200
1200- if ($addOnConf ne ' ' ) {
1201+ if (ref $addOnConf eq ' ARRAY ' ) {
12011202 for my $conf (@$addOnConf ) {
1202- $content .= <<"EOF" ;
1203-
1204- include('$conf ');
1205- EOF
1203+ $content .= " \n include('$conf ');" ;
12061204 }
12071205 }
12081206
Original file line number Diff line number Diff line change 221221 <%= maketext('course institution (will override "Institution" input above)') =%>
222222 </label>
223223 </div>
224- % my $addOnConfFolder = $ce->{webworkDirs}{addOnConf};
225224 % my @addOnConfFiles;
226- % if (-d $addOnConfFolder ) {
227- % @addOnConfFiles = glob "$addOnConfFolder /*.conf";
228- % for (0.. $#addOnConfFiles){
225+ % if (-d $ce->{webworkDirs}{addOnConf} ) {
226+ % @addOnConfFiles = glob "$ce->{webworkDirs}{addOnConf} /*.conf";
227+ % for (0 .. $#addOnConfFiles){
229228 % $addOnConfFiles[$_] =~ s/^.*\/|\.conf$//g;
230229 % }
231230 % }
236235 <div class="col-auto">
237236 <%= select_field add_on_conf => [
238237 c(
239- maketext('Use Default')
240- => [ [ maketext('Distribution Default Config File ') => '' ] ],
241- 'data-single' => 'true'
238+ maketext('Default')
239+ => [ [ maketext('Use distribution default config file ') => '', selected => undef ] ],
240+ 'data-single' => 'true',
242241 ),
243242 c(
244243 maketext('Source Course')
245- => [ [ maketext("Source Course 's Config File ") => '*' ] ],
244+ => [ [ maketext("Use source course 's config file ") => '*' ] ],
246245 'data-single' => 'true'
247246 ),
248247 c(
249- maketext('Append to Distribution Default ')
248+ maketext('Append to distribution default ')
250249 => [ map { [ $_ => "$_.conf" ] } @addOnConfFiles ]
251250 )
252251 ],
You can’t perform that action at this time.
0 commit comments