view release on metacpan or search on metacpan
lib/App/Math/Tutor/Cmd/Unit/Cmd/Cast.pm view on Meta::CPAN
our $VERSION = '0.005';
use Moo;
use MooX::Cmd;
use MooX::Options;
use Carp qw(croak);
use File::ShareDir ();
use Template ();
use Scalar::Util qw(looks_like_number);
has template_filename => (
is => "ro",
default => "twocols"
);
with "App::Math::Tutor::Role::UnitExercise", "App::Math::Tutor::Role::DecFracExercise";
sub _get_castable_numbers
{
lib/App/Math/Tutor/Cmd/Unit/Cmd/Compare.pm view on Meta::CPAN
our $VERSION = '0.005';
use Moo;
use MooX::Cmd;
use MooX::Options;
use Carp qw(croak);
use File::ShareDir ();
use Template ();
use Scalar::Util qw(looks_like_number);
has template_filename => (
is => "ro",
default => "twocols"
);
with "App::Math::Tutor::Role::UnitExercise";
sub _build_exercises
{
lib/App/Math/Tutor/Cmd/VulFrac/Cmd/Compare.pm view on Meta::CPAN
our $VERSION = '0.005';
use Moo;
use MooX::Cmd;
use MooX::Options;
use Carp qw(croak);
use File::ShareDir ();
use Template ();
use Scalar::Util qw(looks_like_number);
has template_filename => (
is => "ro",
default => "twocols"
);
with "App::Math::Tutor::Role::VulFracExercise";
sub _build_exercises
{
lib/App/Math/Tutor/Role/DecFracExercise.pm view on Meta::CPAN
App::Math::Tutor::Role::DecFracExercise - role for exercises in decimal fraction
=cut
use Moo::Role;
use MooX::Options;
with "App::Math::Tutor::Role::Exercise", "App::Math::Tutor::Role::DecFrac";
use Scalar::Util qw(looks_like_number);
our $VERSION = '0.005';
sub _lt { $_[0] < $_[1]; }
sub _le { $_[0] <= $_[1]; }
sub _gt { $_[0] > $_[1]; }
sub _ge { $_[0] >= $_[1]; }
sub _ok { 1; }
=head1 ATTRIBUTES
lib/App/Math/Tutor/Role/DecFracExercise.pm view on Meta::CPAN
Specifies number of decimal digits (after decimal point)
=cut
option digits => (
is => "ro",
doc => "Specified number of decimal digits (after decimal point)",
long_doc => "Specify count of decimal digits after decimal point (limit value using range)",
isa => sub {
defined( $_[0] )
and looks_like_number( $_[0] )
and $_[0] != int( $_[0] )
and die("Digits must be natural");
defined( $_[0] )
and ( $_[0] < 2 or $_[0] > 13 )
and die("Digits must be between 2 and 13");
},
coerce => sub {
int( $_[0] );
},
default => sub { 5; },
lib/App/Math/Tutor/Role/NaturalExercise.pm view on Meta::CPAN
App::Math::Tutor::Role::NaturalExercise - role for for exercises with natural numbers
=cut
use Moo::Role;
use MooX::Options;
with "App::Math::Tutor::Role::Exercise", "App::Math::Tutor::Role::Natural";
use Scalar::Util qw/looks_like_number/;
our $VERSION = '0.005';
=head1 ATTRIBUTES
=head2 format
Specifies format of operand
=cut
lib/App/Math/Tutor/Role/NaturalExercise.pm view on Meta::CPAN
option format => (
is => "ro",
doc => "specifies format of natural number",
long_doc => "Allow specifying the format of the natural number "
. "whereby any digit is typed with 'n' as placeholder:\n\n"
. "\t--format 5nnn\n\n"
. "creates natural numbers from 0002 .. 5999.\n\n"
. "Default: 100",
isa => sub {
defined( $_[0] )
and !looks_like_number( $_[0] )
and $_[0] !~ m,^\d?n+?$,
and die("Invalid format");
},
coerce => sub {
defined( $_[0] ) or return 100;
looks_like_number( $_[0] ) and int( $_[0] ) == $_[0] and return $_[0];
my ($fmtv) = ( $_[0] =~ m,^(\d?n+)?$, );
my $startv = "1";
$fmtv =~ s/^(\d)(.*)/$2/ and $startv = $1;
my $maxv = $startv . "0" x length($fmtv);
$maxv;
},
default => sub { 100 },
format => "s",
short => "f",
lib/App/Math/Tutor/Role/PolyExercise.pm view on Meta::CPAN
App::Math::Tutor::Role::PolyExercise - role for for exercises with polynom
=cut
use Moo::Role;
use MooX::Options;
with "App::Math::Tutor::Role::Exercise", "App::Math::Tutor::Role::Poly";
use Scalar::Util qw/looks_like_number/;
our $VERSION = '0.005';
=head1 ATTRIBUTES
=head2 format
Specifies format of factor per term
=cut
lib/App/Math/Tutor/Role/PolyExercise.pm view on Meta::CPAN
option format => (
is => "ro",
doc => "specifies format of natural number as factor per term",
long_doc => "Allow specifying the format of the natural number "
. "whereby any digit is typed with 'n' as placeholder:\n\n"
. "\t--format 5nnn\n\n"
. "creates natural numbers from -5999 .. 5999.\n\n"
. "Default: 100",
isa => sub {
defined( $_[0] )
and !looks_like_number( $_[0] )
and $_[0] !~ m,^\d?n+?$,
and die("Invalid format");
},
coerce => sub {
defined( $_[0] ) or return 100;
looks_like_number( $_[0] ) and int( $_[0] ) == $_[0] and return $_[0];
my ($fmtv) = ( $_[0] =~ m,^(\d?n+)?$, );
my $startv = "1";
$fmtv =~ s/^(\d)(.*)/$2/ and $startv = $1;
my $maxv = $startv . "0" x length($fmtv);
$maxv;
},
default => sub { 100 },
format => "s",
short => "f",
lib/App/Math/Tutor/Role/PolyExercise.pm view on Meta::CPAN
Specifies format of exponent
=cut
option max_power => (
is => "ro",
doc => "specifies the highest exponent",
long_doc => "Allow specifying the format of the polynom " . "by using the higest exponent.\n\n" . "Default: 2",
isa => sub {
defined( $_[0] )
and !looks_like_number( $_[0] )
and die("Invalid exponent");
int( $_[0] ) == $_[0]
or die("Invalid exponent");
},
default => sub { 2 },
format => "i",
short => "e",
);
=head2 probability
lib/App/Math/Tutor/Role/PolyExercise.pm view on Meta::CPAN
Specifies probability per term in %
=cut
option probability => (
is => "ro",
doc => "specifies probability per term",
long_doc => "Allow specifying the probability of each term of the polynom\n\n" . "Default: 80",
isa => sub {
defined( $_[0] )
and !looks_like_number( $_[0] )
and die("Invalid probability");
$_[0] <= 0
and $_[0] > 100
and die("Invalid probability");
},
default => sub { 95 },
format => "f",
short => "p",
);