parent
f00ac3585b
commit
794734e008
After Width: | Height: | Size: 565 B |
@ -0,0 +1,37 @@ |
||||
body { |
||||
font-size: 25px; |
||||
line-height: 1.25em !important; |
||||
text-align: justify; |
||||
-webkit-touch-callout: none; |
||||
-webkit-user-select: none; |
||||
-khtml-user-select: none; |
||||
-moz-user-select: none; |
||||
-ms-user-select: none; |
||||
user-select: none; |
||||
} |
||||
|
||||
.text-highlight { |
||||
-webkit-transition: color .3s linear, text-shadow .3s linear; |
||||
-khtml-transition: color .3s linear, text-shadow .3s linear; |
||||
-moz-transition: color .3s linear, text-shadow .3s linear; |
||||
-ms-transition: color .3s linear, text-shadow .3s linear; |
||||
transition: color .3s linear, text-shadow .3s linear; |
||||
} |
||||
|
||||
.text-highlight.active { |
||||
color: red; |
||||
-webkit-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1); |
||||
-khtml-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1); |
||||
-moz-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1); |
||||
-ms-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1); |
||||
text-shadow: 0px 0px 1px rgba(255, 0, 0, 1); |
||||
-webkit-transition: color .3s linear, text-shadow .3s linear; |
||||
-khtml-transition: color .3s linear, text-shadow .3s linear; |
||||
-moz-transition: color .3s linear, text-shadow .3s linear; |
||||
-ms-transition: color .3s linear, text-shadow .3s linear; |
||||
transition: color .3s linear, text-shadow .3s linear; |
||||
} |
||||
|
||||
br { |
||||
margin-bottom: 1em; |
||||
} |
@ -0,0 +1,79 @@ |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
$(function () { |
||||
var parent$ = window.parent.$, |
||||
$player = parent$('audio#lp_audio_media_player_html5'); |
||||
|
||||
if ($player.length === 0) { |
||||
$player = parent$('audio#lp_audio_media_player'); |
||||
} |
||||
|
||||
var player = $player.get(0), |
||||
def = $.Deferred(); |
||||
|
||||
if (!$player.length) { |
||||
processText(wordsCount); |
||||
|
||||
return; |
||||
} |
||||
|
||||
player.preload = 'auto'; |
||||
|
||||
function processText(turns) { |
||||
var tagEnd = '</span> ', |
||||
tagStart = tagEnd + '<span class="text-highlight">', |
||||
wordsPerSecond = Math.ceil(wordsCount / turns); |
||||
|
||||
var indexes = Object.keys(words); |
||||
|
||||
var output = ''; |
||||
|
||||
for (var i = 0; i < turns; i++) { |
||||
var block = indexes.slice(i * wordsPerSecond, i * wordsPerSecond + wordsPerSecond), |
||||
index = block[0]; |
||||
|
||||
if (!index) { |
||||
continue; |
||||
} |
||||
|
||||
output += tagStart + words[index]; |
||||
|
||||
for (var j = 1; j < block.length; j++) { |
||||
index = block[j]; |
||||
output += ' ' + words[index]; |
||||
} |
||||
} |
||||
|
||||
output += tagEnd; |
||||
output = output.slice(tagEnd.length); |
||||
|
||||
$('.page-blank').html(output); |
||||
|
||||
def.resolve(output); |
||||
|
||||
return def.promise(); |
||||
} |
||||
|
||||
player.ontimeupdate = function () { |
||||
var block = Math.ceil(this.currentTime); |
||||
|
||||
$('.text-highlight') |
||||
.removeClass('active') |
||||
.filter(function (index) { |
||||
return index + 1 == block; |
||||
}) |
||||
.addClass('active'); |
||||
}; |
||||
player.onloadedmetadata = function () { |
||||
var turns = Math.ceil(this.duration); |
||||
|
||||
processText(turns) |
||||
.then(function (output) { |
||||
var to = window.setTimeout(function () { |
||||
player.play(); |
||||
|
||||
window.clearTimeout(to); |
||||
}, 1500); |
||||
}); |
||||
} |
||||
}); |
@ -0,0 +1,75 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Print a highlighted document inside a session |
||||
* |
||||
* @package chamilo.learnpath |
||||
*/ |
||||
|
||||
use Chamilo\CourseBundle\Entity\CDocument; |
||||
|
||||
$_in_course = true; |
||||
|
||||
require_once __DIR__.'/../inc/global.inc.php'; |
||||
|
||||
$current_course_tool = TOOL_LEARNPATH; |
||||
|
||||
api_protect_course_script(true); |
||||
|
||||
$id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
||||
$lpId = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : 0; |
||||
$courseInfo = api_get_course_info(); |
||||
$courseCode = $courseInfo['code']; |
||||
$courseId = $courseInfo['real_id']; |
||||
$userId = api_get_user_id(); |
||||
$sessionId = api_get_session_id(); |
||||
|
||||
$em = Database::getManager(); |
||||
$documentRepo = $em->getRepository('ChamiloCourseBundle:CDocument'); |
||||
|
||||
// This page can only be shown from inside a learning path |
||||
if (!$id && !$lpId) { |
||||
api_not_allowed(true); |
||||
exit; |
||||
} |
||||
|
||||
/** @var CDocument $document */ |
||||
$document = $documentRepo->findOneBy(['cId' => $courseId, 'iid' => $id]); |
||||
|
||||
if (empty($document)) { |
||||
// Try with normal id |
||||
/** @var CDocument $document */ |
||||
$document = $documentRepo->findOneBy(['cId' => $courseId, 'id' => $id]); |
||||
|
||||
if (empty($document)) { |
||||
Display::return_message(get_lang('FileNotFound'), 'error'); |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
$documentPathInfo = pathinfo($document->getPath()); |
||||
$jplayer_supported_files = ['mp4', 'ogv', 'flv', 'm4v']; |
||||
$extension = isset($documentPathInfo['extension']) ? $documentPathInfo['extension'] : ''; |
||||
|
||||
$coursePath = api_get_path(SYS_COURSE_PATH).$courseInfo['directory']; |
||||
$documentPath = '/document'.$document->getPath(); |
||||
$documentText = file_get_contents($coursePath.$documentPath); |
||||
$documentText = api_remove_tags_with_space($documentText); |
||||
|
||||
$words = array_map( |
||||
function ($word) { |
||||
return nl2br($word); |
||||
}, |
||||
str_word_count($documentText, 2, '0..9'."\n") |
||||
); |
||||
|
||||
$htmlHeadXtra[] = '<script> |
||||
var words = '.json_encode($words, JSON_OBJECT_AS_ARRAY).', |
||||
wordsCount = '.count($words).' |
||||
</script>'; |
||||
$htmlHeadXtra[] = api_get_js('highlighted_document/js/start.js'); |
||||
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_JS_PATH).'highlighted_document/css/start.css'); |
||||
|
||||
$template = new Template(strip_tags($document->getTitle())); |
||||
$template->display_blank_template(); |
Loading…
Reference in new issue