Skip to content

Commit

Permalink
Assorted linting from local_moodlecheck
Browse files Browse the repository at this point in the history
Removed empty lines, Strings responsenotrequired and responseoptions were
duplicated in both de and en, removed first copy. Other minor lint report fixes
  • Loading branch information
marcusgreen committed Oct 26, 2024
1 parent 9b43ba0 commit 7c08952
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
2 changes: 0 additions & 2 deletions classes/form/edit_spellchek.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ public function definition() {
$mform->addElement('hidden', 'answerstepid');
$mform->setType('answerstepid', PARAM_INT);


$mform->addElement('static', 'student_answer', get_string('spellcheck_student_anser_desc', 'qtype_aitext'));
$mform->setType('student_answer', PARAM_RAW);


$mform->addElement(
'editor',
'spellcheck_editor',
Expand Down
1 change: 0 additions & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@ function xmldb_qtype_aitext_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2024051101, 'qtype', 'aitext');
}


return true;
}
20 changes: 9 additions & 11 deletions lang/de/qtype_aitext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$string['answerfiles'] = 'Antwortdateien';
$string['answertext'] = 'Antworttext';
$string['attachmentsoptional'] = 'Anhänge sind optional';
$string['automatic_spellcheck'] = 'Automatische Rechtschreibprüfung';
$string['cachedef_stringdata'] = 'Cachedef stringdata';
$string['defaultmarksscheme'] = 'Markierungsschema';
$string['defaultmarksscheme_setting'] = 'Dies wird das Standard-Bewertungsschema für neue Fragen sein. Fragenautoren sollten dieses Schema an die jeweilige Frage anpassen.';
Expand All @@ -44,9 +45,9 @@
$string['err_maxwordlimitnegative'] = 'Maximales Wortlimit kann keine negative Zahl sein';
$string['err_minwordlimit'] = 'Minimum word limit is enabled but is not set';
$string['err_minwordlimitnegative'] = 'Minimales Wortlimit kann keine negative Zahl sein';
$string['err_parammissing'] = 'Ungültige Parameter. Stellen Sie sicher, dass Sie eine Beispiel-Antwort und einen Prompt eingegeben haben.';
$string['err_retrievingfeedback'] = 'Fehler beim Abrufen des Feedbacks vom KI-Tool: {$a}';
$string['err_retrievingtranslation'] = 'Fehler beim Abrufen der Übersetzung: {$a}';
$string['err_parammissing'] = 'Ungültige Parameter. Stellen Sie sicher, dass Sie eine Beispiel-Antwort und einen Prompt eingegeben haben.';
$string['formateditor'] = 'HTML-Editor';
$string['formateditorfilepicker'] = 'HTML-Editor mit Dateipicker';
$string['formatmonospaced'] = 'Einfacher Text, Schriftart monospaced';
Expand Down Expand Up @@ -81,8 +82,6 @@
$string['responsefieldlines'] = 'Größe des Eingabefeldes';
$string['responseformat'] = 'Antwortformat';
$string['responseformat_setting'] = 'Der Editor, den der Schüler bei der Beantwortung verwendet';
$string['responseoptions'] = 'Antwortmöglichkeiten';
$string['responsenotrequired'] = 'Texteingabe ist optional';
$string['responseisrequired'] = 'Den Schüler zur Texteingabe auffordern';
$string['responsenotrequired'] = 'Die Texteingabe ist optional';
$string['responseoptions'] = 'Antwortmöglichkeiten';
Expand All @@ -94,17 +93,16 @@
$string['sampleanswerempty'] = 'Vergewissern Sie sich, dass Sie eine KI-Eingabeaufforderung und eine Beispielantwort haben, bevor Sie den Test durchführen.';
$string['sampleanswerevaluate'] = 'Beispielantwort auswerten';
$string['showprompt'] = 'Eingabeaufforderung anzeigen';
$string['spellcheck_editor_desc'] = 'Dies ist der Text, in dem die Rechtschreibfehler von der KI korrigiert wurden. Sie können diesen Korrekturvorschlag bearbeiten.';


$string['spellcheck_prompt'] = 'Gib den Text ohne strukturelle Änderung 1:1 wieder. Verzichte auf ein Feedback. Aber korrigiere alle Rechtschreibfehler im nachfolgenden Text: ';
$string['spellcheck_student_anser_desc'] = 'Dies ist die ursprüngliche Antwort des Schülers';
$string['spellcheckedit'] = 'Rechtschreibprüfung bearbeiten';
$string['spellcheckeditor'] = 'Rechtschreibprüfung der KI bearbeiten';
$string['thedefaultmarksscheme'] = 'Ziehe für jeden Grammatik- oder Rechtschreibfehler einen Punkt von der Gesamtpunktzahl ab.';
$string['thedefaultprompt'] = 'Erklären Sie, ob etwas mit der Grammatik und der Rechtschreibung im Text nicht stimmt.';
$string['untestedquestionbehaviour'] = 'Ungetestetes Frageverhalten';
$string['wordcount'] = 'Wortanzahl: {$a}';
$string['wordcounttoofew'] = 'Wortanzahl: {$a->count}, weniger als die erforderlichen {$a->limit} Wörter.';
$string['wordcounttoomuch'] = 'Wortanzahl: {$a->count}, mehr als das Limit von {$a->limit} Wörtern.';
$string['automatic_spellcheck'] = 'Automatische Rechtschreibprüfung';
$string['spellcheckedit'] = 'Rechtschreibprüfung bearbeiten';
$string['spellcheckeditor'] = 'Rechtschreibprüfung der KI bearbeiten';
$string['spellcheck_editor_desc'] = 'Dies ist der Text, in dem die Rechtschreibfehler von der KI korrigiert wurden. Sie können diesen Korrekturvorschlag bearbeiten.';
$string['spellcheck_student_anser_desc'] = 'Dies ist die ursprüngliche Antwort des Schülers';


$string['spellcheck_prompt'] = 'Gib den Text ohne strukturelle Änderung 1:1 wieder. Verzichte auf ein Feedback. Aber korrigiere alle Rechtschreibfehler im nachfolgenden Text: ';
16 changes: 7 additions & 9 deletions lang/en/qtype_aitext.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$string['answerfiles'] = 'Answer files';
$string['answertext'] = 'Answer text';
$string['attachmentsoptional'] = 'Attachments are optional';
$string['automatic_spellcheck'] = 'Automatic spellcheck';
$string['cachedef_stringdata'] = 'Cachedef stringdata';
$string['defaultmarksscheme'] = 'Marks scheme';
$string['defaultmarksscheme_setting'] = 'This will be the default marks scheme for new questions. Questions authors should alter this to suit the question.';
Expand All @@ -44,9 +45,9 @@
$string['err_maxwordlimitnegative'] = 'Maximum word limit cannot be a negative number';
$string['err_minwordlimit'] = 'Minimum word limit is enabled but is not set';
$string['err_minwordlimitnegative'] = 'Minimum word limit cannot be a negative number';
$string['err_parammissing'] = 'Invalid parameters. Make sure you have a sample answer and prompt';
$string['err_retrievingfeedback'] = 'Error retrieving feedback from the AI tool: {$a}';
$string['err_retrievingtranslation'] = 'Error retrieving translation: {$a}';
$string['err_parammissing'] = 'Invalid parameters. Make sure you have a sample answer and prompt';
$string['formateditor'] = 'HTML editor';
$string['formateditorfilepicker'] = 'HTML editor with file picker';
$string['formatmonospaced'] = 'Plain text, monospaced font';
Expand Down Expand Up @@ -88,8 +89,6 @@
$string['responsefieldlines'] = 'Input box size';
$string['responseformat'] = 'Response format';
$string['responseformat_setting'] = 'The editor the student uses when responding';
$string['responseoptions'] = 'Response options';
$string['responsenotrequired'] = 'Text input is optional';
$string['responseisrequired'] = 'Require the student to enter text';
$string['responsenotrequired'] = 'Text input is optional';
$string['responseoptions'] = 'Response options';
Expand All @@ -101,15 +100,14 @@
$string['sampleanswerempty'] = 'Make sure that you have an AI prompt and sample answer before testing.';
$string['sampleanswerevaluate'] = 'Evaluate Sample Answer';
$string['showprompt'] = 'Show prompt';
$string['spellcheck_editor_desc'] = 'This is the text in which the spelling mistakes have been corrected by AI. You can edit this suggested correction.';
$string['spellcheck_prompt'] = 'Reproduce the text 1:1. Give no feedback!. But correct all spelling mistakes in the following text: ';
$string['spellcheck_student_anser_desc'] = 'This is the original student\'s answer';
$string['spellcheckedit'] = 'Edit spellcheck';
$string['spellcheckeditor'] = 'Edit the ai based spellcheck';
$string['thedefaultmarksscheme'] = 'Deduct a point from the total score for each grammar or spelling mistake.';
$string['thedefaultprompt'] = 'Explain if there is anything wrong with the grammar and spelling in the text.';
$string['untestedquestionbehaviour'] = 'Untested question behaviour';
$string['wordcount'] = 'Word count: {$a}';
$string['wordcounttoofew'] = 'Word count: {$a->count}, less than the required {$a->limit} words.';
$string['wordcounttoomuch'] = 'Word count: {$a->count}, more than the limit of {$a->limit} words.';
$string['automatic_spellcheck'] = 'Automatic spellcheck';
$string['spellcheck_prompt'] = 'Reproduce the text 1:1. Give no feedback!. But correct all spelling mistakes in the following text: ';
$string['spellcheckedit'] = 'Edit spellcheck';
$string['spellcheckeditor'] = 'Edit the ai based spellcheck';
$string['spellcheck_editor_desc'] = 'This is the text in which the spelling mistakes have been corrected by AI. You can edit this suggested correction.';
$string['spellcheck_student_anser_desc'] = 'This is the original student\'s answer';
5 changes: 2 additions & 3 deletions question.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function apply_attempt_state(question_attempt_step $step) {
* @throws dml_exception
* @throws moodle_exception
*/
private function get_spellchecking(array $response):string {
private function get_spellchecking(array $response): string {
$fullaiprompt = $this->build_full_ai_spellchecking_prompt($response['answer']);
$ai = new local_ai_manager\manager('feedback');
$llmresponse = $ai->perform_request($fullaiprompt, ['component' => 'qtype_aitext', 'contextid' => $this->contextid]);
Expand All @@ -178,7 +178,7 @@ private function get_spellchecking(array $response):string {
*/
public function grade_response(array $response): array {

if($this->spellcheck) {
if ($this->spellcheck) {
$spellcheckresponse = $this->get_spellchecking($response);
$this->insert_attempt_step_data('-spellcheckresponse', $spellcheckresponse);
}
Expand Down Expand Up @@ -256,7 +256,6 @@ public function build_full_ai_prompt($response, $aiprompt, $defaultmark, $marksc
* @throws coding_exception
*/
public function build_full_ai_spellchecking_prompt(string $response): string {
// $response = strip_tags($response);
return get_string('spellcheck_prompt', 'qtype_aitext') . ($response);
}

Expand Down
4 changes: 4 additions & 0 deletions questiontype.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ protected function export_errorcmid($cmid) {
return '';
}

/**
* Decide the menu based on the menu name and if tenant is allowed
* @return mixed
*/
public function menu_name() {
$tenant = \core\di::get(\local_ai_manager\local\tenant::class);
return $tenant->is_tenant_allowed() ? parent::menu_name() : '';
Expand Down
2 changes: 1 addition & 1 deletion tests/question_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* Unit tests for the matching question definition class.
*
* @package qtype_aitext
* @author Marcus Green 2024
* @copyright 2024 Marcus Green
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class question_test extends \advanced_testcase {
Expand Down
2 changes: 2 additions & 0 deletions tests/question_type_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ final class question_type_test extends \advanced_testcase {
protected $qtype;

protected function setUp(): void {
parent::setUp();
$this->qtype = new qtype_aitext();
}

protected function tearDown(): void {
parent::tearDown();
$this->qtype = null;
}

Expand Down

0 comments on commit 7c08952

Please sign in to comment.