Exemplo n.º 1
0
 function definition()
 {
     $mform =& $this->_form;
     //Is the & symbol for error supression needed?  Perhaps it is when $this->_form is not yet defined
     $mform->addElement('select', 'category', get_string('category'), category_menu());
     $options = array('rows' => 7);
     $mform->addElement('htmleditor', 'question', get_string('question'), $options);
     $mform->setType('question', PARAM_RAW);
     //Perhaps not filtering this is when multi-media is showing extra stuff.  Check into using something other than PARAM_RAW
     $mform->addElement('htmleditor', 'answer', get_string('answer'), $options);
     $mform->setType('answer', PARAM_RAW);
     $mform->addElement('text', 'reference', 'Reference', array('size' => '70'));
     unset($options);
     $options[0] = get_string("zerodef", "memorybank");
     $options[1] = get_string("onedef", "memorybank");
     $options[2] = get_string("twodef", "memorybank");
     $options[3] = get_string("threedef", "memorybank");
     $options[4] = get_string("fourdef", "memorybank");
     $options[5] = get_string("fivedef", "memorybank");
     $mform->addElement('select', 'initialgrade', get_string("initialgrade", "memorybank"), $options);
     $mform->setDefault('initialgrade', 4);
     $mform->addElement('checkbox', 'visible', get_string('visible'));
     $mform->setDefault('visible', true);
     $currentyear = date('Y');
     $options = array('startyear' => $currentyear, 'stopyear' => $currentyear + 1, 'timezone' => 99, 'applydst' => true, 'optional' => false);
     $mform->addElement('date_time_selector', 'initviewtime', get_string("nextviewing", "memorybank"), $options);
     $mform->setDefault('initviewtime', nextViewingDay() - 24 * 60 * 60);
     //$mform->disabledIf('visible', 'initviewtime[off]', 'checked');  //Check if this is working
     $instid = required_param('instid');
     $mform->addElement('hidden', 'instid', $instid);
     $mform->addElement('hidden', 'qid', null);
     $mform->addElement('hidden', 'what', 'add');
     $this->add_action_buttons();
     $what = optional_param('what', null);
     if ($what === 'edit') {
         $qid = required_param('qid');
         $question = get_record('memorybank_bank', 'id', $qid);
         $mform->setDefault('initialgrade', $question->initialgrade);
         $mform->setDefault('question', $question->question);
         $mform->setDefault('answer', $question->answer);
         $mform->setDefault('reference', $question->reference);
         $mform->setDefault('initviewtime', $question->initviewtime);
         $mform->setDefault('visible', $question->visible);
         $mform->setDefault('what', 'edit');
         $mform->setDefault('qid', $qid);
         $mform->setDefault('category', $question->modid);
     }
 }
Exemplo n.º 2
0
<?php

require_once '../../config.php';
require_once 'locallib.php';
global $CFG;
$username = optional_param('username');
$user = get_record('user', 'username', $username);
if (empty($user)) {
    echo get_string('no_such_user', 'memorybank', $username);
    //"$username is not setup for using MemoryBanks");
    exit;
}
$currenttime = time();
$qcount = count_records_select('memorybank_schedule', "userid = {$user->id} AND nextviewing <= {$currenttime}");
if (empty($qcount)) {
    echo get_string('questions_completed', 'memorybank', userdate(nextViewingDay(), '%H:%M'));
    exit;
}
echo "<a href='{$CFG->wwwroot}/mod/memorybank/view.php' target='_blank'>{$qcount}" . get_string("userQcount", "memorybank", $username) . "</a>";
Exemplo n.º 3
0
 $question = get_record('memorybank_bank', 'id', $qid);
 if (empty($question)) {
     var_dump(debug_backtrace());
     die('got level of invalid question');
 }
 if (!($schedule = get_record('memorybank_schedule', 'userid', $USER->id, 'questionid', $qid))) {
     die('this item is not currently scheduled.  It should not be called');
 } else {
     $currenthalflife = $schedule->halflife;
     $previoustimeanswered = $schedule->lastanswered;
     $schedule->lastanswered = time();
     $schedule->lastgrade = $level;
     // compute this based on answer $schedule->nextviewing
     //$schedule->nextviewing = time() + (-log(.9)/log(2))*$memorybank_DEFAULT_HALFLIFE;
     $schedule->viewcount++;
     $schedule->nextviewing = nextViewingDay() + rand(0, 60);
     if ($level > 2) {
         $schedule->nextviewing += ($level - 3) * ($schedule->viewcount - rand(0, 1)) * 24 * 60 * 60;
         //echo('next viewing in '. ($schedule->nextviewing - time())/(24*60*60));
     }
     update_record("memorybank_schedule", $schedule);
 }
 $submission = new object();
 $submission->qid = $qid;
 $submission->userid = $USER->id;
 $submission->timequestionviewed = $lasttime;
 $submission->timeanswered = $schedule->lastanswered;
 $submission->millisecondresponse = ($submission->timeanswered - $submission->timequestionviewed) * 1000;
 $submission->grade = $level;
 $submission->viewcount = $schedule->viewcount;
 $submission->currenthalflife = $currenthalflife;