function backup($bf, $preferences, $question, $level = 6) { $status = true; $multianswers = get_records("question_multianswer", "question", $question, "id"); //If there are multianswers if ($multianswers) { //Print multianswers header $status = fwrite($bf, start_tag("MULTIANSWERS", $level, true)); //Iterate over each multianswer foreach ($multianswers as $multianswer) { $status = fwrite($bf, start_tag("MULTIANSWER", $level + 1, true)); //Print multianswer contents fwrite($bf, full_tag("ID", $level + 2, false, $multianswer->id)); fwrite($bf, full_tag("QUESTION", $level + 2, false, $multianswer->question)); fwrite($bf, full_tag("SEQUENCE", $level + 2, false, $multianswer->sequence)); $status = fwrite($bf, end_tag("MULTIANSWER", $level + 1, true)); } //Print multianswers footer $status = fwrite($bf, end_tag("MULTIANSWERS", $level, true)); //Now print question_answers $status = question_backup_answers($bf, $preferences, $question); } return $status; }
/** * Backup the extra information specific to an essay question - over and above * what is in the mdl_question table. * * @param file $bf The backup file to write to. * @param object $preferences the blackup options controlling this backup. * @param $questionid the id of the question being backed up. * @param $level indent level in the backup file - so it can be formatted nicely. */ function backup($bf, $preferences, $questionid, $level = 6) { return question_backup_answers($bf, $preferences, $questionid, $level); }
/** * Backup the data in the question * * This is used in question/backuplib.php */ function backup($bf, $preferences, $question, $level = 6) { $status = true; $webworks = get_records('question_webwork', 'question', $question, 'id'); //If there are webworks if ($webworks) { //Iterate over each webwork foreach ($webworks as $webwork) { $status = fwrite($bf, start_tag("WEBWORK", $level, true)); fwrite($bf, full_tag("CODECHECK", $level + 1, false, $webwork->codecheck)); fwrite($bf, full_tag("CODE", $level + 1, false, $webwork->code)); fwrite($bf, full_tag("GRADING", $level + 1, false, $webwork->grading)); $status = fwrite($bf, end_tag("WEBWORK", $level, true)); } $status = question_backup_answers($bf, $preferences, $question); } return $status; }
function backup($bf, $preferences, $question, $level = 6) { $status = true; $extraquestionfields = $this->extra_question_fields(); if (is_array($extraquestionfields)) { $questionextensiontable = array_shift($extraquestionfields); $record = get_record($questionextensiontable, $this->questionid_column_name(), $question); if ($record) { $tagname = strtoupper($this->name()); $status = $status && fwrite($bf, start_tag($tagname, $level, true)); foreach ($extraquestionfields as $field) { if (!isset($record->{$field})) { echo "No data for field {$field} when backuping " . $this->name() . ' question id ' . $question; return false; } fwrite($bf, full_tag(strtoupper($field), $level + 1, false, $record->{$field})); } $status = $status && fwrite($bf, end_tag($tagname, $level, true)); } } $extraasnwersfields = $this->extra_answer_fields(); if (is_array($extraasnwersfields)) { //TODO backup the answers, with any extra data. } else { $status = $status && question_backup_answers($bf, $preferences, $question); } return $status; }
/** * Backup the data in the question to a backup file. * * This function is used by question/backuplib.php to create a copy of the data * in the question so that it can be restored at a later date. The method writes * all the supplementary algebra type-specific information from the question_algebra * data base table as well as writing out all the variables used by the question. * It also uses the question_backup_answers function from question/backuplib.php to * backup all the question answers. * * @param $bf the backup file to write the information to * @param $preferences backup preferences in effect (not used) * @param $question the ID number of the question being backed up * @param $level the indentation level of the data being written * * @return bool true if the backup was successful, false if it failed. */ function backup($bf, $preferences, $question, $level = 6) { // Set the devault return value, $status, to be true $status = true; $algebraqs = get_records('question_algebra', 'questionid', $question, 'id ASC'); // If there are algebra questions if ($algebraqs) { // Iterate over each algebra question foreach ($algebraqs as $algebra) { $status = $status && fwrite($bf, start_tag('ALGEBRA', $level, true)); // Print algebra question contents fwrite($bf, full_tag('COMPAREBY', $level + 1, false, $algebra->compareby)); fwrite($bf, full_tag('VARIABLES', $level + 1, false, $algebra->variables)); fwrite($bf, full_tag('NCHECKS', $level + 1, false, $algebra->nchecks)); fwrite($bf, full_tag('TOLERANCE', $level + 1, false, $algebra->tolerance)); fwrite($bf, full_tag('ALLOWEDFUNCS', $level + 1, false, $algebra->allowedfuncs)); fwrite($bf, full_tag('DISALLOW', $level + 1, false, $algebra->disallow)); fwrite($bf, full_tag('ANSWERPREFIX', $level + 1, false, $algebra->answerprefix)); // Backup all the variables $status = $status && $this->backup_variables($bf, $preferences, $question, 7); // End algebra data $status = $status && fwrite($bf, end_tag('ALGEBRA', $level, true)); } // Backup the answers $status = $status && question_backup_answers($bf, $preferences, $question); } return $status; }
function backup($bf, $preferences, $question, $level = 6) { $status = true; $calculateds = get_records("question_calculated", "question", $question, "id"); //If there are calculated-s if ($calculateds) { //Iterate over each calculateds foreach ($calculateds as $calculated) { $status = $status && fwrite($bf, start_tag("CALCULATED", $level, true)); //Print calculated contents fwrite($bf, full_tag("ANSWER", $level + 1, false, $calculated->answer)); fwrite($bf, full_tag("TOLERANCE", $level + 1, false, $calculated->tolerance)); fwrite($bf, full_tag("TOLERANCETYPE", $level + 1, false, $calculated->tolerancetype)); fwrite($bf, full_tag("CORRECTANSWERLENGTH", $level + 1, false, $calculated->correctanswerlength)); fwrite($bf, full_tag("CORRECTANSWERFORMAT", $level + 1, false, $calculated->correctanswerformat)); //Now backup numerical_units $status = question_backup_numerical_units($bf, $preferences, $question, 7); //Now backup required dataset definitions and items... $status = question_backup_datasets($bf, $preferences, $question, 7); //End calculated data $status = $status && fwrite($bf, end_tag("CALCULATED", $level, true)); } //Now print question_answers $status = question_backup_answers($bf, $preferences, $question); } return $status; }
function backup($bf, $preferences, $question, $level = 6) { $status = true; $multichoices = get_records("question_multichoice", "question", $question, "id"); //If there are multichoices if ($multichoices) { //Iterate over each multichoice foreach ($multichoices as $multichoice) { $status = fwrite($bf, start_tag("MULTICHOICE", $level, true)); //Print multichoice contents fwrite($bf, full_tag("LAYOUT", $level + 1, false, $multichoice->layout)); fwrite($bf, full_tag("ANSWERS", $level + 1, false, $multichoice->answers)); fwrite($bf, full_tag("SINGLE", $level + 1, false, $multichoice->single)); fwrite($bf, full_tag("SHUFFLEANSWERS", $level + 1, false, $multichoice->shuffleanswers)); fwrite($bf, full_tag("CORRECTFEEDBACK", $level + 1, false, $multichoice->correctfeedback)); fwrite($bf, full_tag("PARTIALLYCORRECTFEEDBACK", $level + 1, false, $multichoice->partiallycorrectfeedback)); fwrite($bf, full_tag("INCORRECTFEEDBACK", $level + 1, false, $multichoice->incorrectfeedback)); fwrite($bf, full_tag("ANSWERNUMBERING", $level + 1, false, $multichoice->answernumbering)); $status = fwrite($bf, end_tag("MULTICHOICE", $level, true)); } //Now print question_answers $status = question_backup_answers($bf, $preferences, $question); } return $status; }
function backup($bf, $preferences, $question, $level = 6) { $status = true; $truefalses = get_records("question_truefalse", "question", $question, "id"); //If there are truefalses if ($truefalses) { //Iterate over each truefalse foreach ($truefalses as $truefalse) { $status = fwrite($bf, start_tag("TRUEFALSE", $level, true)); //Print truefalse contents fwrite($bf, full_tag("TRUEANSWER", $level + 1, false, $truefalse->trueanswer)); fwrite($bf, full_tag("FALSEANSWER", $level + 1, false, $truefalse->falseanswer)); $status = fwrite($bf, end_tag("TRUEFALSE", $level, true)); } //Now print question_answers $status = question_backup_answers($bf, $preferences, $question); } return $status; }
/** * Backup the data in the question * * This is used in question/backuplib.php */ function backup($bf, $preferences, $question, $level = 6) { $status = true; $numericals = get_records('question_numerical', 'question', $question, 'id ASC'); //If there are numericals if ($numericals) { //Iterate over each numerical foreach ($numericals as $numerical) { $status = fwrite($bf, start_tag("NUMERICAL", $level, true)); //Print numerical contents fwrite($bf, full_tag("ANSWER", $level + 1, false, $numerical->answer)); fwrite($bf, full_tag("TOLERANCE", $level + 1, false, $numerical->tolerance)); //Now backup numerical_units $status = question_backup_numerical_units($bf, $preferences, $question, 7); $status = fwrite($bf, end_tag("NUMERICAL", $level, true)); } //Now print question_answers $status = question_backup_answers($bf, $preferences, $question); } return $status; }
function backup($bf, $preferences, $question, $level = 6) { $status = true; $shortanswers = get_records('question_shortanswer', 'question', $question, 'id ASC'); //If there are shortanswers if ($shortanswers) { //Iterate over each shortanswer foreach ($shortanswers as $shortanswer) { $status = fwrite($bf, start_tag("SHORTANSWER", $level, true)); //Print shortanswer contents fwrite($bf, full_tag("ANSWERS", $level + 1, false, $shortanswer->answers)); fwrite($bf, full_tag("USECASE", $level + 1, false, $shortanswer->usecase)); $status = fwrite($bf, end_tag("SHORTANSWER", $level, true)); } //Now print question_answers $status = question_backup_answers($bf, $preferences, $question); } return $status; }
/** * Backup the data in the question * * This is used in question/backuplib.php */ function backup($bf, $preferences, $question, $level = 6) { $status = true; if (!($alldata = self::load_all_data($question))) { return $status; } $status = $status && fwrite($bf, start_tag('MATRIX', $level, true)); $status = $status && fwrite($bf, full_tag('QUESTIONID', $level + 1, false, $question)); $status = $status && fwrite($bf, full_tag('GRADEMETHOD', $level + 1, false, $alldata->grademethod)); $status = $status && fwrite($bf, full_tag('MULTIPLE', $level + 1, false, $alldata->multiple)); $status = $status && fwrite($bf, full_tag('RENDERER', $level + 1, false, $alldata->renderer)); $status = $status && fwrite($bf, start_tag('ROWS', $level + 1, true)); foreach ($alldata->rows as $row) { $status = $status && fwrite($bf, start_tag('ROW', $level + 2, true)); $status = $status && fwrite($bf, full_tag('ID', $level + 3, false, $row->id)); $status = $status && fwrite($bf, full_tag('MATRIXID', $level + 3, false, $row->matrixid)); $status = $status && fwrite($bf, full_tag('SHORTTEXT', $level + 3, false, $row->shorttext)); $status = $status && fwrite($bf, full_tag('DESCRIPTION', $level + 3, false, $row->description)); $status = $status && fwrite($bf, full_tag('FEEDBACK', $level + 3, false, $row->feedback)); $status = $status && fwrite($bf, end_tag('ROW', $level + 2, true)); } $status = $status && fwrite($bf, end_tag('ROWS', $level + 1, true)); $status = $status && fwrite($bf, start_tag('COLS', $level + 1, true)); foreach ($alldata->cols as $col) { $status = $status && fwrite($bf, start_tag('COL', $level + 2, true)); $status = $status && fwrite($bf, full_tag('ID', $level + 3, false, $col->id)); $status = $status && fwrite($bf, full_tag('MATRIXID', $level + 3, false, $col->matrixid)); $status = $status && fwrite($bf, full_tag('SHORTTEXT', $level + 3, false, $col->shorttext)); $status = $status && fwrite($bf, full_tag('DESCRIPTION', $level + 3, false, $col->description)); $status = $status && fwrite($bf, end_tag('COL', $level + 2, true)); } $status = $status && fwrite($bf, end_tag('COLS', $level + 1, true)); $status = $status && fwrite($bf, start_tag('WEIGHTS', $level + 1, true)); foreach ($alldata->rawweights as $weight) { $status = $status && fwrite($bf, start_tag('WEIGHT', $level + 2, true)); $status = $status && fwrite($bf, full_tag('ID', $level + 3, false, $weight->id)); $status = $status && fwrite($bf, full_tag('ROWID', $level + 3, false, $weight->rowid)); $status = $status && fwrite($bf, full_tag('COLID', $level + 3, false, $weight->colid)); $status = $status && fwrite($bf, full_tag('WEIGHT', $level + 3, false, $weight->weight)); $status = $status && fwrite($bf, end_tag('WEIGHT', $level + 2, true)); } $status = $status && fwrite($bf, end_tag('WEIGHTS', $level + 1, true)); $status = $status && fwrite($bf, end_tag('MATRIX', $level, true)); $status = question_backup_answers($bf, $preferences, $question); return $status; }
/** * Backup the data in the question * * This is used in question/backuplib.php */ function backup($bf, $preferences, $question, $level = 6) { $status = true; $fileresponses = get_records("question_fileresponse", "question", $question, "id ASC"); // If there is a question if ($fileresponses) { // Iterate over each foreach ($fileresponses as $fileresponse) { $status = $status && fwrite($bf, start_tag("FILERESPONSE", $level, true)); // Print contents $status = $status && fwrite($bf, full_tag("MAXBYTES", $level + 1, false, $fileresponse->maxbytes)); $status = $status && fwrite($bf, full_tag("ESSAY", $level + 1, false, $fileresponse->essay)); $status = $status && fwrite($bf, end_tag("FILERESPONSE", $level, true)); } // Now print question_answers $status = $status && question_backup_answers($bf, $preferences, $question, $level); } return $status; }
function wrsqz_backup($questionType, $dbType, &$bf, &$preferences, &$question, &$level, $extraquestionfields, $questionid_column_name) { $problemRecord = get_records('question_' . $dbType, 'question', $question, 'id'); $questionRecord = get_records('question_' . $questionType . 'wiris', 'question', $question, 'id'); $questions = array(); $status = true; if ($questionRecord !== false) { foreach($questionRecord as $quest){ $questions[$quest->question]->options = unserialize($quest->options); } } if ($questionType == 'shortanswer') { if ($questionRecord !== false) { foreach ($questionRecord as $quest) { $questions[$quest->question]->eqoption = $quest->eqoption; } } //This is what does the parent (/question/questiontype.php) class, //but in the shortanswer case we cannot call the parent because //the tag name is the same ("<SHORTANSWERWIRIS>"). $record = get_record('question_shortanswer', 'question', $question); $answers = $record->answers; $usecase = $record->usecase; }else if ($questionType == 'truefalse' || $questionType == 'multichoice') { if ($questionRecord !== false) { foreach ($questionRecord as $quest) { $questions[$quest->question]->override = $quest->override; } } } if ($problemRecord !== false) { foreach ($problemRecord as $quest) { $questions[$quest->question]->program = $quest->program; } } $tagname = strtoupper($questionType) . 'WIRIS'; foreach ($questions as $q) { $status = fwrite($bf, start_tag($tagname, $level, true)); if (!empty($q->program)) { $programParsed = wrsqz_mathmlEncode($q->program); $levelUp = $level + 1; $status = fwrite($bf, full_tag('WIRISPROGRAM', $levelUp, false, $programParsed)) && $status; if ($questionType == 'truefalse' || $questionType == 'multichoice') { $status = fwrite($bf, full_tag('WIRISOVERRIDEANSWER', $levelUp, false, $q->override)); }else if ($questionType == 'shortanswer') { $status = fwrite($bf, full_tag('WIRISEDITOR', $levelUp, false, $q->eqoption)) && $status; }else if ($questionType == 'multianswer') { //TODO //$status = fwrite($bf, full_tag('WIRISEDITOR', $levelUp, false, $q->eqoption)) && $status; } $status = fwrite($bf, start_tag('WIRISOPTIONS', $levelUp, true))&& $status; foreach($q->options as $key=>$value){ if($key == 'hiddenInitialCASValue') $value = wrsqz_mathmlEncode($value); $status = fwrite($bf, full_tag($key, $levelUp+1, false, print_r($value, true))) && $status; } $status = fwrite($bf, end_tag('WIRISOPTIONS', $levelUp, true)) && $status; } $status = fwrite($bf, end_tag($tagname, $level, true)) && $status; if ($questionType == 'shortanswer'){ //this is done by the parent class in the other questiontypes $status = fwrite($bf, start_tag('SHORTANSWER', $level, true)) && $status; $status = fwrite($bf, full_tag('ANSWERS', $levelUp, false, $answers)) && $status; $status = fwrite($bf, full_tag('USECASE', $levelUp, false, $usecase)) && $status; $status = fwrite($bf, end_tag('SHORTANSWER', $level, true)) && $status; $status = question_backup_answers($bf, $preferences, $question) && $status; } } return $status; }
/** * Backup the data in the question * * This is used in question/backuplib.php */ function backup($bf, $preferences, $question, $level = 6) { $status = true; $webworks = get_records('question_webwork', 'question', $question, 'id'); //If there are webworks if ($webworks) { //Print webworks header //Iterate over each webwork foreach ($webworks as $webwork) { $status = fwrite($bf, start_tag("WEBWORK", $level, true)); fwrite($bf, full_tag("CODE", $level + 1, false, $webwork->code)); fwrite($bf, full_tag("SEED", $level + 1, false, $webwork->seed)); fwrite($bf, full_tag("TRIALS", $level + 1, false, $webwork->trials)); $webworksderived = get_records('question_webwork_derived', 'question_webwork', $webwork->id); if ($webworksderived) { $status = fwrite($bf, start_tag("WEBWORKDERIVED", $level + 1, true)); foreach ($webworksderived as $webworkderived) { fwrite($bf, full_tag("ID", $level + 2, false, $webworkderived->id)); fwrite($bf, full_tag("QUESTION_WEBWORK", $level + 2, false, $webworkderived->question_webwork)); fwrite($bf, full_tag("HTML", $level + 2, false, $webworkderived->html)); fwrite($bf, full_tag("SEED", $level + 2, false, $webworkderived->seed)); } $status = fwrite($bf, end_tag("WEBWORKDERIVED", $level + 1, true)); } $status = fwrite($bf, end_tag("WEBWORK", $level, true)); } //Print webworks footer //Now print question_webwork $status = question_backup_answers($bf, $preferences, $question); } return $status; }
function backup($bf, $preferences, $question, $level = 6) { $status = true; $dragdrops = get_records("question_dragdrop", "questionid", $question, "id"); //If there are dragdrops if ($dragdrops) { //Iterate over each dragdrop foreach ($dragdrops as $dragdrop) { $status = fwrite($bf, start_tag("DRAGDROP", $level, true)); fwrite($bf, full_tag("ID", $level + 1, false, $dragdrop->id)); fwrite($bf, full_tag("QUESTIONID", $level + 1, false, $dragdrop->questionid)); fwrite($bf, full_tag("BACKGROUNDMEDIA", $level + 1, false, $dragdrop->backgroundmedia)); //fwrite ($bf,full_tag("DRAGDROPMEDIA",$level+1,false,$dragdrop->dragdropmedia)); $medias = get_records_list("question_dragdrop_media", "id", $dragdrop->dragdropmedia, "id"); if ($medias) { $status = $status && fwrite($bf, start_tag("DRAGDROPMEDIAS", $level + 1, true)); //Iterate over each dragdrop foreach ($medias as $media) { $status = fwrite($bf, start_tag("DRAGDROPMEDIA", $level + 2, true)); fwrite($bf, full_tag("ID", $level + 3, false, $media->id)); fwrite($bf, full_tag("QUESTIONID", $level + 3, false, $media->questionid)); fwrite($bf, full_tag("QUESTIONTEXT", $level + 3, false, $media->questiontext)); fwrite($bf, full_tag("MEDIA", $level + 3, false, $media->media)); fwrite($bf, full_tag("ALT", $level + 3, false, $media->alt)); fwrite($bf, full_tag("WIDTH", $level + 3, false, $media->width)); fwrite($bf, full_tag("HEIGHT", $level + 3, false, $media->height)); fwrite($bf, full_tag("MIMETYPE", $level + 3, false, $media->mimetype)); fwrite($bf, full_tag("TARGETX", $level + 3, false, $media->targetx)); fwrite($bf, full_tag("TARGETY", $level + 3, false, $media->targety)); fwrite($bf, full_tag("DISPLAYWIDTH", $level + 3, false, $media->displaywidth)); fwrite($bf, full_tag("DISPLAYHEIGHT", $level + 3, false, $media->displayheight)); fwrite($bf, full_tag("POSITIONED", $level + 3, false, $media->positioned)); //fwrite ($bf,full_tag("HOTSPOTS",$level+3,false,$media->hotspots)); //each media has one hotspot at least $hotspots = get_records_list('question_dragdrop_hotspot', 'id', $media->hotspots); $status = $status && fwrite($bf, start_tag("HOTSPOTS", $level + 3, true)); foreach ($hotspots as $hotspot) { $status = $status && fwrite($bf, start_tag("HOTSPOT", $level + 4, true)); fwrite($bf, full_tag("ID", $level + 4, false, $hotspot->id)); fwrite($bf, full_tag("QUESTIONID", $level + 4, false, $hotspot->questionid)); fwrite($bf, full_tag("X", $level + 4, false, $hotspot->x)); fwrite($bf, full_tag("Y", $level + 4, false, $hotspot->y)); fwrite($bf, full_tag("WIDTH", $level + 4, false, $hotspot->width)); fwrite($bf, full_tag("HEIGHT", $level + 4, false, $hotspot->height)); $status = $status && fwrite($bf, end_tag("HOTSPOT", $level + 2, true)); } $status = $status && fwrite($bf, end_tag("HOTSPOTS", $level + 3, true)); fwrite($bf, full_tag("PRIMARY_HOTSPOT", $level + 3, false, $media->primary_hotspot)); $status = fwrite($bf, end_tag("DRAGDROPMEDIA", $level + 2, true)); } $status = $status && fwrite($bf, end_tag("DRAGDROPMEDIAS", $level + 1, true)); } fwrite($bf, full_tag("FREESTYLE", $level + 1, false, $dragdrop->freestyle)); fwrite($bf, full_tag("FEEDBACKFRACTION", $level + 1, false, $dragdrop->feedbackfraction)); fwrite($bf, full_tag("FEEDBACKOK", $level + 1, false, $dragdrop->feedbackok)); fwrite($bf, full_tag("FEEDBACKMISSED", $level + 1, false, $dragdrop->feedbackmissed)); fwrite($bf, full_tag("ARRANGEMEDIA", $level + 1, false, $dragdrop->arrangemedia)); fwrite($bf, full_tag("PLACEMEDIA", $level + 1, false, $dragdrop->placemedia)); //Print dragdrop contents //first the backgroundmedia $status = $status && fwrite($bf, start_tag("BACKGROUND", $level + 1, true)); $backgroundmedia = get_record("question_dragdrop_media", "id", $dragdrop->backgroundmedia); if ($backgroundmedia) { fwrite($bf, full_tag("ID", $level + 2, false, $backgroundmedia->id)); fwrite($bf, full_tag("QUESTIONID", $level + 2, false, $backgroundmedia->questionid)); fwrite($bf, full_tag("QUESTIONTEXT", $level + 2, false, $backgroundmedia->questiontext)); fwrite($bf, full_tag("MEDIA", $level + 2, false, $backgroundmedia->media)); fwrite($bf, full_tag("ALT", $level + 2, false, $backgroundmedia->alt)); fwrite($bf, full_tag("WIDTH", $level + 2, false, $backgroundmedia->width)); fwrite($bf, full_tag("HEIGHT", $level + 2, false, $backgroundmedia->height)); fwrite($bf, full_tag("MIMETYPE", $level + 2, false, $backgroundmedia->mimetype)); } $status = $status && fwrite($bf, end_tag("BACKGROUND", $level + 1, true)); $status = $status && fwrite($bf, end_tag("DRAGDROP", $level, true)); } //Now print question_answers $status = question_backup_answers($bf, $preferences, $question); } return $status; }