@@ -296,7 +296,7 @@ This gets a single global/default setting.
296
296
297
297
=over
298
298
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
300
300
on the setting.
301
301
302
302
=item * C<$as_result_set > , a boolean if the return is to be a result_set
@@ -315,11 +315,10 @@ sub getGlobalSetting ($self, %args) {
315
315
316
316
DB::Exception::SettingNotFound-> throw(message => $setting_info -> {setting_name }
317
317
? " 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" )
319
319
unless $global_setting ;
320
320
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 };
323
322
}
324
323
325
324
=head2 getCourseSettings
@@ -351,12 +350,9 @@ sub getCourseSettings ($self, %args) {
351
350
my @settings_from_db = $course -> course_settings;
352
351
353
352
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 ];
360
356
}
361
357
362
358
=pod
@@ -369,7 +365,7 @@ This gets a single course setting.
369
365
370
366
=over
371
367
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
373
369
on the setting.
374
370
375
371
=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
388
384
sub getCourseSetting ($self , %args ) {
389
385
my $global_setting = $self -> getGlobalSetting(info => $args {info }, as_result_set => 1);
390
386
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." )
392
388
unless defined ($global_setting );
393
389
394
390
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 });
396
392
397
393
DB::Exception::SettingNotFound-> throw(
398
394
message => ' The course setting with '
399
395
. (
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 "
402
398
)
403
399
. (
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}"
406
402
)
407
403
) unless defined ($setting );
408
404
409
405
return $setting if $args {as_result_set };
410
- my $setting_to_return =
411
- $args {merged }
406
+ return $args {merged }
412
407
? { $setting -> get_inflated_columns, $setting -> global_setting-> get_inflated_columns }
413
408
: { $setting -> get_inflated_columns };
414
- return $setting_to_return ;
415
409
}
416
410
417
411
=pod
@@ -425,7 +419,7 @@ Update a single course setting.
425
419
=over
426
420
427
421
=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 > ).
429
423
430
424
=item * C<params > the updated value of the course setting.
431
425
@@ -446,14 +440,12 @@ sub updateCourseSetting ($self, %args) {
446
440
my $course = $self -> getCourse(info => getCourseInfo($args {info }), as_result_set => 1);
447
441
my $global_setting = $self -> getGlobalSetting(info => getSettingInfo($args {info }));
448
442
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 } });
452
444
453
445
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 }
457
449
};
458
450
459
451
isValidSetting($global_setting , $params -> {value });
@@ -462,12 +454,9 @@ sub updateCourseSetting ($self, %args) {
462
454
defined ($course_setting ) ? $course_setting -> update($params ) : $course -> add_to_course_settings($params );
463
455
464
456
return $up_setting if $args {as_result_set };
465
- my $setting_to_return =
466
- ($args {merged })
457
+ return ($args {merged })
467
458
? { $up_setting -> get_inflated_columns, $up_setting -> global_setting-> get_inflated_columns }
468
459
: { $up_setting -> get_inflated_columns };
469
-
470
- return $setting_to_return ;
471
460
}
472
461
473
462
=pod
@@ -481,7 +470,7 @@ Delete a single course setting.
481
470
=over
482
471
483
472
=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 > ).
485
474
486
475
=item * C<$as_result_set > , a boolean if the return is to be a result_set
487
476
0 commit comments