forked from trampgeek/moodle-qtype_coderunner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress on scheduled grading cache purging and scripts for purging b…
…y course. Also contains new functionality in bulktester (eg, nruns setting) and updates to the Coderunner settings.php
- Loading branch information
Showing
17 changed files
with
547 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
// This file is part of CodeRunner - http://coderunner.org.nz | ||
// | ||
// CodeRunner is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// CodeRunner 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. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with CodeRunner. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* This script runs all the question tests for all deployed versions of all | ||
* questions in a given context and, optionally, a given question category. | ||
* It is a modified version of the script from the qtype_stack plugin. | ||
* | ||
* @package qtype_coderunner | ||
* @copyright 2016 Richard Lobb, The University of Canterbury | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace qtype_coderunner; | ||
|
||
use context; | ||
|
||
define('NO_OUTPUT_BUFFERING', true); | ||
|
||
require_once(__DIR__ . '/../../../config.php'); | ||
// require_once($CFG->libdir . '/questionlib.php'); | ||
|
||
|
||
|
||
// Get the parameters from the URL. | ||
$contextid = required_param('contextid', PARAM_INT); | ||
$usettl = required_param('usettl', PARAM_INT); // 1 for use, 0 for don't use. | ||
|
||
// Login and check permissions. | ||
$context = context::instance_by_id($contextid); | ||
require_login(); | ||
require_capability('moodle/question:editall', $context); | ||
$PAGE->set_url('/question/type/coderunner/cachepurge.php', ['contextid' => $context->id, 'useTTL' => $usettl]); | ||
$PAGE->set_context($context); | ||
$title = 'Purging cache for ' . $context->get_context_name(); //get_string('bulktesttitle', 'qtype_coderunner', $context->get_context_name()); | ||
$PAGE->set_title($title); | ||
|
||
|
||
|
||
// Release the session, so the user can do other things while this runs. | ||
\core\session\manager::write_close(); | ||
|
||
// Create the helper class. | ||
$purger = new cache_purger(); | ||
|
||
|
||
echo $OUTPUT->header(); | ||
echo $OUTPUT->heading($title, 4); | ||
|
||
$purger->purge_cache_for_context($context->id, $usettl); | ||
|
||
|
||
echo $OUTPUT->footer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
// This file is part of CodeRunner - http://coderunner.org.nz | ||
// | ||
// CodeRunner is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// CodeRunner 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. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Stack. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* This script provides an index for purging grading cache entries by course. | ||
* | ||
* @package qtype_coderunner | ||
* @copyright 2024 Paul McKeown, The University of Canterbury | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace qtype_coderunner; | ||
|
||
use context_system; | ||
use context; | ||
use html_writer; | ||
use moodle_url; | ||
|
||
|
||
require_once(__DIR__ . '/../../../config.php'); | ||
require_once($CFG->libdir . '/questionlib.php'); | ||
|
||
// Login and check permissions. | ||
$context = context_system::instance(); | ||
require_login(); | ||
|
||
$PAGE->set_url('/question/type/coderunner/cachepurgeindex.php'); | ||
$PAGE->set_context($context); | ||
$PAGE->set_title('Coderunner Cache Purge Index'); //get_string('bulktestindextitle', 'qtype_coderunner')); | ||
|
||
|
||
// Display. | ||
echo $OUTPUT->header(); | ||
echo $OUTPUT->heading(get_string('coderunnercontexts', 'qtype_coderunner')); | ||
|
||
// Find in which contexts the user can edit questions. | ||
//$questionsbycontext = $bulktester->get_num_coderunner_questions_by_context(); | ||
|
||
|
||
$cachepurger = new cache_purger(); | ||
$allvisiblecoursecontexts = $cachepurger->get_all_visible_course_contextids(); | ||
krsort($allvisiblecoursecontexts); // Effectively newest first. | ||
$keycounts = $cachepurger->key_count_by_course($allvisiblecoursecontexts); | ||
|
||
// List all contexts available to the user. | ||
if (count($allvisiblecoursecontexts) == 0) { | ||
echo html_writer::tag('p', get_string('unauthorisedbulktest', 'qtype_coderunner')); | ||
} else { | ||
echo html_writer::start_tag('ul'); | ||
//$buttonstyle = 'border: 1px solid gray; padding: 2px 2px 0px 2px;'; | ||
$buttonstyle = 'border: 1px solid #F0F0F0; background-color: #FFFFC0; padding: 2px 2px 0px 2px;border: 4px solid white'; | ||
foreach ($allvisiblecoursecontexts as $contextid) { | ||
$context = context::instance_by_id($contextid); | ||
$name = $context->get_context_name(true, true); | ||
$courseid = $context->instanceid; | ||
|
||
$purgeusingttlurl = new moodle_url('/question/type/coderunner/cachepurge.php', ['contextid' => $contextid, 'usettl' => 1]); | ||
$purgeusingttllink = html_writer::link( | ||
$purgeusingttlurl, | ||
'Purge all old cache entries (ie, using TTL)', | ||
// get_string('bulktestallincontext', 'qtype_coderunner'), | ||
['title' => 'Purge all old', //get_string('testalltitle', 'qtype_coderunner'), | ||
'style' => $buttonstyle] | ||
); | ||
|
||
$purgeallurl = new moodle_url('/question/type/coderunner/cachepurge.php', ['contextid' => $contextid, 'usettl' => 0]); | ||
$purgealllink = html_writer::link( | ||
$purgeallurl, | ||
'Purge all in context', | ||
// get_string('bulktestallincontext', 'qtype_coderunner'), | ||
['title' => 'Purge all', //get_string('testalltitle', 'qtype_coderunner'), | ||
'style' => $buttonstyle] | ||
); | ||
|
||
|
||
$litext = $name . ' [Course id= ' . $courseid . '] cache size=' . $keycounts[$contextid] . ' ' . $purgeusingttllink . ' ' . $purgealllink; | ||
$class = 'cachepurge coderunner context normal'; | ||
echo html_writer::start_tag('li', ['class' => $class]); | ||
echo $litext; | ||
echo html_writer::end_tag('li'); | ||
} | ||
echo html_writer::end_tag('ul'); | ||
|
||
// Maybe do a purge all later... | ||
// if (has_capability('moodle/site:config', context_system::instance())) { | ||
// echo html_writer::tag('p', html_writer::link( | ||
// new moodle_url('/question/type/coderunner/bulktestall.php'), | ||
// get_string('bulktestrun', 'qtype_coderunner') | ||
// )); | ||
// } | ||
} | ||
|
||
|
||
echo $OUTPUT->footer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.