Example #1
0
    /**
     * Muestra Toolbox: Ranking actual de los cursos del usuario y link
     * a las páginas de detalles.
     *
     * @return string HTML a mostrar
     */
    function toolbox()
    {
        //REVISAR obtenemos la funcion de contenido de toolbox
        global $USER, $CFG, $DB, $PAGE, $COURSE;
        if ($CFG->block_uai_local_modules && !in_array('toolbox', explode(',', $CFG->block_uai_local_modules))) {
            return false;
        }
        $categoryid = 0;
        if ($COURSE && $COURSE->id > 1) {
            $categoryid = $COURSE->category;
        } elseif ($PAGE->context instanceof context_coursecat) {
            $categoryid = intval($PAGE->context->__get('instanceid'));
        }
        if (!$categoryid) {
            return false;
        }
        $modulestatsnode = navigation_node::create(get_string('modulestats', 'local_uai'), new moodle_url("/local/uai/modulestats.php", array('id' => $categoryid)), navigation_node::TYPE_CUSTOM, null, null, new pix_icon('i/report', get_string('modulestats', 'local_uai')));
        //url para ver sedes
        $rootnode = navigation_node::create(get_string('pluginname', 'local_uai'));
        $rootnode->add_node($modulestatsnode);
        return $rootnode;
        require_once $CFG->dirroot . '/local/toolbox/lib.php';
        require_once $CFG->dirroot . '/course/lib.php';
        require_once $CFG->dirroot . '/lib/accesslib.php';
        require_once $CFG->dirroot . '/lib/moodlelib.php';
        require_once $CFG->dirroot . '/lib/weblib.php';
        $html = '';
        //Link to the page of ToolBox (view.php)
        $toolbox = $CFG->wwwroot . '/local/toolbox/view.php';
        $summary = get_summary();
        $valor = $summary['nivel'];
        $textscore = get_score_text($valor);
        $imagescore = get_img_source($valor);
        $context = context_course::instance($COURSE->id);
        //obtenemos el contexto del curso
        //revisamos la capacidad que tiene el usuario
        if (has_capability('local/toolbox:viewtoolboxstudent', $context)) {
            //alumno
            $html .= '<div><b><a href="' . $toolbox . '?view=miscursos">' . get_string('minivel', 'local_toolbox') . $textscore . ' (' . $summary["nivel"] . ')</a></b></div>
					<div><img src="' . $imagescore . '"></div>
							<hr>
							<div><a href="' . $toolbox . '?view=acerca">' . get_string('acerca', 'local_toolbox') . '</a></div>';
        } elseif (has_capability('local/toolbox:viewtoolboxteacher', $context)) {
            //profesor
            $ranking = get_ranking();
            $userid = $USER->id;
            $rank = null;
            if (isset($ranking[$userid])) {
                $rank = $ranking[$userid]->rank;
            }
            if ($rank) {
                // si tiene ranking, desplegamos su posicion en el ranking
                $totalProfesores = count($ranking);
                $html .= '<div><b>' . get_string('minivel', 'local_toolbox') . $textscore . ' (' . $summary["nivel"] . ')</b></div>
						<div><img src="' . $imagescore . '"></div>
								<div><b>' . get_string('miranking', 'local_toolbox') . $rank . get_string('mirankingde', 'local_toolbox') . $totalProfesores . '</b></div>
										<hr>
										<div><a href="' . $toolbox . '?view=miscursos">' . get_string('miscursos', 'local_toolbox') . '</a></div>
												<div><a href="' . $toolbox . '?view=acerca">' . get_string('acerca', 'local_toolbox') . '</a></div>';
            } else {
                //si no tiene ranking, se le muestra "Sin ranking"
                $totalProfesores = count($ranking);
                $html .= '<div><b>' . get_string('minivel', 'local_toolbox') . $textscore . ' (' . $summary["nivel"] . ')</b></div>
						<div><img src="' . $imagescore . '"></div>
								<div><b>' . get_string('miranking', 'local_toolbox') . get_string('sinranking', 'local_toolbox') . '</b></div>
										<hr>
										<div><a href="' . $toolbox . '?view=miscursos">' . get_string('miscursos', 'local_toolbox') . '</a></div>
												<div><a href="' . $toolbox . '?view=acerca">' . get_string('acerca', 'local_toolbox') . '</a></div>';
            }
        } elseif (has_capability('local/toolbox:viewtoolboxmanager', $context)) {
            //decano y rector y manager
            $ranking = get_ranking();
            $userid = $USER->id;
            $rank = $ranking[$userid]->rank;
            $totalProfesores = count($ranking);
            $html .= '<div><b>' . get_string('minivel', 'local_toolbox') . $textscore . ' (' . $summary["nivel"] . ')</b></div>
					<div><img src="' . $imagescore . '"></div>
							<div><b>' . get_string('miranking', 'local_toolbox') . $rank . get_string('mirankingde', 'local_toolbox') . $totalProfesores . '</b></div>
									<hr>
									<div><a href="' . $toolbox . '?view=miscursos">' . get_string('miscursos', 'local_toolbox') . '</a></div>
											<div><a href="' . $toolbox . '?view=ranking&rank=' . $summary["uai"] . '">' . get_string('ranking', 'local_toolbox') . '</a></div>
													<div><a href="' . $toolbox . '?view=acerca">' . get_string('acerca', 'local_toolbox') . '</a></div>';
        } elseif (has_capability('local/toolbox:viewtoolboxuser', $context)) {
            /////otro usuario
            $html = "";
        } else {
            $html = "";
        }
        $html = '

				<li class="type_course depth_2 collapsed contains_branch">
				<p class="tree_item branch">
				<span tabindex="0">' . get_string('toolbox', 'block_uai') . '</span>
						</p>
						<ul>
						<li class="type_custom depth_3 item_with_icon">
						' . $html . '
								</li>
								</ul>
								</li>
								';
        return $html;
    }
Example #2
0
 /**
  * Get post thumbnail src, if the post have not thumbnail, then get the first image from post content.
  *
  * @version 1.1.0
  * @param int $post_id The post ID, default is global $post->ID
  * @param string $size Thumbnail size
  * @return string Placeholder img url
  */
 public static function get_thumbnail_src($post_id = null, $size = 'thumbnail', $replace_img = null)
 {
     static $caches = [];
     if (!$post_id) {
         global $post;
         $post_id = $post->ID;
     }
     $cache_id = $post_id . $size . $replace_img;
     if (isset($caches[$cache_id])) {
         return $caches[$cache_id];
     }
     $src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size);
     if (!empty($src)) {
         $caches[$cache_id] = $src[0];
         return $caches[$cache_id];
     }
     /**
      * have not thumbnail, get first img from post content
      */
     $post = theme_cache::get_post($post_id);
     $caches[$cache_id] = get_img_source($post->post_content);
     if ($caches[$cache_id]) {
         return $caches[$cache_id];
     }
     if ($replace_img) {
         return $replace_img;
     }
     return null;
 }
Example #3
0
 /**
  * get_thumbnail_src
  *
  * @return 
  * @version 1.1.0
  */
 public static function get_thumbnail_src($post_id, $size = 'thumbnail', $placeholder = null)
 {
     if (!$placeholder) {
         $placeholder = self::$thumbnail_placeholder;
     }
     if (!$size) {
         $size = self::$thumbnail_size[0];
     }
     $src = null;
     if (has_post_thumbnail($post_id)) {
         $src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size)[0];
     }
     /** get img src from post content */
     if (!$src) {
         $post = theme_cache::get_post($post_id);
         $src = $post ? get_img_source($post->post_content) : false;
         unset($post);
     }
     if (!$src) {
         $src = $placeholder;
     }
     return esc_url($src);
 }
Example #4
0
 /**
  * Obtiene una tabla donde se muestra los cursos inscritus y su rol, adem�s
  * de el nivel alcanzado en las herramientas: Foro con Nota, Cuestionarios, Calificaciones.
  * @param array $datos Matr�z con el nombre del curso y el score de cada herramienta 
  * e.g. array('idCurso' => array('nombre' => 'nombre1(rol1)', 'Foro' => 'X.XX', 'Cuestionario' => 'nombre1(X.XX)', 'Calificacion' => 'nombre1(X.XX)')etc.) 
  * @return string Fragmento HTML
  */
 public function show_cursos_grid(array $datos)
 {
     global $CFG;
     $grid = new html_table();
     $grid->attributes = array('class' => 'gridCursos');
     $grid->data = array();
     $grid->data[0] = new html_table_row();
     $grid->data[0]->attributes['class'] .= 'gridCursosHeader';
     $grid->data[0]->cells[0] = new html_table_cell(get_string('c/h', 'local_toolbox'));
     $grid->data[0]->cells[1] = new html_table_cell(html_writer::tag('a', get_string('foros', 'local_toolbox'), array('href' => 'http://webcursos.cloudlab.cl/mod/page/view.php?id=334191', 'style' => 'color:#fff;')));
     $grid->data[0]->cells[2] = new html_table_cell(html_writer::tag('a', get_string('cuestionarios', 'local_toolbox'), array('href' => 'http://webcursos.cloudlab.cl/mod/page/view.php?id=334156', 'style' => 'color:#fff;')));
     $grid->data[0]->cells[3] = new html_table_cell(html_writer::tag('a', get_string('calificaciones', 'local_toolbox'), array('href' => 'http://webcursos.cloudlab.cl/mod/page/view.php?id=355417', 'style' => 'color:#fff;')));
     $row = 1;
     foreach ($datos as $idCurso => $dato) {
         $cell = 0;
         $anchor_name = html_writer::tag('a', $dato['nombre'], array('href' => $CFG->wwwroot . '/course/view.php?id=' . $idCurso, 'style' => 'color:#000'));
         $img_foro = html_writer::empty_tag('img', array('src' => get_img_source($dato['Foro']), 'alt' => get_score_text($dato['Foro']), 'title' => get_score_text($dato['Foro']) . ' : ' . $dato['Foro']));
         $img_quiz = html_writer::empty_tag('img', array('src' => get_img_source($dato['Cuestionario']), 'alt' => get_score_text($dato['Cuestionario']), 'title' => get_score_text($dato['Cuestionario']) . ' : ' . $dato['Cuestionario']));
         $img_gradebook = html_writer::empty_tag('img', array('src' => get_img_source($dato['Calificacion']), 'alt' => get_score_text($dato['Calificacion']), 'title' => get_score_text($dato['Calificacion']) . ' : ' . $dato['Calificacion']));
         $grid->data[$row] = new html_table_row();
         $grid->data[$row]->cells[$cell] = new html_table_cell($anchor_name);
         $cell++;
         $grid->data[$row]->cells[$cell] = new html_table_cell($img_foro);
         $cell++;
         $grid->data[$row]->cells[$cell] = new html_table_cell($img_quiz);
         $cell++;
         $grid->data[$row]->cells[$cell] = new html_table_cell($img_gradebook);
         $cell++;
         $row++;
     }
     $output = html_writer::table($grid);
     //Reemplazado por lo que aparece más abajo, dado que así se mantiene el orden.
     $output .= html_writer::start_tag('div');
     $tutorial = array();
     $tutorial[0][0] = html_writer::empty_tag('img', array('src' => get_img_source('0'), 'alt' => 'Básico', 'title' => 'Básico'));
     $tutorial[0][1] = html_writer::empty_tag('img', array('src' => get_img_source('1'), 'alt' => 'Intermedio', 'title' => 'Intermedio'));
     $tutorial[0][2] = html_writer::empty_tag('img', array('src' => get_img_source('2'), 'alt' => 'Avanzado', 'title' => 'Avanzado'));
     $tutorial[0][3] = html_writer::empty_tag('img', array('src' => get_img_source('3'), 'alt' => 'Experto', 'title' => 'Experto'));
     $tutorial[1][0] = html_writer::start_tag('center') . html_writer::start_tag('b') . get_string('basico', 'local_toolbox') . html_writer::end_tag('b') . html_writer::end_tag('center');
     $tutorial[1][1] = html_writer::start_tag('center') . html_writer::start_tag('b') . get_string('intermedio', 'local_toolbox') . html_writer::end_tag('b') . html_writer::end_tag('center');
     $tutorial[1][2] = html_writer::start_tag('center') . html_writer::start_tag('b') . get_string('avanzado', 'local_toolbox') . html_writer::end_tag('b') . html_writer::end_tag('center');
     $tutorial[1][3] = html_writer::start_tag('center') . html_writer::start_tag('b') . get_string('experto', 'local_toolbox') . html_writer::end_tag('b') . html_writer::end_tag('center');
     $logos = new html_table();
     $logos->attributes = array('class' => 'logos');
     $logos->data = $tutorial;
     $output .= html_writer::table($logos);
     $output .= html_writer::end_tag('div');
     /*
         	$output .= html_writer::start_tag('div', array('class' => 'tutoriales'));
         	$output .=html_writer::start_tag('table');
         	$output .= html_writer::start_tag('tr');
         	$output .= html_writer::empty_tag('td');
            	$output .= html_writer::empty_tag('img', array('src' => get_img_source('0'), 'alt' => 'Básico', 'title' => 'Básico'));
         	$output .= html_writer::empty_tag('td');
            	$output .= html_writer::empty_tag('img', array('src' => get_img_source('1'), 'alt' => 'Intermedio', 'title' => 'Intermedio'));    	
         	$output .= html_writer::empty_tag('td');
            	$output .= html_writer::empty_tag('img', array('src' => get_img_source('2'), 'alt' => 'Avanzado', 'title' => 'Avanzado'));
         	$output .= html_writer::empty_tag('td');
            	$output .= html_writer::empty_tag('img', array('src' => get_img_source('3'), 'alt' => 'Experto', 'title' => 'Experto'));    	
         	$output .= html_writer::empty_tag('td');
         //	$output .= html_writer::empty_tag('img', array('src' => get_img_source('4'), 'alt' => 'Error', 'title' => 'Error'));
         	$output .= html_writer::end_tag('tr');
         	$output .= html_writer::end_tag('table');
            	$output .= html_writer::end_tag('div');
         	$output .= html_writer::start_tag('div', array('class' => 'tutoriales'));
             $output .= html_writer::start_tag('b');
             $output .=html_writer::start_tag('table');
         	$output .= html_writer::start_tag('tr');
         	$output .= html_writer::empty_tag('td');
             $output .= html_writer::tag('a', ''.get_string('basico','local_toolbox'), array('style'=>'color:#000;'));
             $output .= html_writer::empty_tag('td');
             $output .= html_writer::tag('a', ''.get_string('intermedio','local_toolbox'), array('style'=>'color:#000;'));
             $output .= html_writer::empty_tag('td');
             $output .= html_writer::tag('a', ''.get_string('avanzado','local_toolbox'), array('style'=>'color:#000;'));
             $output .= html_writer::empty_tag('td');
             $output .= html_writer::tag('a',''.get_string('experto','local_toolbox'), array('style'=>'color:#000;'));
             $output .= html_writer::empty_tag('td');
             $output .= html_writer::end_tag('tr');
         	$output .= html_writer::end_tag('table');
             $output .= html_writer::end_tag('b');
         	$output .= html_writer::end_tag('div');
     */
     return $output;
 }