Package 'learnrhash'

Title: Tools for hashing learnr sessions
Description: This package provides tools for the hashing of learnr sessions. The resulting hashes are presented as base64 encoded strings which can easily be copied into a web form, LMS submission tool, etc.
Authors: Colin Rundel [aut, cre], Mine Cetinkaya-Rundel [aut]
Maintainer: Colin Rundel <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2024-11-21 04:35:17 UTC
Source: https://github.com/rundel/learnrhash

Help Index


Decode hashed text into an R object

Description

Decode hashed text into an R object

Usage

decode_obj(txt, compress = c("bzip2", "gzip", "xz", "none"))

Arguments

txt

Hashed text.

compress

Compression method.


Encode an R object into hashed text

Description

Encode an R object into hashed text

Usage

encode_obj(obj, compress = c("bzip2", "gzip", "xz", "none"))

Arguments

obj

R object

compress

Compression method.


Extract hash contents

Description

The following are helper functions for extracting data from hashed learnr solutions.

  • extract_hash - extracts the contents of the hashes into label, type, answer, correct, and timestamp columns

  • extract_questions - extracts the contents of the hashes for answered questions.

  • extract_exercises - extracts the contents of the hashes for answered exercises.

Usage

extract_hash(df, hash = "hash")

extract_exercises(df, hash = "hash")

extract_questions(df, hash = "hash")

Arguments

df

Data Frame. A data frame containing hash in a character column.

hash

Character. The name of the column containing the hashes


Learnr addon elements

Description

The following are addon element for learnr tutorials that enable the encoding and decoding of hashed learnr solutions.

Note that when including these functions in a learnr Rmd document it is necessary that the logic functions, ⁠*_logic()⁠, be included in an R chunk where context="server" as they interact with the underlying Shiny functionality. Conversely, any of the ui functions, ⁠*_ui()⁠, must not be included in an R chunk with a context. Both types of functions have been written to provide useful feedback if they detect they are in the wrong R chunk type.

Usage

decoder_logic()

decoder_ui()

encoder_logic(strip_output = FALSE)

default_ui(url = "http://google.com")

iframe_ui(src = "http://google.com", ...)

encoder_ui(ui_before = default_ui(), ui_after = NULL)

Arguments

strip_output

Exercises save their output as html, for exercises that result in plots these can result in very large hashes. The option allows this information to be removed to keep hash sizes more manageable.

url

Link url to use.

src

Source of the iframe.

...

Other iframe attributes, e.g. height and width

ui_before

Shiny ui elements to include before the hash ui

ui_after

Shiny ui elements to include after the hash ui,

Details

For either of the ui parameters you can wrap multiple shiny elements together with shiny::div.