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

Spell checker invalidunknown. #40

Open
marcusgreen opened this issue Dec 26, 2024 · 17 comments
Open

Spell checker invalidunknown. #40

marcusgreen opened this issue Dec 26, 2024 · 17 comments

Comments

@marcusgreen
Copy link

I did fresh install of Moodle 4.5, added the mebis version of aitext (at the forked branch). When I tried running the spell checker I got an error message. I was hoping to ensure that my branch works in the same way but I am not quite shure what it should have done. I have attached an image.
aitext_spellcheck

@PhMemmel
Copy link
Member

Thanks for the feedback. Could you please provide the debug output? If it's not shown in the frontend it should be logged into the browser console if debug mode is enabled.

@marcusgreen
Copy link
Author

Will check (just looking into what code is called)

@marcusgreen
Copy link
Author

I had debug set to none, I have now set it to developer... (was running the code in preview mode...)

File: /lib/dml/moodle_database.php
Line: 1690
Stack trace:
SELECT c.*
FROM {course_modules} cm
JOIN {course} c ON c.id = cm.course
WHERE cm.id = ?
[array (
0 => 0,
)]
Error code: invalidrecordunknown

  • line 1690 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 2868 of /lib/modinfolib.php: call to moodle_database->get_record_sql()
  • line 76 of /question/type/aitext/classes/form/edit_spellchek.php: call to get_course_and_cm_from_cmid()
  • line 68 of /lib/form/classes/dynamic_form.php: call to qtype_aitext\form\edit_spellchek->get_context_for_dynamic_submission()
  • line 71 of /lib/form/classes/external/dynamic_form.php: call to core_form\dynamic_form->__construct()
  • line ? of unknownfile: call to core_form\external\dynamic_form::execute()
  • line 253 of /lib/external/classes/external_api.php: call to call_user_func_array()
  • line 83 of /lib/ajax/service.php: call to core_external\external_api::call_external_function()

@marcusgreen
Copy link
Author

I will now test it as part of a quiz

@marcusgreen
Copy link
Author

image
Works when part of a quiz :)

@PhMemmel
Copy link
Member

So it only happens in teacher preview question mode? Will try to have a look soon.

@PhMemmel
Copy link
Member

I can understand where this error comes from, unfortunately, i cannot reproduce. When trying to do the preview from the question bank, there is no "edit spellcheck" button, because there's no capability set on this context I believe. Could you please provide exact steps what I need to do? I tested with latest moodle main and latest version of 405_core_ai branch from your repository.

By the way: This branch still has and uses the setting uselocalaimanager instead of the new backend setting. Is 405_core_ai still the one we should work on? :)

@marcusgreen
Copy link
Author

On my repo I intend to rename main as classic and rename 405_core_ai as main (if I can work out how to get git to do that). I was looking into the spell checker in the hope that my repo would be the same as yours and the code could converge. I will try to reproduce the steps, and I am wondering if it is something to do with me testing as admin.

@PhMemmel
Copy link
Member

Ah, admin.... Well yes, the link to edit the spellcheck suggestion is hidden behind capabilities. If you're not in a relevant context it won't be shown. I tried to test as admin: I still do not get an error, neither in the preview inside a test nor in a preview in the question bank. But maybe that's a 4.5 issue, because there the question banks have not been migrated yet and probably are in a different context than a course context.

@marcusgreen
Copy link
Author

I am on the branch called forked.

@marcusgreen
Copy link
Author

I tried switching role to teacher.. but it still manifested.

@PhMemmel
Copy link
Member

The line you posted is only accessed when the capabilities are there in the correct context.

Regarding the branches: I believe you should have a look at the things I tried to improve regarding the upstream compatibility. Unfortunately, it's already outdated, because we were too slow: mebis-lp/moodle-qtype_aitext#6

@marcusgreen
Copy link
Author

Where are the permissions checked? I was looking for an easy way to check if the question is in preview mode but I have yet to find it.

@PhMemmel
Copy link
Member

4 lines above actually.

Suggestion: You describe me exactly what I need to do to reproduce the issue (Please in a style of "now click this link and then this button ...", I'm still unsure, where exactly you are triggering this issue). I will set up a moodle 4.5 instance (hopefully tomorrow) and rebase the changes I wanted to provide against your 405_core_ai branch.

You then can re-test and review and I hope I will also find a solution for the context issue.

@marcusgreen
Copy link
Author

aitext_spellcheck.mp4

@PhMemmel
Copy link
Member

So, I think I finally figured out what was going on and reworked the whole handling of context, I removed the dependency on the course module so that also preview mode should be working fine now.

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

No branches or pull requests

2 participants