33 lines
751 B
Python
33 lines
751 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
|
import json
|
|
|
|
print("Handler program/match-regex loaded!")
|
|
|
|
|
|
# helper
|
|
|
|
|
|
class ExerciseHandler(object):
|
|
def __init__(self, parser=None):
|
|
self.parser = parser
|
|
self.data = {'code': ''}
|
|
print("ExerciseHandler program/match-regex")
|
|
print("parser.path", parser.path)
|
|
|
|
item = self.parser.item
|
|
data = self.data
|
|
|
|
# enable grading for this exercise type
|
|
item.grading = True
|
|
|
|
item.content = self.parser.get_exercise_content()
|
|
data['question'] = self.parser.get_file_content('question')
|
|
data['regex'] = self.parser.get_file_content('regex').strip()
|
|
|
|
|
|
item.data = json.dumps(self.data)
|
|
item.save()
|