###### Abstract  
Online learning environments such as e-learning platforms are often used to encourage collaborative activities amongst students. In this context, group work is often used to improve the learning outcomes. Group formation is often performed randomly since university courses can be composed of a large number of students. While random formation saves time and resources, the student heterogeneity in terms of learning capabilities is not guaranteed. Although advanced e-learning platforms such as Moodle are widely used, they lack plugins that allow the automatic formation of heterogeneous groups of students. This work proposes a novel intelligent plugin for Moodle that allows the creation of heterogeneous groups by using Machine Learning. This intelligent application can be used in order to improve the students' performance in collaborative activities. Our machine learning approach first uses clustering algorithms on Moodle data to identify homogeneous groups that are composed of students having similar behavior. Heterogeneous groups are then created by combining students selected from different homogeneous groups. To this end, a novel algorithm and the corresponding software, which allow the creation of heterogeneous groups, have been developed. We have implemented our approach by realizing a Moodle plugin where teachers can create heterogeneous groups. e-learning; machine learning; moodle; clustering; heterogeneous groups +
Footnote †: journal: Medical  
This needs to taking into account the number and the heterogeneity of the components. Concerning the number of members, groups need to be formed by at least three or more people, although groups of four or five members are more effective [7]. Groups can also consist of two people, but in this case, the lack of creativity and variety of ideas does not encourage teamwork [8]. Another characteristic of success in group works is certainly the heterogeneity of students in terms of cognitive resources, characteristics, and behaviors [9]. Building optimal groups of students for collaborative activities is not easy. Normally, different approaches that do not always guarantee the formation of heterogeneous groups are used: random, automatic, and teacher selection [10]. In the first case, the teacher randomly divides students into groups, either manually or through a computer system. This is the simplest and fastest method to mix all students with the hope of achieving heterogeneity within groups [11]. For the improvement of social and cognitive performance, especially for students with low motivation, it is important that the formation of the group can also be conducted through the students' self-selection approach (i.e., the automatic selection). It allows for the creation of groups with high empathy, but they are not always pedagogically heterogeneous. The third approach, which could guarantee the formation of heterogeneous groups, is the selection made by the teacher on the basis of pre-established characteristics, such as knowledge, skills, interests, and learning style [12]. At a university level, this method is difficult to implement since teachers hardly can identify certain characteristics and behaviors of students. This difficulty comes not only from the large number of participants but also from the relatively short duration and the not always mandatory attendance of courses. In our university, the first experiences of online collaborative activities were based on shaping the groups by means of a random selection of students, without an underlying criterion. This led to a number of negative outcomes. More in detail, according to our previous studies for an online laboratory of genomics, which included a peer review collaborative activity, a final questionnaire on the students' perception of the effectiveness of the collaborative activities demonstrated the intrinsic problems arising from the way the groups of students were formed.