Skip to content

Redesign the "helptable" management#27

Merged
TamaroWalter merged 6 commits into
mainfrom
redesign/update_helptable
May 28, 2026
Merged

Redesign the "helptable" management#27
TamaroWalter merged 6 commits into
mainfrom
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
@dlmsr dlmsr force-pushed the redesign/update_helptable branch from cab4ec9 to e5f75bd Compare March 26, 2026 13:07
Copy link
Copy Markdown
Member

@dlmsr dlmsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TamaroWalter , I have finally managed to complete my review. I have left some comments with questions or change requests.

Comment thread amd/src/update_helptable.js Outdated
Comment thread amd/src/update_helptable.js Outdated
Comment thread classes/external/update_helptable.php Outdated
Comment thread templates/helptable_manager/mapping_submit.mustache
Comment thread templates/helptable_manager/overview.mustache
Comment thread lib_his.php Outdated
Comment thread lang/de/local_lsf_unification.php
Comment thread helptablemanager.php Outdated
Comment thread helptablemanager.php
Comment thread helptablemanager.php Outdated
@TamaroWalter TamaroWalter force-pushed the redesign/update_helptable branch from 9e14e8c to b97a96e Compare May 20, 2026 08:06
@TamaroWalter
Copy link
Copy Markdown
Member Author

All right, i dropped the commit that changed the workflow and the other details are in the last commit :)

@TamaroWalter TamaroWalter requested review from dlmsr and removed request for dlmsr May 20, 2026 08:42
PostgreSQL requires ORDER BY expressions to appear in the select list
for SELECT DISTINCT queries.
This function was added a long time ago but never used. For now it
will be removed.
… 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 96c2084 to f7a28f9 Compare May 27, 2026 14:51
@TamaroWalter TamaroWalter merged commit 1fb456b into main May 28, 2026
24 checks passed
@TamaroWalter TamaroWalter deleted the redesign/update_helptable branch May 28, 2026 19:04
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

2 participants