예제 #1
0
파일: Lessons.php 프로젝트: csev/tsugi-php
    public function renderSingle()
    {
        global $CFG;
        $module = $this->module;
        echo '<div style="float:right; padding-left: 5px; vertical-align: text-top;"><ul class="pager">' . "\n";
        $disabled = $this->position == 1 ? ' disabled' : '';
        if ($this->position == 1) {
            echo '<li class="previous disabled"><a href="#" onclick="return false;">&larr; Previous</a></li>' . "\n";
        } else {
            $prev = 'index=' . ($this->position - 1);
            if (isset($this->lessons->modules[$this->position - 2]->anchor)) {
                $prev = 'anchor=' . $this->lessons->modules[$this->position - 2]->anchor;
            }
            echo '<li class="previous"><a href="lessons.php?' . $prev . '">&larr; Previous</a></li>' . "\n";
        }
        echo '<li><a href="lessons.php">All (' . $this->position . ' / ' . count($this->lessons->modules) . ')</a></li>';
        if ($this->position >= count($this->lessons->modules)) {
            echo '<li class="next disabled"><a href="#" onclick="return false;">&rarr; Next</a></li>' . "\n";
        } else {
            $next = 'index=' . ($this->position + 1);
            if (isset($this->lessons->modules[$this->position]->anchor)) {
                $next = 'anchor=' . $this->lessons->modules[$this->position]->anchor;
            }
            echo '<li class="next"><a href="lessons.php?' . $next . '">&rarr; Next</a></li>' . "\n";
        }
        echo "</ul></div>\n";
        echo '<h1>' . $module->title . "</h1>\n";
        if (isset($module->videos)) {
            $videos = $module->videos;
            echo '<ul class="bxslider">' . "\n";
            foreach ($videos as $video) {
                echo '<li><iframe src="https://www.youtube.com/embed/' . $video->youtube . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen ' . ' alt="' . htmlentities($video->title) . '"></iframe>' . "\n";
            }
            echo "</ul>\n";
        }
        if (isset($module->description)) {
            echo '<p>' . $module->description . "</p>\n";
        }
        echo "<ul>\n";
        if (isset($module->slides)) {
            echo '<li><a href="' . $module->slides . '" target="_blank">Slides</a></li>' . "\n";
        }
        if (isset($module->chapters)) {
            echo '<li>Chapters: ' . $module->chapters . '</a></li>' . "\n";
        }
        if (isset($module->assignment)) {
            echo '<li><a href="' . $module->assignment . '" target="_blank">Assignment Specification</a></li>' . "\n";
        }
        if (isset($module->solution)) {
            echo '<li><a href="' . $module->solution . '" target="_blank">Assignment Solution</a></li>' . "\n";
        }
        if (isset($module->references)) {
            if (count($module->references) > 0) {
                echo "<li>References:<ul>\n";
                foreach ($module->references as $reference) {
                    echo '<li><a href="' . $reference->href . '" target="_blank">' . $reference->title . "</a></li>\n";
                }
                echo "</ul></li>\n";
            } else {
                echo '<li>Reference: <a href="' . $module->references->href . '" target="_blank">' . $module->references->title . "</a></li>\n";
            }
        }
        if (isset($module->lti) && isset($_SESSION['secret'])) {
            $ltis = $module->lti;
            if (count($ltis) > 1) {
                echo "<li>Tools:<ul> <!-- start of ltis -->\n";
            }
            $count = 0;
            foreach ($ltis as $lti) {
                $key = isset($_SESSION['oauth_consumer_key']) ? $_SESSION['oauth_consumer_key'] : false;
                $secret = isset($_SESSION['secret']) ? $_SESSION['secret'] : false;
                if (isset($lti->resource_link_id)) {
                    $resource_link_id = $lti->resource_link_id;
                } else {
                    $resource_link_id = 'resource:';
                    if ($this->anchor != null) {
                        $resource_link_id .= $this->anchor . ':';
                    }
                    if ($this->position != null) {
                        $resource_link_id .= $this->position . ':';
                    }
                    if ($count > 0) {
                        $resource_link_id .= '_' . $count;
                    }
                    $resource_link_id .= md5($CFG->context_title);
                }
                $count++;
                $resource_link_title = isset($lti->title) ? $lti->title : $module->title;
                $parms = array('lti_message_type' => 'basic-lti-launch-request', 'resource_link_id' => $resource_link_id, 'resource_link_title' => $resource_link_title, 'tool_consumer_info_product_family_code' => 'tsugi', 'tool_consumer_info_version' => '1.1', 'context_id' => $_SESSION['context_key'], 'context_label' => $CFG->context_title, 'context_title' => $CFG->context_title, 'user_id' => $_SESSION['user_key'], 'lis_person_name_full' => $_SESSION['displayname'], 'lis_person_contact_email_primary' => $_SESSION['email'], 'roles' => 'Learner');
                if (isset($_SESSION['avatar'])) {
                    $parms['user_image'] = $_SESSION['avatar'];
                }
                if (isset($lti->custom)) {
                    foreach ($lti->custom as $custom) {
                        if (isset($custom->value)) {
                            $parms['custom_' . $custom->key] = $custom->value;
                        }
                        if (isset($custom->json)) {
                            $parms['custom_' . $custom->key] = json_encode($custom->json);
                        }
                    }
                }
                $return_url = $CFG->getCurrentUrl();
                if ($this->anchor) {
                    $return_url .= '?anchor=' . urlencode($this->anchor);
                } elseif ($this->position) {
                    $return_url .= '?index=' . urlencode($this->position);
                }
                $parms['launch_presentation_return_url'] = $return_url;
                if (isset($_SESSION['tsugi_top_nav'])) {
                    $parms['ext_tsugi_top_nav'] = $_SESSION['tsugi_top_nav'];
                }
                $form_id = "tsugi_form_id_" . bin2Hex(openssl_random_pseudo_bytes(4));
                $parms['ext_lti_form_id'] = $form_id;
                $endpoint = $lti->launch;
                $parms = LTI::signParameters($parms, $endpoint, "POST", $key, $secret, "Finish Launch", $CFG->product_instance_guid, $CFG->servicename);
                $content = LTI::postLaunchHTML($parms, $endpoint, false, '_pause');
                $title = isset($lti->title) ? $lti->title : "Autograder";
                echo '<li><a href="#" onclick="document.' . $form_id . '.submit();return false">' . htmlentities($title) . '</a></li>' . "\n";
                echo "<!-- Start of content -->\n";
                print $content;
                echo "<!-- End of content -->\n";
            }
            if (count($ltis) > 1) {
                echo "</li></ul><!-- end of ltis -->\n";
            }
        }
        if (!isset($module->discuss)) {
            $module->discuss = true;
        }
        if (!isset($module->anchor)) {
            $module->anchor = $this->position;
        }
        // For now do not add disqus to each page.
        if (false && isset($CFG->disqushost) && isset($_SESSION['id']) && $module->discuss) {
            ?>
<hr/>
<div id="disqus_thread" style="margin-top: 30px;"></div>
<script>

/**
 *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
 *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables */
var disqus_config = function () {
    this.page.url = '<?php 
            echo $CFG->disqushost;
            ?>
';  // Replace PAGE_URL with your page's canonical URL variable
    this.page.identifier = '<?php 
            echo $module->anchor;
            ?>
'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
(function() { // DON'T EDIT BELOW THIS LINE
    var d = document, s = d.createElement('script');
    s.src = '//php-intro.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<?php 
        }
    }
예제 #2
0
        $script = isset($REGISTER_LTI2['script']) ? $REGISTER_LTI2['script'] : "index.php";
        $path = $CFG->wwwroot . '/' . str_replace("register.php", $script, $path);
        // Title is for the href and text is for display
        $json = LTI::getLtiLinkJSON($path, $title, $title, false, $fa_icon);
        $retval = json_encode($json);
        $parms = array();
        $parms["lti_message_type"] = "ContentItemSelection";
        $parms["lti_version"] = "LTI-1p0";
        $parms["content_items"] = $retval;
        $data = LTIX::postGet('data');
        if ($data) {
            $parms['data'] = $data;
        }
        $parms = LTIX::signParameters($parms, $result_url, "POST", "Install Tool");
        $endform = '<a href="index.php" class="btn btn-warning">Back to Store</a>';
        $content = LTI::postLaunchHTML($parms, $result_url, true, false, $endform);
        echo $content;
    } else {
        echo '<div style="border: 2px, solid, red;" class="card">';
        if ($fa_icon) {
            echo '<a href="index.php?install=' . urlencode($tool) . '">';
            echo '<i class="fa ' . $fa_icon . ' fa-2x" style="color: #1894C7; float:right; margin: 2px"></i>';
            echo '</a>';
        }
        echo '<p><strong>' . htmlent_utf8($title) . "</strong></p>";
        echo '<p>' . htmlent_utf8($text) . "</p>\n";
        echo '<center><a href="index.php?install=' . urlencode($tool) . '" class="btn btn-default" role="button">Details</a></center>';
        echo "</div>\n";
    }
    $toolcount++;
}
예제 #3
0
파일: dev.php 프로젝트: ixtel/tsugi
    echo "<br/>\n";
}
echo "</fieldset>\n";
echo "</div>\n";
echo "</form>\n";
$parms = $lmsdata;
// Cleanup parms before we sign
foreach ($parms as $k => $val) {
    if (strlen(trim($parms[$k])) < 1) {
        unset($parms[$k]);
    }
}
// Add oauth_callback to be compliant with the 1.0A spec
$parms["oauth_callback"] = "about:blank";
if ($outcomes) {
    $parms["lis_outcome_service_url"] = $outcomes;
}
$parms['launch_presentation_css_url'] = $cssurl;
if (isset($_POST['launch']) || isset($_POST['debug'])) {
    // Switch to direct launches instead of going through lti.php
    $endpoint = str_replace("lti.php", $_POST['custom_assn'], $endpoint);
    $parms = LTI::signParameters($parms, $endpoint, "POST", $key, $secret, "Finish Launch", $tool_consumer_instance_guid, $tool_consumer_instance_description);
    $content = LTI::postLaunchHTML($parms, $endpoint, isset($_POST['debug']), "width=\"100%\" height=\"900\" scrolling=\"auto\" frameborder=\"1\" transparency");
    echo "<hr>\n";
    print $content;
}
?>
      </div>
    </div> <!-- /container -->
<?php 
$OUTPUT->footer();
예제 #4
0
파일: LTIX.php 프로젝트: csev/tsugi-php
 /**
  * getLaunchContent - Get the launch data for am LTI ContentItem launch
  */
 public static function getLaunchContent($endpoint, $debug = false)
 {
     $info = LTIX::getKeySecretForLaunch($endpoint);
     if ($info === false) {
         return '<p style="color:red">Unable to load key/secret for ' . htmlentities($endpoint) . "</p>\n";
     }
     $key = $info['key'];
     $secret = $info['secret'];
     $parms = LTIX::getLaunchData();
     $parms = LTI::signParameters($parms, $endpoint, "POST", $key, $secret, "Button");
     $content = LTI::postLaunchHTML($parms, $endpoint, false);
     return $content;
 }