$stractions = get_string("actions", "jclic");
$strtime = get_string("time", "jclic");
$stryes = get_string("yes");
$strno = get_string("no");
print_header("{$course->shortname}: {$jclic->name}", "{$jclic->name}", "");
$sessions = jclic_get_sessions($jclic->id, $USER->id);
if (sizeof($sessions) > 0) {
    echo "<script language=\"JavaScript\" src=\"../prototype.js\" type=\"text/javascript\"></script>";
    echo '<table class="generaltable" align="center" border="0" cellpadding="5" cellspacing="1" width="95%"><tbody>';
    $general_align = array('center', 'center', 'center', 'center', 'center', 'center');
    // Print header
    jclic_print_row(array($strstarttime, $strscore, $strtotaltime, $strdone, $stractivitysolved, $strattempts), $general_align, '', true);
    // Print session data
    foreach ($sessions as $session) {
        $sessiontime = '<a href="#" onclick="Element.toggle(\'' . $session->session_id . '\')">' . date('d/m/Y H:i', strtotime($session->starttime)) . '</a>';
        $table_data = array($sessiontime, $session->score . '%', $session->totaltime, $session->done, $session->solved, $session->attempts . ($jclic->maxattempts > 0 ? '/' . $jclic->maxattempts : ''));
        jclic_print_row($table_data, $general_align);
        // Print activities for each session
        print_session_activities($session->session_id);
    }
    if (sizeof($sessions) > 1) {
        $sessions_summary = jclic_get_sessions_summary($jclic->id, $USER->id);
        jclic_print_row(array('<b>' . $strtotals . '</b>', '<b>' . $sessions_summary->score . '%</b>', '<b>' . $sessions_summary->totaltime . '</b>', '<b>' . $sessions_summary->done . '</b>', '<b>' . $sessions_summary->solved . '</b>', '<b>' . $sessions_summary->attempts . '</b>'), $general_align);
    }
    echo '</tbody></table><br>';
} else {
    echo '<br><center>' . $strmsgnosessions . '</center>';
}
?>
		
Пример #2
0
if ($where) {
    $where .= ' AND ';
}
if ($sort = $table->get_sql_sort()) {
    $sort = ' ORDER BY ' . $sort;
}
$ufields = user_picture::fields('u', $extrafields);
if (!empty($users)) {
    $select = "SELECT {$ufields} ";
    $sql = 'FROM {user} u ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
    $ausers = $DB->get_records_sql($select . $sql . $sort, $params, $table->get_page_start(), $table->get_page_size());
    if ($ausers !== false) {
        //$grading_info = grade_get_grades($course->id, 'mod', 'jclic', $jclic->id, array_keys($ausers));
        $countusers = 0;
        foreach ($ausers as $auser) {
            $sessions_summary = jclic_get_sessions_summary($jclic->id, $auser->id);
            if ($sessions_summary->attempts <= 0) {
                continue;
            }
            $countusers++;
            $picture = $OUTPUT->user_picture($auser);
            $userlink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $auser->id . '&course=' . $course->id . '">' . fullname($auser, has_capability('moodle/site:viewfullnames', $context)) . '</a>';
            $extradata = array();
            foreach ($extrafields as $field) {
                $extradata[] = $auser->{$field};
            }
            $numsessions = 0;
            if ($mode == 'details') {
                // Print sessions for each student
                $sessions = jclic_get_sessions($jclic->id, $auser->id);
                $numsessions = count($sessions);
Пример #3
0
/**
 * Return grade for given user or all users.
 *
 * @todo: implement userid=0 (all users)
 * @todo: optimize this function (to avoid call jclic_get_sessions_summary or update only mandatory info)
 *
 * @param object $jclic object
 * @param int $userid optional user id, 0 means all users
 * @return array array of grades, false if none
 */
function jclic_get_user_grades($jclic, $userid = 0)
{
    global $CFG;
    require_once $CFG->dirroot . '/mod/jclic/locallib.php';
    // sanity check on $jclic->id
    if (!isset($jclic->id)) {
        return;
    }
    $grades[$userid] = new stdClass();
    $sessions_summary = jclic_get_sessions_summary($jclic->id, $userid);
    $grades[$userid]->userid = $userid;
    $grades[$userid]->attempts = $sessions_summary->attempts;
    $grades[$userid]->totaltime = $sessions_summary->totaltime;
    $grades[$userid]->starttime = $sessions_summary->starttime;
    $grades[$userid]->done = $sessions_summary->done;
    $grades[$userid]->rawgrade = 0;
    if ($jclic->avaluation == 'score') {
        $grades[$userid]->rawgrade = $sessions_summary->score;
    } else {
        $grades[$userid]->rawgrade = $sessions_summary->solved;
    }
    return $grades;
}
function jclic_user_grades($grades, $jclic, $userid)
{
    $sessions_summary = jclic_get_sessions_summary($jclic->id, $userid);
    if ($jclic->avaluation == 'score') {
        $grades[$userid] = $sessions_summary->score;
    } else {
        $grades[$userid] = $sessions_summary->solved;
    }
    return $grades;
}
                     $student_info = print_user_picture($student, $course->id, NULL, 0, true) . $student->firstname . ' ' . $student->lastname;
                     $table_data = array($student_info, $sessiontime, $session->done, $session->solved, $session->totaltime, $session->score . '%', $session->attempts . ($jclic->maxattempts > 0 ? '/' . $jclic->maxattempts : ''));
                     $table_props = array('rowspan="' . (sizeof($sessions) * 2 + 1) . '"', '', '', '', '', '', '');
                     $table_align = $general_align;
                 } else {
                     $table_data = array($sessiontime, $session->done, $session->solved, $session->totaltime, $session->score . '%', $session->attempts . ($jclic->maxattempts > 0 ? '/' . $jclic->maxattempts : ''));
                     $table_props = '';
                     $table_align = array('center', 'center', 'center', 'center', 'center', 'center');
                 }
                 jclic_print_row($table_data, $table_align, $table_props);
                 // Print activities for each session
                 print_session_activities($session->session_id);
             }
         }
     }
     $sessions_summary = jclic_get_sessions_summary($jclic->id, $student->userid);
     $starttime = array_key_exists('starttime', $sessions_summary) ? $sessions_summary->starttime : '0';
     if ($starttime > 0) {
         $starttime = date('d/m/Y H:i', strtotime($sessions_summary->starttime));
     } else {
         $starttime = '-';
     }
     if (!$showall || sizeof($sessions) <= 0) {
         $table_align = $general_align;
         $student_info = print_user_picture($student, $course->id, NULL, 0, true) . $student->firstname . ' ' . $student->lastname;
         jclic_print_row(array($student_info, !$showall ? $starttime : (sizeof($sessions) <= 0 ? '-' : '<b>' . $strtotals . '</b>'), '<b>' . $sessions_summary->done . '</b>', '<b>' . $sessions_summary->solved . '</b>', '<b>' . $sessions_summary->totaltime . '</b>', '<b>' . $sessions_summary->score . ' %</b>', '<b>' . $sessions_summary->attempts . ($jclic->maxattempts > 0 ? '/' . $jclic->maxattempts : '') . '</b>'), $table_align);
     } else {
         $table_align = array('center', 'center', 'center', 'center', 'center', 'center');
         jclic_print_row(array(!$showall ? $starttime : (sizeof($sessions) <= 0 ? '-' : '<b>' . $strtotals . '</b>'), '<b>' . $sessions_summary->done . '</b>', '<b>' . $sessions_summary->solved . '</b>', '<b>' . $sessions_summary->totaltime . '</b>', '<b>' . $sessions_summary->score . ' %</b>', '<b>' . $sessions_summary->attempts . ($jclic->maxattempts > 0 ? '/' . $jclic->maxattempts : '') . '</b>'), $table_align);
     }
 }