In this paper, we focus on optimizing the assignment of students to courses. The target courses are conducted by different teachers using the same syllabus, course design, and lecture materials. More than 1,300 students are mechanically assigned to one of ten courses taught by different teachers. Therefore, mismatches often occur between students' learning behavior patterns and teachers' approach to teaching. As a result, students may be less satisfied, have a lower level of understanding of the material, and achieve less. To solve these problems, we propose a strategy to optimize the assignment of students to courses based on learning activity analytics. The contributions of this study are 1) clarifying the relationship between learning behavior pattern and teaching based on learning activity analytics using large-scale educational data, 2) optimizing the assignment of students to courses based on learning behavior pattern analytics, and 3) demonstrating the effectiveness of assignment optimization via simulation experiments.