Skip to content

readingbat/readingbat-template

Repository files navigation

Kotlin

ReadingBat Template

ReadingBat.com is an attempt to make learning how to program a little easier.

We are big fans of CodingBat.com (so much so, that we shamelessly copied its look and feel). However, we observed that students often start using it to write code, prior to being equipped with the skill of reading code. It is difficult to write code without first learning how to read and follow code! So we set out to create ReadingBat.com, which attempts to make students comfortable reading code challenges and learning code idioms. Once a student is comfortable with reading code, they can head straight for CodingBat.com and move on to authoring their own code!

This template is for teachers who want to author their own ReadingBat content. Once you create content for your students, send us a note and we will link the ReadingBat.com site to it.

Content Specification

Specify ReadingBat content with the ReadingBat-specific Kotlin DSL. Using the DSL does not require in-depth knowledge of Kotlin.

ReadingBat supports challenges written in 3 languages: Python, Java and Kotlin.

Specify the content in the src/main/kotlin/Content.kt file.

The structure of the DSL is:

val content = 
  readingBatContent { 
    python {                                    // Creates a LanguageGroup object
      group("Group 1") {                        // Creates a ChallengeGroup named "Group 1"
        packageName = "group1"                  // The path of the challenges in this group
        description = "Description of **Python** Group 1" // Descriptions support markdown

        challenge("find_it") {                  // Creates a Challenge for group1/find_it.py
          returnType = BooleanType              // Challenge return type
        }

        challenge("boolean2") {                 // Creates a Challenge for group1/boolean2.py
          returnType = BooleanType              // Challenge return type
        }
        
        // Include all challenges matching the "slice*.py" filename pattern
        includeFilesWithType = "slice*.py" returns StringType  
      }
    }

    java {
      group("Group 1") {
        packageName = "group1"
        description = "Description of **Java** Group 1"

        challenge("JoinEnds") {                 // Java Return types are inferred from the code
          codingBatEquiv = "p141494"            // Will add a link to this codingbat.com challenge
        }

        challenge("ReplaceCheck")               // Creates a Challenge for group1/ReplaceCheck.java

        // Include all challenges matching the "Has*.java" filename pattern
        includeFiles = "Has*.java"
      }
    }

    kotlin {
      group("Group 1") {
        packageName = "kgroup1"
        description = "Description of **Kotlin** Group 1"

        challenge("StringLambda1") {
          returnType = StringType
        }

        // Include all challenges matching the "lambda*.kt" filename pattern
        includeFilesWithType = "lambda*.kt" returns StringType
      }
    }
  }

DSL Objects

Challenge Code

Examples

This repo describes the ReadingBat.com website. Its Content.kt combines content from 2 other repos.

Content.kt Files for ReadingBat.com

Code Content for ReadingBat.com