Giter Site home page Giter Site logo

bblearntools's Introduction

BBLearnTools

Tools in Python for writing math and quizzes for Blackboard Learn ("Original View", not "Ultra". It seems that Blackboard "Ultra" restricted the ways of uploading questions, which makes blackjax and bbtextquiz incompatible with Ultra).

Blackboard Learn is a widespread commercial LMS (Learning Management System).

BBLearnTools is not affiliated with or endorsed by Blackboard Inc. BBLearnTools is made available under the terms of the MIT License.

Modules in BBLearnTools:

  • blackjax: for rendering math in Blackboard with Mathjax2.
  • bbtextquiz: for writing pools of questions in text files, that can be uploaded to Blackboard.

Module blackjax

LaTeX syntax for math content can be used in blackboard's text editor. This LaTeX code can be interpreted by MathType and rendered with images. The result is not always satisfying. An not very-known alternative is to use Mathjax2, instead of the default MathType, to render math content.

Blackjax provides tools to convert text written outside of Blackboard Learn, into text whose math can sucessfully be rendered by Mathjax2 within Blackboard Learn (in most Blakboard tools, but not all of them; not, for instance, in discussion boards).

How to use Mathjax in Blackboard

To use MathJax in blackboard, you just need to insert in your text (in the source code window of the text editor in Blackboard) the call to mathjax

<script type="text/javascript" async src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS_CHTML"></script>

and write your math delimited with \(...\) (inline math) and \[...\] or \begin{equation}... \end{equation}(display math), following the following rule: don't leave any whitespace or newline character in math mode. You may replace them with HTML non-breakable spaces (&nbsp;). This is because Blackboard may insert formatting code at these places, and break the LaTeX code before it is interpreted by MathJax.

Blackjax just adapts your text so that it fulfills these requirements.

Example:

In Python, load blackjaxify:

from blackjax import blackjaxify

and define

s = r'''Consider the function $f$, periodic with period $2 \, \pi$,
that fulfills:
<br>
$$f(x) = \left\lbrace
\begin{matrix}
1 &  \text{ for } x \in (-\pi;0),\\
-x + 1  & \text{ for } x \in [0;\pi].
\end{matrix}
\right.$$
<br>
Find the coefficient $b_5$ of the Fourier series of $f$.'''

Then

print(blackjaxify(s))

gives:

<script type='text/javascript' async src='https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS_CHTML'></script>
Consider the function \(f\), periodic with period \(2&nbsp;\,&nbsp;\pi\),
that fulfills:
<br>
\begin{equation}f(x)&nbsp;=&nbsp;\left\lbrace&nbsp;\begin{matrix}&nbsp;1&nbsp;&&nbsp;&nbsp;\text{&nbsp;for&nbsp;}&nbsp;x&nbsp;\in&nbsp;(-\pi;0),\\&nbsp;-x&nbsp;+&nbsp;1&nbsp;&nbsp;&&nbsp;\text{&nbsp;for&nbsp;}&nbsp;x&nbsp;\in&nbsp;[0;\pi].&nbsp;\end{matrix}&nbsp;\right.\end{equation}
<br>
Find the coefficient \(b_5\) of the Fourier series of \(f\).

This string can now be copied & pasted in blackboard's editor (in the source code window) or used in pools of questions that can be uploaded as text files (Note that in this case, all newline characters should be erased).

This is now rendered in Blackboard as:

Steps

  • write your text. Use LaTeX syntaxis for math, delimited with $...$ or \(...\) for inline math, and $$...$$, \[...], \begin{equation}...\end{eqution}, \begin{align}...\end{align}for display math. Use HTML tags for formatting text, in particular <br> for newlines (the ordinary newline chars won't be kept).

  • In python, save your text in a string and apply blackjaxify.

Caveat

Calling Mathjax depends on the availability and accessibility of the Mathjax CDN services.

References

See the wiki.

Module bbtextquiz

Blackboard ("Original view") offers the possibility to upload pools of questions as tab-separated text files. The module bbtextquiz provides functions for writing such files.

Example 1: a pool of 4 questions of different types

As an example, we create a pool of four questions:

q = r'For $F(x,y)=x^2 y - x^2 - 2 y^2 + 3$, ¿What type of point is $(2;1)$?'
Q1 = fields_MC(q, [('a local maximum', False), 
                   ('a local minimum', False), 
                   ('a saddle point', True)])

Q2 = fields_MA('¿Which of the following functions are even?', 
          [('cosine', True), ('sine', False), ('$x^2$', True), ('$x+1$', False)])

Q3 = fields_TF('The series with general term $1/n$ is convergent.', False )

q = r'''¿What is the infinite sum  
$1+\frac{1}{5} + \frac{1}{25}+ \frac{1}{125} + \cdots$?
<br>
Give your answer with two decimal places.'''
Q4 = fields_NUM(q, 1.25, 0.01)

write_bbpool('pool4.txt', [Q1, Q2, Q3, Q4])

The newly created file pool4.txt can be uplodad to Blackboard as indicated in the Blackboard help page "Upload Questions". Here is the preview of an exam created by uploading it.

Example 2: a pool of similar questions with different data

We consider the creation of a pool of 16 questions, all identical except for the numerical data. For this we use a Template string, with varible fields enclosed by the delimiters \temp{...}.

from string import Template  
class BBTemplate(Template):
    delimiter = r'\temp'  
    
# question template (use Template strings)
q = BBTemplate(r"How many \temp{type} pairs of distinct elements of $\{1, 2, \ldots, \temp{n}\}$ are there?")

# function that computes the answer from the data
def ans(type, n): return int(n*(n-1)/2) if type == 'unordered' else n*(n-1)

L = [fields_NUM(q.substitute(type=type, n=n), ans(type, n)) 
     for n in range(7, 15) for type in ['ordered', 'unordered']]
write_bbpool('pool_on_pairs.txt', L)

This pool can be used in a test to create a Random Block. Here is one of the questions:

Main functions in bbtextquiz

The main functions in this module are write_bbpool to write the file, and fields_MC, fields_MA, fields_NUM, fields_TFto format thge questions of type MC (Multiple Choice), MA (Multiple Answers), NUM (Numeric) and TF (True/False). The other questions are not supported by now, but it would not be difficult to complete the file bbtextquiz.py for including them.

Install

  • just download the files blackjax.py and bbtextquiz.py and import them in your python file/interactive session with from blackjax import blackjaxifyand/or from bbtextquiz import *.

  • or download and install the whole project BBLearnTools by running python setup.py install. Then import within python with from blackjax import blackjaxifyand/or from bbtextquiz import *. You can also build the documentation in html by running, from command line and from the directory docs, the command make html.

bblearntools's People

Contributors

emmanueljeanbriand avatar

Watchers

 avatar

Forkers

fmuro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.