Example #1
0
 function addmedia($tpl = null)
 {
     $medias = $this->get('listaddmedia');
     if (isset($_GET['type']) && $_GET['type'] == 'audio') {
         foreach ($medias as $element) {
             $modal_task = new guruAdminModelguruTask();
             $element->prevw = $modal_task->parse_audio($element->id);
         }
     }
     $types = $this->get('distincttypes');
     $this->assignRef('types', $types);
     $this->assignRef('medias', $medias);
     $pagination = $this->get('Pagination');
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
Example #2
0
    if (isset($current) && isset($current->jump_step) && $current->jump_step == $element->id && $current->type_selected == "module") {
        $background = " style='background: #C8BBBE;' ";
        $counter2 = $counter;
    }
    echo "<span " . $background . " onmouseover='javascript:on_over(\"" . $counter . "\")' onmouseout='javascript:on_out(\"" . $counter . "\")' onclick='javascript:on_click(\"" . $counter . "\", \"" . $element->id . "\", \"module\")' id=" . $counter . ">" . $element->title . "</span><input type='hidden' name='" . $counter . "F' id='" . $counter . "F' value='" . $element->id . "' />";
    $background = "";
    $idTasksForDay = guruAdminModelguruTask::getIDTasksForDay($element->id);
    if (count($idTasksForDay)) {
        echo "<ul style='display:block; margin-left:20px; padding-left:0; margin-bottom:0;margin-top:0;'>";
        $nr = 0;
        $counter++;
        foreach ($idTasksForDay as $element2) {
            $nr++;
            if ($element2 != 0) {
                $aTask = guruAdminModelguruTask::getTask2($element2);
                $layout_nr = guruAdminModelguruTask::select_layout($element2);
                ?>
									<li style="padding-top: 2px; list-style-type:none;vertical-align:middle;" isLeaf="true" LeafId="<?php 
                echo $aTask->id;
                ?>
">
									<?php 
                if (isset($layout_nr) && $layout_nr < 13 && $layout_nr > 0) {
                    echo '<img border="0" src="' . JURI::base() . 'components/com_guru/images/screen-' . $layout_nr . '-tn.gif" alt="layout" />';
                }
                ?>
									
									<?php 
                $background = "";
                if (isset($current) && isset($aTask) && isset($current->jump_step) && $current->jump_step == $aTask->id && $current->type_selected != "module") {
                    $background = " style='background: #C8BBBE;' ";
Example #3
0
         }
     }
 } elseif ($quiz_questions[$i]->type == "multiple") {
     if (isset($question_answers) && count($question_answers) > 0) {
         foreach ($question_answers as $question_answer) {
             $media_associated_answers = json_decode($question_answer->media_ids);
             $media_content = "";
             $result_media_answers = array();
             if (isset($media_associated_answers) && count($media_associated_answers) > 0) {
                 foreach ($media_associated_answers as $media_key => $answer_media_id) {
                     $media_that_needs_to_be_sent = guruAdminModelguruTask::getMediaFromId($answer_media_id);
                     if (isset($media_that_needs_to_be_sent) && count($media_that_needs_to_be_sent) > 0) {
                         if ($media_that_needs_to_be_sent["0"]->type == "text") {
                             $result_media_answers[] = guruAdminModelguruTask::parse_txt($media_that_needs_to_be_sent["0"]->id);
                         } else {
                             $result_media_answers[] = guruAdminModelguruTask::parse_media($media_that_needs_to_be_sent["0"]->id, 0);
                         }
                     }
                 }
             }
             $multiple_ans_given = explode(",", @$answer_given_by_user[$question_answer->question_id]["answers_given"]);
             $checked = '';
             if (in_array($question_answer->id, $multiple_ans_given)) {
                 $checked = 'checked="checked"';
             }
             $option_value = '<input type="checkbox" ' . $checked . ' name="multiple_ans[' . intval($quiz_questions[$i]->id) . '][]" value="' . $question_answer->id . '"/>&nbsp;' . $question_answer->answer_content_text . '<br/>' . implode("", $result_media_answers) . "<br/>";
             $quiz_form_content .= $option_value;
         }
     }
 }
 $quiz_form_content .= '		</div>';
Example #4
0
$style_before_menu_med_15 = '';
$style_after_menu_med_15 = 'style="display:none"';
$the_media_id = guruAdminModelguruTask::select_media($program->id, 1, 12);
if ($the_media_id > 0) {
    $layout_media15 = $the_media_id;
    $layout_media15_content = guruAdminModelguruTask::parse_media($layout_media15, "15");
    $style_before_menu_med_15 = 'style="display:none"';
    $style_after_menu_med_15 = '';
}
$narration = 0;
$style_before_menu_med_99 = '';
$style_after_menu_med_99 = 'style="display:none"';
$the_media_id = guruAdminModelguruTask::select_media($program->id, 1, 99);
if ($the_media_id > 0) {
    $narration = $the_media_id;
    $model_task = new guruAdminModelguruTask();
    $narration_content = $model_task->parse_audio($narration);
    $narration_title = $model_task->getMediaName($narration);
    $style_before_menu_med_99 = 'style="display:none"';
    $style_after_menu_med_99 = '';
}
$db = JFactory::getDBO();
$kunenayn = "SELECT forum_kunena_generatedt FROM #__guru_task where id=" . intval($program->id);
$db->setQuery($kunenayn);
$db->query($kunenayn);
$kunenayn = $db->loadColumn();
?>
    <div class="clearfix"></div>
    <ul id="gurutabs" data-tabs="tabs" class="nav nav-tabs">
        <li class="active"><a href="#tab1" data-toggle="tab"><?php 
echo JText::_("GURU_GENERAL");
Example #5
0
 for ($i = 0; $i < $n; $i++) {
     //echo "<font color='blue'>".$i."</font>";
     $file = $medias[$i];
     @($file->prevw = str_replace("autostart=1", "autostart=0", @$file->prevw));
     if (isset($_GET['med'])) {
         $media_to_replace = $_GET['med'];
         $_SESSION['addmed_tskmed_to_rep'] = $_GET['med'];
     } elseif (isset($_SESSION['addmed_tskmed_to_rep'])) {
         $media_to_replace = $_SESSION['addmed_tskmed_to_rep'];
     } else {
         $media_to_replace = NULL;
     }
     $id = $file->id;
     $checked = JHTML::_('grid.id', $i, $id);
     $asoc_file = guruAdminModelguruTask::get_asoc_file_for_media($id);
     $all_media_categories = guruAdminModelguruTask::getMediaCategoriesName();
     $action = JRequest::getVar("action", "");
     $link = "";
     $file->name = str_replace('"', "&quot;", $file->name);
     if ($action == "new_module") {
         $link = "addmedia('" . $id . "', '" . addslashes($file->name) . "', '" . addslashes($asoc_file) . "', '" . addslashes($file->instructions) . "', 'new_module'); ";
     } else {
         $link = "addmedia('" . $id . "', '" . addslashes($file->name) . "', '" . addslashes($asoc_file) . "', '" . addslashes($file->instructions) . "' ); ";
     }
     $published = $file->published;
     // displaying now only the MEDIA (without DOCS and without QUIZ)
     //	if($file->type!='docs' && $file->type!='quiz' && $file->type!='text')
     $type = "";
     switch ($file->type) {
         case "video":
             $type = JText::_('GURU_MEDIATYPEVIDEO');
Example #6
0
$mmediam = $program->daymmedia;
$configuration = guruAdminModelguruDays::getConfigs();
$course_config = json_decode($configuration->ctgpage);
$full_image_size = $course_config->ctg_image_size;
$full_image_proportional = $course_config->ctg_image_size_type == "0" ? "w" : "h";
$display_before = $program->media_id == "0" ? "block" : "none";
$display_after = $program->media_id == "0" ? "none" : "block";
$srcimg = JURI::base() . "/components/com_guru/images/";
$layout_media1_content = '';
$type_media = "video";
$style_before_menu_txt_1 = "";
$style_after_menu_txt_1 = 'style="display:none;"';
if ($program->media_id != "0") {
    require_once JPATH_COMPONENT_ADMINISTRATOR . DS . "models" . DS . "gurutask.php";
    $type_media = guruAdminModelguruTask::getMediaType($program->media_id);
    $name_media = guruAdminModelguruTask::getMediaName($program->media_id);
    $layout_media1_content = $name_media;
    $style_before_menu_txt_1 = 'style="display:none;"';
    $style_after_menu_txt_1 = '';
}
?>

<style>
	div.modal1 {
		left: 4% !important;
		width: 770px !important;
		top:6%!important;
		position: fixed;
    	z-index: 9999;
	}
	
Example #7
0
            $style_after_menu_txt_5 = '';
            if ($the_text_obj[1] == 2) {
                $text_is_quiz = 1;
                $the_quiz_id = guruAdminModelguruTask::real_quiz_id($the_text_id);
            }
        }
    }
}
$layout_media7 = 0;
$style_before_menu_med_7 = '';
$style_after_menu_med_7 = 'style="display:none"';
if ($the_layout_is == 6) {
    $the_media_id = guruAdminModelguruTask::select_media($program->id, 1);
    if ($the_media_id > 0) {
        $layout_media7 = $the_media_id;
        $layout_media7_content = guruAdminModelguruTask::parse_media($layout_media7);
        $style_before_menu_med_7 = 'style="display:none"';
        $style_after_menu_med_7 = '';
    }
}
echo $pane->startPanel(JText::_('Layout'), "layout");
$srcimg = JURI::base() . "/components/com_guru/images/";
$layout_styledisplay = array(1 => 'style="display:none"', 2 => 'style="display:none"', 3 => 'style="display:none"', 4 => 'style="display:none"', 5 => 'style="display:none"', 6 => 'style="display:none"');
$layout_styledisplay[$the_layout_is] = 'style=""';
$layout_imgstyle = array(1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
$layout_imgstyle[$the_layout_is] = 'style="border:3px; border-style:solid; border-color:#0000FF;"';
?>
    <fieldset class="adminform">
	<legend><?php 
if ($program->id < 1) {
    echo JText::_('GURU_NEW');
Example #8
0
		<th>
			<?php 
echo JText::_('GURU_TASK_LOCKED');
?>
		</th>		
	</tr>
</thead>

<tbody>

<?php 
for ($i = 0; $i < $n; $i++) {
    $program = $this->programs[$i];
    $id = $program->id;
    //$checked = JHTML::_('grid.id', $i, $id);
    $checked_array = guruAdminModelguruTask::checkbox_construct($i, $id, $name = 'cid');
    $checked_array_expld = explode('$$$$$', $checked_array);
    $checked = $checked_array_expld[0];
    $locked = $checked_array_expld[1];
    if ($locked == 'disabled="disabled"') {
        $locked = '<font color="#FF0000">' . JText::_('GURU_TASK_LOCKED_Y') . '</font>';
    } else {
        $locked = '<font color="#00FF00">' . JText::_('GURU_TASK_LOCKED_N') . '</font>';
    }
    $link = JRoute::_("index.php?option=com_guru&controller=guruTasks&task=edit&cid[]=" . $id);
    $link2 = JRoute::_("index.php?option=com_guru&controller=guruTCategs&task=edit&cid[]=" . $id);
    $published = JHTML::_('grid.published', $program, $i);
    $mediatype = 'image';
    ?>
	<tr class="camp<?php 
    echo $k;
Example #9
0
 function getMainMedia()
 {
     $id = JRequest::getVar("id", "0", "get", "int");
     if ($id == 0) {
         $cid = JRequest::getVar("cid", array(), "get", "array");
         $id = $cid["0"];
     }
     $database = JFactory::getDBO();
     $sql = "SELECT * FROM #__guru_media\r\n\t\t\t\tWHERE id = " . $id;
     $database->setQuery($sql);
     $media = $database->loadObject();
     $media->code = stripslashes($media->code);
     if ($media->type == 'Article') {
         $id = $media->code;
         include_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurutask.php';
         $class_guru_task = new guruAdminModelguruTask();
         $media->code = $class_guru_task->getArticleById($id);
     }
     $configs = $this->getConfig();
     $video_size = $configs->default_video_size;
     if ($media->type != "url" && $media->type != "image" && $media->type != "docs" && $media->type != "audio" && $media->option_video_size == 0) {
         if (trim($video_size) != "") {
             $temp = explode("x", trim($video_size));
             $media->width = $temp["1"];
             $media->height = $temp["0"];
         }
     }
     if ($media->width == 0) {
         $media->width = 400;
     }
     $media->code = $this->parse_media($media);
     return $media;
 }
Example #10
0
    function parse_media($id, $layout = 0)
    {
        $db = JFactory::getDBO();
        $jnow = JFactory::getDate();
        $date = $jnow->toSQL();
        $guruHelper = new guruHelper();
        $max_id = NULL;
        $configs = $this->getConfig();
        $no_plugin_for_code = 0;
        $aheight = 0;
        $awidth = 0;
        $vheight = 0;
        $vwidth = 0;
        if ($layout != 12) {
            $sql = "SELECT * FROM #__guru_media\r\n\t\t\t\t\tWHERE id = " . $id;
            $db->setQuery($sql);
            $media = $db->loadObject();
            @($media->code = stripslashes(@$media->code));
        } else {
            $sql = "SELECT * FROM #__guru_quiz WHERE id = " . $id;
            $db->setQuery($sql);
            $db->query();
            $media = $db->loadObject();
            $media->type = "quiz";
            $media->code = "";
        }
        $default_video_size_string = $configs->default_video_size;
        $default_video_size_array = explode("x", $default_video_size_string);
        $default_video_height = $default_video_size_array["0"];
        $default_video_width = $default_video_size_array["1"];
        //start video
        if (isset($media->type) && $media->type == 'video') {
            if ($media->source == 'url' || $media->source == 'local') {
                if ($media->width == 0 || $media->height == 0 || $media->option_video_size == "0") {
                    $media->width = $default_video_width;
                    //300;
                    $media->height = $default_video_height;
                    //400;
                }
            } elseif ($media->source == 'code') {
                if ($media->option_video_size == "0") {
                    $media->width = $default_video_width;
                    //300;
                    $media->height = $default_video_height;
                    //400;
                    $replace_with = 'width="' . $media->width . '"';
                    $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'height="' . $media->height . '"';
                    $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="width" value="' . $media->width . '"';
                    $media->code = preg_replace('#name="width" value="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="height" value="' . $media->height . '"';
                    $media->code = preg_replace('#name="height" value="[0-9]+"#', $replace_with, $media->code);
                } elseif ($media->width == 0 || $media->height == 0) {
                    //parse the code to get the width and height if we have width=... and height=....
                    $begin_tag = strpos($media->code, 'width="');
                    if ($begin_tag !== false) {
                        $remaining_code = substr($media->code, $begin_tag + 7, strlen($media->code));
                        $end_tag = strpos($remaining_code, '"');
                        $media->width = substr($remaining_code, 0, $end_tag);
                        $begin_tag = strpos($media->code, 'height="');
                        if ($begin_tag !== false) {
                            $remaining_code = substr($media->code, $begin_tag + 8, strlen($media->code));
                            $end_tag = strpos($remaining_code, '"');
                            $media->height = substr($remaining_code, 0, $end_tag);
                            $no_plugin_for_code = 1;
                        } else {
                            $media->width = $default_video_width;
                            //300;
                            $media->height = $default_video_height;
                            //400;
                        }
                    } else {
                        $media->width = $default_video_width;
                        //300;
                        $media->height = $default_video_height;
                        //400;
                    }
                } else {
                    if ($media->option_video_size == "0") {
                        $media->width = $default_video_width;
                        //300;
                        $media->height = $default_video_height;
                        //400;
                    }
                    $replace_with = 'width="' . $media->width . '"';
                    $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'height="' . $media->height . '"';
                    $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="width" value="' . $media->width . '"';
                    $media->code = preg_replace('#name="width" value="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="height" value="' . $media->height . '"';
                    $media->code = preg_replace('#name="height" value="[0-9]+"#', $replace_with, $media->code);
                }
            }
            $vwidth = $media->width;
            $vheight = $media->height;
        } elseif (isset($media->type) && $media->type == 'audio') {
            if ($media->source == 'url' || $media->source == 'local') {
                if ($media->width == 0 || $media->height == 0) {
                    $media->width = 20;
                    $media->height = 300;
                }
            } elseif ($media->source == 'code') {
                if ($media->width == 0 || $media->height == 0) {
                    $begin_tag = strpos($media->code, 'width="');
                    if ($begin_tag !== false) {
                        $remaining_code = substr($media->code, $begin_tag + 7, strlen($media->code));
                        $end_tag = strpos($remaining_code, '"');
                        $media->width = substr($remaining_code, 0, $end_tag);
                        $begin_tag = strpos($media->code, 'height="');
                        if ($begin_tag !== false) {
                            $remaining_code = substr($media->code, $begin_tag + 8, strlen($media->code));
                            $end_tag = strpos($remaining_code, '"');
                            $media->height = substr($remaining_code, 0, $end_tag);
                            $no_plugin_for_code = 1;
                        } else {
                            $media->height = 20;
                            $media->width = 300;
                        }
                    } else {
                        $media->height = 20;
                        $media->width = 300;
                    }
                } else {
                    $replace_with = 'width="' . $media->width . '"';
                    $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'height="' . $media->height . '"';
                    $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code);
                }
            }
            $awidth = $media->width;
            $aheight = $media->height;
        }
        $parts = explode(".", @$media->local);
        $extension = $parts[count($parts) - 1];
        if (isset($media->type) && ($media->type == 'video' || $media->type == 'audio')) {
            $media->width = "100%";
            if ($media->type == 'video' && $extension == "avi") {
                $auto_play = "";
                if ($media->auto_play == "1") {
                    $auto_play = "&autoplay=1";
                }
                $media->code = '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="' . $media->width . '" height="' . $media->height . '">
<param name="fileName" value="' . JURI::root() . $configs->videoin . "/" . $media->local . '">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="true">
<param name="showControls" value="true">
<param name="Volume" value="10">
<param name="autoplay" value="false">
<embed width="' . $media->width . '" height="' . $media->height . '" name="plugin" src="' . JURI::root() . $configs->videoin . "/" . $media->local . '" type="video/x-msvideo">
</object>';
            } elseif ($no_plugin_for_code == 0) {
                $vwidth = "100%";
                $awidth = "100%";
                $media->code = $guruHelper->create_media_using_plugin($media, $configs, $awidth, $aheight, $vwidth, $vheight);
            }
        }
        //end audio
        //start docs type
        if (isset($media->type) && $media->type == 'docs') {
            $media->code = 'The selected element is a text file that can\'t have a preview';
            if ($media->source == 'local' && (substr($media->local, strlen($media->local) - 3, 3) == 'txt' || substr($media->local, strlen($media->local) - 3, 3) == 'pdf') && $media->width > 1 && $media->height > 0) {
                if ($media->height == 0) {
                    $media->height = 600;
                }
                $media->code = '<div class="contentpane">
							<iframe id="blockrandom" name="iframe" src="' . JURI::root() . $configs->docsin . '/' . $media->local . '" width="' . $media->width . '" height="' . $media->height . '" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe>
						</div>';
                $media->name = '<div style="text-align:center"><i>' . $media->name . '</i></div>';
                $media->instructions = '<div style="text-align:center"><i>' . $media->instructions . '</i></div>';
                $media->code = '<div style="text-align:center"><i>' . $media->code . '</i></div>';
                $return = "";
                if ($media->show_instruction == 2) {
                    $return .= $media->code;
                } elseif ($media->show_instruction == 1) {
                    $return .= $media->code;
                    $return .= '' . $media->instructions . '<br/>';
                } elseif ($media->show_instruction == 0) {
                    $return .= '' . $media->instructions . '<br/>';
                    $return .= $media->code;
                }
                if (isset($media->hide_name) && $media->hide_name == 0) {
                    $return .= $media->name;
                }
                return $return;
            } elseif ($media->source == 'url' && (substr($media->url, strlen($media->url) - 3, 3) == 'txt' || substr($media->url, strlen($media->url) - 3, 3) == 'pdf') && $media->width > 1) {
                $media->code = '<div class="contentpane">
							<iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="' . $media->width . '" height="' . $media->height . '" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe>
						</div>';
                $media->name = '<div style="text-align:center"><i>' . $media->name . '</i></div>';
                $media->instructions = '<div style="text-align:center"><i>' . $media->instructions . '</i></div>';
                $media->code = '<div style="text-align:center"><i>' . $media->code . '</i></div>';
                $return = "";
                if ($media->show_instruction == 2) {
                    $return .= $media->code;
                } elseif ($media->show_instruction == 1) {
                    $return .= $media->code;
                    $return .= '' . $media->instructions . '<br/>';
                } elseif ($media->show_instruction == 0) {
                    $return .= '' . $media->instructions . '<br/>';
                    $return .= $media->code;
                }
                if (isset($media->hide_name) && $media->hide_name == 0) {
                    $return .= $media->name;
                }
                return $return;
            } elseif ($media->source == 'local' && $media->width == 1) {
                $media->code = '<br /><a href="' . JURI::root() . $configs->docsin . '/' . $media->local . '" target="_blank">' . $media->local . '</a>';
                return stripslashes($media->code . '<p /><div  style="text-align:center"><i>' . $media->instructions . '</i></div>');
            } elseif ($media->source == 'url' && $media->width == 0) {
                $media->code = '<div class="contentpane">
							<iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="100%" height="600" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe> </div>';
            } elseif ($media->source == 'url' && $media->width == 1) {
                $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->local . '</a>';
            } elseif ($media->source == 'local' && $media->height == 0) {
                $media->code = '<br /><a href="' . JURI::root() . $configs->docsin . '/' . $media->local . '" target="_blank">' . $media->name . '</a>';
                return stripslashes($media->code . '<p /><div  style="text-align:center"><i>' . $media->instructions . '</i></div>');
            }
        }
        //end doc
        //start url
        if (isset($media->type) && $media->type == 'url') {
            if ($media->width == 1) {
                $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->url . '</a>';
            } else {
                $media->code = '<iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="800px" height="600px" scrolling="auto" align="top" frameborder="2"></iframe>';
            }
        }
        //end url
        //start article
        if (isset($media->type) && $media->type == 'Article') {
            $id = $media->code;
            include_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurutask.php';
            $media->code = guruAdminModelguruTask::getArticleById($id);
        }
        //end article
        //start image
        if (isset($media->type) && $media->type == 'image') {
            require_once "components/com_guru/helpers/helper.php";
            $helper = new guruHelper();
            $width = $media->width;
            $height = $media->height;
            $new_size = "";
            $type = "";
            if (intval($width) != 0) {
                $new_size = $width;
                $type = "w";
            } else {
                $new_size = $height;
                $type = "h";
            }
            $helper->createThumb($media->local, $configs->imagesin . '/media', $new_size, $type);
            $media->code = '<img src="' . JURI::root() . $configs->imagesin . '/media/thumbs' . $media->local . '" />';
        }
        //end image
        //start text
        if (isset($media->type) && $media->type == 'text') {
            $media->code = $media->code;
        }
        //end text
        //start docs type
        if (isset($media->type) && $media->type == 'file') {
            $media->code = JText::_('GURU_NO_PREVIEW');
            if ($media->source == 'local' && (substr($media->local, strlen($media->local) - 3, 3) == 'zip' || substr($media->local, strlen($media->local) - 3, 3) == 'exe')) {
                $media->code = '<br /><a href="' . JURI::root() . $configs->filesin . '/' . $media->local . '" target="_blank">' . $media->local . '</a>';
                //return stripslashes($media->code.'<p /><div  style="text-align:center"><i>'.$media->instructions.'</i></div>');
            } else {
                if ($media->source == 'url') {
                    $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->local . '</a>';
                }
            }
        }
        //end doc
        if (isset($media->type) && $media->type == 'quiz' && $media->published == '1' && strtotime($media->startpublish) <= strtotime($date) && (strtotime($media->endpublish) >= strtotime($date) || $media->endpublish == "0000-00-00 00:00:00")) {
            $document = JFactory::getDocument();
            $document->addStyleSheet("components/com_guru/css/quiz.css");
            $document->addScript("components/com_guru/js/programs.js");
            $media->code = '';
            $query = "SELECT * FROM #__guru_quiz WHERE id = " . $media->id . " and published=1";
            $db->setQuery($query);
            $result_quiz = $db->loadObject();
            $sql_quest = "SELECT count(id) from #__guru_questions where qid=" . $media->id;
            $db->setQuery($query);
            $result_quest = $db->loadResult();
            $query = "UPDATE #__guru_quiz set nb_quiz_select_up=" . $result_quest . " WHERE id = " . $media->id;
            $db->setQuery($query);
            $sql = "SELECT max_score, pbl_max_score, limit_time, show_limit_time, time_quiz_taken, show_nb_quiz_taken, nb_quiz_select_up, show_nb_quiz_select_up  FROM #__guru_quiz where id=" . $result_quiz->id;
            $db->setQuery($sql);
            $result_settings_quiz = $db->loadObject();
            if ($result_quiz->is_final == 0) {
                $text_quiz_info_top = JText::_("GURU_MINIMUM_SCORE_QUIZ");
                $text_quiz_info_top1 = JText::_("GURU_QUIZ_TAKEN_UP_TO");
            } else {
                $text_quiz_info_top = JText::_("GURU_MINIMUM_SCORE_FINAL_QUIZ");
                $text_quiz_info_top1 = JText::_("GURU_QUIZ_CAN_BE_TAKEN");
            }
            $table_quiz = '<table><tr><td>';
            if ($result_settings_quiz->show_limit_time == 0) {
                $table_quiz .= JText::_("GURU_LIMIT_QUIZ") . ": " . "<span style='color:#669900'>" . $result_settings_quiz->limit_time . "</span>" . " " . JText::_("GURU_REAL_MINUTES");
            }
            $table_quiz .= '</td><td style="padding-left:25px;">';
            if ($result_settings_quiz->pbl_max_score == 0) {
                $table_quiz .= $text_quiz_info_top . ": " . "<span style='color:#669900'>" . $result_settings_quiz->max_score . JText::_("GURU_PERCENT") . "</span>";
            }
            $table_quiz .= '</td><tr><td>';
            if ($result_settings_quiz->show_nb_quiz_select_up == 0) {
                $table_quiz .= JText::_("GURU_QUESTIONS") . ": " . "<span style='color:#669900'>" . $result_settings_quiz->nb_quiz_select_up . "</span>";
            }
            $table_quiz .= '</td><td style="padding-left:25px;">';
            if ($result_settings_quiz->show_nb_quiz_taken == 0) {
                if ($result_settings_quiz->time_quiz_taken < 0) {
                    $result_settings_quiz->time_quiz_taken = 0;
                }
                if ($result_settings_quiz->time_quiz_taken == 11) {
                    $timestotake = "Unlimited";
                } else {
                    $timestotake = $result_settings_quiz->time_quiz_taken;
                }
                $table_quiz .= $text_quiz_info_top1 . ": " . "<span style='color:#669900'>" . $timestotake . "</span>" . " " . JText::_("GURU_TIMES");
            }
            $table_quiz .= '</td></tr></table>';
            if (isset($_SESSION["submit_disabled"])) {
                $table_quiz .= '<table><tr><td style="padding-top:15px;">' . $_SESSION["submit_disabled"] . '</td></tr></table>';
            }
            $user = JFactory::getUser();
            $user_id = $user->id;
            $sql = "SELECT `time_quiz_taken_per_user` FROM #__guru_quiz_taken where quiz_id=" . $result_quiz->id . " AND user_id=" . $user_id . " ORDER BY id DESC LIMIT 0,1";
            $db->setQuery($sql);
            $result_time_user = $db->loadColumn();
            $result_time_user = @$result_time_user["0"];
            if ($result_settings_quiz->time_quiz_taken == 11) {
                $result_time_user = 11;
            } else {
                $result_time_user = $result_settings_quiz->time_quiz_taken - $result_time_user;
            }
            $media->code .= '<span class="guru_quiz_title">' . $result_quiz->name . '</span>';
            $media->code .= ' <div class="g_quiz_info">' . $table_quiz . '</div>';
            if ($result_quiz->description != "") {
                $media->code .= '<span class="guru_quiz_description">' . $result_quiz->description . '</span>';
            }
            if (isset($result_settings_quiz->nb_quiz_select_up) && $result_settings_quiz->nb_quiz_select_up != 0 && $result_settings_quiz->show_nb_quiz_select_up == 0) {
                $order_by = " ORDER BY RAND() LIMIT  " . $result_settings_quiz->nb_quiz_select_up . "";
            } else {
                $order_by = " ORDER BY reorder LIMIT  " . $result_settings_quiz->nb_quiz_select_up . "";
            }
            if ($result_quiz->is_final == 1) {
                $sql = "SELECT \tquizzes_ids FROM #__guru_quizzes_final WHERE qid=" . $media->id;
                $db->setQuery($sql);
                $db->query();
                $result = $db->loadResult();
                $result_qids = explode(",", trim($result, ","));
                if ($result_qids["0"] == "") {
                    $result_qids["0"] = 0;
                }
                if (isset($result_qids) && count($result_qids) > 0) {
                    foreach ($result_qids as $key => $value) {
                        $quiz_id = intval($value);
                        $sql = "select `published` from #__guru_quiz where `id`=" . intval($quiz_id);
                        $db->setQuery($sql);
                        $db->query();
                        $published = $db->loadColumn();
                        $published = @$published["0"];
                        if (intval($published) == 0) {
                            unset($result_qids[$key]);
                        }
                    }
                }
                if (count($result_qids) == 0 || $result_qids["0"] == "") {
                    $result_qids["0"] = 0;
                }
                $query = "SELECT * FROM #__guru_questions WHERE qid IN (" . implode(",", $result_qids) . ") and published=1" . $order_by;
            } else {
                $query = "SELECT * FROM #__guru_questions WHERE qid = " . $media->id . " and published=1" . $order_by;
            }
            $db->setQuery($query);
            $quiz_questions = $db->loadObjectList();
            $media->code .= '<div id="the_quiz">';
            $array_quest = array();
            $question_number = 1;
            if (!isset($quiz_questions) || count($quiz_questions) <= 0) {
                return "";
            }
            $per_page = $result_quiz->questions_per_page;
            // questions per page
            if ($per_page == 0) {
                $per_page = count($quiz_questions);
            }
            $nr_pages = 1;
            // default one page
            if (count($quiz_questions) > 0 && count($quiz_questions) > $per_page) {
                $nr_pages = ceil(count($quiz_questions) / $per_page);
            }
            for ($pag = 1; $pag <= $nr_pages; $pag++) {
                $k = ($pag - 1) * $per_page;
                $added = 0;
                $display = "";
                if ($pag == 1) {
                    $display = "block";
                } else {
                    $display = "none";
                }
                $media->code .= '<div id="quiz_page_' . $pag . '" style="display:' . $display . ';">';
                // start page
                while (isset($quiz_questions[$k]) && $added < $per_page) {
                    $one_question = $quiz_questions[$k];
                    $array_quest[] = $one_question->id;
                    $question_answers_number = 0;
                    $media->code .= '<ul class="guru_list">';
                    $media->code .= '<li class="question">' . $question_number . ". " . $one_question->text . '</li>';
                    if ($one_question->a1 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="1a" name="q' . $one_question->id . '[]" />' . " " . $one_question->a1 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a2 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="2a" name="q' . $one_question->id . '[]">' . " " . $one_question->a2 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a3 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="3a" name="q' . $one_question->id . '[]">' . " " . $one_question->a3 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a4 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="4a" name="q' . $one_question->id . '[]">' . " " . $one_question->a4 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a5 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="5a" name="q' . $one_question->id . '[]">' . " " . $one_question->a5 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a6 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="6a" name="q' . $one_question->id . '[]">' . " " . $one_question->a6 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a7 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="7a" name="q' . $one_question->id . '[]">' . " " . $one_question->a7 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a8 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="8a" name="q' . $one_question->id . '[]">' . " " . $one_question->a8 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a9 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="9a" name="q' . $one_question->id . '[]">' . " " . $one_question->a9 . '</li>';
                        $question_answers_number++;
                    }
                    if ($one_question->a10 != '') {
                        $media->code .= '<li class="answer"><input type="checkbox" value="10a" name="q' . $one_question->id . '[]">' . " " . $one_question->a10 . '</li>';
                        $question_answers_number++;
                    }
                    $correct_answers = explode('|||', $one_question->answers);
                    foreach ($correct_answers as $key => $value) {
                        if (intval(intval($value)) != 0) {
                            $correct_answers[$key] = intval($value);
                        } else {
                            unset($correct_answers[$key]);
                        }
                    }
                    $the_right_answer = array();
                    foreach ($correct_answers as $key => $value) {
                        $column = "a" . $value;
                        $the_right_answer[] = $one_question->{$column};
                    }
                    $the_right_answer = implode("|||", $the_right_answer);
                    $all_answers = array();
                    $all_answers_text = array();
                    if (trim($one_question->a1) != "") {
                        $all_answers[] = "1a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a1));
                    }
                    if (trim($one_question->a2) != "") {
                        $all_answers[] = "2a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a2));
                    }
                    if (trim($one_question->a3) != "") {
                        $all_answers[] = "3a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a3));
                    }
                    if (trim($one_question->a4) != "") {
                        $all_answers[] = "4a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a4));
                    }
                    if (trim($one_question->a5) != "") {
                        $all_answers[] = "5a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a5));
                    }
                    if (trim($one_question->a6) != "") {
                        $all_answers[] = "6a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a6));
                    }
                    if (trim($one_question->a7) != "") {
                        $all_answers[] = "7a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a7));
                    }
                    if (trim($one_question->a8) != "") {
                        $all_answers[] = "8a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a8));
                    }
                    if (trim($one_question->a9) != "") {
                        $all_answers[] = "9a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a9));
                    }
                    if (trim($one_question->a10) != "") {
                        $all_answers[] = "10a";
                        $all_answers_text[] = trim(str_replace("'", "&acute;", $one_question->a10));
                    }
                    $all_answers = implode("|||", $all_answers);
                    $all_answers_text = implode("|||", $all_answers_text);
                    $question_number++;
                    $media->code .= '</ul>';
                    $k++;
                    $added++;
                }
                if ($pag == $nr_pages) {
                    $catid_req = JRequest::getVar("catid", "");
                    $module_req = JRequest::getVar("module", "");
                    $cid_req = JRequest::getVar("cid", "");
                    $media->code .= '<br />
						   <div align="left" style="padding-left:4px;">
								<input type="hidden" value="' . $media->name . '" id="quize_name" name="quize_name"/>
								<input type="hidden" value="' . $result_settings_quiz->nb_quiz_select_up . '" id="nb_of_questions" name="nb_of_questions"/>
								<input type="hidden" value="' . $media->id . '" id="quize_id" name="quize_id"/>
								<input type="hidden" value="1" name="submit_action" id="submit_action" />
								<input type="hidden" value="' . $catid_req . '" name="catid_req" id="catid_req">
								<input type="hidden" value="' . $module_req . '" name="module_req" id="module_req">
								<input type="hidden" value="' . $cid_req . '" name="cid_req" id="cid_req">
								<input type="hidden" value="' . $open_target . '" name="open_target" id="open_target">
								<input type="button"  name="submitbutton" class="btn btn-warning" id ="submitbutton" value="' . JText::_("GURU_QUIZ_SUBMIT") . '" onclick="document.getElementById(\'quizz_exam\').submit();" />
						  </div>';
                }
                $media->code .= '</div>';
                // end page
            }
            if ($nr_pages > 1) {
                $media->code .= '<div class="pagination pagination-centered"><ul class="uk-pagination">';
                $media->code .= '<li class="pagination-start" id="pagination-start"><span class="pagenav">' . JText::_("GURU_START") . '</span></li>';
                $media->code .= '<li class="pagination-prev" id="pagination-prev"><span class="pagenav">' . JText::_("GURU_PREV") . '</span></li>';
                for ($p = 1; $p <= $nr_pages; $p++) {
                    if ($p == 1) {
                        $media->code .= '<li id="list_1"><span class="pagenav">1</span></li>';
                    } else {
                        $media->code .= '<li id="list_' . $p . '">
											<a onclick="changePage(' . intval($p) . ', ' . intval($nr_pages) . '); return false;" href="#">' . $p . '</a>
										 </li>';
                    }
                }
                $media->code .= '<li class="pagination-next" id="pagination-next">
										<a href="#" onclick="changePage(2, ' . intval($nr_pages) . '); return false;">' . JText::_("GURU_NEXT") . '</a>
									 </li>';
                $media->code .= '<li class="pagination-end" id="pagination-end">
										<a href="#" onclick="changePage(' . intval($nr_pages) . ', ' . intval($nr_pages) . '); return false;">' . JText::_("GURU_END") . '</a>
									 </li>';
                $media->code .= '</ul></div>';
            }
            // create quiz taken and question
            $sql = "SELECT `open_target` FROM `#__guru_config` WHERE `id`=1";
            $db->setQuery($sql);
            $db->query();
            $open_target = $db->loadColumn();
            $open_target = $open_target["0"];
            $media->code .= '<input type="hidden" value="' . ($question_number - 1) . '" name="question_number" id="question_number" />';
            $media->code .= '<input type="hidden" value="' . implode(",", $array_quest) . '" name="list_questions_id" id="list_questions_id" />';
            $media->code .= '<input type="hidden" value="' . $max_id . '" name="id_quiz_question" id="id_quiz_question" />';
            $_SESSION["questionsids"] = implode(",", $array_quest);
            $_SESSION["quiz_id"] = $media->id;
            if (isset($result_time_user) && $result_time_user <= 0) {
                $disabled = 'disabled=disabled';
                $msg = JText::_("GURU_QUIZ_RES_MC");
                $_SESSION["submit_disabled"] = $msg;
            } else {
                $disabled = '';
            }
            $media->code .= '</div>';
        }
        $return = "";
        if (isset($media->show_instruction) && $media->show_instruction == "0") {
            //show the instructions above
            $return = '<div  style="text-align:center"><i>' . $media->instructions . '</i></div>' . $media->code;
        } elseif (isset($media->show_instruction) && $media->show_instruction == "1") {
            //show the instructions above
            $return = $media->code . '<br /><br />
					 <div  style="text-align:center"><i>' . $media->instructions . '</i></div>';
        } elseif (isset($media->show_instruction) && $media->show_instruction == "2") {
            //don't show the instructions
            $return = $media->code;
        } elseif (!isset($media->show_instruction) || $media->show_instruction == NULL) {
            $return = $media->code;
        }
        if (@$media->type != 'quiz') {
            if (@$media->hide_name == 0) {
                $return .= '<div class="clearfix"></div><div class="g_media_title text-centered">' . @$media->name . '</div>';
            }
        }
        return stripslashes($return);
    }
Example #11
0
	</tr>
</thead>

<tbody>
<?php 
$pid = intval($_GET['cid'][0]);
if ($n > 0) {
    for ($i = 0; $i < $n; $i++) {
        $file = $this->medias[$i];
        $media_to_replace = $_GET['txt'];
        $id = $file->id;
        $checked = JHTML::_('grid.id', $i, $id);
        $asoc_file = guruAdminModelguruTask::get_asoc_file_for_media($id);
        $action = JRequest::getVar("action", "");
        if ($file->type == 'quiz') {
            $the_quiz_id = guruAdminModelguruTask::real_quiz_id($file->id);
        }
        if ($file->type == 'quiz') {
            $link = "addmedia('" . $id . "', '" . addslashes($file->name) . "', '" . addslashes($asoc_file) . "', '" . $file->instructions . "' , '1', '" . $the_quiz_id . "' ); ";
        } else {
            if ($action == "new_module") {
                $link = "addmedia('" . $id . "', '" . addslashes($file->name) . "', '" . addslashes($asoc_file) . "', '" . $file->instructions . "' , '0', 'new_module' ); ";
            } else {
                $link = "addmedia('" . $id . "', '" . addslashes($file->name) . "', '" . addslashes($asoc_file) . "', '" . $file->instructions . "' , '0', '0' ); ";
            }
        }
        $published = JHTML::_('grid.published', $file, $i);
        if ($file->type == 'text') {
            ?>
	<tr class="camp0"> 
	   <td><?php 
Example #12
0
    public static function parse_media($id, $layout = 0)
    {
        $db = JFactory::getDBO();
        $jnow = JFactory::getDate();
        $date = $jnow->toSQL();
        $guruHelper = new guruHelper();
        $max_id = NULL;
        $open_target = "";
        $configs = self::getConfig();
        $no_plugin_for_code = 0;
        $aheight = 0;
        $awidth = 0;
        $vheight = 0;
        $vwidth = 0;
        if ($layout != 12) {
            $sql = "SELECT * FROM #__guru_media\r\n\t\t\t\t\tWHERE id = " . $id;
            $db->setQuery($sql);
            $media = $db->loadObject();
            @($media->code = stripslashes(@$media->code));
        } else {
            $sql = "SELECT * FROM #__guru_quiz WHERE id = " . $id;
            $db->setQuery($sql);
            $db->query();
            $media = $db->loadObject();
            @($media->type = "quiz");
            $media->code = "";
        }
        $default_video_size_string = $configs->default_video_size;
        $default_video_size_array = explode("x", $default_video_size_string);
        $default_video_height = $default_video_size_array["0"];
        $default_video_width = $default_video_size_array["1"];
        //start video
        if (isset($media->type) && $media->type == 'video') {
            if ($media->source == 'url' || $media->source == 'local') {
                if ($media->width == 0 || $media->height == 0 || $media->option_video_size == "0") {
                    $media->width = $default_video_width;
                    //300;
                    $media->height = $default_video_height;
                    //400;
                }
            } elseif ($media->source == 'code') {
                if ($media->option_video_size == "0") {
                    $media->width = $default_video_width;
                    //300;
                    $media->height = $default_video_height;
                    //400;
                    $replace_with = 'width="' . $media->width . '"';
                    $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'height="' . $media->height . '"';
                    $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="width" value="' . $media->width . '"';
                    $media->code = preg_replace('#name="width" value="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="height" value="' . $media->height . '"';
                    $media->code = preg_replace('#name="height" value="[0-9]+"#', $replace_with, $media->code);
                } elseif ($media->width == 0 || $media->height == 0) {
                    //parse the code to get the width and height if we have width=... and height=....
                    $begin_tag = strpos($media->code, 'width="');
                    if ($begin_tag !== false) {
                        $remaining_code = substr($media->code, $begin_tag + 7, strlen($media->code));
                        $end_tag = strpos($remaining_code, '"');
                        $media->width = substr($remaining_code, 0, $end_tag);
                        $begin_tag = strpos($media->code, 'height="');
                        if ($begin_tag !== false) {
                            $remaining_code = substr($media->code, $begin_tag + 8, strlen($media->code));
                            $end_tag = strpos($remaining_code, '"');
                            $media->height = substr($remaining_code, 0, $end_tag);
                            $no_plugin_for_code = 1;
                        } else {
                            $media->width = $default_video_width;
                            //300;
                            $media->height = $default_video_height;
                            //400;
                        }
                    } else {
                        $media->width = $default_video_width;
                        //300;
                        $media->height = $default_video_height;
                        //400;
                    }
                } else {
                    if ($media->option_video_size == "0") {
                        $media->width = $default_video_width;
                        //300;
                        $media->height = $default_video_height;
                        //400;
                    }
                    $replace_with = 'width="' . $media->width . '"';
                    $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'height="' . $media->height . '"';
                    $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="width" value="' . $media->width . '"';
                    $media->code = preg_replace('#name="width" value="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'name="height" value="' . $media->height . '"';
                    $media->code = preg_replace('#name="height" value="[0-9]+"#', $replace_with, $media->code);
                }
            }
            $vwidth = $media->width;
            $vheight = $media->height;
        } elseif (isset($media->type) && $media->type == 'audio') {
            if ($media->source == 'url' || $media->source == 'local') {
                if ($media->width == 0 || $media->height == 0) {
                    $media->width = 20;
                    $media->height = 300;
                }
            } elseif ($media->source == 'code') {
                if ($media->width == 0 || $media->height == 0) {
                    $begin_tag = strpos($media->code, 'width="');
                    if ($begin_tag !== false) {
                        $remaining_code = substr($media->code, $begin_tag + 7, strlen($media->code));
                        $end_tag = strpos($remaining_code, '"');
                        $media->width = substr($remaining_code, 0, $end_tag);
                        $begin_tag = strpos($media->code, 'height="');
                        if ($begin_tag !== false) {
                            $remaining_code = substr($media->code, $begin_tag + 8, strlen($media->code));
                            $end_tag = strpos($remaining_code, '"');
                            $media->height = substr($remaining_code, 0, $end_tag);
                            $no_plugin_for_code = 1;
                        } else {
                            $media->height = 20;
                            $media->width = 300;
                        }
                    } else {
                        $media->height = 20;
                        $media->width = 300;
                    }
                } else {
                    $replace_with = 'width="' . $media->width . '"';
                    $media->code = preg_replace('#width="[0-9]+"#', $replace_with, $media->code);
                    $replace_with = 'height="' . $media->height . '"';
                    $media->code = preg_replace('#height="[0-9]+"#', $replace_with, $media->code);
                }
            }
            $awidth = $media->width;
            $aheight = $media->height;
        }
        $parts = explode(".", @$media->local);
        $extension = $parts[count($parts) - 1];
        if (isset($media->type) && ($media->type == 'video' || $media->type == 'audio')) {
            $media->width = "100%";
            if ($media->type == 'video' && $extension == "avi") {
                $auto_play = "";
                if ($media->auto_play == "1") {
                    $auto_play = "&autoplay=1";
                }
                $media->code = '<object id="MediaPlayer1" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="' . $media->width . '" height="' . $media->height . '">
<param name="fileName" value="' . JURI::root() . $configs->videoin . "/" . $media->local . '">
<param name="animationatStart" value="true">
<param name="transparentatStart" value="true">
<param name="autoStart" value="true">
<param name="showControls" value="true">
<param name="Volume" value="10">
<param name="autoplay" value="false">
<embed width="' . $media->width . '" height="' . $media->height . '" name="plugin" src="' . JURI::root() . $configs->videoin . "/" . $media->local . '" type="video/x-msvideo">
</object>';
            } elseif ($no_plugin_for_code == 0) {
                $vwidth = "100%";
                $awidth = "100%";
                $media->code = $guruHelper->create_media_using_plugin($media, $configs, $awidth, $aheight, $vwidth, $vheight);
            }
        }
        //end audio
        //start docs type
        if (isset($media->type) && $media->type == 'docs') {
            $media->code = 'The selected element is a text file that can\'t have a preview';
            if ($media->source == 'local' && (substr($media->local, strlen($media->local) - 3, 3) == 'txt' || substr($media->local, strlen($media->local) - 3, 3) == 'pdf') && $media->width > 1 && $media->height > 0) {
                if ($media->height == 0) {
                    $media->height = 600;
                }
                if (substr($media->local, strlen($media->local) - 3, 3) == 'pdf') {
                    $media->code = '<div class="contentpane">
							<object data="' . JURI::root() . $configs->docsin . '/' . $media->local . '" type="application/pdf" width="' . $media->width . '" height="' . $media->height . '" style="max-width:100%;">
								<embed src="' . JURI::root() . $configs->docsin . '/' . $media->local . '" type="application/pdf" />
							</object>
						</div>';
                } else {
                    $media->code = '<div class="contentpane">
							<iframe id="blockrandom" name="iframe" src="' . JURI::root() . $configs->docsin . '/' . $media->local . '" width="' . $media->width . '" height="' . $media->height . '" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe>
						</div>';
                }
                $media->name = '<div class="uk-text-center"><i>' . $media->name . '</i></div>';
                $media->instructions = '<div class="uk-text-center"><i>' . $media->instructions . '</i></div>';
                $media->code = '<div class="uk-text-center"><i>' . $media->code . '</i></div>';
                $return = "";
                if ($media->show_instruction == 2) {
                    $return .= $media->code;
                } elseif ($media->show_instruction == 1) {
                    $return .= $media->code;
                    $return .= '' . $media->instructions . '<br/>';
                } elseif ($media->show_instruction == 0) {
                    $return .= '' . $media->instructions . '<br/>';
                    $return .= $media->code;
                }
                if (isset($media->hide_name) && $media->hide_name == 0) {
                    $return .= $media->name;
                }
                return $return;
            } elseif ($media->source == 'url' && (substr($media->url, strlen($media->url) - 3, 3) == 'txt' || substr($media->url, strlen($media->url) - 3, 3) == 'pdf') && $media->width > 1) {
                $media->code = '<div class="contentpane">
							<iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="' . $media->width . '" height="' . $media->height . '" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe>
						</div>';
                $media->name = '<div class="uk-text-center"><i>' . $media->name . '</i></div>';
                $media->instructions = '<div class="uk-text-center"><i>' . $media->instructions . '</i></div>';
                $media->code = '<div class="uk-text-center"><i>' . $media->code . '</i></div>';
                $return = "";
                if ($media->show_instruction == 2) {
                    $return .= $media->code;
                } elseif ($media->show_instruction == 1) {
                    $return .= $media->code;
                    $return .= '' . $media->instructions . '<br/>';
                } elseif ($media->show_instruction == 0) {
                    $return .= '' . $media->instructions . '<br/>';
                    $return .= $media->code;
                }
                if (isset($media->hide_name) && $media->hide_name == 0) {
                    $return .= $media->name;
                }
                return $return;
            } elseif ($media->source == 'local' && $media->width == 1) {
                $media->code = '<br /><a href="' . JURI::root() . $configs->docsin . '/' . $media->local . '" target="_blank">' . $media->local . '</a>';
                return stripslashes($media->code . '<p /><div class="uk-text-center"><i>' . $media->instructions . '</i></div>');
            } elseif ($media->source == 'url' && $media->width == 0) {
                $media->code = '<div class="contentpane">
							<iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="100%" height="600" scrolling="auto" align="top" frameborder="2" class="wrapper"> This option will not work correctly. Unfortunately, your browser does not support inline frames.</iframe> </div>';
            } elseif ($media->source == 'url' && $media->width == 1) {
                $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->local . '</a>';
            } elseif ($media->source == 'local' && $media->height == 0) {
                $media->code = '<br /><a href="' . JURI::root() . $configs->docsin . '/' . $media->local . '" target="_blank">' . $media->name . '</a>';
                return stripslashes($media->code . '<p /><div class="uk-text-center"><i>' . $media->instructions . '</i></div>');
            }
        }
        //end doc
        //start url
        if (isset($media->type) && $media->type == 'url') {
            if ($media->width == 1) {
                $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->url . '</a>';
            } else {
                $frame_width = "800";
                $frame_height = "600";
                if ($media->width != 0 && $media->width != "" && $media->width != 1) {
                    $frame_width = $media->width;
                }
                if ($media->height != 0 && $media->height != "") {
                    $frame_height = $media->height;
                }
                $media->code = '<iframe id="blockrandom" name="iframe" src="' . $media->url . '" width="' . intval($frame_width) . 'px" height="' . intval($frame_height) . 'px" scrolling="auto" align="top" frameborder="2"></iframe>';
            }
        }
        //end url
        //start article
        if (isset($media->type) && $media->type == 'Article') {
            $id = $media->code;
            include_once JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_guru' . DS . 'models' . DS . 'gurutask.php';
            $media->code = guruAdminModelguruTask::getArticleById($id);
        }
        //end article
        //start image
        if (isset($media->type) && $media->type == 'image') {
            require_once "components/com_guru/helpers/helper.php";
            $helper = new guruHelper();
            $width = $media->width;
            $height = $media->height;
            $new_size = "";
            $type = "";
            if (intval($width) != 0) {
                $new_size = $width;
                $type = "w";
            } else {
                $new_size = $height;
                $type = "h";
            }
            $helper->createThumb($media->local, $configs->imagesin . '/media', $new_size, $type);
            $media->code = '<img src="' . JURI::root() . $configs->imagesin . '/media/thumbs' . $media->local . '" />';
        }
        //end image
        //start text
        if (isset($media->type) && $media->type == 'text') {
            $media->code = $media->code;
        }
        //end text
        //start docs type
        if (isset($media->type) && $media->type == 'file') {
            $media->code = JText::_('GURU_NO_PREVIEW');
            if ($media->source == 'local' && (substr($media->local, strlen($media->local) - 3, 3) == 'zip' || substr($media->local, strlen($media->local) - 3, 3) == 'exe')) {
                $media->code = '<br /><a href="' . JURI::root() . $configs->filesin . '/' . $media->local . '" target="_blank">' . $media->local . '</a>';
            } else {
                if ($media->source == 'url') {
                    $media->code = '<a href="' . $media->url . '" target="_blank">' . $media->local . '</a>';
                }
            }
        }
        //end doc
        if (isset($media->type) && $media->type == 'quiz' && @$media->published == '1' && strtotime($media->startpublish) <= strtotime($date) && (strtotime($media->endpublish) >= strtotime($date) || $media->endpublish == "0000-00-00 00:00:00")) {
            $document = JFactory::getDocument();
            $document->addStyleSheet("components/com_guru/css/quiz.css");
            $helperclass = new guruHelper();
            $all_quiz_question_from_page = array();
            $media->code = '';
            $query = "SELECT * FROM #__guru_quiz WHERE id = " . $media->id . " and published=1";
            $db->setQuery($query);
            $result_quiz = $db->loadObject();
            $sql_quest = "SELECT count(id) from #__guru_questions_v3 where qid=" . $media->id;
            $db->setQuery($query);
            $result_quest = $db->loadResult();
            $query = "UPDATE #__guru_quiz set nb_quiz_select_up=" . $result_quest . " WHERE id = " . $media->id;
            $db->setQuery($query);
            $sql = "SELECT max_score, pbl_max_score, limit_time, show_limit_time, time_quiz_taken, show_nb_quiz_taken, nb_quiz_select_up, show_nb_quiz_select_up  FROM #__guru_quiz where id=" . $result_quiz->id;
            $db->setQuery($sql);
            $result_settings_quiz = $db->loadObject();
            if ($result_quiz->is_final == 0) {
                $text_quiz_info_top = JText::_("GURU_MINIMUM_SCORE_QUIZ");
                $text_quiz_info_top1 = JText::_("GURU_QUIZ_TAKEN_UP_TO");
            } else {
                $text_quiz_info_top = JText::_("GURU_MINIMUM_SCORE_FINAL_QUIZ");
                $text_quiz_info_top1 = JText::_("GURU_QUIZ_CAN_BE_TAKEN");
            }
            $table_quiz = '<div class="uk-grid">';
            if ($result_settings_quiz->show_limit_time == 0) {
                $table_quiz .= '<div class="uk-width-large-1-2">' . JText::_("GURU_LIMIT_QUIZ") . ": " . "<span style='color:#669900'>" . $result_settings_quiz->limit_time . "</span>" . " " . JText::_("GURU_REAL_MINUTES") . '</div>';
            }
            if ($result_settings_quiz->pbl_max_score == 0) {
                $table_quiz .= '<div class="uk-width-large-1-2">' . $text_quiz_info_top . ": " . "<span style='color:#669900'>" . $result_settings_quiz->max_score . JText::_("GURU_PERCENT") . "</span>" . '</div>';
            }
            $table_quiz .= '</div>';
            $table_quiz .= '<div class="uk-grid">';
            if ($result_settings_quiz->show_nb_quiz_select_up == 0) {
                $table_quiz .= '<div class="uk-width-large-1-2">' . JText::_("GURU_QUESTIONS") . ": " . "<span style='color:#669900'>" . $result_settings_quiz->nb_quiz_select_up . "</span>" . '</div>';
            }
            if ($result_settings_quiz->show_nb_quiz_taken == 0) {
                if ($result_settings_quiz->time_quiz_taken < 0) {
                    $result_settings_quiz->time_quiz_taken = 0;
                }
                if ($result_settings_quiz->time_quiz_taken == 11) {
                    $timestotake = "Unlimited";
                } else {
                    $timestotake = $result_settings_quiz->time_quiz_taken;
                }
                $table_quiz .= '<div class="uk-width-large-1-2">' . $text_quiz_info_top1 . ": " . "<span style='color:#669900'>" . $timestotake . "</span>" . " " . JText::_("GURU_TIMES") . '</div>';
            }
            $table_quiz .= '</div>';
            if (isset($_SESSION["submit_disabled"])) {
                $table_quiz .= '<div class="uk-grid">';
                $table_quiz .= '<div class="uk-width-large-1-2">' . $_SESSION["submit_disabled"] . '</div>';
                $table_quiz .= '</div>';
            }
            $user = JFactory::getUser();
            $user_id = $user->id;
            $media->code .= '<div class="uk-panel uk-panel-box uk-panel-box-secondary"><h3 class="uk-panel-title">' . $result_quiz->name . '</h3></div>';
            $media->code .= '<div class="uk-panel uk-panel-box uk-panel-box-secondary uk-margin">' . $table_quiz . '</div>';
            if ($result_quiz->description != "") {
                $media->code .= '<div class="uk-panel uk-panel-box uk-panel-box-secondary uk-margin">' . $result_quiz->description . '</div>';
            }
            if (isset($result_settings_quiz->nb_quiz_select_up) && $result_settings_quiz->nb_quiz_select_up != 0 && $result_settings_quiz->show_nb_quiz_select_up == 0) {
                $order_by = " ORDER BY RAND() LIMIT  " . $result_settings_quiz->nb_quiz_select_up . "";
            } else {
                $order_by = " ORDER BY question_order LIMIT  " . $result_settings_quiz->nb_quiz_select_up . "";
            }
            if ($result_quiz->is_final == 1) {
                $sql = "SELECT \tquizzes_ids FROM #__guru_quizzes_final WHERE qid=" . $media->id;
                $db->setQuery($sql);
                $db->query();
                $result = $db->loadResult();
                $result_qids = explode(",", trim($result, ","));
                if ($result_qids["0"] == "") {
                    $result_qids["0"] = 0;
                }
                if (isset($result_qids) && count($result_qids) > 0) {
                    foreach ($result_qids as $key => $value) {
                        $quiz_id = intval($value);
                        $sql = "select `published` from #__guru_quiz where `id`=" . intval($quiz_id);
                        $db->setQuery($sql);
                        $db->query();
                        $published = $db->loadColumn();
                        $published = @$published["0"];
                        if (intval($published) == 0) {
                            unset($result_qids[$key]);
                        }
                    }
                }
                if (count($result_qids) == 0 || $result_qids["0"] == "") {
                    $result_qids["0"] = 0;
                }
                $query = "SELECT * FROM #__guru_questions_v3 WHERE qid IN (" . implode(",", $result_qids) . ") and published=1" . $order_by;
            } else {
                $query = "SELECT * FROM #__guru_questions_v3 WHERE qid = " . $media->id . " and published=1" . $order_by;
            }
            $db->setQuery($query);
            $quiz_questions = $db->loadObjectList();
            $media->code .= '<div id="the_quiz" class="uk-panel uk-panel-box-secondary uk-margin">';
            $array_quest = array();
            $question_number = 1;
            $per_page = $result_quiz->questions_per_page;
            // questions per page
            if ($per_page == 0) {
                $per_page = count($quiz_questions);
            }
            $nr_pages = 1;
            // default one page
            if (count($quiz_questions) > 0 && count($quiz_questions) > $per_page) {
                $nr_pages = ceil(count($quiz_questions) / $per_page);
            }
            for ($pag = 1; $pag <= $nr_pages; $pag++) {
                $i = ($pag - 1) * $per_page;
                $added = 0;
                $display = "";
                if ($pag == 1) {
                    $display = "block";
                } else {
                    $display = "none";
                }
                $media->code .= '<div id="quiz_page_' . $pag . '" style="display:' . $display . ';">';
                // start page
                while (isset($quiz_questions[$i]) && $added < $per_page) {
                    $all_quiz_question_from_page[] = $quiz_questions[$i]->id;
                    $question_answers_number = 0;
                    $media_associated_question = json_decode($quiz_questions[$i]->media_ids);
                    $media_content = "";
                    $result_media = array();
                    $q = "SELECT * FROM #__guru_question_answers WHERE question_id = " . intval($quiz_questions[$i]->id) . " ORDER BY id";
                    $db->setQuery($q);
                    $question_answers = $db->loadObjectList();
                    for ($j = 0; $j < count($media_associated_question); $j++) {
                        @($media_that_needs_to_be_sent = self::getMediaFromId($media_associated_question[$j]));
                        if (isset($media_that_needs_to_be_sent) && count($media_that_needs_to_be_sent) > 0) {
                            $media_created = $helperclass->create_media_using_plugin_for_quiz($media_that_needs_to_be_sent["0"], $configs, '24', '', '150', 150);
                            if ($media_that_needs_to_be_sent["0"]->type == "file") {
                                // do nothing
                            } elseif ($media_that_needs_to_be_sent["0"]->type == "video") {
                                if (strpos($media_created, "width") !== FALSE) {
                                    $media_created = preg_replace('/width="(.*)"/msU', 'width="150"', $media_created);
                                }
                                if (strpos($media_created, "height") !== FALSE) {
                                    $media_created = preg_replace('/height="(.*)"/msU', 'height="150"', $media_created);
                                }
                                $hover_div = '<div class="hover-video" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">&nbsp;</div>';
                                $media_created = $hover_div . $media_created;
                            } elseif ($media_that_needs_to_be_sent["0"]->type == "image") {
                                $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_created . '</a>';
                            } elseif ($media_that_needs_to_be_sent["0"]->type == "text") {
                                $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                            } elseif ($media_that_needs_to_be_sent["0"]->type == "Article") {
                                $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                            } elseif ($media_that_needs_to_be_sent["0"]->type == "url") {
                                $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . $media_that_needs_to_be_sent["0"]->url . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                            } elseif ($media_that_needs_to_be_sent["0"]->type == "audio") {
                                // do nothing
                            } elseif ($media_that_needs_to_be_sent["0"]->type == "docs") {
                                // do nothing
                            }
                            $result_media[] = $media_created;
                        }
                    }
                    $media->code .= '<div class="guru-question"><div class="uk-grid">';
                    if ($quiz_questions[$i]->type == "essay") {
                        //start essay question
                        $doc = JFactory::getDocument();
                        $doc->addStyleSheet(JURI::root() . 'components/com_guru/css/redactor.css');
                        echo '<script type="text/javascript" language="javascript" src="' . JURI::root() . 'components/com_guru/js/redactor.min.js' . '"></script>';
                        $media->code .= '		<div class="uk-width-large-1-1">';
                        $media->code .= '<h4>' . $quiz_questions[$i]->question_content . '</h4>' . implode("", $result_media);
                        $media->code .= '<textarea style="max-width:100%" name="essay[' . intval($quiz_questions[$i]->id) . ']" rows="10" class="useredactor"></textarea>';
                        $media->code .= '		</div>';
                        $upload_script = 'window.addEvent( "domready", function(){
											jQuery(".useredactor").redactor({
												 buttons: [\'bold\', \'italic\', \'underline\', \'link\', \'alignment\', \'unorderedlist\', \'orderedlist\']
											});
											jQuery(".redactor_useredactor").css("height","400px");
										  });';
                        $doc->addScriptDeclaration($upload_script);
                    } else {
                        // the rest: true/false, single, multiple
                        $media->code .= '<div class="uk-width-large-4-10 uk-width-medium-4-10 uk-width-small-1-1">';
                        $media->code .= '<h4>' . $quiz_questions[$i]->question_content . "</h4>" . implode("<br/>", $result_media);
                        $media->code .= '</div>';
                    }
                    $media->code .= '<div class="uk-width-large-6-10 uk-width-medium-6-10 uk-width-small-1-1">';
                    if ($quiz_questions[$i]->type == "true_false") {
                        $media->code .= '<div class="uk-grid">';
                        foreach ($question_answers as $question_answer) {
                            if ($question_answer->answer_content_text == "True") {
                                $question_answer->answer_content_text = JText::_("GURU_QUESTION_OPTION_TRUE");
                            } elseif ($question_answer->answer_content_text == "False") {
                                $question_answer->answer_content_text = JText::_("GURU_QUESTION_OPTION_FALSE");
                            }
                            $media->code .= '<div class="uk-float-left guru-question-answer uk-width-large-2-5 uk-width-small-1-1 uk-width-medium-2-5" id="guru-question-answer-' . $question_answer->question_id . '-' . $question_answer->id . '">
												 <div class="uk-float-left">
													<input type="radio" onclick="javascript:answerTrueFalseSelected(' . intval($question_answer->question_id) . ', ' . intval($question_answer->id) . ');" name="truefs_ans[' . intval($question_answer->question_id) . ']" value="' . $question_answer->id . '" />
													<span class="lbl"></span>
												 </div>
												 <div class="uk-float-left">
													&nbsp;' . $question_answer->answer_content_text . '&nbsp;&nbsp;
												 </div>
											 </div>';
                        }
                        $media->code .= '</div>';
                    } elseif ($quiz_questions[$i]->type == "single") {
                        if (isset($question_answers) && count($question_answers) > 0) {
                            $media->code .= '<div class="uk-grid">';
                            foreach ($question_answers as $question_answer) {
                                $media_associated_answers = json_decode($question_answer->media_ids);
                                $media_content = "";
                                $result_media_answers = array();
                                if (isset($media_associated_answers) && count($media_associated_answers) > 0) {
                                    foreach ($media_associated_answers as $media_key => $answer_media_id) {
                                        $media_that_needs_to_be_sent = self::getMediaFromId($answer_media_id);
                                        $media_created = $helperclass->create_media_using_plugin_for_quiz($media_that_needs_to_be_sent["0"], $configs, '24', '', '150', 150);
                                        if ($media_that_needs_to_be_sent["0"]->type == "file") {
                                            // do nothing
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "video") {
                                            if (strpos($media_created, "width") !== FALSE) {
                                                $media_created = preg_replace('/width="(.*)"/msU', 'width="150"', $media_created);
                                            }
                                            if (strpos($media_created, "height") !== FALSE) {
                                                $media_created = preg_replace('/height="(.*)"/msU', 'height="150"', $media_created);
                                            }
                                            $hover_div = '<div class="hover-video" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">&nbsp;</div>';
                                            $media_created = $hover_div . $media_created;
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "image") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_created . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "text") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "Article") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "url") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . $media_that_needs_to_be_sent["0"]->url . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "audio") {
                                            // do nothing
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "docs") {
                                            // do nothing
                                        }
                                        $result_media_answers[] = $media_created;
                                    }
                                }
                                $option_value = '<input type="radio" id="ans' . $question_answer->id . '" name="answers_single[' . intval($quiz_questions[$i]->id) . ']" value="' . $question_answer->id . '" onclick="javascript:answerSingleSelected(' . intval($question_answer->question_id) . ', ' . intval($question_answer->id) . ');"/><span class="lbl"></span>&nbsp;' . $question_answer->answer_content_text . '<br/>' . implode("<br/>", $result_media_answers) . "<br/>";
                                $media->code .= '<div class="guru-question-answer uk-width-large-2-5 uk-width-small-1-1 uk-width-medium-2-5" id="guru-question-answer-' . $question_answer->question_id . '-' . $question_answer->id . '">' . $option_value . '</div>';
                            }
                            $media->code .= '</div>';
                        }
                    } elseif ($quiz_questions[$i]->type == "multiple") {
                        if (isset($question_answers) && count($question_answers) > 0) {
                            $media->code .= '<div class="uk-grid">';
                            foreach ($question_answers as $question_answer) {
                                $media_associated_answers = json_decode($question_answer->media_ids);
                                $media_content = "";
                                $result_media_answers = array();
                                if (isset($media_associated_answers) && count($media_associated_answers) > 0) {
                                    foreach ($media_associated_answers as $media_key => $answer_media_id) {
                                        $media_that_needs_to_be_sent = self::getMediaFromId($answer_media_id);
                                        $media_created = $helperclass->create_media_using_plugin_for_quiz($media_that_needs_to_be_sent["0"], $configs, '24', '', '150', 150);
                                        if ($media_that_needs_to_be_sent["0"]->type == "file") {
                                            // do nothing
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "video") {
                                            if (strpos($media_created, "width") !== FALSE) {
                                                $media_created = preg_replace('/width="(.*)"/msU', 'width="150"', $media_created);
                                            }
                                            if (strpos($media_created, "height") !== FALSE) {
                                                $media_created = preg_replace('/height="(.*)"/msU', 'height="150"', $media_created);
                                            }
                                            $hover_div = '<div class="hover-video" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">&nbsp;</div>';
                                            $media_created = $hover_div . $media_created;
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "image") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_created . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "text") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "Article") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . JURI::root() . "index.php?option=com_guru&view=gurutasks&task=preview&id=" . intval($media_that_needs_to_be_sent["0"]->id) . "&tmpl=component" . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "url") {
                                            $media_created = '<a href="#" onclick="javascript:openMyModal(0, 0, \'' . $media_that_needs_to_be_sent["0"]->url . '\'); return false;">' . $media_that_needs_to_be_sent["0"]->name . '</a>';
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "audio") {
                                            // do nothing
                                        } elseif ($media_that_needs_to_be_sent["0"]->type == "docs") {
                                            // do nothing
                                        }
                                        $result_media_answers[] = $media_created;
                                    }
                                }
                                $option_value = '<input type="checkbox" onclick="javascript:answerMultipleSelected(' . intval($question_answer->question_id) . ', ' . intval($question_answer->id) . ');" name="multiple_ans[' . intval($quiz_questions[$i]->id) . '][]" value="' . $question_answer->id . '"/>&nbsp;' . $question_answer->answer_content_text . '<br/>' . implode("<br/>", $result_media_answers) . "<br/>";
                                $media->code .= '<div class="guru-question-answer uk-width-large-2-5 uk-width-small-1-1 uk-width-medium-2-5" id="guru-question-answer-' . $question_answer->question_id . '-' . $question_answer->id . '">' . $option_value . '</div>';
                            }
                            $media->code .= '</div>';
                        }
                    }
                    $media->code .= '	</div>';
                    $media->code .= '</div></div>';
                    $i++;
                    $added++;
                }
                if ($pag == $nr_pages) {
                    $catid_req = JRequest::getVar("catid", "");
                    $module_req = JRequest::getVar("module", "");
                    $cid_req = JRequest::getVar("cid", "");
                    $media->code .= '<br />
						   <div align="left" style="padding-left:4px;">
								<input type="hidden" value="' . $media->name . '" id="quize_name" name="quize_name"/>
								<input type="hidden" value="' . $result_settings_quiz->nb_quiz_select_up . '" id="nb_of_questions" name="nb_of_questions"/>
								<input type="hidden" value="' . $media->id . '" id="quize_id" name="quize_id"/>
								<input type="hidden" value="1" name="submit_action" id="submit_action" />
								<input type="hidden" value="' . $catid_req . '" name="catid_req" id="catid_req">
								<input type="hidden" value="' . $module_req . '" name="module_req" id="module_req">
								<input type="hidden" value="' . $cid_req . '" name="cid_req" id="cid_req">
								<input type="hidden" value="' . $open_target . '" name="open_target" id="open_target">
								<input type="hidden" value="' . implode(",", $all_quiz_question_from_page) . '" name="all_questions_ids">
								<input type="button"  name="submitbutton" class="uk-button uk-button-success" id ="submitbutton" value="' . JText::_("GURU_QUIZ_SUBMIT") . '" onclick="document.getElementById(\'quizz_exam\').submit();" />
						  </div>';
                }
                $media->code .= '</div>';
                // end page
            }
            if ($nr_pages > 1) {
                $media->code .= '<div class="pagination pagination-centered"><ul class="uk-pagination">';
                $media->code .= '<li class="pagination-start" id="pagination-start"><span class="pagenav">' . JText::_("GURU_START") . '</span></li>';
                $media->code .= '<li class="pagination-prev" id="pagination-prev"><span class="pagenav">' . JText::_("GURU_PREV") . '</span></li>';
                for ($p = 1; $p <= $nr_pages; $p++) {
                    if ($p == 1) {
                        $media->code .= '<li id="list_1"><span class="pagenav">1</span></li>';
                    } else {
                        $media->code .= '<li id="list_' . $p . '">
											<a onclick="changePage(' . intval($p) . ', ' . intval($nr_pages) . '); return false;" href="#">' . $p . '</a>
										 </li>';
                    }
                }
                $media->code .= '<li class="pagination-next" id="pagination-next">
										<a href="#" onclick="changePage(2, ' . intval($nr_pages) . '); return false;">' . JText::_("GURU_NEXT") . '</a>
									 </li>';
                $media->code .= '<li class="pagination-end" id="pagination-end">
										<a href="#" onclick="changePage(' . intval($nr_pages) . ', ' . intval($nr_pages) . '); return false;">' . JText::_("GURU_END") . '</a>
									 </li>';
                $media->code .= '</ul></div>';
            }
            // create quiz taken and question
            $sql = "SELECT `open_target` FROM `#__guru_config` WHERE `id`=1";
            $db->setQuery($sql);
            $db->query();
            $open_target = $db->loadColumn();
            $open_target = $open_target["0"];
            $media->code .= '<input type="hidden" value="' . ($question_number - 1) . '" name="question_number" id="question_number" />';
            $media->code .= '<input type="hidden" value="' . implode(",", $array_quest) . '" name="list_questions_id" id="list_questions_id" />';
            $media->code .= '<input type="hidden" value="' . $max_id . '" name="id_quiz_question" id="id_quiz_question" />';
            $_SESSION["questionsids"] = implode(",", $array_quest);
            $_SESSION["quiz_id"] = $media->id;
            if (isset($result_time_user) && $result_time_user <= 0) {
                $disabled = 'disabled=disabled';
                $msg = JText::_("GURU_QUIZ_RES_MC");
                $_SESSION["submit_disabled"] = $msg;
            } else {
                $disabled = '';
            }
            $media->code .= '</div>';
        }
        $return = "";
        if (isset($media->show_instruction) && $media->show_instruction == "0") {
            //show the instructions above
            $return = '<div  style="text-align:center"><i>' . $media->instructions . '</i></div>' . $media->code;
        } elseif (isset($media->show_instruction) && $media->show_instruction == "1") {
            //show the instructions above
            $return = $media->code . '<br /><br />
					 <div class="uk-text-center"><i>' . $media->instructions . '</i></div>';
        } elseif (isset($media->show_instruction) && $media->show_instruction == "2") {
            //don't show the instructions
            $return = $media->code;
        } elseif (!isset($media->show_instruction) || $media->show_instruction == NULL) {
            $return = $media->code;
        }
        if (@$media->type != 'quiz') {
            if (@$media->hide_name == 0) {
                $return .= '<div class="uk-text-bold uk-text-center">' . @$media->name . '</div>';
            }
        }
        return stripslashes($return);
    }