Programming should be considered as an ill-defined domain because for a given programming problem there might be many alternative solution strategies and for each of them a wide spectrum of solutions can be created. Most programming problems, which are used to tutor beginners, are simple and might have well-defined start and goal states. The task statement can be well specified and a solution can easily be checked for being correct or not. However, the activity of solving a programming task is a design problem. One can not only apply different programming techniques to create a solution, but also modularize a program to make the code clear, easy maintainable and reusable. In this paper, we demonstrate how we applied weighted constraints to build a diagnosis component which serves the student model of an intelligent tutoring system (ITS) for logic programming. This technology has been integrated into a web-based ITS. We evaluated the coverage of error diagnosis with 221 student solutions of past examinations and the system was able to produce a correct analysis for 87.9% of collected solutions.