$questionScore = Display::tag('div', $objQuestionTmp->selectWeighting(), array('style' => $styleScore));
                echo '<div id="question_id_list_' . $id . '" >';
                echo '<div class="header_operations">';
                echo $questionName;
                echo $questionType;
                echo $questionCategory;
                echo $questionLevel;
                echo $questionScore;
                echo $actions;
                echo '</div>';
                echo '<div class="question-list-description-block">';
                echo '<p>';
                //echo get_lang($question_class.$label);
                echo get_lang($question_class);
                echo '<br />';
                //echo get_lang('Level').': '.$objQuestionTmp->selectLevel();
                echo '<br />';
                showQuestion($id, false, null, null, false, true, false, true, $objExercise->feedback_type, true);
                echo '</p>';
                echo '</div>';
                echo '</div>';
                unset($objQuestionTmp);
            }
        }
    }
    if (!$nbrQuestions) {
        echo Display::display_warning_message(get_lang('NoQuestion'));
    }
    echo '</div>';
    //question list div
}
Ejemplo n.º 2
0
Green Check Mark:<img src='./images/check.png' />    Correct<br>
Red Cross Mark:<img src='./images/ex.jpg' />    Incorrect (try again)<br>
Question Mark:<img src='./images/questicon.png' />    Some letters need an accent mark<br></p>

</div></center>
<center>
<input type='button' value='Check Your Answers'  onClick='changeimages();' />
<input type='button' value='Restart'  onClick='clearall();' />
</center>
<p>

<div class='hidddenbox' >
<?php 
if ($qtype == "oneline") {
    for ($i = 0; $i < sizeof($questions); $i++) {
        echo showQuestion($i, $questions[$i][0], $questions[$i][1], $questions[$i][2]);
    }
} else {
    if ($qtype == "twoline") {
        for ($i = 0; $i < sizeof($questions); $i++) {
            echo showQuestionPair($i, $questions[$i][0], $questions[$i][1], $questions[$i][2], $questions[$i][3], $questions[$i][4], $questions[$i][5]);
        }
    }
}
?>
	
</div>	
	
	
	
</section>
Ejemplo n.º 3
0
                $objQuestionTmp->read($questionId);
                $questionName = $objQuestionTmp->selectTitle();
                // destruction of the Question object
                unset($objQuestionTmp);
                echo '<div class\\"alert1\\" ' . $langAlreadyAnswered . ' &quot;' . q($questionName) . '&quot;</div>';
                break;
            }
        }
    }
    // shows the question and its answers
    echo "<table width=\"100%\" class=\"tbl\">\n          <tr class='sub_title1'>\n            <td colspan=\"2\">" . $langQuestion . ": " . $i;
    if ($exerciseType == 2) {
        echo "/" . $nbrQuestions;
    }
    echo "</td></tr>";
    showQuestion($questionId);
    echo "<tr><td colspan=\"2\">&nbsp;</td></tr></table>";
    // for sequential exercises
    if ($exerciseType == 2) {
        // quits the loop
        break;
    }
}
// end foreach()
if (!$questionList) {
    echo "\n      <table width=\"100%\">\n      <tr>\n        <td colspan='2'>\n          <div class='alert alert-danger'>{$langNoAnswer}</div>\n        </td>\n      </tr>\n      </table>";
} else {
    echo "<br/><table width='100%' class='tbl'><tr>\n               <td><div class='right'><input class='btn btn-primary' type='submit' value=\"";
    if ($exerciseType == 1 || $nbrQuestions == $questionNum) {
        echo "{$langCont}\" />&nbsp;";
    } else {
Ejemplo n.º 4
0
        // if it is not the right question, goes to the next loop iteration
        if (isset($exerciseResult)) {
            $answered_question_ids = array_keys($exerciseResult);
        } else {
            $answered_question_ids = array();
        }      
        if (in_array($questionId, $answered_question_ids)) {
            continue;
        } 
    }

    // shows the question and its answers
    $question = new Question();
    $question->read($questionId);
 
    showQuestion($question, $exerciseResult);

    $tool_content .= "<br>";
    // for sequential exercises
    if ($exerciseType == 2) {
        // quits the loop
        break;
    }
} // end foreach()

if (!$questionList) {
    $tool_content .= "
            <div class='alert alert-warning'>$langNoQuestion</div>
            <div class='pull-right'>
                <a href='index.php?course=$course_code' class='btn btn-default'>$langBack</a>
            </div>";
/**
 * This function exports the given Chamilo test
 * @param	integer	Test ID
 * @return string 	The test itself as an HTML string
 */
function export_exercise($item_id) {

    global $expdir, $_course, $_configuration, $_SESSION, $_SERVER, $language_interface, $langExerciseNotFound, $langQuestion, $langOk, $origin, $questionNum;

    $exerciseId = $item_id;

    require_once '../exercice/testcategory.class.php';
    require_once '../exercice/exercise.class.php';
    require_once '../exercice/question.class.php';
    require_once '../exercice/answer.class.php';
    require_once '../exercice/exercise.lib.php';

    $TBL_EXERCISES = Database :: get_course_table(TABLE_QUIZ_TEST);

    /* Clears the exercise session */
    if (isset ($_SESSION['objExercise'])) {
        Session::erase('objExercise');
    }
    if (isset ($_SESSION['objQuestion'])) {
        Session::erase('objQuestion');
    }
    if (isset ($_SESSION['objAnswer'])) {
        Session::erase('objAnswer');
    }
    if (isset ($_SESSION['questionList'])) {
        Session::erase('questionList');
    }
    if (isset ($_SESSION['exerciseResult'])) {
        Session::erase('exerciseResult');
    }

    // If the object is not in the session:
    if (!isset ($_SESSION['objExercise'])) {
        // Construction of Exercise.
        $objExercise = new Exercise();

        $sql = "SELECT title,description,sound,type,random,active FROM $TBL_EXERCISES WHERE id='$exerciseId'";
        // If the specified exercise doesn't exist or is disabled:
        if (!$objExercise->read($exerciseId) || (!$objExercise->selectStatus() && !api_is_allowed_to_edit() && ($origin != 'learnpath'))) {
            die($langExerciseNotFound);
        }

        // Saves the object into the session.
        Session::write('objExercise',$objExercise);
    }

    $exerciseTitle = $objExercise->selectTitle();
    $exerciseDescription = $objExercise->selectDescription();
    $exerciseSound = $objExercise->selectSound();
    $randomQuestions = $objExercise->isRandom();
    $exerciseType = $objExercise->selectType();

    if (!isset ($_SESSION['questionList'])) {
        // Selects the list of question ID.
        $questionList = $randomQuestions ? $objExercise->selectRandomList() : $objExercise->selectQuestionList();

        // Saves the question list into the session.
        Session::write('questionList',$questionList);
    }

    $nbrQuestions = sizeof($questionList);

    // If questionNum comes from POST and not from GET:
    if (!$questionNum || $_POST['questionNum']) {
        // Only used for sequential exercises (see $exerciseType).
        if (!$questionNum) {
            $questionNum = 1;
        } else {
            $questionNum ++;
        }
    }

    $exerciseTitle = text_filter($exerciseTitle);

    $test .= "<h3>".$exerciseTitle."</h3>";

    if (!empty ($exerciseSound)) {
        $test .= "<a href=\"../document/download.php?doc_url=%2Faudio%2F".$exerciseSound."\"&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9 target=\"_blank\"><img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=".get_lang("Sound")."\" /></a>";
    }

    $exerciseDescription = text_filter($exerciseDescription);

    // Writing the .js file with to check the correct answers begin.
    $scriptfilename = "Exercice".$item_id.".js";
    $s = "<script type=\"text/javascript\" src='../js/".$scriptfilename."'></script>";
    $test .= $s;

    $content = "function evaluate() {
        alert('Test evaluated.');
        }
        ";

    if (!$handle = fopen($expdir.'/js/'.$scriptfilename, 'w')) {
        echo "Cannot open file ($scriptfilename)";
    }
    if (fwrite($handle, $content) === false) {
        echo "Cannot write to file ($filename)";
        exit;
    }
    fclose($handle);

    // Writing the .js file with to check the correct answers end.
    $s = "
        <p>$exerciseDescription</p>
        <table width='100%' border='0' cellpadding='1' cellspacing='0'>
         <form method='post' action=''><input type=\"hidden\" name=\"SQMSESSID\" value=\"36812c2dea7d8d6e708d5e6a2f09b0b9\" />
         <input type='hidden' name='formSent' value='1' />
         <input type='hidden' name='exerciseType' value='".$exerciseType."' />
         <input type='hidden' name='questionNum' value='".$questionNum."' />
         <input type='hidden' name='nbrQuestions' value='".$nbrQuestions."' />
         <tr>
          <td>
          <table width='100%' cellpadding='4' cellspacing='2' border='0'>";

    $test .= $s;

    $i = 0;

    foreach ($questionList as $questionId) {
        $i ++;

        echo $s = "<tr bgcolor='#e6e6e6'><td valign='top' colspan='2'>".get_lang('Question')." ";
        // Call the showQuestion() function from exercise.lib.php. This basically displays the question in a table.
        $test .= showQuestion($questionId, false, 'export', $i);

    } // end foreach()

    $s = "</table></td></tr><tr><td><br/><input type='button' value='".$langOk."' onclick=\"javascript: evaluate(); alert('Evaluated.');\">";
    $s .= "</td></tr></form></table>";
    $s .= "<script type='text/javascript'> loadPage(); </script>";
    $b = 2;
    $test .= $s;
    return ($test);
}
Ejemplo n.º 6
0
 if ($objExercise->type == ALL_ON_ONE_PAGE && isset($_GET['reminder']) && $_GET['reminder'] == 2) {
     $remind_highlight = 'no_remind_highlight';
 }
 $exercise_actions = '';
 $is_remind_on = false;
 $attributes = array('id' => 'remind_list[' . $questionId . ']');
 if (in_array($questionId, $remind_list)) {
     $is_remind_on = true;
     $attributes['checked'] = 1;
     $remind_question = true;
     $remind_highlight = ' remind_highlight ';
 }
 // Showing the question
 echo '<div id="question_div_' . $questionId . '" class="main_question ' . $remind_highlight . '" >';
 // Shows the question and its answers
 showQuestion($questionId, false, $origin, $i, true, false, $user_choice, false);
 // Button save and continue
 switch ($objExercise->type) {
     case ONE_PER_PAGE:
         $exercise_actions .= $objExercise->show_button($questionId, $current_question);
         break;
     case ALL_ON_ONE_PAGE:
         $button = '<a href="javascript://" class="btn" onclick="save_now(\'' . $questionId . '\'); ">' . get_lang('SaveForNow') . '</a>';
         $button .= '<span id="save_for_now_' . $questionId . '"></span>&nbsp;';
         $exercise_actions .= Display::div($button, array('class' => 'exercise_save_now_button'));
         break;
 }
 // Checkbox review answers
 if ($objExercise->review_answers) {
     $remind_question_div = Display::tag('label', Display::input('checkbox', 'remind_list[' . $questionId . ']', '', $attributes) . get_lang('ReviewQuestionLater'), array('class' => 'checkbox', 'for' => 'remind_list[' . $questionId . ']'));
     $exercise_actions .= Display::div($remind_question_div, array('class' => 'exercise_save_now_button'));