hedyorg / hedy

Hedy is a gradual programming language to teach children programming. Gradual languages use different language levels, where each level adds new concepts and syntactic complexity. At the end of the Hedy level sequence, kids master a subset of syntactically valid Python.
https://www.hedy.org
European Union Public License 1.2
1.26k stars 282 forks source link

🧪generatingQLCs for level 1 test #5542

Closed alexpaascual closed 1 week ago

alexpaascual commented 1 month ago

This code defines a function generate_question that analyzes a student's code to help them reflect on their work. The function takes an input string representing the student's code, identifies various commands within the code (such as print, ask, echo, play, forward, and turn) LEVEL 1, and generates a list of relevant questions. It then randomly selects and returns one of these questions to prompt the student to think about and self-explain their code. I am aware that it won't work as intended as I need to make more changes in other files for it to work properly :)

Checklist Done? Check if you have it all in place using this list: (mark with x if done)

Felienne commented 1 month ago

Marking this as draft unutil it is ready!

Felienne commented 1 month ago

Hi @alexpaascual!

I am looking at your code and I see you are doing the analysis with string manipulation. This works but it is not very performant or elegant and it will be a lot of work for you. You can repurpose some of the work we have done!

We have a parser that already transforms a program into a tree (see here)

This can be used from program analysis! For example, in this PR you can see that Julia created a new function to determine roles, based on the transpiler. She used the function all_variables:

https://github.com/hedyorg/hedy/blob/0d0d159c8ed4eef733192f5aadc4b46ea8f80737/hedy.py#L1168

Tree traversal will be a bit more complex than what you are doing now, but it will be better and easier in the end.

If you help me see what functions you need (by completing the list we talked about) I can help you along a bit more if needed!

alexpaascual commented 1 month ago

Hi Felienne,

Thanks for the guidance, now it is clearer how the data is being parsed. I will try to restructure it how you suggested and I will update the excel with the one I currently have, plus the information you told me to add before in the meeting. If I have any problems, I will let you know ASAP.

Thanks a lot!


From: Felienne Hermans @.> Sent: 28 May 2024 15:53 To: hedyorg/hedy @.> Cc: Pascual Pintado, A. (Alejandro) @.>; Mention @.> Subject: Re: [hedyorg/hedy] 🧪generatingQLCs for level 1 test (PR #5542)

Hi @alexpaascualhttps://github.com/alexpaascual!

I am looking at your code and I see you are doing the analysis with string manipulation. This works but it is not very performant or elegant and it will be a lot of work for you. You can repurpose some of the work we have done!

We have a parser that already transforms a program into a tree (see herehttps://github.com/hedyorg/hedy/wiki/Hedy-Architecture#transpiling)

This can be used from program analysis! For example, in this PRhttps://github.com/hedyorg/hedy/pull/5500/files you can see that Julia created a new function to determine roles, based on the transpiler. She used the function all_variables:

https://github.com/hedyorg/hedy/blob/0d0d159c8ed4eef733192f5aadc4b46ea8f80737/hedy.py#L1168

Tree traversal will be a bit more complex than what you are doing now, but it will be better and easier in the end.

If you help me see what functions you need (by completing the list we talked about) I can help you along a bit more if needed!

— Reply to this email directly, view it on GitHubhttps://github.com/hedyorg/hedy/pull/5542#issuecomment-2135276708, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASKYUUIJJULSOIUPAWQZAQ3ZESD6VAVCNFSM6AAAAABH4MU7IKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGI3TMNZQHA. You are receiving this because you were mentioned.Message ID: @.***>

alexpaascual commented 2 weeks ago

Updated the analyze_code and generate_question functions to avoid using string manipulation. Instead of slicing strings, now using structured parsing and specific functions for each command(AST). This makes the code cleaner and easier to understand.

Felienne commented 1 week ago

Hi @alexpaascual!

Since you are not going to implement, I am closing this for now (you can always reopen it if you want!)