Creating and grading exercises is one of the most time-consuming tasks for instructors. These activities are usually performed manually, which requires substantial time and may introduce errors. An assistant tool that automates them can reduce this burden. Diagram-based exercises can be represented as models, enabling their automatic generation for target environments such as web and mobile applications or learning platforms such as Moodle. This paper presents an automated process for synthesizing five types of diagram-based exercises for Moodle. Because the process is model-based, the solution is domain-independent and can be applied to domains such as automata, electronics, and software design. We report its use in a university course on automata theory and evaluate its generality, effectiveness, and efficiency. The results illustrate the benefits of the approach.