makeopensource / devU

Autograder version 4
11 stars 14 forks source link

Non-container grading endpoint #40

Closed keiferms3 closed 8 months ago

keiferms3 commented 8 months ago

Create an endpoint to run non-container autograders on a submission.

RA341 commented 8 months ago

I talked to Jesse he said to import my grader function instead of a api endpoint.

Let me know what information you have available , when calling the grader i.e nonContainerAutograderID or assignment id so I can make the function accordingly

keiferms3 commented 8 months ago

At the moment I'm retrieving all non-container autograders from the db that have the same assignmentId as the submission the endpoint has been called for. Then the submission's questions are iterated through, and for each question I check if a grader with a matching question exists, and if yes then perform the grading logic. I just pushed a commit with how the service function is at the moment if you want specifics.

Something I could use from your end is feedback from the autograders. I'm not sure how exactly we plan to implement that, but the grading endpoint should receive feedback so it can attach it to the submission and problem scores

RA341 commented 8 months ago

grader with regex support

export function checkAnswer(studentAnswer: string, nonContainerAutoGrader: NonContainerAutoGrader) {

  if (nonContainerAutoGrader.isRegex) {
    // Create a regex pattern
    const pattern = parseRegex(nonContainerAutoGrader.correctString)
    // Use the test method
    const isMatch: boolean = pattern.test(studentAnswer)
    if (isMatch) {
      return nonContainerAutoGrader.score
    }
  } else {
    // if no regex is set use normal string matching
    if (studentAnswer === nonContainerAutoGrader.correctString) {
      return nonContainerAutoGrader.score
    }
  }

  // default value to return if all conditions fail to execute
  // i.e. the answer is incorrect or improperly formatted
  return 0
}