-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grading refactor: introduce TestCaseGrade (#127)
This class holds the evaluation and scoring results, as well as the final verdict. The term "message" in scoring result is also renamed to "private info", which can only be seen by judges. This is a preparation for supporting scores in grade.
- Loading branch information
Showing
39 changed files
with
587 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#pragma once | ||
|
||
#include "tcframe/evaluator/BatchEvaluator.hpp" | ||
#include "tcframe/evaluator/EvaluationResult.hpp" | ||
#include "tcframe/evaluator/Evaluator.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "tcframe/grade/EvaluationResult.hpp" | ||
#include "tcframe/grade/ScoringResult.hpp" | ||
#include "tcframe/grade/TestCaseGrade.hpp" | ||
#include "tcframe/grade/TestCaseGradeCreator.hpp" | ||
#include "tcframe/grade/Verdict.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <tuple> | ||
#include <utility> | ||
|
||
#include "Verdict.hpp" | ||
#include "tcframe/os.hpp" | ||
#include "tcframe/util.hpp" | ||
|
||
using std::move; | ||
using std::string; | ||
using std::tie; | ||
|
||
namespace tcframe { | ||
|
||
struct TestCaseGrade { | ||
friend class TestCaseGradeBuilder; | ||
|
||
private: | ||
Verdict verdict_; | ||
optional<double> score_; | ||
|
||
optional<ExecutionResult> evaluationExecutionResult_; | ||
optional<ExecutionResult> scoringExecutionResult_; | ||
optional<string> privateScoringInfo_; | ||
|
||
public: | ||
const Verdict& verdict() const { | ||
return verdict_; | ||
} | ||
|
||
const optional<double>& score() const { | ||
return score_; | ||
} | ||
|
||
optional<ExecutionResult> evaluationExecutionResult() const { | ||
return evaluationExecutionResult_; | ||
} | ||
|
||
optional<ExecutionResult> scoringExecutionResult() const { | ||
return scoringExecutionResult_; | ||
} | ||
|
||
const optional<string>& privateScoringInfo() const { | ||
return privateScoringInfo_; | ||
} | ||
|
||
bool operator==(const TestCaseGrade& o) const { | ||
return tie( | ||
verdict_, | ||
score_, | ||
evaluationExecutionResult_, | ||
scoringExecutionResult_, | ||
privateScoringInfo_) == tie( | ||
o.verdict_, | ||
o.score_, | ||
o.evaluationExecutionResult_, | ||
o.scoringExecutionResult_, | ||
o.privateScoringInfo_); | ||
} | ||
}; | ||
|
||
class TestCaseGradeBuilder { | ||
private: | ||
TestCaseGrade subject_; | ||
|
||
public: | ||
TestCaseGradeBuilder& setVerdict(Verdict verdict) { | ||
subject_.verdict_ = verdict; | ||
return *this; | ||
} | ||
|
||
TestCaseGradeBuilder& setScore(double score) { | ||
subject_.score_ = optional<double>(score); | ||
return *this; | ||
} | ||
|
||
TestCaseGradeBuilder& setEvaluationExecutionResult(ExecutionResult evaluationExecutionResult) { | ||
return setEvaluationExecutionResult(optional<ExecutionResult>(evaluationExecutionResult)); | ||
} | ||
|
||
TestCaseGradeBuilder& setEvaluationExecutionResult(optional<ExecutionResult> evaluationExecutionResult) { | ||
subject_.evaluationExecutionResult_ = evaluationExecutionResult; | ||
return *this; | ||
} | ||
|
||
TestCaseGradeBuilder& setScoringExecutionResult(ExecutionResult scoringExecutionResult) { | ||
return setScoringExecutionResult(optional<ExecutionResult>(scoringExecutionResult)); | ||
} | ||
|
||
TestCaseGradeBuilder& setScoringExecutionResult(optional<ExecutionResult> scoringExecutionResult) { | ||
subject_.scoringExecutionResult_ = scoringExecutionResult; | ||
return *this; | ||
} | ||
|
||
TestCaseGradeBuilder& setPrivateScoringInfo(string privateScoringInfo) { | ||
return setPrivateScoringInfo(optional<string>(privateScoringInfo)); | ||
} | ||
|
||
TestCaseGradeBuilder& setPrivateScoringInfo(optional<string> privateScoringInfo) { | ||
subject_.privateScoringInfo_ = privateScoringInfo; | ||
return *this; | ||
} | ||
|
||
TestCaseGrade build() { | ||
return move(subject_); | ||
} | ||
}; | ||
|
||
} |
Oops, something went wrong.