UNIMOODLE / moodle-mod_hybridteaching

P1
Other
1 stars 0 forks source link

Hybridteaching API method hybridteaching_set_attendance_log doesn't create new log. #133

Open juacas opened 1 month ago

juacas commented 1 month ago

Scenario

Integrating Hybridteaching with another plugin using public methods of HybridTeaching.

Trying to manually register a new log for a user in an existent session.

Error

Calling this public function with parameters:

https://github.com/UNIMOODLE/moodle-mod_hybridteaching/blob/6df1b00d5e8ebc9351f8a1249053b367e23f91ba/classes/controller/attendance_controller.php#L385

hybridteaching:

{
    "id": "5",
    "course": "28",
    "name": "hybrid teaching test",
    "intro": "<p dir=\"ltr\" style=\"text-align: left;\">test<\/p>",
    "introformat": "1",
    "useattendance": "1",
    "usevideoconference": "0",
    "userecordvc": "0",
    "typevc": "",
    "config": "0",
    "sessionscheduling": "1",
    "reusesession": "0",
    "starttime": "0",
    "duration": "0",
    "timezone": null,
    "grade": "100",
    "maxgradeattendance": "0",
    "maxgradeattendancemode": "1",
    "participants": "[{\"selectiontype\":\"all\",\"selectionid\":\"all\",\"role\":\"viewer\"},{\"selectiontype\":\"user\",\"selectionid\":\"2\",\"role\":\"moderator\"}]",
    "waitmoderator": "0",
    "advanceentrycount": "0",
    "advanceentryunit": "1",
    "closedoorscount": "0",
    "closedoorsunit": "1",
    "userslimit": "0",
    "wellcomemessage": "0",
    "graceperiod": "0",
    "graceperiodunit": "1",
    "disablecam": "0",
    "disablemic": "0",
    "disableprivatechat": "0",
    "disablepublicchat": "0",
    "disablenote": "0",
    "hideuserlist": "0",
    "blockroomdesign": "0",
    "ignorelocksettings": "0",
    "initialrecord": "0",
    "hiderecordbutton": "0",
    "showpreviewrecord": "0",
    "downloadrecords": "0",
    "validateattendance": "0",
    "attendanceunit": "1",
    "completionattendance": "0",
    "useqr": "1",
    "rotateqr": "1",
    "rotateqrsecret": "Hv0VvItd",
    "studentpassword": "text",
    "usercreator": null,
    "timecreated": "1722514089",
    "timemodified": null
}

Session:

{
    " id ": " 36 ",
    " hybridteachingid ": " 5 ",
    " name ": " test hybrid 1 ",
    " description ": " < p dir =  \ " ltr \ " style=\"text-align: left;\">Ejemplo<\/p>",
    "descriptionformat": "1",
    "groupid": "0",
    "starttime": "1722859800",
    "duration": "7311",
    "sessionfiles": "455829117",
    "typevc": "",
    "userecordvc": "0",
    "vcreference": null,
    "processedrecording": null,
    "storagereference": null,
    "visiblerecord": "1",
    "visiblechat": "1",
    "visibleatt": "1",
    "isfinished": "1",
    "attexempt": "0",
    "caleventid": "2058",
    "visible": "1",
    "timecreated": "1722514286",
    "timemodified": "1722867001",
    "createdby": "2",
    "modifiedby": "2"
}

action: 1 userid: 4 (User enrolled in the course) event = true

Generates an error:

{
    "errorcode": "codingerror",
    "module": "debug",
    "a": "Invalid database query parameter value",
    "link": "",
    "debuginfo": "Objects are are not allowed: stdClass"
}

Problem 1: $session parameter is declared as object but used as int in query https://github.com/UNIMOODLE/moodle-mod_hybridteaching/blob/6df1b00d5e8ebc9351f8a1249053b367e23f91ba/classes/controller/attendance_controller.php#L400

Problem 2: Type of $session is \stdClass, not object.

Expected behaviour: Calling this method should register a new attendance log for this user in this session.

Patching the code with:

$sessiontime = $DB->get_record('hybridteaching_session', ['id' => $session->id], 'starttime, duration');

The method doesn't raise errors but no attendance logs are recorded.

juacas commented 1 month ago

What's the way of registering a manual attendance log?

What do atttype codes mean in attendance methods?

Please, document it.