line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Math::Tutor::Cmd::VulFrac::Cmd::Compare; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16625
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
App::Math::Tutor::Cmd::VulFrac::Cmd::Compare - Plugin for comparing vulgar fractions |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.005'; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
3
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
17
|
1
|
|
|
1
|
|
282
|
use MooX::Cmd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
18
|
1
|
|
|
1
|
|
1774
|
use MooX::Options; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
1116
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
21
|
1
|
|
|
1
|
|
247
|
use File::ShareDir (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Template (); |
23
|
|
|
|
|
|
|
use Scalar::Util qw(looks_like_number); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has template_filename => ( |
26
|
|
|
|
|
|
|
is => "ro", |
27
|
|
|
|
|
|
|
default => "twocols" |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
with "App::Math::Tutor::Role::VulFracExercise"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _build_exercises |
33
|
|
|
|
|
|
|
{ |
34
|
|
|
|
|
|
|
my ($self) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my (@tasks); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
foreach my $i ( 1 .. $self->quantity ) |
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
my @line; |
41
|
|
|
|
|
|
|
foreach my $j ( 0 .. 1 ) |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
my ( $a, $b ) = $self->get_vulgar_fractions(2); |
44
|
|
|
|
|
|
|
push @line, [ $a, $b ]; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
push @tasks, \@line; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $exercises = { |
50
|
|
|
|
|
|
|
section => "Vulgar fraction comparison", |
51
|
|
|
|
|
|
|
caption => 'Vulgar fractions', |
52
|
|
|
|
|
|
|
label => 'vulgar_fractions_comparison', |
53
|
|
|
|
|
|
|
header => [ [ 'Vulgar fraction Comparison', 'Vulgar fraction Comparison' ] ], |
54
|
|
|
|
|
|
|
solutions => [], |
55
|
|
|
|
|
|
|
challenges => [], |
56
|
|
|
|
|
|
|
}; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
foreach my $line (@tasks) |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
my ( @solution, @challenge ); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
foreach my $i ( 0 .. 1 ) |
63
|
|
|
|
|
|
|
{ |
64
|
|
|
|
|
|
|
my ( $a, $b ) = @{ $line->[$i] }; |
65
|
|
|
|
|
|
|
push( @challenge, "\$ $a \\underbracket[0.5pt]{\\texttt{ }}\\text{ } $b \$" ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my @way; # remember Frank Sinatra :) |
68
|
|
|
|
|
|
|
my $op = $a <=> $b; |
69
|
|
|
|
|
|
|
$op < 0 and push( @way, "$a < $b" ); |
70
|
|
|
|
|
|
|
$op > 0 and push( @way, "$a > $b" ); |
71
|
|
|
|
|
|
|
$op == 0 and push( @way, "$a = $b" ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
push( @solution, '$ ' . join( " = ", @way ) . ' $' ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
push( @{ $exercises->{solutions} }, \@solution ); |
77
|
|
|
|
|
|
|
push( @{ $exercises->{challenges} }, \@challenge ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$exercises; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright 2010-2014 Jens Rehsack. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
88
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
89
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |