Trying to figure out module_item creation behavior (parallel requests)

mike_young
Community Member

Hi all!

Long-time lurker, first-time poster. Many thanks to everyone who has shared their tricks for negotiating the Canvas REST API, especially @James with parallel requests and pagination strategies! Huge help. Big kudos. 😃

As it says in the subject, I'm trying to figure out some module_item creation behavior. Here's the story:

  1. I am doing stacks of parallel cURL requests in PHP using curl_multi handles.
  2. Specifically, I am building multiple module items at once. I am building my POST requests correctly, and everything works successfully, including positioning, EXCEPT... for completion_requirements.
  3. The module item objects in the requests look like this in JSON format (real #s scrubbed, obv):

    {
    "module_item": {
    "title": "Whatever",
    "position": #,
    "indent": 0,
    "type": "Assignment",
    "module_id": #,
    "content_id": #,
    "completion_requirement": {
    "type": "min_score",
    "min_score": 80
    },
    "published": true,
    }
    }

  4. The module item objects I get back from Canvas look like this (PHP print_r output):

    [id] => #
    [title] => Whatever
    [position] => #
    [indent] => 0
    [quiz_lti] =>
    [type] => Assignment
    [module_id] => #
    [html_url] => correct URL
    [content_id] => #
    [url] => correct URL
    [completion_requirement] => stdClass Object
    (
    [type] => min_score
    [min_score] => 80
    )

    [published] => 1
    [unpublishable] => 1

  5. Nothing weird I can see except that "unpublishable" property, which I can't quite track down in the Canvas source code API behavior. The problem is that even though completion_requirement is returned correctly for every module item I create, it inconsistently ends up missing in the actual course when I check through the UI and through the API (by grabbing the new module item info).
  6. As implied by the mysterious italics, this behavior is inconsistent. I've thought about patterns based on where the call is in the batch, and there is no seeming correlation between whether it's the last call of the batch, the first call, etc.

I suspect the issue is related to the parallel cURL calls because I know the Canvas REST API doesn't like them. Maybe @James or another kind parallel request guru with time on their hands might be able to shed some light?

Thank you all very much! 😃
Mike

0 Likes