ONO::FW::Edu::Apps::Modules::WritingIdeas

package ONO::FW::Edu::Apps::Modules::WritingIdeas;
################################################################################
# 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::Edu::Apps::Variation;

use ONO::Lib::Encoding::HTML;

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::Lang::ToolBox;
use ONO::Lib::Data::Letters;
use ONO::Lib::UI::Check;

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 = "writingideas";

my $WEB;

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

my @txt = (
"Writing ideas",
"Create...",
);
if ($lang eq "deX") {
@txt = (
);
}

my $NAME = $txt[0];
$vars{'app_input_print_options_title_default'} = $NAME;

#

my $total_pix = ONO::FW::Apps::Core::Lang->total_pix();

if (ONO::IO->devstation) {
$vars{'username'} = "jos";
}
if (ONO::FW::Apps::Core->running(\%vars,$db) && ($vars{'output_web'} || $vars{'output_paper'})) {
$vars{'wordlist_force_loading'} = 1;
}

$vars{'app_input_langs_lang_2'} = "img";

my (
$RETURN,$WORDLIST_ref,$TRANS_ref,$IMGS_ref,
$USE_GROUPS,$USE_GROUPS_ALT,$USE_GROUPS_LU,$USE_GROUPS_CUSTOM_ref,
$CACHE_WORDS,$CACHE_TRANS,$CACHE_IMGS,
$use_language1,$use_language2,
$use_images,$use_images_reverse,$use_images_forced,$use_custom_groups,$use_lu,
$get_words,$words_found,$multi_frame_custom_width,$hide_flags,
) = ONO::FW::Apps::Core::Lang->lang_load_wordlist($db,$community,\%vars);

$WEB .= $RETURN;
my @WORDLIST = @$WORDLIST_ref;
my @TRANS = @$TRANS_ref;
my @IMGS = @$IMGS_ref,
my @USE_GROUPS_CUSTOM = @$USE_GROUPS_CUSTOM_ref;

$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) && $words_found) || $vars{'output_web_crosswords_code'}) {

#############################################################
# 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);

my $generate_now;

if (!$generate_now) {

my $CONF_BOX_TITLE = ONO::FW::Apps::Core->conf_box_title("ono/setup",$BLK{'Configure_exercise'});

my ($IMAGES);

foreach my $opt ('1','2') {
my $chk;
my $SWITCH = ONO::Lib::UI::Check->switch("filter_student_",$chk,"");
$IMAGES .= qq~<tr>
<td>$SWITCH</td>
<td>...</td>
</tr>
~;
}

$WEB .= qq~<div class="abs" style="top:2px;width:100%;max-width:920px">
<div class="box_fabric" style="padding:5px 10px 5px 10px">
$CONF_BOX_TITLE
<div class="box_paper">
<table class="wide_table">
<tr>
<td class="pad5_2">$BLK{'Title'}:</td>
<td class="pad5_2 w80"><input type="text" name="" value="" class="w95"></td>
<td class="pad5_2">$BLK{'Code'}:</td>
<td class="pad5_2 w20"><input type="text" name="" value="" class="w95"></td>
</tr>
</table>
<div class="inline w100">
<div class="p5 bt bb mb10">Basic Info...</div>
</div>
<div class="inline w100">
<div class="w33 fl">
<div class="pad10_2 br">
<h4 class="col6">Images</h4>
<table class="default_table">
$IMAGES
</table>
main images<br>
add images<br>
verbs<br>
adjectives<br>
optional<br>
display text
</div>
</div>
<div class="w33 fl">
<div class="pad10_2 br">
<h4 class="col6">Instructions</h4>
min words<br>
max words<br>
min pages<br>
max pages<br>
more (enter)
</div>
</div>
<div class="w33 fl">
<div class="pad10_2">
<h4 class="col6">Print Opts</h4>
unique copies<br>
pages<br>
lines<br>
</div>
</div>
</div>
</div>
<div class="inline">
<input type="submit" name="" value="$BLK{'print'}" class="button_green mt10 mb5 ml5">
</div>
</div>
</div>
~;

}

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

my $question_number = ONO::FW::Apps::Core->question_number($vars{'output_web_question_number'});

if ($vars{'app_input_number_of_questions'} > $words_found) {
$vars{'app_input_number_of_questions'} = $words_found;
}

my (
$focus_on,
$page,$pages,%cache,
$whilecounter,$stats_switches,
$PDF_OPTS,
$stat_correct,$stat_wrong,$stat_todo,$stat_todo_total,@letters_lc,@letters_uc,
$longest_word,
);

my $questions_per_page = 20;

if ($vars{'output_paper'} && $vars{'output_web_crosswords_code'}) {

$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'})) {

my $copy = 1;

my @corr_cache;
my $AUTO_SUBMIT;

if ($vars{'output_paper'}) {

if ($copy > 1) {
@WORDLIST = ONO::Lib::Basic->randomize_array(@WORDLIST);
}

$WEB .= qq~<$form>
<input type="hidden" name="output_web_cache_words" value="$CACHE_WORDS">
<input type="hidden" name="output_web_cache_trans" value="$CACHE_TRANS">
<input type="hidden" name="output_web_cache_imgs" value="$CACHE_IMGS">
~;



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

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




}

}

if ($vars{'output_paper'} && $vars{'output_web_crosswords_code'}) {

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

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


}

}

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

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

} else {

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

$WEB .= ONO::FW::Apps::Core->infopics(
"sheet:168:180:110:15:vocabulary_sheet_1.jpg",
"sheet:168:40:140:-10:vocabulary_sheet_1.jpg",
);

if (!$vars{'app_input_number_of_questions'}) {
$vars{'app_input_number_of_questions'} = 20;
if (ONO::IO->device eq "phone") {
$vars{'app_input_number_of_questions'} = 10;
}
}

$vars{'lang_default_setup_config_max_cats'} = 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;

if (!$vars{'ouput_web'} && !$vars{'ouput_paper'}) {
$vars{'app_input_display_images_large'} = 1;
}

my $CONF .= ONO::FW::Apps::ToolBox->conf_input("lang", $BLK_ref,\%vars,"ips","$default[0];en:de:fr$LU");
$CONF .= ONO::FW::Apps::ToolBox->conf_input("spacer", $BLK_ref,\%vars);
$CONF .= ONO::FW::Apps::ToolBox->conf_input("selections", $BLK_ref,\%vars,"Nl",$BLK{'lists'},$default_lessons,$all_lessons,"$BLK{'Add_a_list'}::$custom_lessons");
$CONF .= ONO::FW::Apps::ToolBox->conf_input("difficulty", $BLK_ref,\%vars,"i",5,3);
$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,
"p-d-D",
);

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

$WEB .= qq~<div class="abs large" style="width:430px;top:10px;right:10px">
<img class="block64 fl mr5 mb5" src="/ono/osr/images/icons/crystal/64x64/apps/ktip.png" alt="">
<div class="mt10">$txt[1]</div>
</div>
~;

$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);

my $VARIATION = ONO::FW::Edu::Apps::Variation->variation();
if ($community eq "school") {
$WEB = ONO::Lib::Encoding::HTML->encode($WEB);
}

return $WEB;

}

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

1;

__END__