Skip to content

Commit

Permalink
Fix count nb words on report essay questions
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavobazzo committed May 9, 2024
1 parent 19d52ba commit 742fd3b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/classes/PersistCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,15 @@ public function reportQuizEssayAnswers($courseId, $cmId, $groupId, $studentId, $
//$output = preg_replace('/\s\s+/',' ',$input);

$answer = html_entity_decode($item->answer);
$answer = strip_tags($item->answer);
$item->nbWords = str_word_count($answer);
$answer = str_replace( '<', ' <', $item->answer );
$answer = str_replace( '-', '', $item->answer );
$answer = strip_tags( $answer );
//$item->nbWords = str_word_count($answer);
$item->nbWords = preg_match_all('/\pL+[^\']/u', $answer, $matches);

/*echo "<pre>";
var_dump($matches);
die();*/

if($onlyLastTry){
if(!isset($result[$item->userId])){
Expand Down

0 comments on commit 742fd3b

Please sign in to comment.