Giter Club home page Giter Club logo

code-workout's Introduction

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.

code-workout's People

Contributors

1-alex98 avatar awhicks avatar ayaankazerouni avatar dependabot[bot] avatar hosamshahin avatar kbuffardi avatar lin251 avatar mkomohammed avatar pmk1433 avatar pxmore91 avatar s-edwards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-workout's Issues

Fix MC questions to work properly again

Now that the model refactoring has been performed, MC questions need to be fixed to work again, including correct handling of attempt/answer recording. Use the current coding prompt/answer structure as a model.

Move to FriendlyId for slug-based url support

Replace the roll-your-own "url_part" support in various model classes with FriendlyId support instead. Also, move from having all models use top-level urls, to providing scope-based urls that match logical breadcrumbs instead.

Add breadcrumbs

Priyanka did some prototype screens that included breadcrumbs, a feature we had discussed as useful. These should be included for Torch. We need to figure out the appropriate strategy and build it into our pages/controllers now, instead of trying to add it later.

Redo the breadcrumbs

Redo the breadcrumbs done in #16 so that they will work in a consistent manner with the new organization of entities.

Refactor tag support to use acts_as_taggable_on

Get rid of the custom tag model and use this gem instead. Refactor tag support to use different tag fields for different types, and use the gem's features to build an appropriate filterable tag cloud.

Fix handling of syntax/compilation errors in coding questions

They currently don't display any useful info. These need to be fixed so that appropriate feedback is generated. This probably involves updating the coding prompt answer class to include this error feedback when no test case results are available.

Use server-side push to deliver exercise feedback results

Currently, when a student practices an exercise, the exercises_controller sleeps a fixed delay (3s) before returning (line 610). This is because immediately after the answer submission, the client code attempts to retrieve the results via an ajax call. The sleep is broken, since there is no guarantee the results will be ready after that time is up, and it effectively is a broken strategy to turn the async answer processing into a synchronous call (!). The sleep should be removed, and instead feedback results should be pushed from the server via HTML5 server-side push, instead of pulled from the client after submission.

Fix exercise versioning during editing

The exercise edit page does not correctly work with the current exercise versioning scheme. After editing, the newly created version does not receive copies of any relationships or nested objects (e.g., tags, coding question). Further, the editing page takes the browser right back to the same (starting) version instead of the newly produced version, making it appear that changes are unsaved. In addition to directing the browser to the correct page, a flash notice should probably be included to make it clear that changes were saved and a new version was created.

Fix the display of the CodeMirror area

During the practice of the exercise, the CodeMirror area is display in a funky manner instead of the horizontal scrolling being done in a graceful manner. Probably need to fix how we are doing it with CodeMirror.

cw-practice

Redo navigation of exercises in workouts

Need to redo the way that a student navigates through the exercises in the workout. Currently, the list of 'remaining' exercises are maintained in params/session but this does not safeguard against situations where students might be jumping around workouts exercises. Need to develop a consistent mechanism that will suggest the next exercise that a student is led to by the 'Next exercise' link.

Probably be ought to be done as a model class method rather than a controller method.

Refactor the record_workout_score method

The record_workout_score method is present in two different places (mainly in CodeWorker) and needs to be refactored so that it made as a class method of WorkoutScore instead. Need to redo it so that it takes into consider the workout_id while recording attempts, so this entails redoing the relationships between Attempts and Workouts. Any other comments?

Add self-enrollment links to course offering lists

On the pages that show lists of course offerings, we need to add self-enrollment links for those offerings that the current user is not enrolled in, if those offerings do allow self-enrollment. These pages include:

/courses
/courses/<organization>
/courses/<organization>/<term>

In addition, we should modify the course show page (which is at /courses/<organization>/<term>/<course>) so that, if the current user is not enrolled, it shows the list of offerings including self-enrollment links/info, for those where self-enrollment is available.

Also, we need to update the course offerings model to include an optional cut-off date for self-enrollment. New course offerings that allow self-enrollment should use use the end date of their associated term as the default cutoff date, but the instructor should be able to change this date. After the specified date, self-enrollment should be closed (no longer available).

Figure out VT login instructions

How should VT users login? Perhaps we should just use VT G-mail credentials for logging in students? We need to figure out the procedure and instructions so students can begin using CodeWorkout in summer.

Fix kaminari paging of course rosters on roster tab of course show page

There is already some setup for this on the page, but the problem is when multiple course sections are shown. If there are multiple sections, they currently all use the same dom ID names for the tables, and for the paging controls. That won't work. Instead, those ID names need to be specific to each course offering. Also, I ended up removing the roster partial, since it didn't seem to be doing anything useful--instead, we can probably go with just the row partial like Pythy. However, this means the show.js.coffee view is out of sync and paging doesn't work at the moment.

Implement enrollment deletion on roster tab of course show page

There is already an "X", but it needs to be turned into an action that deletes the corresponding course enrollment and refreshes the corresponding table on the page. Note that there may be multiple tables on the page if multiple sections are available, and the correct table must be refreshed.

Remove the "instructor" global role

This role shouldn't exist. All instructor-level permissions should be role-based, relative to the user's course role in the relevant course offering. There should not be any "global" permissions for instructors.

Effectively, the only "global" role should be for admin accounts, and all other accounts should be globally "equal", and use only role-based permissions.

Validate CanCan permissions

Need to validate the CanCan permissions on CodeWorkout in a systematic role-based way before Husky after the core system is completed for Torch. Need to both test it ourselves and use some 'student/instructor' role-players to test it around.

Fix exercises_controller's evaluate method to work with new data model

Update the evaluate action to use the new model for attempts. The evaluate action should create the attempt, and create the corresponding prompt answer(s) from the field values, storing the answers. Then the id for the newly created attempt is what get posted for the worker to process.

In addition, the code worker needs to be updated to use the new attempt model.

Exercise thumbnail point displays

Exercise thumbnails need to include meaningful point displays even when the exercise is not associated with the current workout, and need to include meaningful points earned info if the current user has completed (or attempted) it. At present, the logic for displaying points earned + total points in thumbnails is incomplete and needs to be redone. It does not appropriately tie into XP when exercises are outside of assigned workouts.

Fix exercises_controller#random_exercise to use all ids

The exercises_controller#random_exercise method limits results to id numbers >= 200. This is an artifact of the test database used during development, and should be fixed to use the full range of available exercises. Also, double-check that it only pulls from public exercises.

Double-check scoring behavior

Ensure that the scores being calculated for individual exercises and for workouts are correct. This needs to be tested with exercises where different test cases have different weights, and for workouts where different exercises are worth different numbers of points, and for workouts where some exercises are partially correct but not fully correct.

What is the limit on workout names?

The Workout model has a validation rule that requires workout names to be between 1-50 characters in length. The corresponding validation error message describes the same thing, and limits the characters that can appear in workout names. However, the database schema does not have this length limit.

Is this length limit necessary for some reason, or can it be removed? Similarly, is the character set limitation necessary for some reason, or can it be removed?

Fix displaying of scores in thumbnails

Both for exercises and for workouts. We also need to ensure the overall workout "show" pages correctly show both individual exercise scores and also the total score for the whole workout correctly.

Should sm and lg thumbnails be merged?

There are currently two styles of thumbnails for both exercises and workouts. The original intent was for one to be a smaller sidebar-only version, while the other would perhaps contain more content/detail for use in the main content area.

However, at present, these two are virtually identical except for the css tag of the main element. It would be possible to merge these pairs into one view per model instead of having two. An additional view parameter could be used for indicating lg vs. sm, for customizing css tags, adjusting teaser text length, etc., if there are no significant logic differences between the two views. Should we do this?

Refactor exercise/base_exercise classes and controller

Currently, the exercise controller is the center of activity for exercises, but base_exercise is actually the central entity, with "exercise" objects actually being versions of the exercise along a history trail of edits. It would probably be better to make BaseExercise the center for editing exercises, although we still want "exercise" to be the word used in routes. This would require some refactoring, however.

Double-check add/remove links for nested objects in formtastic forms

The add/remove links in subforms for things like the exercise editing page appeared to stop working at some point. I think this is because the link construction is incorrect and doesn't follow formtastic conventions. Double-check whether these work correctly, since we need them so that full editing can be achieved.

Add JSON import of exerises

See the export comments. We eventually want to be able to do effective round-trip export/import in a consistent way, both to support external authoring, to support other tools, and to provide for convenient external storage.

Huge number of DB fetches per page load

On pages where the sidebar has workout contents, or on search results pages that show thumbnails of exercises or workouts, a large number of DB fetches are generated. This is because of the cascading nature of the relationships involved. Showing one thumbnail requires accessing many objects--for each tag, as well as for the user's latest attempt or score, etc. However, if this results in 1/2-1 dozen fetches for one thumbnail, that is multiplied by the number of thumbnails being rendered. We should consider preloading tags (at least) in the fetches that generate the list of thumbnails to render.

Ideally, the relationships that lead to the displayed lists of thumbnails should be defined to include the tags relation as preloaded.

Figure out SSE AJAXy feedback push

Need to figure out how to do server-side push to students to receive feedback on their exercise practice on development. This is done to give indications for issue #15.

The "Create your course" button on the homepage needs to be fixed

The "Create your course" button on the homepage should be revised to be a modal with a progressive refinement-style search interface (it really means creating a course offering, with the addition of creating the associated course if necessary). This part of the UI also needs to include conditional registration if the user hasn't registered yet.

Workout score displays

Fix displaying of scores in thumbnails, as well as overall workout scores in workout show pages.

Sidebar throws an error when there is no current workout

The error is:

ActiveRecord::RecordNotFound (Couldn't find Exercise without an ID):
app/views/layouts/sidebar.html.haml:14:in `app_views_layouts__sidebar_html_haml_...'

The sidebar needs to be fixed so that it does not assume a current workout is actively being practiced.

Add roster upload support to roster tab on courses page

Add a pythy-style button that supports manual enrollment of individual accounts or bulk upload of CSV files to the roster tab on the courses page. There should be one button per course section, when multiple sections are shown (inside the loop over @course_offerings).

Refactor grade downloads to use csv shaper

I added csv shaper for doing the csv export support for exercises. We should use it for other csv generating tasks, since it does make the code nicer and cleaner. It is currently implemented so you can write "views" that produce pure csv.

Attempt::get_workout_score is broken

The code in this method assumes that all of a user's attempts in a workout are stored sequentially by id, and that they are contiguous with no other user's attempts in between. This is plainly flawed, and the method needs to be rewritten. Overall, it looks like the whole attempts infrastructure needs to be rewritten :-(.

Add user-selectable time zone and tz-dependent time displays (locale dependent formats?)

Currently, time/date display is done through default rendering only. We need to provide appropriate user/profile settings so that users can choose their preferred time zone (and/or display format?), and provide more appropriate displays of dates and times on pages that show them. We need a convenient way to manage this so we don't have to put bulky code in every view that displays time info.

Add JSON export of exercises

We need to provide for appropriate permissions enforcement, but it would be good to have a useful JSON-based export format, instead of (or in addition to) CSV.

Boolean checkboxes in edit forms don't work

Boolean checkboxes for attributes in formtastic forms don't seem to work correctly. Is there javascript missing, or is it some other problem?

According to Krishnan, this could be due to javascript code that auto-clears all checkboxes. See application.js line 79. This should be removed (and the root problem fixed).

Fix exercise thumbnail icons

Exercise thumbnails (both small and large) currently include an icon. Right now, there is one fixed icon for all thumbnails, but the icon should be based on the exercise type (MC = glyphicon-th-list, coding = fa-file-code-o or fa-keyboard-o?) instead.

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.