Affective experiences within academic contexts significantly influence educational outcomes. Despite this, the literature reveals a gap in generalising these effects to specific classroom activities, partly arising from the absence of suitable instruments to measure emotions in situational educational scenarios. Our study introduces an experience sampling method to measure sixteen discrete emotional states, deriving two scales for positive and negative activating emotions. Grounded in psychological and neuroscientific theories that integrate emotion with cognition, our research explores the interplay between prior knowledge, preservice teachers' anticipatory situational emotions, and subsequent learning in an experimental science education context. Analysing data from 269 preservice teachers from diverse backgrounds (STEM and non-STEM) at the upper-secondary level, we found that negative activating emotions are often rooted in non-STEM backgrounds and exacerbated by limited prior science knowledge. These negative emotions impact achievement and learning primarily through the mediating role of boredom. Furthermore, our results indicate that the detrimental impact of boredom on achievement is significantly influenced by prior knowledge, with a more pronounced effect on students with lower levels. Given that emotions are amenable to intervention, our findings propose that specifically addressing boredom in students with low prior knowledge could amplify the benefits of educational strategies.