Your own parser possible with PEG.js

There are many parser generators out there, but the vast majority of them only run in shells on the server side and are usually written in C. What if you need a solution that not only understands JavaScript syntax but can also generate ready to use JavaScript code in the form of a function?

Example use case

But why did I need a parser? A few weeks ago I was looking for the possibility of parsing LaTex math expressions. My black box model required a valid LaTex string as an input, and a JavaScript function as an output, e.g.

LaTex:

x+4

Returns:

function (x) {
    return x + 4;
}

Looking for a solution

After spending some time researching various parser generators out there, I concluded that PEG.js was one of the most appropriate solutions to this problem. There are two other able to output results in JavaScript, but Waxeye works only from command line, and OMetaJS while very powerful, it doesn’t have proper documentation.

PEG.js describes itself as “a simple parser generator for JavaScript that produces fast parsers with excellent error reporting.” As I found out, it is indeed a simple parser generator with the biggest advantage being a very low entry barrier (If you navigate to http://pegjs.majda.cz/online, you’ll see an example grammar that recognises basic arithmetic expressions like addition and multiplication).

The project is in its early stages, and still under development, so, it may take some time to see v1.0 next to the name. Though, I must admit, even the early release is cool.

Simple calculator extended

Based on the earlier mentioned example provided on their website I was playing around and quickly found a way to offer much more than it was on the example page (check this Gist). It simply takes a LaTex expression and evaluates it returning a value, e.g.

LaTex:

\frac{1}{2}*\abs{-10}

Returns:

5

But it wasn’t exactly something I wanted, as you see in the Example Use Case section. To plot a function on a graph I needed a JavaScript function which I could pass a variable to (most commonly x).

Real parser

The parser I was writing had to be able to decompose passed LaTex, i.e. for each portion of the LaTex, generate a function that accepts any defined parameter, evaluate the LaTex, and return the result.. Here’s a diagram of a concept I came up with:

LaTex:

\frac{x}{2}*\abs{-10}

A given LaTex expression could be divided into blocks as follows:

Screen Shot 2014-10-28 at 4.03.17 pm

Returns:

var func = function (x) {
    return (function (x) { // multiply
        return (function (x) { // fraction
            return (function (x) { // x
                return x;
            })(x) / (function (x) { // 2
                return 2;
            })(x);
        })(x) * (function (x) { // absolute
            return Math.abs((function (x) { // -10
                return -10;
            })(x));
        })(x);
    })(x);
};

func(5); // outputs 25
func(4); // outputs 20
func(1); // outputs 5
func(0); // outputs 0

Now returned function can be plotted on a graph, using e.g. JSXGraph library:

plotted

OK – it all looks pretty, but now the hard part. It’s like I invited you to watch a game, but instead of watching it, you’re constantly staring at a website with live scores being refreshed every few minutes. I promised a parser that can convert LaTex expression to executable JavaScript function but all you see are hardcoded snippets of code, and nothing automated. Well – you just have to be patient.

Let’s be even more ambitious

One of our unwritten rules of thumb is to make our solutions as sweet as possible, so, I made few tweaks to this task to sweeten the pot a bit.

There can be many occasions when you want to plot a set of variations of the same functions, e.g. slightly changing the position of a graph. To achieve this, your function needs to accept more parameters than only x. Let me give you an example:

LaTex:

a*x+b

Returns:

var func = function (obj) { … };
func({x:5,a:1,b:2}); // outputs 7
func({x:6,a:3,b:4}); // outputs 22

You can see that our parameterized LaTeX defines more than one variable – now we have a, b and x. It requires our parser to be able to recognise all variables, and let us pass their values on execution to a generated function. I don’t want to bore you with going through the solution step by step, as this article is not a tutorial (nevertheless, the parser is available here).

Summary

One of the design decisions in PEG.js is avoidance of recursion. It’s up to you to decide whether this decision will prevent you from using this tool or not. There are problems which are much easier to solve using recursion, and can really mess up your parser grammar if you decide to take a path around it. In case of PEG.js, a path around recursion is mandatory.

I think PEG.js is a great tool, and worthy of attention. I hope it grows and that someday we will see v1.0.

How it all Started: Gavin Cooney, CEO Learnosity

Screen Shot 2014-10-28 at 17.21.16
The below interview with Gavin originally featured in the Q3 2014 issue of the In Business magazine.

IB: How did you fund your business initially?

GC: While the dream was always to be a product company, we were fortunate to have a very close relationship with the Board of Studies in New South Wales. They’re the government body responsible for the State exams in New South Wales. Consulting revenue from bespoke e-learning projects helped to support us in the earlier years while we got up and running.

IB: What’s the best advice you were given?

GC:You really need to listen to your customers. As an entrepreneur it can become too easy to fall in to the trap of going in all guns blazing, full of innovative ideas telling customers that you have exactly what they need when really it was by listening to exactly what they wanted (and delivering) that we managed to make the break.

IB: What was the most important lesson you learned starting out?

GC:After doing both a business degree and a Masters in business I realised very quickly that I knew absolutely nothing about running my own business. It was definitely a baptism of fire. Turned out there were lots of things to learn about funding and the traditional ways of growing a business. We eventually discovered that going the VC route wasn’t necessary and we ended up going it alone.

IB: Your biggest make or break moment?

GC:The development of an embeddable “record button” for one of our clients in 2011. All they wanted us to do was to develop one record button which could be placed within their existing e-books. Initially we had pitched a full solution, convinced that was what they needed. But they didn’t want that. They wanted a single button. This was a pivotal moment for us, we found our niche and this paved the way for our strategic shift into SaaS where we give our clients the ability to build education’s next big thing using our tools and services.

IB: Would you change anything in hindsight?

GC:Its very easy to look back in hindsight and see how things could have been easier. We made a lot of mistakes, slept on lots of sofas went to lots of conferences we didn’t really need to be at. Really, lots of trial and error. Course it would be great if we could take our current business plan and implement it back in 2008 but it wasn’t possible – in fact the market might not have even been ready back then. But if I had to change one thing, it would be the amount of time we spent on doing the rounds with VCs. Concentrate on the product, make it awesome and they’ll come knocking – even if you no longer need them!

Amazon Web Services Recognizes Learnosity with Amazon Partner Network Membership

aws

New York, 27th October: Learnosity, a Software as a Service (SaaS) educational technology company, today announced its membership with Amazon Web Services’ (AWS) Partner Network (APN) as a Standard Technology Partner. This award is a testament to Learnosity’s commitment to provide the most flexible, scalable and reliable cloud-based, educational solutions.

“We are delighted to join the Amazon Partner Network” says Learnosity CTO Mark Lynch. “The K-12 educational sector has many technology challenges including scale, cost sensitivity and security. AWS enables us to scale our systems dynamically by scaling up during demand spikes and down during demand lulls, in a way that is cost efficient and effective.  By leveraging multiple geographic locations we can get the best performance for our users, and the advanced security features available on AWS such as encrypted volumes and rotating authentication keys help to keep student data safe and secure. ”

Learnosity offers a set of tools and services that allow clients – educational publishers and testing organizations – to quickly and easily add Common Core-aligned, interactive assessments to their digital products. Complementary authoring and reporting tools are also available.

About Learnosity

Learnosity is a rapidly expanding educational technology company. The company offers a set of tools and services that allow clients to incorporate powerful interactive assessment into their digital products quickly and easily. Run by a talented group of people who are passionate about transforming learning and assessment, Learnosity is committed to designing market-leading software to allow developers to create exceptional assessment products, make teachers’ lives easier, and above all, instill a love of learning in students. The Company is seeing an annual doubling of revenues, and works with some of the leading names in the Education industry.  The Learnosity Toolkit was recently named the Best K-12 Enterprise Solution by the SIIA, and National Champion for Innovation in the European Business Awards.  Learnosity has offices in NYC, Dublin and Sydney. For more information contact Learnosity on +353 (0) 1 4498789, info@learnosity.com or visit www.learnosity.com.

About AWS APN

APN is a global program that offer solutions providers technical information as well as sales and marketing support to accelerate their business on AWS. Technology Partners provide software solutions that are either hosted on, or integrated with, the AWS platform. Technology Partners include Independent Software Vendors (ISVs), SaaS, PaaS, developer tools, management and security vendors.

Learnosity wins SIIA CODiE

What Winning a CODiE Award means to Learnosity

While we always knew that SIIA and the CODiE Awards were influential, we did not anticipate the incredible impact that winning a CODiE Award has had for Learnosity.

Learnosity was thrilled to be nominated for a CODiE.  The evening event itself was a fantastic opportunity for us to meet C-level execs from some of the biggest companies in the education space, as well as from some smaller companies which are creating some really exciting EdTech products.

In our award category (Best K-12 Enterprise Solution) we were up against some fantastic products from both big and small companies.  Having our product named “the best” by independent judges was a great honor. For Learnosity, a relatively small company, to win is a true validation that this award is not based on past reputations, but rather on the strength of the product and the value that it brings to the industry.

What has really been impressive is the impact the award has made.  Since being named “the best”, the award has helped bring in new business, reopened previously shut doors and, of course, provided affirmation to our existing clients. Winning the CODiE has given us exposure on a national level and has delivered tangible sales and marketing benefits; we have definitely seen an increase in inbound leads since winning. The CODiE Awards have great brand recognition and immediately let people know that we are recognized as a key player in our field and that we are successfully providing innovative solutions for the difficult Common Core assessment challenges faced by our clients.

And we certainly haven’t been shy about telling the world about our CODiE Award; not only does the award itself take pride of place in our Dublin office, the CODiE Winner logo is front and center on our website and features heavily in our new marketing materials.  The visibility of our CODiE Award likely played a key role in Learnosity being named a “National Champion for Ireland”, by the European Business Awards.

Internally too, the CODiE Award has been a great recognition of the hard work and achievements of our insanely talented development team in Australia. The guys down under are that step removed from the market and don’t always hear the positive feedback from our clients. The award has really helped to motivate them and proves that what they are working on is truly helping shape education around the world. Making a difference is why most of us are in this business.  As “the best”, it’s clear that our work and vision are making a difference.

We continue to be grateful to SIIA and everyone who voted for The Learnosity Toolkit. We are constantly working to improve our product.  For us, being “the best” isn’t about a one-time award – it’s a constant commitment to deliver value and impact for our customers. We are looking forward to not only defending our title next year, but entering a couple more categories!

About Learnosity

Headquartered in Dublin and Sydney, Learnosity are a group of people who are passionate about transforming learning and assessment. We are committed to designing market-leading software which lets developers create exceptional assessment products; makes teachers’ lives easier and above all instills a love of learning in students.

The Learnosity Toolkit is comprised of a suite of APIs which enable clients to easily incorporate interactive assessment, as well as authoring and reporting capabilities into their applications, eBooks and websites. By providing the the core building blocks of any digital assessment product yet leaving the end design decisions in the hands of our clients we help our partners to build better products with less time and money.

This blog originally featured as a guest post on: http://www.siia.net/blog/index.php/2014/10/what-winning-a-codie-award-means-to-learnosity/

Shading Question Type

We have released the draft Simple Shading Question Type.

The Shading Question provides a visual representation of functions and calculations including fractions and ratios. Authors are able to generate a set of cells which can be shaded by a student.

The canvas and shading options can be configured to suit many question variations. Configurable options include:

  • Row and column count
  • Row and column size
  • Border
  • Insert background image
  • Author hidden or shaded areas
  • Insert cell image

Triumph Learning Launches Waggle SBAC

Waggle Logo

New online learning platform addresses Common Core assessment needs

New York, October 16, 2014: Triumph Learning, producer of critically acclaimed K-12 instructional materials and interactive digital tools, announces Waggle for the Smarter Balance Assessment Consortium (SBAC). The SBAC assessments in Waggle include 26 different item types that students will see on the SBAC assessments including Part A and Part B problems and performance tasks.

The Smarter Balance Assessment Consortium is a state-led consortium working to develop next-generation assessments that measure student progress toward college- and career-readiness. Smarter Balance is one of two multistate consortia awarded funding from the U.S. Department of Education in 2010 to develop an assessment system aligned to the Common Core State Standards (CCSS) by the 2014-15 school year.

“With Waggle, SBAC states can gain a greater understanding about Common Core State Standards and assessments,” said Aoife Dempsey, chief technology officer of Triumph Learning. “Our personalized learning platform provides students with the practice and instruction to build the skills and critical thinking that they need for college- and career-readiness.”

Triumph Learning has also partnered with Learnosity, which offers tools and services that incorporate powerful interactive assessment into digital products quickly and easily. Learnosity is committed to designing market-leading software to allow developers to create exceptional assessment products, make teachers’ lives easier, and above all, instill a love of learning in students.

“Our partnership with Triumph Learning is a natural fit,” said Gavin Cooney, co-founder and CEO of Learnosity. “By using the Learnosity tools and services Triumph Learning is able to provide Common Core Coach content in an even wider variety of online interactive item types than are in the SBAC assessments.”

Triumph Learning recently received three Education Software Review (EDDIE) Awards for its online learning platform, Waggle. The company took home the top prize for its new learning solution in the following categories: Online English Language Arts Courseware, Online Math Courseware and Online Classroom Management System.

About Triumph Learning 
Triumph Learning, LLC, is a leading educational content company and publisher of print and digital K-12 resources, standards-aligned instructional materials and effective literacy programs, serving more than 6 million students in 36,000 schools in 2013. Triumph Learning offers unique student solutions, robust teacher support, and professional development opportunities. Triumph Learning is committed to serving all students with a mix of interactive digital tools and innovative student texts with products such as Coach, Buckle Down, and Waggle. For more information, visit http://www.triumphlearning.com.

About Learnosity 
Learnosity is a rapidly expanding educational technology company. The company offers a set of tools and services that allow clients to incorporate powerful interactive assessment into their digital products quickly and easily. Run by a talented group of people who are passionate about transforming learning and assessment, Learnosity is committed to designing market-leading software to allow developers to create exceptional assessment products, make teachers’ lives easier, and above all, instil a love of learning in students. The Company is seeing an annual doubling of revenues, and works with some of the leading names in the Education industry. The Learnosity Toolkit was recently named the Best K-12 Enterprise Solution by the SIIA, and National Champion for Innovation in the European Business Awards. Learnosity has offices in NYC, Dublin and Sydney. For more information, visit http://www.learnosity.com.

The original press release is accessible at: http://www.prweb.com/releases/2014/10/prweb12252922.htm

Learnosity And Triumph Learning Announce Strategic Partnership

Triumph Learning Logo

Joining forces to bring innovative learning and assessment solutions to millions of students across the U.S.

Learnosity and Triumph Learning today announced their strategic partnership to enhance learning environments for tens of millions of students across the country. Triumph Learning joins a rapidly growing list of educational publishers and assessment companies joining forces with Learnosity to improve learning and assessment worldwide.

Triumph Learning is using the Learnosity APIs to seamlessly integrate Common Core-aligned, technology-enhanced item types (TEIs), which allow students to demonstrate mastery of key concepts and skills, into their digital products.

“We’re very excited to announce the Learnosity-Triumph Learning partnership,” said Learnosity CEO and co-founder Gavin Cooney. “Our SaaS approach has allowed Triumph Learning to speed up the launch of Waggle for the Smarter Balanced Assessments. Waggle, the first of many Triumph Learning-Learnosity collaborations, has recently been introduced to classrooms and has already been well-received by students and teachers alike. We’re very proud to be involved with this great product and look forward to working on many more together.”

Waggle is a personalized, smart practice solution for elementary and middle schools, built by Triumph Learning in conjunction with Learnosity. Waggle’s Smart Practice helps students build skills and prepare for assessments in a supportive, engaging environment. Designed for students in grades 3-8, Waggle offers in-depth practice with customized feedback and scaffolded instruction in both English Language Arts (ELA) and Math.

“With the help of Learnosity, we are able to accelerate learning for students and help them build confidence in their skills for SBAC,” said Aoife Dempsey, Chief Technology Officer of Triumph Learning, “This partnership will provide teachers with a wider range of items types that they will see on the Smarter Balanced assessments and provide teachers with insightful and intuitive reporting to inform instruction and meet each student where they are.”

About Learnosity

Learnosity is a rapidly expanding educational technology company. The company offers a set of tools and services that allow clients to incorporate powerful interactive assessment into their digital products quickly and easily. Run by a talented group of people who are passionate about transforming learning and assessment, Learnosity is committed to designing market-leading software to allow developers to create exceptional assessment products, make teachers’ lives easier, and above all, instil a love of learning in students. The Company is seeing an annual doubling of revenues, and works with some of the leading names in the Education industry. The Learnosity Toolkit was recently named the Best K-12 Enterprise Solution by the SIIA, and National Champion for Innovation in the European Business Awards. Learnosity has offices in NYC, Dublin and Sydney. For more information, visit http://www.learnosity.com.

About Triumph Learning

Triumph Learning, LLC, is a leading educational content company and publisher of print and digital K-12 resources, standards-aligned instructional materials and effective literacy programs, serving more than 6 million students in 36,000 schools in 2013. Triumph Learning offers unique student solutions, robust teacher support, and professional development opportunities. Triumph Learning is committed to serving all students with a mix of interactive digital tools and innovative student texts with products such as Coach, Buckle Down, and Waggle. For more information, visit http://www.triumphlearning.com.

Accessibility – busting a few misconceptions

For the past couple of months, we’ve been doing Show & Tell every few weeks to encourage knowledge sharing within the team. For the most recent one, I did a talk on accessibility to explain what it is, why it’s important and the various things we can do to improve the accessibility of our product. Accessibility should be the foundation of what we do, and as creators – whether we’re designers, developers, product managers – we all have the responsibility to make sure what we create is available to the widest audience possible.

Why should I care?

There are some common misconceptions around accessibility which often makes it a low priority to a business. I believe that’s because people don’t often understand the impact an inaccessible website can have.

“I don’t have users with disabilities”

The most common misconception I hear is probably “I don’t have users with disability”. Disability comes in many forms: visual, hearing, motor and cognitive. They also come in various level of severity. For example, when we talk about visual impairment, we’re not just talking about people with blindness. There are also people with low vision and colour blindness. Both are just as common forms of visual impairment. People with disabilities are around us a lot more than we realise. To give you a rough idea:

  • In Australia and US, 1 in 5 people have some form of disability [1] [2]
  • In US, 8.1 million people have visual impairment, 7.6 million people have hearing difficulty and almost 20 million people have trouble lifting and grasping things [3]
  • In Australia, 8% of people (mostly males) have some form of colour-blindness [1]

On top of this, there are also people with short-term impairment. I’m sure a lot of us have experienced repetitive strain injury (RSI) or broken an arm in an accident. We might end up needing to rely on the keyboard for a while and I’m quite certain it was a pretty frustrating experience. Our ageing population is also increasing, which means more and more people will have trouble with their vision, hearing and mobility.

“Accessibility is optional”

Accessibility is not optional. In the US, there’s Section 508 of the Rehabilitation Act which requires any electronic and information technology used and maintained by the federal government agencies to be accessible to people with disabilities. This means if you provide any services to the government, they will need to be Section 508 compliant. It is also possible for people to make a complaint to the Human Rights and Equal Opportunity Commission (HREOC) if they find your website to be inaccessible. The Maguire V SOCOG 2000 case is a good example of that.

“Accessibility has little benefit for my business”

An accessible website doesn’t just benefit people with disabilities. In fact, accessibility and usability are very tightly related. Having things like consistent design, clear and readable content all contributes to the accessibility as well as usability of your website. So ultimately, better accessibility means better usability!

Improving accessibility of our product

The past couple of months, we have been making an effort in improving the accessibility of our product.

Alternative text

It is important to have meaningful text for important images especially for screen reader users. Our image uploader now has an “Alternative Text” field, allowing author to add alternative text to the images they upload. When no value is entered, rather than omitting the alt attribute, we’ll output it with an empty value, i.e. alt="" to ensure screen readers don’t read out the file path of the image source.

Image uploader showing image alternative text field

Accessibility Options Panel

To help students with visual impairment, they can access the “Accessibility Options Panel” to change the visual appearance of the assessment. They can choose to change the font size of the questions, as well as a different colour scheme if they have a particular colour blindness.

Use different visuals to convey meaning

As part of WCAG’s Success Criterion 1.4.1 Use of Color, we should not rely on using colour alone to convey meaning as some people may not be able to see the intended colour. I used a very handy Chrome extension called Spectrum to run a little test on our Questions. The extension shows you how people with different Colour Vision Deficiencies view things. Without any use of icons, this is what the validation of our MCQ looks like to people who have trouble seeing red and green. You can’t really tell which is the correct and incorrect answer. MCQ validation with no icons

The best thing to do in this situation is add an icon (which we already do): MCQ with validation icons

Our text highlight and token highlight questions were relying on the yellow background colour to indicate highlighted text. To pass the accessibility criterion, we added a dark border around the highlighted text to make it stand out more.

Keyboard accessibility

Having a keyboard accessible assessment will benefit every student, especially those who can’t use a mouse or touchpad. In an Assessment, students can use left and right arrow keys to go through the different Items. In the past few weeks, we’ve been focusing on making some of our widgets keyboard accessible e.g. character map and the formula keyboard. We followed the DHTML Style Guide Working Group recommendation when determining keys for interaction:

  • Use tab to move focus between widgets
  • Once a user has tabbed into a widget, use arrow keys to navigate between elements for interaction

Our work is not done yet

When designing and developing, it is important that we think about users with different needs. Will a visually impaired person have trouble seeing this colour? How can someone with motor difficulty be able to interact with this question? Creating a rich and interactive application that is fully accessible is no easy task, and there is still so much to be done. But we are definitely trying our best and continuing our work in ensuring students are not disadvantaged when using our Assessments.


References:

  1. http://www.and.org.au/pages/disability-statistics.html
  2. https://www.census.gov/newsroom/releases/archives/miscellaneous/cb12-134.html
  3. http://www.interactiveaccessibility.com/accessibility-statistics
  4. https://www.census.gov/newsroom/releases/archives/miscellaneous/cb12-134.html

Numberline Plot – on the line

We have extended the functionality of the Numberline Plot to include plotting responses on the line.

The addition of a toggle button to turn stacked responses on or off makes using this option easy.

Points, segments, rays and hollow points are supported and collision detection has been enabled to ensure that responses do not overlap.

Learnosity Hiring: Business Development Engineer – New York City

Learnosity is on a mission to deliver on the promise of technology in education by providing the best assessments to students worldwide. We do this by enabling our customers to create engaging, authentic assessments using our powerful authoring and broad range of question types.

With offices in Sydney, Dublin and New York, a talented and growing team, an impressive client list and a recent CODiE award, it’s an incredibly exciting time to join the team.

We are looking for a sharp, technical individual to join the BD team in New York City and help us continue to grow and to continue delivering for our clients.

Technically our products are based on several technologies. We have a large number of integration points with JavaScript APIs with PHP back ends. We provide our clients with scalability through the use of Amazon’s Cloud Services.

Who are we looking for?

Up until now the tech team has been mainly based in Sydney with the business team in Dublin. With an international clientele it is important that we start to build a  presence in New York too.

We are looking for someone who can bridge the technical – business divide. Someone who is equally comfortable talking to clients and prospective clients as well as digging into code to find the root of a problem. You will need to acquire a thorough technical understanding of our product suite in order to successfully field questions from third party developer teams.
What is the role?

The role is comprised of two main parts:

Product Engineer
You will represent the Learnosity technical team on business calls and will answer the more difficult technical questions, provide product advice and work with both the third party dev. team and the Learnosity developer team to architect mutually agreeable solutions. Typically you and one of the senior members of the business development team will represent Learnosity at business meetings.
You will also be responsible for preparing functional specs and responding to tenders/RFPs.

Technical Client Liaison
You will play a key role in developing long -term relationships with clients through supporting client developer teams with their implementation and by checking out bugs and recommending/implementing fixes as appropriate. You will take ownership of our documentation site. This is the primary port of call for client support and needs to be updated and amended with every release.

You will need to be:

comfortable digging into code, passionate about technology & keen to continue learning;
confident providing technical advice and recommendations to clients;
an excellent communicator; comfortable communicating with tech and non-tech teams alike;
willing to work appropriate hours, to liaise with the Sydney team and our international clientele;
willing to travel (we anticipate the first month or so of the role will be in Sydney).

It would be great if you have:

  • 3+ years experience as a developer;
  • MBA or similar;
  • technical writing experience;
  • a strong understanding of Web technologies.
  • Being part of the Learnosity team is a commitment to push yourself and those around you to do better, constantly adapt and learn new technologies, and be able to apply yourself to any challenge, whether you’re just starting out or a veteran of the industry.

If this sounds like the job for you, email a covering letter explaining why you’ll be great and your resume to careers@learnosity.com with the subject line “Name_ Learnosity New York”