Пример #1
1
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$ship_name = $_POST['ship_name'];
$ship_address = $_POST['ship_address'];
$ship_city = $_POST['ship_city'];
$ship_state = $_POST['ship_state'];
$ship_zip = $_POST['ship_zip'];
$ship_country = $_POST['ship_country'];
do_html_header('结算');
do_html_top();
if (is_array($_SESSION['cart'])) {
    if ($name && $address && $city && $state && $zip && $country) {
        $userid = find_userid($_SESSION['valid_user']);
        if ($order_info = insert_order($_POST, $userid)) {
            display_cart($_SESSION['cart'], false, 1, 1);
            display_card_form($order_info);
        } else {
            echo "订单写入数据库失败";
        }
    } else {
        echo "用户信息填写不完整";
        display_button('checkout.php', '返回');
    }
} else {
    echo "您还没有添加商品到购物车";
    display_button('index.php', '返回首页');
}
do_html_footer();
Пример #2
0
function evaluate_quiz($acode, $jobid, $newattempt, $blended)
{
    global $USER;
    global $CFG;
    mtrace("Evaluation QUIZ Processing..." . "<BR><BR>");
    try {
        print "New Attempt is: " . $newattempt . "<BR/>";
        $detected_userid = find_userid($acode, $jobid);
        if ($detected_userid == null or $detected_userid == '') {
            throw new EvaluationError(get_string('ErrorUserIDEmpty', 'blended'), EvaluationError::USERID_IS_EMPTY);
        }
        $user_reg = blended_get_user($detected_userid, $blended);
        if ($user_reg == null) {
            throw new EvaluationError(get_string('ErrorUserNotInCourse', 'blended'), EvaluationError::USER_NOT_IN_THIS_COURSE);
        }
        $userid = $user_reg->id;
        mtrace('Obtained USERID value: ' . $userid . " OK. <BR/>");
        $quiz = get_quiz($acode);
        $attempts = quiz_get_user_attempts($quiz->id, $userid, 'all', true);
        mtrace("Searching quiz... Success." . "<BR/>");
        $uniqueid = get_uniqueid($acode);
        mtrace('Obtained uniqueid: OK. <BR/>');
        $timestamp = get_timestamp($acode);
        mtrace('Obtained timestamp: OK. <BR/>');
        if (!get_record('quiz_attempts', 'uniqueid', $uniqueid)) {
            $newattempt = true;
        } else {
            $newattempt = false;
            mtrace("User {$userid} had opened this attempt already.");
        }
        $attemptnumber = 1;
        if ($newattempt == false) {
            mtrace('Obtaining user attempt...<BR/>');
            set_attempt_unfinished($uniqueid);
            $attempt = quiz_get_user_attempt_unfinished($quiz->id, $userid);
        } elseif ($newattempt == true) {
            mtrace('Creating new attempt...<BR/>');
            $attempt = create_new_attempt($quiz, $attemptnumber, $userid, $acode, $uniqueid, $timestamp);
            // Save the attempt
            if (!insert_record('quiz_attempts', $attempt)) {
                throw new EvaluationError(get_string('ErrorCouldNotCreateAttempt', 'blended'), EvaluationError::CREATE_QUIZ_ATTEMPT_ERROR);
            }
            // Actualizamos el estado de las imágenes para indicar que ya está creado un nuevo attempt
            update_images_status($acode, $jobid);
        }
        update_question_attempts($uniqueid);
        // /*
        mtrace('<BR>Getting questions and question options... ');
        $questions = get_questions($attempt, $quiz);
        if (!get_question_options($questions)) {
            error('Could not load question options');
        }
        mtrace('Success! <BR>');
        //	print ("<BR>He obtenido questions: ");
        //print_object($questions);
        $lastattemptid = false;
        //	 if ($attempt->attempt > 1 and $quiz->attemptonlast and !$attempt->preview) {
        // Find the previous attempt
        //      if (!$lastattemptid = get_field('quiz_attempts', 'uniqueid', 'quiz', $attempt->quiz, 'userid', $attempt->userid, 'attempt', $attempt->attempt-1)) {
        //        error('Could not find previous attempt to build on');
        //  }
        //}
        //print ('He obtenido lastattemptid');
        mtrace('Getting question states... ');
        if (!($states = get_question_states($questions, $quiz, $attempt, $lastattemptid))) {
            error('Could not restore question sessions');
        }
        mtrace('Success! <BR>');
        mtrace('Getting responses... <BR>');
        $responses = get_responses($acode, $jobid, $attempt);
        //print('Estas son las responses:');
        //print_object($responses);
        //$timestamp=time();
        $event = 8;
        $actions = question_extract_responses($questions, $responses, $event);
        $questionids = get_questionids($acode);
        //	print $questionids;
        $questionidarray = explode(',', $questionids);
        $success = true;
        mtrace('<BR> Processing responses and saving session... ');
        foreach ($questionidarray as $i) {
            if (!isset($actions[$i])) {
                $actions[$i]->responses = array('' => '');
                $actions[$i]->event = QUESTION_EVENTOPEN;
            }
            $actions[$i]->timestamp = $timestamp;
            if (question_process_responses($questions[$i], $states[$i], $actions[$i], $quiz, $attempt)) {
                save_question_session($questions[$i], $states[$i]);
            } else {
                $success = false;
            }
        }
        mtrace('Success! <BR>');
        // Set the attempt to be finished
        $timestamp = time();
        //$attempt->timefinish = $timestamp;
        // Update the quiz attempt and the overall grade for the quiz
        mtrace('<BR> Finishing the attempt... ');
        // print_object ($attempt);
        if (set_field('quiz_attempts', 'timefinish', $timestamp, 'uniqueid', $uniqueid) == false) {
            throw new EvaluationError('Unable to finish the quiz attempt!', EvaluationError::FINISH_QUIZ_ATTEMPT_ERROR);
        }
        mtrace('Success! <BR>');
        if ($attempt->attempt > 1 || $attempt->timefinish > 0 and !$attempt->preview) {
            mtrace('<BR> Saving quiz grade... ');
            quiz_save_best_grade($quiz, $userid);
        }
        mtrace('Success! <BR>');
        // */
        mtrace("Process Done. <BR><BR>");
        mtrace("<center> Your quiz has been succesfully evaluated!! </center>");
    } catch (EvaluationError $e) {
        throw $e;
    }
    return;
}
Пример #3
0
for ($i = 0; $i < $numActivities; $i++) {
    if (isset($_REQUEST["selectedActivity{$i}"])) {
        $acodes[] = $_REQUEST["selectedActivity{$i}"];
    }
}
if ($acode) {
    $acodes[] = $acode;
}
global $CFG;
print_spacer(20);
print_heading(format_string(get_string('correction', 'blended')));
// iterate over the activity codes
foreach ($acodes as $acode) {
    $link = new stdClass();
    $quizid = find_quizid($acode);
    $id_member = find_userid($acode, $jobid);
    $user_reg = blended_get_user($id_member, $blended);
    $link->hrefText = "Resultados";
    $link->href = "{$CFG->wwwroot}/mod/quiz/report.php?&q={$quizid}";
    try {
        evaluate_quiz($acode, $jobid, $newattempt, $blended);
    } catch (EvaluationError $e) {
        print "EvaluationError: " . $e->getMessage();
        register_exception($e, $jobid);
    } catch (ResultsError $e) {
        print "ResultsError: " . $e->getMessage();
        register_exception($e, $jobid);
    }
    /**
     * Mark images as passed
     */
Пример #4
0
$message->acode = $acode;
$message->jobname = $jobname;
$jobpath = create_url($jobname, $course->id);
$message->href = $jobpath;
$message->hrefText = $jobname;
print_spacer(20);
print_heading(format_string(get_string('correction', 'blended')));
print_box(format_text(get_string('showdetailspagedesc', 'blended', $message)), 'generalbox', 'intro');
print_spacer(20);
$values = new stdClass();
try {
    $defaulteval = get_eval_value($acode, $jobid);
    $values->eval = $defaulteval;
    $values->activitycode = $acode;
    $values->jobid = $jobid;
    $useridvalue = find_userid($acode, $jobid);
    print "Act {$acode}, job {$jobid} user ({$useridvalue})";
    $values->userid = $useridvalue;
    $values->a = $a;
    $values->id = $id;
    $values->warnings = get_doubtfull_marks($acode, $jobid);
    $mform = new correctionForm($values);
    if (!$mform->is_cancelled() && ($data = $mform->get_data())) {
        process_results_form($data);
    }
    if (isset($data->errors_resolved)) {
        $continue = "{$CFG->wwwroot}/mod/blended/scannedJob.php?a={$a}&jobid={$jobid}";
        print_continue($continue);
    } else {
        if ($mform->is_cancelled()) {
            //you need this section if you have a cancel button on your form
/**
 * Construct a table view of all results related to a quiz
 * 
 */
function show_quiz_results_table($blended, $quiz, $course, $context)
{
    global $CFG;
    $currentpage = 'quizJob.php';
    if (!($images_view = get_records($table = "blended_images", $field = 'jobid', $value = $jobid, $sort = 'activitycode,pageindex'))) {
        print_box(get_string('ErrorScannedImageNotFound', 'blended'));
    } else {
        $i = 0;
        $images = array();
        $displayed_codes = array();
        $iconWarning = '<img src="images/warning.png" width="32" alt="' . get_string('MarkWarning', 'blended') . '"/>';
        echo "<form action=\"evaluate.php\" method=\"POST\" >";
        echo '<input type="hidden" name="a" value="' . $blended->id . '"/>';
        echo '<input type="hidden" name="jobid" value="' . $jobid . '"/>';
        foreach ($images_view as $result) {
            $acode = $result->activitycode;
            $imgout = $result->imgout;
            $pageindex = $result->pageindex;
            if ($acode) {
                $quiz_already_displayed = in_array($acode, $displayed_codes);
                if ($quiz_already_displayed == false) {
                    $imagerow = array();
                    $id_member = find_userid($acode, $jobid);
                    $user_reg = blended_get_user($id_member, $blended);
                    $verresultados = get_string('modulename', 'quiz') . $acode;
                    $quiz_in_course = check_quiz_course($acode, $course);
                    $showdetailslink = "<a href=\"showdetails.php?&a={$blended->id}&acode={$acode}&jobid={$result->jobid}\">{$verresultados}</a>";
                    $attempts = get_record('blended_attempts', 'id', $acode);
                    $index = $i + 1;
                    if ($user_reg != null && $attempts != false) {
                        $checkbox = "<input type=\"checkbox\" name=\"selectedActivity{$index}\" value=\"{$acode}\" />";
                    } else {
                        $checkbox = "<input type=\"checkbox\" name=\"selectedActivity{$index}\" disabled=\"true\" value=\"{$acode}\" />";
                    }
                    $imagerow["index"] = $checkbox . $index;
                    $imagerow["correctionlink"] = $showdetailslink;
                    $imagerow["activitycode"] = $result->activitycode . get_string('page', 'blended') . $pageindex;
                    $imagerow["alumno"] = '';
                    if ($user_reg !== null) {
                        $imagerow["alumno"] = print_user_picture($user_reg, $course->id, null, null, true) . fullname($user_reg);
                    } else {
                        $imagerow["alumno"] = get_string('ErrorUserIDEmpty', 'blended');
                    }
                    $imagerow["pasar"] = '';
                    $imagerow["status"] = '';
                    $status = '';
                    $warnings = count_doubtfull_marks($acode, $jobid);
                    if ($warnings > 0) {
                        $warn = $iconWarning . "Hay {$warnings} marcas dudosas!!";
                    } else {
                        $warn = '';
                    }
                    $imagerow["activitycode"] = $warn . '<br/>' . $imagerow["activitycode"];
                    if ($quiz_in_course) {
                        if (has_capability('mod/blended:evaluatequiz', $context)) {
                            if ($result->status == IMAGE_STATUS_PENDING) {
                                $evaluate = get_string('blendedPassToQuiz', 'blended');
                                $link = "<a href=\"evaluate.php?&a={$blended->id}&acode={$acode}&jobid={$jobid}\">{$evaluate}</a>";
                                $imagerow["pasar"] = $link;
                                $status = get_string('NotYet', 'blended');
                            } else {
                                $imagerow["pasar"] = get_string('blendedPassedToQuiz', 'blended');
                                $link = "<a href=\"evaluate.php?a={$blended->id}&acode={$acode}&jobid={$jobid}\">" . get_string('blendedPassAgainToQuiz', 'blended') . "</a>";
                                $status = $link;
                            }
                        } else {
                            $imagerow["pasar"] = "Permission Denied" . ($status = "");
                        }
                    }
                    $imagerow["status"] = $status;
                    if (has_capability('mod/blended:deletequiz', $context)) {
                        $imgdelete = "<img src=\"delete.gif\"/>";
                        $link = "<a href=\"delete_quiz.php?page={$currentpage}&acode={$acode}&jobid={$jobid}&a={$blended->id}\">{$imgdelete}</a>";
                        $delete = $link;
                        $imagerow["delete"] = $delete;
                    }
                    if ($attempts == false) {
                        // attempt not found in blended.
                        /*	echo"<center>";
                        			mtrace("El cuestionario que ha procesado pertenece a otro curso o no existe en la base de datos de este servidor.");
                        			echo"<center><br><br>";*/
                        $scan = blended_getOMRScanJob($result->jobid);
                        $resultname = $scan->scan_name . "-" . $result->id;
                        $correctionlink = "<a href=\"activitycode.php?&a={$blended->id}&jobid={$result->jobid}&resultid={$result->id}\">{$resultname}</a>";
                        $imagerow["correctionlink"] = $correctionlink;
                        //$imagerow["correctionlink"]='';
                        $imagerow["activitycode"] = "Erróneo." . $result->activitycode . ' ' . get_string('pages', 'blended') . $pageindex;
                        $imagerow["alumno"] = '';
                        $imagerow["pasar"] = '<img align="left" src="images/warning.png" width="32"/>' . get_string('ErrorActivityCodeNotFound', 'blended', $acode);
                        $status = "";
                        $key = "{$acode}{$pageindex}";
                        $images[$key] = $imagerow;
                    } else {
                        $displayed_codes[$acode] = $acode;
                        // avoid using another rows for different pages of the same activity
                        $images[$acode] = $imagerow;
                    }
                    $i++;
                } else {
                    $images[$acode]["activitycode"] .= ", " . $pageindex;
                }
            }
            // $acode!=null
        }
        echo '<input type="hidden" name="numActivities" value="' . $index . '" />';
        /**
         *  Add results with no $acode detected
         ***/
        foreach ($images_view as $result) {
            $scan = blended_getOMRScanJob($result->jobid);
            $acode = $result->activitycode;
            $resultname = $scan->scan_name . "-" . $result->id;
            $page = $result->page;
            if ($acode == null) {
                $imagerow = array();
                $imagerow["index"] = "";
                $correctionlink = "<a href=\"activitycode.php?&a={$blended->id}&jobid={$result->jobid}&resultid={$result->id}\">{$resultname}</a>";
                $imagerow["correctionlink"] = $correctionlink;
                $imagerow["activitycode"] = get_string('UnclassifiedPage', 'blended');
                $imagerow["alumno"] = '';
                $imagerow["pasar"] = '';
                $imagerow["status"] = get_string('NotYet', 'blended');
                if (has_capability('mod/blended:deletescanjob', $context)) {
                    $link = "<a href=\"delete_quiz.php?page={$currentpage}&acode={$acode}&jobid={$jobid}&a={$blended->id}\">{$imgdelete}</a>";
                    $delete = $link;
                    $imagerow["delete"] = $delete;
                }
                $images[] = $imagerow;
                $i++;
            }
        }
        //tabla de resultados
        $table = new stdClass();
        $table->class = 'mytable';
        $table->head = array('Seleccionar', 'Ver Resultados', 'ActivityCode', 'Alumno', 'Pasar a QUIZ', 'Evaluado en Moodle', 'Borrar');
        $align = "left";
        $table->align = array($align, $align, $align, $align, $align, $align, $align);
        $tablealign = "center";
        $table->tablealign = $tablealign;
        $table->rowclasses = array();
        $table->data = $images;
        print_table($table);
        echo '<center><input type="submit" name="manyActivities" value="' . get_string('blendedPassSelectedToQuiz', 'blended') . '"/></center>';
        echo "</form>";
    }
    return;
}