Skip to content

Commit

Permalink
Activity data source implemented - DASH-941
Browse files Browse the repository at this point in the history
  • Loading branch information
raja-lmsace committed Jul 17, 2024
1 parent 46b827c commit f1d6eaf
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 11 deletions.
16 changes: 15 additions & 1 deletion classes/local/dash_framework/query_builder/builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,24 @@ public function query() {
global $DB;

[$sql, $params] = $this->get_sql_and_params();

return $DB->get_records_sql($sql, $params, $this->get_limitfrom(), $this->get_limitnum());
}


/**
* Return the all records from this query
*
* @return array
* @throws dml_exception
* @throws exception\invalid_operator_exception
*/
public function get_all_records_query() {
global $DB;

[$sql, $params] = $this->get_sql_and_params();
return $DB->get_records_sql($sql, $params);
}

/**
* Get number of records this query will return.
*
Expand Down
4 changes: 2 additions & 2 deletions classes/local/data_custom/abstract_custom_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ abstract public static function get_features_config(&$mform, $source);
*
* @return string
*/
abstract public function get_mustache_template_name() : string;
abstract public function get_mustache_template_name(): string;

/**
* Verify the user has capability ti config the widget.
*
* @param context $context
* @return bool
*/
abstract public static function has_capbility($context) : bool;
abstract public static function has_capbility($context): bool;

/**
* Layout class that the widget will used.
Expand Down
2 changes: 1 addition & 1 deletion classes/local/data_grid/data/data_collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function is_empty() {
* The return value will be casted to boolean if non-boolean was returned.
* @since 5.0.0
*/
public function offsetExists($offset) : bool {
public function offsetExists($offset): bool {
if ($offset == 'data') {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/local/data_grid/data/data_collection_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function is_empty() {
* The return value will be casted to boolean if non-boolean was returned.
* @since 5.0.0
*/
public function offsetExists($offset) : bool {
public function offsetExists($offset): bool {
if ($offset == 'data') {
return true;
}
Expand Down
18 changes: 15 additions & 3 deletions classes/local/data_source/abstract_data_source.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ abstract class abstract_data_source implements data_source_interface, \templatab
*/
private $tables = [];

/**
* @var int
*/
protected $count;

/**
* Constructor.
*
Expand Down Expand Up @@ -182,11 +187,11 @@ public function get_paginator(): paginator {

if ($this->paginator == null) {
$this->paginator = new paginator(function () {
$count = $this->get_query()->count();
$this->count = $this->get_data_records_count();
if ($maxlimit = $this->get_max_limit()) {
return $maxlimit < $count ? $maxlimit : $count;
return $maxlimit < $this->count ? $maxlimit : $this->count;
}
return $count;
return $this->count;
}, 0, $perpage);
}

Expand Down Expand Up @@ -719,4 +724,11 @@ public function is_widget() {
return false;
}

/**
* Get a data source table records count
*/
public function get_data_records_count() {
return $this->get_query()->count();
}

}
1 change: 0 additions & 1 deletion classes/local/widget/groups/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public static function create_group($formdata) {
'formdata' => $formdata,
]);

// TODO: TEST Require capability.
if ($formdata) {
parse_str($formdata, $data);
$data = (object) $data;
Expand Down
1 change: 0 additions & 1 deletion classes/local/widget/mylearning/mylearning_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@ public static function get_course_contents($courseid) {

// Now security checks.
$context = context_course::instance($course->id);
// TODO: course content view capability check.
$canupdatecourse = true;

// Create return value.
Expand Down
5 changes: 4 additions & 1 deletion lang/en/block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
$string['status:completed'] = 'Completed';
$string['status:inprogress'] = 'In Progress';
$string['status:notyetstarted'] = 'Not yet started';
$string['status:notcompleted'] = 'Not completed';
$string['status:all'] = 'All';
$string['status:enrolled'] = 'Enrolled';
$string['widget:mycontacts'] = 'My Contacts';
Expand Down Expand Up @@ -877,4 +878,6 @@
$string['competencycolor'] = 'Competency color';
$string['competencyimage'] = 'Competency image';
$string['missingdatasource'] = "The datasources are missing. Please check them.";

$string['viewactivity'] = "View activity";
$string['activitybutton'] = "Activity button";
$string['modulename'] = 'Module name';
3 changes: 3 additions & 0 deletions tests/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

defined('MOODLE_INTERNAL') || die();

/**
* phpunit test coverage information class.
*/
return new class extends phpunit_coverage_info {
/** @var array The list of folders relative to the plugin root to whitelist in coverage generation. */
protected $whitelistfolders = [
Expand Down

0 comments on commit f1d6eaf

Please sign in to comment.