GithubHelp home page GithubHelp logo

psyanite / scorm-parser Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 6.0 4.41 MB

🍰 Scala library to parse and validate SCORM 1.2 packages

License: Apache License 2.0

Scala 100.00%
scorm parse parser library adl tincan scala-library scala

scorm-parser's Introduction

scorm-parser

A Scala library to parse and validate SCORM 1.2 packages.

Configuration

Scala 2.12.3 is required.

Bintray

groupId: io.github.psyanite
artifactId: scorm-parser_2.12
version: 0.2.6

Usage

Using the parser

import com.psyanite.scorm.PackageParser
import com.psyanite.scorm.validator.ManifestValidator


val zip = new File("my-scorm-package.zip")
try {
  val parser = PackageParser(zip)
  val manifest = parser.parse()
  val errors = ManifestValidator().validate(manifest)
} catch {
  case e: Exception => println(e.message)
}

val directory = new File("/my-unzipped-scorm-package")
try {
  val parser = PackageParser(directory)
  val manifest = parser.parse()
  val errors = ManifestValidator().validate(manifest)
} catch {
  case e: Exception => println(e.message)
}

manifest.item.head.masteryScore match {
  case Some(score) => println("Mastery score is %d".format(score))
  case None        => println("Mastery score not found")
}

manifest.resources.head.href match {
  case Some(href) => println("Entry point on first resource is %s".format(href))
  case None       => println("Entry point on first resource not found")
}

manifest.resources(1).head.href match {
  case Some(href) => println("Entry point on second resource is %s".format(href))
  case None       => println("Entry point on second resource not found")
}

Manifest class

class Manifest (
  var metadata:  Metadata,
  var items:     Seq[Item],
  var resources: Seq[Resource]
)

Metadata class

case class Metadata (
  var schema:        Option[String],
  var schemaVersion: Option[String],
  var scheme:        Option[String]
)

Item class

case class Item (
  var identifier:   String,
  var title:        String,
  var masteryScore: Option[Int]
)

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.