Skip to content

Instantly share code, notes, and snippets.

@vad23klev
Created June 8, 2015 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vad23klev/e0e578f04c4fad56cec1 to your computer and use it in GitHub Desktop.
Save vad23klev/e0e578f04c4fad56cec1 to your computer and use it in GitHub Desktop.
Test function
public function test_validate_without_analyzers() {
$language = new block_formal_langs_language_cpp_parseable_language();
$question = new qtype_correctwriting_question();
$question->usecase = true;
$question->lexicalerrorthreshold = 3000;
$question->lexicalerrorweight = 0.1;
$question->usedlanguage = $language;
$question->movedmistakeweight = 0.1;
$question->absentmistakeweight = 0.11;
$question->addedmistakeweight = 0.12;
$question->hintgradeborder = 0.75;
$question->maxmistakepercentage = 0.95;
$question->qtype = new qtype_correctwriting();
$question->islexicalanalyzerenabled = 1;
$question->isenumanalyzerenabled = 1;
$question->issequenceanalyzerenabled = 1;
$question->issyntaxanalyzerenabled = 0;
$contexts = new question_edit_contexts(context_system::instance());
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
$cat = $generator->create_question_category(array());
$question->category = $cat->id;
$form = new qtype_correctwriting_edit_form("",$question,$cat,$contexts);
$data = array(
'langid' => 1
);
$errors = $form->validation($data, $files);
$expected_errors = [];
$this->assertEquals($errors,$expected_errors);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment