Dictation? Melodic dictation. Harmonic dictation.
There are books with CDs to help with ear training. You start off with simple stuff and gets more and more complex. Diatonic and then chromatic stuff.
It's practicing, like anything. You could find a tutor and take some lessons. Being able to sing a little bit is useful too.
If you guess and write something that makes sense -- progresses and follows the rules -- they might still give you some credit for that, even if you didn't know what you were hearing.
For writing, you just use a / pencil mark for a note head. There's not enough time to make full noteheads while doing that. A / and the stem is one octave long.
The stuff you've written looks like beginner ear training exercises.
It's not so bad. It really helps to tune the ears up with that stuff, practicing it. Your mind adjusts after awhile. Tuning -- intonation -- being able to sing in tune and tell if a pitch is flat or sharp is very useful too. And something pianists might not get much use out of listening. I know of a professional pianist with perfect pitch who can't tell sharp or flat. Kind of strange.
Dictation would fal under "ear training" or "aural skills." You'll find more info that way. And dictation is the flipside of sight-singing -- learning solfege, being able to take those exercieses, what you see written down, and sing them back or just hear them in your head.