unset($SESSION->skillsoft_id); } $SESSION->skillsoft_id = $skillsoft->id; $SESSION->skillsoft_status = 'Not Initialized'; $SESSION->skillsoft_mode = 'normal'; $SESSION->skillsoft_attempt = 1; $pagetitle = strip_tags($course->shortname . ': ' . format_string($skillsoft->name) . ' (' . format_string($skillsoft->assetid) . ')'); add_to_log($course->id, 'skillsoft', 'view activity', 'view.php?id=' . $cm->id, 'View SkillSoft Asset: ' . $skillsoft->name, $cm->id); $PAGE->set_url($url); // // Print the page header // $PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); $attempt = skillsoft_get_last_attempt($skillsoft->id, $USER->id); if ($attempt == 0) { $attempt = 1; } $currenttab = 'info'; require $CFG->dirroot . '/mod/skillsoft/tabs.php'; $viewreport = get_string('skillsoft_viewreport', 'skillsoft'); //echo '<div class="reportlink"><a href="'.new moodle_url('/mod/skillsoft/report.php', array('id'=>$skillsoft->id, 'user'=>'true', 'attempt'=>$attempt)).'">'.$viewreport.'</a></div>'; // Print the main part of the page //print_heading(format_string($skillsoft->name).' ('.format_string($skillsoft->assetid).')'); if (!empty($skillsoft->intro)) { echo $OUTPUT->box('<div class="structurehead">' . get_string('skillsoft_summary', 'skillsoft') . '</div>' . format_text($skillsoft->intro), 'generalbox boxaligncenter boxwidthwide', 'summary'); } if (!empty($skillsoft->audience)) { echo $OUTPUT->box('<div class="structurehead">' . get_string('skillsoft_audience', 'skillsoft') . '</div>' . format_text($skillsoft->audience), 'generalbox boxaligncenter boxwidthwide', 'audience'); }
/** * Print a detailed representation of what a user has done with * a given particular instance of this module, for user activity reports. * This needs to output the information * * @return boolean * @todo Finish documenting this function */ function skillsoft_user_complete($course, $user, $mod, $skillsoft) { global $OUTPUT; require_once 'locallib.php'; $table = new html_table(); $table->head = array(get_string('skillsoft_attempt', 'skillsoft'), get_string('skillsoft_firstaccess', 'skillsoft'), get_string('skillsoft_lastaccess', 'skillsoft'), get_string('skillsoft_completed', 'skillsoft'), get_string('skillsoft_lessonstatus', 'skillsoft'), get_string('skillsoft_totaltime', 'skillsoft'), get_string('skillsoft_firstscore', 'skillsoft'), get_string('skillsoft_currentscore', 'skillsoft'), get_string('skillsoft_bestscore', 'skillsoft'), get_string('skillsoft_accesscount', 'skillsoft')); $table->align = array('left', 'left', 'left', 'left', 'center', 'center', 'right', 'right', 'right', 'right'); $table->wrap = array('', '', '', '', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); $table->width = '80%'; $table->size = array('*', '*', '*', '*', '*', '*', '*', '*', '*', '*'); $row = array(); $score = ' '; $maxattempts = skillsoft_get_last_attempt($skillsoft->id, $user->id); if ($maxattempts == 0) { $maxattempts = 1; } for ($a = $maxattempts; $a > 0; $a--) { $row = array(); $score = ' '; if ($trackdata = skillsoft_get_tracks($skillsoft->id, $user->id, $a)) { $row[] = '<a href="' . new moodle_url('/mod/skillsoft/report.php', array('id' => $skillsoft->id, 'user' => 'true', 'attempt' => $trackdata->attempt)) . '">' . $trackdata->attempt . '</a>'; $row[] = isset($trackdata->{'[SUMMARY]firstaccess'}) ? userdate($trackdata->{'[SUMMARY]firstaccess'}) : ''; $row[] = isset($trackdata->{'[SUMMARY]lastaccess'}) ? userdate($trackdata->{'[SUMMARY]lastaccess'}) : ''; if ($skillsoft->completable == true) { $row[] = isset($trackdata->{'[SUMMARY]completed'}) ? userdate($trackdata->{'[SUMMARY]completed'}) : ''; $row[] = isset($trackdata->{'[CORE]lesson_status'}) ? $trackdata->{'[CORE]lesson_status'} : ''; $row[] = isset($trackdata->{'[CORE]time'}) ? $trackdata->{'[CORE]time'} : ''; $row[] = isset($trackdata->{'[SUMMARY]firstscore'}) ? $trackdata->{'[SUMMARY]firstscore'} : ''; $row[] = isset($trackdata->{'[SUMMARY]currentscore'}) ? $trackdata->{'[SUMMARY]currentscore'} : ''; $row[] = isset($trackdata->{'[SUMMARY]bestscore'}) ? $trackdata->{'[SUMMARY]bestscore'} : ''; } else { $row[] = $OUTPUT->help_icon('skillsoft_noncompletable', 'skillsoft', get_string('skillsoft_na', 'skillsoft')); $row[] = $OUTPUT->help_icon('skillsoft_noncompletable', 'skillsoft', get_string('skillsoft_na', 'skillsoft')); $row[] = $OUTPUT->help_icon('skillsoft_noncompletable', 'skillsoft', get_string('skillsoft_na', 'skillsoft')); $row[] = $OUTPUT->help_icon('skillsoft_noncompletable', 'skillsoft', get_string('skillsoft_na', 'skillsoft')); $row[] = $OUTPUT->help_icon('skillsoft_noncompletable', 'skillsoft', get_string('skillsoft_na', 'skillsoft')); $row[] = $OUTPUT->help_icon('skillsoft_noncompletable', 'skillsoft', get_string('skillsoft_na', 'skillsoft')); } $row[] = isset($trackdata->{'[SUMMARY]accesscount'}) ? $trackdata->{'[SUMMARY]accesscount'} : ''; $table->data[] = $row; } } echo html_writer::table($table); return true; }
/** * Processes all the entries imported from custom report in the datbase * updating skillsoft_au_track and gradebook * * @param $trace false default, flag to indicate if mtrace messages should be sent * @param string $prefix - The string to prefix all mtrace reports with * @return unknown_type */ function skillsoft_process_received_customreport($handle, $trace = false, $prefix = ' ') { global $CFG, $DB; set_time_limit(0); $starttime = microtime(true); if ($trace) { mtrace($prefix . get_string('skillsoft_customreport_process_start', 'skillsoft')); } //Get a count of records and process in batches $conditions = array('userid' => '0'); $countofunprocessed = $DB->count_records('skillsoft_report_results', $conditions); if ($trace) { mtrace($prefix . get_string('skillsoft_customreport_process_totalrecords', 'skillsoft', $countofunprocessed)); } // $limitfrom=0; // $limitnum=1000; // // do { // if ($trace) { // mtrace($prefix.get_string('skillsoft_customreport_process_batch','skillsoft',$limitfrom)); // } // if ($unmatchedreportresults = $DB->get_records_select('skillsoft_report_results','userid=0',null,'id ASC','*',$limitfrom,$limitnum)) { // foreach ($unmatchedreportresults as $reportresults) { // $reportresults->userid = skillsoft_getusername_from_loginname($reportresults->loginname); // if ($reportresults->userid != 0) // { // $id = $DB->update_record('skillsoft_report_results',$reportresults); // } // } // } // $limitfrom += 1000; // } while (($unmatchedreportresults != false) && ($limitfrom < $countofunprocessed)); //Perform the match of userid using SQL alone $sql = "UPDATE {skillsoft_report_results} "; $sql .= "SET userid = "; $sql .= "(SELECT id FROM {user} WHERE "; $sql .= $DB->sql_concat("'" . $CFG->skillsoft_accountprefix . "'", "{user}." . $CFG->skillsoft_useridentifier); $sql .= " = {skillsoft_report_results}.loginname) "; $sql .= "WHERE EXISTS "; $sql .= "(SELECT id FROM {user} WHERE "; $sql .= $DB->sql_concat("'" . $CFG->skillsoft_accountprefix . "'", "{user}." . $CFG->skillsoft_useridentifier); $sql .= " = {skillsoft_report_results}.loginname) "; $DB->execute($sql); //Select all the unprocessed Custom Report Results's //We do it this way so that if we create a new Moodle SkillSoft activity for an asset we //have TDR's for already we can "catch up" $sql = "SELECT t.id as id, s.id AS skillsoftid, u.id AS userid, t.firstaccessdate, t.lastaccessdate, t.completeddate, t.firstscore, t.currentscore, t.bestscore, t.lessonstatus, t.duration, t.accesscount, t.processed, t.attempt "; $sql .= "FROM {skillsoft_report_results} t "; $sql .= "INNER JOIN {user} u ON u.id = t.userid "; $sql .= "INNER JOIN {skillsoft} s ON t.assetid = s.assetid "; $sql .= "WHERE t.processed=0 "; $sql .= "ORDER BY s.id,u.id,t.firstaccessdate"; $lastreportresults = new stdClass(); $lastreportresults->skillsoftid = NULL; $lastreportresults->userid = NULL; $rs = $DB->get_recordset_sql($sql); if ($rs->valid()) { foreach ($rs as $reportresults) { if ($trace) { mtrace($prefix . $prefix . get_string('skillsoft_customreport_process_retrievedresults', 'skillsoft', $reportresults)); } if ($reportresults->attempt != 0) { $attempt = $reportresults->attempt; } else { $attempt = skillsoft_get_last_attempt($reportresults->skillsoftid, $reportresults->userid); //Check if "last attempt" is first attempt if not increment if ($attempt == 0) { $attempt = 1; } else { $attempt = $attempt + 1; } } if ($reportresults->skillsoftid != $lastreportresults->skillsoftid || $reportresults->userid != $lastreportresults->userid) { $skillsoft = $DB->get_record('skillsoft', array('id' => $reportresults->skillsoftid)); $user = $DB->get_record('user', array('id' => $reportresults->userid)); $handler = new aicchandler($user, $skillsoft, $attempt, $CFG->skillsoft_strictaiccstudentid); } //Process the ReportResults as AICC Data if ($skillsoft->completable) { $handler->processreportresults($reportresults, $attempt); } else { //Only update attempt 1 $handler->processreportresults($reportresults, 1); } $reportresults->processed = 1; $reportresults->attempt = $attempt; $lastreportresults = $reportresults; $gradeupdate = skillsoft_update_grades($skillsoft, $user->id); $id = $DB->update_record('skillsoft_report_results', $reportresults); } } $rs->close(); //Update the skillsoft_report_track skillsoft_update_customreport_processed($handle); $endtime = microtime(true); $duration = $endtime - $starttime; if ($trace) { mtrace($prefix . get_string('skillsoft_customreport_process_end', 'skillsoft') . ' (took ' . $duration . ' seconds)'); } }
$currenttab = 'allreports'; require $CFG->dirroot . '/mod/skillsoft/tabs.php'; //Just report on the activity //SQL to get all get all userid/skillsoftid records $sql = "SELECT ai.userid, ai.skillsoftid\r\n FROM {skillsoft_au_track} ai\r\n WHERE ai.skillsoftid = ?\r\n GROUP BY ai.userid,ai.skillsoftid"; $params = array($skillsoft->id); $table = new html_table(); $table->tablealign = 'center'; $table->head = array(get_string('name'), $strattempt, get_string('skillsoft_firstaccess', 'skillsoft'), get_string('skillsoft_lastaccess', 'skillsoft'), get_string('skillsoft_completed', 'skillsoft'), get_string('skillsoft_lessonstatus', 'skillsoft'), get_string('skillsoft_totaltime', 'skillsoft'), get_string('skillsoft_firstscore', 'skillsoft'), get_string('skillsoft_currentscore', 'skillsoft'), get_string('skillsoft_bestscore', 'skillsoft'), get_string('skillsoft_accesscount', 'skillsoft')); $table->align = array('left', 'left', 'left', 'left', 'left', 'center', 'center', 'right', 'right', 'right', 'right'); $table->wrap = array('', '', '', '', '', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); $table->width = '80%'; $table->size = array('*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*'); if ($skillsoftusers = $DB->get_records_sql($sql, $params)) { foreach ($skillsoftusers as $skillsoftuser) { $maxattempts = skillsoft_get_last_attempt($skillsoft->id, $skillsoftuser->userid); if ($maxattempts == 0) { $maxattempts = 1; } for ($a = $maxattempts; $a > 0; $a--) { $row = array(); $userdata = $DB->get_record('user', array('id' => $skillsoftuser->userid), 'id, firstname, lastname, picture, imagealt, email'); $row[] = $OUTPUT->user_picture($userdata, array('courseid' => $course->id)) . ' ' . '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $skillsoftuser->userid . '&course=' . $course->id . '">' . fullname($userdata) . '</a>'; $score = ' '; if ($trackdata = skillsoft_get_tracks($skillsoftuser->skillsoftid, $skillsoftuser->userid, $a)) { $row[] = $trackdata->attempt; $row[] = isset($trackdata->{'[SUMMARY]firstaccess'}) ? userdate($trackdata->{'[SUMMARY]firstaccess'}) : ''; $row[] = isset($trackdata->{'[SUMMARY]lastaccess'}) ? userdate($trackdata->{'[SUMMARY]lastaccess'}) : ''; if ($skillsoft->completable == true) { $row[] = isset($trackdata->{'[SUMMARY]completed'}) ? userdate($trackdata->{'[SUMMARY]completed'}) : ''; $row[] = isset($trackdata->{'[CORE]lesson_status'}) ? $trackdata->{'[CORE]lesson_status'} : '';