package ONO::FW::Edu::Apps::Modules::Sentences;
################################################################################
# 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::FW::Apps::ToolBox;
use ONO::Lib::PDF::Draw;
use ONO::Lib::PDF::ToolBox;
use ONO::FW::Apps::Core;
use ONO::FW::Apps::Core::Graphics;
use ONO::FW::Apps::Core::Lang;
use ONO::Lib::Parser;
use ONO::FW::Apps::PDF;
use ONO::IO;
use ONO::DB;
use ONO::Lib::SQL::TableCreate;
use ONO::Lib::Basic;
use ONO::Lib::Data::Generators::Sentence;
use ONO::Lib::Data::Color;
use ONO::Lib::Data::Letters;
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 = "sentences";
my $WEB;
ONO::FW::Apps::Core->now("",$app,$vars{'app_lang'});
$vars{'app_input_print_options_title_default'} = $BLK{'Sentences'};
# $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)) {
#############################################################
# WORKSHEET MAKER
#############################################################
if ($vars{'output_worksheet_maker'}) {
$vars_ref = ONO::FW::Edu::Apps::Modules::WorksheetMaker::Input->vars(\%vars);
%vars = %$vars_ref;
}
#############################################################
# ONLINE TRAINING
#############################################################
$WEB .= ONO::FW::Apps::Core->blockbackbutton($BASE,$vars_ref);
if ($vars{'output_web'} || $vars{'output_paper'}) {
my $questions_per_page = 1;
my $PDF_OPTS;
if ($vars{'output_paper'}) {
$PDF_OPTS = ONO::FW::Apps::Core->headers_options($BLK_ref,$vars_ref);
ONO::FW::Apps::PDF->new("$BASE/pdf/pdf-$pdfkey.pdf","",$format);
}
foreach my $copy (ONO::FW::Apps::Core->unique_copies($vars{'app_input_print_options_unique_copies'})) {
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'},$PDF_OPTS,$vars{'app_input_print_options_code'},$format);
ONO::FW::Apps::Core->unique_copies_info($canvas,$copy,$vars_ref);
ONO::Lib::PDF::ToolBox->canvas_test($canvas);
my $pdf_y = 4;
my $count;
foreach my $RES (ONO::Lib::Data::Generators::Sentence->sentences(20,$vars{'app_input_langs_lang_1'},$BLK_ref)) {
$count++;
ONO::Lib::PDF::Draw->text($canvas,7,$pdf_y, "$count.","r");
ONO::Lib::PDF::Draw->text($canvas,9,$pdf_y, $RES);
$pdf_y = $pdf_y + 9.5;
}
}
if ($vars{'output_web'}) {
$WEB .= qq~<div class="p10">
<div class="inline w100">~;
foreach my $RES (ONO::Lib::Data::Generators::Sentence->sentences(16,$vars{'app_input_langs_lang_1'},$BLK_ref)) {
$WEB .= qq~ <div class="box_paper mr10 mb10 fl">~;
$WEB .= $RES;
$WEB .= qq~ </div>~;
}
my $VARS;
foreach my $key ('app_input_langs_lang_1','app_input_number_of_questions','output_web_question_number','output_selected') {
if ($vars{$key}) {
$VARS .= "&$key=$vars{$key}";
}
}
$WEB .= qq~ </div>
</div>
<div class="inline">
<a href="$action_url&output_web=1$VARS" class="button_green ml10">$BLK{'again'}...</a>
<a href="$action_url" class="button_yellow ml10">$BLK{'done'} / $BLK{'back'}</a>
</div>
~;
}
}
if ($vars{'output_paper'}) {
ONO::FW::Apps::PDF->end;
$WEB .= ONO::FW::Apps::Core->output_paper($pdfkey,\%BLK,\%vars,$HTTP,$BASE);
}
}
if ($vars{'output_web'}) {
ONO::FW::Apps::Core->varstore($vars{'username'},$vars{'virclass'},$vars{'anonymous'},\%vars);
}
$WEB .= ONO::FW::Apps::Core->vardump($vars_ref);
$WEB = ONO::FW::Edu::Apps::ToolBox->apps_gate($WEB,$vars_ref);
} else {
#############################################################
# EXERCISE SETUP
#############################################################
my @rgb = ONO::Lib::Data::Color->hex();
my @letters = (ONO::Lib::Data::Letters->get_lc(),ONO::Lib::Data::Letters->get_uc());
my $letters_num = @letters;
$WEB .= qq~<div class="rel" style="width:920px;height:480px;overflow:hidden">~;
for (my $i = 0; $i < 256; $i++) {
my $x = int(rand(920));
my $y = int(rand(480));
my $r = int(rand(60))-30;
my $s = int(rand(100))+12;
my $L = $letters[int(rand($letters_num))];
my ($R,$G,$B) = ($rgb[int(rand(12))+3],$rgb[int(rand(12))+3],$rgb[int(rand(12))+3]);
$WEB .= qq~<div class="abs" style="top:${y}px;left:${x}px;font-size:${s}px;color:#$R$R$G$G$B$B;-ms-transform:rotate(${r}deg);-webkit-transform:rotate(${r}deg);transform:rotate(${r}deg)">$L</div>~;
}
$WEB .= qq~</div>~;
if (!$vars{'app_input_number_of_questions'}) {
$vars{'app_input_number_of_questions'} = 20;
}
my (
$default_ref,$default_lessons,$all_lessons,$custom_lessons,$LU,
) = ONO::FW::Apps::Core::Lang->lang_default_setup_config(\%vars);
my @default = @$default_ref;
$vars{'software_base'} = $BASE;
$vars{'output_web_custom_text'} = $BLK{'generate_online'};
my $CONF .= ONO::FW::Apps::ToolBox->conf_input("lang", $BLK_ref,\%vars,"is","$default[0];en:de:fr$LU");
$CONF .= ONO::FW::Apps::ToolBox->conf_input("spacer", $BLK_ref,\%vars);
$WEB .= ONO::FW::Apps::Core->conf_box(
$db,
$community,
$app,
$form,
"",
$action_url,
$CONF,
$lang,
$BLK_ref,
\%vars,
"op-nd-LT",
);
$WEB .= ONO::FW::Apps::Core->vardump($vars_ref);
$WEB = ONO::FW::Edu::Apps::ToolBox->apps_gate($WEB,$vars_ref);
}
my ($status,$WEB) = ONO::Lib::Parser->parse($WEB,$vars_ref);
return $WEB;
}
###################################################################
#### THAT'S IT :-D
###################################################################
1;
__END__