package ONO::FW::Edu::Apps::Modules::Worksheet;
################################################################################
# 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 Encode;
use ONO::IO;
use ONO::ToolBox::Auth;
use ONO::Lib::Lang::LangKitEdu;
use ONO::FW::Apps::Core;
use ONO::FW::Apps::Core::Graphics;
use ONO::FW::Edu::Apps::Modules::Clock;
use ONO::Lib::UI::Check;
use ONO::Lib::Parser;
use ONO::FW::User::Init;
use ONO::FW::Apps::PDF;
use ONO::FW::Edu::Apps::Manager::ToolBox;
use ONO::Lib::PDF::Gen;
use ONO::Lib::Code::RandomID;
use ONO::Lib::PDF::Draw;
use ONO::Lib::PDF::ToolBox;
use ONO::Lib::Encoding::URL;
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;
ONO::FW::Apps::Core->now("","mksheet",$vars{'app_lang'});
my $mz_font_multiplier = 1.8;
my $action_url = qq~$ENV{'SCRIPT_NAME'}?app_lang=$vars{'app_lang'}&~;
my $form = qq~form action="$ENV{'SCRIPT_NAME'}" method="post">
<input type="hidden" name="app_lang" value="$vars{'app_lang'}"
~;
my ($WEB,$WORK_INFO,$page_switches,%text);
if ($vars{'app_file'}) {
$page_switches .= "C";
}
$BLK{'Empty_Sheets'} = "Empty Sheets";
$text{'info1'} = qq~This web app allows to generate "empty" worksheets filled with lines, grids or cells for example.~;
$text{'info2'} = qq~Alternatively, you may also use our language and math web apps to create worksheets with dedicated content.~;
$text{'gen'} = "Worksheet generators";
$text{'info'} = qq~[b]Individualized[/b] and [b]dynamically generated[/b] worksheets help [b]students to focus on their real needs[/b]
and allow teachers to create a [b]differentiated learning[/b] environment rather than simply "teaching to the middle".
~;
$text{'sheet_empty'} = "No lines, no grids or cells";
$text{'sheet_lines'} = "Text lines";
$text{'sheet_lines2'} = "Text lines with guides";
$text{'sheet_grid'} = "Grid";
$text{'sheet_cells'} = "Cells";
$text{'sheet_mathgrid'} = "Grid cells";
$text{'sheet_mathhouses'} = "Math houses";
$text{'sheet_mathwalls'} = "Math walls";
$text{'sheet_mathclocks'} = "Clocks";
$text{'checklist_1'} = "Completely individualized";
$text{'checklist_2'} = "Including corrections";
$text{'print_img_1'} = "print images";
$text{'print_img_2'} = "found";
if ($vars{'app_lang'} eq "de") {
$BLK{'Empty_Sheets'} = "Leere Blätter";
$text{'info1'} = qq~Diese Web-App ermöglicht es, "leere" Arbeitsblätter zu erstellen, die beispielsweise mit Linien, Rastern oder Zellen gefüllt sind.~;
$text{'info2'} = qq~Alternativ dazu kannst du auch unsere Sprach- und Mathematik-Web-Apps verwenden, um Arbeitsblätter mit dedizierten Inhalten zu erstellen.~;
$text{'gen'} = "Arbeitsblatt generieren";
$text{'info'} = qq~[b]Individualisierte[/b] und [b]dynamisch generierte[/b] Arbeitsblätter helfen den Schülern sich auf ihre [b]wirklichen Bedürfnisse[/b] zu
konzentrieren und erlauben Lehrern eine [b]differenzierte Lernumgebung[/b] zu erschaffen, anstatt sich einfach auf ein "Mittelmaß" zu beschränken.
~;
$text{'sheet_empty'} = "Keine Linien, keine Raster oder Zellen";
$text{'sheet_lines'} = "Textzeilen (Linien)";
$text{'sheet_lines2'} = "Textzeilen (mit Hilfslinien)";
$text{'sheet_grid'} = "Raster";
$text{'sheet_cells'} = "Zellen";
$text{'sheet_mathgrid'} = "Rasterzellen / Tafelrechnungen";
$text{'sheet_mathhouses'} = "Rechenhäuser";
$text{'sheet_mathwalls'} = "Rechenmauern";
$text{'sheet_mathclocks'} = "Uhren";
$text{'checklist_1'} = "Individuell angepasst";
$text{'checklist_2'} = "Inklusive Verbesserungen";
$text{'print_img_1'} = "Bilder drucken";
$text{'print_img_2'} = "gefunden";
}
if ($vars{'app_lang'} eq "fr") {
$BLK{'Empty_Sheets'} = "Fiches vides";
$text{'info1'} = qq~Cette web app permet de générer des feuilles de calcul "vides" remplies de lignes, de grilles ou de cellules par exemple.~;
$text{'info2'} = qq~Alternativement, vous pouvez également utiliser nos applications Web linguistiques et math pour créer des fiches avec un contenu dédié.~;
$text{'gen'} = "Générateurs de fiches";
$text{'info'} = qq~Les fiches [b]individualisées[/b] et [b]générées dynamiquement[/b] aident les étudiants à se [b]concentrer sur leurs besoins réels[b]
et permettent aux enseignants de créer un [b]environnement d'apprentissage différencié[/b] plutôt que de simplement "enseigner au milieu".
~;
$text{'sheet_empty'} = "Pas de lignes, pas de carrés ou cellules";
$text{'sheet_lines'} = "Lignes";
$text{'sheet_lines2'} = "Lignes & aides";
$text{'sheet_grid'} = "Carrés";
$text{'sheet_cells'} = "Cellules";
$text{'sheet_mathgrid'} = "Cellules carrées / calculs écrits";
$text{'sheet_mathhouses'} = "Mathé - maisons";
$text{'sheet_mathwalls'} = "Mathé - murs";
$text{'sheet_mathclocks'} = "Montres";
$text{'checklist_1'} = "Adaptation individuelle";
$text{'checklist_2'} = "Corrections incluses";
$text{'print_img_1'} = "imprimer images";
$text{'print_img_2'} = "trouvées";
}
if ($vars{'app_lang'} eq "lu") {
$BLK{'Empty_Sheets'} = "Eidel Blieder";
$text{'info1'} = qq~Dës Web App erlaabt et "eidel" Aarbechtsblieder ze maachen, zum Beispill mat Zeilen, Gitteren oder Zellen.~;
$text{'info2'} = qq~Alternativ dozou kanns du och eis Sproochen- a Mathe-Web-Apps benotze fir Aarbechtsblieder mat speziellem Inhalt ze generéieren.~;
$text{'gen'} = "Aarbechtsblat generéieren";
$text{'info'} = qq~[b]Individualiséiert[/b] an [b]dynamesch generéiert[/b] Aarbechtsblieder hëllefen de Schüler sech op hir [b]wierklech Besoins[/b] ze
konzentréieren an erlaben et den Enseignanten en [b]differenzéiert Léierëmfeld[/b] ze schafen, amplaz sech einfach op e "Mëttelmooss" ze beschränken.
~;
$text{'sheet_empty'} = "Keng Linnen, kee Raster oder Zellen";
$text{'sheet_lines'} = "Textzeilen (Linnen)";
$text{'sheet_lines2'} = "Textzeilen (mat Hëllefslinnen)";
$text{'sheet_grid'} = "Raster";
$text{'sheet_cells'} = "Zellen";
$text{'sheet_mathgrid'} = "Rasterzellen / Tafelrechnungen";
$text{'sheet_mathhouses'} = "Rechenhaiser";
$text{'sheet_mathwalls'} = "Rechemaueren";
$text{'sheet_mathclocks'} = "Aueren";
$text{'checklist_1'} = "Individuell ugepasst";
$text{'checklist_2'} = "Inklusiv Verbesserungen";
$text{'print_img_1'} = "Biller drécken";
$text{'print_img_2'} = "fonnt";
}
my $CHECKLIST = qq~<ul style="list-style-image:url('/ono/osr/images/icons/crystal/16x16/actions/agt_action_success.png');margin:0px">
<li style="margin-bottom:5px">$text{'checklist_1'}</li>
<li style="margin-bottom:5px">$text{'checklist_2'}</li>
</ul>
~;
my $EXEC = qq~/cgi-bin/local/perl/school/index_elearning.pl?mode=exec&app~;
if (!$vars{'mode'}) {
$vars{'mode'} = "sheet";
$WORK_INFO = qq~<tr class="vtop">
<td><img class="block48 fr mt5" src="/ono/osr/images/icons/crystal/64x64/apps/ktip.png" alt=""></td>
<td><div class="large col6 lh125 mt5 mb5">$text{'info1'}</div><div class="col9 lh125 mb10">$text{'info2'}</div></td>
</tr>
~;
}
if (($vars{'mode'} eq "sheet" || $vars{'mode'} =~ /^sheet_/) && !$vars{'print'}) {
if ($vars{'app_file'}) {
} else {
$WEB .= ONO::FW::Apps::Core->infopics(
"sheet:230:90:0:25:empty_sheet_5.jpg",
"sheet:180:40:40:-5:empty_sheet_3.jpg",
"sheet:200:80:20:5:empty_sheet_1.jpg",
"sheet:140:40:150:-15:empty_sheet_4.jpg",
"sheet:160:80:130:-10:empty_sheet_2.jpg",
);
}
$vars{'mode_selected'} = $vars{'mode'};
if ($vars{'mode'} eq "sheet") {
$vars{'mode_selected'} = "sheet_lines";
}
if ($vars{'app_file'} && !$vars{'title'}) {
$vars{'title'} = $vars{'app_file'};
$vars{'title'} =~ s~^(.*)/~~;
$vars{'title'} =~ s~\.(.*?)$~~;
$vars{'title'} = ucfirst $vars{'title'};
if ($vars{'app_file_title'}) {
$vars{'title'} = ONO::Lib::Encoding::URL->input_decode($vars{'app_file_title'});
}
$vars{'title'} =~ s~_~ ~g;
}
my $FORMAT = ONO::Lib::PDF::ToolBox->format("app_input_paper_format",$BLK_ref,$vars_ref);
my $SWITCH = ONO::Lib::UI::Check->switch("auto_date",1,"r");
my $DESIGN = ONO::FW::Apps::Core->print_design("app_input_print_options_design",$lang,$BLK_ref);
my ($COPIES,$hide_subtitle);
for (my $i = 1; $i < 51; $i++) {
$COPIES .= qq~<option value="$i">$i</option>~;
}
if ($vars{'mode'} eq "sheet") {
$hide_subtitle = "hide";
}
$WEB .= qq~<div class="box_fabric_white_light abs ml10 mt10" style="width:520px">
<img class="block24 fl mr5" src="/ono/osr/images/icons/crystal/32x32/ono/setup.png" alt="">
<h3 class="col6">$BLK{'Configure'}:</h3>
<$form>
<div id="worksheet_print_options" class="box_fabric abs hide" style="width:400px;top:24px;left:24px;z-index:999">
<img class="block24 fl mr5" src="/ono/osr/images/icons/crystal/32x32/ono/print.png" alt="">
<h3 class="col6">$BLK{'Print_options'}</h3>
<div class="box_paper">
<table class="default_table">
<tr>
<td></td>
<td>$FORMAT</td>
</tr>
<tr>
<td><div class="fr"><div class="select"><select name="copies">$COPIES</select></div></div></td>
<td>$BLK{'copies'} / $BLK{'pages'}</td>
</tr>
<tr>
<td>$SWITCH</td>
<td>$BLK{'print_date'}</td>
</tr>
$DESIGN
<tr>
<td></td>
<td><a href="javascript:void(0);" onclick="onojs_hide('worksheet_print_options');" class="button_green">$BLK{'ok'}</a></td>
</tr>
</table>
</div>
</div>
<div class="box_paper">
<input type="hidden" id="app_file_id" name="app_file" value="$vars{'app_file'}">
<input type="hidden" id="app_file_title_id" name="app_file_title" value="$vars{'app_file_title'}">
<table class="default_table">
$WORK_INFO
<tr>
<td class="tar">$BLK{'title'}:</td>
<td class="w100">
<input type="text" id="title_id" name="title" value="$vars{'title'}" class="w90">
</td>
</tr>
<tr class="$hide_subtitle">
<td class="tar">$BLK{'subtitle'}:</td>
<td>
<input type="text" id="subtitle_id" name="subtitle" value="$vars{'subtitle'}" style="width:60%">
</td>
</tr>
~;
if ($vars{'app_file'}) {
my $FILE = $vars{'app_file'};
$FILE =~ s~^(.*)/~~;
$WEB .= qq~ <tr>
<td class="tar">$BLK{'file'}:</td>
<td>$FILE</td>
</tr>
~;
}
my $TYPES = qq~<input type="hidden" id="selector_mode" name="mode" value="$vars{'mode_selected'}">
<script>
function selector(id) {
document.getElementById('selector_mode').value=id;
document.getElementById('selector_sheet_lines').style.backgroundColor='#f6f6f6';
document.getElementById('selector_sheet_lines2').style.backgroundColor='#f6f6f6';
document.getElementById('selector_sheet_grid').style.backgroundColor='#f6f6f6';
document.getElementById('selector_sheet_cells').style.backgroundColor='#f6f6f6';
document.getElementById('selector_sheet_mathhouses').style.backgroundColor='#f6f6f6';
document.getElementById('selector_sheet_mathwalls').style.backgroundColor='#f6f6f6';
document.getElementById('selector_sheet_mathclocks').style.backgroundColor='#f6f6f6';
document.getElementById('selector_'+id).style.backgroundColor='#cceecc';
}
</script>
~;
my $TYPES2 = qq~<script>
function selector2(id) {
var title = document.getElementById('title_id').value;
var subtitle = document.getElementById('subtitle_id').value;
var app_file = document.getElementById('app_file_id').value;
var app_file_title = document.getElementById('app_file_title_id').value;
window.location='$action_url&mode='+id+'&title='+title+'&subtitle='+subtitle+'&app_file='+app_file+'&app_file_title='+app_file_title;
}
</script>
~;
foreach my $type (
'empty',
'lines',
'lines2',
'grid',
'cells',
'mathgrid',
'mathhouses',
'mathwalls',
'mathclocks',
) {
my $hide;
my $color = "f6f6f6";
if (($vars{'mode'} eq "sheet" && $type eq "lines") || $vars{'mode'} eq "sheet_$type") {
$color = "cceecc";
}
my $IMG = "/images/morzino/worksheet_generators/sheet_$type.png";
if ($type eq "empty") {
$hide = " hide";
$IMG = "/ono/osr/images/spacer/trans.gif";
}
my $TYPE = qq~<img class="block50 trans20" src="$IMG" alt="" onmouseover="onojs_block('info_sheet_$type');" onmouseout="onojs_hide('info_sheet_$type');">
<div id="info_sheet_$type" class="abs hide">
<img class="block16 rel" src="/ono/osr/images/arrows/nuvola/white32shadow/nav_up.png" style="bottom:15px;z-index:10" alt="">
<div class="box_white rel" style="z-index:9;bottom:16px;right:10px">$text{"sheet_$type"}</div>
</div>
~;
if ($vars{'app_file'}) {
if ($type eq "empty") {
$hide = "";
}
if ($vars{'mode'} !~ /^sheet_/) {
$vars{'layout'} = "empty";
$vars{'mode'} = "sheet_empty";
if ($type eq "empty") {
$color = "cceecc";
}
}
if ($type !~ /^(empty|lines|lines2|cells)$/) {
$hide = " hide";
}
if ($vars{'app_file'} =~ /\.txt/ && $type eq "cells") {
$hide = " hide";
}
}
$TYPES .= qq~<div id="selector_sheet_$type" class="block50 bo mb5 mr5 fl$hide" style="background-color:#$color" onclick="selector('sheet_$type');">$TYPE</div>~;
$TYPES2 .= qq~<a href="javascript:void(0);" onclick="selector2('sheet_$type');">
<div class="block50 bo mb5 mr5 fl$hide" style="background-color:#$color">$TYPE</div>
</a>
~;
}
if ($vars{'mode'} !~ /^sheet_/) {
$WEB .= qq~ <tr class="vtop">
<td class="tar">$BLK{'type'}:</td>
<td>$TYPES</td>
</tr>
~;
} else {
$WEB .= qq~ <tr class="vtop">
<td class="tar">$BLK{'type'}:</td>
<td>$TYPES2</td>
</tr>
<input type="hidden" name="mode" value="$vars{'mode'}">
~;
}
if ($vars{'mode'} =~ /^sheet_(grid|lines|lines2)$/) {
my $LAYOUT = qq~<input type="hidden" id="selector_layout" name="layout" value="$vars{'layout'}">
<script>
function sellayout(layout) {
document.getElementById('selector_layout').value=layout;
document.getElementById('selector_layout_left').style.backgroundColor='#f6f6f6';
document.getElementById('selector_layout_none').style.backgroundColor='#f6f6f6';
document.getElementById('selector_layout_right').style.backgroundColor='#f6f6f6';
document.getElementById('selector_layout_'+layout).style.backgroundColor='#cceecc';
document.getElementById('selector_layout2_left').style.backgroundColor='#f6f6f6';
document.getElementById('selector_layout2_right').style.backgroundColor='#f6f6f6';
if (layout == 'left' || layout == 'right') {
document.getElementById('selector_layout2_'+layout).style.backgroundColor='#cceecc';
}
}
</script>
~;
foreach my $layout ('left','none','right') {
my $color = "f6f6f6";
if ((!$vars{'layout'} && $layout eq "none") || $vars{'layout'} eq $layout) {
$color = "cceecc";
}
my ($LAYDEMO,$CLASS,$STYLE);
if ($layout ne "none") {
$LAYDEMO = qq~<div id="selector_layout2_$layout" class="block50 abs" style="background-color:#$color;width:17px;top:0px;$layout:0px">
<div style="padding:5px 2px 0px 2px"><div class="bo" style="height:38px"></div></div>
</div>~;
if ($vars{'mode'} eq "sheet_lines2") {
$STYLE = qq~ style="width:34px"~;
if ($layout eq "left") {
$CLASS = " fr";
}
}
}
$LAYOUT .= qq~<div id="selector_layout_$layout" class="block50 bo mr5 fl rel" style="background-color:#$color" onclick="sellayout('$layout');">
<img class="block50 trans20$CLASS" src="/images/morzino/worksheet_generators/$vars{'mode'}.png"$STYLE alt="">
$LAYDEMO
</div>
~;
}
if (!$vars{'app_file'}) {
$WEB .= qq~ <tr class="vtop">
<td class="tar">$BLK{'layout'}:</td>
<td>$LAYOUT</td>
</tr>
~;
}
}
$WEB .= qq~ <tr>
<td class="p5"></td>
<td class="p5"></td>
</tr>
~;
my ($app_data_ref,$app_conf_ref,$app_pdf_x,$app_pdf_y,$app_images,$DEBUG) = &load_app_data("",$vars{'app_file'},$vars{'username'});
my %app_conf = %$app_conf_ref;
if (ONO::IO->devstation) {
$WEB .= qq~ <tr>
<td></td>
<td>$DEBUG</td>
</tr>
~;
}
if ($vars{'mode'} =~ /^sheet_empty$/) {
my %chk;
$chk{'10'} = "selected";
my $SPACING;
for (my $i = 1; $i < 26; $i++) {
$SPACING .= qq~ <option $chk{$i} value="$i">$i mm</option>~;
}
$WEB .= qq~ <tr>
<td class="tar">$BLK{'Spacing'}:</td>
<td class="p0">
<table class="default_table">
<tr>
<td>
<div class="select"><select name="size">
$SPACING
</select></div>
</td>
</tr>
</table>
</td>
</tr>
~;
}
if ($vars{'mode'} =~ /^sheet_(grid|mathgrid|lines|lines2)$/) {
my %chk;
if ($vars{'mode'} =~ /sheet_(grid|mathgrid)/) {
$chk{'5'} = "selected";
}
if ($vars{'mode'} eq "sheet_lines") {
$chk{'10'} = "selected";
}
if ($vars{'mode'} eq "sheet_lines2") {
$chk{'12'} = "selected";
}
my $SPACING;
for (my $i = 1; $i < 26; $i++) {
$SPACING .= qq~ <option $chk{$i} value="$i">$i mm</option>~;
}
$WEB .= qq~ <tr>
<td class="tar">$BLK{'Size'}:</td>
<td class="p0">
<table class="default_table">
<tr>
<td>
<div class="select"><select name="size">
$SPACING
</select></div>
</td>
<td>$BLK{'Line'}:</td>
<td>
<div class="select"><select name="line">
<option value="0.05">0.05 mm</option>
<option value="0.10">0.10 mm</option>
<option value="0.20" selected>0.20 mm</option>
<option value="0.30">0.30 mm</option>
<option value="0.40">0.40 mm</option>
<option value="0.50">0.50 mm</option>
</select></div>
</td>
</tr>
</table>
</td>
</tr>
~;
}
if (($vars{'mode'} =~ /^sheet_(grid|lines|lines2)$/ || $vars{'app_file'} =~ /\.appconf$/) && $vars{'mode'} !~ /^sheet_(cells)$/) {
my $min = 1;
my $max = 3;
my $hide;
if ($vars{'app_file'} =~ /\.txt$/) {
$max = 1;
}
if ($app_conf{"AppConfType"} eq "vocs") {
$min = 2;
$max = 2;
$hide = "hide";
}
my $COLS;
for (my $i = $min; $i < $max+1; $i++) {
$COLS .= qq~<option value="$i">$i</option>~;
}
$WEB .= qq~ <tr class="$hide">
<td>$BLK{'columns'}:</td>
<td><div class="select"><select name="cols">$COLS</select></div></td>
</tr>
~;
}
if ($vars{'mode'} =~ /^sheet_(cells|mathhouses|mathwalls)$/) {
my (%chk1,%chk2);
if (!$vars{'cols'} || !$vars{'rows'}) {
if ($vars{'mode'} =~ /^sheet_(cells)$/) {
$chk1{'2'} = "selected";
$chk2{'10'} = "selected";
}
if ($vars{'mode'} =~ /^sheet_(mathhouses)$/) {
$chk1{'3'} = "selected";
$chk2{'3'} = "selected";
}
if ($vars{'mode'} =~ /^sheet_(mathwalls)$/) {
$chk1{'3'} = "selected";
$chk2{'5'} = "selected";
}
} else {
$chk1{$vars{'cols'}} = "selected";
$chk2{$vars{'rows'}} = "selected";
}
my $min_rows = 1;
my $max_rows = 20;
if ($vars{'mode'} =~ /^sheet_(mathwalls)$/) {
$min_rows = 2;
$max_rows = 5;
}
my $min_cols = 1;
my $max_cols = 5;
if ($app_conf{"AppConfType"} eq "vocs") {
$min_cols = 2;
$max_cols = 2;
}
my ($COLS,$ROWS);
for (my $i = $min_cols; $i < $max_cols+1; $i++) {
$COLS .= qq~ <option $chk1{$i} value="$i">$i</option>~;
}
for (my $i = $min_rows; $i < $max_rows+1; $i++) {
$ROWS .= qq~ <option $chk2{$i} value="$i">$i</option>~;
}
if ($vars{'mode'} =~ /^sheet_(cells|mathhouses)$/) {
$WEB .= qq~ <tr>
<td class="tar">$BLK{'columns'}:</td>
<td class="p0">
<table class="default_table">
<tr>
<td>
<div class="select"><select id="cols" name="cols">
$COLS
</select></div>
</td>
<td>$BLK{'rows'}:</td>
<td>
<div class="select"><select id="rows" name="rows">
$ROWS
</select></div>
</td>
</tr>
</table>
</td>
</tr>
~;
}
if ($vars{'mode'} =~ /^sheet_(mathwalls)$/) {
$WEB .= qq~ <tr>
<td class="tar">$BLK{'rows'}:</td>
<td>
<div class="select"><select id="rows" name="rows">
$ROWS
</select></div>
</td>
</tr>
~;
}
}
if ($app_images) {
my $SWITCH = ONO::Lib::UI::Check->switch("print_images",1,"r");
$WEB .= qq~ <tr>
<td></td>
<td class="p5"></td>
</tr>
<tr>
<td>$SWITCH</td>
<td>$text{'print_img_1'} ($app_images $text{'print_img_2'})</td>
</tr>
~;
}
if ($vars{'mode'} =~ /^sheet_/) {
$WEB .= qq~ <tr>
<td></td>
<td>
<input type="submit" name="output_paper" value="$BLK{'print_worksheet'}" class="button_green mt5">
<a href="javascript:void(0);" onclick="onojs_block('worksheet_print_options');" class="button mt5">$BLK{'print_options'}</a>
<a href="$action_url" class="button_yellow mt5">$BLK{'cancel'}</a>
</td>
</tr>
<input type="hidden" name="print" value="1">
~;
} else {
$WEB .= qq~ <tr>
<td></td>
<td><input type="submit" name="output_paper" value="$BLK{'print_worksheet'}" class="button_green mt5"></td>
</tr>
~;
}
$WEB .= qq~ </table>
</div>
</form>
</div>
~;
}
if ($vars{'mode'} =~ /^sheet_/ && $vars{'print'}) {
# load app file content
my ($app_data_ref,$app_conf_ref,$app_pdf_x,$app_pdf_y,$app_images) = &load_app_data("",$vars{'app_file'},$vars{'username'});
my @app_data = @$app_data_ref;
my %app_conf = %$app_conf_ref;
$vars{'app_conf_type'} = $app_conf{'AppConfType'};
# page setup
$vars{'line'} =~ s~[^0-9\.]~~gi;
if ($vars{'size'} < 1 || $vars{'size'} > 25) {
$vars{'size'} = 10;
}
if ($vars{'cols'} < 1 || $vars{'cols'} > 20) {
$vars{'cols'} = 10;
}
if ($vars{'rows'} < 1 || $vars{'rows'} > 20) {
$vars{'rows'} = 10;
}
# start creating...
ONO::FW::Apps::PDF->new("$BASE/pdf/pdf-$pdfkey.pdf","",$vars{"print_paper_format_status"});
if ($vars{'copies'} < 1 || $vars{'copies'} > 99) {
$vars{'copies'} = 1;
}
for (my $copy = 1; $copy < $vars{'copies'}+1; $copy++) {
# new page
if ($vars{'copies'} > 1) {
if ($copy > 1) {
ONO::FW::Apps::PDF->page("",$format);
}
ONO::Lib::PDF::Draw->text($canvas,130,-20,"$copy / $vars{'copies'}");
if ($copy > 1 && $vars{'mode'} eq "sheet_lines2") {
ONO::Lib::PDF::Draw->font("MZ");
}
}
# headers
ONO::FW::Apps::Core->headers(\%vars,$format,$page_switches);
# ONO::Lib::PDF::ToolBox->canvas_test($canvas);
ONO::FW::Apps::PDF->title($vars{'title'},$vars{'subtitle'},"",$format);
# page layout / content
&page_layout("",$canvas,$format,\%vars);
# print app file content
if ($vars{'app_file'} =~ /\.(appconf|txt)$/) {
($app_pdf_x,$app_pdf_y) = (0,0);
my $line_total = @app_data;
my ($line_count,$DEBUG);
my $line_height = $vars{'size'};
my $line_font_offset = 1;
my $para_offset = 2;
my $font_size = 12;
if ($vars{'mode'} eq "sheet_lines2") {
$line_height = $vars{'size'}*2;
$line_font_offset = $vars{'size'}*1.33;
$para_offset = 1;
$font_size = $vars{'size'}*$mz_font_multiplier;
$app_pdf_x = 1;
}
if ($font_size != 12) {
ONO::Lib::PDF::Draw->font("",$font_size);
}
my @cp = ONO::Lib::PDF::ToolBox->canvas_split($canvas);
my $max_x = $cp[3];
my $max_y = $cp[4]-($line_height*1.5)+$line_font_offset;
if ($vars{'print_images'}) {
# $max_y = $max_y-$line_height/2;
}
if ($vars{'app_file'} =~ /\.txt$/ || $app_conf{"AppConfType"} eq "sentences") {
# if (ONO::IO->devstation) {
# ONO::Lib::PDF::Draw->font("DY");
# }
if ($vars{'mode'} eq "sheet_lines2") {
ONO::Lib::PDF::Draw->font("MZ");
}
foreach my $line (@app_data) {
my $print_line;
my $valid_line = 1;
if ($app_conf{"AppConfType"} eq "sentences") {
$valid_line = 0;
if ($line =~ m~^"(.*)"~) {
$line = $1;
$line =~ s~"~"~g;
$valid_line = 1;
}
}
if ($valid_line) {
foreach my $word (split(/ /,$line)) {
if (ONO::Lib::PDF::Draw->string_width("$print_line $word","",$font_size) > $max_x) {
if ($app_pdf_y > $max_y) {
&page_new("",$canvas,$format,$font_size,$copy,\%vars,$BASE,$page_switches);
$app_pdf_y = 0;
if ($vars{'mode'} eq "sheet_lines2") {
ONO::Lib::PDF::Draw->font("MZ");
}
}
$print_line =~ s~^ ~~;
ONO::Lib::PDF::Draw->text($canvas,$app_pdf_x,$app_pdf_y+$line_height-$line_font_offset,$print_line,"","","-","","","",$font_size);
$print_line = $word;
$app_pdf_y = $app_pdf_y + $line_height;
} else{
$print_line .= " $word";
}
}
if ($print_line) {
if ($app_pdf_y > $max_y) {
&page_new("",$canvas,$format,$font_size,$copy,\%vars,$BASE,$page_switches);
$app_pdf_y = 0;
if ($vars{'mode'} eq "sheet_lines2") {
ONO::Lib::PDF::Draw->font("MZ");
}
}
$print_line =~ s~^ ~~;
ONO::Lib::PDF::Draw->text($canvas,$app_pdf_x,$app_pdf_y+$line_height-$line_font_offset,$print_line,"","","-","","","",$font_size);
}
$app_pdf_y = $app_pdf_y + $line_height*$para_offset;
}
}
}
if ($vars{'app_file'} =~ /\.appconf$/ && $app_conf{"AppConfType"} ne "sentences") {
if ($vars{'mode'} eq "sheet_lines2") {
ONO::Lib::PDF::Draw->font("MZ");
}
my $col = 1;
my $max_y_add = 0;
my $pdf_x_off = 0;
my $pdf_x_img = 0;
my $counter;
if ($vars{'mode'} eq "sheet_lines") {
$max_y_add = $line_height;
}
if ($vars{'mode'} eq "sheet_lines2") {
$pdf_x_off = 1;
}
if ($vars{'mode'} eq "sheet_cells") {
$line_height = 190/$vars{'rows'};
$line_font_offset = $line_height/2.2;
$pdf_x_off = 5;
}
if ($vars{'print_images'}) {
$pdf_x_img = $line_height+1;
}
foreach my $line (@app_data) {
if ($line =~ m~^"(.*?)"~) {
my $print_line = $1;
$print_line =~ s~^ ~~;
$print_line =~ s~ $~~;
$counter++;
if ($app_pdf_y > $max_y + $max_y_add) {
if ($vars{'cols'} == 1 || $col == $vars{'cols'}) {
&page_new("",$canvas,$format,$font_size,$copy,\%vars,$BASE,$page_switches);
if ($vars{'mode'} eq "sheet_lines2") {
ONO::Lib::PDF::Draw->font("MZ");
}
$col = 1;
$app_pdf_x = 0;
$app_pdf_y = 0;
} else {
$col++;
$app_pdf_x = $app_pdf_x + ($max_x/$vars{'cols'})*1.06;
$app_pdf_y = 0;
}
}
if ($vars{'mode'} eq "sheet_cells") {
if ($col == 1) {
$pdf_x_off = 5;
}
if ($col == 2) {
if ($vars{'cols'} == 2) {
$pdf_x_off = 0;
}
if ($vars{'cols'} == 3) {
$pdf_x_off = 1;
}
}
if ($col == 3) {
$pdf_x_off = -2;
}
}
my $img_printed;
if ($vars{'print_images'}) {
if ($app_conf{"AppConfType"} eq "words") {
if ($line =~ /^"(.*?)","(.*?)"/ && $line !~ /"0000"/) {
my $img = $2;
if (ONO::IO->exists("images/pix/preview/rgb/$img.jpg")) {
my ($img_x,$img_y) = &img_xy("",$col,$max_x,$app_pdf_y,$line_height,$line_font_offset,$vars_ref);
ONO::Lib::PDF::Draw->image($canvas,$img_x, $img_y, $line_height-2,$line_height-2,"images/pix/preview/rgb/$img.jpg",1,2);
$img_printed++;
}
} else {
if ($line =~ /^"(.*?)"/) {
my $CUSTOM_FILE = ONO::FW::Edu::Apps::Manager::ToolBox->img_detect_custom_file($1);
if (ONO::IO->exists("$app_conf{'custom_img_dir'}/$CUSTOM_FILE")) {
my ($img_x,$img_y) = &img_xy("",$col,$max_x,$app_pdf_y,$line_height,$line_font_offset,$vars_ref);
ONO::Lib::PDF::Draw->image($canvas,$img_x, $img_y, $line_height-2,$line_height-2,"$app_conf{'custom_img_dir'}/$CUSTOM_FILE",1,2);
$img_printed++;
}
}
}
}
if ($app_conf{"AppConfType"} eq "vocs") {
if ($line =~ /^"(.*?)","(.*?)","(.*?)"/ && $line !~ /"0000"/) {
my $img = $3;
if (ONO::IO->exists("images/pix/preview/rgb/$img.jpg")) {
my ($img_x,$img_y) = &img_xy("",$col,$max_x,$app_pdf_y,$line_height,$line_font_offset,$vars_ref);
ONO::Lib::PDF::Draw->image($canvas,$img_x, $img_y, $line_height-2,$line_height-2,"images/pix/preview/rgb/$img.jpg",1,2);
$img_printed++;
}
} else {
if ($line =~ /^"(.*?)","(.*?)"/) {
my $CUSTOM_FILE = ONO::FW::Edu::Apps::Manager::ToolBox->img_detect_custom_file($1);
if (ONO::IO->exists("$app_conf{'custom_img_dir'}/$CUSTOM_FILE")) {
my ($img_x,$img_y) = &img_xy("",$col,$max_x,$app_pdf_y,$line_height,$line_font_offset,$vars_ref);
ONO::Lib::PDF::Draw->image($canvas,$img_x, $img_y, $line_height-2,$line_height-2,"$app_conf{'custom_img_dir'}/$CUSTOM_FILE",1,2);
$img_printed++;
}
}
}
}
}
if ($app_conf{"AppConfType"} eq "words" || $app_conf{"AppConfType"} eq "verbs") {
ONO::Lib::PDF::Draw->text($canvas,$app_pdf_x+$pdf_x_off+$pdf_x_img,$app_pdf_y+$line_height-$line_font_offset,$print_line,"","","-","","","",$font_size);
}
if ($app_conf{"AppConfType"} eq "vocs" && $line =~ /^"(.*?)","(.*?)"/) {
my $print_line_2 = $2;
$print_line_2 =~ s~^ ~~;
$print_line_2 =~ s~ $~~;
my $pdf_x_off_2 = $pdf_x_off;
if ($vars{'mode'} eq "sheet_lines" || $vars{'mode'} eq "sheet_lines2") {
$pdf_x_off_2 = $pdf_x_off + 5;
}
if ($vars{'print_images'} && $vars{'mode'} eq "sheet_cells") {
$pdf_x_off_2 = -5;
}
ONO::Lib::PDF::Draw->text($canvas,$app_pdf_x+$pdf_x_off+$pdf_x_img, $app_pdf_y+$line_height-$line_font_offset,$print_line,"","","-","","","",$font_size);
ONO::Lib::PDF::Draw->text($canvas,$app_pdf_x+$pdf_x_off_2+$pdf_x_img+$max_x/2, $app_pdf_y+$line_height-$line_font_offset,$print_line_2,"","","-","","","",$font_size);
}
$app_pdf_y = $app_pdf_y + $line_height;
if ($app_conf{"AppConfType"} eq "vocs" && $app_pdf_y > $max_y) {
&page_new("",$canvas,$format,$font_size,$copy,\%vars,$BASE,$page_switches);
$app_pdf_x = 0;
$app_pdf_y = 0;
}
}
}
}
}
}
ONO::FW::Apps::PDF->end;
$WEB .= ONO::FW::Apps::Core->output_paper($pdfkey,\%BLK,\%vars,$HTTP,$BASE);
}
my ($status,$WEB) = ONO::Lib::Parser->parse($WEB,$vars_ref);
$WEB .= ONO::FW::Apps::Core->vardump(\%vars);
$WEB = ONO::FW::Edu::Apps::ToolBox->apps_gate($WEB,$vars_ref);
return $WEB;
}
sub img_xy {
my (
$self,
$col,
$max_x,
$app_pdf_y,
$line_height,
$line_font_offset,
$vars_ref,
) = @_;
my %vars = %$vars_ref;
my $img_x = ($max_x/$vars{'cols'})*($col-1);
my $img_y = $app_pdf_y+$line_height/2-$line_font_offset;
if ($vars{'mode'} eq "sheet_cells") {
$img_x++
}
if ($col == 2 && $vars{'mode'} ne "sheet_cells") {
if ($vars{'cols'} == 2) {
$img_x = $img_x + 5;
}
if ($vars{'cols'} == 3) {
$img_x = $img_x + 3;
}
}
if ($col == 3 && $vars{'mode'} ne "sheet_cells") {
$img_x = $img_x + 7;
}
return ($img_x,$img_y);
}
sub load_app_data {
my (
$self,
$app_file,
$username,
) = @_;
my (@app_data,%app_conf,$app_pdf_x,$app_pdf_y,$app_images,$DEBUG);
$DEBUG = "debug: load_app_data: no such file";
if ($app_file =~ m~^media/(.*)\.(appconf|txt)$~ && ONO::IO->exists($app_file)) {
my ($CUSTOM_DIR,$virclass);
if ($app_file =~ m~^media/virclass/(.*?)/~) {
$virclass = $1;
}
$DEBUG = "debug: load_app_data: file exists, username = $username, virclass = $virclass";
@app_data = ONO::IO->list($app_file);
if ($app_file =~ /\.appconf$/) {
foreach my $line (@app_data) {
if ($line =~ /^AppConf(.*?) "(.*?)"/) {
$app_conf{"AppConf$1"} = $2;
}
if (!$CUSTOM_DIR) {
if ($line =~ /^AppConfLang "(.*?)"/) {
$CUSTOM_DIR = ONO::FW::Edu::Apps::Manager::ToolBox->img_detect_custom_dir($1,$username,$virclass);
}
if ($line =~ /^AppConfLang1 "(.*?)"/) {
$CUSTOM_DIR = ONO::FW::Edu::Apps::Manager::ToolBox->img_detect_custom_dir($1,$username,$virclass);
}
if ($CUSTOM_DIR) {
$app_conf{'custom_img_dir'} = $CUSTOM_DIR;
$DEBUG .= ", custom dir = $CUSTOM_DIR";
}
}
if ($app_conf{"AppConfType"} eq "words") {
if ($line =~ /^"(.*?)","(.*?)"/) {
my $word = $1;
my $img = $2;
if ($word =~ /[A-Za-z]/) {
if ($img =~ /[0-9]/) {
$app_images++;
}
}
} else {
if ($CUSTOM_DIR && $line =~ /^"(.*?)"/) {
my $CUSTOM_FILE = ONO::FW::Edu::Apps::Manager::ToolBox->img_detect_custom_file($1);
if (ONO::IO->exists("$CUSTOM_DIR/$CUSTOM_FILE")) {
$app_images++;
$DEBUG .= ", custom img: $CUSTOM_FILE";
}
}
}
}
if ($app_conf{"AppConfType"} eq "vocs") {
if ($line =~ /^"(.*?)","(.*?)","(.*?)"/) {
my $word1 = $1;
my $word2 = $2;
my $img = $3;
if ($word1 =~ /[A-Za-z]/ && $word2 =~ /[A-Za-z]/) {
if ($img =~ /[0-9]/) {
$app_images++;
}
}
} else {
if ($CUSTOM_DIR && $line =~ /^"(.*?)","(.*?)"/) {
my $CUSTOM_FILE = ONO::FW::Edu::Apps::Manager::ToolBox->img_detect_custom_file($1);
if (ONO::IO->exists("$CUSTOM_DIR/$CUSTOM_FILE")) {
$app_images++;
$DEBUG .= ", custom img: $CUSTOM_FILE";
}
}
}
}
}
}
}
return (\@app_data,\%app_conf,$app_pdf_x,$app_pdf_y,$app_images,$DEBUG)
}
sub page_new {
my (
$self,
$canvas,
$format,
$font_size,
$copy,
$vars_ref,
$BASE,
$switches,
) = @_;
my %vars = %$vars_ref;
ONO::FW::Apps::PDF->page("",$format);
ONO::FW::Apps::Core->headers(\%vars,$format,$switches);
# ONO::Lib::PDF::ToolBox->canvas_test($canvas);
ONO::FW::Apps::PDF->title($vars{'title'},$vars{'subtitle'},"",$format);
if ($vars{'copies'} > 1) {
ONO::Lib::PDF::Draw->text($canvas,130,-20,"$copy / $vars{'copies'}");
}
&page_layout("",$canvas,$format,\%vars);
if ($font_size != 12) {
ONO::Lib::PDF::Draw->font("",$font_size);
}
}
sub page_layout {
my (
$self,
$canvas,
$format,
$vars_ref,
) = @_;
my %vars = %$vars_ref;
# layout
if ($vars{'mode'} =~ /^sheet_(lines|lines2|grid)$/ && $vars{'layout'} =~ /^(left|right)$/) {
my @coords = (0,0,70,190);
if ($vars{'layout'} eq "right") {
@coords = (100,0,170,190);
}
ONO::Lib::PDF::Draw->rect($canvas,@coords);
}
# grid
if ($vars{'mode'} eq "sheet_grid") {
my ($max_h,$max_v,$whilecounter,$offset_x,$offset_x2);
if ($vars{'layout'} eq "left") {
$offset_x = 80;
}
if ($vars{'layout'} eq "right") {
$offset_x2 = 80;
}
while ($max_h < 170 && $whilecounter < 1024) {
$whilecounter++;
$max_h = $max_h + $vars{'size'};
}
while ($max_v < 190 && $whilecounter < 1024) {
$whilecounter++;
$max_v = $max_v + $vars{'size'};
}
ONO::Lib::PDF::Draw->rect($canvas,0+$offset_x,0,$max_h-$offset_x2,$max_v,$vars{'line'});
for (my $h = $vars{'size'}; $h < 190; $h=$h+$vars{'size'}) {
ONO::Lib::PDF::Draw->line($canvas,0+$offset_x,$h,$max_h-$offset_x2,$h,$vars{'line'});
for (my $v = $vars{'size'} + $offset_x; $v < 170-$offset_x2; $v=$v+$vars{'size'}) {
ONO::Lib::PDF::Draw->line($canvas,$v,0,$v,$max_v,$vars{'line'});
}
}
}
# math grid
if ($vars{'mode'} eq "sheet_mathgrid") {
my ($max_h,$max_v,$whilecounter);
while ($max_h < 46 && $whilecounter < 1024) {
$whilecounter++;
$max_h = $max_h + $vars{'size'};
}
while ($max_v < 36 && $whilecounter < 1024) {
$whilecounter++;
$max_v = $max_v + $vars{'size'};
}
for (my $x = 0; $x < 3; $x++) {
for (my $y = 0; $y < 4; $y++) {
my $lim_x = $x*60+$max_h;
my $lim_y = $y*50+$max_v;
my $whilecounter;
while ($lim_x > 170 && $whilecounter < 1024) {
$whilecounter++;
$lim_x = $lim_x - $vars{'size'};
}
while ($lim_y > 190 && $whilecounter < 1024) {
$whilecounter++;
$lim_y = $lim_y - $vars{'size'};
}
ONO::Lib::PDF::Draw->rect($canvas,$x*60,$y*50,$lim_x,$lim_y,$vars{'line'});
for (my $h = $y*50+$vars{'size'}; $h < $lim_y; $h = $h + $vars{'size'}) {
ONO::Lib::PDF::Draw->line($canvas,$x*60,$h,$lim_x,$h,$vars{'line'});
}
for (my $v = $x*60+$vars{'size'}; $v < $lim_x; $v = $v + $vars{'size'}) {
ONO::Lib::PDF::Draw->line($canvas,$v,$y*50,$v,$lim_y,$vars{'line'});
}
}
}
}
# lines
if ($vars{'mode'} eq "sheet_lines") {
my ($start,$end,$length,$tosub) = &_col_lay_calc("",$vars_ref);
for (my $c = 0; $c < $vars{'cols'}; $c++) {
my $from = $start;
my $to = $end;
if ($vars{'cols'} > 1) {
$from = $from + int($length/$vars{'cols'})*$c;
$to = $to + int($length/$vars{'cols'})*($c+1)-10;
}
for (my $i = $vars{'size'}; $i < 190; $i = $i + $vars{'size'}) {
ONO::Lib::PDF::Draw->line($canvas,$from,$i,$to-$tosub,$i,$vars{'line'});
}
}
}
# lines2
if ($vars{'mode'} eq "sheet_lines2") {
my ($start,$end,$length,$tosub) = &_col_lay_calc("",$vars_ref);
for (my $c = 0; $c < $vars{'cols'}; $c++) {
my $from = $start;
my $to = $end;
if ($vars{'cols'} > 1) {
$from = $from + int($length/$vars{'cols'})*$c;
$to = $to + int($length/$vars{'cols'})*($c+1)-10;
}
for (my $i = 0; $i < 180; $i = $i + $vars{'size'}*2) {
ONO::Lib::PDF::Draw->eduline($canvas,$from,$i,$to-$tosub,$vars{'size'},$vars{'line'});
}
}
}
# cells
if ($vars{'mode'} eq "sheet_cells") {
my $start_x = 0;
my $start_y = 0;
my $length_x = 170;
my $length_y = 190;
if ($vars{'print_images'} && $vars{'app_conf_type'} eq "vocs") {
$start_x = $vars{'size'}*2;
}
for (my $i = 0; $i < $vars{'rows'}+1; $i++) {
my $y = ($length_y/$vars{'rows'})*$i;
ONO::Lib::PDF::Draw->line($canvas,$start_x,$y,$length_x,$y,$vars{'line'});
}
for (my $i = 0; $i < $vars{'cols'}+1; $i++) {
my $x = $start_x+(($length_x-$start_x)/$vars{'cols'})*$i;
ONO::Lib::PDF::Draw->line($canvas,$x,$start_y,$x,$length_y,$vars{'line'});
}
}
# math - houses and walls
if ($vars{'mode'} =~ /^sheet_math(houses|walls)$/) {
my ($num_h,$num_v) = (3,3);
if ($vars{'mode'} eq "sheet_mathhouses") {
if ($vars{'rows'} > 4) {
$num_h = 2;
}
if ($vars{'rows'} > 8) {
$num_h = 1;
}
}
if ($vars{'mode'} eq "sheet_mathwalls") {
($num_h,$num_v) = (5,4);
if ($vars{'rows'} > 2) {
($num_h,$num_v) = (5,3);
}
if ($vars{'rows'} > 3) {
($num_h,$num_v) = (5,2);
}
if ($vars{'rows'} > 4) {
($num_h,$num_v) = (4,2);
}
}
for (my $h = 0; $h < $num_h; $h++) {
for (my $v = 0; $v < $num_v; $v++) {
if ($vars{'mode'} eq "sheet_mathhouses") {
ONO::FW::Apps::Core::Graphics->pdf_draw_house($canvas,170/$num_v*$v,190/$num_h*$h,"$vars{'cols'}:$vars{'rows'}");
}
if ($vars{'mode'} eq "sheet_mathwalls") {
ONO::FW::Apps::Core::Graphics->pdf_draw_wall($canvas,170/$num_v*$v,190/$num_h*$h,$vars{'rows'},"","","","pdf");
}
}
}
}
# math - clocks
if ($vars{'mode'} =~ /^sheet_mathclocks$/) {
my @clocks = (3,4);
for (my $x = 0; $x < $clocks[0]; $x++) {
for (my $y = 0; $y < $clocks[1]; $y++) {
ONO::Lib::PDF::Draw->embed_pdf($canvas,$x*68,$y*48+15,"ono-data/school/pdf/clock.pdf",0.155,"",$format);
}
}
for (my $x = 0; $x < $clocks[0]; $x++) {
for (my $y = 0; $y < $clocks[1]; $y++) {
my $x1 = $x*68+16.22;
my $y1 = $y*48+15.11;
# my ($use_hour,$use_min) = (0,0);
# my ($x2h,$y2h,$x2m,$y2m) = ONO::FW::Edu::Apps::Modules::Clock->handmath($x1,$y1,$use_hour,$use_min);
# ONO::Lib::PDF::Draw->line($canvas,$x1,$y1,$x2h,$y2h,2.2);
# ONO::Lib::PDF::Draw->line($canvas,$x1,$y1,$x2m,$y2m,1);
ONO::Lib::PDF::Draw->text($canvas,$x*68+16,$y*48+37,"...... : ......","center");
if ($vars{"app_input_24h"}) {
ONO::Lib::PDF::Draw->text($canvas,$x1,$y1+28,"...... : ......","center");
}
}
}
}
}
sub _col_lay_calc {
my $vars_ref = $_[1];
my %vars = %$vars_ref;
my $start = 0;
my $end = 170;
my $tosub = 0;
if ($vars{'layout'} eq "left") {
$start = 80;
}
if ($vars{'layout'} eq "right") {
$end = 90;
}
if ($vars{'cols'} > 1) {
$tosub = 90;
if ($vars{'layout'} ne "left" && $vars{'layout'} ne "right") {
$tosub = 170;
}
}
my $length = $end - $start;
if ($vars{'cols'} > 1) {
$length = $length + 10;
}
if ($vars{'print_images'}) {
$start = $start + $vars{'size'};
if ($vars{'mode'} eq "sheet_lines2") {
$start = $start + $vars{'size'};
}
}
return ($start,$end,$length,$tosub);
}
###################################################################
#### THAT'S IT :-D
###################################################################
1;
__END__