+# V 0.3.9 Snaketext-Prüfung
+
+## Added
+- TextProcessor: neu: wordStatistics()
+- TaskController: neu: checkSnakeText()
+
+## Changed
+- PageController: Redirect von Create nach Edit
+
# V 0.3.8 Design
## Added
);
return $rc;
}
+ public static function wordStatistics(string $text): array{
+ $rc = [];
+ $max = strlen($text) - 1;
+ $match = null;
+ while($text !== ''){
+ if (preg_match('/^\s+/', $text, $match)){
+ $text = substr($text, strlen($match[0]));
+ continue;
+ }
+ if (preg_match('/^([äöüÄÖÜß\w]+[*:][iI][äöüÄÖÜ\w]+|[äöüÄÖÜß\w]+|[:.,;?-])/', $text, $match)){
+ $word = $match[1];
+ $text = substr($text, strlen($word));
+ } else {
+ $word = $text[0];
+ $text = substr($text, 1);
+ }
+ if (array_key_exists($word, $rc)){
+ $rc[$word]++;
+ } else {
+ $rc[$word] = 1;
+ }
+ }
+ return $rc;
+ }
}
$validated['info'] = strip_tags($validated['info']);
$validated['owner_id'] = $fields['owner_id'];
$validated['contents'] = MediaWiki::expandStarItems($validated['contents']);
- Page::create($validated);
+ $page = Page::create($validated);
+ if ($page != null){
+ $rc = redirect("/page-edit/$page->id");
+ }
}
}
if ($rc == null) {
$rc->pageId = $pageId;
return $rc;
}
+ private function checkSnakeText($solution, $original): int{
+ $solutionWords = TextProcessor::wordStatistics($solution);
+ $originalWords = TextProcessor::wordStatistics($original);
+ $rc = 0;
+ foreach ($originalWords as $key => $count){
+ if (! array_key_exists($key, $solutionWords)){
+ $rc += $count;
+ } elseif ($count != ($count2 = $solutionWords[$key])){
+ $rc += abs($count - $count2);
+ }
+ }
+ return $rc;
+ }
public function create(Request $request)
{
$rc = null;
}
}
if ($request->btnSubmit === 'btnCheck') {
- $fields['message'] = __('I found 3 errors.');
+ $errors = $this->checkSnakeText($fields['solution'], $page->contents);
+ $fields['message'] = __('I found :n error(s)', ['n' => $errors]);
}
if ($request->btnSubmit === 'btnStore') {
$note->update(['body' => $fields['solution']]);
"Group": "Gruppe",
"Groups": "Gruppen",
"Hello": "Hallo",
+ "I found :n error(s)": "Ich habe :n Fehler gefunden",
"Id": "Id",
"Imprint": "Impressum",
"Info": "Info",
"Reference": "Referenz",
"Remain signed in": "Angemeldet bleiben",
"Repetition": "Wiederholung",
+ "Responsibility changed": "Verantwortung ge\u00e4ndert",
"Role": "Rolle",
"Roles": "Rollen",
"Scope": "Bereich",
"Text": "Text",
"The provided credentials do not match our records.": "EMail und Passwort passen nicht zu den gespeicherten Daten.",
"The repetion field is required.": "Das Feld Wiederholung ist notwendig",
+ "The responsibility has been transferred to you": "Die Verantwortung einer Notiz wurde auf dich \u00fcbertragen",
"The search criteria select %d out of %d data records.": "Die Suchkriterien w\u00e4hlen %d von %d Datens\u00e4tzen aus.",
"The search criterion selects %d out of %d data records.": "Das Suchkriterium w\u00e4hlt %d von %d Datens\u00e4tzen aus.",
"Title": "Titel",
.lkn-text {
color: black;
background-color: white;
- border: 0.15rem solid #143F4E;
+ border: 0.15rem solid #607375;
}
/* Links */
.lkn-header-frame
{
background-color: #c2b0a8;
- border: 0.2rem solid #143F4E;
+ border: 0.15rem solid #607375;
}
.lkn-pagination-block
{
"free text": "Freier Text",
"Genus": "Geschlecht",
"grammar rules": "Grammatikregeln",
+"I found :n error(s)": "Ich habe :n Fehler gefunden",
"masculine": "Maskulinum",
"neuter": "Neutrum",
"Not verified": "Nicht überprüft",
{|
|-
+| a
|}
+ ||
U+x2B50;
\ No newline at end of file