Skip to content

Instantly share code, notes, and snippets.

@andrewnicols
Created July 5, 2021 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewnicols/8cf36e5a1967aa7ba57a135c8e78a21b to your computer and use it in GitHub Desktop.
Save andrewnicols/8cf36e5a1967aa7ba57a135c8e78a21b to your computer and use it in GitHub Desktop.
<?php
define('CLI_SCRIPT', true);
require_once('config.php');
$cmid = 16;
$users = [
11,
];
require_once($CFG->dirroot . '/mod/assign/locallib.php');
[$course, $cm] = get_course_and_cm_from_cmid($cmid);
$context = \context_module::instance($cm->id);
$assign = new assign($context, $cm, $course);
foreach ($users as $userid) {
$user = \core_user::get_user($userid);
\core\session\manager::init_empty_session();
\core\session\manager::set_user($user);
$notices = [];
$assign->submit_for_grading([
'userid' => $user->id,
], $notices);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment