@@ -296,7 +296,7 @@ This gets a single global/default setting.
296296
297297=over
298298
299- =item * C<info > which is a hash of either a C<setting_id > or C<setting_name > with information
299+ =item * C<info > which is a hash of either a C<global_setting_id > or C<setting_name > with information
300300on the setting.
301301
302302=item * C<$as_result_set > , a boolean if the return is to be a result_set
@@ -315,11 +315,10 @@ sub getGlobalSetting ($self, %args) {
315315
316316 DB::Exception::SettingNotFound-> throw(message => $setting_info -> {setting_name }
317317 ? " The setting with name $setting_info ->{setting_name} is not found"
318- : " The setting with setting_id $setting_info ->{setting_id } is not found" )
318+ : " The setting with global_setting_id $setting_info ->{global_setting_id } is not found" )
319319 unless $global_setting ;
320320 return $global_setting if $args {as_result_set };
321- my $setting_to_return = { $global_setting -> get_inflated_columns };
322- return $setting_to_return ;
321+ return { $global_setting -> get_inflated_columns };
323322}
324323
325324=head2 getCourseSettings
@@ -351,12 +350,9 @@ sub getCourseSettings ($self, %args) {
351350 my @settings_from_db = $course -> course_settings;
352351
353352 return \@settings_from_db if $args {as_result_set };
354- my @settings_to_return = map {
355- $args {merged }
356- ? { $_ -> get_inflated_columns, $_ -> global_setting-> get_inflated_columns }
357- : { $_ -> get_inflated_columns };
358- } @settings_from_db ;
359- return \@settings_to_return ;
353+ return $args {merged }
354+ ? [ map { { $_ -> get_inflated_columns, $_ -> global_setting-> get_inflated_columns } } @settings_from_db ]
355+ : [ map { { $_ -> get_inflated_columns } } @settings_from_db ];
360356}
361357
362358=pod
@@ -369,7 +365,7 @@ This gets a single course setting.
369365
370366=over
371367
372- =item * C<info > which is a hash of either a C<setting_id > or C<setting_name > with information
368+ =item * C<info > which is a hash of either a C<global_setting_id > or C<setting_name > with information
373369on the setting.
374370
375371=item * C<merged > , a boolean on whether the course setting is merged with its corresponding
@@ -388,30 +384,28 @@ A single course setting as either a hashref or a C<DBIx::Class::ResultSet::Cours
388384sub getCourseSetting ($self , %args ) {
389385 my $global_setting = $self -> getGlobalSetting(info => $args {info }, as_result_set => 1);
390386 DB::Exception::SettingNotFound-> throw(
391- message => " The global setting with name: '" . $args {info }-> {setting_name } . " ' is not a defined info ." )
387+ message => " The global setting with name: '" . $args {info }{setting_name } . " ' is not defined." )
392388 unless defined ($global_setting );
393389
394390 my $course = $self -> getCourse(info => getCourseInfo($args {info }), as_result_set => 1);
395- my $setting = $course -> course_settings-> find({ setting_id => $global_setting -> setting_id });
391+ my $setting = $course -> course_settings-> find({ global_setting_id => $global_setting -> global_setting_id });
396392
397393 DB::Exception::SettingNotFound-> throw(
398394 message => ' The course setting with '
399395 . (
400- $args {info }-> {setting_name } ? " name: '$args {info}-> {setting_name}'"
401- : " setting_id of $args {info}->{setting_id } is not a found in the course "
396+ $args {info }{setting_name } ? " name: '$args {info}{setting_name}'"
397+ : " global_setting_id of $args {info}{global_setting_id } is not found in the course "
402398 )
403399 . (
404- $args {info }-> {course_name } ? (" with name '" . $args {info }-> {course_name } . " '" )
405- : " with course_id of $args {info}-> {course_id}"
400+ $args {info }{course_name } ? (" with name '" . $args {info }{course_name } . " '" )
401+ : " with course_id of $args {info}{course_id}"
406402 )
407403 ) unless defined ($setting );
408404
409405 return $setting if $args {as_result_set };
410- my $setting_to_return =
411- $args {merged }
406+ return $args {merged }
412407 ? { $setting -> get_inflated_columns, $setting -> global_setting-> get_inflated_columns }
413408 : { $setting -> get_inflated_columns };
414- return $setting_to_return ;
415409}
416410
417411=pod
@@ -425,7 +419,7 @@ Update a single course setting.
425419=over
426420
427421=item * C<info > which is a hash containing information about the course (either a
428- C<course_id > or C<course_name > ) and a setting (either a C<setting_id > or C<setting_name > ).
422+ C<course_id > or C<course_name > ) and a setting (either a C<global_setting_id > or C<setting_name > ).
429423
430424=item * C<params > the updated value of the course setting.
431425
@@ -446,14 +440,12 @@ sub updateCourseSetting ($self, %args) {
446440 my $course = $self -> getCourse(info => getCourseInfo($args {info }), as_result_set => 1);
447441 my $global_setting = $self -> getGlobalSetting(info => getSettingInfo($args {info }));
448442
449- my $course_setting = $course -> course_settings-> find({
450- setting_id => $global_setting -> {setting_id }
451- });
443+ my $course_setting = $course -> course_settings-> find({ global_setting_id => $global_setting -> {global_setting_id } });
452444
453445 my $params = {
454- course_id => $course -> course_id,
455- setting_id => $global_setting -> {setting_id },
456- value => $args {params }{value }
446+ course_id => $course -> course_id,
447+ global_setting_id => $global_setting -> {global_setting_id },
448+ value => $args { params }{ value } =~ / ^ $ / ? undef : $args {params }{value }
457449 };
458450
459451 isValidSetting($global_setting , $params -> {value });
@@ -462,12 +454,9 @@ sub updateCourseSetting ($self, %args) {
462454 defined ($course_setting ) ? $course_setting -> update($params ) : $course -> add_to_course_settings($params );
463455
464456 return $up_setting if $args {as_result_set };
465- my $setting_to_return =
466- ($args {merged })
457+ return ($args {merged })
467458 ? { $up_setting -> get_inflated_columns, $up_setting -> global_setting-> get_inflated_columns }
468459 : { $up_setting -> get_inflated_columns };
469-
470- return $setting_to_return ;
471460}
472461
473462=pod
@@ -481,7 +470,7 @@ Delete a single course setting.
481470=over
482471
483472=item * C<info > which is a hash containing information about the course (either a
484- C<course_id > or C<course_name > ) and a setting (either a C<setting_id > or C<setting_name > ).
473+ C<course_id > or C<course_name > ) and a setting (either a C<global_setting_id > or C<setting_name > ).
485474
486475=item * C<$as_result_set > , a boolean if the return is to be a result_set
487476
0 commit comments