Beispiel #1
0
 if ($book >= 1) {
     $bookdata = $DB->get_record("reader_publisher", array("id" => $book));
 }
 $attemptsofbook = $DB->get_records_sql("SELECT * FROM {reader_attempts} WHERE quizid= ?  and reader= ? ", array($book, $reader->id));
 while (list($attemptsofbookkey, $attemptsofbook_) = each($attemptsofbook)) {
     if (strtolower($attemptsofbook_->passed) == 'true') {
         $pfcmark = 'P';
     } else {
         if (strtolower($attemptsofbook_->passed) == 'false') {
             $pfcmark = 'F';
         } else {
             $pfcmark = 'C';
         }
     }
     $userdata = $DB->get_record("user", array("id" => $attemptsofbook_->userid));
     $table->data[] = array(html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => 'adjustscoresupbooks[]', 'value' => $attemptsofbook_->id)), fullname($userdata), array(html_writer::link(new moodle_url('/mod/reader/report.php', array('idh' => $id, 'q' => $bookdata->quizid, 'mode' => 'analysis', 'b' => $bookdata->id)), $bookdata->name), $bookdata->name), $bookdata->publisher, $bookdata->level, reader_get_reader_difficulty($reader, $bookdata->id), round($attemptsofbook_->persent) . "%", $pfcmark, date("d-M-Y", $attemptsofbook_->timemodified), 'deleted');
 }
 $table->data = reader_sort_table_data($table->data, $titlesarray, $orderby, $sort);
 $publisherform = array("id=" . $id . "&publisher=Select_Publisher" => get_string("selectpublisher", "reader"));
 $publishers = $DB->get_records("reader_publisher", NULL, "publisher");
 foreach ($publishers as $publisher_) {
     $publisherform["id=" . $id . "&publisher=" . $publisher_->publisher] = $publisher_->publisher;
 }
 $alink = new moodle_url("/mod/reader/admin.php", array("id" => $id, "act" => $act, 'a' => 'admin'));
 if (isset($adjustscorestext)) {
     reader_red_notice($adjustscorestext);
 }
 $o = "";
 $o .= html_writer::start_tag('table', array('style' => 'width:100%'));
 $o .= html_writer::start_tag('tr');
 $o .= html_writer::start_tag('td', array('align' => 'right'));
                if ($showform) {
                    if (!empty($books_->sametitle) && is_array($alreadyansweredbookssametitle)) {
                        if ($reader->individualbooks == 1) {
                            if (!in_array($books_->sametitle, $alreadyansweredbookssametitle)) {
                                $booksform[$books_->bookid] = "{$books_->name} ({$books_->level}[RL " . reader_get_reader_difficulty($reader, $books_->bookid) . "])";
                            }
                        } else {
                            if (!in_array($books_->sametitle, $alreadyansweredbookssametitle)) {
                                $booksform[$books_->id] = "{$books_->name} ({$books_->level}[RL " . reader_get_reader_difficulty($reader, $books_->id) . "])";
                            }
                        }
                    } else {
                        if ($reader->individualbooks == 1) {
                            $booksform[$books_->bookid] = "{$books_->name} ({$books_->level}[RL " . reader_get_reader_difficulty($reader, $books_->bookid) . "])";
                        } else {
                            $booksform[$books_->id] = "{$books_->name} ({$books_->level}[RL " . reader_get_reader_difficulty($reader, $books_->id) . "])";
                        }
                    }
                }
            }
        }
    }
}
if ($publisher != "Select Publisher") {
    if (count($booksform) > 0) {
        echo html_writer::start_tag('select', array('size' => 10, 'name' => 'book', 'id' => 'id_book', 'style' => 'width: 500px;', 'multiple' => 'multiple'));
        foreach ($booksform as $booksformkey => $booksformvalue) {
            echo html_writer::tag('option', $booksformvalue, array('value' => $booksformkey));
        }
        echo html_writer::end_tag('select');
    } else {
Beispiel #3
0
function reader_get_student_attempts($userid, $reader, $allreaders = false, $booklist = false)
{
    global $CFG, $COURSE, $bookpersentmaxgrade, $DB, $USER;
    $returndata = array();
    $totable = array();
    $readersql = "";
    if ($booklist) {
        $reader->ignordate = 0;
    }
    if (!$allreaders) {
        $readersql = " and ra.reader= :readerid ";
    }
    $studentattempts_p = $DB->get_records_sql("SELECT ra.timefinish,ra.userid,ra.attempt,ra.persent,ra.id,ra.quizid,ra.sumgrades,ra.passed,ra.checkbox,ra.preview,rp.name,rp.publisher,rp.level,rp.length,rp.image,rp.difficulty,rp.words,rp.sametitle,rp.id as rpid FROM {reader_attempts} ra LEFT JOIN {reader_publisher} rp ON rp.id = ra.quizid WHERE ra.preview != 1 and ra.userid= :userid and ra.timefinish > :readerignordate {$readersql} ORDER BY ra.timefinish", array("readerid" => $reader->id, "userid" => $userid, "readerignordate" => $reader->ignordate));
    $studentattempts_n = $DB->get_records_sql("SELECT ra.timefinish,ra.userid,ra.attempt,ra.persent,ra.id,ra.quizid,ra.sumgrades,ra.passed,ra.checkbox,ra.preview,rp.name,rp.publisher,rp.level,rp.length,rp.image,rp.difficulty,rp.words,rp.sametitle,rp.id as rpid FROM {reader_attempts} ra LEFT JOIN {reader_noquiz}    rp ON rp.id = ra.quizid WHERE ra.preview = 1 and ra.userid= :userid and ra.timefinish > :readerignordate {$readersql} ORDER BY ra.timefinish", array("readerid" => $reader->id, "userid" => $userid, "readerignordate" => $reader->ignordate));
    if (is_array($studentattempts_n) && is_array($studentattempts_p)) {
        $studentattempts = array_merge($studentattempts_p, $studentattempts_n);
    } elseif ($studentattempts_n) {
        $studentattempts = $studentattempts_n;
    } else {
        $studentattempts = $studentattempts_p;
    }
    if (!($studentlevel = $DB->get_record("reader_levels", array("userid" => $USER->id, "readerid" => $reader->id)))) {
        $createlevel = new stdClass();
        $createlevel->userid = $USER->id;
        $createlevel->startlevel = 0;
        $createlevel->currentlevel = 0;
        $createlevel->readerid = $reader->id;
        $createlevel->promotionstop = $reader->promotionstop;
        $createlevel->time = time();
        $DB->insert_record('reader_levels', $createlevel);
        $studentlevel = $DB->get_record("reader_levels", array("userid" => $USER->id, "readerid" => $reader->id));
    }
    if (is_array($studentattempts)) {
        $totable['correct'] = 0;
        $totable['incorrect'] = 0;
        $totable['totalpoints'] = 0;
        $totable['countattempts'] = 0;
        foreach ($studentattempts as $studentattempt) {
            $totable['countattempts']++;
            if ($studentattempt->passed == "true" || $studentattempt->passed == "TRUE") {
                $statustext = "Passed";
                $status = "correct";
                $totable['points'] = reader_get_reader_length($reader, $studentattempt->rpid);
                $totable['correct']++;
            } else {
                if ($studentattempt->passed == "cheated") {
                    $statustext = "<font color='red'>" . get_string('cheated', 'reader') . "</font>";
                } else {
                    $statustext = "Not Passed";
                }
                $status = "incorrect";
                $totable['points'] = 0;
                $totable['incorrect']++;
            }
            $totable['totalpoints'] += round($totable['points'], 2);
            if (!isset($bookpersentmaxgrade[$studentattempt->quizid])) {
                $totalgrade = 0;
                $answersgrade = $DB->get_records("reader_question_instances", array("quiz" => $studentattempt->quizid));
                foreach ($answersgrade as $answersgrade_) {
                    $totalgrade += $answersgrade_->grade;
                }
                $totable['bookpersent'] = $studentattempt->persent . "%";
                $totable['bookmaxgrade'] = $totalgrade * reader_get_reader_length($reader, $studentattempt->rpid);
                $bookpersentmaxgrade[$studentattempt->quizid] = array($totable['bookpersent'], $totable['bookmaxgrade']);
            } else {
                list($totable['bookpersent'], $totable['bookmaxgrade']) = $bookpersentmaxgrade[$studentattempt->quizid];
            }
            if ($studentattempt->preview == 1) {
                $statustext = "Credit";
            }
            $returndata[$studentattempt->id] = array("id" => $studentattempt->id, "quizid" => $studentattempt->quizid, "timefinish" => $studentattempt->timefinish, "booktitle" => $studentattempt->name, "image" => $studentattempt->image, "words" => $studentattempt->words, "booklength" => reader_get_reader_length($reader, $studentattempt->rpid), "booklevel" => $studentattempt->level, "bookdiff" => reader_get_reader_difficulty($reader, $studentattempt->rpid), "persent" => $studentattempt->persent, "passed" => $studentattempt->passed, "checkbox" => $studentattempt->checkbox, "sametitle" => $studentattempt->sametitle, "userlevel" => $studentlevel->currentlevel, "status" => $status, "statustext" => $statustext, "bookpoints" => $totable['points'], "bookpersent" => $totable['bookpersent'], "bookmaxgrade" => $totable['bookmaxgrade'], "totalpoints" => $totable['totalpoints'], "startlevel" => $studentlevel->startlevel, "currentlevel" => $studentlevel->currentlevel);
        }
        $totable['startlevel'] = $studentlevel->startlevel;
        $totable['currentlevel'] = $studentlevel->currentlevel;
        return array($returndata, $totable);
    } else {
        return false;
    }
}