Giter VIP home page Giter VIP logo

canvas-php-accounttree's Introduction

canvas-php-accountTree

This is a set of basic functions for retrieving the account tree for a designated account and it's sub-accounts in the Canvas LMS and formatting them as options for a dropdown menu.

Canvas LMS - REST API and Extensions Documentation

Dependencies

How-To Use

Retrieving Multidimensional Array of Tree

The array is based off a need for only three (3) pieces of information: Account ID, Account Name, and Sub-Acocunts.

Note: The function depends upon the $cURL variable name matching. If you wish to change it from the example, it MUST be changed in the function to match.

<?php
  // Update to reflect the token of the admin user that is to be used
  $token = "Authorization: Bearer 1234~8ca7f0dc11599a193be27500387156b982e53d7a180973cc33c8c159a62c1373";
  // Update to reflect the address to your institute
  $site = "canvas.instructure.com";
  // Update to reflect the root account the tree is to be built off

  // Dependency
  require "class.curl.php";

  // Functions
  require "functions.accountTree.php";

  $cURL = new Curl($token, $site);

  $subAccounts = buildTreeArray($accountID);

  $cURL->closeCurl();
?>

Converting the Multidimensional Array into a Dropdown Menu

This function only creates the OPTIONs for a SELECT. Building the SELECT will be dependent upon your use for it.

<?php
  // Update to reflect the token of the admin user that is to be used
  $token = "Authorization: Bearer 1234~8ca7f0dc11599a193be27500387156b982e53d7a180973cc33c8c159a62c1373";
  // Update to reflect the address to your institute
  $site = "canvas.instructure.com";
  // Update to reflect the root account the tree is to be built off

  // Dependency
  require "class.curl.php";

  // Functions
  require "functions.accountTree.php";

  $cURL = new Curl($token, $site);

  // Customize the SELECT element to meet your needs
  $dropdownMenu = '<select id="account" name="account">' . buildOptions(buildTreeArray($accountID)) . '</select>';

  $cURL->closeCurl();
?>

canvas-php-accounttree's People

Contributors

cesbrandt avatar

Stargazers

Tulio Nogueira avatar

Watchers

James Cloos avatar  avatar

Forkers

tuliomn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.