1
0
Fork 0

fixed file names and button listeners

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2025-03-08 21:42:01 +07:00
parent 12877873b7
commit 1708965be2
2 changed files with 25 additions and 14 deletions

View File

@ -176,7 +176,8 @@ final class interneturok extends core
if (!empty($accounts)) { if (!empty($accounts)) {
// Initialized accounts // Initialized accounts
if (shuffle($accounts)) { /* if (shuffle($accounts)) { */
if (true) {
// Shuffled accounts // Shuffled accounts
foreach ($accounts as $account) { foreach ($accounts as $account) {
@ -243,7 +244,6 @@ final class interneturok extends core
if ($homework->status === 'checked' && $homework->mark === 5) { if ($homework->status === 'checked' && $homework->mark === 5) {
// Homework checked and completed for a grade of 5 // Homework checked and completed for a grade of 5
// Writing into the output buffer // Writing into the output buffer
echo "Найдено домашнее задание: $homework->item_id с оценкой $homework->mark\n"; echo "Найдено домашнее задание: $homework->item_id с оценкой $homework->mark\n";
@ -778,8 +778,19 @@ final class interneturok extends core
if ($attachment->uploader_role === 'student' && $attachment->attachable_type === 'Result::Homework') { if ($attachment->uploader_role === 'student' && $attachment->attachable_type === 'Result::Homework') {
// Found the homework attachment // Found the homework attachment
// Searching for number of the attachment and the file extension
preg_match('/^(\d+).*(\.\w{3,4})$/', $attachment->attach_path, $matches);
try {
// Initializing the name of the attachment file
$name = $matches[1] . $matches[2];
} catch (exception $exception) {
// Initializing the name of the attachment file
$name = uniqid() . '.jpg';
}
// Initializing path to the downloaded file // Initializing path to the downloaded file
$path = $storage . DIRECTORY_SEPARATOR . $attachment->attach_path; $path = $storage . DIRECTORY_SEPARATOR . ($name ?? uniqid() . '.jpg');
// Downloading the file // Downloading the file
$this->browser->request('GET', $attachment->attach, ['sink' => $path]); $this->browser->request('GET', $attachment->attach, ['sink' => $path]);

View File

@ -80,15 +80,8 @@ for ($i = 4; $i <= 11; ++$i) {
$robot->onCbQueryData(["grade_$i"], fn(context $context) => parser::grade(context: $context, grade: $i)); $robot->onCbQueryData(["grade_$i"], fn(context $context) => parser::grade(context: $context, grade: $i));
} }
for ($i = 2; $i <= 9; ++$i) { for ($i = 32; $i <= 38; ++$i) {
// Generating buttons from 2 to 9 numbers of weeks // Generating buttons from 32 to 38 numbers of weeks
// Initializing numbers of weeks buttons
$robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i));
}
for ($i = 11; $i <= 18; ++$i) {
// Generating buttons from 11 to 18 numbers of weeks
// Initializing numbers of weeks buttons // Initializing numbers of weeks buttons
$robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i)); $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i));
@ -101,8 +94,15 @@ for ($i = 21; $i <= 30; ++$i) {
$robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i)); $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i));
} }
for ($i = 32; $i <= 38; ++$i) { for ($i = 11; $i <= 18; ++$i) {
// Generating buttons from 32 to 38 numbers of weeks // Generating buttons from 11 to 18 numbers of weeks
// Initializing numbers of weeks buttons
$robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i));
}
for ($i = 2; $i <= 9; ++$i) {
// Generating buttons from 2 to 9 numbers of weeks
// Initializing numbers of weeks buttons // Initializing numbers of weeks buttons
$robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i)); $robot->onCbQueryData(["week_$i"], fn(context $context) => parser::date(context: $context, week: $i));