Skip to content

Redesign the "helptable" management#27

Open
TamaroWalter wants to merge 11 commits intomainfrom
redesign/update_helptable
Open

Redesign the "helptable" management#27
TamaroWalter wants to merge 11 commits intomainfrom
redesign/update_helptable

Conversation

@TamaroWalter
Copy link
Copy Markdown
Member

@TamaroWalter TamaroWalter commented Mar 25, 2026

🔀 Purpose of this PR:

  • Fixes a bug
  • Updates for a new Moodle version
  • Adds a new feature of functionality
  • Improves or enhances existing features
  • Refactoring: restructures code for better performance or maintainability
  • Testing: add missing or improve existing tests
  • Miscellaneous: code cleaning (without functional changes), documentation, configuration, ...

📝 Description:

This pull requests redesigns the "update_helptable" feature.

Refactor function insert_missing_helptable_entries :

The main job of it is to fill and update the datatables of ´lsf_unification´, that contain all the course categories from the lsf_view. ´lsf_unification´ saves a full category tree and saves the distance between two categories.

Example: In the lsf_view this categories exists:

lsf_view_cats

Every category knows is predecessor and successor. lsf_unification fills 2 tables:

local_lsf_unification_category:

id ueid parent ....
0 root_cat null ...
1 cat2 root_cat ...

local_lsf_unification_categoryparenthood: This table saves the distance between each category

id child parent distance
0 cat2 root_cat 1
1 cat4 cat3 1
2 cat4 root_cat 2

Changes made in the function:

  • heavily reduce DB calls by using fetching data once from lsf_view instead of calling the db for every individual record.
  • Use in_memory lookup instead of calling the DB
  • Add DB-transaction
  • throw away var_dumps and ugly logging. Add two simple mtrace for now

In a more or less manual testing the DB calls were reduced (with testdata from the lsf_view) from 1116 to 203 👍🏼 .

Beautify the helptablemanager.php:

This page shows the category tree of the lsf to the admin and lets the admin create mappings from the lsf-categories to moodle-categories.

What was changed?:

  • extract all inline html buildup and echo-statements to mustache templates
  • cleanup the page
  • Use bootstrap classes to beautify the mapping table

This is how the new mapping table looks:

image
image

📋 Checklist

Please confirm the following (check all that apply):

  • Code passes the code checker without errors and warnings.
  • Code passes the moodle-ci/cd pipeline on all supported Moodle versions or the ones the plugin supports.
  • Code does not have var_dump() or var_export or any other debugging statements (or commented out code) that
    should not appear on the productive branch.
  • Code only uses language strings instead of hard-coded strings.

🔍 Related Issues

@TamaroWalter TamaroWalter self-assigned this Mar 25, 2026
@TamaroWalter TamaroWalter requested a review from dlmsr March 25, 2026 08:50
@TamaroWalter TamaroWalter linked an issue Mar 25, 2026 that may be closed by this pull request
@TamaroWalter TamaroWalter changed the title Redesign/update helptable Redesign the "helptables" Mar 25, 2026
@TamaroWalter TamaroWalter changed the title Redesign the "helptables" Redesign the "helptable" management Mar 25, 2026
Replace update_helptable.php with external function. Extract html code to templates
Use bootstrap classes to make the table visually appealing
The "print_res_selection" was added a long time ago but never used. For now it will be removed
Due to previous changes, the lib_his.php needs this additions
… handling and correctnes

- Replace per-iteration pg_query in do-while with in-memory lookup via $lsfcategories array
- Replace find_origin_category DB queries with in-memory traversal
- Use insert_records for bulk relation inserts instead of individual insert_record calls
- Replace get_record + update_record with set_field for txt2 updates
- Wrap all DB writes in a single transaction; roll back on failure
- Remove nested try-catch blocks that silently swallowed errors
- Improve mtrace logging for sync summary and failure messages
@dlmsr dlmsr force-pushed the redesign/update_helptable branch from cab4ec9 to e5f75bd Compare March 26, 2026 13:07
Sometimes a category does not have subcategories. In this case
the "mapping_submit" stage should directly show the category it will map to.
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.

Optimize Helptablemanager.php

1 participant