Skip to content

Commit 71786a3

Browse files
committed
Accept assignment-question id as well
1 parent 03fcbbb commit 71786a3

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

app/Http/Controllers/QuestionController.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,18 @@ function getWebworkCodeFromFilePath(Request $request,
16911691
$response['message'] = $authorized->message();
16921692
return $response;
16931693
}
1694+
//allow for assignment-question
1695+
$pattern = '/^[^-]*-[^-]*$/';
1696+
if (preg_match($pattern, $request->file_path)) {
1697+
$parts = explode('-',$request->file_path);
1698+
if (isset($parts[1]) && is_numeric($parts[1])){
1699+
$request->file_path = $parts[1];
1700+
} else {
1701+
$response['message'] = "That does not look like a valid ADAPT ID or WebWork File Path.";
1702+
return $response;
1703+
}
1704+
1705+
}
16941706

16951707
try {
16961708
if (is_numeric($request->file_path)) {

resources/js/components/questions/CreateQuestion.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,6 +2463,8 @@ export default {
24632463
},
24642464
async updateTemplateWithPreexistingWebworkFilePath (filePath) {
24652465
this.updatingTempalteWithPreexistingWebworkFilePath = true
2466+
let parts = filePath.split('-')
2467+
let questionId = parts.pop()
24662468
try {
24672469
const { data } = await axios.post('/api/questions/get-webwork-code-from-file-path', { file_path: filePath })
24682470
if (data.type === 'error') {

0 commit comments

Comments
 (0)