Skip to content

Commit d99b4e6

Browse files
committed
Merge pull request #49 from ucfcdl/UDOIT_issue39
Udoit issue39
2 parents 1b22733 + 2f509cd commit d99b4e6

File tree

6 files changed

+15
-69
lines changed

6 files changed

+15
-69
lines changed

assets/js/default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ function loader(text) {
6161
/* Builds up the results and adds them to the page */
6262
function checker() {
6363
var main_action = $('input[name="main_action"]').val();
64+
var base_url = $('input[name="base_url"]').val();
6465
var course_id = $('input[name="session_course_id"]').val();
6566
var context_label = $('input[name="session_context_label"]').val();
6667
var context_title = $('input[name="session_context_title"]').val();
@@ -77,6 +78,7 @@ function checker() {
7778
type: "POST",
7879
data: {
7980
main_action: main_action,
81+
base_url: base_url,
8082
content: content,
8183
course_id: course_id,
8284
context_label: context_label,
@@ -272,6 +274,7 @@ $(document).ready(function() {
272274
var values = $(this).serializeArray();
273275
var errorsRemaining = -1;
274276

277+
values.push({ name: 'base_url', value: $('input[name="base_url"]').val() });
275278
values.push({ name: 'course_id', value: $('input[name="session_course_id"]').val() });
276279
values.push({ name: 'context_label', value: $('input[name="session_context_label"]').val() });
277280
values.push({ name: 'context_title', value: $('input[name="session_context_title"]').val() });

config/localConfig.template.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
header("Pragma: no-cache"); // HTTP 1.0.
55
header("Expires: 0"); // Proxies.
66

7-
/* This tests to see if the user came from something other than the URL of your LMS */
8-
$referer_test = '';
9-
10-
/* Set the path for the base directory (where the user will start choosing from) */
11-
$base_url = ''; // Without trailing slash
12-
137
/* Oauth 1.0 Settings (For use when installing the app in Canvas) */
148
$consumer_key = '';
159
$shared_secret = '';

index.php

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -28,63 +28,6 @@
2828
session_start();
2929
header('Content-Type: text/html; charset=utf-8');
3030

31-
if ( isset($_SERVER['HTTP_REFERER']) ) {
32-
if ( preg_match($referer_test, $_SERVER['HTTP_REFERER']) != 1) {
33-
?>
34-
<!DOCTYPE html>
35-
<html lang="en">
36-
<head>
37-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
38-
<title>UDOIT Accessibility Checker</title>
39-
<link rel="icon" type="image/png" href="favicon.ico">
40-
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
41-
<link href='//fonts.googleapis.com/css?family=Sonsie+One' rel='stylesheet' type='text/css'>
42-
<link href="assets/css/main.css?c=0" type="text/css" rel="stylesheet" media="screen">
43-
<link href="assets/css/print.css" type="text/css" rel="stylesheet" media="print">
44-
</head>
45-
<body>
46-
<div class="container">
47-
<header id="mainHeader" class="navbar navbar-default center">
48-
<h1 class="logo">UDOIT</h1>
49-
</header>
50-
<div class="alert alert-danger">
51-
<p><?= $error_msg_wrong_referrer ?></p>
52-
</div>
53-
</div>
54-
</body>
55-
</html>
56-
<?php
57-
die();
58-
}
59-
} else {
60-
?>
61-
<!DOCTYPE html>
62-
<html lang="en">
63-
<head>
64-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
65-
<title>UDOIT Accessibility Checker</title>
66-
<link rel="icon" type="image/png" href="favicon.ico">
67-
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
68-
<link href='//fonts.googleapis.com/css?family=Sonsie+One' rel='stylesheet' type='text/css'>
69-
<link href="assets/css/main.css" type="text/css" rel="stylesheet" media="screen">
70-
<link href="assets/css/print.css" type="text/css" rel="stylesheet" media="print">
71-
</head>
72-
<body>
73-
<div class="container">
74-
<header id="mainHeader" class="navbar navbar-default center">
75-
<h1 class="logo">UDOIT</h1>
76-
</header>
77-
<div class="alert alert-danger">
78-
<p><?= $error_msg_no_referrer ?></p>
79-
</div>
80-
</div>
81-
</body>
82-
</html>
83-
<?php
84-
die();
85-
}
86-
87-
8831
if (!isset($_SESSION['valid'])) {
8932
$_SESSION['valid'] = false;
9033
}
@@ -124,6 +67,9 @@
12467

12568
$redirect = true;
12669

70+
// Establish base_url given by canvas API
71+
$base_url = 'https://'.$_POST['custom_canvas_api_domain'].'/';
72+
12773
// Pull the API key from the database
12874
$dsn = "mysql:dbname=$db_name;host=$db_host";
12975

@@ -206,6 +152,7 @@
206152
</div>
207153
<form class="form-horizontal no-print" id="udoitForm" method="post" action="lib/process.php" role="form">
208154
<input type="hidden" name="main_action" value="udoit">
155+
<input type="hidden" name="base_url" value="https://<?php echo $_POST['custom_canvas_api_domain'] ?>/">
209156
<input type="hidden" name="session_course_id" value="<?php echo $_SESSION['launch_params']['custom_canvas_course_id'] ?>">
210157
<input type="hidden" name="session_context_label" value="<?php echo $_SESSION['launch_params']['context_label'] ?>">
211158
<input type="hidden" name="session_context_title" value="<?php echo $_SESSION['launch_params']['context_title'] ?>">

lib/Ufixit.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ public function fixAltText($error_html, $new_content, $submitting_again = false)
154154
*/
155155
public function fixCss($error_colors, $error_html, $new_content, $submitting_again = false)
156156
{
157-
$this->dom->loadHTML('<?xml encoding="utf-8" ?>' . $error_html);
158-
159157
$fixed_css = $error_html;
160158

161159
for ($i = 0; $i < count($error_colors); $i++) {
@@ -446,7 +444,7 @@ public function uploadFixedAssignments($corrected_error, $error_html)
446444
{
447445
$get_uri = $this->base_uri."/api/v1/courses/".$this->course_id."/assignments/".$this->content_id."?&access_token=".$this->api_key;
448446
$content = Request::get($get_uri)->send();
449-
$html = $content->body->description;
447+
$html = html_entity_decode($content->body->description);
450448

451449
$error_html = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $error_html), ['doctype' => 'html5']);
452450
$corrected_error = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $corrected_error), ['doctype' => 'html5']);
@@ -467,7 +465,7 @@ public function uploadFixedDiscussions($corrected_error, $error_html)
467465
{
468466
$get_uri = $this->base_uri."/api/v1/courses/".$this->course_id."/discussion_topics/".$this->content_id."?&access_token=".$this->api_key;
469467
$content = Request::get($get_uri)->send();
470-
$html = $content->body->message;
468+
$html = html_entity_decode($content->body->message);
471469

472470
$error_html = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $error_html), ['doctype' => 'html5']);
473471
$corrected_error = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $corrected_error), ['doctype' => 'html5']);
@@ -558,7 +556,7 @@ public function uploadFixedPages($corrected_error, $error_html)
558556
{
559557
$get_uri = $this->base_uri."/api/v1/courses/".$this->course_id."/pages/".$this->content_id."?access_token=".$this->api_key;
560558
$content = Request::get($get_uri)->send();
561-
$html = $content->body->body;
559+
$html = html_entity_decode($content->body->body);
562560

563561
$error_html = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $error_html), ['doctype' => 'html5']);
564562
$corrected_error = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $corrected_error), ['doctype' => 'html5']);
@@ -580,7 +578,7 @@ public function uploadFixedSyllabus($corrected_error, $error_html)
580578
{
581579
$get_uri = $this->base_uri."/api/v1/courses/".$this->course_id."/?include[]=syllabus_body&access_token=".$this->api_key;
582580
$content = Request::get($get_uri)->send();
583-
$html = $content->body->syllabus_body;
581+
$html = html_entity_decode($content->body->syllabus_body);
584582

585583
$error_html = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $error_html), ['doctype' => 'html5']);
586584
$corrected_error = HTMLMinify::minify(str_replace($this->annoying_entities, $this->entity_replacements, $corrected_error), ['doctype' => 'html5']);

lib/process.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
include 'Ufixit.php';
2525

2626
use Httpful\Request;
27+
$base_url = $_POST['base_url'];
2728
$SESSION_course_id = $_POST['course_id'];
2829
$SESSION_context_label = $_POST['context_label'];
2930
$SESSION_context_title = $_POST['context_title'];

udoit.xml.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
<lticm:property name="tool_id">udoit</lticm:property>
4242
<lticm:property name="privacy_level">public</lticm:property>
4343
<lticm:property name="domain"><?= $_SERVER['SERVER_NAME'] ?></lticm:property>
44+
<lticm:options name="custom_fields">
45+
<lticm:property name="canvas_api_domain">$Canvas.api.domain</lticm:property>
46+
</lticm:options>
4447
<lticm:options name="course_navigation">
4548
<lticm:property name="url"><?= $launch ?></lticm:property>
4649
<lticm:property name="default">enabled</lticm:property>

0 commit comments

Comments
 (0)