Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME

Quiz - A Quiz engine

VERSION

Version 0.01-TRIAL

SYNOPSIS

Most basic interface

my $quiz = create_quiz('Quiz1', 'question1' => 'answer1', 'question2' => 'answer2');

my %item = next_question('Quiz1');

print $item{question} . "\n";

my %res = respond_question($item{item_id}, 'response');

print ($res{grade} ? 'Correct answer.' : 'Wrong!');

See statistics on your responses

get_average_grade();
get_average_grade(item_id => $item_id);
get_average_grade(quiz => 'quiz');

See all quizzes

my @quizzes = get_quizzes();

See all quizzes containing the word 'Lesson'

my @quizzes = get_quizzes('Lesson');

Rename a Quiz

rename_quiz($old_name, $new_name);

Delete a Quiz

delete_quiz($quiz_name);

See all items in a quiz

my @items = get_items(quiz => 'Name');

See all items

my @items = get_items();

See all items whose question contains the word 'language'

my @items = get_item(question => 'language');

See all items whose answer contains the word 'Perl'

my @items = get_item(answer => 'Perl');

Remove an item from the quiz

remove_item_from_quiz('Quiz name', $item_id);

Modify an item

edit_item_question($item_id, 'new question');
edit_item_answer($item_id, 'new answer');

Delete an item

delete_item($item_id);

Run a quiz session to be asked all questions

my $session = session_start_quiz("Quiz1");
while (my $question =  session_next_question($session)) {
    my $answer = <STDIN>;
    my $item = session_respond_question($answer, $session);
}
print session_results($session);

List existing sessions

get_sessions();

List existing sessions for a quiz

get_sessions('Quiz name');

Get the session creation time

session_creation_time($session_id)

Create an item (without association to a quiz)

my $item_id = create_item('question', 'answer');

Reuse a question in a quiz

add_item_to_quiz($quiz, $item_id);

Order the items in a quiz

set_quiz_items_rank($quiz, $first_item_id, $second_item_id, $third_item_id);

Delete results for an item

delete_item_results()

Reset all results

delete_all_results()

Clean up old results

cleanup_old_results();

Clean up old sessions

cleanup_old_sessions();

INSTALLATION

Use Carton or find the list of modules to install in the file cpanfile.

$ carton install

Install sqlite3.

The default database will be in the file ./dbquiz.sqlite .

TEST

$ carton exec prove -I.

CAVEAT

This library is not made for handling a large dataset. If you handle a great number of quizzes, use subroutines that operate only on a single quiz (which is not expected to be very big).

There is not account system, any call can modify any data. Build your own account system on top if needed.

This library has not been designed for thread safety.

About

Prof - a basic quiz engine

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages