Skip to content

Commit 914ba90

Browse files
committed
Updated tasks
1 parent 15886dc commit 914ba90

8 files changed

Lines changed: 116 additions & 214 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
agreements:
2-
- text: If you have not already done so, please complete the survey on <a href="https://www.sqrlab.ca/">LimeSurvey</a>
2+
- text: If you have not already done so, please complete the survey on <a href="https://www.sqrlab.ca/survey/index.php?r=survey/index&sid=896941&lang=en">LimeSurvey</a>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
def calculate_gpa(results):
2+
"""
3+
Args:
4+
results (list): list of (letter_grade, credits) tuples.
5+
Valid grades: A, B, C, D, F. Credits must be > 0.
6+
Returns:
7+
dict: { 'gpa': float|None, 'classification': str|None,
8+
'status': 'ok'|'error', 'message': str }
9+
"""
10+
grade_points = {'A': 4.0, 'B': 3.0, 'C': 2.0, 'D': 1.0, 'F': 0.0}
11+
12+
if not results:
13+
return {'gpa': None, 'classification': None,
14+
'status': 'error', 'message': 'No results provided'}
15+
16+
total_points = 0
17+
total_credits = 0
18+
19+
for grade, credits in results:
20+
if grade not in grade_points or credits <= 0:
21+
return {'gpa': None, 'classification': None,
22+
'status': 'error', 'message': 'Invalid grade or credits'}
23+
total_points += grade_points[grade] * credits
24+
total_credits += credits
25+
26+
gpa = total_points / total_credits
27+
28+
if gpa >= 3.5:
29+
classification = 'First Class'
30+
elif gpa >= 2.0:
31+
classification = 'Second Class'
32+
else:
33+
classification = 'Fail'
34+
35+
return {'gpa': round(gpa, 2), 'classification': classification,
36+
'status': 'ok', 'message': 'GPA calculated'}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
def check_parcel(tracking_id, weight_kg, destination):
2+
"""
3+
Validate a parcel and assign a shipping tier.
4+
5+
Args:
6+
tracking_id (str): Non-empty parcel identifier.
7+
weight_kg (float): Parcel weight in kg (must be > 0 and <= 30).
8+
destination (str): 'domestic' or 'international'.
9+
10+
Returns:
11+
dict: {
12+
'tier': 'standard', 'express', or None,
13+
'delivery_days': int or None,
14+
'status': 'ok' or 'error',
15+
'message': str
16+
}
17+
"""
18+
if not isinstance(tracking_id, str) or not tracking_id.strip():
19+
return {'tier': None, 'delivery_days': None,
20+
'status': 'error', 'message': 'Invalid tracking ID'}
21+
22+
if weight_kg <= 0 or weight_kg > 30:
23+
return {'tier': None, 'delivery_days': None,
24+
'status': 'error', 'message': 'Weight out of range'}
25+
26+
if destination not in ('domestic', 'international'):
27+
return {'tier': None, 'delivery_days': None,
28+
'status': 'error', 'message': 'Unknown destination type'}
29+
30+
if weight_kg <= 2:
31+
tier = 'express'
32+
else:
33+
tier = 'standard'
34+
35+
if destination == 'domestic':
36+
delivery_days = 2 if tier == 'express' else 5
37+
else:
38+
delivery_days = 7 if tier == 'express' else 14
39+
40+
return {'tier': tier, 'delivery_days': delivery_days,
41+
'status': 'ok', 'message': 'Parcel accepted'}

ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/content/task/print_error.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/content/task/read.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

ij-plugin/src/main/resources/org/jetbrains/research/tasktracker/config/content/task/write.py

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
scenario:
22
steps:
33
- units:
4-
- !<List>
5-
taskIds:
6-
- "sample_statement_coverage"
7-
- "print_error_statement_coverage"
8-
- "read_statement_coverage"
9-
- "write_branch_coverage"
10-
# - "read_path_coverage"
4+
- !<Task>
5+
id: "statement_coverage"
6+
- !<Task>
7+
id: "branch_coverage"
Lines changed: 34 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,50 @@
11
tasks:
2-
- description: "Sample Task - Statement Coverage: This task is a sample for reference only to show what a basic Python unit test using pytest looks like.\n\nStatement Coverage: Causes every statement in the program to be executed at least once, giving us confidence that every statement is at least capable of executing correctly.\n\nSystem: Make a test case for each statement in the program, independent of the others.\n\nCompletion criterion: A test case for every statement.\n\nNote: You only need to do statement coverage for the provided code for this study.\n\nWhen you are done the task, please back up the file in a separate location before submitting it.\n\nThe files can be found in the tasktracker directory.\n\nYou will need to import print_error.py and pytest."
3-
id: sample_statement_coverage
4-
name: "Statement Coverage Sample"
5-
focusFileId: "statement_coverage_sample"
6-
files:
7-
- filename: "test_sample"
8-
sourceSet: "SRC"
9-
templateFile: "test_sample"
10-
extension: PYTHON
11-
id: "test_sample_file"
12-
- filename: "sample"
13-
sourceSet: "SRC"
14-
templateFile: "sample"
15-
extension: PYTHON
16-
id: "sample"
17-
openAllFiles: true
18-
- description: "Statement Coverage: Causes every statement in the program to be executed at least once, giving us confidence that every statement is at least capable of executing correctly.\n\nSystem: Make a test case for each statement in the program, independent of the others.\n\nCompletion criterion: A test case for every statement.\n\nNote: You only need to do statement coverage for the provided code for this study.\n\nWhen you are done the task, please back up the file in a separate location before submitting it.\n\nThe files can be found in the tasktracker directory.\n\nYou will need to import print_error.py and pytest."
19-
id: print_error_statement_coverage
20-
name: "Print Error Statement Coverage"
21-
focusFileId: "print_error_statement_coverage_file"
22-
files:
23-
- filename: "test_print_error"
24-
sourceSet: "SRC"
25-
extension: PYTHON
26-
id: "print_error_statement_coverage_file"
27-
- filename: "print_error"
28-
sourceSet: "SRC"
29-
templateFile: "print_error"
30-
extension: PYTHON
31-
id: "print_error"
32-
openAllFiles: true
332

34-
- description: "Statement Coverage: Causes every statement in the program to be executed at least once, giving us confidence that every statement is at least capable of executing correctly.\n\nSystem: Make a test case for each statement in the program, independent of the others.\n\nCompletion criterion: A test case for every statement.\n\nNote: You only need to do statement coverage for the provided code for this study.\n\nWhen you are done the task, please back up the file in a separate location before submitting it.\n\nThe files can be found in the tasktracker directory.\n\nYou will need to import read.py and pytest."
35-
id: read_statement_coverage
36-
name: "Read Statement Coverage"
37-
focusFileId: "read_statement_coverage_file"
3+
- description: "Complete the task using the instructions on LimeSurvey. The task file will be under tasktracker/python/MagicSquare/src. /n/n After completing the task, and submitting the files on LimeSurvey, click next. Statement Coverage: Causes every statement in the program to be executed at least once, giving us confidence that every statement is at least capable of executing correctly.\n\nSystem: Make a test case for each statement in the program, independent of the others.\n\nCompletion criterion: A test case for every statement.\n\nNote: You only need to do statement coverage for the provided code for this study.\n\nWhen you are done the task, please back up the file in a separate location before submitting it.\n\nThe files can be found in the tasktracker directory.\n\nYou will need to import print_error.py and pytest."
4+
id: statement_coverage
5+
name: "Calculate GPA Statement Coverage"
6+
focusFileId: "test_calculate_gpa"
387
files:
39-
- filename: "test_read_statement"
8+
- filename: "test_calculate_gpa"
409
sourceSet: "SRC"
4110
extension: PYTHON
42-
id: "read_statement_coverage_file"
43-
- filename: "read"
11+
id: "test_calculate_gpa"
12+
- filename: "calculate_gpa"
4413
sourceSet: "SRC"
45-
templateFile: "read"
14+
templateFile: "calculate_gpa"
4615
extension: PYTHON
47-
id: "read"
16+
id: "calculate_gpa"
4817
openAllFiles: true
4918

50-
- description: "Branch Coverage: Causes every decision (if, switch, while, etc.) in the program to be made both ways (or every possible way for switch).\n\nSystem: Design a test case to exercise each decision in the program each way (true/false).\n\nCompletion criterion: A test case for each side of each decision.\n\nNote: You only need to do branch coverage for the provided code for this study.\n\nWhen you are done the task, please back up the file in a separate location before submitting it.\n\nThe files can be found in the tasktracker directory.\n\nYou will need to import write.py and pytest."
51-
id: write_branch_coverage
52-
name: "Write Branch Coverage"
53-
focusFileId: "write_branch_coverage_file"
19+
- description: "Complete the task using the instructions on LimeSurvey. The task file will be under tasktracker/python/WordSearch/src. /n/n After completing the task, and submitting the files on LimeSurvey, click next. Branch Coverage: Causes every decision (if, switch, while, etc.) in the program to be made both ways (or every possible way for switch).\n\nSystem: Design a test case to exercise each decision in the program each way (true/false).\n\nCompletion criterion: A test case for each side of each decision.\n\nNote: You only need to do branch coverage for the provided code for this study.\n\nWhen you are done the task, please back up the file in a separate location before submitting it.\n\nThe files can be found in the tasktracker directory.\n\nYou will need to import write.py and pytest."
20+
id: branch_coverage
21+
name: "Check Parcel Branch Coverage"
22+
focusFileId: "test_check_parcel"
5423
files:
55-
- filename: "test_write_branch"
24+
- filename: "test_check_parcel"
5625
sourceSet: "SRC"
5726
extension: PYTHON
58-
id: "write_branch_coverage_file"
59-
- filename: "write"
27+
id: "test_check_parcel"
28+
- filename: "check_parcel"
6029
sourceSet: "SRC"
61-
templateFile: "write"
30+
templateFile: "check_parcel"
6231
extension: PYTHON
63-
id: "write"
32+
id: "check_parcel"
6433
openAllFiles: true
6534

66-
- description: "Path Coverage: Ensures that every unique path through the program, from start to finish, is executed at least once.\n\nSystem: Design test cases to cover all possible paths in the control flow graph of the program.\n\nCompletion criterion: A test case for every distinct control flow path.\n\nNote: You only need to do path coverage for the provided code for this study.\n\nYou will need to import read.py and pytest."
67-
id: read_path_coverage
68-
name: "Read Path Coverage"
69-
focusFileId: "read_path_coverage_file"
70-
files:
71-
- filename: "test_read_branch"
72-
sourceSet: "SRC"
73-
extension: PYTHON
74-
id: "read_path_coverage_file"
75-
- filename: "read"
76-
sourceSet: "SRC"
77-
templateFile: "read"
78-
extension: PYTHON
79-
id: "read"
80-
openAllFiles: true
35+
# - description: "Sample Task - Statement Coverage: This task is a sample for reference only to show what a basic Python unit test using pytest looks like.\n\nStatement Coverage: Causes every statement in the program to be executed at least once, giving us confidence that every statement is at least capable of executing correctly.\n\nSystem: Make a test case for each statement in the program, independent of the others.\n\nCompletion criterion: A test case for every statement.\n\nNote: You only need to do statement coverage for the provided code for this study.\n\nWhen you are done the task, please back up the file in a separate location before submitting it.\n\nThe files can be found in the tasktracker directory.\n\nYou will need to import print_error.py and pytest."
36+
# id: sample_statement_coverage
37+
# name: "Statement Coverage Sample"
38+
# focusFileId: "statement_coverage_sample"
39+
# files:
40+
# - filename: "test_sample"
41+
# sourceSet: "SRC"
42+
# templateFile: "test_sample"
43+
# extension: PYTHON
44+
# id: "test_sample_file"
45+
# - filename: "sample"
46+
# sourceSet: "SRC"
47+
# templateFile: "sample"
48+
# extension: PYTHON
49+
# id: "sample"
50+
# openAllFiles: true

0 commit comments

Comments
 (0)