Skip to content

Commit

Permalink
refactor DB statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed May 15, 2024
1 parent bd1be15 commit 6f3197d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions classes/external/answer_questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ public static function execute_returns(): external_function_parameters {
* @throws moodle_exception For general Moodle-related errors.
*/
public static function execute(array $module, array $questions): array {
global $DB;
$time_at_request_start = time();

$params = self::validate_parameters(self::execute_parameters(), ['module' => $module, 'questions' => $questions]);
Expand All @@ -133,7 +132,7 @@ public static function execute(array $module, array $questions): array {
$questions = self::validate_and_enhance_questions($questions, $module->instance);

$quba = helpers::load_or_create_question_usage($module->id);
$completion = self::process_questions($questions, $time_at_request_start, $module, $DB, $quba);
$completion = self::process_questions($questions, $time_at_request_start, $module, $quba);

$module_completion_status = static::determine_module_completion_status($completion, $module);
$tasks_completion_data = static::get_tasks_completion_data($questions, $quba);
Expand Down Expand Up @@ -303,7 +302,9 @@ private static function all_elements_are_bool(array $array): bool {
* @throws dml_transaction_exception
* @throws dml_exception
*/
protected static function process_questions(array $questions, int $time_at_request_start, stdClass $module, moodle_database $DB, question_usage_by_activity $quba): completion_info {
protected static function process_questions(array $questions, int $time_at_request_start, stdClass $module, question_usage_by_activity $quba): completion_info {
global $DB;

// start delegating transaction
$transaction = $DB->start_delegated_transaction();

Expand Down

0 comments on commit 6f3197d

Please sign in to comment.