{'fraction_non_alphanumeric': 0.021418961976917086, 'fraction_numerical': 0.005806131841676698, 'mean_word_length': 4.741260162601626, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
pygiftgenerator: A python module designed to prepare Moodle-based quizzes

We present pygiftgenerator, a python module for systematically preparing a large number of numerical and multiple-choice questions for Moodle-based quizzes oriented to students' formative evaluation. The use of the module is illustrated by means of examples provided with the code and they cover topics from Mechanics, Electromagnetism, Thermodynamics and Modern Physics. The fact that pygiftgenerator relies on a well-established computer language which allows to combine and reuse functions in order to solve complex problems, makes it a very robust tool. Simply by changing the input parameters, a large question bank with solutions even to complex physical problems can be generated. Thus, it is a powerful alternative to the calculated and multiple choice questions which can be written directly in the Moodle platform. The module writes the questions to be imported into Moodle in a simple and human-readable ASCII output using the GIFT format, which enables html definitions for URLs for importing figures, or for simple text formatting (sub/superindices or Greek letters) for equations and units. This format also admits LaTeX typing for complex equations.


Introduction
The introduction of the European Credit Transfer System (ECTS) criteria [1], which are the standards accepted by all universities included in the European Higher Education Area (EHEA) to guarantee the convergence of the different education systems in Europe, and the launching of the so-called Bologna Process [2] has introduced a revolution in the teaching-learning process in European universities. The teaching-learning process has switched from a teaching-centered education to a learning-centered one, requiring that i) lecturers change traditional teaching methodologies to give students the leading position and ii) students become active learners, taking a larger commitment in their learning process, a role which enables them reach the competences and learning outcomes designed in the new curricula. To this end, all the universities have adopted new technologies specially suited to offering new online teaching and learning environments to both students and lecturers. There is no doubt that this change of paradigm would not have succeeded without the introduction of all these online resources.
Recent reviews show that online learning is optimal when it is combined with the face-to-face modality and this effect is statistically significant [3]. Nevertheless, lecturers should not be tempted to use online resources just as mere vehicles that deliver instruction [4,5] and should design them to make the most out of their capabilities. Doing so has demonstrated that the use of active learning techniques contributes to improving the outcomes of the learning process [6,7,8,9,10,11]. Online platforms such as Moodle [12], allow students to tackle different activities: downloading lecture notes at home, exchanging ideas in discussion forums, uploading assignments, peerinstruction activities, chat-rooms, surveys, quizzes, plugins to virtual online classrooms and many others. In the last decade there has been a significant proliferation of online courses in many universities [13,14], although there are not so many studies devoted to massive assessment tools [15].
The use of Moodle-based quizzes for formative evaluation has been considered for years. In a recent study [16], the authors focused in the optimization of Moodle quizzes for online asessments. They showed that there are many important reasons to consider Moodle-based tests as an instrument during the learning process at the university level. The first reason is that they are effective learning tools from the point of view of the knowledge acquired by the students during the course. An important aspect in this regard is the automated feedback they offer, which is able to engage students better than delayed feedback. On the other hand, automated grading by Moodle according to a well-constructed question bank saves significant amounts of time that the instructors should otherwise invest in manually correcting exams and calculating the marks obtained by students. Automatic grading allows that this scarce resource (time) can be devoted to other teaching activities such as preparation of experiments, classroom demonstrations, new handouts, and so on. On the other hand, the ability to randomize questions and answers inside them allows to produce tests which are relatively robust against plagiarism [16]. This is an important characteristic in case some of the quizzes are unsupervised.
The authors of the present contribution have been using Moodle-based Multiple-Choice (MC) quizzes as a formative evaluation tool for many academic years (2012present) with the students enrolled in the subject of General Physics of first year STEM (Science, Technology, Engineering and Mathematics) degrees taught in the Faculty of Science and Technology in the University of the Basque Country UPV/EHU. At the end of every topic of the subject, students answer 10 questions, randomly extracted for every student and with answers randomized within each question, from quite a large questionbank (around 60-70 per chapter) prepared by the lecturers. The goal of these quizzes is twofold: i) allow the students to self-evaluate their performance along the semester; ii) give real-time feedback to the lecturer on the performance of each student. A full description of this methodology can be found in [17]. A study of the results obtained with this strategy demonstrates that those students regularly taking and passing the tests increase their probability of passing the course and, on average, obtain better final marks [17]. Since 2016-2017 we have made them optional as a training tool for a honest self-evaluation. In this case, even if the students are not forced to solve the quizzes, they are aware that these are for their own benefit, and the same conclusion achieved in the previous study is drawn. Those who pass the tests, increase the probability of passing the subject and obtain, on average, better marks [8]. We have also used the system at the MSc level during two years.
If properly set out, the MC quizzes and Numerical questions in Moodle can be a very valuable online tool for teaching and for (formative) evaluation, as already shown in our previous studies. We list some of the advantages of using them: they allow selfcorrection; questions and answers can be randomized; they allow immediate or delayed feedback; they can be made available only within a time-window; a countdown for solving them can be set; questions can be classified in categories and subcategories; questions can be exported from a course to be imported back to another course in many different formats; equations and images are allowed within the questions; and many more. But probably one of most useful features of the Moodle question bank is that when it is large enough, all students get randomly assigned different questions of a similar level of complexity that evaluate the same learning outcome. This guarantees that they can not share the answers while they fill in the quiz. More importantly, this ensures that all students are evaluated fully respecting the principle of equal opportunities. Of course, this means that, depending on the amount of students enrolled in the course, a huge amount of questions must be generated. Thus, the workload upon instructors increases dramatically.
The recent outbreak of the global COVID-19 pandemic in spring of 2020 has put the online teaching and learning on the focus of all educational systems worldwide. Indeed, the closure of schools and universities has literally obliged to adapt all the teachinglearning process to the online world unexpectedly and in a very short time. Lecturers and students have suddenly needed to modify the way they teach and the way they learn, respectively. Moreover, due to the long period of confinement ordered by most of the governments, a face-to-face evaluation in most of the universities will not be possible. Therefore, the final evaluation of the teaching-learning process will also need to be done using online resources, with all the drawbacks and difficulties this implies, such as students not being under surveillance to avoid them sharing answers during the exam.
In this paper we introduce the pygiftgenerator module for python [18]. It is easy and intuitive to use and it allows the instructors to prepare a large amount of MC and numerical questions based on the set up of a single problem (which can also include images). Since the system works by allowing to change the values for the parameters involved in the problem, many different instances of the same problem can be easily produced in GIFT format. The output file in GIFT format holds the questions and their corresponding answers, all of them classified according to the Moodle categories specified by the user. They can then be easily uploaded to the question-bank in the Moodle platform of any course. If the instructors design carefully the taxonomy of categories to which the questions belong, the automatic random selection of questions for every student from the same or similar families of problems is straightforward and allows the instructor to cover the syllabus of the course.
The paper is organized as follows: Section 2 describes the methodology used by the module to generate easy-to-import GIFT files in Moodle and Section 3 outlines its implementation and installation. Some applications to selected problems in different fields of Physics are shown in Section 4. We finish with the discussion in Section 5 and conclusions in Section 6.

Methodology
The GIFT format [19] is one of the formats used by the Moodle learning environment to allow the preparation of questions for their batch import into a given course. It is relatively simple for the case of simple text questions, but it can also hold HTML tags, so that basic text formatting and even remote url-defined files (images, references) can be included in questions. L A T E X code can also be inserted in the GIFT files, so that complex equations are also supported.
An important first step in this module is the preparation of variable input parameters for every problem. We show two different ways of treating this. In the first case, the parameter set is randomly extracted from a combination of input lists specified by the user, which allows the instructors to keep numbers used as input parameters nice looking or inside a discrete set that is physically meaningful. The way this system works by combining lists of parameters is illustrated in file EM DC circuit MC.py distributed with the module.
A second option is to produce the input parameters by means of calls to random number generators from the program that is generating the questions. Even in this case, as shown in the example file TH Blackbody Planck NQ.py , some of the input parameters may be preset through a list (representing a range of temperatures in this An important aspect previous to the design of the questions is the preparation of a consistent tree of categories and subcategories which allow the instructors to perform a proper classification of topics and subtopics which aids in the random extraction of questions by the Moodle quiz preparation system for each individual student. These categories are kept during the production of the GIFT code and are imported by Moodle properly (see figure 1). This is important when random tests for students are designed on the basis of diverse topics. They allow properly sampling the program covered through the year and equally distributing different options to every student.
There are many classes of questions available in Moodle, and all of them can be imported by means of the GIFT format, such as MC, True-False, Short Answer and Numerical to name a few. Considering that we deal with exercises in the field of Physics, we have focused in Numerical and MC types only, since we found them to be the most interesting for carrying out exams during the COVID-19 exam period. A similar structure of code can be used for the other kind of questions, and it might even happen that we support them in the future. However, in many cases (Short Answer, Missing Words or Matching questions, for instance), the use of a module such as pygiftgenerator wouldn't be effective at all. The reason is that the use of python as a computer language as we propose in this paper is perfect for questions in which numerical computation is needed, since the answer can be recalculated for different values of the parameters. This applies perfectly to Numerical and MC questions. However, for Short Answer or Matching questions, the use of a computer language doesn't draw a significant advantage and using it would require much more work than the one needed to write them directly in GIFT. Thus, the authors have decided to exclusively support Numerical and MC questions. In the latter case, the module ensures that questions with repeated answers are not included in the output GIFT file.
The GIFT file produced by a python interpreter running a program built around the pygiftgenerator.py module can be easily imported to the question bank of a Moodle installation. A screenshot of the importing result is shown in figure 2. Additionally, the questions are properly classified in the tree categories and subcategories initially designed by the instructors.

Implementation
The module pygiftgenerator can be installed by means of a standard setup.py installation script which uses the distutils tools. The code has been tested with versions 3.6, 3.7 and 3.8 of python. It is open source distributed under the GPLv3 license and it can be obtained at the htps://gitlab.com/EHU/pygiftgenerator repository.

Results: Application to selected problems
We list here a selection of applications. Many more and their corresponding example files can be found in the documentation available with the module.

Mechanics
The following example deals with the application of Newton's second law to a system of pulleys and point masses. This is a classical example covered in a General Physics course in first year undergraduate studies related with the dynamics of rigid bodies, since the pulleys we will deal with have a non-negligible mass. Figure 3 shows two coupled pulleys rotating about a common axis. The large (small) one has radius r 1 (r 2 ) and a mass m 1 (m 2 ) hangs from its rim with a mass-less string. When the system is released, the ratio of parameters for each pulley defines the direction of rotation of the system. The positive direction of rotation used in the problem is marked with the arrow. This means that the accelerations of masses m i and angular acceleration of the pulleysystem will be positive when the system rotates clockwise, and negative when the system rotates anticlockwise. With this criterion we can apply Newton's second law to the masses attached to the strings Σ F i = m i a i and calculate the torque on the pulleys Σ M = I α, with a i = αr i due to the rotation-translation constraints of the strings around the pulleys. Therefore the problem reduces to solving the following system of equations The examples in pygiftgenerator ask the students to solve the problem for the following quantities: (ii) The tension of the string attached to m 1 , given by with α from Equation (4).
(iii) The tension of the string attached to m 2 , given by with α from Equation (4).
(iv) The acceleration of any of the masses, given by with α from Equation (4). This is a clear example in which based on a single figure and slightly changing the set up of the problem, one can prepare a large amount of different questions involving the different physical quantities represented by the equations above. See example files ME coupled pulleys NQ.py for Numerical and ME coupled pulleys MC.py for Multiple Choice examples.

Direct current circuit with multiple batteries and resistors
This example covers one of the typical cases that can be found in standard textbooks for first year undergraduate Physics in Physics or Engineering degrees [20]. Figure 4 shows an example where four resistors and two batteries are arranged forming a network with two junctions and three possible loops. Two of the resistors are fixed (R 1 = 10 Ω and R 2 = 12 Ω) and the input parameters that are varied in order to produce the different questions are R 3 , R 4 and the batteries' electromotive forces V 1 and V 2 . The questions that are presented to the students range from finding the intensities I 2 and I 3 flowing through resistors R 2 and R 3 to calculating the power dissipated in resistor R 3 . In all cases, the circuit is solved by using the expressions: and with Solvers which produce questions regarding the intensities I 3 and the power P 3 dissipated by R 3 are given in files EM DC circuit MC.py and EM DC circuit NQ.py for MC and Numerical questions, respectively.

Magnetic field produced by two parallel infinite wires
We first use the expression corresponding to the magnetic field produced by a wire [21,22] (also known in electromagnetism as magnetic flux density [23]). By using the superposition principle, we combine that expression with the field produced by a second parallel wire. Changing the variables defining the geometry of the problem and the intensities flowing through the conductors, many questions can be defined. Currents as defined in figure 5 are taken as positive and the student is required to calculate the total magnetic field at the point marked by a star, which is placed at a distance b from the origin of coordinates and which is given by: with s 1 and s 2 coefficients valued 1 or -1 according to the orientation of currents I 1 and I 2 and µ 0 the permeability of free space. This example is coded in file EM Magnetic Field NQ.py as a Numerical question and in file EM Magnetic Field MC.py as Multiple Choice. [24], we can build questions related to the determination of the density of dry air ρ d = P/(R d T ), with R d = 287 J kg -1 K -1 the gas constant corresponding to the mixture of dry air, P pressure in Pa and T air temperature in K.

Equation of state of air Following relevant literature
The density of moist air ρ m = (P − e)/(R d T ) + e/(R v T ) is computed from the mixture of dry air and water vapour, with R v = 461 J kg -1 K -1 the gas constant corresponding to water vapour and e the partial pressure corresponding to water vapour in the moist air measured in Pa.
The virtual temperature of air T v represents the temperature at which dry air has the same density as a given parcel of moist air and is computed by means of the expression: The expressions above can be combined with Equation (13) to calculate the saturation pressure of water vapour e s in Pa as a function of temperature through a common approximation [25]: with L = 2.5×10 6 J kg -1 the latent heat of evaporation of water. This allows to compute relative humidity defined from water vapour mixing ratio w = ρ v /ρ d as: 4.3.2. Adiabatic evolution of unsaturated air In the last example in this section, potential temperature is computed to determine the adiabatic evolution of air, with c p the specific heat of air at constant pressure. These questions must use pressures and temperatures at given ranges of temperature and pressure at the atmosphere to be meaningful, as shown in example TH adiabatic process NQ.py .

Modern Physics
4.4.1. Relativistic collisions of particles with photons In this example, it is considered that a photon with energy E collides against a particle at rest with mass m = E 0 c 2 and we want to obtain the energy E * m and linear momentum of the particle as seen from the center of mass reference frame (CM-RF). The velocity of the CM-RF is given by: which yields a value of for the CM-RF Lorentz's factor. Thus, the particle's energy after the collision, as seen from the CM-RF is and its linear momentum Example file MP SRelativity CMCollision NQ.py shows the code that produces results for collisions between photons and particles with different energies. As an improvement to previous examples, in this case, the output is written in an ASCII file by the code, and no redirection is needed. In order to get that done, the additional parameter ofile is added to the constructor of the question objects.

Photoelectric effect
Let the photoelectric work function of a metal be W . If light having a wavelength λ shines on the surface, photo-electrons with kinetic energy K will be emitted from the surface provided that the energy of the incident beam is larger than the work function of the metal. These three magnitudes are related by where c is the speed of light and h is Planck's constant. The photoelectric threshold wavelength for the surface is the minimum wavelength needed to eject electrons from the surface: The maximum velocity of an ejected electron is: where m e is the mass of the electron and its corresponding de Broglie wavelength reads The example in file MP photEffect workfunc NQ.py allows to generate questions for the excitation threshold wavelength while the code provided in file MP photEffect ejectedElectrons NQ.py can be used to either obtain the maximum velocity of the ejected electrons or their deBroglie wavelength.

Discussion
There are some question types such as Simple Calculated, Calculated and Calculated MC questions supported in Moodle. Thus, it can be fair to question the need of a module like the one presented in this paper. As we see it, performing the computations in an external language such as python, allows to achieve at least four objectives. First, the degree of complexity of the problems which can be handled can be extended beyond the ones available in the inner core of Moodle.
Second, as shown in some of the examples above, particularly the ones involving the case of the coupled pulleys (Section 4.1) or the DC circuit (Subsection 4.2.1), different versions of similar problems can be prepared using a single set of parameters. With little effort, the amount of generated different problems increases, even if most of them can be solved by applying the same concepts. If the amount of time given for solving the online questionnaire is properly calibrated, the results obtained from the test should be trustworthy as reflecting students' knowledge even if the quiz is unsupervised.
Third, the fact that many parts of the solution are common for the same set of parameters and different questions (see in particular the cases of the coupled pulleys or DC circuit) makes it easier to produce the set of questions by means of the solution proposed in this paper, since these variables are shared during the generation of the questions in the same piece of code, avoiding thus potential coding errors that might happen if the questions were prepared independently.
Fourth, python is a full featured computer language with access to many external modules and packages and with the ability to build complex programs. The capability to write L A T E X code in GIFT questions allows the instructors to build complex equations (determinants or systems of equations for instance). This, combined with the linear algebra routines provided by numpy allow to use this system to solve problems of linear algebra of higher dimension which would be very complex to code directly in Moodle. Additionally, the use of python as the computing core allows the instructors to use external auxiliary functions (see the example TH relative humidity NQ.py for calculating the saturation pressure of water vapour) that are used once and again during the computation of many quantities involved in the solutions of the problems at hand. Having to rewrite them in every question would be very error-prone and time-consuming.
There are many learning environments, such as Moodle, Blackboard or Canvas, to name a few, which support the use of calculated questions. We are addressing in this paper the platform that our university provides to us, but after a revision of the features of calculated (formula) questions in these platforms, the previous statements still stand true. The solution provided here allows more complex computations with better reliability, so that the same methodology could probably be extended to formats allowed by those platforms for importing questions.
We have provided interfaces for producing Numerical questions and Numerical MC questions, which are the ones that we find more relevant from the point of view of teaching Physics and the massive production of questions for a question bank which should allow individual and independent tests for every student. There are, of course, other options in Moodle such as MC text questions which allow challenging conceptual tests in the field of Physics. However, from the point of view of producing those questions, our experience from the past years shows that MC conceptual text questions are better produced directly on the Moodle interface and that a python program would only complicate the steps needed to arrive to the final product (a GIFT file to be imported to the question bank). An additional advantage of using the GIFT format for importing the results into Moodle is that it is a simple ASCII-based format which can be easily read by humans before uploading the file to Moodle, so that inconsistencies can be easily detected. In this first release of the software, we have selected the GIFT format for allowing an easy upload of the questions to the Moodle server. Depending on the configuration of the server, this may make the inclusion of figures rather cumbersome. Images can also be encoded using base64 package into the GIFT file, as shown in EM circuit2 NQ.py . However, this leads to very large and difficult to read GIFT files. Probably, future releases of pygiftgenerator will also export questions in the XML Moodle format to ease the upload of figures and other resources.
We have tested this solution for preparing an online exam for 220 students during the first weeks of COVID-19 lockdown and results seem promising, but a full analysis of the results is not possible, since we lack a control group.

Conclusions
In this contribution we present a python-based flexible module for producing a large amount of Numerical and MC Numerical questions oriented to evaluating students online. This is very relevant currently, during the lockdown due to the COVID-19 pandemic, which has enforced the closure of most schools and universities. In particular, new online tools need to be designed to evaluate students' learning process. If these tools are meant to substitute on-site supervised written exams, they require a minimum guarantee that students will not be able to share answers while solving the exam because of the fact that no one is supervising them in a room. This python module allows to produce a large question bank. All the questions are different but can be classified into categories and types. This way, the probability of students getting quizzes with exactly the same questions is very low, and can be made negligible just by increasing the amount of items prepared. The module is quite flexible, as shown in this contribution and can be used to cover different branches of Physics, with examples selected in this contribution covering many different topics, such as Dynamics, Thermodynamics, Electromagnetism, Special Relativity and Quantum Mechanics. We have selected python because it is a simple programming language. It is very friendly for people who are not programming experts. Its learning curve is not too steep. Besides that, the module presented here is quite easy to use, which makes us think that it can be used by instructors worldwide without a significant inversion of time for learning its working. However, the system is powerful; the examples provided in the documentation of the module show that it can produce many different questions from the same set of parameters with a unique identification and organized in categories. Equations written in L A T E X or even figures can be imported by Moodle from the GIFT files generated.