Inheritance: extends xx
Exemplo n.º 1
1
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, '<div id="MainDiv" class="StdDiv">')) {
         // not an hp6 file
         return false;
     }
     if (!strpos($content, 'function Create_StateArray()')) {
         // not a Rottmeier file
         return false;
     }
     if (!strpos($content, 'this.ErrorFound = false;')) {
         // not a Rottmeier FindIt file
         return false;
     }
     if (strpos($content, 'this.GapSolved = false;')) {
         // oops - a Rottmeier FindIt (b) file
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, '<div id="MainDiv" class="StdDiv">')) {
         // not an hp6 file
         return false;
     }
     if (!strpos($content, '<div id="ClozeDiv">')) {
         // not a jcloze file
         return false;
     }
     if (strpos($content, 'function Create_StateArray()')) {
         // a Rottmeier DropDown or FindIt file
         return false;
     }
     if (strpos($content, 'function Add_GlossFunctionality()')) {
         // a Rottmeier JGloss file
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, 'div id="MainDiv" class="StdDiv"')) {
         // not a HP file
         return false;
     }
     if (!strpos($content, 'div id="MatchDiv"')) {
         // not a jmatch file
         return false;
     }
     if (strpos($content, 'function CheckPair(id){')) {
         if (strpos($content, 'M = new Array();')) {
             if (strpos($content, 'clickarray = new Array();')) {
                 // jmemori
                 return true;
             }
         }
     }
     // not a jmemori file
     return false;
 }
Exemplo n.º 4
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, '<div class="Feedback" id="DivIntroPage">')) {
         // not a jmatch-intro file
         return false;
     }
     if (strpos($content, '<div id="MainDiv" class="StdDiv">')) {
         if (strpos($content, '<div id="MatchDiv" align="center">')) {
             // jmatch-intro v6
             return true;
         }
     }
     if (strpos($content, '<div class="StdDiv" id="CheckButtonDiv">')) {
         if (strpos($content, 'F = new Array();')) {
             if (strpos($content, 'D = new Array();')) {
                 // overkill?
                 // jmatch-intro v6+ (drag and drop)
                 return true;
             }
         }
     }
     // not a jmatch-intro file
     return false;
 }
Exemplo n.º 5
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, '<div id="MainDiv" class="StdDiv">')) {
         if (!strpos($content, '<div class="StdDiv" id="CheckButtonDiv">')) {
             // not a hp6 file
             return false;
         }
     }
     if (!strpos($content, '<div id="SegmentDiv">')) {
         // drop-down
         if (!strpos($content, '<div id="Drop')) {
             // drag-and-drop
             // not a jmix file
             return false;
         }
     }
     return true;
 }
Exemplo n.º 6
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!preg_match('/<!--\\s*<!DOCTYPE[^>]*>\\s*-->/', $content)) {
         // no fancy DOCTYPE workarounds for IE6
         return false;
     }
     // detect <object ...>, <embed ...> and self-closing <script ... /> tags
     if (!preg_match('/<object[^>]*id="presentation"[^>]*>/', $content)) {
         return false;
     }
     if (!preg_match('/<embed[^>]*name="presentation"[^>]*>/', $content)) {
         return false;
     }
     if (!preg_match('/<script[^>]*src="[^">]*fixprompt.js"[^>]*\\/>/', $content)) {
         return false;
     }
     return true;
 }
Exemplo n.º 7
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     // e.g. http://www.qedoc.net/library/PLJUB_019.zip
     $search = '/http:\\/\\/www\\.qedoc.(?:com|net)\\/library\\/\\w+\\.zip/i';
     return preg_match($search, $sourcefile->get_source());
     // Note: we may want to detect the following as well:
     // http://www.qedoc.net/qqp/jnlp/PLJUB_019.jnlp
 }
Exemplo n.º 8
0
 /**
  * add_response_to_rawdata
  *
  * @param xxx $table (passed by reference)
  * @param xxx $attemptid
  * @param xxx $column
  * @param xxx $response
  */
 function add_response_to_rawdata(&$table, $attemptid, $column, $response)
 {
     $text = '';
     static $str = null;
     if (is_null($str)) {
         $str = (object) array('correct' => get_string('correct', 'mod_hotpot'), 'wrong' => get_string('wrong', 'mod_hotpot'), 'ignored' => get_string('ignored', 'mod_hotpot'), 'score' => get_string('score', 'mod_hotpot'), 'hintsclueschecks' => get_string('clues', 'mod_hotpot') . ',' . get_string('hints', 'mod_hotpot') . ',' . get_string('checks', 'mod_hotpot'));
     }
     // correct
     if ($value = $response->correct) {
         $value = $table->set_legend($column, $value);
         $text .= html_writer::tag('li', $value, array('class' => 'correct'));
     }
     // wrong
     if ($value = $response->wrong) {
         $values = array();
         foreach (explode(',', $value) as $v) {
             $values[] = $table->set_legend($column, $v);
         }
         $text .= html_writer::tag('li', implode(',', $values), array('class' => 'wrong'));
     }
     // ignored
     if ($value = $response->ignored) {
         $values = array();
         foreach (explode(',', $value) as $v) {
             $values[] = $table->set_legend($column, $v);
         }
         $text .= html_writer::tag('li', implode(',', $values), array('class' => 'ignored'));
     }
     // numeric
     if (is_numeric($response->score)) {
         $value = $response->score . '%';
         $text .= html_writer::tag('li', $value, array('class' => 'score'));
         $hints = empty($response->hints) ? 0 : $response->hints;
         $clues = empty($response->clues) ? 0 : $response->clues;
         $checks = empty($response->checks) ? 0 : $response->checks;
         $value = '(' . $hints . ',' . $clues . ',' . $checks . ')';
         $text .= html_writer::tag('li', $value, array('class' => 'hintsclueschecks'));
     }
     if ($text) {
         $text = html_writer::tag('ul', $text, array('class' => 'response'));
     }
     $table->rawdata[$attemptid]->{$column} = $text;
 }
Exemplo n.º 9
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (strpos($content, '<div id="MainDiv" class="StdDiv">')) {
         if (strpos($content, '<table class="FlashcardTable" border="0" cellspacing="0">')) {
             // hp6 jmatch flashcard
             return true;
         }
     }
     // not a jmatch-intro file
     return false;
 }
Exemplo n.º 10
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, '<div id="MainDiv" class="StdDiv">')) {
         // not an hp6 file
         return false;
     }
     if (!strpos($content, '<div id="QNav" class="QuestionNavigation">')) {
         // not a jquiz file
         return false;
     }
     return true;
 }
Exemplo n.º 11
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, '<div class="StdDiv">')) {
         // not an tt3 file
         return false;
     }
     if (!strpos($content, '<form id="Rhubarb" action="" onsubmit="CheckGuess(); return false">')) {
         // not an rhubarb file
         return false;
     }
     return true;
 }
Exemplo n.º 12
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (strpos($content, '<!-- JMatch_Sort v')) {
         if (strpos($content, 'var hauteurUserDefined1')) {
             if (strpos($content, 'var largeurUserDefined2')) {
                 // jmatch-sort
                 return true;
             }
         }
     }
     // not a jmatch-sort file
     return false;
 }
Exemplo n.º 13
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     if (!preg_match('/\\.html?$/', $sourcefile->get_filename())) {
         // wrong file type
         return false;
     }
     if (!($content = self::get_content($sourcefile))) {
         // empty or non-existant file
         return false;
     }
     if (!strpos($content, '<div class="StdDiv">')) {
         // not an tt3 file
         return false;
     }
     if (!strpos($content, '<div id="ChoiceDiv">')) {
         // not an sequitur file
         return false;
     }
     if (!strpos($content, '<div class="Story" id="Story">')) {
         // not an sequitur file
         return false;
     }
     return true;
 }
Exemplo n.º 14
0
/**
 * hotpot_reset_course_form_definition
 *
 * @param xxx $mform (passed by reference)
 */
function hotpot_reset_course_form_definition(&$mform)
{
    $mform->addElement('header', 'hotpotheader', get_string('modulenameplural', 'hotpot'));
    $mform->addElement('checkbox', 'reset_hotpot_deleteallattempts', get_string('deleteallattempts', 'hotpot'));
}
Exemplo n.º 15
0
 /**
  * adjust_grades_in_rawdata
  *
  * this function adjusts the grade values
  *
  * @param xxx $table (passed by reference)
  * @return xxx
  */
 function adjust_grades_in_rawdata(&$table)
 {
     if (empty($table->rawdata)) {
         return false;
         // no records
     }
     if (!$table->has_column('grade')) {
         return false;
         // no grade column
     }
     if (empty($table->column_suppress) || empty($table->column_suppress['grade'])) {
         return false;
         // grade column is not suppressed (i.e. it is always printed)
     }
     $userid = 0;
     $grade = 0;
     $prefix = '';
     foreach ($table->rawdata as $id => $record) {
         if ($userid) {
             if ($userid == $record->userid) {
                 // same user - do nothing
             } else {
                 if ($grade == $record->grade) {
                     // oops, same grade as previous user - we must adjust the grade value,
                     // so that "print_row()" (lib/tablelib.php) does not suppress this grade
                     if ($prefix) {
                         $prefix = '';
                     } else {
                         // add an empty span tag to make grade different from previous user's
                         $prefix = html_writer::tag('span', '');
                     }
                 } else {
                     // different grade from previous user, so we can unset the prefix
                     $prefix = '';
                 }
             }
             if ($prefix) {
                 $table->rawdata[$id]->grade = $prefix . $table->rawdata[$id]->grade;
             }
         }
         $userid = $record->userid;
         $grade = $record->grade;
     }
 }
Exemplo n.º 16
0
 /**
  * fix_special
  *
  * @param xxx $match
  * @param xxx $output (passed by reference)
  * @return xxx
  */
 function fix_special($output, $match)
 {
     $url = trim($match[1]);
     $player = trim($match[2]);
     $width = trim($match[3]);
     $height = trim($match[4]);
     $options = trim($match[5]);
     $space = trim($match[6]);
     // convert $url to $absoluteurl
     $absoluteurl = $output->convert_url_relative($url);
     //$absoluteurl = $output->convert_url($url, '');
     // set height equal to width, if necessary
     if ($width && !$height) {
         $height = $width;
     }
     //if ($player=='' && $this->image_filetypes && preg_match('/\.(?:'.$this->image_filetypes.')/i', $url)) {
     //    $player = 'img';
     //}
     //if ($player=='img' || $player=='image') {
     //    return '<img src="'.$absoluteurl.'" width="'.$width.'" height="'.$height.'" />';
     //}
     if ($player == '') {
         $player = $this->get_defaultplayer($url);
     }
     // $options_array will be passed to mediaplugin_filter
     $options_array = array();
     // add $player, $width and $height to $option_array
     if ($player == 'movie' || $player == 'object') {
         $options_array['movie'] = $absoluteurl;
         $options_array['skipmediaurl'] = true;
     } else {
         if ($player == 'center' || $player == 'hide') {
             $options_array[$player] = true;
             $player = '';
         } else {
             if ($player) {
                 $options_array['player'] = $player;
             }
         }
     }
     if ($width) {
         $options_array['width'] = $width;
     }
     if ($height) {
         $options_array['height'] = $height;
     }
     // transfer $options to $option_array
     if (preg_match_all('/([^ =\\]]+)(=((?:\\\\?"[^"]*")|\\w*))?/s', $options, $matches)) {
         $i_max = count($matches[0]);
         for ($i = 0; $i < $i_max; $i++) {
             $name = $matches[1][$i];
             if ($matches[2][$i]) {
                 $options_array[$name] = trim($matches[3][$i], '"\\');
             } else {
                 $options_array[$name] = true;
                 // boolean switch
             }
         }
     }
     // remove trailing space if player is to be centered or hidden
     if (!empty($options_array['center']) || !empty($options_array['hide'])) {
         $space = '';
     }
     $link = '<a href="' . $absoluteurl . '" target="_blank">' . $url . '</a>';
     return $this->fix_link($output, $options_array, $link) . $space;
 }
Exemplo n.º 17
0
/**
 * xmldb_hotpot_fix_previous_field
 *
 * @param xxx $dbman
 * @param xmldb_table $table
 * @param xmldb_field $field (passed by reference)
 * @return void, but may update $field->previous
 */
function xmldb_hotpot_fix_previous_field($dbman, $table, &$field)
{
    $previous = $field->getPrevious();
    if (empty($previous) || $dbman->field_exists($table, $previous)) {
        // $previous field exists - do nothing
    } else {
        // $previous field does not exist, so remove it
        $field->setPrevious(null);
    }
}
Exemplo n.º 18
0
 /**
  * setupForm
  *
  * @param xxx $mform (passed by reference)
  */
 function setupForm(&$mform)
 {
     $objs = array($mform->createElement('select', $this->_name . '_op', null, $this->get_operators()), $mform->createElement('duration', $this->_name, null, array('optional' => 0, 'defaultunit' => 1)));
     $mform->addElement('group', $this->_name . '_grp', $this->_label, $objs, '', false);
     $mform->disabledIf($this->_name . '_grp', $this->_name . '_op', 'eq', 0);
     $mform->setType($this->_name . '_op', PARAM_INT);
     $mform->setType($this->_name . '[number]', PARAM_INT);
     $mform->setType($this->_name . '[timeunit]', PARAM_INT);
     if (!is_null($this->_default)) {
         $mform->setDefault($this->_name, $this->_default);
     }
     if ($this->_advanced) {
         $mform->setAdvanced($this->_name . '_grp');
     }
 }
Exemplo n.º 19
0
 /**
  * set_preferred_pagelayout
  *
  * @param xxx $PAGE
  */
 public function set_preferred_pagelayout($PAGE)
 {
     // page layouts are defined in theme/xxx/config.php
     switch ($this->navigation) {
         case self::NAVIGATION_ORIGINAL:
         case self::NAVIGATION_NONE:
             // $PAGE->set_pagelayout('popup');
             $PAGE->set_pagelayout('embedded');
             break;
         case self::NAVIGATION_FRAME:
         case self::NAVIGATION_EMBED:
             $framename = optional_param('framename', '', PARAM_ALPHA);
             if ($framename == 'top') {
                 $PAGE->set_pagelayout('frametop');
             }
             if ($framename == 'main') {
                 $PAGE->set_pagelayout('embedded');
             }
             break;
         case self::NAVIGATION_TOPBAR:
             $PAGE->set_pagelayout('login');
             // no nav menu
             break;
     }
 }
Exemplo n.º 20
0
 /**
  * exitlinks
  *
  * @param xxx $hotpot
  * @return xxx
  */
 public function exitlinks($hotpot)
 {
     $table = new html_table();
     $table->attributes['class'] = 'hotpotexitlinks';
     if ($hotpot->attempt->status == hotpot::STATUS_COMPLETED) {
         if ($hotpot->require_exitgrade() && $hotpot->attempt->score < $hotpot->exitgrade) {
             // insufficient grade to show link to next activity
             $cm = false;
         } else {
             // get next activity, if there is one
             $cm = $hotpot->get_cm('exit');
         }
         if ($cm) {
             $url = new moodle_url('/mod/' . $cm->modname . '/view.php', array('id' => $cm->id));
             $table->data[] = new html_table_row(array(new html_table_cell(html_writer::link($url, get_string('exit_next', 'hotpot'))), new html_table_cell(html_writer::link($url, format_string(urldecode($cm->name))))));
         }
     }
     if ($hotpot->exitoptions & hotpot::EXITOPTIONS_RETRY) {
         // retry this hotpot, if allowed
         if ($hotpot->attemptlimit == 0 || empty($hotpot->attempts) || $hotpot->attemptlimit < count($hotpot->attempts)) {
             $table->data[] = new html_table_row(array(new html_table_cell(html_writer::link($hotpot->view_url(), get_string('exit_retry', 'hotpot'))), new html_table_cell(html_writer::link($hotpot->view_url(), format_string($hotpot->name)))));
         }
     }
     if ($hotpot->exitoptions & hotpot::EXITOPTIONS_INDEX) {
         $table->data[] = new html_table_row(array(new html_table_cell(html_writer::link($hotpot->index_url(), get_string('exit_index', 'hotpot'))), new html_table_cell(html_writer::link($hotpot->index_url(), get_string('exit_index_text', 'hotpot')))));
     }
     if ($hotpot->exitoptions & hotpot::EXITOPTIONS_COURSE) {
         $table->data[] = new html_table_row(array(new html_table_cell(html_writer::link($hotpot->course_url(), get_string('exit_course', 'hotpot'))), new html_table_cell(html_writer::link($hotpot->course_url(), get_string('exit_course_text', 'hotpot')))));
     }
     if ($hotpot->exitoptions & hotpot::EXITOPTIONS_GRADES) {
         if ($hotpot->course->showgrades && $hotpot->gradeweighting) {
             $url = new moodle_url($hotpot->grades_url());
             $table->data[] = new html_table_row(array(new html_table_cell(html_writer::link($url, get_string('exit_grades', 'hotpot'))), new html_table_cell(html_writer::link($url, get_string('exit_grades_text', 'hotpot')))));
         }
     }
     $output = '';
     if ($count = count($table->data)) {
         if ($count > 1) {
             $output .= $this->whatnext('exit_whatnext');
         }
         $output .= html_writer::table($table);
     }
     return $output;
 }
Exemplo n.º 21
0
 /**
  * store
  *
  * @param xxx $hotpot
  */
 public static function store($hotpot)
 {
     global $CFG, $DB, $USER;
     if (empty($hotpot->attempt)) {
         return;
         // no attempt record - shouldn't happen !!
     }
     if ($hotpot->attempt->userid != $USER->id) {
         return;
         // wrong userid - shouldn't happen !!
     }
     // update quiz attempt fields using incoming data
     $hotpot->attempt->score = max(0, optional_param(self::scorefield, 0, PARAM_INT));
     $hotpot->attempt->status = max(0, optional_param('status', 0, PARAM_INT));
     $hotpot->attempt->redirect = max(0, optional_param('redirect', 0, PARAM_INT));
     $hotpot->attempt->details = optional_param(self::detailsfield, '', PARAM_RAW);
     // update timemodified for this attempt
     $hotpot->attempt->timemodified = $hotpot->time;
     // time values, e.g. "2008-09-12 16:18:18 +0900",
     // need to be converted to numeric date stamps
     $timefields = array('starttime', 'endtime');
     foreach ($timefields as $timefield) {
         $hotpot->attempt->{$timefield} = 0;
         // default
         if ($time = optional_param($timefield, '', PARAM_RAW)) {
             // make sure the timezone has a "+" sign
             // Note: sometimes it gets stripped (by optional_param?)
             $time = preg_replace('/(?<= )\\d{4}$/', '+$0', trim($time));
             // convert $time to numeric date stamp
             // PHP4 gives -1 on error, whereas PHP5 give false
             $time = strtotime($time);
             if ($time && $time > 0) {
                 $hotpot->attempt->{$timefield} = $time;
             }
         }
     }
     unset($timefields, $timefield, $time);
     // set finish times
     $hotpot->attempt->timefinish = $hotpot->time;
     // increment quiz attempt duration
     $startfield = self::durationstartfield;
     // "starttime" or "timestart"
     $finishfield = self::durationfinishfield;
     // "endtime" or "timefinish"
     $duration = $hotpot->attempt->{$finishfield} - $hotpot->attempt->{$startfield};
     if (empty($hotpot->attempt->duration)) {
         $hotpot->attempt->duration = $duration;
     } else {
         if ($duration > 0) {
             $hotpot->attempt->duration += $duration;
         }
     }
     unset($duration, $startfield, $finishfield);
     // set clickreportid, (for click reporting)
     $hotpot->attempt->clickreportid = $hotpot->attempt->id;
     // check if there are any previous results stored for this attempt
     // this could happen if ...
     //     - the quiz has been resumed
     //     - clickreporting is enabled for this quiz
     if ($DB->get_field('hotpot_attempts', 'timefinish', array('id' => $hotpot->attempt->id))) {
         if ($hotpot->clickreporting) {
             // self::can_clickreporting()
             // add quiz attempt record for each form submission
             // records are linked via the "clickreportid" field
             // update timemodified and status in previous records in this clickreportid group
             $DB->set_field('hotpot_attempts', 'timemodified', $hotpot->time, array('clickreportid' => $hotpot->attempt->clickreportid));
             $DB->set_field('hotpot_attempts', 'status', $hotpot->attempt->status, array('clickreportid' => $hotpot->attempt->clickreportid));
             // add new attempt record
             unset($hotpot->attempt->id);
             if (!($hotpot->attempt->id = $DB->insert_record('hotpot_attempts', $hotpot->attempt))) {
                 print_error('error_insertrecord', 'hotpot', '', 'hotpot_attempts');
             }
         } else {
             // remove previous responses for this attempt, if required
             // (N.B. this does NOT remove the attempt record, just the responses)
             $DB->delete_records('hotpot_responses', array('attemptid' => $hotpot->attempt->id));
         }
     }
     // add details of this quiz attempt, if required
     // "hotpot_storedetails" is set by administrator
     // Site Admin -> Modules -> Activities -> HotPot
     if ($CFG->hotpot_storedetails) {
         // delete/update/add the details record
         if ($DB->record_exists('hotpot_details', array('attemptid' => $hotpot->attempt->id))) {
             $DB->set_field('hotpot_details', 'details', $hotpot->attempt->details, array('attemptid' => $hotpot->attempt->id));
         } else {
             $details = (object) array('attemptid' => $hotpot->attempt->id, 'details' => $hotpot->attempt->details);
             if (!$DB->insert_record('hotpot_details', $details, false)) {
                 print_error('error_insertrecord', 'hotpot', '', 'hotpot_details');
             }
             unset($details);
         }
     }
     // add details of this attempt
     self::store_details($hotpot->attempt);
     // update the attempt record
     if (!$DB->update_record('hotpot_attempts', $hotpot->attempt)) {
         print_error('error_updaterecord', 'hotpot', '', 'hotpot_attempts');
     }
     // regrade the quiz to take account of the latest quiz attempt score
     hotpot_update_grades($hotpot->to_stdclass(), $hotpot->attempt->userid);
 }
Exemplo n.º 22
0
 /**
  * is_quizfile
  *
  * @param xxx $sourcefile
  * @return xxx
  */
 public static function is_quizfile($sourcefile)
 {
     return preg_match('/\\.jcl$/', $sourcefile->get_filename());
 }