Server Handbook live check: run log
------------------------------------------------------------------------------
Tool https://serverhandbook.com/tools/moodle-report-charts
Check scripts/live/checks/tool-moodle-report-charts.mjs (sha256 955e72b358663f0c760f94d335f729c4436a39a6a05b85d84fc6d6b61e5effa1)
Ran at 2026-12-05T10:05:13Z (432 s)
Result PASS, all 26 claims held
Tested on
System Ubuntu 24.04.5 LTS
Kernel 6.8.0-151-generic
Package nginx 1.24.0-2ubuntu7.21
Package php-fpm 2:8.3+93ubuntu2
Package postgresql-17 17.12-1.pgdg24.04+1
Package moodle 5.3.1
Setup A fresh Ubuntu 24.04 server (4 GB of memory) with Moodle 5.3.1 installed as lesson 1 of the Moodle course installs it (Nginx, PHP-FPM, PostgreSQL; done by the check before the first step shown; the site name moodle.example.com points to it through an /etc/hosts line, as your DNS would), reached over SSH as a sudo user. A course with six learners, two pages, two graded assignments and course completion was made through Moodle's own APIs before the first step shown.
Every version above was read from the server at run time. Passwords used on the
throwaway test server are shown as [password]. How we test: https://serverhandbook.com/how-we-test
------------------------------------------------------------------------------
What the steps changed on the server (recorded before the first step and after the last)
Packages added (0)
Packages upgraded (0)
Packages removed (0)
Services enabled at boot (0)
Services disabled (0)
Listening sockets opened (0)
Listening sockets closed (0)
Files added in /etc (0)
Files changed in /etc (0)
Files removed from /etc (0)
Disk used on / (includes logs written during the run): +7.5 MB
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Claims (26), each with what the run saw
------------------------------------------------------------------------------
1. ok a bare Ubuntu 24.04 server box (web-server) starts
2. ok the tool refuses an .xlsx, a foreign report and an empty file, and skips each broken row with its reason (local check: all pass)
| PASS logs: read as the logs report, every row counted
| PASS logs: dates read day first, decided from a day over 12
| PASS logs {}: 8 events = Python's 8
| PASS logs {}: per day equals Python
| PASS logs {}: per hour equals Python
| PASS logs {}: per component equals Python
| PASS logs {}: per event name equals Python
| PASS logs {}: top users equal Python
| PASS logs {"component":"System"}: 4 events = Python's 4
| PASS logs {"component":"System"}: per day equals Python
| PASS logs {"component":"System"}: per hour equals Python
| PASS logs {"component":"System"}: per component equals Python
| PASS logs {"component":"System"}: per event name equals Python
| PASS logs {"component":"System"}: top users equal Python
| PASS logs {"from":"2026-11-11","to":"2026-11-13"}: 4 events = Python's 4
| PASS logs {"from":"2026-11-11","to":"2026-11-13"}: per day equals Python
| PASS logs {"from":"2026-11-11","to":"2026-11-13"}: per hour equals Python
| PASS logs {"from":"2026-11-11","to":"2026-11-13"}: per component equals Python
| PASS logs {"from":"2026-11-11","to":"2026-11-13"}: per event name equals Python
| PASS logs {"from":"2026-11-11","to":"2026-11-13"}: top users equal Python
| PASS logs: an empty day (10/11/2026) is shown as 0, labels in the file's day-first order
| PASS logs: the Urdu and Chinese user names survive
| PASS logs: the IP address is never in a chart or the summary
| PASS logs: a month-first file (11/14/26) is read month first and says so
| PASS logs: the site-wide log (Course column first, day without its zero) is read
| PASS grades: read as the grades export, 5 students, 3 items, nothing skipped
| PASS grades: the course total comes first
| PASS grades Course total: graded, sum, no-grade [4,240.25,1] = Python [4,240.25,1]
| PASS grades Course total: the histogram holds every graded student (4)
| PASS grades Quiz: 稻田测验: graded, sum, no-grade [4,22.75,1] = Python [4,22.75,1]
| PASS grades Quiz: 稻田测验: the histogram holds every graded student (4)
| PASS grades Assignment: پانی کا منصوبہ: graded, sum, no-grade [3,217.5,2] = Python [3,217.5,2]
| PASS grades Assignment: پانی کا منصوبہ: the histogram holds every graded student (3)
| PASS grades: course total bands run 0 to 100 (best 94.25), 94.25 in the 90–100 band
| PASS grades: the Chinese item name survives and its top is 10 (best 10.00 in the last band)
| PASS grades: no student name, ID number or email is in a chart or the summary
| PASS grades: a Percentage export ("85.00 %") is read on 0–100
| PASS grades: a Letter export is counted per letter
| PASS completion: read as the completion report, 4 learners, 2 activities, nothing skipped
| PASS completion: per activity and course {"Course complete":[1,3],"稻田测验":[3,1],"پانی کا منصوبہ":[2,2]} = Python {"稻田测验":[3,1],"پانی کا منصوبہ":[2,2],"Course complete":[1,3]}
| PASS completion: the Email address identity column is not taken for a criterion
| PASS completion: a single-column criterion (course grade) is counted by its date
| PASS refused: an empty file
| PASS refused: a binary file (the Excel export)
| PASS refused: an OJS statistics report
| PASS refused: a log downloaded in French
| PASS refused: a grades export with semicolons
| PASS refused: a header with no rows
| PASS skipped and named: a log time Excel rewrote (2026-11-14 21:05)
| PASS skipped and named: a log row with a missing cell
| PASS skipped and named: a log date that does not exist (31/02/26)
| PASS skipped and named: a grade with a decimal comma (8,50)
| PASS skipped and named: a completion status typed by hand ("done")
| PASS skipped and named: a course completion date Excel rewrote (14/11/2026)
|
| all checks pass
3. ok (setup) the site name points to this server
4. ok (setup) Nginx, PHP-FPM and the PHP extensions
5. ok (setup) the PostgreSQL project's repository (Moodle 5.3 needs 17; 24.04 ships 16)
6. ok (setup) PostgreSQL 17
7. ok (setup) role and database moodle
8. ok (setup) Moodle 5.3.1 from git
9. ok (setup) the Composer libraries (vendor/)
10. ok (setup) moodledata
11. ok (setup) max_input_vars = 5000 (the installer needs it)
12. ok (setup) the command-line installer
13. ok (setup) config.php root:www-data 640, the router configured
14. ok (setup) Moodle's cron every minute (www-data)
15. ok (setup) the Nginx server block
16. ok (setup) the login page answers
|
Log in to the site | learn
17. ok (setup) the course, six learners, four activities, course completion and grades made through Moodle’s APIs
| {"course":2,"cm":{"page1":1,"page2":2,"assign1":3,"assign2":4},"learners":["3","4","5","6","7","8"]}
18. ok five learners signed in (303 to their dashboard) and opened the course and its pages (13 × 200)
| 13 200
| 5 303
19. ok the completion task ran ("Scheduled task complete")
| Scheduled task complete: Calculate regular completion data (core\task\completion_regular_task)
20. ok the tables hold the activity: log rows, grades for two assignments and the course total, completions
| logs|91
| component|core|83
| component|mod_page|8
| user|-|9
| user|Admin User|50
| user|Amina Yusuf|8
| user|Kwame Osei|8
| user|Lucía Pérez|4
| user|بلال احمد|8
| user|芳 王|4
| grade|Course total|5|79.2000
| grade|Harden SSH|5|72.7000
| grade|سرور کی حفاظت|4|8.1250
| completed|1|5
| completed|2|3
| completed|3|5
| completed|4|4
| course|3
21. ok the three CSV files downloaded (logs, completion, grades)
| == logs.csv: 91 rows
| Time,"User full name","Affected user","Event context",Component,"Event name",Description,Origin,"IP address"
| "5/12/26, 10:11:22","Lucía Pérez","Lucía Pérez","Page: Read the server checklist",System,"Course activity completion updated","The user with id '7' updated the completion state for the course module with id '1' for the user with id '7'.",web,127.0.0.1
| "5/12/26, 10:11:22","Lucía Pérez","Lucía Pérez","Page: Read the server checklist",System,"Course activity completion updated","The user with id '7' updated the completion state for the course module with id '1' for the user with id '7'.",web,127.0.0.1
| == completion.csv: 6 rows
| ID,Name,"Email address","Read the server checklist","Read the server checklist - Completion date",服务器入门,"服务器入门 - Completion date","Harden SSH","Harden SSH - Completion date","سرور کی حفاظت","سرور کی حفاظت - Completion date","Course complete"
| 8,"Tom Becker",learner6@example.com,"Not completed",,"Not completed",,"Not completed",,"Not completed",,
| 4,"Kwame Osei",learner2@example.com,Completed,"2026-12-05 10:11:20",Completed,"2026-12-05 10:11:20",Completed,"2026-12-05 10:11:00",Completed,"2026-12-05 10:11:01","2026-12-05 10:11:20"
| == grades.csv: 6 rows
| "First name","Last name","ID number",Institution,Department,"Email address","Assignment: Harden SSH (Real)","Assignment: سرور کی حفاظت (Real)","Course total (Real)","Last downloaded from this course"
| Tom,Becker,,,,learner6@example.com,-,-,-,1796465499
| Kwame,Osei,,,,learner2@example.com,78.50,7.50,86.00,1796465499
22. ok the tool reads the three as logs, grades and completion, every row counted, none skipped
| logs {"kind": "logs", "dataRows": 91, "events": 91, "skipped": [], "order": "dmy", "byComponent": {"Page": 8, "System": 83}, "byEvent": {"Course activity completion updated": 25, "Course completed": 3, "Course created": 1, "Course module created": 4, "Course module viewed": 8, "Course section created": 3, "Course viewed": 5, "Enrolment instance created": 3, "Grade item created": 3, "Grade item updated": 6, "Role assigned": 6, "User enrolled in course": 6, "User graded": 18}, "byUser": {"(no user: not logged in or the system)": 9, "Admin User": 50, "Amina Yusuf": 8, "Kwame Osei": 8, "Lucía Pérez": 4, "بلال احمد": 8, "芳 王": 4}, "days": {"2026-12-05": 91}}
| grades {"kind": "grades", "students": 6, "dataRows": 6, "skipped": [], "items": [{"name": "Course total", "display": "Real", "graded": 5, "noGrade": 1, "mean": 79.2, "median": 86, "min": 41, "max": 101, "values": [86, 41, 101, 74, 94]}, {"name": "Assignment: Harden SSH", "display": "Real", "graded": 5, "noGrade": 1, "mean": 72.7, "median": 78.5, "min": 41, "max": 92, "values": [78.5, 41, 92, 64, 88]}, {"name": "Assignment: سرور کی حفاظت", "display": "Real", "graded": 4, "noGrade": 2, "mean": 8.125, "median": 8.25, "min": 6, "max": 10, "values": [7.5, 9, 10, 6]}]}
| completion {"kind": "completion", "learners": 6, "dataRows": 6, "skipped": [], "criteria": [{"name": "Read the server checklist", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "服务器入门", "activity": true, "done": 3, "notDone": 3, "bad": 0}, {"name": "Harden SSH", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "سرور کی حفاظت", "activity": true, "done": 4, "notDone": 2, "bad": 0}], "course": {"name": "Course complete", "activity": false, "done": 3, "notDone": 3, "bad": 0}}
23. ok logs: the tool’s rows, per component (Page = mod_page, System = core) and per user equal logstore_standard_log
| logs {"kind": "logs", "dataRows": 91, "events": 91, "skipped": [], "order": "dmy", "byComponent": {"Page": 8, "System": 83}, "byEvent": {"Course activity completion updated": 25, "Course completed": 3, "Course created": 1, "Course module created": 4, "Course module viewed": 8, "Course section created": 3, "Course viewed": 5, "Enrolment instance created": 3, "Grade item created": 3, "Grade item updated": 6, "Role assigned": 6, "User enrolled in course": 6, "User graded": 18}, "byUser": {"(no user: not logged in or the system)": 9, "Admin User": 50, "Amina Yusuf": 8, "Kwame Osei": 8, "Lucía Pérez": 4, "بلال احمد": 8, "芳 王": 4}, "days": {"2026-12-05": 91}}
| grades {"kind": "grades", "students": 6, "dataRows": 6, "skipped": [], "items": [{"name": "Course total", "display": "Real", "graded": 5, "noGrade": 1, "mean": 79.2, "median": 86, "min": 41, "max": 101, "values": [86, 41, 101, 74, 94]}, {"name": "Assignment: Harden SSH", "display": "Real", "graded": 5, "noGrade": 1, "mean": 72.7, "median": 78.5, "min": 41, "max": 92, "values": [78.5, 41, 92, 64, 88]}, {"name": "Assignment: سرور کی حفاظت", "display": "Real", "graded": 4, "noGrade": 2, "mean": 8.125, "median": 8.25, "min": 6, "max": 10, "values": [7.5, 9, 10, 6]}]}
| completion {"kind": "completion", "learners": 6, "dataRows": 6, "skipped": [], "criteria": [{"name": "Read the server checklist", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "服务器入门", "activity": true, "done": 3, "notDone": 3, "bad": 0}, {"name": "Harden SSH", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "سرور کی حفاظت", "activity": true, "done": 4, "notDone": 2, "bad": 0}], "course": {"name": "Course complete", "activity": false, "done": 3, "notDone": 3, "bad": 0}}
| logs|91
| component|core|83
| component|mod_page|8
| user|-|9
| user|Admin User|50
| user|Amina Yusuf|8
| user|Kwame Osei|8
| user|Lucía Pérez|4
| user|بلال احمد|8
| user|芳 王|4
| grade|Course total|5|79.2000
| grade|Harden SSH|5|72.7000
| grade|سرور کی حفاظت|4|8.1250
| completed|1|5
| completed|2|3
| completed|3|5
| completed|4|4
| course|3
24. ok grades: graded learners and the mean of each item, the course total included, equal grade_grades
| logs {"kind": "logs", "dataRows": 91, "events": 91, "skipped": [], "order": "dmy", "byComponent": {"Page": 8, "System": 83}, "byEvent": {"Course activity completion updated": 25, "Course completed": 3, "Course created": 1, "Course module created": 4, "Course module viewed": 8, "Course section created": 3, "Course viewed": 5, "Enrolment instance created": 3, "Grade item created": 3, "Grade item updated": 6, "Role assigned": 6, "User enrolled in course": 6, "User graded": 18}, "byUser": {"(no user: not logged in or the system)": 9, "Admin User": 50, "Amina Yusuf": 8, "Kwame Osei": 8, "Lucía Pérez": 4, "بلال احمد": 8, "芳 王": 4}, "days": {"2026-12-05": 91}}
| grades {"kind": "grades", "students": 6, "dataRows": 6, "skipped": [], "items": [{"name": "Course total", "display": "Real", "graded": 5, "noGrade": 1, "mean": 79.2, "median": 86, "min": 41, "max": 101, "values": [86, 41, 101, 74, 94]}, {"name": "Assignment: Harden SSH", "display": "Real", "graded": 5, "noGrade": 1, "mean": 72.7, "median": 78.5, "min": 41, "max": 92, "values": [78.5, 41, 92, 64, 88]}, {"name": "Assignment: سرور کی حفاظت", "display": "Real", "graded": 4, "noGrade": 2, "mean": 8.125, "median": 8.25, "min": 6, "max": 10, "values": [7.5, 9, 10, 6]}]}
| completion {"kind": "completion", "learners": 6, "dataRows": 6, "skipped": [], "criteria": [{"name": "Read the server checklist", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "服务器入门", "activity": true, "done": 3, "notDone": 3, "bad": 0}, {"name": "Harden SSH", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "سرور کی حفاظت", "activity": true, "done": 4, "notDone": 2, "bad": 0}], "course": {"name": "Course complete", "activity": false, "done": 3, "notDone": 3, "bad": 0}}
| [{"name":"Course total","n":5,"avg":79.2},{"name":"Harden SSH","n":5,"avg":72.7},{"name":"سرور کی حفاظت","n":4,"avg":8.125}]
25. ok completion: completed per activity (Urdu and Chinese names too) and the course, equal Moodle’s completion tables
| logs {"kind": "logs", "dataRows": 91, "events": 91, "skipped": [], "order": "dmy", "byComponent": {"Page": 8, "System": 83}, "byEvent": {"Course activity completion updated": 25, "Course completed": 3, "Course created": 1, "Course module created": 4, "Course module viewed": 8, "Course section created": 3, "Course viewed": 5, "Enrolment instance created": 3, "Grade item created": 3, "Grade item updated": 6, "Role assigned": 6, "User enrolled in course": 6, "User graded": 18}, "byUser": {"(no user: not logged in or the system)": 9, "Admin User": 50, "Amina Yusuf": 8, "Kwame Osei": 8, "Lucía Pérez": 4, "بلال احمد": 8, "芳 王": 4}, "days": {"2026-12-05": 91}}
| grades {"kind": "grades", "students": 6, "dataRows": 6, "skipped": [], "items": [{"name": "Course total", "display": "Real", "graded": 5, "noGrade": 1, "mean": 79.2, "median": 86, "min": 41, "max": 101, "values": [86, 41, 101, 74, 94]}, {"name": "Assignment: Harden SSH", "display": "Real", "graded": 5, "noGrade": 1, "mean": 72.7, "median": 78.5, "min": 41, "max": 92, "values": [78.5, 41, 92, 64, 88]}, {"name": "Assignment: سرور کی حفاظت", "display": "Real", "graded": 4, "noGrade": 2, "mean": 8.125, "median": 8.25, "min": 6, "max": 10, "values": [7.5, 9, 10, 6]}]}
| completion {"kind": "completion", "learners": 6, "dataRows": 6, "skipped": [], "criteria": [{"name": "Read the server checklist", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "服务器入门", "activity": true, "done": 3, "notDone": 3, "bad": 0}, {"name": "Harden SSH", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "سرور کی حفاظت", "activity": true, "done": 4, "notDone": 2, "bad": 0}], "course": {"name": "Course complete", "activity": false, "done": 3, "notDone": 3, "bad": 0}}
| {"1":5,"2":3,"3":5,"4":4} course 3
26. ok (tested on) the box reports its OS, kernel and the version of 4 package(s)
| PRETTY_NAME="Ubuntu 24.04.5 LTS"
| VIRT=none
| KERNEL=6.8.0-151-generic
| PKG nginx 1.24.0-2ubuntu7.21
| PKG php-fpm 2:8.3+93ubuntu2
| PKG postgresql-17 17.12-1.pgdg24.04+1
| moodle: $release = '5.3.1 (Build: 20261112)'; // Human-friendly version name
------------------------------------------------------------------------------
Commands and what they printed (5)
------------------------------------------------------------------------------
$ login() {
$ rm -f $3; T=$(curl -s -c $3 -b $3 http://moodle.example.com/login/index.php | grep -oP 'name="logintoken" value="\K[^"]+')
$ curl -s -c $3 -b $3 -o /dev/null -w '%{http_code}\n' --data-urlencode logintoken=$T --data-urlencode username=$1 --data-urlencode password=$2 http://moodle.example.com/login/index.php
$ }
$ for n in 1 2 3 4 5; do
$ login learner$n '[password]' /tmp/l$n
$ curl -s -b /tmp/l$n -o /dev/null -w '%{http_code}\n' 'http://moodle.example.com/course/view.php?id=2'
$ curl -s -b /tmp/l$n -o /dev/null -w '%{http_code}\n' 'http://moodle.example.com/mod/page/view.php?id=1'
$ if [ $n -le 3 ]; then curl -s -b /tmp/l$n -o /dev/null -w '%{http_code}\n' 'http://moodle.example.com/mod/page/view.php?id=2'; fi
$ done | sort | uniq -c
13 200
5 303
$ cd /var/www/moodle && sudo -u www-data php admin/cli/scheduled_task.php --execute='\core\task\completion_regular_task' 2>&1 | tail -n 1
Scheduled task complete: Calculate regular completion data (core\task\completion_regular_task)
$ sudo -u postgres psql -d moodle -At -F '|' -c "SELECT 'logs', count(*) FROM mdl_logstore_standard_log WHERE courseid = 2"
$ sudo -u postgres psql -d moodle -At -F '|' -c "SELECT 'component', component, count(*) FROM mdl_logstore_standard_log WHERE courseid = 2 GROUP BY component ORDER BY 2"
$ sudo -u postgres psql -d moodle -At -F '|' -c "SELECT 'user', CASE WHEN u.id IS NULL THEN '-' ELSE u.firstname || ' ' || u.lastname END, count(*) FROM mdl_logstore_standard_log l LEFT JOIN mdl_user u ON u.id = l.userid WHERE l.courseid = 2 GROUP BY 2 ORDER BY 2"
$ sudo -u postgres psql -d moodle -At -F '|' -c "SELECT 'grade', COALESCE(gi.itemname, 'Course total'), count(gg.finalgrade), round(avg(gg.finalgrade), 4) FROM mdl_grade_items gi LEFT JOIN mdl_grade_grades gg ON gg.itemid = gi.id AND gg.finalgrade IS NOT NULL WHERE gi.courseid = 2 GROUP BY gi.id ORDER BY gi.id"
$ sudo -u postgres psql -d moodle -At -F '|' -c "SELECT 'completed', cm.id, count(c.id) FROM mdl_course_modules cm LEFT JOIN mdl_course_modules_completion c ON c.coursemoduleid = cm.id AND c.completionstate > 0 WHERE cm.course = 2 GROUP BY cm.id ORDER BY cm.id"
$ sudo -u postgres psql -d moodle -At -F '|' -c "SELECT 'course', count(*) FROM mdl_course_completions WHERE course = 2 AND timecompleted IS NOT NULL"
logs|91
component|core|83
component|mod_page|8
user|-|9
user|Admin User|50
user|Amina Yusuf|8
user|Kwame Osei|8
user|Lucía Pérez|4
user|بلال احمد|8
user|芳 王|4
grade|Course total|5|79.2000
grade|Harden SSH|5|72.7000
grade|سرور کی حفاظت|4|8.1250
completed|1|5
completed|2|3
completed|3|5
completed|4|4
course|3
$ login() {
$ rm -f $3; T=$(curl -s -c $3 -b $3 http://moodle.example.com/login/index.php | grep -oP 'name="logintoken" value="\K[^"]+')
$ curl -s -c $3 -b $3 -o /dev/null -w '%{http_code}\n' --data-urlencode logintoken=$T --data-urlencode username=$1 --data-urlencode password=$2 http://moodle.example.com/login/index.php
$ }
$ login admin '[password]' /tmp/a > /dev/null
$ mkdir -p /tmp/reports && cd /tmp/reports
$ curl -s -b /tmp/a -o logs.csv 'http://moodle.example.com/report/log/index.php?chooselog=1&id=2&logreader=logstore_standard&download=csv'
$ curl -s -b /tmp/a -o completion.csv 'http://moodle.example.com/report/completion/index.php?course=2&dataformat=csv'
$ F=$(curl -s -b /tmp/a 'http://moodle.example.com/grade/export/txt/index.php?id=2')
$ K=$(echo "$F" | grep -oP 'name="sesskey" type="hidden" value="\K[^"]+' | head -n 1)
$ ITEMS=$(echo "$F" | grep -oP 'name="itemids\[\K\d+' | sort -u | sed 's/.*/-d itemids[&]=1/')
$ curl -s -b /tmp/a -o grades.csv -d id=2 -d sesskey=$K -d _qf__grade_export_form=1 $ITEMS -d export_feedback=0 -d export_onlyactive=1 -d 'display[real]=1' -d decimals=2 -d separator=comma -d submitbutton=Download 'http://moodle.example.com/grade/export/txt/export.php'
$ for f in logs completion grades; do echo "== $f.csv: $(($(wc -l < $f.csv) - 1)) rows"; head -n 3 $f.csv; done
== logs.csv: 91 rows
Time,"User full name","Affected user","Event context",Component,"Event name",Description,Origin,"IP address"
"5/12/26, 10:11:22","Lucía Pérez","Lucía Pérez","Page: Read the server checklist",System,"Course activity completion updated","The user with id '7' updated the completion state for the course module with id '1' for the user with id '7'.",web,127.0.0.1
"5/12/26, 10:11:22","Lucía Pérez","Lucía Pérez","Page: Read the server checklist",System,"Course activity completion updated","The user with id '7' updated the completion state for the course module with id '1' for the user with id '7'.",web,127.0.0.1
== completion.csv: 6 rows
ID,Name,"Email address","Read the server checklist","Read the server checklist - Completion date",服务器入门,"服务器入门 - Completion date","Harden SSH","Harden SSH - Completion date","سرور کی حفاظت","سرور کی حفاظت - Completion date","Course complete"
8,"Tom Becker",learner6@example.com,"Not completed",,"Not completed",,"Not completed",,"Not completed",,
4,"Kwame Osei",learner2@example.com,Completed,"2026-12-05 10:11:20",Completed,"2026-12-05 10:11:20",Completed,"2026-12-05 10:11:00",Completed,"2026-12-05 10:11:01","2026-12-05 10:11:20"
== grades.csv: 6 rows
"First name","Last name","ID number",Institution,Department,"Email address","Assignment: Harden SSH (Real)","Assignment: سرور کی حفاظت (Real)","Course total (Real)","Last downloaded from this course"
Tom,Becker,,,,learner6@example.com,-,-,-,1796465499
Kwame,Osei,,,,learner2@example.com,78.50,7.50,86.00,1796465499
$ echo '{"logs":{"file":"/tmp/moodle-reports-fm3bA4/logs.csv","kind":"logs","dataRows":91,"events":91,"skipped":[],"order":"dmy","byComponent":{"Page":8,"System":83},"byEvent":{"Course activity completion updated":25,"Course completed":3,"Course created":1,"Course module created":4,"Course module viewed":8,"Course section created":3,"Course viewed":5,"Enrolment instance created":3,"Grade item created":3,"Grade item updated":6,"Role assigned":6,"User enrolled in course":6,"User graded":18},"byUser":{"(no user: not logged in or the system)":9,"Admin User":50,"Amina Yusuf":8,"Kwame Osei":8,"Lucía Pérez":4,"بلال احمد":8,"芳 王":4},"days":{"2026-12-05":91}},"grades":{"file":"/tmp/moodle-reports-fm3bA4/grades.csv","kind":"grades","students":6,"dataRows":6,"skipped":[],"items":[{"name":"Course total","display":"Real","graded":5,"noGrade":1,"mean":79.2,"median":86,"min":41,"max":101,"values":[86,41,101,74,94]},{"name":"Assignment: Harden SSH","display":"Real","graded":5,"noGrade":1,"mean":72.7,"median":78.5,"min":41,"max":92,"values":[78.5,41,92,64,88]},{"name":"Assignment: سرور کی حفاظت","display":"Real","graded":4,"noGrade":2,"mean":8.125,"median":8.25,"min":6,"max":10,"values":[7.5,9,10,6]}]},"completion":{"file":"/tmp/moodle-reports-fm3bA4/completion.csv","kind":"completion","learners":6,"dataRows":6,"skipped":[],"criteria":[{"name":"Read the server checklist","activity":true,"done":5,"notDone":1,"bad":0},{"name":"服务器入门","activity":true,"done":3,"notDone":3,"bad":0},{"name":"Harden SSH","activity":true,"done":5,"notDone":1,"bad":0},{"name":"سرور کی حفاظت","activity":true,"done":4,"notDone":2,"bad":0}],"course":{"name":"Course complete","activity":false,"done":3,"notDone":3,"bad":0}}}' | python3 -c "import json,sys; d=json.load(sys.stdin); [print(k, json.dumps({x: v for x, v in r.items() if x not in ('file', 'values')}, ensure_ascii=False)) for k, r in d.items()]"
logs {"kind": "logs", "dataRows": 91, "events": 91, "skipped": [], "order": "dmy", "byComponent": {"Page": 8, "System": 83}, "byEvent": {"Course activity completion updated": 25, "Course completed": 3, "Course created": 1, "Course module created": 4, "Course module viewed": 8, "Course section created": 3, "Course viewed": 5, "Enrolment instance created": 3, "Grade item created": 3, "Grade item updated": 6, "Role assigned": 6, "User enrolled in course": 6, "User graded": 18}, "byUser": {"(no user: not logged in or the system)": 9, "Admin User": 50, "Amina Yusuf": 8, "Kwame Osei": 8, "Lucía Pérez": 4, "بلال احمد": 8, "芳 王": 4}, "days": {"2026-12-05": 91}}
grades {"kind": "grades", "students": 6, "dataRows": 6, "skipped": [], "items": [{"name": "Course total", "display": "Real", "graded": 5, "noGrade": 1, "mean": 79.2, "median": 86, "min": 41, "max": 101, "values": [86, 41, 101, 74, 94]}, {"name": "Assignment: Harden SSH", "display": "Real", "graded": 5, "noGrade": 1, "mean": 72.7, "median": 78.5, "min": 41, "max": 92, "values": [78.5, 41, 92, 64, 88]}, {"name": "Assignment: سرور کی حفاظت", "display": "Real", "graded": 4, "noGrade": 2, "mean": 8.125, "median": 8.25, "min": 6, "max": 10, "values": [7.5, 9, 10, 6]}]}
completion {"kind": "completion", "learners": 6, "dataRows": 6, "skipped": [], "criteria": [{"name": "Read the server checklist", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "服务器入门", "activity": true, "done": 3, "notDone": 3, "bad": 0}, {"name": "Harden SSH", "activity": true, "done": 5, "notDone": 1, "bad": 0}, {"name": "سرور کی حفاظت", "activity": true, "done": 4, "notDone": 2, "bad": 0}], "course": {"name": "Course complete", "activity": false, "done": 3, "notDone": 3, "bad": 0}}
------------------------------------------------------------------------------
The check's source (scripts/live/checks/tool-moodle-report-charts.mjs)
As it ran.
------------------------------------------------------------------------------
/**
* TOOL proof (plan07 §2): /tools/moodle-report-charts. Rented build server (LIVE_VPS + LIVE_VPS_NODOMAIN=1, 4 GB), per
* release. Hidden setup: Moodle as lesson 1 installs it (moodle-base.mjs), then scripts/live/moodle-report-course.php:
* a course with completion, six learners (one Urdu, one Chinese name), two pages and two assignments (one Chinese, one
* Urdu title), course completion on all four, and the teacher's grades, through Moodle's own APIs.
*
* What it proves: learners sign in and open the course and its pages over the web (real log rows, real completion),
* Moodle's completion task runs, and the three reports are downloaded as an admin downloads them: Reports > Logs
* (download=csv), Grade administration > Export > Plain text file (the form posted with its defaults, comma), and
* Reports > Course completion (dataformat=csv). The tool's OWN module (lib/tools/moodle-report-charts/report.ts, through
* scripts/tools/check-moodle-report-charts.ts --read) reads all three with no row skipped, and its counts equal Moodle's
* tables: logstore_standard_log (rows, per component, per user), grade_grades (graded learners and mean per item, the
* course total included), course_modules_completion and course_completions. The tool's refusals run on this computer
* (hidden, its result is a claim).
*/
import { execFileSync } from 'node:child_process'
import { mkdtempSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { bareBox, reportBox } from '../lib.mjs'
import { putFile } from '../box.mjs'
import { basePackages, baseSetup, installMoodle, SITE } from '../moodle-base.mjs'
export const meta = { box: 'vps' }
const RELEASE = process.env.LIVE_BOX_RELEASE || '24.04'
const DB_PASS = '[password]'
const ADMIN_PASS = '[password]'
const LEARNER_PASS = '[password]'
const TOOL = 'scripts/tools/check-moodle-report-charts.ts'
const S = `http://${SITE}`
const PSQL = (sql) => `sudo -u postgres psql -d moodle -At -F '|' -c "${sql}"`
// sign in through the login form (its logintoken), the cookie in $3
const LOGIN = [
'login() {',
` rm -f $3; T=$(curl -s -c $3 -b $3 ${S}/login/index.php | grep -oP 'name="logintoken" value="\\K[^"]+')`,
` curl -s -c $3 -b $3 -o /dev/null -w '%{http_code}\\n' --data-urlencode logintoken=$T --data-urlencode username=$1 --data-urlencode password=$2 ${S}/login/index.php`,
'}',
].join('\n')
const NO_USER = '(no user: not logged in or the system)'
const check = (ctx) =>
bareBox(ctx, async ({ sudoUser }) => {
const sh = sudoUser()
const { run, L } = sh
const local = execFileSync('npx', ['tsx', TOOL], { encoding: 'utf8' })
ctx.check('the tool refuses an .xlsx, a foreign report and an empty file, and skips each broken row with its reason (local check: all pass)', /all checks pass/.test(local) && !/^FAIL/m.test(local), local)
installMoodle(ctx, sh, { release: RELEASE, dbPass: DB_PASS, adminPass: ADMIN_PASS })
ctx.secret(LEARNER_PASS)
if (!putFile('scripts/live/moodle-report-course.php', '/tmp/moodle-report-course.php')) throw new Error('could not copy the course script')
const made = L(`cd /var/www/moodle && sudo -u www-data php /tmp/moodle-report-course.php '${LEARNER_PASS}' 2>&1 | tail -n 1`, 600000)
let ids
try {
ids = JSON.parse(made)
} catch {
ids = undefined
}
if (!ctx.check('(setup) the course, six learners, four activities, course completion and grades made through Moodle’s APIs', Boolean(ids?.course), made)) throw new Error('setup failed: course')
const { course, cm } = ids
// ── the learners: sign in, open the course and its pages ─────────────────────────────
const visits = run(
[
LOGIN,
'for n in 1 2 3 4 5; do',
` login learner$n '${LEARNER_PASS}' /tmp/l$n`,
` curl -s -b /tmp/l$n -o /dev/null -w '%{http_code}\\n' '${S}/course/view.php?id=${course}'`,
` curl -s -b /tmp/l$n -o /dev/null -w '%{http_code}\\n' '${S}/mod/page/view.php?id=${cm.page1}'`,
` if [ $n -le 3 ]; then curl -s -b /tmp/l$n -o /dev/null -w '%{http_code}\\n' '${S}/mod/page/view.php?id=${cm.page2}'; fi`,
'done | sort | uniq -c',
].join('\n'),
{ id: 'learner-visits' },
)
ctx.check('five learners signed in (303 to their dashboard) and opened the course and its pages (13 × 200)', /^\s*5 303$/m.test(visits.out) && /^\s*13 200$/m.test(visits.out), visits.out)
const task = run(`cd /var/www/moodle && sudo -u www-data php admin/cli/scheduled_task.php --execute='\\core\\task\\completion_regular_task' 2>&1 | tail -n 1`, { id: 'completion-task', timeout: 600000 })
ctx.check('the completion task ran ("Scheduled task complete")', /Scheduled task complete/.test(task.out), task.out)
// ── what Moodle's tables say, just before the downloads (each download logs an event of its own) ──
const db = run(
[
PSQL(`SELECT 'logs', count(*) FROM mdl_logstore_standard_log WHERE courseid = ${course}`),
PSQL(`SELECT 'component', component, count(*) FROM mdl_logstore_standard_log WHERE courseid = ${course} GROUP BY component ORDER BY 2`),
PSQL(`SELECT 'user', CASE WHEN u.id IS NULL THEN '-' ELSE u.firstname || ' ' || u.lastname END, count(*) FROM mdl_logstore_standard_log l LEFT JOIN mdl_user u ON u.id = l.userid WHERE l.courseid = ${course} GROUP BY 2 ORDER BY 2`),
PSQL(`SELECT 'grade', COALESCE(gi.itemname, 'Course total'), count(gg.finalgrade), round(avg(gg.finalgrade), 4) FROM mdl_grade_items gi LEFT JOIN mdl_grade_grades gg ON gg.itemid = gi.id AND gg.finalgrade IS NOT NULL WHERE gi.courseid = ${course} GROUP BY gi.id ORDER BY gi.id`),
PSQL(`SELECT 'completed', cm.id, count(c.id) FROM mdl_course_modules cm LEFT JOIN mdl_course_modules_completion c ON c.coursemoduleid = cm.id AND c.completionstate > 0 WHERE cm.course = ${course} GROUP BY cm.id ORDER BY cm.id`),
PSQL(`SELECT 'course', count(*) FROM mdl_course_completions WHERE course = ${course} AND timecompleted IS NOT NULL`),
].join('\n'),
{ id: 'moodle-tables' },
)
const rows = (k) => db.out.split('\n').filter((l) => l.startsWith(`${k}|`)).map((l) => l.split('|').slice(1))
const logTotal = Number(rows('logs')[0]?.[0])
const comps = Object.fromEntries(rows('component').map(([c, n]) => [c, Number(n)]))
const users = Object.fromEntries(rows('user').map(([u, n]) => [u === '-' ? NO_USER : u, Number(n)]))
const grades = rows('grade').map(([name, n, avg]) => ({ name, n: Number(n), avg: Number(avg) }))
const done = Object.fromEntries(rows('completed').map(([id, n]) => [id, Number(n)]))
const courseDone = Number(rows('course')[0]?.[0])
ctx.check('the tables hold the activity: log rows, grades for two assignments and the course total, completions', logTotal > 50 && grades.length === 3 && done[cm.page1] === 5 && done[cm.page2] === 3 && done[cm.assign1] === 5 && done[cm.assign2] === 4 && courseDone === 3, db.out)
// ── the three downloads, as an admin makes them ───────────────────────────────────────
const dl = run(
[
LOGIN,
`login admin '${ADMIN_PASS}' /tmp/a > /dev/null`,
'mkdir -p /tmp/reports && cd /tmp/reports',
`curl -s -b /tmp/a -o logs.csv '${S}/report/log/index.php?chooselog=1&id=${course}&logreader=logstore_standard&download=csv'`,
`curl -s -b /tmp/a -o completion.csv '${S}/report/completion/index.php?course=${course}&dataformat=csv'`,
`F=$(curl -s -b /tmp/a '${S}/grade/export/txt/index.php?id=${course}')`,
`K=$(echo "$F" | grep -oP 'name="sesskey" type="hidden" value="\\K[^"]+' | head -n 1)`,
`ITEMS=$(echo "$F" | grep -oP 'name="itemids\\[\\K\\d+' | sort -u | sed 's/.*/-d itemids[&]=1/')`,
`curl -s -b /tmp/a -o grades.csv -d id=${course} -d sesskey=$K -d _qf__grade_export_form=1 $ITEMS -d export_feedback=0 -d export_onlyactive=1 -d 'display[real]=1' -d decimals=2 -d separator=comma -d submitbutton=Download '${S}/grade/export/txt/export.php'`,
'for f in logs completion grades; do echo "== $f.csv: $(($(wc -l < $f.csv) - 1)) rows"; head -n 3 $f.csv; done',
].join('\n'),
{ id: 'downloads' },
)
ctx.check('the three CSV files downloaded (logs, completion, grades)', (dl.out.match(/^== \w+\.csv: \d+ rows$/gm) ?? []).length === 3, dl.out)
const dir = mkdtempSync(join(tmpdir(), 'moodle-reports-'))
for (const f of ['logs', 'grades', 'completion']) writeFileSync(join(dir, `${f}.csv`), Buffer.from(L(`base64 -w0 /tmp/reports/${f}.csv`).trim(), 'base64'))
const read = Object.fromEntries(
execFileSync('npx', ['tsx', TOOL, ...['logs', 'grades', 'completion'].map((f) => `--read=${join(dir, `${f}.csv`)}`)], { encoding: 'utf8' })
.trim()
.split('\n')
.map((l) => JSON.parse(l))
.map((r) => [r.file.split('/').pop().replace('.csv', ''), r]),
)
const said = run(`echo '${JSON.stringify(read).replaceAll("'", '')}' | python3 -c "import json,sys; d=json.load(sys.stdin); [print(k, json.dumps({x: v for x, v in r.items() if x not in ('file', 'values')}, ensure_ascii=False)) for k, r in d.items()]"`, { id: 'tool-read' })
const { logs, grades: g, completion: c } = read
ctx.check('the tool reads the three as logs, grades and completion, every row counted, none skipped', logs?.kind === 'logs' && g?.kind === 'grades' && c?.kind === 'completion' && !logs.skipped.length && !g.skipped.length && !c.skipped.length, said.out)
ctx.check('logs: the tool’s rows, per component (Page = mod_page, System = core) and per user equal logstore_standard_log', logs?.events === logTotal && logs.byComponent.Page === comps.mod_page && logs.byComponent.System === comps.core && JSON.stringify(Object.entries(logs.byUser).sort()) === JSON.stringify(Object.entries(users).sort()), `${said.out}\n${db.out}`)
const gi = (name) => g?.items.find((it) => it.name === name || it.name.endsWith(`: ${name}`))
ctx.check('grades: graded learners and the mean of each item, the course total included, equal grade_grades', grades.every(({ name, n, avg }) => gi(name)?.graded === n && Math.abs(gi(name).mean - avg) < 0.0001), `${said.out}\n${JSON.stringify(grades)}`)
const crit = (cmid, name) => c?.criteria.find((x) => x.name === name)?.done === done[cmid]
ctx.check('completion: completed per activity (Urdu and Chinese names too) and the course, equal Moodle’s completion tables', crit(cm.page1, 'Read the server checklist') && crit(cm.page2, '服务器入门') && crit(cm.assign1, 'Harden SSH') && crit(cm.assign2, 'سرور کی حفاظت') && c.course.done === courseDone && c.learners === 6, `${said.out}\n${JSON.stringify(done)} course ${courseDone}`)
ctx.stepsDone()
reportBox(ctx, L, `${baseSetup(RELEASE, { memory: '4 GB' })} A course with six learners, two pages, two graded assignments and course completion was made through Moodle's own APIs before the first step shown.`, basePackages(RELEASE).packages, basePackages(RELEASE).extra)
})
export default check