示例#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;
    }
            echo "</td></tr>";
        }
        echo "</table>";
        break;
        // case alltournaments
    // case alltournaments
    case 'ranking':
        $players = get_ranking();
        draw_ranking($players, true);
        break;
        // case ranking
    // case ranking
    case 'groupranking':
        include "groups_functions.php";
        $_GET['groups'] = true;
        $players = get_ranking();
        ?>

<table border="0" style="width: 100%">
<tr>
<td><b>Points</b></td>
<td><b>Group</b></td>
<td><b>Chess-AG</b></td>
</tr>

<?php 
        $list = array();
        $teams = array();
        while (list($key, $value) = each($players)) {
            $val = $players[$key];
            if ($val['wins'] == "") {
示例#3
0
          <td><?php 
    echo get_ranking($tech_strength);
    ?>
</td>
        </tr>
        <tr> 
          <td>Presentation:</td>
          <td><?php 
    echo get_ranking($presentation);
    ?>
</td>
        </tr>
        <tr> 
          <td>Overall Evaluation:</td>
          <td><?php 
    echo get_ranking($overall);
    ?>
</td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td><p><strong>Comments:<br>
        </strong><?php 
    echo nl2br(ereg_replace("  ", "&nbsp;&nbsp;", stripslashes(get_comment($paperInfo->PaperID, $reviewInfo->MemberName, &$err_message))));
    ?>
</p></td>
  </tr>
function calculate_winner($id)
{

$players = get_ranking($id);

$list = array();

while(list($key, $value) = each($players))
{

$val = $players[$key];

if ($val['wins'] == "") $val['wins'] = 0;
if ($val['draws'] == "") $val['draws'] = 0;
if ($val['losses'] == "") $val['losses'] = 0;

// Calculate Points: Wins = 2 Points, Draws = 1 Point, Losses = 0 Points

$points = 0;

$points = $points + ($val['wins'] * 2) + $val['draws'];

$list[$key] = $points;

} // while

arsort($list);

list($key,$val) = each($list);

return $key;

}
示例#5
0
 */
/*
 * 方法get
 * 参数:
 * count 返回排名数据, -1 表示获取所有数据, 默认为前10
 */
// 参数检查
if (!isset($_GET["count"])) {
    $error_string = "top_ranking_photos: parameter count needed";
    echo json_encode(array("ERROR" => $error_string));
    error_log($error_string);
    return;
}
require_once "../database/db_creator.php";
// 调用函数
get_ranking($_GET["count"]);
function get_ranking($count)
{
    global $db;
    if ($count == 0) {
        echo json_encode(array("ERROR" => "count can't be zero"));
        return;
    } elseif ($count > 0) {
        $stmt = $db->prepare("SELECT * FROM Photos ORDER  BY favour_count DESC LIMIT :count");
        $stmt->bindParam(":count", $count, PDO::PARAM_INT);
    } else {
        // 获取全部照片,按照[赞]的数量
        $stmt = $db->prepare("SELECT * FROM Photos ORDER  BY favour_count DESC");
    }
    try {
        $stmt->execute();
示例#6
0
$PAGE->set_pagelayout('standard');
$renderer = $PAGE->get_renderer('local_toolbox');
echo $OUTPUT->header();
echo $renderer->start_layout();
echo $renderer->show_descripcion($desc);
$pageCount = 10;
//Cantidad de Entradas a mostrar en el Ranking
switch ($view) {
    case 'miscursos':
        $cursos = get_cursos();
        echo $renderer->show_cursos_grid($cursos);
        break;
    case 'ranking':
        $rol = get_rol();
        if ($rol == 'Decano' || $rol == 'Rector') {
            $ranking = get_ranking($idFacultad);
            $facultades = get_facultades();
            $totalCount = count($ranking);
            echo $renderer->show_barrauai_toolbox($facultades, $view, get_string('facultad', 'local_toolbox'), $idFacultad, '', 'Universidad');
            echo $renderer->show_ranking($ranking, $view, 'Profesor', $page, $rank, $idFacultad, $pageCount);
            if ($rank != 0) {
                $page = floor($rank / $pageCount);
                $page = $page <= 0 ? 0 : $page;
            }
            echo $OUTPUT->paging_bar($totalCount, $page, $pageCount, $CFG->wwwroot . '/s/toolbox/view.php?view=ranking&idFacultad=' . $idFacultad, 'page');
        } else {
            $cursos = get_cursos();
            echo $renderer->show_cursos_grid($cursos);
        }
        break;
    case 'acerca':