Type: | Package |
Title: | Defining 'Moodle' Elements from R |
Version: | 1.2.0 |
Description: | The main objective of this package is to support the definition of 'Moodle' elements taking advantage of the power that R offers. In this first version, it allows the definition of quizzes to be included in the question bank. |
License: | MIT + file LICENSE |
URL: | https://josesamos.github.io/moodef/, https://github.com/josesamos/moodef |
BugReports: | https://github.com/josesamos/moodef/issues |
Imports: | blastula, dplyr, glue, magick, readr, readxl, snakecase, tibble, tidyr, tools, xlsx, xml2 |
Suggests: | knitr, pander, rmarkdown, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
Language: | en-GB |
LazyData: | true |
RoxygenNote: | 7.3.2 |
Depends: | R (≥ 3.5) |
NeedsCompilation: | no |
Packaged: | 2025-01-26 12:48:14 UTC; jsamos |
Author: | Jose Samos |
Maintainer: | Jose Samos <jsamos@ugr.es> |
Repository: | CRAN |
Date/Publication: | 2025-01-26 13:10:02 UTC |
Resize and Center an Image
Description
Resizes an image to fit within the specified dimensions, centering it on a blank canvas.
Usage
adapt_image(image_file, width = 800, height = 600)
Arguments
image_file |
|
width |
|
height |
|
Value
A string representing the path to the new resized image file.
Allowed Question Types
Description
A vector of allowed question types for validation in the package.
Usage
allowed_types
Format
A character vector with 12 elements, including:
"numerical"
Numerical questions
"multichoice"
Multiple-choice questions
"ordering"
Ordering questions
"ordering<|>h"
Horizontal ordering questions
"ordering<|>v"
Vertical ordering questions
"ddwtos"
Drag-and-drop words into sentences
"gapselect"
Gap select questions
"matching"
Matching questions
"essay"
Essay questions
"truefalse"
True/False questions
"shortanswer"
Short-answer questions
"ddmarker"
Drag-and-drop markers
Define the category of questions
Description
Define the category of questions
Usage
category_question(category, questions)
Arguments
category |
A string, category name. |
questions |
A string, formatted questions. |
Value
A string.
Create a question data frame common to normal and extended questions.
Description
Create a question data frame common to normal and extended questions.
Usage
create_common_question_df()
Create a question data frame common to normal and extended questions with default values.
Description
Create a question data frame common to normal and extended questions with default values.
Usage
create_default_value_question_df()
Create a question csv file
Description
Creates an empty question csv file.
Usage
create_question_csv(file, sep = ",", extended = FALSE)
Arguments
file |
A string, name of a text file. |
sep |
Column separator character. |
extended |
A Boolean, use extended question definition. |
Value
A string.
See Also
Other support functions:
create_question_data_frame()
,
create_question_excel()
,
read_question_csv()
,
read_question_excel()
,
vector_to_string()
Examples
file <- create_question_csv(file = tempfile(fileext = '.csv'))
Create a question data frame
Description
Creates an empty question data frame.
Usage
create_question_data_frame(extended = FALSE)
Arguments
extended |
A Boolean, use extended question definition. |
Value
A data frame.
See Also
Other support functions:
create_question_csv()
,
create_question_excel()
,
read_question_csv()
,
read_question_excel()
,
vector_to_string()
Examples
df <- create_question_data_frame()
Create a question Excel file
Description
Creates an empty question Excel file.
Usage
create_question_excel(file, extended = FALSE)
Arguments
file |
A string, name of a text file. |
extended |
A Boolean, use extended question definition. |
Value
A string.
See Also
Other support functions:
create_question_csv()
,
create_question_data_frame()
,
read_question_csv()
,
read_question_excel()
,
vector_to_string()
Examples
file <- create_question_excel(file = tempfile(fileext = '.xlsx'))
Define an extended question
Description
This function allows users to define an extended question, including metadata, feedback and optional image data.
Usage
define_extended_question(
qc,
category,
type,
fraction,
id,
name,
author,
fb_general,
fb_correct,
fb_partially,
fb_incorrect,
question,
image,
image_alt,
answer,
a_1,
a_2,
a_3,
a_4,
a_5,
a_6,
a_7,
fb_answer,
fb_a_1,
fb_a_2,
fb_a_3,
fb_a_4,
fb_a_5,
fb_a_6,
fb_a_7,
tag_1,
tag_2,
tag_3,
tag_4,
tag_5,
tag_6,
tag_7,
tag_8,
tag_9
)
## S3 method for class 'question_category'
define_extended_question(
qc,
category = "",
type = "",
fraction = 0,
id = "",
name = "",
author = "",
fb_general = "",
fb_correct = "",
fb_partially = "",
fb_incorrect = "",
question = "",
image = "",
image_alt = "",
answer = "",
a_1 = "",
a_2 = "",
a_3 = "",
a_4 = "",
a_5 = "",
a_6 = "",
a_7 = "",
fb_answer = "",
fb_a_1 = "",
fb_a_2 = "",
fb_a_3 = "",
fb_a_4 = "",
fb_a_5 = "",
fb_a_6 = "",
fb_a_7 = "",
tag_1 = "",
tag_2 = "",
tag_3 = "",
tag_4 = "",
tag_5 = "",
tag_6 = "",
tag_7 = "",
tag_8 = "",
tag_9 = ""
)
Arguments
qc |
A question category object. It should have a |
category |
A character string specifying the category of the question. |
type |
A character string indicating the type of the question. |
fraction |
A number between 0 and 1. |
id |
A unique identifier for the question. |
name |
A character string representing the name of the question. |
author |
The name of the author of the question. |
fb_general |
General feedback for the question. |
fb_correct |
Feedback displayed when the correct answer is selected. |
fb_partially |
Feedback displayed for partially correct answers. |
fb_incorrect |
Feedback displayed for incorrect answers. |
question |
The text of the question. |
image |
Path to an image file associated with the question. |
image_alt |
Alternative text describing the image for accessibility. Required if an image is provided. |
answer |
The correct answer to the question. |
a_1 |
Additional possible answer. |
a_2 |
Additional possible answer. |
a_3 |
Additional possible answer. |
a_4 |
Additional possible answer. |
a_5 |
Additional possible answer. |
a_6 |
Additional possible answer. |
a_7 |
Additional possible answer. |
fb_answer |
Feedback for the correct answer. |
fb_a_1 |
Feedback for additional answer. |
fb_a_2 |
Feedback for additional answer. |
fb_a_3 |
Feedback for additional answer. |
fb_a_4 |
Feedback for additional answer. |
fb_a_5 |
Feedback for additional answer. |
fb_a_6 |
Feedback for additional answer. |
fb_a_7 |
Feedback for additional answer. |
tag_1 |
Tag to categorize the question. |
tag_2 |
Tag to categorize the question. |
tag_3 |
Tag to categorize the question. |
tag_4 |
Tag to categorize the question. |
tag_5 |
Tag to categorize the question. |
tag_6 |
Tag to categorize the question. |
tag_7 |
Tag to categorize the question. |
tag_8 |
Tag to categorize the question. |
tag_9 |
Tag to categorize the question. |
Details
Parameter values that are not defined are taken from the category definition, if they are defined there.
The fraction
attribute is used in various question types to determine how a
specific answer impacts the question's score. Specifically, for incorrect answers
in the multichoice
and truefalse
types, the value calculated by dividing
fraction
by the number of incorrect answers available is considered as the
amount deducted in case of an incorrect response.
In the example provided, we have intentionally used the same structure as in
the define_question()
function to demonstrate that any parameters not needed
do not need to be explicitly defined.
Value
Returns the updated question category object.
See Also
Other question definition functions:
define_question()
,
define_questions_from_csv()
,
define_questions_from_data_frame()
,
define_questions_from_excel()
,
generate_xml()
,
generate_xml_file()
,
question_category()
Examples
qc <- question_category(category = 'Initial test') |>
define_extended_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.'
)
Define a question
Description
Define a question and the possible answers. The type of question is deduced.
Usage
define_question(qc, type, question, image, image_alt, answer, ...)
## S3 method for class 'question_category'
define_question(
qc,
type = "",
question = "",
image = "",
image_alt = "",
answer = "",
...
)
Arguments
qc |
A |
type |
A string, question type (if needed). |
question |
A string, statement of the question. |
image |
A string, optional, image file to include in the question. |
image_alt |
A string, description of the image to include in the question. |
answer |
A string, correct answer to the question. |
... |
A string, rest of the answers to the question. |
Details
If we include an image in the question, we must also include text in the alt
field associated with it.
After the correct answer, we can indicate as many answers as we want, if we do not indicate all the parameters, we have to give each answer a parameter name different from the rest of the parameter names.
Value
A question_category
.
See Also
Other question definition functions:
define_extended_question()
,
define_questions_from_csv()
,
define_questions_from_data_frame()
,
define_questions_from_excel()
,
generate_xml()
,
generate_xml_file()
,
question_category()
Examples
qc <- question_category(category = 'Initial test') |>
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.'
)
Define questions from a csv file
Description
Each row in the text file is interpreted as a question. We only have to define the columns that we are going to use, the rest of the columns are taken by default.
Usage
define_questions_from_csv(qc, file, sep)
## S3 method for class 'question_category'
define_questions_from_csv(qc, file, sep = ",")
Arguments
qc |
A |
file |
A string, name of a text file. |
sep |
Column separator character. |
Details
For answers where a vector is required, "<|>" is used as a separator of the vector elements.
Value
A question_category
.
See Also
Other question definition functions:
define_extended_question()
,
define_question()
,
define_questions_from_data_frame()
,
define_questions_from_excel()
,
generate_xml()
,
generate_xml_file()
,
question_category()
Examples
file <- system.file("extdata", "questions.csv", package = "moodef")
qc <-
question_category(category = 'Initial test', adapt_images = TRUE) |>
define_questions_from_csv(file = file)
Define questions from a data frame
Description
Each row in the text data frame is interpreted as a question. We only have to define the columns that we are going to use, the rest of the columns are taken by default.
Usage
define_questions_from_data_frame(qc, df)
## S3 method for class 'question_category'
define_questions_from_data_frame(qc, df)
Arguments
qc |
A |
df |
A data frame. |
Details
For answers where a vector is required, "<|>" is used as a separator of the vector elements.
Value
A question_category
.
See Also
Other question definition functions:
define_extended_question()
,
define_question()
,
define_questions_from_csv()
,
define_questions_from_excel()
,
generate_xml()
,
generate_xml_file()
,
question_category()
Examples
file <- system.file("extdata", "questions.csv", package = "moodef")
df <- read_question_csv(file = file)
qc <-
question_category(category = 'Initial test', adapt_images = TRUE) |>
define_questions_from_data_frame(df)
Define questions from a data frame
Description
Define questions from a data frame
Usage
define_questions_from_df(qc, df)
Define questions from a Excel file
Description
Each row in the Excel file is interpreted as a question. We only have to define the columns that we are going to use, the rest of the columns are taken by default.
Usage
define_questions_from_excel(qc, file, sheet_index, sheet_name)
## S3 method for class 'question_category'
define_questions_from_excel(qc, file, sheet_index = NULL, sheet_name = NULL)
Arguments
qc |
A |
file |
A string, name of an Excel file. |
sheet_index |
A number, sheet index in the workbook. |
sheet_name |
A string, sheet name. |
Details
In addition to the file, we can indicate the sheet by its name or index. If we do not indicate anything, it considers the first sheet.
For answers where a vector is required, "<|>" is used as a separator of the vector elements.
Value
A question_category
.
See Also
Other question definition functions:
define_extended_question()
,
define_question()
,
define_questions_from_csv()
,
define_questions_from_data_frame()
,
generate_xml()
,
generate_xml_file()
,
question_category()
Examples
file <- system.file("extdata", "questions.xlsx", package = "moodef")
qc <-
question_category(category = 'Initial test', adapt_images = TRUE) |>
define_questions_from_excel(file = file)
Determine question type
Description
Determines the type of the question based on its content, provided answers, and optional type parameter.
Usage
determine_question_type(type, question, answer, a_values)
Arguments
type |
A string, suggested type for the question. |
question |
A string, the main question text. |
answer |
A string or vector, the correct answer(s) for the question. |
a_values |
A vector, additional answers for the question. |
Value
A string indicating the question type.
Extract Type and Orientation
Description
This function takes a string representing a question type and its optional orientation
(e.g., "ordering<|>h"
) and splits it into two separate components: the type and
the orientation. If the orientation is not provided, it defaults to "v"
.
Usage
extract_type_orientation(type)
Arguments
type |
A character string indicating the type of a question, which may optionally
include an orientation separated by |
Value
A list with two elements:
- type
The main question type as a character string.
- orientation
The orientation of the type as a character string. Defaults to
"v"
.
Filter non-empty answers
Description
Filters additional answers provided in ...
to ensure only non-empty answers
are included in the final output.
Usage
filter_non_empty_answers(...)
Arguments
... |
Strings, additional answers. |
Value
A vector of non-empty answers.
Generate ddmarker
question
Description
Generate ddmarker
question
Usage
generate_ddmarker(image, image_alt, answer, fb_answer)
Arguments
image |
A string, optional, image file to include in the question. |
image_alt |
A string, description of the image to include in the question. |
answer |
A string vector. |
fb_answer |
A string, answer feedback. |
Value
A string.
Generate ddwtos
question
Description
Generate ddwtos
question
Usage
generate_ddwtos(
answer,
a_values,
correct_feedback,
incorrect_feedback,
partially_correct_feedback
)
Arguments
answer |
A vector of strings. |
a_values |
A vector, rest of answers. |
correct_feedback |
A string. |
incorrect_feedback |
A string. |
partially_correct_feedback |
A string. |
Value
A string.
Generate essay
question
Description
Generate essay
question
Usage
generate_essay()
Value
A string.
Generate gapselect
question
Description
Generate gapselect
question
Usage
generate_gapselect(
answer,
a_values,
correct_feedback,
incorrect_feedback,
partially_correct_feedback
)
Arguments
answer |
A vector of strings. |
a_values |
A vector, rest of answers. |
correct_feedback |
A string. |
incorrect_feedback |
A string. |
partially_correct_feedback |
A string. |
Value
A string.
Generate matching
question
Description
Generate matching
question
Usage
generate_matching(
answer,
a_values,
correct_feedback,
incorrect_feedback,
partially_correct_feedback
)
Arguments
answer |
A vector of strings. |
a_values |
A vector, rest of answers. |
correct_feedback |
A string. |
incorrect_feedback |
A string. |
partially_correct_feedback |
A string. |
Value
A string.
Generate multichoice
question
Description
Generate multichoice
question
Usage
generate_multichoice(
answer,
a_values,
correct_feedback,
incorrect_feedback,
fb_partially,
fb_answer,
fb_a_values,
fraction
)
Arguments
answer |
A string. |
a_values |
A vector, rest of answers. |
correct_feedback |
A string. |
incorrect_feedback |
A string. |
fb_partially |
A string. |
fb_answer |
A string, answer feedback. |
fb_a_values |
A vector, rest of answer feedback. |
fraction |
A number between 0 and 1. |
Value
A string.
Generate numerical
question
Description
Generate numerical
question
Usage
generate_numerical(answer, a_values, fb_answer, fb_a_values)
Arguments
answer |
A vector of strings. |
a_values |
A vector, rest of answers. |
fb_answer |
A string, answer feedback. |
fb_a_values |
A vector, rest of answer feedback. |
Value
A string.
Generate ordering
question
Description
Generate ordering
question
Usage
generate_ordering(
answer,
a_values,
correct_feedback,
incorrect_feedback,
partially_correct_feedback,
orientation
)
Arguments
answer |
A vector of strings. |
a_values |
A vector, rest of answers. |
correct_feedback |
A string. |
incorrect_feedback |
A string. |
partially_correct_feedback |
A string. |
orientation |
A string, 'h' or 'v'. |
Value
A string.
Generate the question body
Description
Creates the body of the question based on its type and additional parameters such as feedback and orientation.
Usage
generate_question_body(
type,
answer,
a_values,
fb_correct,
fb_incorrect,
fb_partially,
orientation,
fb_answer,
fb_a_values,
image,
image_alt,
fraction
)
Arguments
type |
A string, the question type. |
answer |
A string or vector, the correct answer(s) for the question. |
a_values |
A vector, additional answers for the question. |
fb_correct |
A string, feedback for correct answers. |
fb_incorrect |
A string, feedback for incorrect answers. |
fb_partially |
A string, feedback for partially correct answers. |
orientation |
A string, 'v' or 'h'. |
fb_answer |
A string, answer feedback. |
fb_a_values |
A vector, rest of answer feedback. |
image |
Path to an image file associated with the question. |
image_alt |
Alternative text describing the image for accessibility. |
fraction |
A number between 0 and 1. |
Value
A string containing the question body in XML format.
generate question name
node
Description
generate question name
node
Usage
generate_question_name(first_question_number, type, question)
Arguments
first_question_number |
An integer, first number to compose the question names. |
type |
A string, question type (if needed). |
question |
A string, statement of the question. |
Value
A string.
Generate shortanswer
question
Description
Generate shortanswer
question
Usage
generate_shortanswer(answer, fb_answer)
Arguments
answer |
A string. |
fb_answer |
A string, answer feedback. |
Value
A string.
Generate truefalse
question
Description
Generate truefalse
question
Usage
generate_truefalse(answer, fb_answer, fb_a_values, fraction)
Arguments
answer |
A string. |
fb_answer |
A string, answer feedback. |
fb_a_values |
A vector, rest of answer feedback. |
fraction |
A number between 0 and 1. |
Value
A string.
Generate questions xml string
Description
Generate questions xml string
Usage
generate_xml(qc)
## S3 method for class 'question_category'
generate_xml(qc)
Arguments
qc |
A |
Value
A string.
See Also
Other question definition functions:
define_extended_question()
,
define_question()
,
define_questions_from_csv()
,
define_questions_from_data_frame()
,
define_questions_from_excel()
,
generate_xml_file()
,
question_category()
Examples
qc <- question_category(category = 'Initial test') |>
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.'
)
xml <- qc |>
generate_xml()
Generate questions xml file
Description
Generate questions xml file
Usage
generate_xml_file(qc, file)
## S3 method for class 'question_category'
generate_xml_file(qc, file = NULL)
Arguments
qc |
A |
file |
A string, file name. |
Value
A question_category
.
See Also
Other question definition functions:
define_extended_question()
,
define_question()
,
define_questions_from_csv()
,
define_questions_from_data_frame()
,
define_questions_from_excel()
,
generate_xml()
,
question_category()
Examples
qc <- question_category(category = 'Initial test') |>
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.'
) |>
generate_xml_file(file = tempfile(fileext = '.xml'))
Get Detailed Type Names
Description
Determines the type
column of a data frame based on specific conditions and
the content of other columns in the data frame.
Usage
get_detailed_type_names(df)
Arguments
df |
A data frame containing at least the following columns:
|
Details
It checks if some value in the type
column are within the allowed set
('', 'h', 'v', 'x'
) and updates each row based on the associated answers
and other fields.
Value
A character vector containing the updated type
values.
Get non-empty values from fields with a specific prefix
Description
This function takes a dataframe, a row index, and a prefix, returning a vector with the content of columns that start with the given prefix and are not empty.
Usage
get_non_empty_fields_by_prefix(df, i, prefix)
Arguments
df |
A dataframe containing the relevant columns. |
i |
An integer representing the row index. |
prefix |
A string representing the prefix of the column names (e.g., "a_", "fb_a_", "tag_"). |
Value
A vector with non-empty values from the fields with the given prefix in the specified row.
Convert Answer String to Vector
Description
Converts an answer string into a vector using string_to_vector
.
If the input is NULL
, it returns an empty string.
Usage
get_vector_answer(answer)
Arguments
answer |
A character string representing the answer. |
Value
A vector if the answer is successfully converted, or an empty string if the answer is NULL
.
Check if a String Contains Gaps
Description
Checks if a string contains the specific substrings "[[1]]"
and "[[2]]"
.
Usage
has_gaps(str)
Arguments
str |
|
Value
logical
TRUE
if the string contains gaps, FALSE
otherwise.
Check if a String Represents a Numeric Value
Description
Verifies if a string can be converted to a numeric value.
Usage
is_numeric(str)
Arguments
str |
|
Value
logical
TRUE
if the string is numeric, FALSE
otherwise.
Process Question DataFrame
Description
Processes a dataframe by converting columns to character type, handling NAs, and renaming attributes to snake_case.
Usage
process_question_dataframe(df)
Arguments
df |
A dataframe to process. |
Value
A processed dataframe.
question_category
S3 class
Description
Creates a question_category
object.
Usage
question_category(
category = "Default category",
first_question_number = 1,
copyright = "",
license = "",
correct_feedback = "Correct.",
partially_correct_feedback = "Partially correct.",
incorrect_feedback = "Incorrect.",
adapt_images = FALSE,
width = 800,
height = 600,
author = "",
fraction = 0
)
Arguments
category |
A string, category name. |
first_question_number |
An integer, first number to compose the question names. |
copyright |
A string, copyright text to be included in each question that is defined. |
license |
A string, license text to be included in each question that is defined. |
correct_feedback |
A string, feedback on correct answers to each question. |
partially_correct_feedback |
A string, feedback on partially correct answers to each question. |
incorrect_feedback |
A string, feedback on incorrect answers to each question. |
adapt_images |
A boolean, adapt the images so that they are a similar size. |
width |
A integer, width of each image. |
height |
A integer, height of each image. |
author |
A string, author name to be included in each question that is defined. |
fraction |
A number between 0 and 1. |
Details
Defines a category of questions to be included in the Moodle question bank.
It allows us to define the name of the category, the copyright and license literals that will be added to each question, and the feedback literals for correct, partially correct and incorrect questions.
Each question can include an image after the text. We can also configure if we want to automatically transform the images so that they have a standard size that we can also indicate.
The fraction
attribute is used in various question types to determine how a
specific answer impacts the question's score. Specifically, for incorrect answers
in the multichoice
and truefalse
types, the value calculated by dividing
fraction
by the number of incorrect answers available is considered as the
amount deducted in case of an incorrect response.
Value
A question_category
object.
See Also
Other question definition functions:
define_extended_question()
,
define_question()
,
define_questions_from_csv()
,
define_questions_from_data_frame()
,
define_questions_from_excel()
,
generate_xml()
,
generate_xml_file()
Examples
qc <- question_category(category = 'Initial test')
Read a question csv file
Description
Reads a csv file of questions and returns a data frame.
Usage
read_question_csv(file, sep = ",")
Arguments
file |
A string, name of a text file. |
sep |
Column separator character. |
Value
A data frame.
See Also
Other support functions:
create_question_csv()
,
create_question_data_frame()
,
create_question_excel()
,
read_question_excel()
,
vector_to_string()
Examples
file <- system.file("extdata", "questions.csv", package = "moodef")
df <- read_question_csv(file = file)
Read a question Excel file
Description
Reads an Excel file of questions and returns a data frame.
Usage
read_question_excel(file, sheet_index = NULL, sheet_name = NULL)
Arguments
file |
A string, name of a text file. |
sheet_index |
A number, sheet index in the workbook. |
sheet_name |
A string, sheet name. |
Details
In addition to the file, we can indicate the sheet by its name or index. If we do not indicate anything, it considers the first sheet.
Value
A data frame.
See Also
Other support functions:
create_question_csv()
,
create_question_data_frame()
,
create_question_excel()
,
read_question_csv()
,
vector_to_string()
Examples
file <- system.file("extdata", "questions.xlsx", package = "moodef")
df <- read_question_excel(file = file)
Simplified Question Types
Description
A vector of simplified question types used internally in the package.
Usage
simplified_types
Format
A character vector with 4 elements:
""
Empty type
"h"
Horizontal type
"v"
Vertical type
"x"
Other type
Transform a String into a String-Formatted Vector
Description
Converts a string into a string-formatted vector (e.g., "a<|>b<|>c"
-> c("a", "b", "c")
).
Usage
string_to_string_vector(str)
Arguments
str |
|
Value
A string representing a vector in R syntax (e.g., c("a", "b", "c")
), or "\"\""
if the input string is empty.
Transform a String into a Vector of Strings
Description
Splits a string into a vector of strings using "<|>" as a delimiter.
Usage
string_to_vector(str)
Arguments
str |
|
Value
A vector of strings (character
), or NULL
if the input string is empty.
Transforms a vector of strings into a string
Description
Insert the separator that we consider to later perform the reverse operation.
Usage
vector_to_string(vector)
Arguments
vector |
A vector of strings. |
Value
A string.
See Also
Other support functions:
create_question_csv()
,
create_question_data_frame()
,
create_question_excel()
,
read_question_csv()
,
read_question_excel()
Examples
s <- vector_to_string(c('Addition', '+'))
Generate HTML and XML Representations for an Image
Description
This function generates an HTML <img>
tag and an XML <file>
tag for a given image.
The image can be processed to adjust its dimensions and encoded in base64 for embedding.
Usage
xml_image(image, image_alt, adapt_images = FALSE, width = NULL, height = NULL)
Arguments
image |
|
image_alt |
|
adapt_images |
|
width |
|
height |
|
Details
If
adapt_images = TRUE
, the function resizes the image using the specified dimensions.If
adapt_images = FALSE
, the function reads the image's original dimensions and uses them.The image is embedded as a base64 string in the
<file>
tag for compatibility with XML-based systems.
Value
A list with two elements:
img
character
: HTML string containing the<img>
tag.fimg
character
: XML string containing the base64-encoded<file>
tag.
Define the question in xml
Description
Define the question in xml
Usage
xml_question(type, name, questiontext, question_body, question_tags = "")
Arguments
type |
A string, question type. |
name |
A string, question name. |
questiontext |
A string, question text. |
question_body |
A string, question tags. |
Value
A string.
Define the question category in xml
Description
Define the question category in xml
Usage
xml_question_category(category)
Arguments
category |
A string, category name. |
Value
A string.
Define the question id number in xml
Description
Define the question id number in xml
Usage
xml_question_idnumber(idnumber)
Arguments
idnumber |
A string, question id number. |
Value
A string.
Define the question name in xml
Description
Define the question name in xml
Usage
xml_question_name(name)
Arguments
name |
A string, question name. |
Value
A string.
Define the question tags in xml
Description
Define the question tags in xml
Usage
xml_question_tags(tag_values)
Arguments
tag_values |
A string, tag values. |
Value
A string.
generate questiontext
node
Description
generate questiontext
node
Usage
xml_questiontext(
copyright,
license,
adapt_images,
width,
height,
question,
image,
image_alt,
type,
author,
fb_general,
idnumber
)
Arguments
copyright |
A string, copyright text to be included in each question that is defined. |
license |
A string, license text to be included in each question that is defined. |
adapt_images |
A boolean, adapt the images so that they are a similar size. |
width |
A integer, width of each image. |
height |
A integer, height of each image. |
question |
A string, statement of the question. |
image |
A string, optional, image file to include in the question. |
image_alt |
A string, description of the image to include in the question. |
type |
A string, question type. |
author |
A string, author name to be included in each question that is defined. |
fb_general |
A string, general feedback to be included in each question that is defined. |
idnumber |
A string, idnumber to be included in each question that is defined. |
Value
A string.