Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Defining Moodle Elements from R

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

josesamos/moodef

Repository files navigation

CRAN statusR-CMD-checkCodecov test coverageDownloads

The goal of themoodef package is to support the definition ofMoodle elements taking advantage of the powerthat R offers. In particular, in this first version, it allows thedefinition of questions to be included in the question bank to definequizzes.

To define the questions for the quizzes we can use the component forthis purpose that includesMoodle, based on entering data throughscreens. It allows the import and export of questions in variousformats, including XML.

Complementary, using themoodef package, we can define questionnairesfrom R. We have generalized 10 types of questions and simplified theirdefinition. So, we define a question by calling a function or simplyincluding a row in a data frame, a CSV file or anExcel file. Theresult is an XML file that we import intoMoodle. If necessary, someparameter not considered in the generalization can be defined oradjusted there.

The package supports two styles of question definition: the simple styleand the extended style. The following example is based on the simplestyle.

Although not shown in the next example, in each question we can includean image that is embedded in XML. We can set up the size of the imagesso that they are homogeneous when displayed in quizzes.

In addition to facilitating the definition of questions manually, theinfrastructure offered by this package can be used to generate questionsautomatically or semi-automatically from R.

Installation

You can install the released version ofwhen fromCRAN with:

install.packages("moodef")

And the development version fromGitHub with:

# install.packages("pak")pak::pak("josesamos/moodef")

Example

This is a basic example which shows the definition of a question usingthe function:

library(moodef)qc<- question_category(category='Initial test',copyright='Copyright © 2025 Universidad de Granada',license='License Creative Commons Attribution-ShareAlike 4.0',author='Jose Samos')|>  define_question(question='What are the basic arithmetic operations?',answer='Addition, subtraction, multiplication and division.',a_1='Addition and subtraction.',a_2='Addition, subtraction, multiplication, division and square root.'  )file<- tempfile(fileext='.xml')qc<-qc|>  generate_xml_file(file)

First, we create an object using thequestion_category function andconfigure general aspects of the definition in it. Next, we define thequestions, as many as we need, using thedefine_question function (thetype of the questions is deduced from the definition). Finally, wegenerate the questions in XML format, in the form of a string or file.We show the result below.

<?xml version="1.0" encoding="UTF-8"?><quiz>  <questiontype="category">    <category>      <text>$course$/top/Initial test</text>    </category>    <infoformat="html">      <text></text>    </info>    <idnumber></idnumber>  </question>  <questiontype="multichoice">    <name>      <text>q_001_multichoice_what_are_the_basic_arithmetic_operations</text>    </name>    <questiontextformat="html">      <text><![CDATA[        <!-- Copyright © 2025 Universidad de Granada -->        <!-- License Creative Commons Attribution-ShareAlike 4.0 -->        <!-- Author: Jose Samos -->        <p>What are the basic arithmetic operations?</p>]]></text>    </questiontext>    <generalfeedbackformat="html">      <text></text>    </generalfeedback>    <defaultgrade>1.0</defaultgrade>    <penalty>0.5</penalty>    <hidden>0</hidden>    <idnumber></idnumber>    <single>true</single>    <shuffleanswers>true</shuffleanswers>    <answernumbering>abc</answernumbering>    <showstandardinstruction>0</showstandardinstruction>    <correctfeedbackformat="moodle_auto_format">      <text>Correct.</text>    </correctfeedback>    <partiallycorrectfeedbackformat="moodle_auto_format">      <text>Partially correct.</text>    </partiallycorrectfeedback>    <incorrectfeedbackformat="moodle_auto_format">      <text>Incorrect.</text>    </incorrectfeedback>    <answerfraction="100"format="html">      <text>Addition, subtraction, multiplication and division.</text>      <feedbackformat="html">        <text>Correct.</text>      </feedback>    </answer>    <answerfraction="0"format="html">      <text>Addition and subtraction.</text>      <feedbackformat="html">        <text>Incorrect.</text>      </feedback>    </answer>    <answerfraction="0"format="html">      <text>Addition, subtraction, multiplication, division and square root.</text>      <feedbackformat="html">        <text>Incorrect.</text>      </feedback>    </answer>  </question></quiz>

We can call thedefine_question function for each question to bedefined, with the same parameters. Alternatively, we can create a dataframe, a CSV file or anExcel file (with the functions available inthe package) and include in them a row for each question, a column foreach parameter. Below is the content of a CSV file in table format.

typequestionimageimage_altanswera_1a_2
What are the basic arithmetic operations?Addition, subtraction, multiplication and division.Addition and subtraction.Addition, subtraction, multiplication, division and square root.
Match each operation with its symbol.Addition<|>+Subtraction<|>-Multiplication<|>*
The square root is a basic arithmetic operation.False
What basic operation does it have as a + symbol?Addition
The symbol for addition is [[1]], the symbol for subtraction is [[2]].+-
xThe symbol for addition is [[1]], the symbol for subtraction is [[2]].+-
hSort the result from smallest to largest.6/26-26+2
vSort the result from smallest to largest.6/26-26+2
What is the result of SQRT(4)?2-2
What is the result of 4/3?1.33<|>0.03
Describe the addition operation.

The generation of the questions would be similar, as shown below.

file<- system.file("extdata","questions.csv",package="moodef")qc<- question_category(category='Initial test',copyright='Copyright © 2025 Universidad de Granada',license='License Creative Commons Attribution-ShareAlike 4.0',author='Jose Samos')|>  define_questions_from_csv(file=file)file<- tempfile(fileext='.xml')qc<-qc|>  generate_xml_file(file)

We do not show the content of the XML file obtained because in thatexample there are several questions defined and it takes up a lot ofspace.

About

Defining Moodle Elements from R

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp