Skip to content

Commit

Permalink
data_num_submissions change.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Aug 14, 2023
1 parent b6859d9 commit 4f98314
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions classes/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,30 +343,22 @@ protected static function assign_nums($courseid, $mod) {
* @return int
*/
protected static function data_num_submissions($courseid, $mod) {
global $DB;

$modid = $mod->id;
$modinstance = $mod->instance;

static $modtotalsbyid = array();
static $modtotalsbyinstance = array();

if (!isset($modtotalsbyid['data'][$modid])) {
$params['dataid'] = $modid;
if (!isset($modtotalsbyinstance[$modinstance])) {
global $DB;
$params['dataid'] = $modinstance;

// Get the number of contributions for this data activity.
$sql = '
SELECT d.id, count(dataid) as total FROM {data_records} r, {data} d
WHERE r.dataid = d.id AND r.dataid = :dataid GROUP BY d.id';
$sql = 'SELECT count(r.dataid) as total FROM {data_records} r
WHERE r.dataid = :dataid GROUP BY r.dataid';

$modtotalsbyid['data'][$modid] = $DB->get_records_sql($sql, $params);
}
$totalsbyid = $modtotalsbyid['data'][$modid];
// TO BE DELETED echo '<br>' . print_r($totalsbyid, 1) . '<br>'; ....
if (!empty($totalsbyid)) {
if (isset($totalsbyid[$modid])) {
return intval($totalsbyid[$modid]->total);
}
$modtotalsbyid[$modinstance] = $DB->get_records_sql($sql, $params);
}
return 0;

return intval($modtotalsbyid[$modinstance]);
}

/**
Expand Down

0 comments on commit 4f98314

Please sign in to comment.