Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
* Refactor modules with bad code quality
* Remove misc and unused databases modules.
* Add markdown lint in codeclimate config, decrease cyclomatic complexity
* Remove all usages of the MOE project from the edx-adapt
  • Loading branch information
Igor Degtiarov authored Mar 1, 2017
1 parent 4837151 commit 7e2d72d
Show file tree
Hide file tree
Showing 17 changed files with 452 additions and 794 deletions.
43 changes: 43 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Serves for configuration of CodeClimate (automated code review for test coverage, complexity, duplication, etc.)
engines:
radon:
enabled: true
config:
python_version: 2
threshold: "C"
exclude_fingerprints:
# It is not needed to fight for cyclomatic complexity decreasing in tools/** scripts
- 986c7c1735f2a2e2a6500e7148ea4bd5 # cyclomatic complexity in course_setup.py
- ec3a2e4e4d53fb59016309bd007df078 # cyclomatic complexity in transform_to_adapt/transform_problems.py
fixme:
enabled: true
config:
strings:
- FIXME
- BUG
- CUSTOM
- TODO
duplication:
enabled: true
config:
languages:
- javascript:
- python:
python_version: 2
exclude_fingerprints:
# Probabilities POST and PUT methods are marked as duplication
- 4e06d64888f1f615bfcf51416844dca5
eslint:
enabled: true
markdownlint:
enabled: true
exclude_fingerprints:
# Long line in Code block marked as long, but length checking is not expected in code blocks
- 7e02053fa411ee2f67df597e15d10148

ratings:
paths:
- "**.js"
- "**.py"
- "**.md"

128 changes: 58 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Adaptive problem selection interface for EdX courses

[![Travis](https://img.shields.io/travis/raccoongang/edx-adapt.svg)](https://travis-ci.org/raccoongang/edx-adapt) [![Code Climate](https://img.shields.io/codeclimate/github/raccoongang/edx-adapt.svg)](https://codeclimate.com/github/raccoongang/edx-adapt)
[![Travis](https://img.shields.io/travis/raccoongang/edx-adapt.svg)](https://travis-ci.org/raccoongang/edx-adapt)
[![Code Climate](https://img.shields.io/codeclimate/github/raccoongang/edx-adapt.svg)](https://codeclimate.com/github/raccoongang/edx-adapt)

## Installation

Expand Down Expand Up @@ -29,13 +30,12 @@ Activate virtual environment and install all requirements:
> pip install -r requirements
```

## Run edx-adapt application in development mode:
## Run edx-adapt application in development mode

```
> python edx_adapt.py
```


## Run edx-adapt application in production mode

There are few sample config files in `etc/folder` required to configure
Expand All @@ -54,135 +54,120 @@ service manager
`/api/v1/course`

- GET: Show all courses registered in Edx-Adapt
- `response.data = {'course_ids': courses}`
- `response.data = {'course_ids': courses}`
- POST: Create new course in Edx-Adapt
- Parameters: `course_id` (string)

- Parameters: `course_id` (string)

`/api/v1/course/<course_id>/skill`

- GET: Show all skills which course `<course_id>` contains.
- `response.data = {'skills': skills}`
- `response.data = {'skills': skills}`
- POST: Add skill into course `<course_id>`
- Parameters : `skill_name` (string)

- Parameters : `skill_name` (string)

`/api/v1/course/<course_id>/user`

- GET: Show all users registered in the course `<course_id>`
- `response.data = {'users': {'finished': finished_users, 'in_progress':
progress_users}}`
- `response.data = {'users': {'finished': finished_users,
'in_progress': progress_users}}`
- POST: Enroll new user in the course `<course_id>`
- Parameters: `user_id` (string)

- Parameters: `user_id` (string)

`/api/v1/course/<course_id>`

- GET: Show all problems contained to the course `<course_id>`
- `response.data = {'problems': problems}`
- `response.data = {'problems': problems}`
- POST: Add new problem in the course `<course_id>`
- Parameters: `problem_name` (string), `tutor_url` (string), `skills`
(list of strings), `pretest` (boolean), `posttest` (boolean)

- Parameters: `problem_name` (string), `tutor_url` (string), `skills`
(list of strings), `pretest` (boolean), `posttest` (boolean)

`/api/v1/course/<course_id>/skill/<skill_name>`

- GET: Show all problems contained in the course `<course_id>` related
to the skill `<skill_name>`
- `response.data = {'problems': problems}`

to the skill `<skill_name>`
- `response.data = {'problems': problems}`

`/api/v1/course/<course_id>/experiment`

- GET: Show result of all experiments for the course `<course_id>`
- `response.data = {'experiments': exps}`

- `response.data = {'experiments': exps}`

`/api/v1/course/<course_id>/probabilities`

- GET: Show list with default BKT model parameters added to the course
`<course_id>`
- `response.data = {'model_params': prob_list}`
`<course_id>`
- `response.data = {'model_params': prob_list}`

- POST: Add new or update existing model parameters in the course
`<course_id>`
- Parameters: `prob_list` (list of dicts with models parameters)
`[{threshold: float, pg: float, ps: float, pi: float, pt: float}, ...]`

`<course_id>`
- Parameters: `prob_list` (list of dicts with models parameters)
`[{threshold: float, pg: float, ps: float, pi: float, pt: float},
...]`

`/api/v1/course/<course_id>/user/<user_id>/interaction`

- POST: Add user's interaction with Edx into Edx-Adapt
- Parameters: `problem` (string), `correct` (int), `attempt` (int),
`unix_seconds` (string)

- Parameters: `problem` (string), `correct` (int), `attempt` (int),
`unix_seconds` (string)

`/api/v1/course/<course_id>/user/<user_id>`

- GET: Show user's status:
- `reponse.data = {
- `reponse.data = {
"next": next_problem, "current": current_problem,
"done_with_current": done_with_current, "okay": okay,
"done_with_course": done_with_course
}`

}`

`/api/v1/course/<course_id>/user/<user_id>/pageload`

- POST: Add logging information about problem visited by user into
Edx-Adapt
- Parameters: `problem` (string), `unix_seconds` (string)

Edx-Adapt
- Parameters: `problem` (string), `unix_seconds` (string)

`/api/v1/parameters/bulk`

- POST: Add BKT model parameters to each course's skill for the user
- Parameters: `course_id` (string), `user_id` (string), `skills_list`
(list of strings)

- Parameters: `course_id` (string), `user_id` (string), `skills_list`
(list of strings)

`/api/v1/data/logs/course/<course_id>/user/<user_id>/problem/<problem_name>`

- GET: Show collected log data for users `<user_id>` interaction with
problem `<problem_name>` on the course `<course_id>`
- `response.data = {'log': problem log}`

problem `<problem_name>` on the course `<course_id>`
- `response.data = {'log': problem log}`

`/api/v1/data/logs/course/<course_id>/user/<user_id>`

- GET: Show all collected log data for user `<user_id>` interaction on
the course `<course_id>`
- `response.data = {'log': log data}`

the course `<course_id>`
- `response.data = {'log': log data}`

`/api/v1/data/logs/course/<course_id>`

- GET: Show all collected data for every user with status "in progress"
on the course `<course_id>`
- `response.data = {'log': log data}`

on the course `<course_id>`
- `response.data = {'log': log data}`

`/api/v1/data/logs/course/<course_id>/experiment/<experiment_name>`

- GET: Show all collected log data for users successfully passed
experiment `<experiment_name>` on the course `<course_id>`
- `response.data = {'log': log data}`

experiment `<experiment_name>` on the course `<course_id>`
- `response.data = {'log': log data}`

`/api/v1/data/trajectory/course/<course_id>/user/<user_id>`

- GET: Show trajectory of the user `<user_id>` interaction with the
course `<course_id>`
- `response.data = {'data': {}, 'trajectories': {}, 'pretest_length':
course `<course_id>`
- `response.data = {'data': {}, 'trajectories': {}, 'pretest_length':
{}, 'posttest_length': {}}`


`/api/v1/data/trajectory/course/<course_id>`
- GET: Show trajectory for all users with status "in progress" in the
course `<course_id>`
- `response.data = {<user_id_1>: {'data': {}, 'trajectories': {},
'pretest_length': {}, 'posttest_length': {}}, <user_id_2>: {}, ...}`

- GET: Show trajectory for all users with status "in progress" in the
course `<course_id>`
- `response.data = {<user_id_1>: {'data': {}, 'trajectories': {},
'pretest_length': {}, 'posttest_length': {}}, <user_id_2>: {}, ...}`

## Data models stored in the database

Expand All @@ -195,7 +180,7 @@ specifically for certain course.

### Generic collections are: `Courses` and `Generic`

#### `Courses` collection stores documents with base information about the course:
#### `Courses` collection stores documents with base information about the course

```js
{
Expand Down Expand Up @@ -234,13 +219,13 @@ specifically for certain course.
}
```

#### `Generic` collection stores all student - skills related data:

#### `Generic` collection stores all student - skills related data

```js
{
_id: ObjectID(),
key: <string>, // unique compound key, which contains <course_id>, <user_id>, and <skill_name>
key: <string>, // unique compound key, which contains <course_id>,
// <user_id>, and <skill_name>
val: {
threshold: <double>,
pg: <double>,
Expand All @@ -258,7 +243,7 @@ specifically for certain course.
Adaptive logging includes page load data and student's responses on
problems questions.

##### Interaction log doc:
##### Interaction log doc

```js
{
Expand All @@ -278,7 +263,7 @@ problems questions.
}
```

##### Page load log doc:
##### Page load log doc

```js
{
Expand Down Expand Up @@ -313,10 +298,13 @@ student on every step through the adaptive course
},
next: null, // Possible values: dict with problem description, null.
student_id: <string>,
perm: false, // (experimental attribute) boolean flag shows if student has permissions for fluent navigation.
// Permission is changed after student start to answer on post-assessment problems
nav: "adapt" // Save initial student permission. Possible value "adapt" and "free", "adapt" is default behavior
// (perm == false), "free" (perm == true) student had permissions for free navigation through
// adaptive problems
perm: false, // (experimental attribute) boolean flag shows if student
// has permissions for fluent navigation.
// Permission is changed after student start to answer on
// post-assessment problems
nav: "adapt" // Save initial student permission. Possible value "adapt"
// and "free", "adapt" is default behavior
// (perm == false), "free" (perm == true) student had
// permissions for free navigation throug adaptive problems
}
```
2 changes: 0 additions & 2 deletions data/BKT/problems.csv
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ Pre_assessment_8,center
Pre_assessment_9,spread
shape_0,shape
shape_1,shape
skew_easy_0,None
skew_easy_1,shape
skew_easy_2,shape
skew_easy_3,shape
Expand All @@ -81,4 +80,3 @@ t4_2_1,histogram
t5_center,center
t5_shape,shape
t5_spread,spread
labels_we,None
10 changes: 10 additions & 0 deletions edx_adapt/api/resources/base_resource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
General Resources for all API resources modules
"""
from flask_restful import Resource


class BaseResource(Resource):
def __init__(self, **kwargs):
self.repo = kwargs['data'] # repo: DataInterface
self.selector = kwargs['selector'] # selector: SelectInterface
Loading

0 comments on commit 7e2d72d

Please sign in to comment.