Yes, this is a "rule" of English grammar but it has to be understood and applied correctly. The advice to avoid could applies only to those sentences where could refers to an ability to perform a certain particular action on a particular occasion. On this basis, the following sentences are problematic:
? I spent an hour looking for my keys and could find them.
? I could buy the notebook at a good price.
? There was a fire in the building but everybody could escape.
? I played well for a change and could beat him.
In such situations we are more likely to use an alternative such as was able to, managed to, or succeeded in.
Here are explanations and examples from four recent grammars (the first three pedagogic, and the fourth descriptive):
Swan: Practical English Usage
We do not normally use could to say that somebody managed to do
something on one occasion:
? After six hours climbing we could get to the top of the mountain.
Murphy: English Grammar In Use
We use could for general ability. But if we are talking about what
happened in a particular situation, we use was able to or managed to
(not could).
? They didn't want to come at first but we could persuade them.
Carter & McCarthy: Cambridge Grammar of English
When actual achievements are indicated, was/were able to, not could,
is preferred in past affirmative cases:
? The thieves escaped but the police could arrest them later that
evening.
Huddlestone & Pullum: The Cambridge Grammar of the English Language
An important restriction is that could does not normally appear in
affirmative contexts when it is a matter of actualisation of a single
situation viewed perfectively:
? I left early and could get a good seat.
The OP's example sentence is somewhat tricky because staying awake is more of a state than a single action. The following sentence is a more clear-cut example of the application of the rule explained above:
? After lying in bed for hours staring at the ceiling I could fall
asleep.
Better:
After lying in bed for hours staring at the ceiling I managed to fall
asleep.
In the first example, was able to is an alternative.
In the second example, could means that the speaker was in hearing distance of the phone, but implies that the speaker didn’t answer it, at least not immediately. If the speaker had said ‘I was able to hear the phone ringing’, the speech is more likely to continue with something like ‘. . . and so I went over and picked it up.’
In the third example, (1) is not necessarily wrong. It might occur in a sentence such as ‘The doctor said that after treatment he could return to work.’ (2) suggests that not only was he able to return to work, but that he did so.
Could and able to can be interchangeable, but the context will often decide which is chosen.
Best Answer
"Could" is an auxiliary verb with multiple uses. "Could you get me a glass of water?" (asking someone to do something) "He could grow up to be President" (expressing possibility) "He could not climb the tree." (expressing ability or inability) There may be other uses, as well. Considering the third example, though, it shows that there is nothing wrong with saying ""I could only answer half the questions" to mean "I was only able to answer half of the questions." The only difference is that (in the absence of the first sentence, which sets the time in the past) the former version is subject to the possible interpretation "It is possible that I will decide to only answer half of the questions."
Note that I have said "half of the questions." English usage requires the definite article in this case.