1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-25 10:26:17 +02:00
This commit is contained in:
Andrew Nicols 2023-06-01 10:52:22 +08:00
commit 08dab39234
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
2 changed files with 6 additions and 5 deletions
question/classes/statistics/questions

@ -276,11 +276,11 @@ class all_calculated_for_qubaid_condition {
$timemodified = time();
foreach ($this->get_all_slots() as $slot) {
$this->for_slot($slot)->cache($qubaids);
$this->for_slot($slot)->cache($qubaids, $timemodified);
}
foreach ($this->get_all_subq_ids() as $subqid) {
$this->for_subq($subqid)->cache($qubaids);
$this->for_subq($subqid)->cache($qubaids, $timemodified);
}
$transaction->allow_commit();

@ -219,12 +219,13 @@ class calculated {
* Cache calculated stats stored in this object in 'question_statistics' table.
*
* @param \qubaid_condition $qubaids
* @param int|null $timemodified the modified time to store. Defaults to the current time.
*/
public function cache($qubaids) {
public function cache($qubaids, $timemodified = null) {
global $DB;
$toinsert = new \stdClass();
$toinsert->hashcode = $qubaids->get_hash_code();
$toinsert->timemodified = time();
$toinsert->timemodified = $timemodified ?? time();
foreach ($this->fieldsindb as $field) {
$toinsert->{$field} = $this->{$field};
}
@ -232,7 +233,7 @@ class calculated {
if ($this->get_variants()) {
foreach ($this->variantstats as $variantstat) {
$variantstat->cache($qubaids);
$variantstat->cache($qubaids, $timemodified);
}
}
}