lms.model.testdata.quizzes

 1import os
 2import typing
 3
 4import quizcomp.model.quiz
 5
 6import lms.model.assignments
 7
 8THIS_DIR: str = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
 9ROOT_DIR: str = os.path.join(THIS_DIR, '..', '..', '..')
10QUIZ_PATH: str = os.path.join(ROOT_DIR,
11        'testdata', 'lms-docker-canvas-testdata', 'lms-testdata', 'cse-cracks-course', 'quizzes', 'regex', 'quiz.json')
12
13# {course_name: {name: quiz metadata, ...}, ...}
14COURSE_QUIZZES_METADATA: typing.Dict[str, typing.Dict[str, lms.model.assignments.Assignment]] = {}
15
16# {course_name: {name: quiz, ...}, ...}
17COURSE_QUIZZES: typing.Dict[str, typing.Dict[str, quizcomp.model.quiz.Quiz]] = {}
18
19COURSE_QUIZZES_METADATA['Course 101'] = {
20    'Regular Expressions': lms.model.assignments.Assignment(
21        id = '110000200',
22        name = 'Regular Expressions',
23        points_possible = 0.0,
24        description = (
25            'This quiz is open note, open book, and open world.'
26            + ' Assume all regular expressions are done in Python using the `re` standard library.'
27            + " Good luck!"
28        ),
29    ),
30}
31
32if (os.path.exists(QUIZ_PATH)):
33    COURSE_QUIZZES['Course 101'] = {
34        'Regular Expressions': quizcomp.model.quiz.Quiz.from_path(QUIZ_PATH),
35    }
THIS_DIR: str = '/home/runner/work/lms-toolkit/lms-toolkit/lms/model/testdata'
ROOT_DIR: str = '/home/runner/work/lms-toolkit/lms-toolkit/lms/model/testdata/../../..'
QUIZ_PATH: str = '/home/runner/work/lms-toolkit/lms-toolkit/lms/model/testdata/../../../testdata/lms-docker-canvas-testdata/lms-testdata/cse-cracks-course/quizzes/regex/quiz.json'
COURSE_QUIZZES_METADATA: Dict[str, Dict[str, lms.model.assignments.Assignment]] = {'Course 101': {'Regular Expressions': {"close_date": null, "description": "This quiz is open note, open book, and open world. Assume all regular expressions are done in Python using the `re` standard library. Good luck!", "due_date": null, "extra_fields": {}, "id": "110000200", "name": "Regular Expressions", "open_date": null, "points_possible": 0.0}}}
COURSE_QUIZZES: Dict[str, Dict[str, quizcomp.model.quiz.Quiz]] = {'Course 101': {'Regular Expressions': {"attributes": {"shuffle_answers": true}, "course_name": "CSE Cracks", "description": "This quiz is open note, open book, and open world. Assume all regular expressions are done in Python using the `re` standard library. Good luck!", "groups": [{"name": "Ice Breaker", "pick_count": 1, "points": 5, "questions": [{"answers": ["detective work", "fight corruption", "other"], "feedback": "You can have any answer you want.", "prompt": "Taking inspiration from the XKCD comic below,\nhow would you save the day using regular expressions?\n\n![XKCD Comic 208](images/xkcd-regular-expressions.png)", "question_type": "short_answer"}]}, {"attributes": {"shuffle_answers": false}, "name": "Regular Expression in Programming Languages", "pick_count": 1, "points": 5, "questions": [{"answers": [{"correct": true, "text": "True"}, {"correct": false, "text": "False"}], "feedback": {"correct": "You are right!", "incorrect": "Regular expressions are so useful that almost every language supports them."}, "prompt": "Regular expressions are implemented as either a core feature or in the standard library of almost every major programming language.", "question_type": "true_false"}]}, {"name": "Regular Expression Vocabulary", "pick_count": 1, "points": 20, "questions": [{"answers": {"distractors": ["The set of all alphanumeric characters and underscore.", "All digits.", "A repetition operator that matches the range $[1, infinity]$.", "An operator that allows us to select both of two options."], "matches": [["Character Class", "A set of character where any single member of the group can be matched."], ["Anchor", "A special character that can be used to match the beginning or end of a line."], ["Word Boundary", "The empty string between (`[\\W^]` and `\\w`) or between (`\\w` and `[\\W$]`)."], ["Kleene Star", "A repetition operator that matches the range $[0, infinity]$."], ["Group", "A collection of character that can be treated as a single unit."], ["Disjunction", "An operator that allows us to select one of two options."], ["Back Reference", "A special character that allows us to invoke a previous group."]]}, "prompt": "Match the following terms to their corresponding definitions.", "question_type": "matching"}]}, {"name": "Basic Regular Expressions", "pick_count": 1, "points": 5, "questions": [{"answers": [{"correct": true, "text": "`r'\\d{3} \\d{3}-\\d{4}'`"}, {"correct": false, "feedback": "What about whitespace?", "text": "`r'\\d{10}'`"}, {"correct": false, "feedback": "What if there are no digits in the string?", "text": "`r'\\d* \\d*-\\d*'`"}, {"correct": false, "feedback": "Can this take too many digits?", "text": "`r'\\d+ \\d+-\\d+'`"}], "prompt": "Which of the following regular expressions would be best to match a 10-digit phone number formatted as: '123 456-7890'. (Assume any stretch of continuous whitespace is a single space character.)", "question_type": "multiple_choice"}]}, {"attributes": {"skip_numbering": true}, "name": "Passage", "pick_count": 1, "points": 0, "questions": [{"prompt": "Below is the opening paragraph (which is actually just one sentence) from\n*A Tale Of Two Cities* written by Charles Dickens.\nFuture questions may reference this passage as \"the provided passage\".\n\n\"It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness,\nit was the epoch of belief, it was the epoch of incredulity, it was the season of Light,\nit was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us,\nwe had nothing before us, we were all going direct to Heaven, we were all going direct the other way\n\u2014 in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received,\nfor good or for evil, in the superlative degree of comparison only.\"", "question_type": "text_only"}]}, {"hints": {"width": 0.25}, "name": "Passage Search", "pick_count": 1, "points": 10, "questions": [{"answers": [{"margin": 0.0, "type": "exact", "value": 6}], "feedback": "Remember that your answer should be an integer.", "prompt": "In the provided passage, how many non-specific time periods are mentioned,\ni.e., how many matches are there for the following regular expression:\n\n```python\nr'(age|season|epoch)\\s+of\\s+(\\w+)'\n```", "question_type": "numerical"}]}, {"hints": {"inline": true}, "name": "Quantifiers", "pick_count": 1, "points": 5, "questions": [{"answers": {"PART1": [{"correct": false, "text": "`?`"}, {"correct": true, "text": "`*`"}, {"correct": false, "text": "`+`"}], "PART2": [{"correct": true, "text": "`?`"}, {"correct": false, "text": "`*`"}, {"correct": false, "text": "`+`"}], "PART3": [{"correct": false, "text": "`?`"}, {"correct": false, "text": "`*`"}, {"correct": true, "text": "`+`"}]}, "prompt": "For each scenario, select the quantifier that is most appropriate.\n\nYou want to match the leading zeros for some number. E.g., \"00\" for \"005\".\n\n<placeholder>PART1</placeholder>\n\nYou want to match the negative sign for some number. E.g., \"-\" for \"-9\".\n\n<placeholder>PART2</placeholder>\n\nYou want to match the main digits (before any decimal point) for a required number,\ne.g., \"123\" for \"123\".\n\n<placeholder>PART3</placeholder>", "question_type": "multiple_dropdowns"}]}, {"name": "General Quantification", "pick_count": 1, "points": 5, "questions": [{"answers": [{"correct": false, "text": "Long Cat"}, {"correct": true, "text": "Loong Cat"}, {"correct": true, "text": "Looong Cat"}, {"correct": false, "text": "Loooong Cat"}], "prompt": "Which of the following does the regex `r'Lo{2,3}ng Cat'` match? Select all that apply.", "question_type": "multiple_answers"}, {"answers": [{"correct": false, "text": "I'm So Hungry!"}, {"correct": false, "text": "I'm Soo Hungry!"}, {"correct": true, "text": "I'm Sooo Hungry!"}, {"correct": true, "text": "I'm Soooo Hungry!"}], "prompt": "Which of the following does the regex `r'I'm So{3,4} Hungry!'` match? Select all that apply.", "question_type": "multiple_answers"}]}, {"hints": {"inline": true}, "name": "Backreference Matching", "pick_count": 1, "points": 10, "questions": [{"answers": {"A": ["\\\\4"], "B": ["\\\\3"], "C": ["\\\\2"]}, "prompt": "Suppose that we are trying to write a script extract name information from text and put it into a CSV (comma-separated value) file.\nThe order of the columns in our CSV file are: first name, last name, and title.\nAs part of our script, we have a regular expression that looks for people that have their name's written as \"last, first\".\n\n```python\nimport re\n\ndef create_csv_line(text_line):\n regex = r'^\\s*((Dr).?)?\\s*([^,]+)\\s*,\\s*(.+)\\s*$'\n replacement = MY_REPLACEMENT_STRING\n\n return re.sub(regex, replacement, text_line)\n```\n\nFill in the blanks in `MY_REPLACEMENT_STRING` to make the above code work correctly.\n\n`MY_REPLACEMENT_STRING = r'`<placeholder>A</placeholder>`,`<placeholder>B</placeholder>`,`<placeholder>C</placeholder>`'`", "question_type": "fill_in_multiple_blanks"}]}, {"name": "Regex Golf", "pick_count": 1, "points": 15, "questions": [{"answers": ["`r'\\d\\d:\\d\\d [AP]M'`", "`r\"\\d\\d:\\d\\d [AP]M\"`", "`r'\\d{2}:\\d{2} [AP]M'`", "`r\"\\d{2}:\\d{2} [AP]M\"`"], "prompt": "Create a regular expression that matches successfully completes a game a golf with the table below.\n\nSpecifics:\n\n- Match all values in the `Match` column.\n- Do not match any values in the `No Match` column.\n- Write you regex as a raw string using a single or double quotes (not triple quotes).\n- Treat the contents of each table cell as a string (so you do not have the match the quotes).\n- You may assume that any contiguous whitespace is a single space character.\n- You only need to match (or not match) the values in the table, you do not need to extend this pattern to unseen values.\n\n| Match | No Match |\n| ------------ | ------------- |\n| `'12:00 AM'` | `'00:00'` |\n| `'05:30 PM'` | `'17:30'` |\n| `'01:45 AM'` | `'01:65 AM'` |\n| `'10:10 PM'` | `'10:10 ZZ'` |\n| `'12:34 PM'` | `'12:34 pm'` |\n| `'11:59 PM'` | `'23:59'` |\n| | `'123:45 AM'` |\n| | `'12:345 PM'` |", "question_type": "fill_in_the_blank"}]}, {"name": "Write a Function", "pick_count": 1, "points": 20, "questions": [{"answers": ["A complete solution can pull out all three components in one regex."], "prompt": "Implement a function with the following signature and description:\n\n```\nimport re\n\ndef compute(text):\n \"\"\"\n Compute the result of the binary expression represented in the |text| variable.\n The possible operators are: \"+\", \"-\", \"*\", and \"/\".\n Operands may be any real number.\n If the operation is division, the RHS (denominator) will not be zero.\n \"\"\"\n\n return NotImplemented\n```\n\nSpecifics:\n\n- Your function must use regular expressions.\n- You may not use `eval()` or any other Python ast functionality.\n- You may only import modules from the Python standard library.\n- You should return a float that is the result of the binary operation represented by `text`.\n- The operator will be one of: $ \\{+, -, *, /\\} $.\n- Operands may be any real number.", "question_type": "essay"}]}], "name": "Regular Expressions", "term_name": "20XX", "time_limit_mins": 30}}}