Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better view for comparing right with wrong answers #13

Open
sneakyx opened this issue May 7, 2024 · 0 comments
Open

better view for comparing right with wrong answers #13

sneakyx opened this issue May 7, 2024 · 0 comments
Assignees
Labels
backend this is also backend magic enhancement New feature or request frontend this is also frontend foo

Comments

@sneakyx
Copy link
Owner

sneakyx commented May 7, 2024

At the moment, the users have to look very carefully, what was wrong in their answer.
It the direct comparision is shown, it would be better.
possible Vercomparisionsions
a) show both together, but aligned
b) show a comparision with composer require codedungeon/phpunit-result-printer

use Codedungeon\PHPCliColors\Color;
use Codedungeon\PHPCliColors\Color256;

public function highlightStringDifferences($string1, $string2) {
    // Vergleich der beiden Zeichenketten und Hervorheben der Unterschiede
    $diff = new \Diff\Diff($string1, $string2);
    
    // Erzeuge HTML-Ausgabe der Unterschiede
    $renderer = new \Diff\Renderer\Html\SideBySide;
    $diffOutput = $diff->render($renderer);
    
    return $diffOutput;
}

public function compareStrings() {
    $string1 = "Hello World!";
    $string2 = "Hello PHP!";
    
    // Hervorhebung der Unterschiede
    $highlightedDiff = $this->highlightStringDifferences($string1, $string2);
    
    // Rückgabe der hervorgehobenen Unterschiede an die Ansicht oder wo immer benötigt
    return view('diff_view', compact('highlightedDiff'));
}
@sneakyx sneakyx self-assigned this May 7, 2024
@sneakyx sneakyx added enhancement New feature or request frontend this is also frontend foo backend this is also backend magic labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend this is also backend magic enhancement New feature or request frontend this is also frontend foo
Projects
None yet
Development

No branches or pull requests

1 participant