Distance education has been prevalent since the late 1800s, but its rapid expansion began in the late 1990s with the advent of the online technological revolution. Distance learning encompasses all forms of training conducted without the physical presence of learners or teachers. While this mode of education offers great flexibility and numerous advantages for both students and teachers, it also presents challenges such as reduced concentration and commitment from students, and difficulties in course supervision for teachers. This article aims to study student engagement on distance learning platforms by focusing on emotion detection. Leveraging various existing datasets, including the Facial Expression Recognition 2013 (FER2013), the Karolinska Directed Emotional Faces (KDEF), the extended Cohn-Kanade (CK+), and the Kyung Hee University Multimodal Facial Expression Database (KMU-FED), the proposed approach utilizes transfer learning. Specifically, it exploits the large number and diversity of images from datasets like FER2013, and the high-quality images from datasets like KDEF, CK+, and KMU-FED. The model can effectively learn and generalize emotional cues from varied sources by combining these datasets. This comprehensive method achieved a performance accuracy of 96.06%, demonstrating its potential to enhance understanding of student engagement in online learning environments.