Skip to content

Commit

Permalink
Improve report print essay question pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavobazzo committed May 3, 2024
1 parent 303521d commit 4cc967d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
24 changes: 19 additions & 5 deletions src/classes/PersistCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -703,16 +703,20 @@ public function reportQuizEssayAnswers($courseId, $cmId, $groupId, $studentId, $

$query = "select ". $this->sql_uniqueid() ." uniqueId, t1.id course_id, t1.shortname course_name, t2.id cmid, t3.id quiz_id,
t3.name quiz_name, t6.id user_id, t6.firstname first_name, t6.lastname last_name, ". $this->mysqlConn->sql_concat('t6.firstname', "' '", 't6.lastname')." fullname,
t6.email, t5_2.value as answer, t5_1.timecreated as answer_timestamp, t4.attempt
t6.email, t4.attempt,
(select concat(t5_2.value,'#SEP#', t5_1.timecreated) from
mdl_question_attempts t5
inner join mdl_question_attempt_steps t5_1 on t5.id = t5_1.questionattemptid
inner join mdl_question_attempt_step_data t5_2 on t5_1.id = t5_2.attemptstepid and t5_2.name = 'answer'
inner join mdl_qtype_essay_options as t5_3 on t5.questionid = t5_3.questionid
where t5.questionusageid = t4.uniqueid
order by t5_1.sequencenumber desc limit 1
) serialanswer
from {course} t1
inner join {course_modules} t2 on t1.id= t2.course
inner join {modules} t2_1 on t2.module = t2_1.id
inner join {quiz} t3 on t2.instance = t3.id
inner join {quiz_attempts} t4 on t4.quiz = t3.id
inner join {question_attempts} t5 on t4.uniqueid = t5.questionusageid
inner join {question_attempt_steps} t5_1 on t5.id = t5_1.questionattemptid
inner join {question_attempt_step_data} t5_2 on t5_1.id = t5_2.attemptstepid and t5_2.name = 'answer'
inner join {question} t5_3 on t5.questionid = t5_3.id and t5_3.qtype in ('essay', 'essayautograde')
inner join {user} t6 on t4.userid = t6.id and t6.deleted = 0 and t6.suspended = 0
left join {groups_members} t6_1 on t6.id = t6_1.userid
left join {groups} t6_2 on t6_1.groupid = t6_2.id
Expand All @@ -729,6 +733,16 @@ public function reportQuizEssayAnswers($courseId, $cmId, $groupId, $studentId, $

foreach($tmp as $item){
//$output = preg_replace('/\s\s+/',' ',$input);
$item->answer = '';
$item->answerTimestamp = '';

$answer = explode('#SEP#', $item->serialanswer);
if(count($answer) == 2){
$item->answer = $answer[0];
$item->answerTimestamp = $answer[1];
}
unset($item->serialanswer);

$answer = html_entity_decode($item->answer);
$answer = strip_tags($item->answer);
$item->nbWords = str_word_count($answer);
Expand Down
2 changes: 1 addition & 1 deletion src/react/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/react/build/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recit_dashboard",
"version": "1.18.0-stable",
"version": "1.18.2-stable",
"description": "RÉCIT Dashboard",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024020501; // The current module version (Date: YYYYMMDDXX)
$plugin->release = 'v1.18.0-stable';
$plugin->release = 'v1.18.2-stable';
$plugin->supported = [39, 401]; // Moodle 3.9.x, 3.10.x and 3.11.x are supported.
$plugin->requires = 2020061500.00; // Moodle 3.9.0
$plugin->component = 'local_recitdashboard'; // Full name of the plugin (used for diagnostics)
Expand Down
2 changes: 1 addition & 1 deletion src/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function display(){
if ($this->hasAccess()){
echo sprintf("<div id='recit_dashboard' data-student-id='%ld' data-course-id='%ld'></div>", $studentId, $selectedCourseId);
}else{
print_error('accessdenied', 'admin');
throw new \moodle_exception('accessdenied', 'admin');
}
}

Expand Down

0 comments on commit 4cc967d

Please sign in to comment.