ONO::FW::Edu::Apps::Modules::MathCountMC

package ONO::FW::Edu::Apps::Modules::MathCountMC;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2022-2026 Jos Kirps and The Joopita Project [ASBL]
# Copyright (C) 2011-2022 Jos Kirps and Joopita Research ASBL
# Copyright (C) 2006-2011 Jos Kirps and The Joopita Project
# Copyright (C) 2001-2006 Jos Kirps and The WobbleWolf Project
#
# This file, as well as many other parts of the ONO Software Project or
# related elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################

#: This module is a front end application module wrapper that has been
#: created for the Morzino Project (morzino.com) and that has been released
#: as Open Source software.
#:
#: Note that this is NOT a self-contained application, it is only a wrapper
#: that makes heavy use of the ONO Perl Framework application engine.

use strict;

use ONO::FW::Edu::Apps::ToolBox;
use ONO::FW::Edu::Apps::Modules::WorksheetMaker::Input;

use ONO::Lib::Data::Color;

use ONO::Lib::PDF::Draw;
use ONO::Lib::PDF::ToolBox;
use ONO::Lib::PDF::Elements::Abacus;
use ONO::Lib::PDF::Elements::Brick;
use ONO::Lib::PDF::Elements::Dice;
use ONO::Lib::PDF::Elements::Sticker;

use ONO::Lib::UI::Sticker;

use ONO::FW::Apps::Core;
use ONO::FW::Apps::Core::Graphics;

use ONO::FW::Edu::Apps::Modules::MathRods;
use ONO::FW::Edu::Apps::Modules::Money;

use ONO::Lib::Parser;
use ONO::IO;
use ONO::FW::Apps::PDF;
use ONO::FW::Apps::ToolBox;

use ONO::FW::Edu::Apps::Modules::MathCount;

sub learn {

my (
$self,
$option,
$vars_ref,
$HTTP,
$BASE,
) = @_;

################################################################
# INIT - BEGIN
################################################################

my (
$db,
$community,
$action_url,
$form,
$format,
$canvas,
$pdfkey,
$sec,$min,$hour,
$mday,$mon,$year,
$wday,$yday,$timestamp,
$lang,
$BLK_ref,
$vars_ref,
) = ONO::FW::Apps::Core->init($vars_ref);

my %vars = %$vars_ref;
my %BLK = %$BLK_ref;

my $app = "count";

ONO::FW::Apps::Core->now("",$app,$vars{'app_lang'});

my $WEB;

my @txt = (
"count",
"draw",
"Various possibilities",
);

if ($vars{'app_lang'} eq "de") {
@txt = (
"zählen",
"zeichnen",
"Verschiedene Möglichkeiten",
);
}

if ($vars{'app_lang'} eq "lu") {
@txt = (
"zielen",
"zeechnen",
"Verschidde Méiglechkeeten",
);
}

if ($vars{'app_lang'} eq "fr") {
@txt = (
"compter",
"dessiner",
"Possibilités diverses",
);
}

$WEB .= ONO::FW::Apps::Core->output_paper_save($pdfkey,$BLK_ref,\%vars,$HTTP,$BASE,"$year$mon$mday");

if (ONO::FW::Apps::Core->running(\%vars,$db)) {

$WEB .= ONO::FW::Apps::Core->blockbackbutton($BASE,$vars_ref);

($vars{'app_input_range_from'},$vars{'app_input_range_to'}) = ONO::FW::Apps::Core->range_check(50,100,$vars{'app_input_range_from'},$vars{'app_input_range_to'});

#############################################################
# WORKSHEET MAKER
#############################################################

if ($vars{'output_worksheet_maker'}) {

$vars_ref = ONO::FW::Edu::Apps::Modules::WorksheetMaker::Input->vars(\%vars);
%vars = %$vars_ref;

}

#############################################################
# PDF + ONLINE
#############################################################

my ($types_ref,$types_num) = ONO::FW::Edu::Apps::Modules::MathCount->types_detect(\%vars);
my @types = @$types_ref;

my @colors = ONO::Lib::Data::Color->rainbow("10");

if ($vars{'output_paper'} || $vars{'output_web'}) {

my @defs = ONO::FW::Apps::Core::Graphics->image_ids();
my $defs_num = @defs;
my $defs_ref = \@defs;

my $OPTS = ONO::FW::Apps::Core->headers_options($BLK_ref,$vars_ref);

if ($vars{'output_paper'}) {

$WEB = ONO::FW::Apps::Core->output_paper($pdfkey,\%BLK,\%vars,$HTTP,$BASE);

ONO::FW::Apps::PDF->new("$BASE/pdf/pdf-$pdfkey.pdf","",$format);

}

my $question_number = $vars{'output_web_question_number'};

foreach my $copy (ONO::FW::Apps::Core->unique_copies($vars{'app_input_print_options_unique_copies'})) {

if ($vars{'output_web'}) {

if ($vars{'output_web_next_question'}) {

foreach my $key (keys %vars) {
if ($key =~ /^output_web_cache_/) {
$vars{$key} = "";
}
}

$vars{'output_web_answer'} = "";

}

$WEB .= qq~<$form>~;

$WEB .= ONO::FW::Apps::Core->question_progress($vars{'app_input_number_of_questions'},$question_number);

$WEB .= ONO::FW::Apps::Core->stats("",$BLK_ref,"ctTmWvV");

}

if ($vars{'output_paper'}) {

if ($copy > 1) {
ONO::FW::Apps::PDF->page("",$format);
}
ONO::FW::Apps::Core->headers(\%vars,$format);
ONO::FW::Apps::PDF->title($vars{'app_input_print_options_title'},$OPTS,$vars{'app_input_print_options_code'},$format);
ONO::FW::Apps::Core->unique_copies_info($canvas,$copy,$vars_ref);
ONO::FW::Apps::Core::Graphics->pdf_draw_item_numbers($canvas,-2,0,1,4,"HLV",$vars_ref);

# ONO::Lib::PDF::ToolBox->canvas_test($canvas);

}

my (@corr_cache,@corr_pdf,%used,$HTML);

my $corr_counter = 0;

my $HTML_WIDTH = 522;
my $HTML_INPUT;

my ($pdf_x,$pdf_y) = (5,0);

my ($max_x,$max_y) = (1,1);

if ($vars{'output_paper'}) {
($max_x,$max_y) = (3,4);
}

for (my $y = 0; $y < $max_y; $y++) {
for (my $x = 0; $x < $max_x; $x++) {

my $num = $vars{'output_web_cache_num'};
my $type = $vars{'output_web_cache_type'};
my $exercise = "count";
if ($vars{'app_input_execise_draw'}) {
$exercise = "draw";
if ($vars{'app_input_execise_count'} && int(rand(100)) > 50) {
$exercise = "count";
}
}

if (!$num || $type eq "" || $vars{'output_web_next_question'}) {

$type = $types[int(rand($types_num))];

my $whilecounter;
while ($whilecounter < 16 && $used{"type_$type"}) {
$whilecounter++;
$type = $types[int(rand($types_num))];
}

$used{"type_$type"}++;

$num = ONO::FW::Apps::Core->random_number(1,$vars{'app_input_range_to'},1,100,\%vars);

# try to avoid numbers too small...

if ($num < $vars{'app_input_range_to'}/2) {
$num = ONO::FW::Apps::Core->random_number(1,$vars{'app_input_range_to'},1,100,\%vars);
}
while ($whilecounter < 256 && $used{"num_$num"}) {
$whilecounter++;
$num = ONO::FW::Apps::Core->random_number(1,$vars{'app_input_range_to'},1,100,\%vars);
}

# avoid numbers smaller than 2 in draw mode

if ($exercise eq "draw" && $num < 2) {
$num = ONO::FW::Apps::Core->random_number(1,$vars{'app_input_range_to'},1,100,\%vars);
if ($num < 3) {
$num = 2;
}
}

# used cache

$used{"num_$num"}++;

}

if ($vars{'output_paper'}) {

my $BG = ONO::FW::Edu::Apps::Modules::MathCount->rect_bg($type);

ONO::Lib::PDF::Draw->rect($canvas,$pdf_x,$pdf_y+2,$pdf_x+50,$pdf_y+43,1,"0:22:22:22",$BG,2);

}

my $pos_x = 5;
my $pos_y = 5;

my (
$HTML2,
$HTML_INPUT2,
$corr_pdf_ref,
$used_ref,
$vars_ref2,
) = ONO::FW::Edu::Apps::Modules::MathCount->engine($HTML,$HTML_INPUT,$HTML_WIDTH,$canvas,$pdf_x,$pdf_y,$pos_x,$pos_y,$num,$exercise,$type,\@colors,\@defs,$defs_num,\@corr_pdf,\%used,\%vars);

$HTML .= $HTML2;
$HTML_INPUT .= $HTML_INPUT2;
@corr_pdf = @$corr_pdf_ref;
%used = %$used_ref;
%vars = %$vars_ref2;
$vars_ref = $vars_ref2;

# pdf end: show pencil

if ($vars{'output_paper'} && $exercise eq "draw") {

ONO::Lib::PDF::Draw->place_pdf($canvas,$pdf_x+41,$pdf_y+28,"ono/osr/images/icons/crystal/pdf128/ono/edit_thick.pdf",0.15,270,$format);

}

# web end:

if ($vars{'output_web'}) {

my ($stat_correct,$stat_wrong,$stat_todo_total) = (1,1,1);

if ($vars{'output_web_answer'}) {

$vars{'output_web_answer_status'} = 2;

if ($vars{'output_web_answer'} == $num) {

$vars{'output_web_answer_status'} = 1;

} else {

$vars{'output_web_mistakes'}++;

}

}

my $INPUT = ONO::FW::Apps::Core->input_vars(\%vars);

$WEB .= qq~ <div class="abs" style="top:0px;left:0px;width:920px;padding-top:40px">
<div class="inline auto" style="width:${HTML_WIDTH}px">
<div class="inline">$HTML</div>
</div>
</div>
$INPUT
<input type="hidden" name="output_web_cache_type" value="$type">
<input type="hidden" name="output_web_cache_num" value="$num">
$HTML_INPUT
<div class="abs" style="bottom:5px;left:0px;width:920px">
<div class="inline auto">
~;

$WEB = ONO::FW::Apps::Core->stats_replace($WEB,$question_number,$stat_wrong,$stat_todo_total,$vars{'output_web_mistakes'});

$WEB .= ONO::FW::Apps::Core->check_single(
"",
"",
100,
3,
$BLK_ref,
\%vars,
"CnmMS",
$num,
);

$WEB .= qq~ </div>
</div>
</form>
~;

}

# paper end:

if ($vars{'output_paper'}) {

ONO::Lib::PDF::Draw->font('H',12);

my @bad_nums = (0,0);

my $whilecounter;
while ($whilecounter < 256 && (!$bad_nums[0] || !$bad_nums[1] || $bad_nums[0] == $num || $bad_nums[1] == $num)) {
$whilecounter++;
$bad_nums[0] = ONO::FW::Apps::Core->random_number(1,$vars{'app_input_range_to'},1,100,\%vars);
$bad_nums[1] = ONO::FW::Apps::Core->random_number(1,$vars{'app_input_range_to'},1,100,\%vars);
}

if ($vars{'app_input_execise_num_box'} == 2) {

ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+10,$pdf_y+37.5,$pdf_x+20,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+30,$pdf_y+37.5,$pdf_x+40,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);

if (int(rand(100)) > 50) {

$vars{"corr_nums_mode_$corr_counter"} = 1;
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+15,$pdf_y+42.25,$num,"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+35,$pdf_y+42.25,$bad_nums[0],"c");

} else {

$vars{"corr_nums_mode_$corr_counter"} = 2;
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+15,$pdf_y+42.25,$bad_nums[0],"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+35,$pdf_y+42.25,$num,"c");

}

}

if ($vars{'app_input_execise_num_box'} == 3) {

ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+5,$pdf_y+37.5,$pdf_x+15,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+20,$pdf_y+37.5,$pdf_x+30,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+35,$pdf_y+37.5,$pdf_x+45,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);

if (int(rand(100)) < 34) {

$vars{"corr_nums_mode_$corr_counter"} = 1;
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+10,$pdf_y+42.25,$num,"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+25,$pdf_y+42.25,$bad_nums[0],"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+40,$pdf_y+42.25,$bad_nums[1],"c");

} else {

if (int(rand(100)) < 67) {

$vars{"corr_nums_mode_$corr_counter"} = 2;
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+10,$pdf_y+42.25,$bad_nums[0],"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+25,$pdf_y+42.25,$num,"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+40,$pdf_y+42.25,$bad_nums[1],"c");

} else {

$vars{"corr_nums_mode_$corr_counter"} = 3;
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+10,$pdf_y+42.25,$bad_nums[0],"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+25,$pdf_y+42.25,$bad_nums[1],"c");
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+40,$pdf_y+42.25,$num,"c");

}

}

}

$corr_counter++;

$corr_cache[$corr_counter] = "$num\^$type\^$exercise\^";

}

$pdf_x = $pdf_x + 57.5;

}

$pdf_x = 5;
$pdf_y = $pdf_y + 47.5;

}

if ($vars{'output_paper'} && ONO::FW::Apps::Core->print_corrections("$BASE/pdf/pdf-$pdfkey-corr.pdf","",$format,$vars_ref)) {

ONO::FW::Apps::Core->headers(\%vars,$format,"c");
ONO::FW::Apps::PDF->title($BLK{'Corrections'},$OPTS,$vars{'app_input_print_options_code'},$format);
ONO::FW::Apps::Core->unique_copies_info($canvas,$copy,$vars_ref);
ONO::FW::Apps::Core::Graphics->pdf_draw_item_numbers($canvas,-2,0,1,4,"CHLV",$vars_ref);

# ONO::Lib::PDF::ToolBox->canvas_test($canvas);

my $corr_counter = 0;

my ($pdf_x,$pdf_y) = (5,0);

for (my $y = 0; $y < 4; $y++) {
for (my $x = 0; $x < 3; $x++) {

ONO::Lib::PDF::Draw->rect($canvas,$pdf_x,$pdf_y+2,$pdf_x+50,$pdf_y+43,1,"0:22:22:22","0:255:255:255",2);

my @corr = split(/\^/,$corr_cache[$corr_counter]);
my @corr2 = split(/\^/,$corr_cache[$corr_counter+1]);

if ($vars{'app_input_execise_num_box'} == 2) {

ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+10,$pdf_y+37.5,$pdf_x+20,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+30,$pdf_y+37.5,$pdf_x+40,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);

if ($vars{"corr_nums_mode_$corr_counter"} == 1) {
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+15,$pdf_y+42.25,$corr2[0],"c");
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+30,$pdf_y+37.5,$pdf_x+40,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
} else {
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+10,$pdf_y+37.5,$pdf_x+20,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+35,$pdf_y+42.25,$corr2[0],"c");
}

}

if ($vars{'app_input_execise_num_box'} == 3) {

ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+5,$pdf_y+37.5,$pdf_x+15,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+20,$pdf_y+37.5,$pdf_x+30,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+35,$pdf_y+37.5,$pdf_x+45,$pdf_y+44,1,"0:22:22:22","0:255:255:255",1);

if ($vars{"corr_nums_mode_$corr_counter"} == 1) {
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+10,$pdf_y+42.25,$corr2[0],"c");
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+20,$pdf_y+37.5,$pdf_x+30,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+35,$pdf_y+37.5,$pdf_x+45,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
}
if ($vars{"corr_nums_mode_$corr_counter"} == 2) {
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+5,$pdf_y+37.5,$pdf_x+15,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+25,$pdf_y+42.25,$corr2[0],"c");
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+35,$pdf_y+37.5,$pdf_x+45,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
}
if ($vars{"corr_nums_mode_$corr_counter"} == 3) {
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+5,$pdf_y+37.5,$pdf_x+15,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
ONO::Lib::PDF::Draw->rect($canvas,$pdf_x+20,$pdf_y+37.5,$pdf_x+30,$pdf_y+44,1,"0:22:22:22","0:111:111:111",1);
ONO::Lib::PDF::Draw->text($canvas,$pdf_x+40,$pdf_y+42.25,$corr2[0],"c");
}

}

$corr_counter++;

$pdf_x = $pdf_x + 57.5;

}

foreach my $corr (@corr_pdf) {

my @cp = split(/\^/,$corr);

if ($cp[0] eq "circle") {
ONO::Lib::PDF::Draw->circle($canvas,$cp[1],$cp[2],$cp[3],$cp[4],"0:111:111:111","0:111:111:111");
}
if ($cp[0] eq "brick") {
ONO::Lib::PDF::Elements::Brick->brick($canvas,$cp[1],$cp[2],$cp[3],$cp[4],$cp[5],$cp[6],"0:111:111:111");
}
if ($cp[0] eq "dice" || $cp[0] eq "dices") {
ONO::Lib::PDF::Elements::Dice->dice($canvas,$cp[1],$cp[2],$cp[3],$cp[4],"","0:111:111:111");
}
if ($cp[0] eq "stickers") {
ONO::Lib::PDF::Elements::Sticker->sticker($canvas,$cp[1],$cp[2],$cp[4],$cp[4],$cp[3],"","bcsW");
}
if ($cp[0] eq "image") {
ONO::Lib::PDF::Draw->image($canvas,$cp[1],$cp[2],$cp[3],$cp[4],$cp[5],$cp[6],$cp[7]);
}
if ($cp[0] eq "image") {
ONO::Lib::PDF::Draw->image($canvas,$cp[1],$cp[2],$cp[3],$cp[4],$cp[5],$cp[6],$cp[7]);
}
if ($cp[0] eq "abacus") {
ONO::Lib::PDF::Elements::Abacus->abacus($canvas,$cp[1],$cp[2],"","",$cp[3],"","C");
}

}

$pdf_x = 5;
$pdf_y = $pdf_y + 47.5;

}

}

}

if ($vars{'output_paper'}) {

ONO::FW::Apps::PDF->end;

}

}

if ($vars{'output_web'}) {
ONO::FW::Apps::Core->varstore($vars{'username'},$vars{'virclass'},$vars{'anonymous'},\%vars);
}

} else {

#############################################################
# EXERCISE SETUP
#############################################################

# "screen:320:50:40::math_count_mc_screenshot_1.jpg",

$WEB .= ONO::FW::Apps::Core->infopics(
"sheet:168:190:120:15:math_count_mc_sheet_1.jpg",
"sheet:168:40:130:-10:math_count_mc_sheet_2.jpg",
);

if (!$vars{'app_input_number_of_questions'}) {
$vars{'app_input_number_of_questions'} = 20;
}
if (!$vars{'app_input_execise_count'} && !$vars{'app_input_execise_draw'}) {
$vars{'app_input_execise_count'} = 1;
}

my @opts = ONO::FW::Edu::Apps::Modules::MathCount->opts($BLK_ref);

my $type_found = ONO::FW::Edu::Apps::Modules::MathCount->type_found(\%vars,$BLK_ref);

if (!$type_found) {
$vars{"app_input_type_dots"} = 1;
$vars{"app_input_type_rods"} = 1;
$vars{"app_input_type_dices"} = 1;
$vars{"app_input_type_images"} = 1;
}

my ($CUSTOM,$SCRIPT_END) = ONO::FW::Edu::Apps::Modules::MathCount->type_select(\%vars,$BLK_ref);

my ($CURR,$USE,$SCRIPT,$hide_curr) = ONO::FW::Edu::Apps::Modules::MathCount->currency(\%vars,$BLK_ref);

my $CONF .= ONO::FW::Apps::ToolBox->conf_input("range", $BLK_ref,\%vars,"",1,20,100);
$CONF .= ONO::FW::Apps::ToolBox->conf_input("spacer", $BLK_ref,\%vars);

$CONF .= ONO::FW::Apps::ToolBox->conf_input("custom", $BLK_ref,\%vars,"","",$CUSTOM);
$CONF .= ONO::FW::Apps::ToolBox->conf_input("custom", $BLK_ref,\%vars,"","",qq~<div id="currency_selector_id" class="$hide_curr">$CURR</div>~);

my ($CUS1,$CUS2);

if ($vars{'app_input_execise_num_img'} < 2 && $vars{'app_input_execise_num_box'} < 2) {
$vars{'app_input_execise_num_box'} = 3;
}

for (my $i = 1; $i < 4; $i++) {
my ($img,$num) = ($BLK{'image'},$BLK{'number'});
if ($i > 1) {
($img,$num) = ("$BLK{'images'} ($BLK{'if_possible'})",$BLK{'numbers'});
}
my ($sel1,$sel2);
if ($i == $vars{'app_input_execise_num_img'}) {
$sel1 = " selected";
}
if ($i == $vars{'app_input_execise_num_box'}) {
$sel2 = " selected";
}

# as of now, only the 1 single image option is supported:

if ($i < 2) {
$CUS1 .= qq~<option value="$i"$sel1>$i $img</option>~;
}
if ($i > 1) {
$CUS2 .= qq~<option value="$i"$sel2>$i $num</option>~;
}
}

my $CUSTOM2 = qq~<table class="wide_table">
<tr>
<td><div class="select"><select name="app_input_execise_num_img">$CUS1</select></div></td>
<td><div class="select"><select name="app_input_execise_num_box">$CUS2</select></div></td>
</tr>
</table>
~;

$CONF .= ONO::FW::Apps::ToolBox->conf_input("custom", $BLK_ref,\%vars,"","",$CUSTOM2);

# $CONF .= ONO::FW::Apps::ToolBox->conf_input("check", $BLK_ref,\%vars,"S","","execise_count_mc",$vars{'app_input_execise_count_mc'},$txt[0]);
# if (!$vars{'output_web'}) {
# $CONF .= ONO::FW::Apps::ToolBox->conf_input("check", $BLK_ref,\%vars,"S","","execise_draw",$vars{'app_input_execise_draw'},$txt[1]);
# } else {
# $CONF .= qq~<input type="hidden" name="app_input_execise_draw" value="$vars{'app_input_execise_draw'}">~;
# }

$WEB .= ONO::FW::Apps::Core->conf_box(
$db,
$community,
$app,
$form,
"",
$action_url,
$CONF,
$lang,
$BLK_ref,
\%vars,
"p-ncbdi-CDI-u-N",
);

$SCRIPT .= ONO::FW::Edu::Apps::Modules::MathCount->script();

$WEB .= qq~$SCRIPT$SCRIPT_END~;

if ($vars{'app_input_currency'}) {
$WEB .= qq~<script>use_box_select('$vars{'app_input_currency'}')</script>~;
}

if (!$vars{'exercise'}) {
$WEB .= ONO::FW::Apps::Core->info_display(
ONO::FW::Apps::Core->info("info_print",$vars{'app_lang'}),
ONO::FW::Apps::Core->info("info_indiv_diff", $vars{'app_lang'}),
);
}

}

my ($status,$WEB) = ONO::Lib::Parser->parse($WEB,$vars_ref);

$WEB .= ONO::FW::Apps::Core->vardump($vars_ref);

$WEB = ONO::FW::Edu::Apps::ToolBox->apps_gate($WEB,$vars_ref);

return $WEB;

}

###################################################################
#### THAT'S IT :-D
###################################################################

1;

__END__