]> gitweb.hamatoma.de Git - gadeku.git/commitdiff
V 0.3.9 Snaketext-Prüfung
authorHamatoma <author@hamatoma.de>
Mon, 20 May 2024 18:04:33 +0000 (20:04 +0200)
committerHamatoma <author@hamatoma.de>
Mon, 20 May 2024 18:04:33 +0000 (20:04 +0200)
- TextProcessor: neu: wordStatistics()
- TaskController: neu: checkSnakeText()

- PageController: Redirect von Create nach Edit

CHANGELOG.md
app/Helpers/TextProcessor.php
app/Http/Controllers/PageController.php
app/Http/Controllers/TaskController.php
lang/de_DE.json
public/css/purple.css
resources/lang/sources/gadeku.de.json
tests/abrevations.txt

index 29895132e22a811a0e37346fa2205cb11d5aee2f..9c11774432e1d8850f20013f9c5f6a034bea823c 100644 (file)
@@ -1,3 +1,12 @@
+# 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
index fe634ec29e9e14e5e0d6600488812cbe0ab9160d..74a0569b531faa7962bc63a99c52bd934e6ae974 100644 (file)
@@ -28,4 +28,28 @@ class TextProcessor
         );
         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;
+    }
 }
index fc0dfbf785bb5b1f727d6d71dbe76636e9c0e3f2..f024ab5a04f4261b3b66e48d7c92d5ed2a73d712 100644 (file)
@@ -348,7 +348,10 @@ LEFT JOIN sproperties t4 ON t4.id=t0.owner_id
                 $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) {
index 7a80d682a66c74d99ae71d51111e9fa63295b135..5b8db955234ca30672941bfcf523fbb27f6eed57 100644 (file)
@@ -33,6 +33,19 @@ class TaskController extends Controller
         $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;
@@ -100,7 +113,8 @@ class TaskController extends Controller
                 }
             }
             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']]);
index fe32dfb3779938a31e3b27b5397972a5b6b5aebe..b4036f512357b4fae4ce29fa2defdc5ccb58bf38 100644 (file)
@@ -79,6 +79,7 @@
     "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",
index e881b3330e8e17f09d7b55fa70c1edeaa7cc4fb0..84d4cbf8295207f7019f56f18ebe1d7d9218e334 100644 (file)
@@ -9,7 +9,7 @@ h4{ color: #9D8C84 ; border-bottom: solid 0.1rem #9D8C84; }
 .lkn-text { 
     color: black;
     background-color: white;
-    border: 0.15rem solid #143F4E;
+    border: 0.15rem solid #607375;
 }
 /* Links */
 
@@ -29,7 +29,7 @@ h4{ color: #9D8C84 ; border-bottom: solid 0.1rem #9D8C84; }
 .lkn-header-frame
 {
     background-color: #c2b0a8;
-    border: 0.2rem solid #143F4E;
+    border: 0.15rem solid #607375;
 }
 .lkn-pagination-block
 {
index 1ef245873c07895fd632f299ca9e1c0988a29f4c..58eb867683f259aaee12e8fe43c7444e568d359e 100644 (file)
@@ -20,6 +20,7 @@
 "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",
index 17f97f10a1a8a275fe70975221cdf0166d1d41b9..ac1b5f9e8948707b7a5d9c6e4da4199cb7b2e7be 100644 (file)
@@ -4,6 +4,8 @@
 
 {|
 |-
+| a
 |}
+ || 
 
 U+x2B50;
\ No newline at end of file