Given the following sentence:
Vivian _____________ computer lessons for very long so she wasn't sure how to use the Internet.
I put hadn't had in missing place but the answer was hadn't been having. Why is it so?
It is often the case that the choice of whether to use a continuous form is a stylistic choice, depending on how the speaker (or writer) wishes to represent the temporal relationships involved.
If you were just talking about Vivian's experience as a bald fact, you could equally say "Vivian had had computer lessons" or "Vivian had been having computer lessons". These would both be completely grammatical, idiomatic, and accurate, the only difference being whether you chose to put a bit of emphasis on the continuing nature of the lessons, or chose to present them as a single (though lengthy) event.
What makes the difference here is the adverbial phrase "for very long". This makes the continuous "hadn't been having computer lessons" much more natural than the punctual "hadn't had computer lessons".
In fact, I find "Vivian hadn't had computer lessons for very long" unclear, because it suggests to me that it was written by somebody who wasn't a native speaker, and I would wonder if they meant to say "hadn't been having computer lessons for very long" (meaning that the lessons had started recently) or "hadn't had computer lessons for so long" (which, with emphasis on the "so", would mean "it was such a long time since she last had computer lesson").
This is an awkward question because it is framed in a certain context and, depending on the context, more than one answer is possible.
Let's assume that Vivian is still having lessons but that at school last week she wasn't sure how to use the internet. Then we could say:
Vivian hasn't been having computer lessons for very long so she wasn't sure how to use the internet.
That's to say: We use the present perfect continuous because she continues to take lessons and the past tense to describe her experience last week.
But if Vivian stopped taking lessons years ago and we are talking about her school days, we might say:
Vivian hadn't been having......
because we are talking about a learning phase that was completed in the past.
Many native English speakers would simply say that Vivian hadn't had... as you did and nobody would even notice so your choice can easily be excused even if your teacher marked it wrong.
This is because someone who tries to learn computer, should take computer lessons in span of time. So the action of attending the classes happens several times, not in a one session class.