Skip to content

Commit

Permalink
Merge pull request #106 from dmitriim/issue95-MOODLE_401_STABLE
Browse files Browse the repository at this point in the history
issue #95: add UI for archived records
  • Loading branch information
danmarsden authored Oct 29, 2023
2 parents d54fc29 + 92f85be commit b9ce37e
Show file tree
Hide file tree
Showing 12 changed files with 1,458 additions and 2 deletions.
108 changes: 108 additions & 0 deletions classes/reportbuilder/datasource/archived_course_completions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_recompletion\reportbuilder\datasource;

use core_course\reportbuilder\local\entities\course_category;
use core_reportbuilder\datasource;
use core_reportbuilder\local\entities\course;
use core_reportbuilder\local\entities\user;
use local_recompletion\reportbuilder\entities\course_completions;

/**
* Completion archive datasource.
*
* @package local_recompletion
* @author Dmitrii Metelkin <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class archived_course_completions extends datasource {

/**
* Return user friendly name of the datasource
*
* @return string
*/
public static function get_name(): string {
return get_string('datasource:local_recompletion_cc', 'local_recompletion');
}

/**
* Initialise.
*/
protected function initialise(): void {
$coursecompletionsentity = new course_completions();
$completionsalias = $coursecompletionsentity->get_table_alias('local_recompletion_cc');
$this->add_entity($coursecompletionsentity);

$this->set_main_table('local_recompletion_cc', $completionsalias);

// Join the course entity.
$courseentity = new course();
$coursealias = $courseentity->get_table_alias('course');
$this->add_entity($courseentity
->add_join("JOIN {course} {$coursealias} ON {$coursealias}.id = {$completionsalias}.course"));

// Join the course category entity.
$coursecatentity = new course_category();
$categoriesalias = $coursecatentity->get_table_alias('course_categories');
$this->add_entity($coursecatentity
->add_join("JOIN {course_categories} {$categoriesalias} ON {$categoriesalias}.id = {$coursealias}.category"));

// Join the user entity.
$userentity = new user();
$useralias = $userentity->get_table_alias('user');
$this->add_entity($userentity
->add_join("JOIN {user} {$useralias} ON {$useralias}.id = {$completionsalias}.userid"));

$this->add_all_from_entities();
}

/**
* Return the columns that will be added to the report once is created
*
* @return string[]
*/
public function get_default_columns(): array {
return [
'course:coursefullnamewithlink',
'user:fullnamewithlink',
'course_completions:completed',
'course_completions:timecompleted',
];
}

/**
* Return the filters that will be added to the report once is created
*
* @return string[]
*/
public function get_default_filters(): array {
return [
'course:courseselector',
'course_completions:timecompleted',
];
}

/**
* Return the conditions that will be added to the report once is created
*
* @return string[]
*/
public function get_default_conditions(): array {
return [];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_recompletion\reportbuilder\datasource;

use core_course\reportbuilder\local\entities\course_category;
use core_reportbuilder\datasource;
use core_reportbuilder\local\entities\course;
use core_reportbuilder\local\entities\user;
use local_recompletion\reportbuilder\entities\course_modules_completion;

/**
* Completion archive datasource.
*
* @package local_recompletion
* @author Dmitrii Metelkin <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class archived_course_module_completions extends datasource {

/**
* Return user friendly name of the datasource
*
* @return string
*/
public static function get_name(): string {
return get_string('datasource:local_recompletion_cmc', 'local_recompletion');
}

/**
* Initialise.
*/
protected function initialise(): void {
$completionsentity = new course_modules_completion();
$completionsalias = $completionsentity->get_table_alias('local_recompletion_cmc');
$this->add_entity($completionsentity);

$this->set_main_table('local_recompletion_cmc', $completionsalias);

// Join the course entity.
$courseentity = new course();
$coursealias = $courseentity->get_table_alias('course');
$this->add_entity($courseentity
->add_join("JOIN {course} {$coursealias} ON {$coursealias}.id = {$completionsalias}.course"));

// Join the course category entity.
$coursecatentity = new course_category();
$categoriesalias = $coursecatentity->get_table_alias('course_categories');
$this->add_entity($coursecatentity
->add_join("JOIN {course_categories} {$categoriesalias} ON {$categoriesalias}.id = {$coursealias}.category"));

// Join the user entity.
$userentity = new user();
$useralias = $userentity->get_table_alias('user');
$this->add_entity($userentity
->add_join("JOIN {user} {$useralias} ON {$useralias}.id = {$completionsalias}.userid"));

$this->add_all_from_entities();
}

/**
* Return the columns that will be added to the report once is created
*
* @return string[]
*/
public function get_default_columns(): array {
return [
'user:fullnamewithlink',
'course:coursefullnamewithlink',
'course_modules_completion:coursemodule',
'course_modules_completion:completionstate',
];
}

/**
* Return the filters that will be added to the report once is created
*
* @return string[]
*/
public function get_default_filters(): array {
return [
'course:courseselector',
'course_modules_completion:completionstate',
];
}
/**
* Return the conditions that will be added to the report once is created
*
* @return string[]
*/
public function get_default_conditions(): array {
return [];
}
}
114 changes: 114 additions & 0 deletions classes/reportbuilder/datasource/archived_h5pactivities_atempts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace local_recompletion\reportbuilder\datasource;

use core_course\reportbuilder\local\entities\course_category;
use core_reportbuilder\datasource;
use core_reportbuilder\local\entities\course;
use core_reportbuilder\local\entities\user;
use local_recompletion\reportbuilder\entities\h5pactivity_attempts;

/**
* H5pactivity attempts archive datasource.
*
* @package local_recompletion
* @author Dmitrii Metelkin <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class archived_h5pactivities_atempts extends datasource {

/**
* Return user friendly name of the datasource
*
* @return string
*/
public static function get_name(): string {
return get_string('datasource:local_recompletion_h5p', 'local_recompletion');
}

/**
* Initialise.
*/
protected function initialise(): void {
$attempts = new h5pactivity_attempts();
$attemptsalias = $attempts->get_table_alias('local_recompletion_h5p');
$this->add_entity($attempts);

$this->set_main_table('local_recompletion_h5p', $attemptsalias);

// Join the course entity.
$courseentity = new course();
$coursealias = $courseentity->get_table_alias('course');
$this->add_entity($courseentity
->add_join("JOIN {course} {$coursealias} ON {$coursealias}.id = {$attemptsalias}.course"));

// Join the course category entity.
$coursecatentity = new course_category();
$categoriesalias = $coursecatentity->get_table_alias('course_categories');
$this->add_entity($coursecatentity
->add_join("JOIN {course_categories} {$categoriesalias} ON {$categoriesalias}.id = {$coursealias}.category"));

// Join the user entity.
$userentity = new user();
$useralias = $userentity->get_table_alias('user');
$this->add_entity($userentity
->add_join("JOIN {user} {$useralias} ON {$useralias}.id = {$attemptsalias}.userid"));

$this->add_all_from_entities();
}

/**
* Return the columns that will be added to the report once is created
*
* @return string[]
*/
public function get_default_columns(): array {
return [
'user:fullnamewithlink',
'course:coursefullnamewithlink',
'h5pactivity_attempts:h5pactivityid',
'h5pactivity_attempts:attempt',
'h5pactivity_attempts:rawscore',
'h5pactivity_attempts:duration',
'h5pactivity_attempts:completion',
'h5pactivity_attempts:success',
'h5pactivity_attempts:timecreated',
'h5pactivity_attempts:timemodified',
];
}

/**
* Return the filters that will be added to the report once is created
*
* @return string[]
*/
public function get_default_filters(): array {
return [
'course:courseselector',
'h5pactivity_attempts:success'
];
}

/**
* Return the conditions that will be added to the report once is created
*
* @return string[]
*/
public function get_default_conditions(): array {
return [];
}
}
Loading

0 comments on commit b9ce37e

Please sign in to comment.