Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
georgmaisser committed Oct 13, 2023
1 parent 2ee00f2 commit 3e819b7
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
$PAGE->set_context($context);
require_login();

require_capability('local/catquiz:manage_catscales', $context);

$PAGE->set_url(new moodle_url('/local/catquiz/test.php', []));

$title = "Test cases";
Expand All @@ -54,9 +52,6 @@
$username = $sftpusername;
$password = $sftppassword;

// Local directory to save downloaded files
$localdir = $CFG->dataroot . '/temp/' . $did . '/';

$server = $sftpserver;

$remotedir = $sftppath;
Expand Down Expand Up @@ -95,9 +90,6 @@
// Download the file.
$filedata = curl_exec($filehandle);

// Todo: get context.
$context = context_module::instance(1);

if ($filedata !== false) {

// TODO: Store Data in Moodle.
Expand All @@ -107,7 +99,7 @@
$file = $fs->create_file_from_string(
[
'contextid' => $context->id, // Replace with the appropriate context if necessary.
'component' => 'user',
'component' => 'datalynx',
'filearea' => 'draft',
'itemid' => $draftitemid,
'filepath' => '/',
Expand All @@ -116,30 +108,14 @@
$filedata
);

echo "Downloaded $file successfully." . PHP_EOL;
echo "Downloaded successfully." . PHP_EOL;
} else {
echo "Failed to download $file." . PHP_EOL;
echo "Failed to download ." . PHP_EOL;
}

curl_close($filehandle);
}
}
}

curl_close($ch);

if (!is_dir($localdir)) {
// Create the directory if it doesn't exist
if (!mkdir($localdir)) {
// Handle directory creation error (e.g., display an error message)
throw new Exception('Error creating directory');
}
}
$filenames = scandir($localdir);
if ($filenames) {
return $filenames;
} else {
return [];
}

echo $OUTPUT->footer();

0 comments on commit 3e819b7

Please sign in to comment.