jaluoma / pruju-ai

An AI teaching assistant that allows students to interact with the teacher's course materials
MIT License
42 stars 16 forks source link

AttributeError: 'str' object has no attribute 'get' #2

Closed fishfree closed 9 months ago

fishfree commented 9 months ago

A great workpiece!

(prujuai) mememe@ubuntugpu:~/prujuai$ vi .moodle
(prujuai) mememe@ubuntugpu:~/prujuai$ python moodle.py 
Traceback (most recent call last):
  File "/mnt/data/mememe/prujuai/moodle.py", line 144, in <module>
    df=ws_create_file_list(resp)
  File "/mnt/data/mememe/prujuai/moodle.py", line 107, in ws_create_file_list
    for module in section.get('modules', []):
AttributeError: 'str' object has no attribute 'get'

BTW: What's the exact python version of your working instance? @jaluoma Thank you very much!

jaluoma commented 9 months ago

This is probably due to an access issue on the Moodle end. I was able to reproduce this by providing a wrong access token in .moodle. I admit the error message is not very helpful in this regard (i.e., thanks for the useful issue!).

jaluoma commented 9 months ago

re: Python version: At least 3.10 and 3.11 work.

fishfree commented 9 months ago

Thank you, jaluoma! I can confirm my token is correct. Maybe it's because of the token-associated user has not enough permissions. Could you write it clearly here or in the README, please?

Edit: after reading the source file moodle.py, I realized I need add the core_course_get_contentsfunction to the Moodle service.

jaluoma commented 9 months ago

Thanks! The documentation sure needs to be better. :)