Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly fetch a subchapters parent (#776) & refactor TestRepository::read_records() method #849

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ScottVerbeek
Copy link

@ScottVerbeek ScottVerbeek commented Nov 28, 2023

Description

  • The \mod_book\event\chapter_viewed event for module mod_book was fetching a parent chapter incorrectly. Before subchapter was used as a ID, which is actually a boolean value. Here is a representation of what it should look like, and should help understand the code.
 SELECT id, bookid, pagenum, subchapter, title FROM mdl_book_chapters ORDER BY pagenum;                  
 id | bookid | pagenum | subchapter |         title         
----+--------+---------+------------+-----------------------
  1 |      1 |       1 |          0 | Chapter 1
  2 |      1 |       2 |          1 | Chapter 1.1
  3 |      1 |       3 |          1 | Chapter 1.2
  4 |      1 |       4 |          1 | Chapter 1.3
  6 |      1 |       5 |          1 | Chapter 1.4 (was 2.1)
  5 |      1 |       6 |          0 | Chapter 2
(6 rows)
  • The TestRepository::read_records() method only worked properly when parameter array $query contained exactly one element.

Related Issues

PR Type

  • Fix

 - fixes duplicate records returning when multiple conditions for $query is passed
 - fixes records returning when not all conditions are met in $query
@ScottVerbeek ScottVerbeek changed the title correctly fetch a subchapters parent (#776) correctly fetch a subchapters parent (#776) & refactor TestRepository::read_records() method Nov 28, 2023
@ScottVerbeek
Copy link
Author

Running the unit tests locally:

root@6134396f5f13:/var/www/site# vendor/bin/phpunit --testsuite logstore_xapi_testsuite --filter 'logstore_xapi\\mod_book' --testdox
Moodle 4.4dev (Build: 20231124), 6374475dc3cf3a94e22ec18c4655b89819a1b5d6
Php: 8.1.24, pgsql: 14.0 (Debian 14.0-1.pgdg110+1), OS: Linux 6.4.12-060412-generic x86_64
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

existing_chapter_viewed_with_parent_test (logstore_xapi\mod_book\chapter_viewed\existing_chapter_viewed_with_parent\existing_chapter_viewed_with_parent_test)
 ✔ Init
 ✔ Create event

existing_chapter_viewed_without_parent_test (logstore_xapi\mod_book\chapter_viewed\existing_chapter_viewed_without_parent\existing_chapter_viewed_without_parent_test)
 ✔ Init
 ✔ Create event

existing_module_test (logstore_xapi\mod_book\course_module_viewed\existing_module\existing_module_test)
 ✔ Init
 ✔ Create event

Time: 00:00.217, Memory: 76.50 MB

OK (6 tests, 6 assertions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant