Cognitive diagnosis aims to infer students’ mastery of knowledge concepts by modeling their response behaviors, which is crucial for enhancing personalized education and learning interventions. Existing methods mainly rely on statistical models or deep sequential models to capture changes in students’ knowledge states, but they often overlook the effects of non-cognitive factors during the response process on both learning states and response outcomes. To address these issues, this study proposes a dual-path cognitive diagnosis model based on the integration of learning states and cognitive levels. In this model, the state path infers students’ learning states from non-cognitive behavioral features and employs supervised contrastive learning to enhance the discriminative capability of state representations. The cognitive path uses causal analysis to capture the causal relationship between knowledge mastery and response outcomes. The two paths are integrated through a gated fusion mechanism to complement each other and enable dynamic adjustment, thus comprehensively reflecting students’ true mastery levels. To verify the effectiveness of the proposed model, experiments are conducted on three real-world educational datasets. The results show that the model outperforms nine baseline models across key evaluation metrics, and ablation studies confirm the effectiveness of the dual-path design and gated fusion in improving both the performance and interpretability of cognitive diagnosis.