Instructions
Stand on the golden book to the left of the library entrance during Year 4. One of the computer characters will automatically cast "Leviosa," raising the book while you are standing on it.
Jump from the golden book to the nearby stack of books on the second floor. As soon as you land on the stack of books, a ghost appears, ready to attack you. Press "Square" to zap the ghost, defeating it.
Stand in front of the closet next to where the ghost appeared. Press "R2" to obtain the earmuffs from the closet. Return to the library entrance.
Cast "Leviosa" on the red book on the first bookshelf on the right side of the library entrance. Press "Triangle" to switch to Hermione and then cast "Crookshanks" to turn into her cat, Crookshanks.
Walk to the glowing blue paw prints. Press "Square" to dig a hole in the ground, causing gnomes to appear and build you a ladder. Press "Triangle" to switch back to your previous character and climb the ladder onto the top floor.
Walk up to the shrieking mandrake holding a student. Push "Square" to lift the mandrake and place it into the pot on the left side of the student, freeing him.