• Stars
    star
    225
  • Rank 177,187 (Top 4 %)
  • Language
    Ruby
  • Created about 11 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CodeWorkout: a programming practice and self-study web site

CodeWorkout

CodeWorkout is an online system for people learning a programming language for the first time. It is a free, open-source solution for practicing small programming problems. Students may practice coding exercises or multiple-choice-questions on a variety of programming concepts in a web browser and receive immediate feedback.

CodeWorkout was inspired by many great systems built by others, but aims to bring together the best from earlier forerunners while adding important new features. It provides comprehensive support for teachers who want to use coding exercises in their courses, while also maintaining flexibility for self-paced learners who aren't part of an organized course.

Try it out at [https://codeworkout.cs.vt.edu]. You can play around without signing up if you like.

Contents

Setting up a Development Environment Using Docker

Note: If you are comfortable setting up a Rails application, i.e., installing Ruby (2.3.8), Rails (4.2), and MySQL (5.7) on your own machine, you can just do that instead of using Docker. You'll need to change the host keys in config/database.yml to localhost.

The following steps will help set up a development environment for CodeWorkout using Docker and Docker Compose. You can do your editing on your own machine using an editor of your choice; changes will be reflected in the Docker container.

Clone this repository

$ git clone [email protected]:web-cat/code-workout.git
$ cd code-workout

Check out the staging branch. Most new changes won't be accepted directly into the master branch.

$ git checkout staging

Install Docker and build the containers

Instructions to install Docker may be found at the Docker website.

These instructions were written with Docker version 19.03.8 in mind. We don't do anything fancy, so things should work as long as you're reasonably up to date.

We use Docker Compose to tie multiple containers together. One for the web application, and one each for the test and development databases. Docker Compose comes installed with Docker automatically.

Inside the code-workout directory, do the following:

$ docker-compose up # build and start containers for the web application and the databases

This step builds the web container using the provided Dockerfile to install Ruby, Rails, and required dependencies. It also builds the db_dev and db_test containers, each of which pull a ready-to-use MySQL image from DockerHub. Two databases are set up:

  • codeworkout, running on port 3306 on the db_dev container and port 3307 on the host
  • codeworkout_test, running on port 3306 on the db_test container and port 3308 on the host

Credentials for both databases:

  • username: codeworkout
  • pwd: codeworkout

The first time you do this, it will take a bit of time to build all the containers. Subsequent runs of this command will just start the existing containers.

Output from the containers will appear in your console. Do Ctrl-C to exit and stop the containers.

Do the following if you want to run the containers in the background and get your terminal back:

$ docker-compose up -d

You can docker-compose down to stop and remove the containers (or just docker-compose stop to stop without removing).

Set up some development data

This next step sets up the database and populates it with fake data for development. Do the following in the code-workout directory on your machine.

$ docker-compose run web rake db:populate

The above command is telling Docker to "run the command rake db:populate on the web container and exit". This rake task is defined in lib/tasks/sample_data.rake, and runs the following tasks in order:

$ rake db:drop        # drop the database
$ rake db:create      # create the database
$ rake db:schema:load # load the schema from db/schema.rb
$ rake db:seed        # load the seeded data (like timezones, seasons, etc.)
$ rake db:populate    # load sample data; this is a custom rake task

Run rake -T in your project root to see a list of available rake tasks. What's rake?

The initial database population is defined by lib/tasks/sample_data.rake. It uses the factories defined in spec/factories to generate entities. If you add new model classes and want to generate test data in the database, please add to the sample_data.rake file so that this population will happen automatically for everyone. The sample_data.rake contains only "sample/try out" data for use during development, and it won't appear on the production server. Initial database contents provided for all new installs, including the production server, is described in db/seeds.rb instead.

  • The initial database includes the following accounts:

    • [email protected] (pass: adminadmin), has admin-level access
    • [email protected] (pass: hokiehokie), has instructor access
    • example-*@railstutorial.org (pass: hokiehokie) 50 students

    It also includes the following other objects:

    • six terms (spring, summer I, summer II, fall, and winter of the current year),
    • one organization (VT)
    • one course (CS 1114)
    • two offerings of 1114 (one each semester)
      • one course offering is set up with the admin and instructor as instructors, and all other sample accounts as students
  • To reset the database to the initial state do the following:

    • $ cd code-workout
    • $ docker-compose run web rake db:populate

A note on setting up a development database.

We load the schema directly from db/schema.rb, because database migrations tend to go stale over timeβ€”running over 100 migrations, many of which are years old, is likely to run into errors. Migrations are useful for making new changes or reversing recent changes to the schema.

Run servers

To run the development server, do the following in the code-workout directory:

$ docker-compose up # this may take a minute

In your browser, navigate to https://localhost:9292 and you should see the CodeWorkout homepage. (Make sure you have https in front of the URL.)

You can edit files on your own machine; changes will be reflected in container.

Other notes

NOTE 1: Since the Rails application is running on the web container, your typical rails or rake commands are run as you see above, i.e., with docker-compose run web in front of it. For example, to generate a model you would do docker-compose run web rails g model MyModel.

NOTE 2: To end up in a bash shell in the container (i.e., to "SSH" into the server), do the following:

docker-compose run web bash

Note that this does not set up the port forwarding, so if you do this and manually run the server (./runservers.sh), you won't be able to access it from your browser.

NOTE 3: These docs and the Docker setup are recent. Please submit an issue if something is missing, incorrect, or unclear.

Making an Exercise

For instructions on how to make an exercise, see making_an_exercise.md. Note that this functionality is not directly available through the web interface for most users. Please get in touch if you want to add exercises to CodeWorkout.

More Repositories

1

pythy

Pythy – the Cloud-Based IDE for Novice Python Programmers
JavaScript
18
star
2

web-cat-subsystem-Grader

This Web-CAT subsystem provides all of Web-CAT's automated grading services. It manages all grading plug-ins as well.
Java
6
star
3

web-cat.github.io

Web pages for Web-CAT organization on github.
HTML
4
star
4

sofia-core

Sofia – Core Components
Java
3
star
5

web-cat-plugin-JavaTddPlugin

This "all-in-one" plug-in is designed to provide full processing and feedback generation for Java assignments where students write their own JUnit test cases. It includes ANT-based compilation, JUnit processing of student-written tests, support for instructor-written reference tests, PMD and Checkstyle analysis, and JaCoCo-based tracking of code coverage during student testing.
Perl
3
star
6

web-cat-subsystem-Core

This is the principal subsystem for Web-CAT, and provides all the capabilities necessary for loading and operating all other subsystems. It also provides authentication services, and common UI elements used system-wide.
Java
3
star
7

student-library

The Virginia Tech/Web-CAT Java library for use in intro courses
Java
2
star
8

sofia-maps

Sofia – Mapping/GPS Components
Java
2
star
9

sofia-graphics

Sofia – Graphics Components
Java
2
star
10

sofia-demos

Sofia – Demo Applications
Java
2
star
11

assignment-importer

Eclipse Assignment Importer
Java
1
star
12

auto-plagiarism-reports

Python
1
star
13

web-cat-app

This bundle is not a real subsystem. It is the main application startup configuration for the Web-CAT server. it contains very little code, since all behaviors are provided by subsystems instead.
Perl
1
star
14

webcat-grading-plugin-basiccppmain

A grading plug-in for Web-CAT that lets students write simple main()-oriented programs where instructors can write CxxTest-style correctness tests.
C++
1
star
15

code-reading-dojo

CodeReadingDojo game for Android--practice code reading and error-spotting skills
CSS
1
star
16

electronic-submitter

Library to support electronic submission of assignments
Java
1
star
17

web-cat-plugin-PythonPlugin

A Web-CAT grading plug-in for Python that is designed to execute the student program against a set of student-provided tests and also against a set of instructor-provided tests (reference tests).
Perl
1
star
18

eclipse-plugins-importer-exporter

A single Eclipse plug-in and feature that combines the electronic submitter with a UI to easily import projects and dependencies for assignments.
Java
1
star
19

eclipse-plugins-cxxtest

Eclipse plug-ins to add support for CxxTest unit-testing framework under CDT
C++
1
star
20

web-cat-plugin-tester

Web-CAT Grading Plug-In Testing Tool
Java
1
star
21

maria-chatscript

Conversational scripting for Maria, the Web-CAT virtual teaching assistant
JavaScript
1
star
22

dereferee-with-cxxtest

Dereferee, the C++ diagnostic pointer library, including CxxTest unit-testing framework
C++
1
star
23

netbeans-modules-electronic-submitter

NetBeans integration plug-ins for the Electronic Submitter
Java
1
star
24

eclipse-plugins-electronic-submitter

Eclipse integration plug-ins for the Electronic Submitter
Java
1
star