German adjectives endings do not only depend on case, number, and gender, but also on definiteness.
The rule of thumb is that definiteness is expressed only once in a noun phrase. If the adjective comes first in the noun phrase or if it is only preceded by an indefinite article, it takes the definite ending:
Kannst du, o bester Lehrer, uns helfen? – ‘Can you, o best teacher, help us?’
Er ist ein bester Lehrer._ – ‘He is a best teacher.’
If, however, the adjective is already preceded by a definite element such as a definite article or a demonstrative pronoun, then it takes the indefinite ending:
Er ist der beste Lehrer. – ‘He is the best teacher.’
Nur dieser beste Lehrer kann uns helfen. ‘Only this best teacher can help us.’
So much for the clear-cut cases. Unfortunately, an adjective can be preceded by words where the usage varies. After these words, either the definite ending or the indefinite ending can occur. One such group of words are the possessive pronouns that have their own definite endings (unser ‘our’ and euer ‘your’).
The adjective following such a possessive pronoun can have the indefinite ending:
Er ist unser beste Lehrer. – ‘He is our best teacher.’
But it might as well have the definite ending:
Er ist unser bester Lehrer. – ‘He is our best teacher.’
There is no difference in meaning, but the use of the indefinite ending is more old-fashioned.