Skip to content

Conversation

indicozy
Copy link

Since I'm not familiar with PHP, most of the code is AI generated.

I need help to create dev environment and code review.

I want to create wsfunction that issues (if not found) certificate and returns certificate ID as discussed in #712.

However, it's not working properly, more info in the comment below

@indicozy
Copy link
Author

@mdjnelson I created PR for #712, however cURL is not working properly:

curl 'https://moodle.dev/webservice/rest/server.php?wstoken=TOKEN_OF_USER&wsfunction=mod_customcert_get_or_create_certificate&moodlewsrestformat=json&cmid=277' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'origin: http://localhost:5173' \
  -H 'priority: u=1, i' \
  -H 'referer: http://localhost:5173/' \
  -H 'sec-ch-ua: "Not;A=Brand";v="24", "Chromium";v="128"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'

Returns:

{
  "exception": "dml_missing_record_exception",
  "errorcode": "invalidrecordunknown",
  "message": "Не удается найти данную запись в базе данных"
}

I tried to debug it by adding checks and exceptions, however it doesn't change the response's error code. I'm stuck on this stage.

DB info:

INSERT INTO `mdl_course_modules` (`id`, `course`, `module`, `instance`, `section`, `idnumber`, `added`, `score`, `indent`, `visible`, `visibleoncoursepage`, `visibleold`, `groupmode`, `groupingid`, `completion`, `completiongradeitemnumber`, `completionview`, `completionexpected`, `completionpassgrade`, `showdescription`, `availability`, `deletioninprogress`, `downloadcontent`, `lang`) VALUES ('277', '9', '26', '3', '91', '', '1755916142', '0', '0', '1', '1', '1', '0', '0', '0', NULL, '0', '0', '0', '0', NULL, '0', '1', '')

INSERT INTO `mdl_course` (`id`, `category`, `sortorder`, `fullname`, `shortname`, `idnumber`, `summary`, `summaryformat`, `format`, `showgrades`, `newsitems`, `startdate`, `enddate`, `relativedatesmode`, `marker`, `maxbytes`, `legacyfiles`, `showreports`, `visible`, `visibleold`, `downloadcontent`, `groupmode`, `groupmodeforce`, `defaultgroupingid`, `lang`, `calendartype`, `theme`, `timecreated`, `timemodified`, `requested`, `enablecompletion`, `completionnotify`, `cacherev`, `originalcourseid`, `showactivitydates`, `showcompletionconditions`, `pdfexportfont`) VALUES ('9', '3', '30003', 'СЕРВИС. ПРОФЕССИОНАЛЬНЫЙ ИМИДЖ', 'Профессиональный имидж', '', '<p dir=\"ltr\">Этот курс посвящен самым актуальным стратегиям и современным подходам к раннему выявлению и профилактике онкологических заболеваний в условиях первичной медико-санитарной помощи. Вы изучите современные скрининговые программы, методы консультирования пациентов по факторам риска и принципы онконастороженности в ежедневной практике. Курс предназначен для врачей общей практики, терапевтов и фельдшеров, стремящихся повысить эффективность профилактической работы и снизить онкологическую заболеваемость на своем участке.</p>', '1', 'topics', '1', '5', '1753815600', '0', '0', '0', '0', '0', '0', '1', '1', NULL, '0', '0', '0', '', '', '', '1753805401', '1755594415', '0', '1', '0', '1756011550', NULL, '1', '1', NULL)

INSERT INTO `mdl_customcert` (`id`, `course`, `templateid`, `name`, `intro`, `introformat`, `requiredtime`, `verifyany`, `deliveryoption`, `usecustomfilename`, `customfilenamepattern`, `emailstudents`, `emailteachers`, `emailothers`, `protection`, `language`, `timecreated`, `timemodified`) VALUES ('3', '9', '4', 'Сертификат', '', '1', '0', '1', 'I', '0', NULL, '0', '0', '', '', '', '1755916142', '1755916142')

INSERT INTO `mdl_customcert_issues` (`id`, `userid`, `customcertid`, `code`, `emailed`, `timecreated`) VALUES ('4', '3', '3', '2795-0273-6651', '0', '1755920135')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant