Example #1
0
$course_config = json_decode($config->psgpage);
$course_style = json_decode($config->st_psgpage);
$wrap = $course_config->course_wrap_image;
//0-yes, 1-no
$img_align = $course_config->course_image_alignment;
//0-left, 1-right
$type = $course_config->course_image_size_type == "0" ? "w" : "h";
if (trim($program->image) != "") {
    $array = explode("/", $program->image);
    if (isset($array) && count($array) > 0) {
        $program->imageN = $array[count($array) - 1];
    }
}
if (trim($program->image) == "" || $program->image == NULL) {
    $program->image = "components/com_guru/images/no_image.gif";
    $guruHelper->createThumb($program->image, "components/com_guru/images", $course_config->course_image_size, $type);
} else {
    $guruHelper->createThumb($program->imageN, $config->imagesin . "/courses", $course_config->course_image_size, $type);
    $program->image = str_replace("thumbs/", "", $program->image);
}
$img_size = getimagesize(JPATH_SITE . DS . $program->image);
$height = "auto";
if (isset($img_size) && isset($img_size["1"])) {
    $height = $img_size["1"];
}
$db = JFactory::getDBO();
$sql = "SELECT currency, currencypos, course_lesson_release  from #__guru_config where id =1";
$db->setQuery($sql);
$db->query();
$res = $db->loadAssoc();
$amount_students = $guruModelguruProgram->getStudentAmount($program->id);
Example #2
0
    if (isset($array) && count($array) > 0) {
        $author->imageName = $array[count($array) - 1];
    }
}
$type = $config_author->author_image_size_type == "0" ? "w" : "h";
$return = "";
$wrap = $config_author->author_wrap_image;
//0-yes, 1-no
$img_align = $config_author->author_image_alignment;
//0-left, 1-right
$bio_align = $config_author->author_description_alignment == "0" ? "left" : "right";
$item_id = JRequest::getVar("Itemid", "0");
if (trim($author->images) == "") {
    $author->images = "components/com_guru/images/thumbs/no_image.gif";
    $author->imageName = "no_image.gif";
    $guruHelper->createThumb($author->imageName, "components" . DS . "com_guru" . DS . "images", $config_author->author_image_size, $type);
} else {
    $guruHelper->createThumb($author->imageName, $config->imagesin . "/authors", $config_author->author_image_size, $type);
}
$image = "";
if (trim($author->images) != "") {
    if ($img_align == 0) {
        $image = '<img class=" thumbnail pull-left" src="' . JURI::root() . $author->images . '" />';
    } else {
        $image = '<img class=" thumbnail pull-right" src="' . JURI::root() . $author->images . '" />';
    }
}
$bio = $author->full_bio;
// start the calculation for image, description and top links
// count layout
if ($wrap == "1") {
Example #3
0
function generateCoursesCellsB($config_courses, $style_courses, $course, $config)
{
    $guruHelper = new guruHelper();
    $detect = new Mobile_Detect();
    $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
    $type = $config_courses->courses_image_size_type == "0" ? "w" : "h";
    $return = "";
    $layout = $config_courses->courseslayout;
    $wrap = $config_courses->courses_wrap_image;
    //0-yes, 1-no
    $img_align = $config_courses->courses_image_alignment;
    //0-left, 1-right
    $read_more = $config_courses->courses_read_more;
    //0-yes 1-no
    $read_align = $config_courses->courses_read_more_align == "0" ? "left" : "right";
    $description_align = $config_courses->courses_description_alignment == "0" ? "left" : "right";
    $edit_read_more = $config_courses->courses_read_more;
    $alias = trim($course->alias) == "" ? JFilterOutput::stringURLSafe($course->name) : trim($course->alias);
    $item_id = JRequest::getVar("Itemid", "0");
    $rt = "";
    $style_d = "";
    if ($layout == "1") {
        //mini profile
        $image_name = explode("/", $course->image_avatar);
        $image_name = $image_name[count($image_name) - 1];
        if (trim($course->image_avatar) == "") {
            $course->image_avatar = "components/com_guru/images/thumbs/no_image.gif";
            $guruHelper->createThumb($image_name, "components/com_guru/images", $config_courses->courses_image_size, $type);
        } else {
            $guruHelper->createThumb($image_name, $config->imagesin . "/courses", $config_courses->courses_image_size, $type);
        }
        $image_avatar = "";
        if (trim($course->image_avatar) != "") {
            $image = '<img  src="' . JURI::root() . $course->image_avatar . '" />';
            $image_left = '<a class="thumbnail pull-left"  href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $image . '</a>';
            $image_right = '<a class="thumbnail pull-right"  href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $image . '</a>';
        }
        $description = cutBio($course->description, $config_courses->courses_description_length, $config_courses->courses_description_type, $config_courses->courses_description_mode);
        $return .= '<div>';
        if ($wrap == "1") {
            //no wrap
            $class_display = "display:table-cell;";
            if ($img_align == "0") {
                // left
                $return .= "<div>";
                if (trim($image) != "") {
                    $return .= '<div class="image_guru">' . $image_left . '</div>';
                }
                $return .= '<div  class="' . $style_courses->courses_name . '">
											<a href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . intval($item_id)) . '">' . $course->name . '</a>
										</div>';
                if ($read_more == "0" && $edit_read_more == "0") {
                    $rt = '<div class="readon"><a class="btn btn-primary" style="float:' . $read_align . '" href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a></div>';
                }
                $return .= '<div class="' . $style_courses->courses_description . ' " style="text-align:' . $description_align . ' ' . $style_d . '; ' . $class_display . '"><p>' . $description . '</p>' . $rt . '</div>';
                $return .= "</div>";
            } elseif ($img_align == "1") {
                // right
                $return .= "<div>";
                if (trim($image) != "") {
                    $return .= "<div class='image_guru'>" . $image_right . "</div>";
                }
                $return .= '<div class=" ' . $style_courses->courses_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $course->name . '</a>
											</div>';
                if ($read_more == "0" && $edit_read_more == "0") {
                    $rt = '<div class="readon"><a class="btn btn-primary" style="float:' . $read_align . '" href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a></div>';
                }
                $return .= '<div class="' . $style_courses->courses_description . ' " style="text-align:' . $description_align . '; ' . $class_display . '"><p>' . $description . '</p>' . $rt . '</div>';
                $return .= "</div>";
            }
        } elseif ($wrap == "0") {
            //wrap
            if ($img_align == "0") {
                // left
                $return .= '<div>';
                if (trim($image) != "") {
                    $return .= '<div class="image_guru">' . $image_left . '</div>';
                }
                $return .= '<div class="' . $style_courses->courses_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $course->name . '</a>
											</div>';
                if ($read_more == "0" && $edit_read_more == "0") {
                    $rt = '<div class="readon"><a class="btn btn-primary" style="float:' . $read_align . '" href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a></div>';
                }
                $return .= '<div class="' . $style_courses->courses_description . '" style="text-align:' . $description_align . ';"><p>' . $description . '</p>' . $rt . '</div>';
                $return .= "</div>";
            } elseif ($img_align == "1") {
                // right
                $return .= "<div>";
                if (trim($image) != "") {
                    $return .= "<div class='image_guru'>" . $image_right . "</div>";
                }
                $return .= '<div class="' . $style_courses->courses_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $course->name . '</a>
											</div>';
                if ($read_more == "0" && $edit_read_more == "0") {
                    $rt = '<div class="readon"><a class="btn btn-primary" style="float:' . $read_align . '" href="' . JRoute::_('index.php?option=com_guru&view=guruPrograms&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a></div>';
                }
                $return .= '<div class=" ' . $style_courses->courses_description . '" style="text-align:' . $description_align . ';"><p>' . $description . '</p>' . $rt . '</div>';
                $return .= "</div>";
            }
        }
        $return .= '</div>';
    }
    //if mini profile
    return $return;
}
Example #4
0
    $helper = new guruHelper();
    $width = $_row->width;
    $height = $_row->height;
    $new_size = "";
    $type = "";
    if (intval($width) != 0) {
        $new_size = $width;
        $type = "w";
    } else {
        $new_size = $height;
        $type = "h";
    }
    $q = "SELECT * FROM #__guru_config WHERE id = '1' ";
    $db->setQuery($q);
    $configs = $db->loadObject();
    $helper->createThumb($_row->local, $configs->imagesin . '/media', $new_size, $type);
    $media_image = '<img id="view_imagelist23" name="view_imagelist" style="margin:5px;" border="0" alt="" src="' . JURI::root() . $configuration->imagesin . "/media/thumbs" . $_row->local . '" />';
} else {
    $media_image = '<img id="view_imagelist23" name="view_imagelist" style="margin:5px;" border="0" alt="" src="../images/M_images/blank.png" />';
}
// generating thumb image - stop
?>
								<?php 
echo $media_image;
?>
								<input type="hidden" id="image" name="image" value="<?php 
echo $_row->local;
?>
" />
							</td>
						</tr>			
Example #5
0
function generateCategsCells($config_categs, $style_categs, $course, $config)
{
    $guruHelper = new guruHelper();
    $item_id = JRequest::getVar("Itemid", "0");
    $type = $config_categs->ctgs_image_size_type == "0" ? "w" : "h";
    $return = "";
    $layout = $config_categs->ctgslayout;
    $wrap = $config_categs->ctgs_wrap_image;
    //0-yes, 1-no
    $img_align = $config_categs->ctgs_image_alignment;
    //0-left, 1-right
    $read_more = $config_categs->ctgs_read_more;
    //0-yes 1-no
    $read_align = $config_categs->ctgs_read_more_align == "0" ? "left" : "right";
    $description_align = $config_categs->ctgs_description_alignment == "0" ? "left" : "right";
    $edit_read_more = $config_categs->ctgs_read_more;
    $courses_number = countCoursesNumber($course->id);
    $sub_categs_number = countSubcategsNumber($course->id);
    $show_empty_categs = $config_categs->ctgs_show_empty_catgs;
    $show = true;
    if (isset($course->alias) && $course->alias != "") {
        $alias = trim($course->alias);
    } else {
        $alias = JFilterOutput::stringURLSafe($course->name);
    }
    //$alias = isset($course->alias) == "" ? trim($course->alias) : JFilterOutput::stringURLSafe($course->name);
    if ($show_empty_categs == "0") {
        $show = true;
    } elseif ($show_empty_categs == "1") {
        if (intval($sub_categs_number) > 0 || intval($courses_number) > 0) {
            $show = true;
        } else {
            $show = false;
        }
    }
    $edit_sum = "";
    $edit_sum_array = array();
    if ($sub_categs_number > 0) {
        if ($sub_categs_number == 1) {
            $edit_sum_array[] = $sub_categs_number . " " . JText::_("GURU_NUMBER_CATEGORY");
        } else {
            $edit_sum_array[] = $sub_categs_number . " " . JText::_("GURU_NUMBER_CATEGORIES");
        }
    }
    if ($courses_number > 0) {
        if ($courses_number == 1) {
            $edit_sum_array[] = $courses_number . " " . JText::_("GURU_NUMBER_COURSE");
        } else {
            $edit_sum_array[] = $courses_number . " " . JText::_("GURU_NUMBER_COURSES");
        }
    }
    $edit_sum = "";
    if (count($edit_sum_array) > 0) {
        $edit_sum = " (" . implode(" / ", $edit_sum_array) . ") ";
    }
    if ($show === true) {
        if ($layout == "1") {
            //mini profile
            if (trim($course->image) == "") {
                $course->image = "components/com_guru/images/thumbs/no_image.gif";
                $course->imageName = "no_image.gif";
                $guruHelper->createThumb($course->imageName, "components" . DS . "com_guru" . DS . "images", $config_categs->ctgs_image_size, $type);
            } else {
                $guruHelper->createThumb($course->imageName, $config->imagesin . "/categories", $config_categs->ctgs_image_size, $type);
            }
            $image = "";
            if (trim($course->image) != "") {
                if ($img_align == 0) {
                    $image = '<img alt="Category Image" class="' . $style_categs->ctgs_image . ' thumbnail pull-left" src="' . JURI::root() . $course->image . '" />';
                } else {
                    $image = '<img alt="Category Image" class="' . $style_categs->ctgs_image . ' thumbnail pull-right" src="' . JURI::root() . $course->image . '" />';
                }
                $image = '<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $image . '</a>';
            }
            $description = cutBio($course->description, $config_categs->ctgs_description_length, $config_categs->ctgs_description_type, $config_categs->ctgs_description_mode);
            $return .= '<div>';
            $class_display = "display:table-cell;";
            if ($wrap == "1") {
                //no wrap
                if ($img_align == "0") {
                    // left
                    $return .= "<div>";
                    $return .= '<div>';
                    $return .= '<div class="' . $style_categs->ctgs_categ_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '"><h4>' . $course->name . $edit_sum . '</h4></a>
											</div>';
                    if (trim($image) != "") {
                        $return .= '<div class="' . $style_categs->ctgs_image . '">' . $image . '</div>';
                    }
                    if ($read_more == "0" && $edit_read_more == "0") {
                        $rmore = '<a style="float:' . $read_align . '" class="btn btn-primary" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                    } else {
                        $rmore = "";
                    }
                    $return .= '<div class="' . $style_categs->ctgs_description . '" style="text-align:' . $description_align . '; ' . $class_display . '"><p>' . $description . '</p>' . $rmore . '</div>';
                    $return .= "</div>";
                    $return .= '<div>';
                    $return .= "</div>";
                    $return .= "</div>";
                } elseif ($img_align == "1") {
                    // right
                    $return .= "<div>";
                    $return .= '<div>';
                    $return .= '<div class="' . $style_categs->ctgs_categ_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '"><h4>' . $course->name . $edit_sum . '</h4></a>
											</div>';
                    if (trim($image) != "") {
                        $return .= '<div class="' . $style_categs->ctgs_image . '">' . $image . '</div>';
                    }
                    if ($read_more == "0" && $edit_read_more == "0") {
                        $rmore = '<a style="float:' . $read_align . '" class="btn btn-primary" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                    } else {
                        $rmore = "";
                    }
                    $return .= '<div class="' . $style_categs->ctgs_description . '" style="text-align:' . $description_align . '; ' . $class_display . '"><p>' . $description . '</p>' . $rmore . '</div>';
                    $return .= "</div>";
                    $return .= '<div>';
                    $return .= "</div>";
                    $return .= "</div>";
                }
            } elseif ($wrap == "0") {
                //wrap
                if ($img_align == "0") {
                    // left
                    $return .= "<div>";
                    $return .= '<div>';
                    $return .= '<div class="' . $style_categs->ctgs_categ_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '"><h4>' . $course->name . $edit_sum . '</h4></a>
											</div>';
                    if (trim($image) != "") {
                        $return .= '<div class="' . $style_categs->ctgs_image . '">' . $image . '</div>';
                    }
                    if ($read_more == "0" && $edit_read_more == "0") {
                        $rmore = '<a style="float:' . $read_align . '" class="btn btn-primary" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                    } else {
                        $rmore = "";
                    }
                    $return .= '<div class="' . $style_categs->ctgs_description . '" style="text-align:' . $description_align . ';"><p>' . $description . '</p>' . $rmore . '</div>';
                    $return .= "</div>";
                    $return .= "</div>";
                } elseif ($img_align == "1") {
                    // right
                    $return .= "<div>";
                    $return .= '<div>';
                    $return .= '<div class="' . $style_categs->ctgs_categ_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '"><h4>' . $course->name . $edit_sum . '</h4></a>
											</div>';
                    if (trim($image) != "") {
                        $return .= '<div class="' . $style_categs->ctgs_image . '" style="float:right;">' . $image . '</div>';
                    }
                    if ($read_more == "0" && $edit_read_more == "0") {
                        $rmore = '<a style="float:' . $read_align . '" class="btn btn-primary" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                    } else {
                        $rmore = "";
                    }
                    $return .= '<div class="' . $style_categs->ctgs_description . '" style="text-align:' . $description_align . ';"><p>' . $description . '</p>' . $rmore . '</div>';
                    $return .= "</div>";
                    $return .= "</div>";
                }
            }
            $return .= '</div>';
        }
        //if mini profile
    }
    //if show
    return $return;
}
Example #6
0
File: tabs.php Project: JozefAB/qk
function tab5($author, $course, $config, $course_config)
{
    $authors_config = json_decode($config->st_authorspage);
    $detect = new Mobile_Detect();
    $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
    if ($deviceType == "phone") {
        $class_th_links = "class='teacher_links2'";
    } else {
        $class_th_links = "class='well teacher_links'";
    }
    ?>
<div class="course_view_teacher">
    <div id="teacherdetail" class="clearfix com-cont-wrap">
    <!-- Author Name -->
    <div class="name_guru page_title">
        <h2><?php 
    echo $author->name;
    ?>
</h2>
    </div>
     <div class="teacher_row_guru">
        <div class="teacher_cell_guru span12">
            <div class = 'weblinks'>
                <div>
                    <div class="well teacher_links g_toolbar">
                        <?php 
    if (trim($author->show_email) != "" && $author->show_email == 1) {
        ?>
                            <span class="teacher_email_guru">
                                    <a href="mailto:<?php 
        echo $author->email;
        ?>
">
                                        <?php 
        echo JText::_('GURU_EMAIL');
        ?>
                                    </a>
                                </span>
                            <?php 
    }
    if (trim($author->show_website) != "http://" && $author->show_website == 1) {
        ?>
                            <span class="guru_teacher_site">
                                    <a href="<?php 
        echo $author->website;
        ?>
" target="_blank">
                                        <?php 
        echo JText::_('GURU_SITE');
        ?>
                                    </a>
                                </span>
                            <?php 
    }
    if (trim($author->show_blog) != "http://" && $author->show_blog == 1) {
        ?>
                            <span class="guru_teacher_blog">
                                    <a href="<?php 
        echo $author->blog;
        ?>
" target="_blank">
                                        <?php 
        echo JText::_('GURU_BLOG');
        ?>
                                    </a>
                                </span>
                            <?php 
    }
    if (trim($author->show_twitter) != "" && $author->show_twitter == 1) {
        ?>
                            <span class="guru_teacher_twitter">
                                    <a href="http://www.twitter.com/<?php 
        echo $author->twitter;
        ?>
" target="_blank">
                                        <?php 
        echo JText::_('GURU_TWITTER');
        ?>
                                    </a>
                                </span>
                            <?php 
    }
    if (trim($author->show_facebook) != "http://" && $author->show_facebook == 1) {
        ?>
                            <span class="guru_teacher_facebook">
                                    <a href="<?php 
        echo $author->facebook;
        ?>
" target="_blank">
                                        <?php 
        echo JText::_('GURU_FACEBOOK');
        ?>
                                    </a>
                                </span>
                            <?php 
    }
    ?>
                    </div>
                </div>
            </div>
             <div>
                <div>
                <div class="description_guru clearfix" style="text-align:left">
                	<div class='image_guru'>
                        <?php 
    $config_author = json_decode($config->authorpage);
    $img_align = $config_author->author_image_alignment;
    //0-left, 1-right
    if ($img_align == 0) {
        $align = "left";
    } else {
        $align = "right";
    }
    $guruHelper = new guruHelper();
    if (trim($author->images) != "") {
        $type = $course_config->course_image_size_type == "0" ? "w" : "h";
        $guruHelper->createThumb($author->imageName, $config->imagesin . "/authors", $course_config->course_image_size, $type);
        ?>
                            <a href="<?php 
        echo JRoute::_('index.php?option=com_guru&view=guruauthor&layout=view&task=author&cid=' . $author->id . "-" . JFilterOutput::stringURLSafe($author->name));
        ?>
">
                                
                                <img src='<?php 
        echo JURI::root() . $author->images;
        ?>
' alt='author image' align='<?php 
        echo $align;
        ?>
' /></a>
                            <?php 
    }
    ?>
                    </div>
                	<?php 
    echo $author->full_bio;
    ?>
                </div>
                    <div class="teacher_info">
                     <h2 class="teacher_courses_heading_guru"><?php 
    echo JText::_("GURU_TAB_AUTHOR_COURSES");
    ?>
</h2>
                       <div class="clearfix">
                        <div class="g_table_wrap"> 
                            <div class="table_container columns">
                                <table class="table table-striped">
                                    <tr class="courses_table_header g_table_header">
                                        <th class="g_cell_1" ><?php 
    echo JText::_("GURU_TAB_AUTHOR_COURSES_NAME");
    ?>
</th>
                                        <th class="g_cell_2"><?php 
    echo JText::_("GURU_TAB_AUTHOR_COURSES_LEVEL");
    ?>
</th>
                                        <th class="g_cell_3"><?php 
    echo JText::_("GURU_TAB_AUTHOR_COURSES_RELEASE");
    ?>
</th>
                                    </tr>
                                    <?php 
    $k = 0;
    if (count($course) > 0) {
        $itemid = JRequest::getVar("Itemid", "0");
        for ($i = 0; $i < count($course); $i++) {
            $class = "odd";
            if ($k % 2 != 0) {
                $class = "even";
            }
            ?>
                                        <tr class="<?php 
            echo $class;
            ?>
">          
                                            <td class="g_cell_1">
                                                <?php 
            /***$alias = trim($course[$i]->alias) == "" ? JFilterOutput::stringURLSafe($course[$i]->name) : trim($course[$i]->alias);
               $courseLink = JRoute::_('index.php?option=com_guru&view=guruPrograms&layout=view&cid='.$course[$i]->id."-".$alias."&Itemid=".$itemid);***/
            if (isset($course[$i]->alias)) {
                if (trim($course[$i]->alias) == "") {
                    $alias = JFilterOutput::stringURLSafe($course[$i]->name);
                } else {
                    $alis = trim($course[$i]->alias);
                }
                $courseLink = JRoute::_('index.php?option=com_guru&view=guruPrograms&layout=view&cid=' . $course[$i]->id . "-" . $alias . "&Itemid=" . $itemid1);
            } else {
                $courseLink = JRoute::_('index.php?option=com_guru&view=guruPrograms&layout=view&cid=' . $course[$i]->id . "&Itemid=" . $itemid1);
            }
            ?>
                                                <a href='<?php 
            echo $courseLink;
            ?>
'>
                                                    <?php 
            echo $course[$i]->name;
            ?>
                                                </a>
                                            </td>
                                            <td class="g_cell_2"><img src='<?php 
            echo JURI::root() . "components/com_guru/images/" . $course[$i]->level . ".png";
            ?>
'/></td>
                                            <?php 
            $int_date = strtotime($course[$i]->startpublish);
            $date = date($config->datetype, $int_date);
            ?>
                                            <td class="g_cell_3"><?php 
            echo $date;
            ?>
</td>
                                        </tr>
                                    <?php 
            $k++;
        }
    }
    ?>
                            </table>
                            </div>
                        </div>
                      </div>  
                </div>
               </div>
             </div>   
</div>
</div>
</div>
</div>
<?php 
}
Example #7
0
    function generateCategsCellsB($config_categs, $style_categs, $course, $config)
    {
        $item_id = JRequest::getVar("Itemid", "0");
        $type = $config_categs->ctgs_image_size_type == "0" ? "w" : "h";
        $return = "";
        $layout = $config_categs->ctgslayout;
        $wrap = $config_categs->ctgs_wrap_image;
        //0-yes, 1-no
        $img_align = $config_categs->ctgs_image_alignment;
        //0-left, 1-right
        $read_more = $config_categs->ctgs_read_more;
        //0-yes 1-no
        $read_align = $config_categs->ctgs_read_more_align == "0" ? "left" : "right";
        $description_align = $config_categs->ctgs_description_alignment == "0" ? "left" : "right";
        $edit_read_more = $config_categs->ctgs_read_more;
        $courses_number = $this->countCoursesNumber($course->id);
        $sub_categs_number = $this->countSubcategsNumber($course->id);
        $show_empty_categs = $config_categs->ctgs_show_empty_catgs;
        $show = true;
        $rt = "";
        $detect = new Mobile_Detect();
        $deviceType = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer';
        if (isset($course->alias) && $course->alias == "") {
            $alias = trim($course->alias);
        } else {
            $alias = JFilterOutput::stringURLSafe($course->name);
        }
        //$alias = isset($course->alias) == "" ? trim($course->alias) : JFilterOutput::stringURLSafe($course->name);
        if ($show_empty_categs == "0") {
            $show = true;
        } elseif ($show_empty_categs == "1") {
            if (intval($sub_categs_number) > 0 || intval($courses_number) > 0) {
                $show = true;
            } else {
                $show = false;
            }
        }
        $edit_sum = "";
        $edit_sum_array = array();
        if ($sub_categs_number > 0) {
            if ($sub_categs_number == 1) {
                $edit_sum_array[] = $sub_categs_number . " " . JText::_("GURU_NUMBER_CATEGORY");
            } else {
                $edit_sum_array[] = $sub_categs_number . " " . JText::_("GURU_NUMBER_CATEGORIES");
            }
        }
        if ($courses_number > 0) {
            if ($courses_number == 1) {
                $edit_sum_array[] = $courses_number . " " . JText::_("GURU_NUMBER_COURSE");
            } else {
                $edit_sum_array[] = $courses_number . " " . JText::_("GURU_NUMBER_COURSES");
            }
        }
        $edit_sum = "";
        if (count($edit_sum_array) > 0) {
            $edit_sum = " (" . implode(" / ", $edit_sum_array) . ") ";
        }
        if ($deviceType == "phone") {
            $nameandnumb = $course->name . "<br/>" . $edit_sum;
            $style_m = "padding-left:20px;";
        } else {
            $nameandnumb = $course->name . $edit_sum;
            $style_d = "";
        }
        if ($show === true) {
            if ($layout == "1") {
                //mini profile
                if (trim($course->image) == "") {
                    $course->image = "components/com_guru/images/thumbs/no_image.gif";
                    $course->imageName = "no_image.gif";
                    $guru_helper = new guruHelper();
                    $guru_helper->createThumb($course->imageName, "components" . DS . "com_guru" . DS . "images", $config_categs->ctgs_image_size, $type);
                } else {
                    $helper = new guruHelper();
                    $helper->createThumb($course->imageName, $config->imagesin . "/categories", $config_categs->ctgs_image_size, $type);
                }
                $image = "";
                if (trim($course->image) != "") {
                    $image = '<img alt="Category Image" src="' . JURI::root() . $course->image . '" />';
                    $image = '<a class="thumbnail" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $image . '</a>';
                }
                $description = $this->cutBio($course->description, $config_categs->ctgs_description_length, $config_categs->ctgs_description_type);
                if ($wrap == "1") {
                    //no wrap
                    $class_display = "display:table-cell;";
                    if ($img_align == "0") {
                        // left
                        $return .= "<div>";
                        if (trim($image) != "") {
                            $return .= '<div class="' . $style_categs->ctgs_image . '">' . $image . '</div>';
                        }
                        $return .= '<div class="' . $style_categs->ctgs_categ_name . '">

														<a style="' . $style_d . '" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . '-' . $alias . '&Itemid=' . $item_id) . '">' . $nameandnumb . '</a>

													</div>';
                        if ($read_more == "0" && $edit_read_more == "0") {
                            $rt = '<a class="btn readmore" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                        } elseif ($read_more == "1" && $edit_read_more == "0") {
                            $rt = '<a class="btn readmore" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                        }
                        $return .= '<div class="' . $style_categs->ctgs_description . ' ' . $class_display . '" style="text-align:' . $description_align . '; ' . $style_d . '">' . $description . $rt . '</div>';
                        $return .= "</div>";
                    } elseif ($img_align == "1") {
                        // right
                        $return .= "<div class='media-body'>";
                        if (trim($image) != "") {
                            $return .= '<div class="pull-right"><ul class="thumbnails"><li >' . $image . '</li></ul></div>';
                        }
                        $return .= '<div class=" media-heading ' . $style_categs->ctgs_categ_name . '">

														<a style="' . $style_m . '" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . '-' . $alias . '&Itemid=' . $item_id) . '">' . $nameandnumb . '</a>

													</div>';
                        if ($read_more == "0" && $edit_read_more == "0") {
                            $rt = '<a class="btn readmore" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                        } elseif ($read_more == "1" && $edit_read_more == "0") {
                            $rt = '<a class="btn readmore" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                        }
                        $return .= '<div class="media ' . $style_categs->ctgs_description . ' ' . $class_display . '" style="text-align:' . $description_align . '; ' . $style_m . '">' . $description . $rt . '</div>';
                        $return .= "</div>";
                    }
                } elseif ($wrap == "0") {
                    //wrap
                    if ($img_align == "0") {
                        // left
                        $return .= "<div>";
                        $return .= '<div>';
                        $return .= '<div class="' . $style_categs->ctgs_categ_name . '">
												<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . $course->name . $edit_sum . '</a>
											</div>';
                        if (trim($image) != "") {
                            $return .= '<div class="' . $style_categs->ctgs_image . '">' . $image . '</div>';
                        }
                        $return .= '<div class="' . $style_categs->ctgs_description . '" style="text-align:' . $description_align . ';">' . $description . '</div>';
                        if ($read_more == "0" && $edit_read_more == "0") {
                            $return .= '<div class="' . $style_categs->ctgs_st_read_more . '" style="text-align:' . $read_align . '">' . '<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a></div>';
                        } elseif ($read_more == "1" && $edit_read_more == "0") {
                            $return .= '<div class="' . $style_categs->ctgs_st_read_more . '" style="text-align:' . $read_align . '">' . '<a href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a></div>';
                        }
                        $return .= "</div>";
                        $return .= "</div>";
                    } elseif ($img_align == "1") {
                        // right
                        $return .= "<div class='media-body'>";
                        if (trim($image) != "") {
                            $return .= '<div class="pull-right"><ul class="thumbnails"><li >' . $image . '</li></ul></div>';
                        }
                        $return .= '<div class=" media-heading ' . $style_categs->ctgs_categ_name . '">

														<a style="' . $style_m . '" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . '-' . $alias . '&Itemid=' . $item_id) . '">' . $nameandnumb . '</a>

													</div>';
                        if ($read_more == "0" && $edit_read_more == "0") {
                            $rt = '<a class="btn readmore" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                        } elseif ($read_more == "1" && $edit_read_more == "0") {
                            $rt = '<a class="btn readmore" href="' . JRoute::_('index.php?option=com_guru&view=guruPcategs&task=view&cid=' . $course->id . "-" . $alias . "&Itemid=" . $item_id) . '">' . JText::_("GURU_READ_MORE") . '</a>';
                        }
                        $return .= '<div class="media ' . $style_categs->ctgs_description . '" style="text-align:' . $description_align . '; ' . $style_m . '">' . $description . $rt . '</div>';
                        $return .= "</div>";
                    }
                }
                $return .= '</div>';
            }
            //if mini profile
        }
        //if show
        return $return;
    }
Example #8
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 #9
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);
    }