generated from mirzaev/pot
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
cda2d0bcb9 | |||
1708965be2 | |||
12877873b7 |
@@ -243,7 +243,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";
|
||||||
|
|
||||||
@@ -283,7 +282,7 @@ final class interneturok extends core
|
|||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return ['downloads' => ['year' => $year], 'files' => $files];
|
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') {
|
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]);
|
||||||
@@ -811,16 +821,16 @@ final class interneturok extends core
|
|||||||
// Exit (fail)
|
// Exit (fail)
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
function ($response) use ($homework) {
|
function ($exception) use ($homework) {
|
||||||
if ($response->getStatusCode() === 402) {
|
if ($exception->getResponse()?->getStatusCode() === 402) {
|
||||||
// Fail (received the "Payment Required" status code)
|
// Fail (received the "Payment Required" status code)
|
||||||
|
|
||||||
// Writing into the output buffer
|
// Writing into the output buffer
|
||||||
echo "Не удалось скачать домашнее задание $homework потому, что не оплачен тариф\n";
|
echo "Не удалось скачать домашнее задание $homework потому, что не оплачен тариф\n";
|
||||||
|
|
||||||
// Exit (fail)
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exit (fail)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -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));
|
||||||
|
Reference in New Issue
Block a user