1
0
generated from mirzaev/pot

3 Commits
1.1.0 ... 1.1.3

2 changed files with 29 additions and 19 deletions

View File

@@ -243,7 +243,6 @@ final class interneturok extends core
if ($homework->status === 'checked' && $homework->mark === 5) {
// Homework checked and completed for a grade of 5
// Writing into the output buffer
echo "Найдено домашнее задание: $homework->item_id с оценкой $homework->mark\n";
@@ -283,7 +282,7 @@ final class interneturok extends core
// Exit (success)
return ['downloads' => ['year' => $year], 'files' => $files];
}
}
}
}
}
@@ -778,8 +777,19 @@ final class interneturok extends core
if ($attachment->uploader_role === 'student' && $attachment->attachable_type === 'Result::Homework') {
// 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
$path = $storage . DIRECTORY_SEPARATOR . $attachment->attach_path;
$path = $storage . DIRECTORY_SEPARATOR . ($name ?? uniqid() . '.jpg');
// Downloading the file
$this->browser->request('GET', $attachment->attach, ['sink' => $path]);
@@ -811,16 +821,16 @@ final class interneturok extends core
// Exit (fail)
return false;
},
function ($response) use ($homework) {
if ($response->getStatusCode() === 402) {
function ($exception) use ($homework) {
if ($exception->getResponse()?->getStatusCode() === 402) {
// Fail (received the "Payment Required" status code)
// Writing into the output buffer
echo "Не удалось скачать домашнее задание $homework потому, что не оплачен тариф\n";
// Exit (fail)
return false;
}
// Exit (fail)
return false;
}
);
}

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