How to access the contents of a jupyter notebook cell as a string by the ID of the cell (nbgrader)?

I am using nbgrader to create labs for my students for the first time. I want the students to write code for one hot encoding in a cell. Then I use a test to see if all the columns are numeric.

The second test I want to do is to check if they wrote the code for one hot encoding or not. The only way to check that is to get their code as a string. Is there a way to access the code as a string? The ID of the code cell is encoding.

If the above is not possible, do you have any suggestions on what test I can use to check if they used pandas.get_dummies or category_encoders.OneHotEncoder in their code?