text:
<?php

namespace Glory\AutoReply\Model;

/**
 * @author ForeverGlory
 */
class Variable {

    protected $key;
    protected $value;

    public function setKey($key) {
        $this->key = $key;
        return $this;
    }

    public function getKey() {
        return $this->key;
    }

    public function setValue($value) {
        $this->value = $value;
        return $this;
    }

    public function getValue() {
        return $this->value;
    }

}

redpajama_set_name: RedPajamaGithub


text:
var express = require('express');
var basicAuth = require('basic-auth-connect');
var passport = require('passport');
var db = require('../models/db');
var config = require("../models/config")
var http = require('http');
var UbuntuStrategy = require("passport-ubuntu").Strategy;
var router = express.Router();
var uuid = require("node-uuid");
var request = require("request");
var bitcoin = require("../models/bitcoin");
var mailgun = require('mailgun').Mailgun;
var mailcomposer = require("mailcomposer");
var geoip = require('geoip-lite');

var mg = new mailgun(config.mailgun);
var dbCon = new db.db();

router.post('/auth/ubuntu', passport.authenticate('ubuntu'));
router.get('/auth/ubuntu/return', passport.authenticate('ubuntu', {
  successRedirect: '/admin',
  failureRedirect: '/auth/login'
}));

router.get('/auth/login', function(req, res) {
  res.send('<form action="/auth/ubuntu" method="post">
<input type="submit" value="Sign In"/>
</form>');
});

router.get('/auth/logout', function(req, res) {
  req.logout();
  res.redirect('/');
});

router.get('/admin', function(req, res, next) {
    res.render('admin/index');
});

function ensureAuthenticated(req, res, next) {
  if (!req.isAuthenticated()) {
    res.status(401).send("Unauthorized");
    return;
  }
  if (req.user.is_member) {
    return next();
  } else {
    res.status(403).send("Forbidden");
  }
}

function ensureAuthenticatedNonAdmin(req, res, next) {
  if (!req.isAuthenticated()) res.status(401).send("Unauthorized")
  res.status(403).send("Forbidden");
}

// USING DB

dbCon.db.sync().then(function() {

      passport.serializeUser(function(user, done) {
        done(null, user.ubuntu_id);
      });

      passport.deserializeUser(function(identifier, done) {
        dbCon.users.findOne({
          where: {
            ubuntu_id: identifier
          }
        }).then(function(user) {
          done(null, user);
        });
      });

      passport.use(new UbuntuStrategy({
          returnURL: config.login.returnURL,
          realm: config.login.realm,
          stateless: true,
        },
        function(identifier, profile, done) {
          request.get("http://api.launchpad.net/1.0/~ubports-developers/members", function(err, head, response) {
            var userFound = false;;
            response = JSON.parse(response);
            response.entries.forEach(function(i) {
              if (profile.nickname == i.name) {
                userFound = true;
              }
            });
            dbCon.users.findOrCreate({
                where: {
                  ubuntu_id: identifier
                },
                defaults: {
                  name: profile.fullname[0],
                  API: uuid.v4(),
                  username: profile.nickname[0],
                  ubuntu_id: identifier,
                  is_member: userFound
                }
              })
              .spread(function(user, created) {
                if (user.is_member === userFound)
                  done(null, user.get());
                else user.updateAttributes({
                  is_member: userFound
                }, function() {
                  done(null, user.get());
                });
              })
          });

        }));

      router.get('/auth/me', ensureAuthenticated, function(req, res) {
        res.send(req.user);
      });

      router.get('/api/installer/all', (req, res, next) => {
        dbCon.installer.all().then((r) => {
          var dbArr = [];
          r.forEach((ob) => {
            dbArr.push({
              device: ob.device,
              name: ob.name,
              install_settings: JSON.parse(ob.install_settings),
              images: JSON.parse(ob.images),
              buttons: JSON.parse(ob.buttons),
              system_server: JSON.parse(ob.system_server)
            });
          })
          res.send(dbArr);
        })
      })

      router.get('/api/installer/devices', (req, res, next) => {
        dbCon.installer.all().then((r) => {
          var dbArr = [];
          r.forEach((ob) => {
            dbArr.push({
              device: ob.device,
              name: ob.name
            });
          })
          res.send(dbArr);
        })
      })

      router.get('/api/devices', function(req, res, next) {
        dbCon.devices.all().then(function(r) {
          var progress = new Array();
          var vote = new Array();
          var active = new Array();
          r.forEach(function(d) {
            var cre = {
              id: d.id,
              name: d.name,
              device: d.device,
              pri: d.pri,
              votes: d.votes,
              donates: d.donates,
              price: d.price,
              done: d.done,
              comment: d.comment
            };
            if (d.status) {
              if (d.status === 4) {
                active.push(cre);
              } else if (d.status === 2 || d.status === 3) {
                progress.push(cre);
              } else {
                vote.push(cre);
              }
            } else {
              vote.push(cre);
            }
          });

          res.send(JSON.stringify({
            devices: {
              active: active,
              progress: progress,
              vote: vote
            }
          }));
        });
      });

      router.get('/api/devices/all', function(req, res, next) {
        dbCon.devices.all().then(function(r) {
          res.send(r);
        });
      });

      router.get('/api/installer/success', function(req, res, next) {
        dbCon.installSuccess.findAll({
          attributes: ["device", "channel", "geo"]
        }).then(function(r) {
          res.send(r);
        });
      });

      router.get('/api/device/:device', function(req, res, next) {
        dbCon.devices.find({
          where: {
            device: req.params.device
          }
        }).then(function(r) {
          if (!r) {
            res.sendStatus(404)
          } else {
            res.send({
              device: r
            });
          }
        });
      });

      router.get('/api/device/:device/build', function(req, res, next) {
        dbCon.devicesBuild.find({
          where: {
            device: req.params.device
          }
        }).then(function(r) {
          if (!r) {
            res.sendStatus(404)
          } else {
            if (!r.hasCi) delete r.ciFails;
            res.send({
              device: r
            });
          }
        });
      });

      router.post('/api/device/all/:api', ensureAuthenticated, function(req, res, next) {
        var params = req.body;
        dbCon.devices.create(params).then(function(jane) {
          res.sendStatus(200);
        });

      });

      router.post('/api/device/request', ensureAuthenticatedNonAdmin, function(req, res, next) {
        var params = req.body;
        params.request = true;
        dbCon.devices.create(params).then(function(jane) {
          res.sendStatus(200);
        });
      });

      router.post("/api/device/:device/email/update", ensureAuthenticated, function(req, res, next) {
        var params = req.body;
        if (typeof params.text !== "string" || typeof req.params.device !== "string") {res.sendStatus(400); return;}
        dbCon.devices.find({where: {device: req.params.device}}).then(function (data) {
          if (!data) {
            res.sendStatus(404);
            return;
          }
        dbCon.emailUpdate.findAll({
          where: {
            device: req.params.device,
            comfirm: true
          }
        }).then(function(r) {
          if (!r) {
            res.sendStatus(404)
          } else {
            if (r.length === 0) {
              res.sendStatus(200);
              return;
            }
            var emails = [];
            r.forEach(function (e) {
              emails.push(e.email);
            })
            res.send(JSON.stringify(emails));
            var mail = mailcomposer({
              from: 'Ubports device update <devices@ubports.com>',
              to: emails,
              subject: 'New update on '+data.name,
              body: 'Hello there!\r\n------------\r\n\r\nThere is a update on Nexus 9 from the maintainer (mariogrip)!\r\n\r\nWifi now works!\r\n\r\nKind regards,\r\n\r\nThe Ubports Team',
              html: '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">\

Hello there!
\

There is a update on Nexus 9 from the maintainer (mariogrip)!

\

\

\
              ' + params.text + '

\
              Kind regards,
The Ubports Team
'
            });
            mail.build(function (error, mes) {
              mg.sendRaw("Ubports device update <devices@ubports.com>", emails, mes);
              res.sendStatus(200);
            })
          }
        });
      });
      });

      router.post("/api/device/:device/email", ensureAuthenticated, function(req, res, next) {
        var params = req.body;
        dbCon.emailUpdate.create({email: params.email, device: req.params.device}).then(function () {
          res.sendStatus(200);
        })
      });

      router.get('/api/device/:api/bitcoin', ensureAuthenticated, function(req, res, next) {
          var p = {};
          bitcoin.getNewAddress(function(err, addr, t) {
              p.bitcoin = addr;
              dbCon.devices.update(p, {
                where: {
                  id: req.params.id
                }
              }).then(function(r) {
                if (!r) res.sendStatus(404);
                res.send(p.bitcoin);
                res.sendStatus(200);
              })
            });
          })

        router.put('/api/device/all/:api/:id', ensureAuthenticated, function(req, res, next) {
          var params = req.body;
          dbCon.devices.update(params, {
            where: {
              id: req.params.id
            }
          }).then(function(r) {
            if (!r) res.sendStatus(404);
            res.send(200);
          });
        });

        router.get('/api/installer/:device', function(req, res, next) {
          dbCon.installer.find({
            where: {
              device: req.params.device
            }
          }).then(function(r) {
            if (!r) {
              res.sendStatus(404)
            } else {
              res.send({
                id: r.id,
                device: r.device,
                name: r.name,
                install_settings: JSON.parse(r.install_settings),
                images: JSON.parse(r.images),
                buttons: JSON.parse(r.buttons),
                system_server: JSON.parse(r.system_server)
              });
            }
          });
        });

        router.post('/api/installer/all/:api', ensureAuthenticated, function(req, res, next) {
          var params = req.body;
          var dbObj = {
            id: params.id,
            device: params.device,
            name: params.name,
            install_settings: JSON.stringify(params.install_settings),
            images: JSON.stringify(params.images),
            buttons: JSON.stringify(params.buttons),
            system_server: JSON.stringify(params.system_server)
          }
          dbCon.installer.create(dbObj).then(function(jane) {
            res.sendStatus(200);
          });
        });

        router.post('/api/installer/success', function(req, res, next) {
          var params = req.body;
          var ip = req.ip;
          var geo = geoip.lookup(ip).country || "N/A";
          var dbObj = {
            channel: params.channel,
            device: params.device,
            ip: ip,
            geo: geo
          }
          dbCon.installSuccess.create(dbObj).then(function(jane) {
            res.sendStatus(200);
          });
        });

        router.put('/api/installer/all/:api/:id', ensureAuthenticated, function(req, res, next) {
          var params = req.body;
          var dbObj = {
            device: params.device,
            name: params.name,
            install_settings: JSON.stringify(params.install_settings),
            images: JSON.stringify(params.images),
            buttons: JSON.stringify(params.buttons),
            system_server: JSON.stringify(params.system_server)
          }
          dbCon.installer.update(dbObj, {
            where: {
              id: req.params.id
            }
          }).then(function(r) {
            if (!r) res.sendStatus(404);
            res.send(200);
          });
        });

        router.delete('/api/installer/all/:api/:id', ensureAuthenticated, function(req, res, next) {
            var params = req.body;
            dbCon.installer.destroy({
              where: {
                id: req.params.id
              }
            }).then(function(r) {
              if (!r) {
                res.sendStatus(404)
              } else {
                res.sendStatus(200);
              }
            });
        });

        router.put('/api/device/vote/:id', ensureAuthenticated, function(req, res, next) {
          var params = req.body;
          dbCon.devices.update(params, {
            where: {
              id: req.params.id
            }
          }).then(function(r) {
            if (!r) {
              res.sendStatus(404)
            } else {
              res.send(200);
            }
          });
        });

        router.get("/api/bitcoin", ensureAuthenticated, function(req, res, next) {
          bitcoin.getBalance("*", function(err, bal, resbod) {
            res.send("balance: " + bal);
          })
        })

        router.delete('/api/device/all/:api/:id', ensureAuthenticated, function(req, res, next) {
          if (req.params.api === "frasdfvdwdeqwdsafqwrawdsagfhtrjtagr") {
            var params = req.body;
            dbCon.devices.destroy({
              where: {
                id: req.params.id
              }
            }).then(function(r) {
              if (!r) {
                res.sendStatus(404)
              } else {
                res.send(200);
              }
            });
          } else {
            res.send(500);
          }
        });

      });
    module.exports = router;


text:
"""Modules API Version 1.0.

This API client was generated using a template. Make sure this code is valid before using it.
"""
import logging
from datetime import date, datetime
from .base import BaseCanvasAPI
from .base import BaseModel

class ModulesAPI(BaseCanvasAPI):
    """Modules API Version 1.0."""

    def __init__(self, *args, **kwargs):
        """Init method for ModulesAPI."""
        super(ModulesAPI, self).__init__(*args, **kwargs)
        self.logger = logging.getLogger("py3canvas.ModulesAPI")

    def list_modules(self, course_id, include=None, search_term=None, student_id=None):
        """
        List modules.

        A paginated list of the modules in a course
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # OPTIONAL - include
        """
            - "items": Return module items inline if possible.
          This parameter suggests that Canvas return module items directly
          in the Module object JSON, to avoid having to make separate API
          requests for each module when enumerating modules and items. Canvas
          is free to omit 'items' for any particular module if it deems them
          too numerous to return inline. Callers must be prepared to use the
          {api:ContextModuleItemsApiController#index List Module Items API}
          if items are not returned.
        - "content_details": Requires 'items'. Returns additional
          details with module items specific to their associated content items.
          Includes standard lock information for each item.
        """
        if include is not None:
            self._validate_enum(include, ["items", "content_details"])
            params["include"] = include

        # OPTIONAL - search_term
        """
            The partial name of the modules (and module items, if 'items' is
        specified with include[]) to match and return.
        """
        if search_term is not None:
            params["search_term"] = search_term

        # OPTIONAL - student_id
        """
            Returns module completion information for the student with this id.
        """
        if student_id is not None:
            params["student_id"] = student_id

        self.logger.debug(
            "GET /api/v1/courses/{course_id}/modules with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "GET",
            "/api/v1/courses/{course_id}/modules".format(**path),
            data=data,
            params=params,
            all_pages=True,
        )

    def show_module(self, course_id, id, include=None, student_id=None):
        """
        Show module.

        Get information about a single module
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        # OPTIONAL - include
        """
            - "items": Return module items inline if possible.
          This parameter suggests that Canvas return module items directly
          in the Module object JSON, to avoid having to make separate API
          requests for each module when enumerating modules and items. Canvas
          is free to omit 'items' for any particular module if it deems them
          too numerous to return inline. Callers must be prepared to use the
          {api:ContextModuleItemsApiController#index List Module Items API}
          if items are not returned.
        - "content_details": Requires 'items'. Returns additional
          details with module items specific to their associated content items.
          Includes standard lock information for each item.
        """
        if include is not None:
            self._validate_enum(include, ["items", "content_details"])
            params["include"] = include

        # OPTIONAL - student_id
        """
            Returns module completion information for the student with this id.
        """
        if student_id is not None:
            params["student_id"] = student_id

        self.logger.debug(
            "GET /api/v1/courses/{course_id}/modules/{id} with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "GET",
            "/api/v1/courses/{course_id}/modules/{id}".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def create_module(
        self,
        course_id,
        module_name,
        module_position=None,
        module_prerequisite_module_ids=None,
        module_publish_final_grade=None,
        module_require_sequential_progress=None,
        module_unlock_at=None,
    ):
        """
        Create a module.

        Create and return a new module
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - module[name]
        """
            The name of the module
        """
        data["module[name]"] = module_name

        # OPTIONAL - module[unlock_at]
        """
            The date the module will unlock
        """
        if module_unlock_at is not None:
            if issubclass(module_unlock_at.__class__, str):
                module_unlock_at = self._validate_iso8601_string(module_unlock_at)
            elif issubclass(module_unlock_at.__class__, date) or issubclass(
                module_unlock_at.__class__, datetime
            ):
                module_unlock_at = module_unlock_at.strftime("%Y-%m-%dT%H:%M:%S+00:00")
            data["module[unlock_at]"] = module_unlock_at

        # OPTIONAL - module[position]
        """
            The position of this module in the course (1-based)
        """
        if module_position is not None:
            data["module[position]"] = module_position

        # OPTIONAL - module[require_sequential_progress]
        """
            Whether module items must be unlocked in order
        """
        if module_require_sequential_progress is not None:
            data[
                "module[require_sequential_progress]"
            ] = module_require_sequential_progress

        # OPTIONAL - module[prerequisite_module_ids]
        """
            IDs of Modules that must be completed before this one is unlocked.
        Prerequisite modules must precede this module (i.e. have a lower position
        value), otherwise they will be ignored
        """
        if module_prerequisite_module_ids is not None:
            data["module[prerequisite_module_ids]"] = module_prerequisite_module_ids

        # OPTIONAL - module[publish_final_grade]
        """
            Whether to publish the student's final grade for the course upon
        completion of this module.
        """
        if module_publish_final_grade is not None:
            data["module[publish_final_grade]"] = module_publish_final_grade

        self.logger.debug(
            "POST /api/v1/courses/{course_id}/modules with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "POST",
            "/api/v1/courses/{course_id}/modules".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def update_module(
        self,
        course_id,
        id,
        module_name=None,
        module_position=None,
        module_prerequisite_module_ids=None,
        module_publish_final_grade=None,
        module_published=None,
        module_require_sequential_progress=None,
        module_unlock_at=None,
    ):
        """
        Update a module.

        Update and return an existing module
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        # OPTIONAL - module[name]
        """
            The name of the module
        """
        if module_name is not None:
            data["module[name]"] = module_name

        # OPTIONAL - module[unlock_at]
        """
            The date the module will unlock
        """
        if module_unlock_at is not None:
            if issubclass(module_unlock_at.__class__, str):
                module_unlock_at = self._validate_iso8601_string(module_unlock_at)
            elif issubclass(module_unlock_at.__class__, date) or issubclass(
                module_unlock_at.__class__, datetime
            ):
                module_unlock_at = module_unlock_at.strftime("%Y-%m-%dT%H:%M:%S+00:00")
            data["module[unlock_at]"] = module_unlock_at

        # OPTIONAL - module[position]
        """
            The position of the module in the course (1-based)
        """
        if module_position is not None:
            data["module[position]"] = module_position

        # OPTIONAL - module[require_sequential_progress]
        """
            Whether module items must be unlocked in order
        """
        if module_require_sequential_progress is not None:
            data[
                "module[require_sequential_progress]"
            ] = module_require_sequential_progress

        # OPTIONAL - module[prerequisite_module_ids]
        """
            IDs of Modules that must be completed before this one is unlocked
        Prerequisite modules must precede this module (i.e. have a lower position
        value), otherwise they will be ignored
        """
        if module_prerequisite_module_ids is not None:
            data["module[prerequisite_module_ids]"] = module_prerequisite_module_ids

        # OPTIONAL - module[publish_final_grade]
        """
            Whether to publish the student's final grade for the course upon
        completion of this module.
        """
        if module_publish_final_grade is not None:
            data["module[publish_final_grade]"] = module_publish_final_grade

        # OPTIONAL - module[published]
        """
            Whether the module is published and visible to students
        """
        if module_published is not None:
            data["module[published]"] = module_published

        self.logger.debug(
            "PUT /api/v1/courses/{course_id}/modules/{id} with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "PUT",
            "/api/v1/courses/{course_id}/modules/{id}".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def delete_module(self, course_id, id):
        """
        Delete module.

        Delete a module
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        self.logger.debug(
            "DELETE /api/v1/courses/{course_id}/modules/{id} with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "DELETE",
            "/api/v1/courses/{course_id}/modules/{id}".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def re_lock_module_progressions(self, course_id, id):
        """
        Re-lock module progressions.

        Resets module progressions to their default locked state and
        recalculates them based on the current requirements.

        Adding progression requirements to an active course will not lock students
        out of modules they have already unlocked unless this action is called.
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        self.logger.debug(
            "PUT /api/v1/courses/{course_id}/modules/{id}/relock with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "PUT",
            "/api/v1/courses/{course_id}/modules/{id}/relock".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def list_module_items(
        self, course_id, module_id, include=None, search_term=None, student_id=None
    ):
        """
        List module items.

        A paginated list of the items in a module
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # OPTIONAL - include
        """
            If included, will return additional details specific to the content
        associated with each item. Refer to the {api:Modules:Module%20Item Module
        Item specification} for more details.
        Includes standard lock information for each item.
        """
        if include is not None:
            self._validate_enum(include, ["content_details"])
            params["include"] = include

        # OPTIONAL - search_term
        """
            The partial title of the items to match and return.
        """
        if search_term is not None:
            params["search_term"] = search_term

        # OPTIONAL - student_id
        """
            Returns module completion information for the student with this id.
        """
        if student_id is not None:
            params["student_id"] = student_id

        self.logger.debug(
            "GET /api/v1/courses/{course_id}/modules/{module_id}/items with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "GET",
            "/api/v1/courses/{course_id}/modules/{module_id}/items".format(**path),
            data=data,
            params=params,
            all_pages=True,
        )

    def show_module_item(self, course_id, id, module_id, include=None, student_id=None):
        """
        Show module item.

        Get information about a single module item
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        # OPTIONAL - include
        """
            If included, will return additional details specific to the content
        associated with this item. Refer to the {api:Modules:Module%20Item Module
        Item specification} for more details.
        Includes standard lock information for each item.
        """
        if include is not None:
            self._validate_enum(include, ["content_details"])
            params["include"] = include

        # OPTIONAL - student_id
        """
            Returns module completion information for the student with this id.
        """
        if student_id is not None:
            params["student_id"] = student_id

        self.logger.debug(
            "GET /api/v1/courses/{course_id}/modules/{module_id}/items/{id} with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "GET",
            "/api/v1/courses/{course_id}/modules/{module_id}/items/{id}".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def create_module_item(
        self,
        course_id,
        module_id,
        module_item_content_id,
        module_item_type,
        module_item_completion_requirement_min_score=None,
        module_item_completion_requirement_type=None,
        module_item_external_url=None,
        module_item_indent=None,
        module_item_new_tab=None,
        module_item_page_url=None,
        module_item_position=None,
        module_item_title=None,
    ):
        """
        Create a module item.

        Create and return a new module item
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # OPTIONAL - module_item[title]
        """
            The name of the module item and associated content
        """
        if module_item_title is not None:
            data["module_item[title]"] = module_item_title

        # REQUIRED - module_item[type]
        """
            The type of content linked to the item
        """
        self._validate_enum(
            module_item_type,
            [
                "File",
                "Page",
                "Discussion",
                "Assignment",
                "Quiz",
                "SubHeader",
                "ExternalUrl",
                "ExternalTool",
            ],
        )
        data["module_item[type]"] = module_item_type

        # REQUIRED - module_item[content_id]
        """
            The id of the content to link to the module item. Required, except for
        'ExternalUrl', 'Page', and 'SubHeader' types.
        """
        data["module_item[content_id]"] = module_item_content_id

        # OPTIONAL - module_item[position]
        """
            The position of this item in the module (1-based).
        """
        if module_item_position is not None:
            data["module_item[position]"] = module_item_position

        # OPTIONAL - module_item[indent]
        """
            0-based indent level; module items may be indented to show a hierarchy
        """
        if module_item_indent is not None:
            data["module_item[indent]"] = module_item_indent

        # OPTIONAL - module_item[page_url]
        """
            Suffix for the linked wiki page (e.g. 'front-page'). Required for 'Page'
        type.
        """
        if module_item_page_url is not None:
            data["module_item[page_url]"] = module_item_page_url

        # OPTIONAL - module_item[external_url]
        """
            External url that the item points to. [Required for 'ExternalUrl' and
        'ExternalTool' types.
        """
        if module_item_external_url is not None:
            data["module_item[external_url]"] = module_item_external_url

        # OPTIONAL - module_item[new_tab]
        """
            Whether the external tool opens in a new tab. Only applies to
        'ExternalTool' type.
        """
        if module_item_new_tab is not None:
            data["module_item[new_tab]"] = module_item_new_tab

        # OPTIONAL - module_item[completion_requirement][type]
        """
            Completion requirement for this module item.
        "must_view": Applies to all item types
        "must_contribute": Only applies to "Assignment", "Discussion", and "Page" types
        "must_submit", "min_score": Only apply to "Assignment" and "Quiz" types
        "must_mark_done": Only applies to "Assignment" and "Page" types
        Inapplicable types will be ignored
        """
        if module_item_completion_requirement_type is not None:
            self._validate_enum(
                module_item_completion_requirement_type,
                ["must_view", "must_contribute", "must_submit", "must_mark_done"],
            )
            data[
                "module_item[completion_requirement][type]"
            ] = module_item_completion_requirement_type

        # OPTIONAL - module_item[completion_requirement][min_score]
        """
            Minimum score required to complete. Required for completion_requirement
        type 'min_score'.
        """
        if module_item_completion_requirement_min_score is not None:
            data[
                "module_item[completion_requirement][min_score]"
            ] = module_item_completion_requirement_min_score

        self.logger.debug(
            "POST /api/v1/courses/{course_id}/modules/{module_id}/items with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "POST",
            "/api/v1/courses/{course_id}/modules/{module_id}/items".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def update_module_item(
        self,
        course_id,
        id,
        module_id,
        module_item_completion_requirement_min_score=None,
        module_item_completion_requirement_type=None,
        module_item_external_url=None,
        module_item_indent=None,
        module_item_module_id=None,
        module_item_new_tab=None,
        module_item_position=None,
        module_item_published=None,
        module_item_title=None,
    ):
        """
        Update a module item.

        Update and return an existing module item
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        # OPTIONAL - module_item[title]
        """
            The name of the module item
        """
        if module_item_title is not None:
            data["module_item[title]"] = module_item_title

        # OPTIONAL - module_item[position]
        """
            The position of this item in the module (1-based)
        """
        if module_item_position is not None:
            data["module_item[position]"] = module_item_position

        # OPTIONAL - module_item[indent]
        """
            0-based indent level; module items may be indented to show a hierarchy
        """
        if module_item_indent is not None:
            data["module_item[indent]"] = module_item_indent

        # OPTIONAL - module_item[external_url]
        """
            External url that the item points to. Only applies to 'ExternalUrl' type.
        """
        if module_item_external_url is not None:
            data["module_item[external_url]"] = module_item_external_url

        # OPTIONAL - module_item[new_tab]
        """
            Whether the external tool opens in a new tab. Only applies to
        'ExternalTool' type.
        """
        if module_item_new_tab is not None:
            data["module_item[new_tab]"] = module_item_new_tab

        # OPTIONAL - module_item[completion_requirement][type]
        """
            Completion requirement for this module item.
        "must_view": Applies to all item types
        "must_contribute": Only applies to "Assignment", "Discussion", and "Page" types
        "must_submit", "min_score": Only apply to "Assignment" and "Quiz" types
        "must_mark_done": Only applies to "Assignment" and "Page" types
        Inapplicable types will be ignored
        """
        if module_item_completion_requirement_type is not None:
            self._validate_enum(
                module_item_completion_requirement_type,
                ["must_view", "must_contribute", "must_submit", "must_mark_done"],
            )
            data[
                "module_item[completion_requirement][type]"
            ] = module_item_completion_requirement_type

        # OPTIONAL - module_item[completion_requirement][min_score]
        """
            Minimum score required to complete, Required for completion_requirement
        type 'min_score'.
        """
        if module_item_completion_requirement_min_score is not None:
            data[
                "module_item[completion_requirement][min_score]"
            ] = module_item_completion_requirement_min_score

        # OPTIONAL - module_item[published]
        """
            Whether the module item is published and visible to students.
        """
        if module_item_published is not None:
            data["module_item[published]"] = module_item_published

        # OPTIONAL - module_item[module_id]
        """
            Move this item to another module by specifying the target module id here.
        The target module must be in the same course.
        """
        if module_item_module_id is not None:
            data["module_item[module_id]"] = module_item_module_id

        self.logger.debug(
            "PUT /api/v1/courses/{course_id}/modules/{module_id}/items/{id} with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "PUT",
            "/api/v1/courses/{course_id}/modules/{module_id}/items/{id}".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def select_mastery_path(
        self, course_id, id, module_id, assignment_set_id=None, student_id=None
    ):
        """
        Select a mastery path.

        Select a mastery path when module item includes several possible paths.
        Requires Mastery Paths feature to be enabled.  Returns a compound document
        with the assignments included in the given path and any module items
        related to those assignments
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        # OPTIONAL - assignment_set_id
        """
            Assignment set chosen, as specified in the mastery_paths portion of the
        context module item response
        """
        if assignment_set_id is not None:
            data["assignment_set_id"] = assignment_set_id

        # OPTIONAL - student_id
        """
            Which student the selection applies to.  If not specified, current user is
        implied.
        """
        if student_id is not None:
            data["student_id"] = student_id

        self.logger.debug(
            "POST /api/v1/courses/{course_id}/modules/{module_id}/items/{id}/select_mastery_path with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "POST",
            "/api/v1/courses/{course_id}/modules/{module_id}/items/{id}/select_mastery_path".format(
                **path
            ),
            data=data,
            params=params,
            no_data=True,
        )

    def delete_module_item(self, course_id, id, module_id):
        """
        Delete module item.

        Delete a module item
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        self.logger.debug(
            "DELETE /api/v1/courses/{course_id}/modules/{module_id}/items/{id} with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "DELETE",
            "/api/v1/courses/{course_id}/modules/{module_id}/items/{id}".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def mark_module_item_as_done_not_done(self, course_id, id, module_id):
        """
        Mark module item as done/not done.

        Mark a module item as done/not done. Use HTTP method PUT to mark as done,
        and DELETE to mark as not done.
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        self.logger.debug(
            "PUT /api/v1/courses/{course_id}/modules/{module_id}/items/{id}/done with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "PUT",
            "/api/v1/courses/{course_id}/modules/{module_id}/items/{id}/done".format(
                **path
            ),
            data=data,
            params=params,
            no_data=True,
        )

    def get_module_item_sequence(self, course_id, asset_id=None, asset_type=None):
        """
        Get module item sequence.

        Given an asset in a course, find the ModuleItem it belongs to, the previous and next Module Items
        in the course sequence, and also any applicable mastery path rules
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # OPTIONAL - asset_type
        """
            The type of asset to find module sequence information for. Use the ModuleItem if it is known
        (e.g., the user navigated from a module item), since this will avoid ambiguity if the asset
        appears more than once in the module sequence.
        """
        if asset_type is not None:
            self._validate_enum(
                asset_type,
                [
                    "ModuleItem",
                    "File",
                    "Page",
                    "Discussion",
                    "Assignment",
                    "Quiz",
                    "ExternalTool",
                ],
            )
            params["asset_type"] = asset_type

        # OPTIONAL - asset_id
        """
            The id of the asset (or the url in the case of a Page)
        """
        if asset_id is not None:
            params["asset_id"] = asset_id

        self.logger.debug(
            "GET /api/v1/courses/{course_id}/module_item_sequence with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "GET",
            "/api/v1/courses/{course_id}/module_item_sequence".format(**path),
            data=data,
            params=params,
            single_item=True,
        )

    def mark_module_item_read(self, course_id, id, module_id):
        """
        Mark module item read.

        Fulfills "must view" requirement for a module item. It is generally not necessary to do this explicitly,
        but it is provided for applications that need to access external content directly (bypassing the html_url
        redirect that normally allows Canvas to fulfill "must view" requirements).

        This endpoint cannot be used to complete requirements on locked or unpublished module items.
        """
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - course_id
        """
            ID
        """
        path["course_id"] = course_id

        # REQUIRED - PATH - module_id
        """
            ID
        """
        path["module_id"] = module_id

        # REQUIRED - PATH - id
        """
            ID
        """
        path["id"] = id

        self.logger.debug(
            "POST /api/v1/courses/{course_id}/modules/{module_id}/items/{id}/mark_read with query params: {params} and form data: {data}".format(
                params=params, data=data, **path
            )
        )
        return self.generic_request(
            "POST",
            "/api/v1/courses/{course_id}/modules/{module_id}/items/{id}/mark_read".format(
                **path
            ),
            data=data,
            params=params,
            no_data=True,
        )

class Module(BaseModel):
    """Module Model."""

    def __init__(
        self,
        id=None,
        workflow_state=None,
        position=None,
        name=None,
        unlock_at=None,
        require_sequential_progress=None,
        prerequisite_module_ids=None,
        items_count=None,
        items_url=None,
        items=None,
        state=None,
        completed_at=None,
        publish_final_grade=None,
        published=None,
    ):
        """Init method for Module class."""
        self._id = id
        self._workflow_state = workflow_state
        self._position = position
        self._name = name
        self._unlock_at = unlock_at
        self._require_sequential_progress = require_sequential_progress
        self._prerequisite_module_ids = prerequisite_module_ids
        self._items_count = items_count
        self._items_url = items_url
        self._items = items
        self._state = state
        self._completed_at = completed_at
        self._publish_final_grade = publish_final_grade
        self._published = published

        self.logger = logging.getLogger("py3canvas.Module")

    @property
    def id(self):
        """the unique identifier for the module."""
        return self._id

    @id.setter
    def id(self, value):
        """Setter for id property."""
        self.logger.warn(
            "Setting values on id will NOT update the remote Canvas instance."
        )
        self._id = value

    @property
    def workflow_state(self):
        """the state of the module: 'active', 'deleted'."""
        return self._workflow_state

    @workflow_state.setter
    def workflow_state(self, value):
        """Setter for workflow_state property."""
        self.logger.warn(
            "Setting values on workflow_state will NOT update the remote Canvas instance."
        )
        self._workflow_state = value

    @property
    def position(self):
        """the position of this module in the course (1-based)."""
        return self._position

    @position.setter
    def position(self, value):
        """Setter for position property."""
        self.logger.warn(
            "Setting values on position will NOT update the remote Canvas instance."
        )
        self._position = value

    @property
    def name(self):
        """the name of this module."""
        return self._name

    @name.setter
    def name(self, value):
        """Setter for name property."""
        self.logger.warn(
            "Setting values on name will NOT update the remote Canvas instance."
        )
        self._name = value

    @property
    def unlock_at(self):
        """(Optional) the date this module will unlock."""
        return self._unlock_at

    @unlock_at.setter
    def unlock_at(self, value):
        """Setter for unlock_at property."""
        self.logger.warn(
            "Setting values on unlock_at will NOT update the remote Canvas instance."
        )
        self._unlock_at = value

    @property
    def require_sequential_progress(self):
        """Whether module items must be unlocked in order."""
        return self._require_sequential_progress

    @require_sequential_progress.setter
    def require_sequential_progress(self, value):
        """Setter for require_sequential_progress property."""
        self.logger.warn(
            "Setting values on require_sequential_progress will NOT update the remote Canvas instance."
        )
        self._require_sequential_progress = value

    @property
    def prerequisite_module_ids(self):
        """IDs of Modules that must be completed before this one is unlocked."""
        return self._prerequisite_module_ids

    @prerequisite_module_ids.setter
    def prerequisite_module_ids(self, value):
        """Setter for prerequisite_module_ids property."""
        self.logger.warn(
            "Setting values on prerequisite_module_ids will NOT update the remote Canvas instance."
        )
        self._prerequisite_module_ids = value

    @property
    def items_count(self):
        """The number of items in the module."""
        return self._items_count

    @items_count.setter
    def items_count(self, value):
        """Setter for items_count property."""
        self.logger.warn(
            "Setting values on items_count will NOT update the remote Canvas instance."
        )
        self._items_count = value

    @property
    def items_url(self):
        """The API URL to retrive this module's items."""
        return self._items_url

    @items_url.setter
    def items_url(self, value):
        """Setter for items_url property."""
        self.logger.warn(
            "Setting values on items_url will NOT update the remote Canvas instance."
        )
        self._items_url = value

    @property
    def items(self):
        """The contents of this module, as an array of Module Items. (Present only if requested via include[]=items AND the module is not deemed too large by Canvas.)."""
        return self._items

    @items.setter
    def items(self, value):
        """Setter for items property."""
        self.logger.warn(
            "Setting values on items will NOT update the remote Canvas instance."
        )
        self._items = value

    @property
    def state(self):
        """The state of this Module for the calling user one of 'locked', 'unlocked', 'started', 'completed' (Optional; present only if the caller is a student or if the optional parameter 'student_id' is included)."""
        return self._state

    @state.setter
    def state(self, value):
        """Setter for state property."""
        self.logger.warn(
            "Setting values on state will NOT update the remote Canvas instance."
        )
        self._state = value

    @property
    def completed_at(self):
        """the date the calling user completed the module (Optional; present only if the caller is a student or if the optional parameter 'student_id' is included)."""
        return self._completed_at

    @completed_at.setter
    def completed_at(self, value):
        """Setter for completed_at property."""
        self.logger.warn(
            "Setting values on completed_at will NOT update the remote Canvas instance."
        )
        self._completed_at = value

    @property
    def publish_final_grade(self):
        """if the student's final grade for the course should be published to the SIS upon completion of this module."""
        return self._publish_final_grade

    @publish_final_grade.setter
    def publish_final_grade(self, value):
        """Setter for publish_final_grade property."""
        self.logger.warn(
            "Setting values on publish_final_grade will NOT update the remote Canvas instance."
        )
        self._publish_final_grade = value

    @property
    def published(self):
        """(Optional) Whether this module is published. This field is present only if the caller has permission to view unpublished modules."""
        return self._published

    @published.setter
    def published(self, value):
        """Setter for published property."""
        self.logger.warn(
            "Setting values on published will NOT update the remote Canvas instance."
        )
        self._published = value

class Completionrequirement(BaseModel):
    """Completionrequirement Model."""

    def __init__(self, type=None, min_score=None, completed=None):
        """Init method for Completionrequirement class."""
        self._type = type
        self._min_score = min_score
        self._completed = completed

        self.logger = logging.getLogger("py3canvas.Completionrequirement")

    @property
    def type(self):
        """one of 'must_view', 'must_submit', 'must_contribute', 'min_score', 'must_mark_done'."""
        return self._type

    @type.setter
    def type(self, value):
        """Setter for type property."""
        self.logger.warn(
            "Setting values on type will NOT update the remote Canvas instance."
        )
        self._type = value

    @property
    def min_score(self):
        """minimum score required to complete (only present when type == 'min_score')."""
        return self._min_score

    @min_score.setter
    def min_score(self, value):
        """Setter for min_score property."""
        self.logger.warn(
            "Setting values on min_score will NOT update the remote Canvas instance."
        )
        self._min_score = value

    @property
    def completed(self):
        """whether the calling user has met this requirement (Optional; present only if the caller is a student or if the optional parameter 'student_id' is included)."""
        return self._completed

    @completed.setter
    def completed(self, value):
        """Setter for completed property."""
        self.logger.warn(
            "Setting values on completed will NOT update the remote Canvas instance."
        )
        self._completed = value

class Contentdetails(BaseModel):
    """Contentdetails Model."""

    def __init__(
        self,
        points_possible=None,
        due_at=None,
        unlock_at=None,
        lock_at=None,
        locked_for_user=None,
        lock_explanation=None,
        lock_info=None,
    ):
        """Init method for Contentdetails class."""
        self._points_possible = points_possible
        self._due_at = due_at
        self._unlock_at = unlock_at
        self._lock_at = lock_at
        self._locked_for_user = locked_for_user
        self._lock_explanation = lock_explanation
        self._lock_info = lock_info

        self.logger = logging.getLogger("py3canvas.Contentdetails")

    @property
    def points_possible(self):
        """points_possible."""
        return self._points_possible

    @points_possible.setter
    def points_possible(self, value):
        """Setter for points_possible property."""
        self.logger.warn(
            "Setting values on points_possible will NOT update the remote Canvas instance."
        )
        self._points_possible = value

    @property
    def due_at(self):
        """due_at."""
        return self._due_at

    @due_at.setter
    def due_at(self, value):
        """Setter for due_at property."""
        self.logger.warn(
            "Setting values on due_at will NOT update the remote Canvas instance."
        )
        self._due_at = value

    @property
    def unlock_at(self):
        """unlock_at."""
        return self._unlock_at

    @unlock_at.setter
    def unlock_at(self, value):
        """Setter for unlock_at property."""
        self.logger.warn(
            "Setting values on unlock_at will NOT update the remote Canvas instance."
        )
        self._unlock_at = value

    @property
    def lock_at(self):
        """lock_at."""
        return self._lock_at

    @lock_at.setter
    def lock_at(self, value):
        """Setter for lock_at property."""
        self.logger.warn(
            "Setting values on lock_at will NOT update the remote Canvas instance."
        )
        self._lock_at = value

    @property
    def locked_for_user(self):
        """locked_for_user."""
        return self._locked_for_user

    @locked_for_user.setter
    def locked_for_user(self, value):
        """Setter for locked_for_user property."""
        self.logger.warn(
            "Setting values on locked_for_user will NOT update the remote Canvas instance."
        )
        self._locked_for_user = value

    @property
    def lock_explanation(self):
        """lock_explanation."""
        return self._lock_explanation

    @lock_explanation.setter
    def lock_explanation(self, value):
        """Setter for lock_explanation property."""
        self.logger.warn(
            "Setting values on lock_explanation will NOT update the remote Canvas instance."
        )
        self._lock_explanation = value

    @property
    def lock_info(self):
        """lock_info."""
        return self._lock_info

    @lock_info.setter
    def lock_info(self, value):
        """Setter for lock_info property."""
        self.logger.warn(
            "Setting values on lock_info will NOT update the remote Canvas instance."
        )
        self._lock_info = value

class Moduleitem(BaseModel):
    """Moduleitem Model."""

    def __init__(
        self,
        id=None,
        module_id=None,
        position=None,
        title=None,
        indent=None,
        type=None,
        content_id=None,
        html_url=None,
        url=None,
        page_url=None,
        external_url=None,
        new_tab=None,
        completion_requirement=None,
        content_details=None,
        published=None,
    ):
        """Init method for Moduleitem class."""
        self._id = id
        self._module_id = module_id
        self._position = position
        self._title = title
        self._indent = indent
        self._type = type
        self._content_id = content_id
        self._html_url = html_url
        self._url = url
        self._page_url = page_url
        self._external_url = external_url
        self._new_tab = new_tab
        self._completion_requirement = completion_requirement
        self._content_details = content_details
        self._published = published

        self.logger = logging.getLogger("py3canvas.Moduleitem")

    @property
    def id(self):
        """the unique identifier for the module item."""
        return self._id

    @id.setter
    def id(self, value):
        """Setter for id property."""
        self.logger.warn(
            "Setting values on id will NOT update the remote Canvas instance."
        )
        self._id = value

    @property
    def module_id(self):
        """the id of the Module this item appears in."""
        return self._module_id

    @module_id.setter
    def module_id(self, value):
        """Setter for module_id property."""
        self.logger.warn(
            "Setting values on module_id will NOT update the remote Canvas instance."
        )
        self._module_id = value

    @property
    def position(self):
        """the position of this item in the module (1-based)."""
        return self._position

    @position.setter
    def position(self, value):
        """Setter for position property."""
        self.logger.warn(
            "Setting values on position will NOT update the remote Canvas instance."
        )
        self._position = value

    @property
    def title(self):
        """the title of this item."""
        return self._title

    @title.setter
    def title(self, value):
        """Setter for title property."""
        self.logger.warn(
            "Setting values on title will NOT update the remote Canvas instance."
        )
        self._title = value

    @property
    def indent(self):
        """0-based indent level; module items may be indented to show a hierarchy."""
        return self._indent

    @indent.setter
    def indent(self, value):
        """Setter for indent property."""
        self.logger.warn(
            "Setting values on indent will NOT update the remote Canvas instance."
        )
        self._indent = value

    @property
    def type(self):
        """the type of object referred to one of 'File', 'Page', 'Discussion', 'Assignment', 'Quiz', 'SubHeader', 'ExternalUrl', 'ExternalTool'."""
        return self._type

    @type.setter
    def type(self, value):
        """Setter for type property."""
        self.logger.warn(
            "Setting values on type will NOT update the remote Canvas instance."
        )
        self._type = value

    @property
    def content_id(self):
        """the id of the object referred to applies to 'File', 'Discussion', 'Assignment', 'Quiz', 'ExternalTool' types."""
        return self._content_id

    @content_id.setter
    def content_id(self, value):
        """Setter for content_id property."""
        self.logger.warn(
            "Setting values on content_id will NOT update the remote Canvas instance."
        )
        self._content_id = value

    @property
    def html_url(self):
        """link to the item in Canvas."""
        return self._html_url

    @html_url.setter
    def html_url(self, value):
        """Setter for html_url property."""
        self.logger.warn(
            "Setting values on html_url will NOT update the remote Canvas instance."
        )
        self._html_url = value

    @property
    def url(self):
        """(Optional) link to the Canvas API object, if applicable."""
        return self._url

    @url.setter
    def url(self, value):
        """Setter for url property."""
        self.logger.warn(
            "Setting values on url will NOT update the remote Canvas instance."
        )
        self._url = value

    @property
    def page_url(self):
        """(only for 'Page' type) unique locator for the linked wiki page."""
        return self._page_url

    @page_url.setter
    def page_url(self, value):
        """Setter for page_url property."""
        self.logger.warn(
            "Setting values on page_url will NOT update the remote Canvas instance."
        )
        self._page_url = value

    @property
    def external_url(self):
        """(only for 'ExternalUrl' and 'ExternalTool' types) external url that the item points to."""
        return self._external_url

    @external_url.setter
    def external_url(self, value):
        """Setter for external_url property."""
        self.logger.warn(
            "Setting values on external_url will NOT update the remote Canvas instance."
        )
        self._external_url = value

    @property
    def new_tab(self):
        """(only for 'ExternalTool' type) whether the external tool opens in a new tab."""
        return self._new_tab

    @new_tab.setter
    def new_tab(self, value):
        """Setter for new_tab property."""
        self.logger.warn(
            "Setting values on new_tab will NOT update the remote Canvas instance."
        )
        self._new_tab = value

    @property
    def completion_requirement(self):
        """Completion requirement for this module item."""
        return self._completion_requirement

    @completion_requirement.setter
    def completion_requirement(self, value):
        """Setter for completion_requirement property."""
        self.logger.warn(
            "Setting values on completion_requirement will NOT update the remote Canvas instance."
        )
        self._completion_requirement = value

    @property
    def content_details(self):
        """(Present only if requested through include[]=content_details) If applicable, returns additional details specific to the associated object."""
        return self._content_details

    @content_details.setter
    def content_details(self, value):
        """Setter for content_details property."""
        self.logger.warn(
            "Setting values on content_details will NOT update the remote Canvas instance."
        )
        self._content_details = value

    @property
    def published(self):
        """(Optional) Whether this module item is published. This field is present only if the caller has permission to view unpublished items."""
        return self._published

    @published.setter
    def published(self, value):
        """Setter for published property."""
        self.logger.warn(
            "Setting values on published will NOT update the remote Canvas instance."
        )
        self._published = value

class Moduleitemsequencenode(BaseModel):
    """Moduleitemsequencenode Model."""

    def __init__(self, prev=None, current=None, next=None, mastery_path=None):
        """Init method for Moduleitemsequencenode class."""
        self._prev = prev
        self._current = current
        self._next = next
        self._mastery_path = mastery_path

        self.logger = logging.getLogger("py3canvas.Moduleitemsequencenode")

    @property
    def prev(self):
        """The previous ModuleItem in the sequence."""
        return self._prev

    @prev.setter
    def prev(self, value):
        """Setter for prev property."""
        self.logger.warn(
            "Setting values on prev will NOT update the remote Canvas instance."
        )
        self._prev = value

    @property
    def current(self):
        """The ModuleItem being queried."""
        return self._current

    @current.setter
    def current(self, value):
        """Setter for current property."""
        self.logger.warn(
            "Setting values on current will NOT update the remote Canvas instance."
        )
        self._current = value

    @property
    def next(self):
        """The next ModuleItem in the sequence."""
        return self._next

    @next.setter
    def next(self, value):
        """Setter for next property."""
        self.logger.warn(
            "Setting values on next will NOT update the remote Canvas instance."
        )
        self._next = value

    @property
    def mastery_path(self):
        """The conditional release rule for the module item, if applicable."""
        return self._mastery_path

    @mastery_path.setter
    def mastery_path(self, value):
        """Setter for mastery_path property."""
        self.logger.warn(
            "Setting values on mastery_path will NOT update the remote Canvas instance."
        )
        self._mastery_path = value

class Moduleitemsequence(BaseModel):
    """Moduleitemsequence Model."""

    def __init__(self, items=None, modules=None):
        """Init method for Moduleitemsequence class."""
        self._items = items
        self._modules = modules

        self.logger = logging.getLogger("py3canvas.Moduleitemsequence")

    @property
    def items(self):
        """an array containing one ModuleItemSequenceNode for each appearence of the asset in the module sequence (up to 10 total)."""
        return self._items

    @items.setter
    def items(self, value):
        """Setter for items property."""
        self.logger.warn(
            "Setting values on items will NOT update the remote Canvas instance."
        )
        self._items = value

    @property
    def modules(self):
        """an array containing each Module referenced above."""
        return self._modules

    @modules.setter
    def modules(self, value):
        """Setter for modules property."""
        self.logger.warn(
            "Setting values on modules will NOT update the remote Canvas instance."
        )
        self._modules = value


text:
def add_string(tbl, words):
  '''
  Add the string of words to the table.  The first two words are the key and
  the third is appended to a list containing all words following the first
  two.

  Parameters:
    tbl: dictionary
      The dictionary to which the new entiry will be added.

    words: list
      The sequence of words to be added to the dictionary.
  '''

  key = ' '.join([words[0], words[1]])
  if key in tbl:
    lst = tbl[key][:]
    lst.append(words[2])
    tbl[key] = lst
  else:
    tbl[key] = [words[2]]

  return tbl

def gen_table(filename, tbl={}):
  '''
  Generate a table of three-word strings from a learning text.

  Parameters:
    filename: string
      Name of the file containing the learning text.

    tbl: dictionary, optional
      A dictionary to append the new learning text to.

  Returns:
    tbl: list
      A dictionary in which two words index the third in a consecutive
      string.
  '''

  # We will store the data as a dictionary.  The dictionary is indexed by
  # the first two words of a three word string.  The entry is a list
  # composed of the set of all words following the first two words.

  # First read the entire file into memory and generate a list containing
  # all words in order.
  with open(filename) as infile:
    lst = []
    for line in infile:
      words = line.split()
      for word in words:
        lst.append(word.strip())

  # Now generate the dictionary.
  for i in range(len(lst)-2):
    tbl = add_string(tbl, lst[i:i+3])
  return tbl

def markvshaney(tbl, maxwords=500, maxchar=80):
  '''
  Run the Mark V. Shanney algorithm given a table three word strings and
  print out a given number of words of random text.  The code will exceed
  the given number in order to complete a sentence.

  Parameters:
    tbl: dictionary
      A table indexed by two word strings that returns a list containing all
      possible third words following the first two.

    maxwords: int, optional
      The number of words of text to generate.  The code will exceed this
      number to complete a sentence.

    maxchar: int, optional
      The maximum number of characters of text to print to a line.

  Returns:
    Prints text
  '''

  import random
  nwords = 0
  nchar = 0

  # Start with a random key
  key = random.choice(tbl.keys())
  while not key.istitle():
    key = random.choice(tbl.keys())
  while (nwords <= maxwords) or (word3[-1] != '.'):
    word1, word2 = key.split()
    word3 = random.choice(tbl[key])

    nchar += len(word1) + 1
    if nchar >= maxchar:
      print
      nchar = len(word1) + 1
    print word1,
    nwords += 1

    key = ' '.join([word2, word3])

  print word2, word3,

if __name__ == '__main__':
  tbl = gen_table('iliad.txt')
  markvshaney(tbl)


text:
namespace Apache.Ignite.Core.Impl.Binary
{
    using System.Collections.Generic;
    using Apache.Ignite.Core.Binary;
    using Apache.Ignite.Core.Impl.Binary.Metadata;

    /// <summary>
    /// Binary processor.
    /// </summary>
    internal interface IBinaryProcessor
    {
        /// <summary>
        /// Gets metadata for specified type.
        /// </summary>
        BinaryType GetBinaryType(int typeId);

        /// <summary>
        /// Gets metadata for all known types.
        /// </summary>
        List<IBinaryType> GetBinaryTypes();

        /// <summary>
        /// Gets the schema.
        /// </summary>
        int[] GetSchema(int typeId, int schemaId);

        /// <summary>
        /// Put binary types to Grid.
        /// </summary>
        /// <param name="types">Binary types.</param>
        void PutBinaryTypes(ICollection<BinaryType> types);

        /// <summary>
        /// Registers the type.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="typeName">The type name.</param>
        /// <returns>True if registration succeeded; otherwise, false.</returns>
        bool RegisterType(int id, string typeName);

        /// <summary>
        /// Registers the enum.
        /// </summary>
        /// <param name="typeName">Name of the type.</param>
        /// <param name="values">The values.</param>
        /// <returns>Resulting binary type.</returns>
        BinaryType RegisterEnum(string typeName, IEnumerable<KeyValuePair<string, int>> values);

        /// <summary>
        /// Gets the type name by id.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>Type or null.</returns>
        string GetTypeName(int id);
    }
}


text:
class CreateEvents < ActiveRecord::Migration
  def change
    create_table :events do |t|
      t.integer :competition_id
      t.text :description
      t.timestamps
    end
  end
end


text:
Region

<panel title="Regions" brand="primary">

          <link-button label="New Region" brand="success" routerLink="/region/new"></link-button>

                  Name

                  Description

                 {{item.name}}

            {{item.description}}

</panel>


text:
using System;

namespace Solid.Arduino.Firmata
{
    /// <summary>
    /// Provides extension methods for <see cref="byte"/> arrays.
    /// </summary>
    public static class ByteArrayExtensions
    {
        /// <summary>
        /// Converts a <see cref="byte"/> array holding binary coded digits to a readable string.
        /// </summary>
        /// <param name="data">The binary coded digit bytes</param>
        /// <param name="isLittleEndian">Value indicating if the first nibble contains the least significant part</param>
        /// <returns>A string containing numeric data</returns>
        /// <exception cref="ArgumentException">The array contains one or more non-BCD bytes.</exception>
        public static string ConvertBinaryCodedDecimalToString(this byte[] data, bool isLittleEndian = false)
        {
            if (data is null)
                throw new ArgumentNullException(nameof(data));

            if (data.Length == 0)
                return string.Empty;

            char[] chars = new char[data.Length * 2];
            int charIndex = 0;

            if (isLittleEndian)
            {
                for (int x = data.Length - 1; x >= 0; x--)
                {
                    chars[charIndex++] = ConvertToChar(data[x] & 0x0F);
                    chars[charIndex++] = ConvertToChar(data[x] >> 4);
                }
            }
            else
            {
                for (int x = 0; x < data.Length; x++)
                {
                    chars[charIndex++] = ConvertToChar(data[x] >> 4);
                    chars[charIndex++] = ConvertToChar(data[x] & 0x0F);
                }
            }

            return new string(chars);
        }

        private static char ConvertToChar(int code)
        {
            if (code > 9)
                throw new ArgumentException(Messages.ArgumentEx_CannotConvertBcd);

            return Convert.ToChar(code | 0x30);
        }
    }
}


text:
=====
Table
=====

Operation
=========

.. *Define the Operation and point to the applicable algorithm for implementation of this Operation, by following this convention:*

--------------------------

:Operation name: Table
.. :Algorithm name: *XXX*
.. :Algorithm reference: *XXX*
:Description: This Operations serves for displaying of tables.
:Utilised in: :doc:`../uc_workflows/uc09_workflow`,  :doc:`../uc_workflows/uc06_workflow`

--------------------------

Options
=======

.. *Describe options regarding the use of the Operation.*

--------------------------

:name: table settings
:description: settings for the table
:settings: row-wise, column-wise, header, ...

---------------------------------

Input data
==========

.. *Describe all input data (except for parameters) here, following this convention:*

--------------------------

:name: longitude (lon, x)
:type: floating point number
:range: [-180.; +180.] respectively [0.; 360.]
:dimensionality: vector
:description: grid information on longitudes

--------------------------

:name: latitude (lat, y)
:type: floating point number
:range: [-90.; +90.]
:dimensionality: vector
:description: grid information on latitudes

--------------------------

:name: height (z)
:type: floating point number
:range: [-infinity; +infinity]
:dimensionality: vector
:description: grid information on height/depth

-----------------------------

:name: variable(s)
:type: floating point number
:range: [-infinity; +infinity]
:dimensionality: cube or 4D
:description: values of (a) certain variable(s)

-----------------------------

:name: time (steps)
:type: integer or double
:range: [0; +infinity]
:dimensionality: vector
:description: days/months since ...

-----------------------------

Output data
===========

.. *Description of anticipated output data.*

--------------------------------

:name: table
:type: table
:description: displays a table (see Options_)

---------------------------------

Parameters
==========

.. *Define applicable parameters here. A parameter differs from an input in that it has a default value. Parameters are often used to control certain aspects of the algorithm behavior.*

--------------------------

:name: start date
:type: *double?*
:valid values: *[1; infinity]*
:default value: first time step defined by input data
:description: first step of time period to be employed

--------------------------

:name: end date
:type: *double?*
:valid values: *[1; infinity]*
:default value: last time step defined by input data
:description: last step of time period to be employed

--------------------------

:name: lon, x (longitudinal position)
:type: floating point number
:valid values: [-180.; +180.] resp. [0.; 360.]
:default value: -
:description: longitudinal coordinate of point of interest

--------------------------

:name: lat, y (latitudinal position)
:type: floating point number
:valid values: [-90.; +90.]
:default value: -
:description: latitudinal coordinate of point of interest

---------------------------------

:name: lon1, x1 (longitudinal position)
:type: floating point number
:valid values: [-180.; +180.] respectively [0.; 360.]
:default value: minimum longitude of input data
:description: longitudinal coordinate limiting rectangular area of interest

--------------------------

:name: lon2, x2 (longitudinal position)
:type: floating point number
:valid values: [-180.; +180.] resp. [0.; 360.]
:default value: maximum longitude of input data
:description: longitudinal coordinate limiting rectangular area of interest

--------------------------

:name: lat1, y1 (latitudinal position)
:type: floating point number
:valid values: [-90.; +90.]
:default value: minimum latitude of input data
:description: latitudinal coordinate limiting rectangular area of interest

--------------------------

:name: lat2, y2 (latitudinal position)
:type: floating point number
:valid values: [-90.; +90.]
:default value: maximum latitude of input data
:description: latitudinal coordinate limiting rectangular area of interest

-----------------------------

.. Computational complexity
.. ==============================

.. *Describe how the algorithm memory requirement and processing time scale with input size. Most algorithms should be linear or in n*log(n) time, where n is the number of elements of the input.*

.. --------------------------

.. :time: *Time complexity*
.. :memory: *Memory complexity*

.. --------------------------

.. Convergence
.. ===========

.. *If the algorithm is iterative, define the criteria for the algorithm to stop processing and return a value. Describe the behavior of the algorithm if the convergence criteria are never reached.*

.. Known error conditions
.. ======================

.. *If there are combinations of input data that can lead to the algorithm failing, describe here what they are and how the algorithm should respond to this. For example, by logging a message*

.. Example
.. =======

.. *If there is a code example (Matlab, Python, etc) available, provide it here.*

.. ::

..     for a in [5,4,3,2,1]:   # this is program code, shown as-is
..         print a
..     print "it's..."
..     # a literal block continues until the indentation ends


text:
This document describes the installation of the GifyBox on a Raspberry PI. After installing the operating system, some additional steps are required.

## Display Orientation

With the newest Raspian versions, you can no longer change the display orientation using the `/boot/config.txt` file but have to do it with the `xrand` command.

```console
$ xrandr --output HDMI-1 --rotate inverted
```

Afterwards you can persist the setting in the display settings of the user interface.

## Enable the Camera

If you use the standard Raspberry PI camera, you have to enable it in the configuration of the computer.

Start the configuration program:

```console
$ sudo raspi-config
```

Open the *Interfacing Options* and enable the legacy camera.

## Enable Neopixel

The GifyBox uses Neopixel stripes for the visualization of the process.

Due to the fact that the library used for the Neopixel control (`rpi_ws281x`) uses some internal circuits of the computer, which are part of the audio interface, you have to disable the audio interface to enable the Neopixels.

Create a file `/etc/modprobe.d/snd-blacklist.conf` with the following content `blacklist snd_bcm2835`.

```console
$ sudo echo "blacklist snd_bcm2835" > /etc/modprobe.d/snd-blacklist.conf
```

### Raspberry PI 3

If your are using a Raspberry PI 3, the serial interface is not readily available, but you need to change some configuration options. The reason is that the Bluetooth chip uses the same UART component. Therefore, you have to disable Bluetooth to gain access to the RS232 port on `/dev/serial0`.

Please add the following lines to the end of the file `/boot/config.txt`:

```console
dtoverlay=disable-bt
core_freq=250
enable_uart=1
```

Additionally, modify the file `/boot/cmdline.txt` and remove the serial console. If you do not remove it, the Raspberry will open a console on the freshly gained RS232 port, and you cannot use it for the printer.

The file may look like this:

```console
console=serial0,115200 console=tty1 root=PARTUUID=e8fef0a8-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
```

Delete the `console=serial0,115200` part to free the serial interface. After the removal the file looks like this:

```console
console=tty1 root=PARTUUID=e8fef0a8-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
```

Please keep in mind that you should not copy this line directly into your `cmdline.txt` because it contains information about the boot device. This may render your Raspberry PI unusable.

## Install additional packages

Install the following packages:

* build-essential
* git
* scons
* swig
* viewnior
* graphicsmagick

```console
$ sudo apt update
$ sudo apt install build-essential git scons swig viewnior graphicsmagick
```

Install the required Python packages:

* qrcode
* imagio
* pyserial
* requests
* Pillow
* rpi_ws281x

```console
$ sudo pip install qrcode[pil] imageio pyserial requests Pillow rpi_ws281x
```

## Install the GifyBox software

Install the software from the GitHub repository.

```console
$ cd
$ git clone https://github.com/informatik-mannheim/gify-box.git
```

The software client must be run as *root* to have access to the hardware, therefore you can use the starter script in the main directory of the project. Although, it is for the client only, we placed it there to make running the client as easy as possible.

Start the software on the box:

```
$ cd gify-box
$ ./launcher.sh
```

# Prevent Display Blanking

By default, the display will be turned off after a few moments. You won't notice this when the preview is open, because it overlays the blank screen somehow. But the replay of the GIF does not work. So we need to address and fix that.

Turing of the display blanking is done automatically by the [start script](../../launcher.sh). If you want to do it manually, enter the following two commands into the terminal:

```console
xset s off
xset -dpms
```