Example #1
0
    $datapost = clean_param_array($_POST, PARAM_ALPHANUM);
    $dataget = clean_param_array($_GET, PARAM_ALPHANUM);
} elseif (function_exists('clean_param')) {
    $datapost = clean_param($_POST, PARAM_ALPHANUM);
    $dataget = clean_param($_GET, PARAM_ALPHANUM);
} else {
    $datapost = $_POST;
    $dataget = $_GET;
}
if (isset($datapost['stu']) && isset($datapost['cma']) && isset($dataget['id']) && isset($dataget['eva'])) {
    require_once 'lib.php';
    $courseid = $dataget['id'];
    $assessorid = $dataget['eva'];
    $page = $datapost['page'];
    $context = context_course::instance($courseid);
    $report_evalcomix = new grade_report_evalcomix($courseid, null, $context, $page);
    $userid = $datapost['stu'];
    $cmid = $datapost['cma'];
    $report_evalcomix->process_data($datapost);
    //Obtains course�s users
    $users = $report_evalcomix->load_users();
    $coursegroups = $report_evalcomix->load_groups();
    $coursegroupings = $report_evalcomix->load_groupings();
    $finalgrades = evalcomix_grades::get_grades($courseid);
    //$finalgrades = $report_evalcomix->get_grades();
    //echo $report_evalcomix->create_grade_table();
    $showdetails = true;
    $configured = $report_evalcomix->configured_activity($cmid);
    //Only show the user�s grade or all grades if the USER is a teacher or admin
    //if ((has_capability('block/evalcomix:edit',$context, $USER->id) || $userid == $USER->id) && isset($finalgrades[$cmid][$userid])){
    if ((has_capability('moodle/grade:viewhidden', $context, $USER->id) || $userid == $USER->id) && isset($finalgrades[$cmid][$userid])) {
Example #2
0
//Se comprueba que el curso no está recién restaurado, en tal caso actualiza los instrumentos/
//////////////////////////////////////////////////////////////////////////////////////////////
$environment = evalcomix::fetch(array('courseid' => $courseid));
//Si hay instrumentos duplicados (con timemodified a -1)
if (isset($environment->id) && ($webtools = evalcomix_tool::fetch_all(array('evxid' => $environment->id, 'timemodified' => '-1')))) {
    //$webtools = webservice_evalcomix_client::get_ws_list_tool($courseid, MOODLE_NAME);
    $tools = array();
    if (!empty($webtools) && $environment) {
        update_tool_list($environment->id, $webtools);
    }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// Obtención de los objetos necesarios /////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
//Initialise the evalcomix report object that produces the table
$report_evalcomix = new grade_report_evalcomix($courseid, null, $context, $page, $sortitemid);
if (!empty($data)) {
    $report_evalcomix->process_data($data);
}
// Array
// Almacenará los estudiantes que se mostrarán en la tabla de calificaciones
// Los estudiantes que almacenará variará en función de los privilegios del usuario y de la configuración
// de la actividad (grupos, agrupamientos, modalidades de evaluación)
$users = array();
// Array
// Almacenará las actividades que se mostrará en la tabla de calificacions.
// Las instancias que almacenará dependerá de la configuración de la actividad (agrupamientos)
$activities = array();
// Array de dos dimensiones [usuario][actividad];
// Contendrá código HTML que se mostrará en las celdas de la tabla de calificaciones.
// Su contenido dependerá de los privilegios del usuario.
Example #3
0
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 * @author     Daniel Cabeza Sánchez <*****@*****.**>, Juan Antonio Caballero Hernández <*****@*****.**>
 */
require_once '../../../config.php';
require_once $CFG->dirroot . '/blocks/evalcomix/assessment/lib.php';
include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_allowedusers.php';
$search = required_param('search', PARAM_RAW);
$courseid = required_param('id', PARAM_INT);
// course id
$id = required_param('a', PARAM_INT);
$type = optional_param('t', 0, PARAM_INT);
$assessorid = optional_param('as', 0, PARAM_INT);
require_login($courseid);
if ($id) {
    $cm = get_coursemodule_from_id('', $id, 0, false, MUST_EXIST);
    if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
        print_error('nocourseid');
    }
}
$context = context_course::instance($courseid);
$report_evalcomix = new grade_report_evalcomix($courseid, null, $context);
$users = $report_evalcomix->load_users(false);
$allowedusershash = array();
$output = '<select id="assessorid" name="assessorid" style="width:20em" size="20" onclick="document.getElementById(\'submit\').disabled = false;doWork(\'targetstudents\', \'targetstudents.php\', \'u=\'+this.value+\'&id=' . $courseid . '&a=' . $cm->id . '\');">';
if ($type == 'potential' && $assessorid > 0) {
    $allowedusershash[$assessorid] = true;
    if ($allowedusers = evalcomix_allowedusers::fetch_all(array('cmid' => $id, 'assessorid' => $assessorid))) {
        foreach ($allowedusers as $alloweduser) {
            $userid = $alloweduser->studentid;
            $allowedusershash[$userid] = true;
        }
 $cmid = required_param('a', PARAM_INT);
 $studentid = required_param('s', PARAM_INT);
 require_capability('block/evalcomix:assessed', $context, $studentid);
 $lms = MOODLE_NAME;
 $module = evalcomix_tasks::get_type_task($cmid);
 //echo "$courseid - $module - $cmid - $studentid, - $assessor - $mode - $lms ";
 $user = $DB->get_record('user', array('id' => $studentid));
 if ($user) {
     $modinfo = get_fast_modinfo($courseid);
     $mods = $modinfo->get_cms();
     $mod = $mods[$cmid];
     $title = fullname($user) . get_string('studentwork2', 'block_evalcomix') . $mod->name;
 }
 $url_instrument = '';
 if ($perspective == 'assess') {
     $mode = grade_report_evalcomix::get_type_evaluation($studentid, $courseid);
     if ($task = evalcomix_tasks::fetch(array('instanceid' => $cmid))) {
         if (!($modefetch = evalcomix_modes::fetch(array('taskid' => $task->id, 'modality' => $mode)))) {
             print_error('EvalCOMIX: No permissions');
         }
     } else {
         print_error('EvalCOMIX: The activity is not configured with EvalCOMIX');
     }
     $assessor = $USER->id;
     $url_instrument = webservice_evalcomix_client::get_ws_assessment_form($toolid, $lang . '_utf8', $courseid, $module, $cmid, $studentid, $assessor, $mode, $lms, 'assess', $title);
 } elseif ($perspective == 'view') {
     $assessorid = required_param('as', PARAM_INT);
     if ($assessorid == $studentid) {
         $mode = 'self';
     } else {
         //if (has_capability('block/evalcomix:edit',$context, $assessorid)){
Example #5
0
    /**
     * Builds the grade table and returns it in HTML
     * @return string HTML
     */
    public function create_grade_table()
    {
        global $CFG, $OUTPUT, $USER;
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_assessments.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes_time.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes_extra.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/webservice_evalcomix_client.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_grades.php';
        include_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_allowedusers.php';
        $context = context_course::instance($this->courseid);
        $table = '
			<style type="text/css">
					.wrapper1, .wrapper2{width: 100%; border: none 0px RED;
					overflow-x: scroll; overflow-y:hidden;}
					.wrapper1{height: 20px; }
					.wrapper2{}
					#div1 {width:500px; height: 10px; }
					#div2 {width:500px;
					overflow: auto;}
					#div {width:100%}

				</style>
			<div id="div"></div>
			<div class="wrapper1">
				<div class="div1" id="div1" style="width:100%">
				</div>
			</div>
			<div class="wrapper2">
				<div class="div2" id="div2" style="width:100%;">
				
			<!-- <div id="wrapper2" style="overflow:auto;overflow-y:hidden;"> -->
			<table border=1 style="font-size:0.8em;text-align:right;" id="user-grades" class="gradestable flexible boxaligncenter generaltable">';
        //Obtains course´s users
        $users = $this->load_users();
        //if(!has_capability('block/evalcomix:edit',$context, $USER->id)){
        if (!has_capability('moodle/grade:viewhidden', $context, $USER->id)) {
            $coursegroups = $this->load_groups();
            $coursegroupings = $this->load_groupings();
        }
        $table .= $this->get_headers();
        $table .= "\n\t\t\t\t<script type=\"text/javascript\" src=\"../ajax.js\"></script>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\tvar recarga = 0;\n\t\t\t\t\n\t\t\t\t\t function relocate(page,params)\n\t\t\t\t\t {\n\t\t\t\t\t\t  var body = document.body;\n\t\t\t\t\t\t  form=document.createElement('form'); \n\t\t\t\t\t\t  form.method = 'POST'; \n\t\t\t\t\t\t  form.action = page;\n\t\t\t\t\t\t  form.name = 'jsform';\n\t\t\t\t\t\t  for (index in params)\n\t\t\t\t\t\t  {\n\t\t\t\t\t\t\t\tvar input = document.createElement('input');\n\t\t\t\t\t\t\t\tinput.type='hidden';\n\t\t\t\t\t\t\t\tinput.name=index;\n\t\t\t\t\t\t\t\tinput.id=index;\n\t\t\t\t\t\t\t\tinput.value=params[index];\n\t\t\t\t\t\t\t\tform.appendChild(input);\n\t\t\t\t\t\t  }\t  \t\t  \t\t\t  \n\t\t\t\t\t\t  body.appendChild(form);\n\t\t\t\t\t\t  form.submit();\n\t\t\t\t\t }\n\t\t\t\t\t \n\t\t\t\t\tfunction change_recarga(){\n\t\t\t\t\t\trecarga = 1;\n\t\t\t\t\t}\n\t\t\t\t\n\t\t\t\t\tfunction urlDetalles(u){\n\t\t\t\t\t\twin2 = window.open(u, 0, \"menubar=0,location=1,scrollbars,resizable,width=780,height=500\");\n\t\t\t\t\t\tcheckChildDetalles();\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfunction url(u, alu, cmidassign, page, courseid, nombre){\n\t\t\t\t\t\twin2 = window.open(u, nombre, \"menubar=0,location=0,scrollbars,resizable,width=780,height=500\");\n\t\t\t\t\t\tcheckChild(alu, cmidassign, page, courseid);\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tfunction checkChild(alu, cmidassign, page, course) {\n\t\t\t\t\t\tif (win2.closed) {\n\t\t\t\t\t\t\t/*relocate(window.location, {'stu':alu, 'cma':cmidassign});\t*/\t\n\t\t\t\t\t\t\tdoWork('evalcomixtablegrade_'+alu+'_'+cmidassign, 'servidor.php?id=" . $this->courseid . "&eva=" . $USER->id . "', 'courseid='+course+'&page='+page+'&stu='+alu+'&cma='+cmidassign);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse setTimeout(\"checkChild(\"+alu+\",\"+cmidassign+\")\",1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\tfunction checkChildDetalles() {\n\t\t\t\t\t\tif (win2.closed) {\n\t\t\t\t\t\t\tif (recarga == 1) {\n\t\t\t\t\t\t\t\twindow.location.reload(true);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\trecarga = 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tsetTimeout(\"checkChildDetalles()\",1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tfunction checkChild_old(alu) {\t\t\t\t\t\t\n\t\t\t\t\t\tif (win2.closed) {\n\t\t\t\t\t\t\tvar url = String(window.location);\n\t\t\t\t\t\t\tvar long = url.length;\n\t\t\t\t\t\t\tif (url.substring(long-6, long-1) != \"&stu=\") {\n\t\t\t\t\t\t\t\tlocation.href = window.location + \"&stu=\"+alu;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse window.location.reload(true);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse setTimeout(\"checkChild_old(\"+alu+\")\",1);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t</script>\n\t\t\t\t\n  <script type='text/javascript' src='" . $CFG->wwwroot . "/blocks/evalcomix/javascript/jquery-1.4.2.js'></script>\n\t\t\t\t<script type='text/javascript'>//<![CDATA[ \n\t\t\t\t\tvar table = document.getElementById('user-grades');\n\t\t\t\t\t\n\t\t\t\t\tvar div11 = document.getElementById('div1');\n\t\t\t\t\tvar div22 = document.getElementById('div2');\n\t\t\t\t\tvar div = document.getElementById('div');\n\t\t\t\t\tvar documentwidth = \$(div).width();\n\t\t\t\t\t\n\t\t\t\t\tif((table.offsetWidth+100) < documentwidth){\n\t\t\t\t\t\tdiv11.style.width = (documentwidth - 50) +'px';\n\t\t\t\t\t\tdiv22.style.width = (documentwidth - 50)+'px';\n\t\t\t\t\t\t\$(div22).css('text-align','center');\n\t\t\t\t\t\t\$(table).css('margin','0 auto');\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\tdiv11.style.width = (table.offsetWidth+100)+'px';\n\t\t\t\t\t\tdiv22.style.width = (table.offsetWidth+100)+'px';\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\$(window).load(function(){\n\t\t\t\t\t\$(function(){\n\t\t\t\t\t\t\$(\".wrapper1\").scroll(function(){\n\t\t\t\t\t\t\t\$(\".wrapper2\")\n\t\t\t\t\t\t\t\t.scrollLeft(\$(\".wrapper1\").scrollLeft());\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\$(\".wrapper2\").scroll(function(){\n\t\t\t\t\t\t\t\$(\".wrapper1\")\n\t\t\t\t\t\t\t\t.scrollLeft(\$(\".wrapper2\").scrollLeft());\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t\t});//]]>  \n\n\t\t\t\t\t</script>\n\n\t\t\t\t<noscript>\n\t\t\t\t\t<div style='color: #f00;'>" . get_string('alertjavascript', 'block_evalcomix') . "</div>\n\t\t\t\t</noscript>\n";
        $tools = $this->load_tools();
        $lang = current_language();
        //array $finalgrades with two dimensions [$taskinstance][$userid] that contains the finalgrades.
        $finalgrades = evalcomix_grades::get_grades($this->courseid);
        //$finalgrades = $this->get_grades('moodleevx');
        //print_r($this->activities_ids);
        $index = 0;
        if (isset($this->activities['id'])) {
            $num_activities = count($this->activities['id']);
        } else {
            $num_activities = 0;
        }
        //$configured = array();
        $tasks_array = array();
        $groupmodes = array();
        $type_instrument = array();
        $cm = array();
        $whoassesses = array();
        global $DB;
        for ($i = 0; $i < $num_activities; $i++) {
            $cmid = $this->activities['id'][$i];
            //$cm[$cmid] = $this->get_cm($cmid);
            if (!$this->canviewhidden && $this->cm[$cmid]->visible == 0) {
                continue;
            }
            //$configured[$cmid] = $this->configured_activity($cmid);
            $groupmodes[$cmid] = $this->cm[$cmid]->groupmode;
            //$type_instrument[$cmid] = evalcomix_tasks::get_type_task($cmid);
            $type_instrument[$cmid] = $this->activities['modulename'][$i];
            //$mode_time[$cmid]['teacher'] = $this->get_modes_time($cmid, 'teacher');
            if ($tasks_array[$cmid] = evalcomix_tasks::fetch(array('instanceid' => $cmid))) {
                $taskid = $tasks_array[$cmid]->id;
                $mode_teacher[$cmid] = evalcomix_modes::fetch(array('taskid' => $taskid, 'modality' => 'teacher'));
                $mode_time[$cmid]['self'] = $this->get_modestime($tasks_array[$cmid]->id, 'self');
                $mode_time[$cmid]['peer'] = $this->get_modestime($tasks_array[$cmid]->id, 'peer');
                if ($mode_peer[$cmid] = evalcomix_modes::fetch(array('taskid' => $taskid, 'modality' => 'peer'))) {
                    if ($mode_peer_extra = evalcomix_modes_extra::fetch(array('modeid' => $mode_peer[$cmid]->id))) {
                        $whoassesses[$cmid] = $mode_peer_extra->whoassesses;
                    }
                }
            }
            //$mode_time[$cmid]['self'] = $this->get_modes_time($cmid, 'self');
            //$mode_time[$cmid]['peer'] = $this->get_modes_time($cmid, 'peer');
        }
        //To know if the documents uploaded by the students must be shown
        $assessments = $this->load_assessments($tasks_array);
        $now = getdate();
        $now_timestamp = mktime($now["hours"], $now["minutes"], $now["seconds"], $now["mon"], $now["mday"], $now["year"]);
        foreach ($users as $user) {
            //$mode = $this->get_type_evaluation($user->id);
            $mode = grade_report_evalcomix::get_type_evaluation($user->id, $this->courseid);
            if ($mode == 'self' || $mode == 'peer') {
                $gid_loginuser = $this->get_groupids($USER->id);
                $gid_user = $this->get_groupids($user->id);
            }
            $background = 'background-color:#ffffff';
            if ($index % 2 == 0) {
                $background = 'background-color:#ededed';
            }
            $index++;
            $aux = array();
            $table .= '
					<tr style="border:1px solid #146C84;' . $background . '">
					<td style="width:35px;padding:3px;"><div class="userpic">' . $OUTPUT->user_picture($user) . '</div></td>
					<td style="border:1px solid #146C84;"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $this->courseid . '">' . fullname($user) . '</a></td>';
            for ($i = 0; $i < $num_activities; $i++) {
                $allowedusers = array();
                $evaluate = '';
                $cmid = $this->activities['id'][$i];
                if (!$this->canviewhidden && $this->cm[$cmid]->visible == 0) {
                    continue;
                }
                //$configured = $this->configured_activity($this->activities['id'][$i]);
                //boolean, if there is not a grade it will not show the details link
                $showdetails = true;
                $table .= '<td style="border:1px solid #146C84;" title="' . htmlentities(fullname($user) . "\n" . $this->activities['name'][$i], ENT_QUOTES, "UTF-8") . '">';
                $table .= '<div id="evalcomixtablegrade_' . $user->id . '_' . $cmid . '">';
                //Only show the user´s grade or all grades if the USER is a teacher or admin
                if ($this->cm[$cmid]->visible == 0) {
                    $table .= '<span style="font-style:italic;color:#838383">Actividad Oculta</span>';
                } elseif ((has_capability('moodle/grade:viewhidden', $context, $USER->id) || $user->id == $USER->id) && isset($finalgrades[$this->activities['id'][$i]][$user->id]) && $finalgrades[$this->activities['id'][$i]][$user->id] > -3) {
                    if ($finalgrades[$cmid][$user->id] > -1) {
                        $table .= format_float($finalgrades[$cmid][$user->id], 2);
                        $aux[] = $finalgrades[$cmid][$user->id];
                    } else {
                        $table .= '-';
                    }
                    //if there is not anything to assess
                    if ($finalgrades[$cmid][$user->id] == -2) {
                        $showdetails = false;
                    }
                } else {
                    //there is not grade
                    //configured
                    //if($configured[$cmid]){
                    if ($this->activities_configured[$cmid]) {
                        $table .= '-';
                    } else {
                        $table .= '<span style="font-style:italic;color:#f54927">' . get_string('noconfigured', 'block_evalcomix') . '</span>';
                    }
                    $showdetails = false;
                }
                //Checks if $this->activities['id'] is configured in evalcomix
                //if ($configured[$cmid]){
                if ($this->activities_configured[$cmid]) {
                    if ($this->cm[$cmid]->visible == 0) {
                        $table .= '<div><span style="font-style:italic;color:#838383;font-weight:bold">Configurada</span></div>';
                        continue;
                    }
                    //if($tool = get_evalcomix_modality_tool($this->courseid, $tasks_array[$cmid]->id, $mode)){
                    $taskid = $tasks_array[$cmid]->id;
                    if (isset($tools[$taskid][$mode])) {
                        $tool = $tools[$taskid][$mode];
                        //$url_instrument = webservice_evalcomix_client::get_ws_assessment_form($tool->idtool, $this->courseid, $type_instrument[$cmid], $this->activities['id'][$i], $user->id, $USER->id, $mode, MOODLE_NAME, 'assess', $lang.'_utf8');
                        $url_instrument = 'assessment_form.php?id=' . $this->courseid . '&a=' . $cmid . '&t=' . $tool->idtool . '&s=' . $user->id . '&mode=assess';
                        $evaluate = '<input type="image" value="' . get_string('evaluate', 'block_evalcomix') . '" title="' . get_string('evaluate', 'block_evalcomix') . '" style="background-color:transparent;width:16px;" src="../images/evaluar.png" onclick="javascript:url(\'' . $url_instrument . '\',\'' . $user->id . '\',\'' . $this->activities['id'][$i] . '\',\'' . $this->page . '\',\'' . $this->courseid . '\');"/>';
                        //if($assessmentgrade = evalcomix_assessments::fetch(array('taskid'=>$tasks_array[$cmid]->id, 'assessorid'=>$USER->id, 'studentid'=>$user->id))){
                        $assessorid = $USER->id;
                        $studentid = $user->id;
                        if (isset($assessments[$taskid][$assessorid][$studentid])) {
                            $evaluate = '<input type="image" value="' . get_string('evaluate', 'block_evalcomix') . '" title="' . get_string('evaluate', 'block_evalcomix') . '" style="background-color:transparent;width:16px;" src="../images/evaluar2.png" onclick="javascript:url(\'' . $url_instrument . '\',\'' . $user->id . '\',\'' . $this->activities['id'][$i] . '\', \'' . $this->page . '\',\'' . $this->courseid . '\');"/>';
                        }
                        //}
                    }
                    if ($showdetails) {
                        $details = '<input  type="image" value="' . get_string('details', 'block_evalcomix') . '" style="width:16px;background-color:transparent;" title=' . get_string('details', 'block_evalcomix') . ' src="../images/lupa.png" onclick="javascript:urlDetalles(\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/details.php?cid=' . $context->id . '&itemid=' . $tasks_array[$cmid]->id . '&userid=' . $user->id . '&popup=1\');"/>';
                    } else {
                        $details = '';
                    }
                    //Show user´s documents
                    //echo $showdocuments;
                    if ($mode == 'teacher') {
                        $title = get_string('studentwork1', 'block_evalcomix') . get_string('studentwork2', 'block_evalcomix') . $this->activities['name'][$i];
                        $table .= ' <input type="image" value="' . $title . '" style="background-color:transparent;width:13px" title="' . $title . '" src="../images/task.png" 
							onclick="javascript:urlDetalles(\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/user_activity.php?id=' . $user->id . '&course=' . $this->courseid . '&mod=' . $cmid . '\');"/>';
                    }
                    //If the $USER isn´t a teacher or admin evaluate if it should show Evaluate and Details buttons
                    if ($mode == 'self' || $mode == 'peer') {
                        //echo $finalgrades[$this->activities['id'][$i]][$user->id];
                        //Obtains the groupmode of the activity
                        //$groupmode = $this->get_groupmode($this->activities['id'][$i]);
                        $groupmode = $groupmodes[$cmid];
                        $groupmembersonly = 0;
                        if (isset($this->cm[$cmid]->groupmembersonly)) {
                            $groupmembersonly = $this->cm[$cmid]->groupmembersonly;
                        }
                        $groupingid = $this->cm[$cmid]->groupingid;
                        $same_grouping = false;
                        $same_group = $this->same_group($USER->id, $user->id);
                        if ($groupingid != 0) {
                            $same_grouping = $this->same_grouping_by_users($USER->id, $user->id, $this->cm[$cmid]);
                        }
                        /*Groupmode == 1 -> Separated Groups */
                        $condition = true;
                        if (isset($whoassesses[$cmid])) {
                            switch ($whoassesses[$cmid]) {
                                case 0:
                                    $condition = true;
                                    break;
                                case 1:
                                    $condition = !$groupmembersonly && ($same_grouping && ($groupmode != 1 || $same_group) || !$groupingid && ($groupmode != 1 || $same_group)) || $groupmembersonly && (!$groupingid && ($groupmode != 1 && $gid_loginuser != -1 && $gid_user != -1 || $same_group) || $same_grouping && ($groupmode != 1 || $same_group));
                                    break;
                                case 2:
                                    if ($evalcomixallowedusers = evalcomix_allowedusers::fetch_all(array('cmid' => $cmid, 'assessorid' => $USER->id))) {
                                        foreach ($evalcomixallowedusers as $auser) {
                                            $indexuser = $auser->studentid;
                                            $allowedusers[$indexuser] = true;
                                        }
                                    }
                                    $userid = $user->id;
                                    $condition = false;
                                    if (isset($allowedusers[$userid])) {
                                        $condition = $allowedusers[$userid];
                                    } elseif ($USER->id == $user->id) {
                                        $condition = true;
                                    }
                            }
                        }
                        /*if((!$groupmembersonly && (
                        								($same_grouping && (
                        										($groupmode != 1 
                        										|| $same_group))
                        								) 
                        								|| 
                        								(!$groupingid && 
                        									(($groupmode != 1 
                        										|| $same_group)))
                        								)
                        							)
                        							|| ($groupmembersonly  && (
                        //								(!$this->cm[$cmid]->groupingid && $gid_loginuser != -1 && $gid_user != -1)
                        								(!$groupingid && 
                        									((($groupmode != 1 && $gid_loginuser != -1 && $gid_user != -1) 
                        										|| $same_group)))
                        								||
                        								($same_grouping && (
                        									($groupmode != 1 
                        										|| $same_group)))
                        								)
                        							)
                        							)*/
                        if ($condition) {
                            //($this->cm[$cmid]->groupmembersonly && $same_grouping && $groupmode == 1) ||
                            //($groupmode == 1 && ($gid_loginuser == $gid_user || $this->same_grouping($gid_loginuser, $gid_user, $this->activities['id'][$i])))){
                            //$mode_time = $this->get_modes_time($this->activities['id'][$i], $mode);
                            if ($mode == 'self') {
                                //Details always are shown in selfassessment
                                $table .= $details;
                            }
                            if ($mode_time[$cmid][$mode] != false) {
                                $available = $mode_time[$cmid][$mode]->timeavailable;
                                $due = $mode_time[$cmid][$mode]->timedue;
                                //If the availability of the activity started
                                if ($now_timestamp >= $available) {
                                    $title = get_string('studentwork1', 'block_evalcomix') . get_string('studentwork2', 'block_evalcomix') . $this->activities['name'][$i];
                                    $table .= ' <input type="image" value="' . $title . '" style="background-color:transparent;width:13px" title="' . $title . '" src="../images/task.png" 
										onclick="javascript:urlDetalles(\'' . $CFG->wwwroot . '/blocks/evalcomix/assessment/user_activity.php?id=' . $user->id . '&course=' . $this->courseid . '&mod=' . $cmid . '\');"/>';
                                }
                                /*if($mode == 'self') { //Details always are shown in selfassessment
                                			$table .= $details;
                                		}*/
                                if ($now_timestamp >= $due && $mode == 'peer' && $showdetails == true) {
                                    $url_peer_instrument = webservice_evalcomix_client::get_ws_view_assessment($this->courseid, $type_instrument[$cmid], $this->activities['id'][$i], $USER->id, $user->id, 'peer', MOODLE_NAME);
                                    $table .= '<input type="image" value="' . get_string('details', 'block_evalcomix') . '" style="width:16px" title=' . get_string('details', 'block_evalcomix') . ' src="../images/lupa.png" onclick="javascript:urlDetalles(\'' . $url_peer_instrument . '\');"/>';
                                }
                                //Show the buttons if they must be availables
                                if ($now_timestamp >= $available && $now_timestamp < $due) {
                                    $table .= $evaluate;
                                }
                            }
                        }
                    } else {
                        //if $mode == 'teacher'
                        //$table .= $details.$evaluate;
                        $table .= $details;
                        if ($mode_teacher[$cmid] != null && $mode_teacher[$cmid]->modality == 'teacher') {
                            $table .= $evaluate;
                        }
                    }
                }
                $table .= '</div>';
            }
            $table .= '</td>';
            //	}
            //Calculates average
            if (count($aux) == 0) {
                $average = 0;
            } else {
                $average = $this->calculator->calculate_one_array($aux);
                $average = round($average, 2, PHP_ROUND_HALF_UP);
                unset($aux);
            }
            $table .= '<td style="border:1px solid #146C84;">' . $average . '</td></tr>';
        }
        $table .= '</table></div>';
        $table .= '</div>';
        return $table;
    }
Example #6
0
} elseif ($sorttool == 'type') {
    usort($toollist, 'cmp_title_tool');
    usort($toollist, 'cmp_type_tool');
}
//$array = sort_object_array($tools, 'title');print_r($array);exit;
$lang = current_language();
$url_create = webservice_evalcomix_client::get_ws_createtool(null, $lms = MOODLE_NAME, $course->id, $lang . '_utf8');
$counttool = count($toollist);
echo '
	<center>
		<div style="font-weight: bold; margin-bottom:0.5em">
			<h5> ' . $OUTPUT->help_icon('whatis', 'block_evalcomix') . get_string('counttool', 'block_evalcomix') . ':  ' . $counttool . '</h5>
		</div>
		<div>
			<table style="width:80%;text-align:left;border-color:#146C84;background-color:#fff" border=1>
				<tr style="color:#00f; font-weight: bold; text-align:center">
					<td style="background-color:inherit"><a href="index.php?id=' . $courseid . '&sorttool=title">' . get_string('title', 'block_evalcomix') . '</a></td>
					<td style="background-color:inherit"><a href="index.php?id=' . $courseid . '&sorttool=type">' . get_string('type', 'block_evalcomix') . '</a></td>
					<td style="padding:0.2em;background-color:inherit;">';
if ($editing) {
    //if the login user is an editing teacher
    echo '
						<input type="button" value="' . get_string('newtool', 'block_evalcomix') . '" onclick="urledit(\'' . $url_create . '\', \'wincreate\');">';
}
echo '
					</td>
				</tr>
';
foreach ($toollist as $tool) {
    //$url_view = webservice_evalcomix_client::get_ws_viewtool($tool->idtool);
    $url_view = '../assessment/assessment_form.php?id=' . $course->id . '&t=' . $tool->idtool . '&mode=view&vt=1';
Example #7
0
<?php

require_once '../../../config.php';
$courseid = required_param('id', PARAM_INT);
// course id
$cmid = required_param('tid', PARAM_INT);
$modality = required_param('mode', PARAM_ALPHA);
$assessorid = optional_param('a', 0, PARAM_INT);
global $CFG;
require_once $CFG->dirroot . '/blocks/evalcomix/assessment/lib.php';
require_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_tasks.php';
require_once $CFG->dirroot . '/blocks/evalcomix/classes/evalcomix_modes.php';
$context = get_context_instance(CONTEXT_COURSE, $courseid);
$report_evalcomix = new grade_report_evalcomix($courseid, null, $context);
$users = $report_evalcomix->load_users();
$assessed_users = array();
if ($task = evalcomix_tasks::fetch(array('instanceid' => $cmid))) {
    if ($mode = evalcomix_modes::fetch(array('taskid' => $task->id, 'modality' => $modality))) {
        foreach ($users as $user) {
            if (!$assessorid) {
                $assessorid = $user->id;
            }
            //It obtains assignments for each task and user
            $params2 = array('taskid' => $task->id, 'studentid' => $user->id, 'assessorid' => $assessorid);
            $assessments = evalcomix_assessments::fetch_all($params2);
            if ($assessments) {
                $assessed_users[] = $user;
            }
        }
    }
}