PageRenderTime 61ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/oauth/lti/cert/cert_util.php

https://github.com/supungs/AContent
PHP | 1027 lines | 1001 code | 23 blank | 3 comment | 30 complexity | ad7aae8230e0887f42e7a77d40c4804b MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, MIT, AGPL-1.0
  1. <?php
  2. function get_current_date() {
  3. global $current_date;
  4. if ( isset($current_date) ) return $current_date;
  5. $current_date = gmDate("Y-m-d\TH:i:s\Z");
  6. return $current_date;
  7. }
  8. function load_cert_data() {
  9. global $requests;
  10. global $passed;
  11. global $failed;
  12. global $notes;
  13. global $errors;
  14. global $mapping;
  15. if ( ! is_array($requests) ) $requests = $_SESSION['requests'];
  16. if ( ! is_array($requests) ) $requests = array();
  17. if ( ! is_array($passed) ) $passed = $_SESSION['passed'];
  18. if ( ! is_array($passed) ) $passed = array();
  19. if ( ! is_array($failed) ) $failed = $_SESSION['failed'];
  20. if ( ! is_array($failed) ) $failed = array();
  21. if ( ! is_array($notes) ) $notes = $_SESSION['notes'];
  22. if ( ! is_array($notes) ) $notes = array();
  23. if ( ! is_array($errors) ) $errors = $_SESSION['errors'];
  24. if ( ! is_array($errors) ) $errors = array();
  25. // (resource_link_id, user_id, context_id, roles)
  26. if ( ! is_array($mapping) ) $mapping = $_SESSION['mapping'];
  27. if ( ! is_array($mapping) ) $mapping = array();
  28. }
  29. function update_cert_data() {
  30. global $requests;
  31. global $passed;
  32. global $failed;
  33. global $notes;
  34. global $errors;
  35. global $mapping;
  36. global $_SESSION;
  37. ksort($requests);
  38. $_SESSION['requests'] = $requests;
  39. ksort($passed);
  40. $_SESSION['passed'] = $passed;
  41. ksort($failed);
  42. $_SESSION['failed'] = $failed;
  43. ksort($notes);
  44. $_SESSION['notes'] = $notes;
  45. ksort($errors);
  46. $_SESSION['errors'] = $errors;
  47. ksort($mapping);
  48. $_SESSION['mapping'] = $mapping;
  49. }
  50. function mark_pass($test, $msg) {
  51. global $passed;
  52. global $thispass;
  53. load_cert_data();
  54. $thispass[$test] = array(get_current_date(), $msg);
  55. if ( ! isset($passed[$test]) ) {
  56. $passed[$test] = array(get_current_date(), $msg);
  57. }
  58. }
  59. function mark_fail($test, $msg) {
  60. global $failed;
  61. global $thisfail;
  62. load_cert_data();
  63. $thisfail[$test] = array(get_current_date(), $msg);
  64. if ( ! isset($failed[$test]) ) {
  65. $failed[$test] = array(get_current_date(), $msg);
  66. }
  67. }
  68. function doerror($msg) {
  69. global $errors;
  70. load_cert_data();
  71. echo("<p>\n");
  72. echo($msg);
  73. echo("</p>\n");
  74. $reqdebug = print_r($_REQUEST, true);
  75. $errors[get_current_date()] = $reqdebug;
  76. update_cert_data();
  77. }
  78. $cert_lms_text = array(
  79. "1.0" => array("Protocol Compliance and Resource Information", "doc", ""),
  80. "1.1" => array("All messages have required parameters", "",
  81. "All messages require lti_version, lti_message_type, and resource_link_id"),
  82. "1.2" => array("Sends resource_link_title", "pass",
  83. "A title for the resource. This is the clickable text that appears in the link. This parameter is recommended."),
  84. "1.3" => array("Sends resource_link_description", "pass",
  85. "A plain text description of the link’s destination, suitable for display alongside the link. Typically no more than several lines long. This parameter is optional."),
  86. "1.4" => array("Sends tool_consumer_info_product_family_code", "", "Indicates the vendor of the calling LMS (LTI 1.1). This parameter is optional."),
  87. "1.5" => array("Sends tool_consumer_info_version", "", "Indicates the version of the calling LMS (LTI 1.1). This parameter is optional."),
  88. "2.0" => array("OAuth and Signing Requests", "doc", ""),
  89. "2.1" => array("Sign with a producer-provided secret and oauth_consumer_key", "", ""),
  90. "2.2" => array("Can sign requests with URL parameters", "", ""),
  91. "2.3" => array("Can sign a request with a URL parameter with space in the value parameter", "",
  92. "This checks for the presense of a parameter x=With%20Space since some OAuth reference ".
  93. "implementations (i.e. C#) implementations have problems encoding special characters in ".
  94. "URL parameters - so a space in a URL parameter should be %2520 ".
  95. "in the base message string - not %20." .
  96. "While this seems like double-encoding, it is how OAuth works."),
  97. "2.4" => array("Must include oauth_callback for OAuth 1.0A compliance", "fail",
  98. "Even though oauth_callback is not needed by LTI, it should be included ".
  99. "and set to 'about:blank' so that OAuth library code such as the OAuth for perl ".
  100. "properly can check LTI Signatures."),
  101. "3.0" => array("Custom Field Support", "doc", ""),
  102. "3.1" => array("Can send custom fields", "",
  103. "Send this custom field <b>simple_key=custom_simple_value</b>\n"),
  104. "3.2" => array("Properly maps special characters and case in custom fields", "",
  105. "The LTI spec forces all characters in key names to lower case and ".
  106. "maps anything that is not a number or letter to an underscore.".
  107. "Send this field: <b>Complex!@#$^*(){}[]KEY=Complex!@#$^*(){}[]Value</b>\n"),
  108. "4.0" => array("User Information", "doc", ""),
  109. "4.1" => array("Sends a user_id", "" , ""),
  110. "4.2" => array("Sends Learner role", "" ,
  111. "The simplest practice is to simply send either the Learner or Instructor role ".
  112. " or to at least include the Instructor or Learner role with no urn prefix ".
  113. " as one of the comma-separated values. Very simplistic tools will simply ".
  114. " split the role string based on commas and ".
  115. " look for 'Instructor' as one of roles and treat ".
  116. " all other roles as 'Learner'"),
  117. "4.3" => array("Sends Instructor role", "" ,
  118. "The simplest practice is to simply send either the Learner or Instructor role ".
  119. " or to at least include the Instructor or Learner role with no urn prefix ".
  120. " as one of the comma-separated values. Very simplistic tools will simply ".
  121. " split the role string based on commas and ".
  122. " look for 'Instructor' as one of roles and treat ".
  123. " all other roles as 'Learner'"),
  124. "4.4" => array("Follows role naming rules.", "fail",
  125. "Roles is a comma-separated list of URN values for roles. If this ".
  126. "list is non-empty, it should contain at least one role from the ".
  127. "listed role vocabularies (See Appendix A). Context roles such ".
  128. "as 'Learner' or 'Instructor' do not need the 'urn:' prefix. ".
  129. "If the TC wants to include a role from another namespace, ".
  130. "a fully-qualified URN should be used. Usage of roles from ".
  131. "non-LIS vocabularies is discouraged as it may limit interoperability. ".
  132. "This test fails if a non-standard role is present without a 'urn:' ".
  133. "prefix."
  134. ),
  135. "4.5" => array("Sends request a valid name for the user and email", "",
  136. "We define a valid name as either lis_person_name_full or both lis_person_name_family and lis_person_name_given."),
  137. "4.6" => array("Sends request with only lis_person_contact_email_primary but no name information", "", ""),
  138. "4.7" => array("Sends valid user name information but no email address", "",
  139. "We define a valid name as either lis_person_name_full or both lis_person_name_family and lis_person_name_given."),
  140. "4.8" => array("Can suppress all identifiable user information", "" ,
  141. "This request should not include any of: ".
  142. "lis_person_name_family, lis_person_name_given or lis_person_name_full."),
  143. "5.0" => array("Context support", "doc", ""),
  144. "5.1" => array("Can send a context_id.", "", ""),
  145. "5.2" => array("Can send a context_label.", "", ""),
  146. "5.3" => array("Can send a context_title.", "", ""),
  147. "5.4" => array("Can send a request without a context_id", "pass",
  148. "This would happen if the LMS used LTI to launch a tool from outside ".
  149. "a course - for example, in a menu in the LMS"),
  150. "5.5" => array("Can send a context_type.", "pass", ""),
  151. "5.6" => array("Follows context_type rules.", "fail",
  152. "This string is a comma-separated list of URN values that ".
  153. "identify the type of context. At a minimum, the list MUST ".
  154. "include a URN value drawn from the LIS vocabulary (see Appendix A). ".
  155. "The assumed namespace of these URNs is the LIS vocabulary so ".
  156. "TCs can use the handles when the intent is to refer to an ".
  157. "LIS context type. If the TC wants to include a context type ".
  158. "from another namespace, a fully-qualified URN should be used."
  159. ),
  160. "6.0" => array("Multiple Requests and Consistency", "doc",
  161. "This section looks across multiple requests for things we want to see ".
  162. "and things we do not want to see."),
  163. "6.1" => array("Send message from a second resource_link_id", "", ""),
  164. "6.2" => array("Sends a different user_id", "", ""),
  165. "6.3" => array("Can send a different context_id", "", ""),
  166. "6.4" => array("Can send multiple resource_link_id values with the same context_id", "pass",
  167. "This test is looking for multiple placements in a single course. This is optional ".
  168. "and very much depends on features in the LMS."),
  169. "6.5" => array("A resource_link_id never moves from one context_id to another", "fail",
  170. "This is technically possible in general but should not happen during a short test."),
  171. "6.6" => array("Consistency of context_id/user_id/role mappings", "fail",
  172. "For all the requests, a user should have the same role in the same context. ".
  173. "This test fails if we see a user's role change from request to request in a context. ".
  174. "This is technically possible in general but should not happen during a short test."),
  175. "7.0" => array("Launch Support", "doc", "This section is optional."),
  176. "7.1" => array("Sends valid launch_presentation_locale", "", ""),
  177. "7.2" => array("If launch_presentation_document_target is valid", "pass", ""),
  178. "7.3" => array("If launch_presentation_width is present, it is valid", "pass",
  179. "This must be a positive integer."),
  180. "7.4" => array("If launch_presentation_height is present, it is valid", "pass",
  181. "This must be a positive integer."),
  182. "8.0" => array("LTI 1.1: Suport for Outcomes Service", "doc",
  183. "This section verifies proper support for returning grades back to the consumer."),
  184. "8.1" => array("Sends lis_result_sourcedid and lis_outcome_service_url", "", ""),
  185. "8.2" => array("Outcomes Service supports replaceResult operation", "", ""),
  186. "8.3" => array("Outcomes Service supports readResult operation and returns the proper value", "", ""),
  187. "8.4" => array("Outcomes Service supports deleteResult operation", "", ""),
  188. "8.5" => array("Result is properly deleted after deleteResult operation", "", ""),
  189. "8.6" => array("Outcomes Service properly handles unsupported operations", "",
  190. "This should response with a imsx_codeMajor of unsupported"),
  191. "8.7" => array("replaceResult does not accept out of range values", "",
  192. "This should response with a imsx_codeMajor of failure"),
  193. "8.8" => array("replaceResult does not accept invalid values", "",
  194. "This should response with a imsx_codeMajor of failure"),
  195. );
  196. ksort($cert_lms_text);
  197. $tool_tests = array(
  198. "001" => array(
  199. "doc" => "Launch in SI182 as Instructor",
  200. "detail" => "This user has all user information specified.",
  201. "result" => "Should have Instructor powers to edit as appropriate",
  202. "parms" => array(
  203. "resource_link_id" => "rli-1234",
  204. "user_id" => "123456",
  205. "roles" => "Instructor", // or Learner
  206. "lis_person_name_full" => 'Jane Q. Lastname',
  207. "lis_person_name_given" => 'Jane',
  208. "lis_person_name_family" => 'Lastname',
  209. "lis_person_contact_email_primary" => "jane@school.edu",
  210. "lis_person_sourcedid" => "school.edu:jane",
  211. "context_id" => "con-182",
  212. "context_title" => "Design of Personal Environments",
  213. "context_label" => "SI182",
  214. "context_type" => "CourseSection",
  215. "launch_presentation_locale" => "en_US",
  216. )
  217. ),
  218. "002" => array(
  219. "doc" => "Launch in SI182 as Learner",
  220. "detail" => "This user has all user information specified.",
  221. "result" => "Should not have Instructor powers",
  222. "parms" => array(
  223. "resource_link_id" => "rli-1234",
  224. "user_id" => "654321",
  225. "roles" => "Learner", // or Learner
  226. "lis_person_name_full" => 'Bob R. Person',
  227. "lis_person_name_given" => 'Bob',
  228. "lis_person_name_family" => 'Person',
  229. "lis_person_contact_email_primary" => "bob@school.edu",
  230. "lis_person_sourcedid" => "school.edu:bob",
  231. "context_id" => "con-182",
  232. "context_title" => "Design of Personal Environments",
  233. "context_label" => "SI182",
  234. "context_type" => "CourseSection",
  235. "launch_presentation_locale" => "en_US",
  236. )
  237. ),
  238. "003" => array(
  239. "doc" => "Second resource in SI182 as Instructor",
  240. "detail" => "This test changes the resource_link_id without changing context_id",
  241. "result" => "Should have Instructor power but there should be a new instance ".
  242. "of the tool but still in the same course.",
  243. "parms" => array(
  244. "resource_link_id" => "rli-5678",
  245. "user_id" => "123456",
  246. "roles" => "Instructor", // or Learner
  247. "lis_person_name_full" => 'Jane Q. Lastname',
  248. "lis_person_name_given" => 'Jane',
  249. "lis_person_name_family" => 'Lastname',
  250. "lis_person_contact_email_primary" => "jane@school.edu",
  251. "lis_person_sourcedid" => "school.edu:jane",
  252. "context_id" => "con-182",
  253. "context_title" => "Design of Personal Environments",
  254. "context_label" => "SI182",
  255. "context_type" => "CourseSection",
  256. "launch_presentation_locale" => "en_US",
  257. )
  258. ),
  259. // Test privacy options
  260. "004" => array(
  261. "doc" => "SI301 as Instructor with max privacy.",
  262. "detail" => "This starts a series of tests that explore data that may be suppressed ".
  263. "based on the settings in the LMS that control privacy. ".
  264. "A new user and new course but no identifying information. So ".
  265. "lis_person_name_full, lis_person_name_family, lis_person_name_given, ".
  266. "lis_person_contact_email_primary are not sent. The tool should *not* ".
  267. "use the email address as primary key - only the combination of ".
  268. "oauth_consumer_key and user_id. All of the lis_ data needs to be ".
  269. "informative only.",
  270. "result" => "This should work and the user should have Instructor power ".
  271. "but there should be no user name or e-mail info.",
  272. "parms" => array(
  273. "resource_link_id" => "rli-1000",
  274. "user_id" => "user-1000",
  275. "roles" => "Instructor", // or Learner
  276. // "lis_person_name_full" => 'Jane Q. Lastname',
  277. // "lis_person_name_given" => 'Jane',
  278. // "lis_person_name_family" => 'Lastname',
  279. // "lis_person_contact_email_primary" => "jane@school.edu",
  280. // "lis_person_sourcedid" => "school.edu:jane",
  281. "context_id" => "con-301",
  282. "context_title" => "Social Computing",
  283. "context_label" => "SI301",
  284. "context_type" => "CourseSection",
  285. "launch_presentation_locale" => "en_US",
  286. )
  287. ),
  288. "005" => array(
  289. "doc" => "SI301 as Learner with E-Mail but no name.",
  290. "detail" => "A new user where only the lis_person_contact_email_primary is sent.",
  291. "result" => "The tool should deal with the lack of name information.",
  292. "parms" => array(
  293. "resource_link_id" => "rli-1000",
  294. "user_id" => "user-1001",
  295. "roles" => "Learner", // or Learner
  296. // "lis_person_name_full" => 'Jane Q. Lastname',
  297. // "lis_person_name_given" => 'Jane',
  298. // "lis_person_name_family" => 'Lastname',
  299. "lis_person_contact_email_primary" => "user1001@school.edu",
  300. "context_id" => "con-301",
  301. "context_title" => "Social Computing",
  302. "context_label" => "SI301",
  303. "context_type" => "CourseSection",
  304. "launch_presentation_locale" => "en_US",
  305. )
  306. ),
  307. "006" => array(
  308. "doc" => "SI301 as Learner with given/family but no full name.",
  309. "detail" => "A tool should tolerate receiving the given and family names but not the full name.",
  310. "result" => "The tool should detect the user's name properly.",
  311. "parms" => array(
  312. "resource_link_id" => "rli-1000",
  313. "user_id" => "user-1002",
  314. "roles" => "Learner", // or Learner
  315. // "lis_person_name_full" => 'Jane Q. Lastname',
  316. "lis_person_name_given" => 'User1002',
  317. "lis_person_name_family" => 'Learnername',
  318. // "lis_person_contact_email_primary" => "user1001@school.edu",
  319. "context_id" => "con-301",
  320. "context_title" => "Social Computing",
  321. "context_label" => "SI301",
  322. "context_type" => "CourseSection",
  323. "launch_presentation_locale" => "en_US",
  324. )
  325. ),
  326. "007" => array(
  327. "doc" => "SI301 as Learner with full but not given/family name.",
  328. "detail" => "A tool should tolerate receiving the full name but not given or family names.",
  329. "result" => "The tool should detect the user's name properly.",
  330. "parms" => array(
  331. "resource_link_id" => "rli-1000",
  332. "user_id" => "user-1003",
  333. "roles" => "Learner", // or Learner
  334. "lis_person_name_full" => 'User1003 Q. Learnername',
  335. // "lis_person_name_given" => 'User1002',
  336. // "lis_person_name_family" => 'Learnername',
  337. // "lis_person_contact_email_primary" => "user1001@school.edu",
  338. "context_id" => "con-301",
  339. "context_title" => "Social Computing",
  340. "context_label" => "SI301",
  341. "context_type" => "CourseSection",
  342. "launch_presentation_locale" => "en_US",
  343. )
  344. ),
  345. // Test different ways of specifying roles
  346. "008" => array(
  347. "doc" => "SI131 as fully-qualified Instructor urn",
  348. "detail" => "This starts a series of tests that will send the Instructor ".
  349. "role for a series of users using various legal syntax options. ".
  350. "This starts a new course and new resource.".
  351. " urn:lti:role:ims/lis/Instructor",
  352. "result" => "The user should have Instructor privilege.",
  353. "parms" => array(
  354. "resource_link_id" => "rli-6789",
  355. "user_id" => "user-2001",
  356. "roles" => "urn:lti:role:ims/lis/Instructor", // or Learner
  357. "lis_person_name_full" => 'User2001 Q. Lastname',
  358. "lis_person_contact_email_primary" => "user2001@school.edu",
  359. "context_id" => "con-131",
  360. "context_title" => "Movies, Culture, and Technology",
  361. "context_label" => "SI131",
  362. "context_type" => "CourseSection",
  363. "launch_presentation_locale" => "en_US",
  364. )
  365. ),
  366. "009" => array(
  367. "doc" => "SI131 with a role where Instructor is in a list",
  368. "detail" => "urn:non:ims/something/Else,Instructor,urn:lti:instrole:ims/lis/Alumni",
  369. "result" => "The user should have Instructor privilege.",
  370. "parms" => array(
  371. "resource_link_id" => "rli-6789",
  372. "user_id" => "user-2002",
  373. "roles" => "urn:non:ims/something/Else,Instructor,urn:lti:instrole:ims/lis/Alumni",
  374. "lis_person_name_full" => 'User2002 Q. Lastname',
  375. "lis_person_contact_email_primary" => "user2002@school.edu",
  376. "context_id" => "con-131",
  377. "context_title" => "Movies, Culture, and Technology",
  378. "context_label" => "SI131",
  379. "context_type" => "CourseSection",
  380. "launch_presentation_locale" => "en_US",
  381. )
  382. ),
  383. "010" => array(
  384. "doc" => "SI131 where full urn Instructor is in a list",
  385. "detail" => "urn:non:ims/something/Else,urn:lti:role:ims/lis/Instructor,urn:lti:instrole:ims/lis/Alumni",
  386. "result" => "The user should have Instructor privilege.",
  387. "parms" => array(
  388. "resource_link_id" => "rli-6789",
  389. "user_id" => "user-2003",
  390. "roles" => "urn:non:ims/something/Else,urn:lti:role:ims/lis/Instructor,urn:lti:instrole:ims/lis/Alumni",
  391. "lis_person_name_full" => 'User2003 Q. Lastname',
  392. "lis_person_contact_email_primary" => "user2003@school.edu",
  393. "context_id" => "con-131",
  394. "context_title" => "Movies, Culture, and Technology",
  395. "context_label" => "SI131",
  396. "context_type" => "CourseSection",
  397. "launch_presentation_locale" => "en_US",
  398. )
  399. ),
  400. "011" => array(
  401. "doc" => "SI131 where full urn Learner is in a list",
  402. "detail" => "urn:non:ims/something/Else,urn:lti:role:ims/lis/Learner,urn:lti:instrole:ims/lis/Alumni",
  403. "result" => "The user should have Learner privilege.",
  404. "parms" => array(
  405. "resource_link_id" => "rli-6789",
  406. "user_id" => "user-2004",
  407. "roles" => "urn:non:ims/something/Else,urn:lti:role:ims/lis/Learner,urn:lti:instrole:ims/lis/Alumni",
  408. "lis_person_name_full" => 'User2004 Q. Lastname',
  409. "lis_person_contact_email_primary" => "user2004@school.edu",
  410. "context_id" => "con-131",
  411. "context_title" => "Movies, Culture, and Technology",
  412. "context_label" => "SI131",
  413. "context_type" => "CourseSection",
  414. "launch_presentation_locale" => "en_US",
  415. )
  416. ),
  417. "012" => array(
  418. "doc" => "Launch in SI182 as Instructor 999999 providing grade service info.",
  419. "detail" => "A graded resource, launched as instructor.",
  420. "result" => "This allows an instructor to set up the resource before student launch if necessary. It is not necessary to send grades back for non-students.",
  421. "parms" => array(
  422. "resource_link_id" => "rlig-1234",
  423. "user_id" => "999999",
  424. "roles" => "Instructor", // or Learner
  425. "lis_person_name_full" => 'Instruct R. Person',
  426. "lis_person_name_given" => 'Instruct',
  427. "lis_person_name_family" => 'Person',
  428. "lis_person_contact_email_primary" => "instruct@school.edu",
  429. "lis_person_sourcedid" => "school.edu:instruct",
  430. "lis_outcome_service_url" => "replaceme",
  431. "context_id" => "con-182",
  432. "context_title" => "Design of Personal Environments",
  433. "context_label" => "SI182",
  434. "context_type" => "CourseSection",
  435. "launch_presentation_locale" => "en_US",
  436. )
  437. ),
  438. "013" => array(
  439. "doc" => "Launch in SI182 as Learner 654321 providing grade service info.",
  440. "detail" => "You can test the replace, read, and delete operations, monitoring the
  441. grade book as you progress to make sure things are working, but when you leave this
  442. test, make sure that you have a grade set.",
  443. "result" => "A grade should appear in the gradebook for user 654321 if the application sends grades based on learner action.",
  444. "parms" => array(
  445. "resource_link_id" => "rlig-1234",
  446. "user_id" => "654321",
  447. "roles" => "Learner", // or Learner
  448. "lis_person_name_full" => 'Bob R. Person',
  449. "lis_person_name_given" => 'Bob',
  450. "lis_person_name_family" => 'Person',
  451. "lis_person_contact_email_primary" => "bob@school.edu",
  452. "lis_person_sourcedid" => "school.edu:bob",
  453. "lis_outcome_service_url" => "replaceme",
  454. "context_id" => "con-182",
  455. "context_title" => "Design of Personal Environments",
  456. "context_label" => "SI182",
  457. "context_type" => "CourseSection",
  458. "launch_presentation_locale" => "en_US",
  459. )
  460. ),
  461. "014" => array(
  462. "doc" => "Launch in SI182 from the same resource as in test 012 as Learner 543216 providing grade service info.",
  463. "detail" => "Make sure to set a grade for this launch to pass the grade feature.",
  464. "result" => "A grade should appear in the gradebook for user 543216 in the same resource as test 012 if the application sends grades based on learner action",
  465. "parms" => array(
  466. "resource_link_id" => "rlig-1234",
  467. "user_id" => "543216",
  468. "roles" => "Learner", // or Learner
  469. "lis_person_name_full" => 'Sally R. Person',
  470. "lis_person_name_given" => 'Sally',
  471. "lis_person_name_family" => 'Person',
  472. "lis_person_contact_email_primary" => "sally@school.edu",
  473. "lis_person_sourcedid" => "school.edu:sally",
  474. "lis_outcome_service_url" => "replaceme",
  475. "context_id" => "con-182",
  476. "context_title" => "Design of Personal Environments",
  477. "context_label" => "SI182",
  478. "context_type" => "CourseSection",
  479. "launch_presentation_locale" => "en_US",
  480. )
  481. ),
  482. "015" => array(
  483. "doc" => "Re-Launch in SI182 as Instructor 999999 providing grade service info.",
  484. "detail" => "Make sure to set a grade for this launch to pass the grade feature.",
  485. "result" => "A second grade should appear in the grade book for user 654321 and 543216 if the application sends grades based on instructor action",
  486. "parms" => array(
  487. "resource_link_id" => "rlig-1234",
  488. "user_id" => "999999",
  489. "roles" => "Instructor", // or Learner
  490. "lis_person_name_full" => 'Instruct R. Person',
  491. "lis_person_name_given" => 'Instruct',
  492. "lis_person_name_family" => 'Person',
  493. "lis_person_contact_email_primary" => "instruct@school.edu",
  494. "lis_person_sourcedid" => "school.edu:instruct",
  495. "lis_outcome_service_url" => "replaceme",
  496. "context_id" => "con-182",
  497. "context_title" => "Design of Personal Environments",
  498. "context_label" => "SI182",
  499. "context_type" => "CourseSection",
  500. "launch_presentation_locale" => "en_US",
  501. )
  502. ),
  503. "016" => array(
  504. "doc" => "Launch in SI182 as Instructor 999999 in second resource providing grade service info.",
  505. "detail" => "A graded resource, launched as instructor.",
  506. "result" => "This allows an instructor to set up the resource before student launch if necessary. It is not necessary to send grades back for non-students.",
  507. "parms" => array(
  508. "resource_link_id" => "rlig-2341",
  509. "user_id" => "999999",
  510. "roles" => "Instructor", // or Learner
  511. "lis_person_name_full" => 'Instruct R. Person',
  512. "lis_person_name_given" => 'Instruct',
  513. "lis_person_name_family" => 'Person',
  514. "lis_person_contact_email_primary" => "instruct@school.edu",
  515. "lis_person_sourcedid" => "school.edu:instruct",
  516. "lis_outcome_service_url" => "replaceme",
  517. "context_id" => "con-182",
  518. "context_title" => "Design of Personal Environments",
  519. "context_label" => "SI182",
  520. "context_type" => "CourseSection",
  521. "launch_presentation_locale" => "en_US",
  522. )
  523. ),
  524. "017" => array(
  525. "doc" => "Launch different resource in SI182 as Learner 654321 providing grade service info.",
  526. "detail" => "Make sure to set a grade for this launch to pass the grade feature.",
  527. "result" => "A third grade should appear in the gradebook for user 654321 with a new resource id and the same course id if the application sends grades based on learner action.",
  528. "parms" => array(
  529. "resource_link_id" => "rlig-2341",
  530. "user_id" => "654321",
  531. "roles" => "Learner", // or Learner
  532. "lis_person_name_full" => 'Bob R. Person',
  533. "lis_person_name_given" => 'Bob',
  534. "lis_person_name_family" => 'Person',
  535. "lis_person_contact_email_primary" => "bob@school.edu",
  536. "lis_person_sourcedid" => "school.edu:bob",
  537. "lis_outcome_service_url" => "replaceme",
  538. "context_id" => "con-182",
  539. "context_title" => "Design of Personal Environments",
  540. "context_label" => "SI182",
  541. "context_type" => "CourseSection",
  542. "launch_presentation_locale" => "en_US",
  543. )
  544. ),
  545. "018" => array(
  546. "doc" => "Re-Launch in SI182 as Instructor 999999 in second resource providing grade service info.",
  547. "detail" => "Make sure to set a grade for this launch to pass the grade feature.",
  548. "result" => "A second grade should appear in the gradebook for user 543216 if the application sends grades based on instructor action",
  549. "parms" => array(
  550. "resource_link_id" => "rlig-2341",
  551. "user_id" => "999999",
  552. "roles" => "Instructor", // or Learner
  553. "lis_person_name_full" => 'Instruct R. Person',
  554. "lis_person_name_given" => 'Instruct',
  555. "lis_person_name_family" => 'Person',
  556. "lis_person_contact_email_primary" => "instruct@school.edu",
  557. "lis_person_sourcedid" => "school.edu:instruct",
  558. "lis_outcome_service_url" => "replaceme",
  559. "context_id" => "con-182",
  560. "context_title" => "Design of Personal Environments",
  561. "context_label" => "SI182",
  562. "context_type" => "CourseSection",
  563. "launch_presentation_locale" => "en_US",
  564. )
  565. ),
  566. "019" => array(
  567. "doc" => "Launch in GAM101 as Instructor 999999 in second resource providing grade service info.",
  568. "detail" => "A graded resource, launched as instructor.",
  569. "result" => "This allows an instructor to set up the resource before student launch if necessary. It is not necessary to send grades back for non-students.",
  570. "parms" => array(
  571. "resource_link_id" => "rlid-777",
  572. "user_id" => "999999",
  573. "roles" => "Instructor", // or Learner
  574. "lis_person_name_full" => 'Instruct R. Person',
  575. "lis_person_name_given" => 'Instruct',
  576. "lis_person_name_family" => 'Person',
  577. "lis_person_contact_email_primary" => "instruct@school.edu",
  578. "lis_person_sourcedid" => "school.edu:instruct",
  579. "lis_outcome_service_url" => "replaceme",
  580. "context_id" => "con-777",
  581. "context_title" => "Introduction to Gambling",
  582. "context_label" => "GAM101",
  583. "context_type" => "CourseSection",
  584. "launch_presentation_locale" => "en_US",
  585. )
  586. ),
  587. "020" => array(
  588. "doc" => "Launch different resource in GAM101 as Learner 777777 providing grade service info.",
  589. "detail" => "Make sure to set a grade for this launch to pass the grade feature.",
  590. "result" => "A grade should appear in the gradebook context_id=con-777, rlid=rlid-777, user_id=777777 if the application sends grades based on learner action",
  591. "parms" => array(
  592. "resource_link_id" => "rlid-777",
  593. "user_id" => "777777",
  594. "roles" => "Learner", // or Learner
  595. "lis_person_name_full" => 'Luck Y. Seven',
  596. "lis_person_name_given" => 'Luck',
  597. "lis_person_name_family" => 'Seven',
  598. "lis_person_contact_email_primary" => "seven@school.edu",
  599. "lis_person_sourcedid" => "school.edu:seven",
  600. "lis_outcome_service_url" => "replaceme",
  601. "context_id" => "con-777",
  602. "context_title" => "Introduction to Gambling",
  603. "context_label" => "GAM101",
  604. "context_type" => "CourseSection",
  605. "launch_presentation_locale" => "en_US",
  606. )
  607. ),
  608. "021" => array(
  609. "doc" => "Re-Launch in GAM101 as Instructor 999999 in second resource providing grade service info.",
  610. "detail" => "Make sure to set a grade for this launch to pass the grade feature.",
  611. "result" => "A grade should appear in the gradebook context_id=con-777, rlid=rlid-777, user_id=777777 if the application sends grades based on instructor action",
  612. "parms" => array(
  613. "resource_link_id" => "rlid-777",
  614. "user_id" => "999999",
  615. "roles" => "Instructor", // or Learner
  616. "lis_person_name_full" => 'Instruct R. Person',
  617. "lis_person_name_given" => 'Instruct',
  618. "lis_person_name_family" => 'Person',
  619. "lis_person_contact_email_primary" => "instruct@school.edu",
  620. "lis_person_sourcedid" => "school.edu:instruct",
  621. "lis_outcome_service_url" => "replaceme",
  622. "context_id" => "con-777",
  623. "context_title" => "Introduction to Gambling",
  624. "context_label" => "GAM101",
  625. "context_type" => "CourseSection",
  626. "launch_presentation_locale" => "en_US",
  627. )
  628. ),
  629. // Minimal features - Slowly remove information
  630. "090" => array(
  631. "doc" => "Launch in SI502 as Instructor",
  632. "detail" => "This is a instructor user going into a new resource/context. ".
  633. "This starts a series of tests that provide less and less ".
  634. "information until we get to the minimum information. In ".
  635. "each test, we change the user_id.",
  636. "result" => "Should have Instructor powers to edit as appropriate",
  637. "parms" => array(
  638. "resource_link_id" => "rli-3000",
  639. "user_id" => "user-3000",
  640. "roles" => "Instructor",
  641. "lis_person_name_full" => 'User3000 Q. Lastname',
  642. "lis_person_contact_email_primary" => "User3000@school.edu",
  643. "context_id" => "con-502",
  644. "context_title" => "Networked Computing",
  645. "context_label" => "SI502",
  646. "context_type" => "CourseSection",
  647. "launch_presentation_locale" => "en_US",
  648. )
  649. ),
  650. "091" => array(
  651. "doc" => "Launch in SI502 as Instructor (remove name/email)",
  652. "detail" => "This is the same as 020 except we remove name/email",
  653. "result" => "Should have Instructor powers to edit as appropriate",
  654. "parms" => array(
  655. "resource_link_id" => "rli-3000",
  656. "user_id" => "user-3001",
  657. "roles" => "Instructor",
  658. "context_id" => "con-502",
  659. "context_title" => "Networked Computing",
  660. "context_label" => "SI502",
  661. "context_type" => "CourseSection",
  662. "launch_presentation_locale" => "en_US",
  663. )
  664. ),
  665. "092" => array(
  666. "doc" => "Launch in SI502 as Instructor (remove context info)",
  667. "detail" => "This removes all the context information except context_id",
  668. "result" => "Should have Instructor powers to edit as appropriate",
  669. "parms" => array(
  670. "resource_link_id" => "rli-3000",
  671. "user_id" => "user-3002",
  672. "roles" => "Instructor",
  673. "context_id" => "con-502",
  674. "launch_presentation_locale" => "en_US",
  675. )
  676. ),
  677. "093" => array(
  678. "doc" => "Launch as Instructor with no context_id",
  679. "detail" => "This has no context information.",
  680. "result" => "The tool should do something reasonable. This may cause the tool to indicate an error and transfer back to the LMS.",
  681. "parms" => array(
  682. "resource_link_id" => "rli-3000",
  683. "user_id" => "user-3003",
  684. "roles" => "Instructor",
  685. "launch_presentation_locale" => "en_US",
  686. )
  687. ),
  688. "094" => array(
  689. "doc" => "Launch SI502 with no roles",
  690. "detail" => "This removes the roles but keeps context_id",
  691. "result" => "The user should get the lowest level of privilege.",
  692. "parms" => array(
  693. "resource_link_id" => "rli-3000",
  694. "user_id" => "user-3004",
  695. "context_id" => "con-502",
  696. "launch_presentation_locale" => "en_US",
  697. )
  698. ),
  699. "095" => array(
  700. "doc" => "Launch with no roles and no context",
  701. "detail" => "This only has a resource_link_id, user_id, and locale",
  702. "result" => "The tool should do something reasonable.",
  703. "parms" => array(
  704. "resource_link_id" => "rli-3000",
  705. "user_id" => "user-3005",
  706. "launch_presentation_locale" => "en_US",
  707. )
  708. ),
  709. "096" => array(
  710. "doc" => "Launch with only resource_link_id",
  711. "detail" => "This is the absolute minimum launch.",
  712. "result" => "The tool should do something reasonable (i.e. have a decent error message).",
  713. "parms" => array(
  714. "resource_link_id" => "rli-3000",
  715. )
  716. ),
  717. // A Completely Broken launch
  718. "099" => array(
  719. "doc" => "Send a completely broken launch.",
  720. "detail" => "Send a completely broken launch.",
  721. "result" => "This should trigger a call back to the launch_presentation_return_url if the Tool supports it.",
  722. "parms" => array(
  723. "resourcelinkid" => "rli-3000",
  724. )
  725. ),
  726. );
  727. ksort($tool_tests);
  728. $valid_post = Array(
  729. "lti_message_type",
  730. "lti_version",
  731. "resource_link_id",
  732. "resource_link_title",
  733. "resource_link_description",
  734. "user_id",
  735. "user_image",
  736. "roles",
  737. "lis_person_name_given",
  738. "lis_person_name_family",
  739. "lis_person_name_full",
  740. "lis_person_contact_email_primary",
  741. "lis_result_sourcedid",
  742. "lis_outcome_service_url",
  743. "tool_consumer_info_product_family_code",
  744. "tool_consumer_info_version",
  745. "context_id",
  746. "context_type",
  747. "context_title",
  748. "context_label",
  749. "launch_presentation_locale",
  750. "launch_presentation_document_target",
  751. "launch_presentation_width",
  752. "launch_presentation_height",
  753. "launch_presentation_return_url",
  754. "launch_presentation_css_url",
  755. "tool_consumer_instance_guid",
  756. "tool_consumer_instance_name",
  757. "tool_consumer_instance_description",
  758. "tool_consumer_instance_url",
  759. "tool_consumer_instance_contact_email",
  760. "oauth_consumer_key",
  761. "oauth_signature_method",
  762. "oauth_timestamp",
  763. "oauth_nonce",
  764. "oauth_version",
  765. "oauth_signature",
  766. "oauth_callback",
  767. "lis_person_sourcedid",
  768. "lis_course_offering_sourcedid",
  769. "lis_course_section_sourcedid",
  770. "lis_result_sourcedid",
  771. "basiclti_submit" // Just to be nice :)
  772. );
  773. $valid_roles = Array(
  774. "urn:lti:role:ims/lis/Learner",
  775. "urn:lti:role:ims/lis/Learner/Learner",
  776. "urn:lti:role:ims/lis/Learner/NonCreditLearner",
  777. "urn:lti:role:ims/lis/Learner/GuestLearner",
  778. "urn:lti:role:ims/lis/Learner/ExternalLearner",
  779. "urn:lti:role:ims/lis/Learner/Instructor",
  780. "urn:lti:role:ims/lis/Instructor",
  781. "urn:lti:role:ims/lis/Instructor/PrimaryInstructor",
  782. "urn:lti:role:ims/lis/Instructor/Lecturer",
  783. "urn:lti:role:ims/lis/Instructor/GuestInstructor",
  784. "urn:lti:role:ims/lis/Instructor/ExternalInstructor",
  785. "urn:lti:role:ims/lis/ContentDeveloper",
  786. "urn:lti:role:ims/lis/ContentDeveloper/ContentDeveloper",
  787. "urn:lti:role:ims/lis/ContentDeveloper/Librarian",
  788. "urn:lti:role:ims/lis/ContentDeveloper/ContentExpert",
  789. "urn:lti:role:ims/lis/ContentDeveloper/ExternalContentExpert",
  790. "urn:lti:role:ims/lis/Member",
  791. "urn:lti:role:ims/lis/Member/Member",
  792. "urn:lti:role:ims/lis/Manager",
  793. "urn:lti:role:ims/lis/Manager/AreaManager",
  794. "urn:lti:role:ims/lis/Manager/CourseCoordinator",
  795. "urn:lti:role:ims/lis/Manager/Observer",
  796. "urn:lti:role:ims/lis/Manager/ExternalObserver",
  797. "urn:lti:role:ims/lis/Mentor",
  798. "urn:lti:role:ims/lis/Mentor/Mentor",
  799. "urn:lti:role:ims/lis/Mentor/Reviewer",
  800. "urn:lti:role:ims/lis/Mentor/Advisor",
  801. "urn:lti:role:ims/lis/Mentor/Auditor",
  802. "urn:lti:role:ims/lis/Mentor/Tutor",
  803. "urn:lti:role:ims/lis/Mentor/LearningFacilitator",
  804. "urn:lti:role:ims/lis/Mentor/ExternalMentor",
  805. "urn:lti:role:ims/lis/Mentor/ExternalReviewer",
  806. "urn:lti:role:ims/lis/Mentor/ExternalAdvisor",
  807. "urn:lti:role:ims/lis/Mentor/ExternalAuditor",
  808. "urn:lti:role:ims/lis/Mentor/ExternalTutor",
  809. "urn:lti:role:ims/lis/Mentor/ExternalLearningFacilitator",
  810. "urn:lti:role:ims/lis/Administrator",
  811. "urn:lti:role:ims/lis/Administrator/Administrator",
  812. "urn:lti:role:ims/lis/Administrator/Support",
  813. "urn:lti:role:ims/lis/Administrator/ExternalDeveloper",
  814. "urn:lti:role:ims/lis/Administrator/SystemAdministrator",
  815. "urn:lti:role:ims/lis/Administrator/ExternalSystemAdministrator",
  816. "urn:lti:role:ims/lis/Administrator/ExternalDeveloper",
  817. "urn:lti:role:ims/lis/Administrator/ExternalSupport",
  818. "urn:lti:role:ims/lis/TeachingAssistant",
  819. "urn:lti:role:ims/lis/TeachingAssistant/TeachingAssistant",
  820. "urn:lti:role:ims/lis/TeachingAssistant/TeachingAssistantSection",
  821. "urn:lti:role:ims/lis/TeachingAssistant/TeachingAssistantSectionAssociation",
  822. "urn:lti:role:ims/lis/TeachingAssistant/TeachingAssistantOffering",
  823. "urn:lti:role:ims/lis/TeachingAssistant/TeachingAssistantTemplate",
  824. "urn:lti:role:ims/lis/TeachingAssistant/TeachingAssistantGroup",
  825. "urn:lti:role:ims/lis/TeachingAssistant/Grader",
  826. "urn:lti:sysrole:ims/lis/SysAdmin",
  827. "urn:lti:sysrole:ims/lis/SysSupport",
  828. "urn:lti:sysrole:ims/lis/Creator",
  829. "urn:lti:sysrole:ims/lis/AccountAdmin",
  830. "urn:lti:sysrole:ims/lis/User",
  831. "urn:lti:sysrole:ims/lis/Administrator",
  832. "urn:lti:sysrole:ims/lis/None",
  833. "urn:lti:instrole:ims/lis/Student",
  834. "urn:lti:instrole:ims/lis/Faculty",
  835. "urn:lti:instrole:ims/lis/Member",
  836. "urn:lti:instrole:ims/lis/Learner",
  837. "urn:lti:instrole:ims/lis/Instructor",
  838. "urn:lti:instrole:ims/lis/Mentor",
  839. "urn:lti:instrole:ims/lis/Staff",
  840. "urn:lti:instrole:ims/lis/Alumni",
  841. "urn:lti:instrole:ims/lis/ProspectiveStudent",
  842. "urn:lti:instrole:ims/lis/Guest",
  843. "urn:lti:instrole:ims/lis/Other",
  844. "urn:lti:instrole:ims/lis/Administrator",
  845. "urn:lti:instrole:ims/lis/Observer",
  846. "urn:lti:instrole:ims/lis/None",
  847. );
  848. $valid_types = array(
  849. "urn:lti:context-type:ims/lis/CourseTemplate",
  850. "urn:lti:context-type:ims/lis/CourseOffering",
  851. "urn:lti:context-type:ims/lis/CourseSection",
  852. "urn:lti:context-type:ims/lis/Group",
  853. );
  854. /*
  855. urn:lti:sysrole:ims/lis/SysAdmin
  856. urn:lti:instrole:ims/lis/Staff
  857. urn:lti:role:ims/lis/Learner (Context Role)
  858. Learner (Assume Context Role)
  859. */
  860. // Breaks roles by comman and removes whitespace
  861. function split_string($rolestr) {
  862. $x = explode(",",$rolestr);
  863. $pieces = array();
  864. foreach ($x as $key => $value) {
  865. $pieces[$key] = trim($value);
  866. }
  867. return $pieces;
  868. }
  869. function instructor_or_learner($rolestr) {
  870. $pieces = split_string($rolestr);
  871. foreach ($pieces as $key => $value) {
  872. if ( strpos($value, 'Instructor' ) === 0 ) return 'Instructor';
  873. if ( strpos($value, 'urn:lti:role:ims/lis/Instructor' ) === 0 ) return 'Instructor';
  874. }
  875. foreach ($pieces as $key => $value) {
  876. if ( strpos($value, 'Learner' ) === 0 ) return 'Learner';
  877. if ( strpos($value, 'urn:lti:role:ims/lis/Learner' ) === 0 ) return 'Learner';
  878. }
  879. return false;
  880. }
  881. // Tests
  882. // print_r(instructor_or_learner("Learner, Instructor ,urn:ok:non:standard/Role, Fred,urn:lti:role:ims/lis/Learner"));
  883. // print_r(instructor_or_learner("Instructor,urn:ok:non:standard/Role,urn:lti:role:ims/lis/Learner"));
  884. // print_r(instructor_or_learner("urn:ok:non:standard/Role,urn:lti:role:ims/lis/Learner"));
  885. // print_r(instructor_or_learner("ContentDeveloper"));
  886. // Returns an array of errors - no errors returns a zero length array
  887. function check_roles($rolestr) {
  888. global $valid_roles;
  889. $pieces = split_string($rolestr);
  890. $notes = array();
  891. $stdrole = 0;
  892. foreach ($pieces as $key => $value) {
  893. if ( in_array($value, $valid_roles) or
  894. in_array('urn:lti:role:ims/lis/'.$value, $valid_roles) ) {
  895. $stdrole = $stdrole + 1;
  896. // print "Good ".$value."\n";
  897. } else if ( strpos($value, "urn:" ) === 0 ) {
  898. // print "OK WITH URN ".$value."\n";
  899. } else {
  900. // print "Bad ".$value."\n";
  901. $notes[$value] = "Non-standard roles must be fully-qualified urns";
  902. }
  903. }
  904. if ($stdrole == 0 ) {
  905. $notes[] = "Must include at least one standard role";
  906. }
  907. return $notes;
  908. }
  909. // Tests
  910. // print_r(check_roles("Learner, Instructor ,urn:ok:non:standard/Role, Fred,urn:lti:role:ims/lis/Learner"));
  911. // print_r(check_roles("urn:not:ok:needs:one:standard/Role"));
  912. // print_r(check_roles("ContentDeveloper"));
  913. // Returns an array of errors - no errors returns a zero length array
  914. function check_types($typestr) {
  915. global $valid_types;
  916. $pieces = split_string($typestr);
  917. $notes = array();
  918. $stdtype = 0;
  919. foreach ($pieces as $key => $value) {
  920. if ( in_array($value, $valid_types) or
  921. in_array('urn:lti:context-type:ims/lis/'.$value, $valid_types) ) {
  922. $stdtype = $stdtype + 1;
  923. // print "Good ".$value."\n";
  924. } else if ( strpos($value, "urn:" ) === 0 ) {
  925. // print "OK WITH URN ".$value."\n";
  926. } else {
  927. // print "Bad ".$value."\n";
  928. $notes[$value] = "Non-standard types must be fully-qualified urns";
  929. }
  930. }
  931. if ($stdtype == 0 ) {
  932. $notes[] = "Must include at least one standard type";
  933. }
  934. return $notes;
  935. }
  936. // Returns an array of POST parameters that are not allowed
  937. function check_post(){
  938. global $valid_post;
  939. $badpost = Array();
  940. foreach ($_POST as $key => $value) {
  941. if ( $key == 'x' ) continue; // In case they sneak in...
  942. if ( $key == 'y' ) continue; // In case they sneak in...
  943. if ( strpos($key,'custom_') === 0 ) continue;
  944. if ( strpos($key,'ext_') === 0 ) continue;
  945. if ( in_array($key, $valid_post) ) continue;
  946. $badpost[] = $key;
  947. }
  948. return $badpost;
  949. }
  950. // Reset the session retaining the official value
  951. function lti_reset_session() {
  952. $official = $_SESSION['ims:official'];
  953. session_unset();
  954. if ( strlen($official) > 0 ) $_SESSION['ims:official'] = $official;
  955. }
  956. // Tests
  957. // print_r(check_types("ContentDeveloper"));
  958. // print_r(check_types("CourseSection"));
  959. // print_r(check_types("urn:ok:non:standard/Type,urn:lti:context-type:ims/lis/CourseSection"));
  960. ?>