[Catalyst-commits] r7329 - in trunk/examples: . Quiz Quiz/lib
Quiz/lib/Ctca Quiz/lib/Fitb Quiz/lib/Quiz
Quiz/lib/Quiz/Controller Quiz/lib/Quiz/Model
Quiz/lib/Quiz/View Quiz/lib/QuizMaster Quiz/root
Quiz/root/lib Quiz/root/lib/config Quiz/root/lib/site
Quiz/root/src Quiz/root/src/Ctca Quiz/root/src/quiz
Quiz/root/static Quiz/root/static/images Quiz/script Quiz/t
solar at dev.catalyst.perl.org
solar at dev.catalyst.perl.org
Sun Dec 23 17:54:21 GMT 2007
Author: solar
Date: 2007-12-23 17:54:21 +0000 (Sun, 23 Dec 2007)
New Revision: 7329
Added:
trunk/examples/Quiz/
trunk/examples/Quiz/Changes
trunk/examples/Quiz/Makefile.PL
trunk/examples/Quiz/README
trunk/examples/Quiz/ctca.db
trunk/examples/Quiz/ctca.sql
trunk/examples/Quiz/fitb.db
trunk/examples/Quiz/lib/
trunk/examples/Quiz/lib/Ctca.pm
trunk/examples/Quiz/lib/Ctca/
trunk/examples/Quiz/lib/Ctca/CtcaChoices.pm
trunk/examples/Quiz/lib/Ctca/CtcaQuestions.pm
trunk/examples/Quiz/lib/Fitb.pm
trunk/examples/Quiz/lib/Fitb/
trunk/examples/Quiz/lib/Fitb/FitbQuestions.pm
trunk/examples/Quiz/lib/Quiz.pm
trunk/examples/Quiz/lib/Quiz/
trunk/examples/Quiz/lib/Quiz/Controller/
trunk/examples/Quiz/lib/Quiz/Controller/Ctca.pm
trunk/examples/Quiz/lib/Quiz/Controller/Fitb.pm
trunk/examples/Quiz/lib/Quiz/Controller/Root.pm
trunk/examples/Quiz/lib/Quiz/Controller/quiz.pm
trunk/examples/Quiz/lib/Quiz/Model/
trunk/examples/Quiz/lib/Quiz/Model/Ctca.pm
trunk/examples/Quiz/lib/Quiz/Model/Fitb.pm
trunk/examples/Quiz/lib/Quiz/Model/QuizMaster.pm
trunk/examples/Quiz/lib/Quiz/View/
trunk/examples/Quiz/lib/Quiz/View/Quiz.pm
trunk/examples/Quiz/lib/QuizMaster.pm
trunk/examples/Quiz/lib/QuizMaster/
trunk/examples/Quiz/lib/QuizMaster/Modules.pm
trunk/examples/Quiz/lib/QuizMaster/Participants.pm
trunk/examples/Quiz/lib/QuizMaster/QuizModules.pm
trunk/examples/Quiz/lib/QuizMaster/Quizzes.pm
trunk/examples/Quiz/quiz.db
trunk/examples/Quiz/quiz.sql
trunk/examples/Quiz/quiz.yml
trunk/examples/Quiz/root/
trunk/examples/Quiz/root/favicon.ico
trunk/examples/Quiz/root/lib/
trunk/examples/Quiz/root/lib/config/
trunk/examples/Quiz/root/lib/config/col
trunk/examples/Quiz/root/lib/config/main
trunk/examples/Quiz/root/lib/config/url
trunk/examples/Quiz/root/lib/site/
trunk/examples/Quiz/root/lib/site/footer
trunk/examples/Quiz/root/lib/site/header
trunk/examples/Quiz/root/lib/site/html
trunk/examples/Quiz/root/lib/site/layout
trunk/examples/Quiz/root/lib/site/wrapper
trunk/examples/Quiz/root/src/
trunk/examples/Quiz/root/src/Ctca/
trunk/examples/Quiz/root/src/Ctca/index.tt2
trunk/examples/Quiz/root/src/error.tt2
trunk/examples/Quiz/root/src/message.tt2
trunk/examples/Quiz/root/src/quiz/
trunk/examples/Quiz/root/src/quiz/begin.tt2
trunk/examples/Quiz/root/src/quiz/create
trunk/examples/Quiz/root/src/quiz/finish
trunk/examples/Quiz/root/src/quiz/index.tt2
trunk/examples/Quiz/root/src/quiz/start
trunk/examples/Quiz/root/src/ttsite.css
trunk/examples/Quiz/root/src/welcome.tt2
trunk/examples/Quiz/root/static/
trunk/examples/Quiz/root/static/images/
trunk/examples/Quiz/root/static/images/btn_120x50_built.png
trunk/examples/Quiz/root/static/images/btn_120x50_built_shadow.png
trunk/examples/Quiz/root/static/images/btn_120x50_powered.png
trunk/examples/Quiz/root/static/images/btn_120x50_powered_shadow.png
trunk/examples/Quiz/root/static/images/btn_88x31_built.png
trunk/examples/Quiz/root/static/images/btn_88x31_built_shadow.png
trunk/examples/Quiz/root/static/images/btn_88x31_powered.png
trunk/examples/Quiz/root/static/images/btn_88x31_powered_shadow.png
trunk/examples/Quiz/root/static/images/catalyst_logo.png
trunk/examples/Quiz/script/
trunk/examples/Quiz/script/quiz_cgi.pl
trunk/examples/Quiz/script/quiz_create.pl
trunk/examples/Quiz/script/quiz_fastcgi.pl
trunk/examples/Quiz/script/quiz_server.pl
trunk/examples/Quiz/script/quiz_test.pl
trunk/examples/Quiz/t/
trunk/examples/Quiz/t/01app.t
trunk/examples/Quiz/t/02pod.t
trunk/examples/Quiz/t/03podcoverage.t
trunk/examples/Quiz/t/controller_Ctca-Ctca.t
trunk/examples/Quiz/t/controller_quiz.t
trunk/examples/Quiz/t/model_Ctca.t
trunk/examples/Quiz/t/model_Fitb.t
trunk/examples/Quiz/t/model_Quiz.t
Log:
Quiz without deployment feature yet
Added: trunk/examples/Quiz/Changes
===================================================================
--- trunk/examples/Quiz/Changes (rev 0)
+++ trunk/examples/Quiz/Changes 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,4 @@
+This file documents the revision history for Perl extension Quiz.
+
+0.01 2007-12-21 23:21:10
+ - initial revision, generated by Catalyst
Added: trunk/examples/Quiz/Makefile.PL
===================================================================
--- trunk/examples/Quiz/Makefile.PL (rev 0)
+++ trunk/examples/Quiz/Makefile.PL 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,16 @@
+use inc::Module::Install;
+
+name 'Quiz';
+all_from 'lib/Quiz.pm';
+
+requires 'Catalyst::Runtime' => '5.7011';
+requires 'Catalyst::Plugin::ConfigLoader';
+requires 'Catalyst::Plugin::Static::Simple';
+requires 'Catalyst::Action::RenderView';
+requires 'YAML'; # This should reflect the config file format you've chosen
+ # See Catalyst::Plugin::ConfigLoader for supported formats
+catalyst;
+
+install_script glob('script/*.pl');
+auto_install;
+WriteAll;
Added: trunk/examples/Quiz/README
===================================================================
--- trunk/examples/Quiz/README (rev 0)
+++ trunk/examples/Quiz/README 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1 @@
+Run script/quiz_server.pl to test the application.
Added: trunk/examples/Quiz/ctca.db
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/ctca.db
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/ctca.sql
===================================================================
--- trunk/examples/Quiz/ctca.sql (rev 0)
+++ trunk/examples/Quiz/ctca.sql 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,13 @@
+CREATE TABLE ctca_questions(
+ id INTEGER PRIMARY KEY ,
+ question TEXT,
+ correct INTEGER
+);
+
+CREATE TABLE ctca_choices(
+ id INTEGER PRIMARY KEY ,
+ choices TEXT,
+ question INTEGER
+);
+
+
Added: trunk/examples/Quiz/fitb.db
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/fitb.db
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/lib/Ctca/CtcaChoices.pm
===================================================================
--- trunk/examples/Quiz/lib/Ctca/CtcaChoices.pm (rev 0)
+++ trunk/examples/Quiz/lib/Ctca/CtcaChoices.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,31 @@
+package Ctca::CtcaChoices;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("ctca_choices");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "choices",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "question",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:25:20
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3zb/nZvJvoeXo7AfYqDgFw
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+Ctca::CtcaChoices->belongs_to( 'question',
+ 'Ctca::CtcaQuestions',
+ { 'foreign.id' => 'self.question' } );
+
+
+1;
Added: trunk/examples/Quiz/lib/Ctca/CtcaQuestions.pm
===================================================================
--- trunk/examples/Quiz/lib/Ctca/CtcaQuestions.pm (rev 0)
+++ trunk/examples/Quiz/lib/Ctca/CtcaQuestions.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,35 @@
+package Ctca::CtcaQuestions;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("ctca_questions");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "question",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "correct",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:25:20
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:u+CFwhJQ1zVkEbk8v6f87g
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+Ctca::CtcaQuestions->has_many( 'options',
+ 'Ctca::CtcaChoices',
+ { 'foreign.question' => 'self.id' } );
+
+
+1;
+
+
+
Added: trunk/examples/Quiz/lib/Ctca.pm
===================================================================
--- trunk/examples/Quiz/lib/Ctca.pm (rev 0)
+++ trunk/examples/Quiz/lib/Ctca.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,16 @@
+package Ctca;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes;
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:24:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6gIndGXaCkhWg74KnmpWRA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
Added: trunk/examples/Quiz/lib/Fitb/FitbQuestions.pm
===================================================================
--- trunk/examples/Quiz/lib/Fitb/FitbQuestions.pm (rev 0)
+++ trunk/examples/Quiz/lib/Fitb/FitbQuestions.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,22 @@
+package Fitb::FitbQuestions;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("fitb_questions");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-23 22:38:59
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B0C05oIfLoQSg43hEX5/Sw
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
Added: trunk/examples/Quiz/lib/Fitb.pm
===================================================================
--- trunk/examples/Quiz/lib/Fitb.pm (rev 0)
+++ trunk/examples/Quiz/lib/Fitb.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,16 @@
+package Fitb;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes;
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-23 22:38:59
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XZ2FBCSk0YmYbm7bxZb1jw
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
Added: trunk/examples/Quiz/lib/Quiz/Controller/Ctca.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/Controller/Ctca.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/Controller/Ctca.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,47 @@
+package Quiz::Controller::Ctca;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+=head1 NAME
+
+Quiz::Controller::Ctca - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 show
+
+=cut
+
+sub index : PathPart('Ctca') Chained('/quiz/process') Args(1) {
+ my ( $self, $c , $questionid ) = @_;
+ my $question = $c->model('Ctca::CtcaQuestions')->search({id=>$questionid})->first;
+ $c->stash->{question} = $question;
+
+ $c->stash->{options}= [$question->search_related('options',question=>$questionid)->all];
+ $c->session->{quiz}->{answer} = {choice => $question->correct};
+ $c->stash->{template} = 'Ctca/index.tt2';
+
+}
+
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/Quiz/Controller/Fitb.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/Controller/Fitb.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/Controller/Fitb.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,42 @@
+package Quiz::Controller::Fitb;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+=head1 NAME
+
+Quiz::Controller::Ctca - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 show
+
+=cut
+
+sub index : PathPart('Fitb') Chained('/quiz/process') Args(1) {
+ my ( $self, $c , $questionid ) = @_;
+ $c->response->body('This is Just a sample module . If you have reached here after answering 1 or more question from the previous module.It demonstrates how the quiz controller handles the flow of question between modules');
+
+}
+
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/Quiz/Controller/Root.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/Controller/Root.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/Controller/Root.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,56 @@
+package Quiz::Controller::Root;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+#
+# Sets the actions in this controller to be registered with no prefix
+# so they function identically to actions created in MyApp.pm
+#
+__PACKAGE__->config->{namespace} = '';
+
+=head1 NAME
+
+Quiz::Controller::Root - Root Controller for Quiz
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 METHODS
+
+=cut
+
+=head2 default
+
+=cut
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+
+ # Hello World
+ #$c->response->body( $c->welcome_message );
+ $c->response->redirect($c->uri_for('/quiz'));
+}
+
+=head2 end
+
+Attempt to render a view, if needed.
+
+=cut
+
+sub end : ActionClass('RenderView') {}
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/Quiz/Controller/quiz.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/Controller/quiz.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/Controller/quiz.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,293 @@
+
+package Quiz::Controller::quiz;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+
+=head1 NAME
+
+Quiz::Controller::quiz - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+=cut
+
+sub index : Private
+ {
+ my ( $self, $c ) = @_;
+ $c->stash->{quizlist} = [$c->model('QuizMaster::Quizzes')->all];
+
+
+ $c->stash->{template}='quiz/index.tt2'
+
+}
+
+sub create : Local
+ {
+ my ( $self, $c ) = @_;
+
+ my $modulelist = [$c->model('QuizMaster::Modules')->all];
+ $c->stash->{modules} = $modulelist;
+
+ if ($c->request->param('submit')) {
+ my $name = $c->request->param('name');
+ my $quiz = $c->model('QuizMaster::Quizzes')->create({
+ name => $name,
+ });
+
+ my $modules =[$c->request->param('modules')];
+ my $noq =[$c->request->param('noq')];
+
+
+ foreach my $module (@{$modules}) {
+
+
+
+ my $modulename = $modulelist->[$module-1]->name;
+
+
+ my @questions = $c->model($modulename.'::'.$modulename.'Questions')->all;
+ my $tnoq = $#questions + 1;
+
+ $noq->[$module-1] = $tnoq if $noq->[$module-1] > $tnoq;
+ my $selectquest = " ";
+
+ for (my $j=0 ; $j < $noq->[$module-1] ; $j++) {
+ my $rand ;
+
+
+ $rand = (int(rand($noq->[$module-1]))+1);
+
+
+ # Avoid Duplication of questions
+ while ( $selectquest && ($selectquest =~ /\s$rand\s/) ) {
+ $rand = (int(rand($noq->[$module-1]))+1) ;
+
+
+ }
+
+
+
+ $selectquest.=$rand.' ';
+
+
+ }
+ $quiz->add_to_quizmodules({questions => $selectquest,module=>$module});
+
+ }
+
+
+ }
+
+
+
+
+
+}
+
+
+sub deploy : Local
+ {
+ my ($self,$c,$quizid) = @_;
+ #code to slice db
+
+
+
+ #system("/home/John/Desktop/Quiz/deploy.sh");
+
+ $c->response->body('This portion will be completed and updated this week');
+
+ }
+
+
+
+sub start : Local
+ {
+
+ # This function initializes the quiz by loading the details of the module and the questions of each module for the quiz into the session.
+
+ my ($self,$c,$quizid) = @_;
+
+ if ($c->request->param('name')) {
+
+ my $quiz = $c->model('QuizMaster::Quizzes')->search({id=>$quizid})->first;
+ my $modules = [$quiz->search_related('quizmodules',{quiz=>$quizid})->all];
+ $c->session->{quiz}={participant=>$c->request->param('name'),name=>$quiz->name};
+ my $moduledata;
+
+ foreach my $module (@{$modules}) {
+
+
+ push @{$moduledata} , { id => $module->id , name=>$module->module->name, questions => [split ' ',$module->questions] };
+
+ }
+ $c->log->debug('Module data'.$moduledata->[0]->{name});
+
+ $c->session->{quiz}->{modquestions}=$moduledata;
+
+ #set up counter for the questions and modules
+ $c->session->{quiz}->{modindex}=0;
+ $c->session->{quiz}->{qindex}=0;
+
+ #set score and total score as 0
+ $c->session->{quiz}->{score} = 0;
+ $c->session->{quiz}->{tscore} = 0;
+
+ $c->log->debug('Forwarding to process') ;
+ $c->stash->{newurl} = "/quiz/process/$quizid/$moduledata->[0]->{name}/$moduledata->[0]->{questions}->[0]";
+ $c->stash->{template} = 'quiz/begin.tt2';
+
+ }
+
+
+}
+
+
+
+
+
+sub process : PathPart('quiz/process') Chained('/') CaptureArgs(1) {
+
+ my ($self,$c,$quizid) = @_;
+
+
+ # This controller does two things .
+ # 1.It does scoring for the previously answered question
+ # 2.Set the action path for the next question to be used by the module displaying the current question in the form
+
+
+ #Scoring
+ $c->log->debug($c->request->method);
+
+ if ($c->request->method =~ /POST/) {
+ $c->log->debug('Entered here');
+
+ # To make sure we don't evaluate a non existing previous answer when displaying the first question
+ if ($c->session->{quiz}->{answer}) {
+ my $flag= 1;
+
+
+
+
+ foreach (keys %{$c->session->{quiz}->{answer}}) {
+ if ($c->session->{quiz}->{answer}->{$_} != $c->request->param($_) ) {
+ $flag = 0;
+
+ }
+ }
+
+ # The score per question is taken as 10 here . It can also be set to take a value from the sessions in which case the modules can assign different marks to each question
+ my $spq = 10;
+
+ $c->session->{quiz}->{score} += ($flag * $spq);
+ $c->session->{quiz}->{tscore} += $spq;
+ $c->log->debug($c->session->{quiz}->{score});
+
+
+ }
+
+ }
+
+
+ #Determine the action path
+
+
+ my $modindex = $c->session->{quiz}->{modindex};
+ my $qindex = $c->session->{quiz}->{qindex};
+
+ #check that the current question is not the last question of the module
+ if ( $qindex != $#{$c->session->{quiz}->{modquestions}->[$modindex]->{questions}}) {
+
+
+ $c->session->{quiz}->{qindex} += 1;
+ $qindex ++;
+
+ # generate /quiz/process/quizid/modulename/questionid
+ my $modulename = $c->session->{quiz}->{modquestions}->[$modindex]->{name};
+ my $questionid = int($c->session->{quiz}->{modquestions}->[$modindex]->{questions}->[$qindex]);
+
+ $c->stash->{postaction}="/quiz/process/$quizid/$modulename/$questionid";
+
+ } else {
+ #if it is the last question , check that the current module is not the last module
+ if ($modindex != $#{$c->session->{quiz}->{modquestions}}) {
+ $qindex = $c->session->{quiz}->{qindex} = 0;
+ $c->session->{quiz}->{modindex} += 1;
+ $modindex ++;
+ my $modulename = $c->session->{quiz}->{modquestions}->[$modindex]->{name};
+ my $questionid = int($c->session->{quiz}->{modquestions}->[$modindex]->{questions}->[$qindex]);
+
+ $c->stash->{postaction}="/quiz/process/$quizid/$modulename/$questionid";
+
+
+
+ }
+
+ #if the current question is the last question of the last module set action path to the quiz finish controller
+ else {
+ $c->stash->{postaction}="/quiz/finish/$quizid";
+
+ }
+ }
+
+
+}
+
+sub finish : Local {
+
+ my ($self,$c,$quizid) = @_;
+ my $name = $c->session->{quiz}->{participant};
+
+ my $flag= 1;
+
+ foreach (keys %{$c->session->{quiz}->{answer}}) {
+ if ($c->session->{quiz}->{answer}->{$_} != $c->request->param($_) ) {
+ $flag = 0;
+
+ }
+ }
+
+ my $spq = 10;
+
+ $c->session->{quiz}->{score} += ($flag * $spq);
+ $c->session->{quiz}->{tscore} += $spq;
+
+
+ my $score = $c->session->{quiz}->{score};
+ my $tscore = $c->session->{quiz}->{tscore};
+
+ my $participant = $c->model('QuizMaster::Participants')->create({
+ name => $name,
+ quiz => $quizid,
+ score => $score,
+ totalscore => $tscore
+
+ });
+ $c->stash->{score} = "$score / $tscore";
+
+
+}
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/Quiz/Model/Ctca.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/Model/Ctca.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/Model/Ctca.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,36 @@
+package Quiz::Model::Ctca;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => 'Ctca',
+ connect_info => [
+ 'dbi:SQLite:ctca.db',
+
+ ],
+);
+
+=head1 NAME
+
+Quiz::Model::Quiz - Catalyst DBIC Schema Model
+=head1 SYNOPSIS
+
+See L<Quiz>
+
+=head1 DESCRIPTION
+
+L<Catalyst::Model::DBIC::Schema> Model using schema L<QuizMaster>
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/Quiz/Model/Fitb.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/Model/Fitb.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/Model/Fitb.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,36 @@
+package Quiz::Model::Fitb;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => 'Fitb',
+ connect_info => [
+ 'dbi:SQLite:fitb.db',
+
+ ],
+);
+
+=head1 NAME
+
+Quiz::Model::Fitb - Catalyst DBIC Schema Model
+=head1 SYNOPSIS
+
+See L<Quiz>
+
+=head1 DESCRIPTION
+
+L<Catalyst::Model::DBIC::Schema> Model using schema L<Fitb>
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/Quiz/Model/QuizMaster.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/Model/QuizMaster.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/Model/QuizMaster.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,36 @@
+package Quiz::Model::QuizMaster;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => 'QuizMaster',
+ connect_info => [
+ 'dbi:SQLite:quiz.db',
+
+ ],
+);
+
+=head1 NAME
+
+Quiz::Model::Quiz - Catalyst DBIC Schema Model
+=head1 SYNOPSIS
+
+See L<Quiz>
+
+=head1 DESCRIPTION
+
+L<Catalyst::Model::DBIC::Schema> Model using schema L<QuizMaster>
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/Quiz/View/Quiz.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz/View/Quiz.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz/View/Quiz.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,42 @@
+package Quiz::View::Quiz;
+
+use strict;
+use base 'Catalyst::View::TT';
+
+__PACKAGE__->config({
+ CATALYST_VAR => 'Catalyst',
+ INCLUDE_PATH => [
+ Quiz->path_to( 'root', 'src' ),
+ Quiz->path_to( 'root', 'lib' )
+ ],
+ PRE_PROCESS => 'config/main',
+ WRAPPER => 'site/wrapper',
+ ERROR => 'error.tt2',
+ TIMER => 0
+});
+
+=head1 NAME
+
+Quiz::View::Quiz - Catalyst TTSite View
+
+=head1 SYNOPSIS
+
+See L<Quiz>
+
+=head1 DESCRIPTION
+
+Catalyst TTSite View.
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+
Added: trunk/examples/Quiz/lib/Quiz.pm
===================================================================
--- trunk/examples/Quiz/lib/Quiz.pm (rev 0)
+++ trunk/examples/Quiz/lib/Quiz.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,70 @@
+package Quiz;
+
+use strict;
+use warnings;
+
+use Catalyst::Runtime '5.70';
+
+# Set flags and add plugins for the application
+#
+# -Debug: activates the debug mode for very useful log messages
+# ConfigLoader: will load the configuration from a YAML file in the
+# application's home directory
+# Static::Simple: will serve static files from the application's root
+# directory
+
+use Catalyst qw/
+-Debug
+ ConfigLoader
+ Static::Simple
+ Session
+ Session::State::Cookie
+ Session Session::Store::FastMmap
+ /;
+
+our $VERSION = '0.01';
+
+# Configure the application.
+#
+# Note that settings in quiz.yml (or other external
+# configuration file that you set up manually) take precedence
+# over this when using ConfigLoader. Thus configuration
+# details given here can function as a default configuration,
+# with a external configuration file acting as an override for
+# local deployment.
+
+__PACKAGE__->config( name => 'Quiz' );
+
+
+# Start the application
+__PACKAGE__->setup;
+
+
+=head1 NAME
+
+Quiz - Catalyst based application
+
+=head1 SYNOPSIS
+
+ script/quiz_server.pl
+
+=head1 DESCRIPTION
+
+[enter your description here]
+
+=head1 SEE ALSO
+
+L<Quiz::Controller::Root>, L<Catalyst>
+
+=head1 AUTHOR
+
+Antano Solar
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
Added: trunk/examples/Quiz/lib/QuizMaster/Modules.pm
===================================================================
--- trunk/examples/Quiz/lib/QuizMaster/Modules.pm (rev 0)
+++ trunk/examples/Quiz/lib/QuizMaster/Modules.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,30 @@
+package QuizMaster::Modules;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("modules");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:24:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8nVRYoTaUKlh4YlkLlcLXA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+QuizMaster::Modules->has_many( 'quizmodules',
+ 'QuizMaster::QuizModules',
+ { 'foreign.modules' => 'self.id' } );
+
+1;
Added: trunk/examples/Quiz/lib/QuizMaster/Participants.pm
===================================================================
--- trunk/examples/Quiz/lib/QuizMaster/Participants.pm (rev 0)
+++ trunk/examples/Quiz/lib/QuizMaster/Participants.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,36 @@
+package QuizMaster::Participants;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("participants");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "quiz",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "score",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "totalscore",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:24:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tWuats9APAgXYQ+qLETQXw
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+
+QuizMaster::Participants->belongs_to( 'quiz',
+ 'QuizMaster::Quizzes',
+ { 'foreign.id' => 'self.quizzes' } );
+
+1;
Added: trunk/examples/Quiz/lib/QuizMaster/QuizModules.pm
===================================================================
--- trunk/examples/Quiz/lib/QuizMaster/QuizModules.pm (rev 0)
+++ trunk/examples/Quiz/lib/QuizMaster/QuizModules.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,42 @@
+package QuizMaster::QuizModules;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("quizmodules");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "quiz",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "questions",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+ "module",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:24:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RBM0fE+XA5Cyb43LI9FVfg
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+QuizMaster::QuizModules->belongs_to( 'quiz',
+ 'QuizMaster::Quizzes',
+ { 'foreign.id' => 'self.quiz' } );
+
+QuizMaster::QuizModules->belongs_to( 'module',
+ 'QuizMaster::Modules',
+ { 'foreign.id' => 'self.module' } );
+
+
+
+1;
Added: trunk/examples/Quiz/lib/QuizMaster/Quizzes.pm
===================================================================
--- trunk/examples/Quiz/lib/QuizMaster/Quizzes.pm (rev 0)
+++ trunk/examples/Quiz/lib/QuizMaster/Quizzes.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,32 @@
+package QuizMaster::Quizzes;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("quizzes");
+__PACKAGE__->add_columns(
+ "id",
+ { data_type => "INTEGER", is_nullable => 0, size => undef },
+ "name",
+ { data_type => "TEXT", is_nullable => 0, size => undef },
+
+);
+__PACKAGE__->set_primary_key("id");
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:24:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8nVRYoTaUKlh4YlkLlcLXA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+
+
+QuizMaster::Quizzes->has_many( 'quizmodules',
+ 'QuizMaster::QuizModules',
+ { 'foreign.quiz' => 'self.id' } );
+
+1;
+
Added: trunk/examples/Quiz/lib/QuizMaster.pm
===================================================================
--- trunk/examples/Quiz/lib/QuizMaster.pm (rev 0)
+++ trunk/examples/Quiz/lib/QuizMaster.pm 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,16 @@
+package QuizMaster;
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes;
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2007-12-21 23:24:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6gIndGXaCkhWg74KnmpWRA
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
Added: trunk/examples/Quiz/quiz.db
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/quiz.db
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/quiz.sql
===================================================================
--- trunk/examples/Quiz/quiz.sql (rev 0)
+++ trunk/examples/Quiz/quiz.sql 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,27 @@
+CREATE TABLE quizzes(
+ id INTEGER PRIMARY KEY ,
+ name TEXT
+);
+
+CREATE TABLE quizmodules(
+ id INTEGER PRIMARY KEY,
+ name TEXT,
+ quiz INTEGER,
+ questions TEXT,
+ modules integer
+);
+
+CREATE TABLE modules(
+ id INTEGER PRIMARY KEY,
+ name TEXT
+);
+
+CREATE TABLE participants(
+ id INTEGER PRIMARY KEY ,
+ name TEXT,
+ quiz INTEGER ,
+ score INTEGER,
+ totalscore INTEGER
+);
+
+
Added: trunk/examples/Quiz/quiz.yml
===================================================================
--- trunk/examples/Quiz/quiz.yml (rev 0)
+++ trunk/examples/Quiz/quiz.yml 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,4 @@
+---
+name: Quiz
+
+
Added: trunk/examples/Quiz/root/favicon.ico
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/favicon.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/lib/config/col
===================================================================
--- trunk/examples/Quiz/root/lib/config/col (rev 0)
+++ trunk/examples/Quiz/root/lib/config/col 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,21 @@
+[% site.rgb = {
+ black = '#000000'
+ white = '#ffffff'
+ grey1 = '#46494c'
+ grey2 = '#c6c9cc'
+ grey3 = '#e3e6ea'
+ red = '#CC4444'
+ green = '#66AA66'
+ blue = '#89b8df'
+ orange = '#f08900'
+ };
+
+ site.col = {
+ page = site.rgb.white
+ text = site.rgb.grey1
+ head = site.rgb.grey3
+ line = site.rgb.orange
+ message = site.rgb.green
+ error = site.rgb.red
+ };
+%]
Added: trunk/examples/Quiz/root/lib/config/main
===================================================================
--- trunk/examples/Quiz/root/lib/config/main (rev 0)
+++ trunk/examples/Quiz/root/lib/config/main 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,27 @@
+[% # config/main
+ #
+ # This is the main configuration template which is processed before
+ # any other page, by virtue of it being defined as a PRE_PROCESS
+ # template. This is the place to define any extra template variables,
+ # macros, load plugins, and perform any other template setup.
+
+ IF Catalyst.debug;
+ # define a debug() macro directed to Catalyst's log
+ MACRO debug(message) CALL Catalyst.log.debug(message);
+ END;
+
+ # define a data structure to hold sitewide data
+ site = {
+ title => 'Catalyst Advent Day 13',
+ copyright => '2007 Antano Solar John',
+ };
+
+ # load up any other configuration items
+ PROCESS config/col
+ + config/url;
+
+ # set defaults for variables, etc.
+ DEFAULT
+ message = 'There is no message';
+
+-%]
Added: trunk/examples/Quiz/root/lib/config/url
===================================================================
--- trunk/examples/Quiz/root/lib/config/url (rev 0)
+++ trunk/examples/Quiz/root/lib/config/url 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,8 @@
+[% base = Catalyst.req.base;
+
+ site.url = {
+ base = base
+ home = "${base}welcome"
+ message = "${base}message"
+ }
+-%]
Added: trunk/examples/Quiz/root/lib/site/footer
===================================================================
--- trunk/examples/Quiz/root/lib/site/footer (rev 0)
+++ trunk/examples/Quiz/root/lib/site/footer 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,3 @@
+<!-- BEGIN site/footer -->
+<div id="copyright">© [% site.copyright %]</div>
+<!-- END site/footer -->
Added: trunk/examples/Quiz/root/lib/site/header
===================================================================
--- trunk/examples/Quiz/root/lib/site/header (rev 0)
+++ trunk/examples/Quiz/root/lib/site/header 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,3 @@
+<!-- BEGIN site/header -->
+<h1 class="title">[% template.title or site.title %]</h1>
+<!-- END site/header -->
Added: trunk/examples/Quiz/root/lib/site/html
===================================================================
--- trunk/examples/Quiz/root/lib/site/html (rev 0)
+++ trunk/examples/Quiz/root/lib/site/html 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>[% template.title or site.title %]</title>
+ <style type="text/css">
+[% PROCESS ttsite.css %]
+ </style>
+ </head>
+ <body>
+[% content %]
+ </body>
+</html>
Added: trunk/examples/Quiz/root/lib/site/layout
===================================================================
--- trunk/examples/Quiz/root/lib/site/layout (rev 0)
+++ trunk/examples/Quiz/root/lib/site/layout 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,7 @@
+<div id="header">[% PROCESS site/header %]</div>
+
+<div id="content">
+[% content %]
+</div>
+
+<div id="footer">[% PROCESS site/footer %]</div>
Added: trunk/examples/Quiz/root/lib/site/wrapper
===================================================================
--- trunk/examples/Quiz/root/lib/site/wrapper (rev 0)
+++ trunk/examples/Quiz/root/lib/site/wrapper 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,8 @@
+[% IF template.name.match('\.(css|js|txt)');
+ debug("Passing page through as text: $template.name");
+ content;
+ ELSE;
+ debug("Applying HTML page layout wrappers to $template.name\n");
+ content WRAPPER site/html + site/layout;
+ END;
+-%]
Added: trunk/examples/Quiz/root/src/Ctca/index.tt2
===================================================================
--- trunk/examples/Quiz/root/src/Ctca/index.tt2 (rev 0)
+++ trunk/examples/Quiz/root/src/Ctca/index.tt2 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,21 @@
+<form method="post" action="[%postaction%]" >
+
+Question : [%question.question%] <br>
+
+
+Select an answer
+<ul>
+[% FOREACH option IN options %]
+
+<li><input type="radio" name="choice" value="[%option.id%]"/> [% option.choices %] </li>
+
+[% END %]
+
+</ul>
+
+<input type="submit" name="submit" />
+
+</form>
+
+
+
Added: trunk/examples/Quiz/root/src/error.tt2
===================================================================
--- trunk/examples/Quiz/root/src/error.tt2 (rev 0)
+++ trunk/examples/Quiz/root/src/error.tt2 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,10 @@
+[% META title = 'Catalyst/TT Error' %]
+<p>
+ An error has occurred. We're terribly sorry about that, but it's
+ one of those things that happens from time to time. Let's just
+ hope the developers test everything properly before release...
+</p>
+<p>
+ Here's the error message, on the off-chance that it means something
+ to you: <span class="error">[% error %]</span>
+</p>
Added: trunk/examples/Quiz/root/src/message.tt2
===================================================================
--- trunk/examples/Quiz/root/src/message.tt2 (rev 0)
+++ trunk/examples/Quiz/root/src/message.tt2 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,16 @@
+[% META title = 'Catalyst/TT View!' %]
+<p>
+ Yay! You're looking at a page generated by the Catalyst::View::TT
+ plugin module.
+</p>
+<p>
+ We have a message for you: <span class="message">[% message %]</span>.
+</p>
+<p>
+ Why not try updating the message? Go on, it's really exciting, honest!
+</p>
+<form action="[% site.url.message %]"
+ method="POST" enctype="application/x-www-form-urlencoded">
+ <input type="text" name="message" value="[% message %]" />
+ <input type="submit" name="submit" value=" Update Message "/>
+</form>
Added: trunk/examples/Quiz/root/src/quiz/begin.tt2
===================================================================
--- trunk/examples/Quiz/root/src/quiz/begin.tt2 (rev 0)
+++ trunk/examples/Quiz/root/src/quiz/begin.tt2 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1 @@
+<a href="[% Catalyst.uri_for(newurl) %]" > Click on the link to start the quiz </a>
Added: trunk/examples/Quiz/root/src/quiz/create
===================================================================
--- trunk/examples/Quiz/root/src/quiz/create (rev 0)
+++ trunk/examples/Quiz/root/src/quiz/create 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,12 @@
+<form method="post">
+Quiz Name : <input type="textbox" name="name" /> <br>
+Choose Required modules and No of Questions in each module
+<ul>
+[% FOREACH module IN modules %]
+
+<li>[%module.name%] <input type="checkbox" name="modules" value="[%module.id%]"/> No of Questions <input type="textbox" name = "noq" value="2"/>
+</li>
+[% END %]
+</ul>
+<input type="submit" name="submit" />
+</form>
Added: trunk/examples/Quiz/root/src/quiz/finish
===================================================================
--- trunk/examples/Quiz/root/src/quiz/finish (rev 0)
+++ trunk/examples/Quiz/root/src/quiz/finish 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,3 @@
+Quiz Completed
+You scored [%score%]
+
Added: trunk/examples/Quiz/root/src/quiz/index.tt2
===================================================================
--- trunk/examples/Quiz/root/src/quiz/index.tt2 (rev 0)
+++ trunk/examples/Quiz/root/src/quiz/index.tt2 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,14 @@
+<a href="[% Catalyst.uri_for('/quiz/create') %]"> Create New Quiz </a> <br>
+
+Take one of the Existing quiz
+
+<ul>
+
+[% FOREACH quiz IN quizlist %]
+<li>
+ <a href="[% Catalyst.uri_for('/quiz/start'quiz.id) %]">[% quiz.name %] </a>
+</li>
+[% END %]
+
+</ul>
+
Added: trunk/examples/Quiz/root/src/quiz/start
===================================================================
--- trunk/examples/Quiz/root/src/quiz/start (rev 0)
+++ trunk/examples/Quiz/root/src/quiz/start 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,4 @@
+<form method="post">
+Participant Name : <input type="textbox" name="name"/>
+<input type ="submit" name="submit" />
+</form>
Added: trunk/examples/Quiz/root/src/ttsite.css
===================================================================
--- trunk/examples/Quiz/root/src/ttsite.css (rev 0)
+++ trunk/examples/Quiz/root/src/ttsite.css 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,45 @@
+
+html {
+ height: 100%;
+}
+
+body {
+ background-color: [% site.col.page %];
+ color: [% site.col.text %];
+ margin: 0px;
+ padding: 0px;
+ height: 100%;
+}
+
+#header {
+ background-color: [% site.col.head %];
+ border-bottom: 1px solid [% site.col.line %];
+}
+
+#footer {
+ background-color: [% site.col.head %];
+ text-align: center;
+ border-top: 1px solid [% site.col.line %];
+ position: absolute;
+ bottom: 0;
+ left: 0px;
+ width: 100%;
+ padding: 4px;
+}
+
+#content {
+ padding: 10px;
+}
+
+h1.title {
+ padding: 4px;
+ margin: 0px;
+}
+
+.message {
+ color: [% site.col.message %];
+}
+
+.error {
+ color: [% site.col.error %];
+}
Added: trunk/examples/Quiz/root/src/welcome.tt2
===================================================================
--- trunk/examples/Quiz/root/src/welcome.tt2 (rev 0)
+++ trunk/examples/Quiz/root/src/welcome.tt2 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,9 @@
+[% META title = 'Catalyst/TT View!' %]
+<p>
+ Yay! You're looking at a page generated by the Catalyst::View::TT
+ plugin module.
+</p>
+<p>
+ This is the welcome page. Why not try the equally-exciting
+ <a href="[% site.url.message %]">Message Page</a>?
+</p>
Added: trunk/examples/Quiz/root/static/images/btn_120x50_built.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_120x50_built.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/btn_120x50_built_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_120x50_built_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/btn_120x50_powered.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_120x50_powered.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/btn_120x50_powered_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_120x50_powered_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/btn_88x31_built.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_88x31_built.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/btn_88x31_built_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_88x31_built_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/btn_88x31_powered.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_88x31_powered.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/btn_88x31_powered_shadow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/btn_88x31_powered_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/root/static/images/catalyst_logo.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Quiz/root/static/images/catalyst_logo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Quiz/script/quiz_cgi.pl
===================================================================
--- trunk/examples/Quiz/script/quiz_cgi.pl (rev 0)
+++ trunk/examples/Quiz/script/quiz_cgi.pl 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,37 @@
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'CGI' }
+
+use strict;
+use warnings;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Quiz;
+
+Quiz->run;
+
+1;
+
+=head1 NAME
+
+quiz_cgi.pl - Catalyst CGI
+
+=head1 SYNOPSIS
+
+See L<Catalyst::Manual>
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as a cgi script.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+
+=head1 COPYRIGHT
+
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/Quiz/script/quiz_cgi.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/Quiz/script/quiz_create.pl
===================================================================
--- trunk/examples/Quiz/script/quiz_create.pl (rev 0)
+++ trunk/examples/Quiz/script/quiz_create.pl 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,75 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use Catalyst::Helper;
+
+my $force = 0;
+my $mech = 0;
+my $help = 0;
+
+GetOptions(
+ 'nonew|force' => \$force,
+ 'mech|mechanize' => \$mech,
+ 'help|?' => \$help
+ );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+my $helper = Catalyst::Helper->new( { '.newfiles' => !$force, mech => $mech } );
+
+pod2usage(1) unless $helper->mk_component( 'Quiz', @ARGV );
+
+1;
+
+=head1 NAME
+
+quiz_create.pl - Create a new Catalyst Component
+
+=head1 SYNOPSIS
+
+quiz_create.pl [options] model|view|controller name [helper] [options]
+
+ Options:
+ -force don't create a .new file where a file to be created exists
+ -mechanize use Test::WWW::Mechanize::Catalyst for tests if available
+ -help display this help and exits
+
+ Examples:
+ quiz_create.pl controller My::Controller
+ quiz_create.pl controller My::Controller BindLex
+ quiz_create.pl -mechanize controller My::Controller
+ quiz_create.pl view My::View
+ quiz_create.pl view MyView TT
+ quiz_create.pl view TT TT
+ quiz_create.pl model My::Model
+ quiz_create.pl model SomeDB DBIC::Schema MyApp::Schema create=dynamic\
+ dbi:SQLite:/tmp/my.db
+ quiz_create.pl model AnotherDB DBIC::Schema MyApp::Schema create=static\
+ dbi:Pg:dbname=foo root 4321
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Create a new Catalyst Component.
+
+Existing component files are not overwritten. If any of the component files
+to be created already exist the file will be written with a '.new' suffix.
+This behavior can be suppressed with the C<-force> option.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/Quiz/script/quiz_create.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/Quiz/script/quiz_fastcgi.pl
===================================================================
--- trunk/examples/Quiz/script/quiz_fastcgi.pl (rev 0)
+++ trunk/examples/Quiz/script/quiz_fastcgi.pl 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,80 @@
+#!/usr/bin/perl -w
+
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Quiz;
+
+my $help = 0;
+my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr );
+
+GetOptions(
+ 'help|?' => \$help,
+ 'listen|l=s' => \$listen,
+ 'nproc|n=i' => \$nproc,
+ 'pidfile|p=s' => \$pidfile,
+ 'manager|M=s' => \$manager,
+ 'daemon|d' => \$detach,
+ 'keeperr|e' => \$keep_stderr,
+);
+
+pod2usage(1) if $help;
+
+Quiz->run(
+ $listen,
+ { nproc => $nproc,
+ pidfile => $pidfile,
+ manager => $manager,
+ detach => $detach,
+ keep_stderr => $keep_stderr,
+ }
+);
+
+1;
+
+=head1 NAME
+
+quiz_fastcgi.pl - Catalyst FastCGI
+
+=head1 SYNOPSIS
+
+quiz_fastcgi.pl [options]
+
+ Options:
+ -? -help display this help and exits
+ -l -listen Socket path to listen on
+ (defaults to standard input)
+ can be HOST:PORT, :PORT or a
+ filesystem path
+ -n -nproc specify number of processes to keep
+ to serve requests (defaults to 1,
+ requires -listen)
+ -p -pidfile specify filename for pid file
+ (requires -listen)
+ -d -daemon daemonize (requires -listen)
+ -M -manager specify alternate process manager
+ (FCGI::ProcManager sub-class)
+ or empty string to disable
+ -e -keeperr send error messages to STDOUT, not
+ to the webserver
+
+=head1 DESCRIPTION
+
+Run a Catalyst application as fastcgi.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/Quiz/script/quiz_fastcgi.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/Quiz/script/quiz_server.pl
===================================================================
--- trunk/examples/Quiz/script/quiz_server.pl (rev 0)
+++ trunk/examples/Quiz/script/quiz_server.pl 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ $ENV{CATALYST_ENGINE} ||= 'HTTP';
+ $ENV{CATALYST_SCRIPT_GEN} = 30;
+ require Catalyst::Engine::HTTP;
+}
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+my $debug = 0;
+my $fork = 0;
+my $help = 0;
+my $host = undef;
+my $port = $ENV{QUIZ_PORT} || $ENV{CATALYST_PORT} || 3000;
+my $keepalive = 0;
+my $restart = $ENV{QUIZ_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
+my $restart_delay = 1;
+my $restart_regex = '\.yml$|\.yaml$|\.pm$';
+my $restart_directory = undef;
+
+my @argv = @ARGV;
+
+GetOptions(
+ 'debug|d' => \$debug,
+ 'fork' => \$fork,
+ 'help|?' => \$help,
+ 'host=s' => \$host,
+ 'port=s' => \$port,
+ 'keepalive|k' => \$keepalive,
+ 'restart|r' => \$restart,
+ 'restartdelay|rd=s' => \$restart_delay,
+ 'restartregex|rr=s' => \$restart_regex,
+ 'restartdirectory=s' => \$restart_directory,
+);
+
+pod2usage(1) if $help;
+
+if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
+ $ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
+}
+if ( $debug ) {
+ $ENV{CATALYST_DEBUG} = 1;
+}
+
+# This is require instead of use so that the above environment
+# variables can be set at runtime.
+require Quiz;
+
+Quiz->run( $port, $host, {
+ argv => \@argv,
+ 'fork' => $fork,
+ keepalive => $keepalive,
+ restart => $restart,
+ restart_delay => $restart_delay,
+ restart_regex => qr/$restart_regex/,
+ restart_directory => $restart_directory,
+} );
+
+1;
+
+=head1 NAME
+
+quiz_server.pl - Catalyst Testserver
+
+=head1 SYNOPSIS
+
+quiz_server.pl [options]
+
+ Options:
+ -d -debug force debug mode
+ -f -fork handle each request in a new process
+ (defaults to false)
+ -? -help display this help and exits
+ -host host (defaults to all)
+ -p -port port (defaults to 3000)
+ -k -keepalive enable keep-alive connections
+ -r -restart restart when files get modified
+ (defaults to false)
+ -rd -restartdelay delay between file checks
+ -rr -restartregex regex match files that trigger
+ a restart when modified
+ (defaults to '\.yml$|\.yaml$|\.pm$')
+ -restartdirectory the directory to search for
+ modified files
+ (defaults to '../')
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst Testserver for this application.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/Quiz/script/quiz_server.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/Quiz/script/quiz_test.pl
===================================================================
--- trunk/examples/Quiz/script/quiz_test.pl (rev 0)
+++ trunk/examples/Quiz/script/quiz_test.pl 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,54 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+use Getopt::Long;
+use Pod::Usage;
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+use Catalyst::Test 'Quiz';
+
+my $help = 0;
+
+GetOptions( 'help|?' => \$help );
+
+pod2usage(1) if ( $help || !$ARGV[0] );
+
+print request($ARGV[0])->content . "\n";
+
+1;
+
+=head1 NAME
+
+quiz_test.pl - Catalyst Test
+
+=head1 SYNOPSIS
+
+quiz_test.pl [options] uri
+
+ Options:
+ -help display this help and exits
+
+ Examples:
+ quiz_test.pl http://localhost/some_action
+ quiz_test.pl /some_action
+
+ See also:
+ perldoc Catalyst::Manual
+ perldoc Catalyst::Manual::Intro
+
+=head1 DESCRIPTION
+
+Run a Catalyst action from the command line.
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri at oook.de>
+Maintained by the Catalyst Core Team.
+
+=head1 COPYRIGHT
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Property changes on: trunk/examples/Quiz/script/quiz_test.pl
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/examples/Quiz/t/01app.t
===================================================================
--- trunk/examples/Quiz/t/01app.t (rev 0)
+++ trunk/examples/Quiz/t/01app.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,7 @@
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+BEGIN { use_ok 'Catalyst::Test', 'Quiz' }
+
+ok( request('/')->is_success, 'Request should succeed' );
Added: trunk/examples/Quiz/t/02pod.t
===================================================================
--- trunk/examples/Quiz/t/02pod.t (rev 0)
+++ trunk/examples/Quiz/t/02pod.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_files_ok();
Added: trunk/examples/Quiz/t/03podcoverage.t
===================================================================
--- trunk/examples/Quiz/t/03podcoverage.t (rev 0)
+++ trunk/examples/Quiz/t/03podcoverage.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+use Test::More;
+
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_coverage_ok();
Added: trunk/examples/Quiz/t/controller_Ctca-Ctca.t
===================================================================
--- trunk/examples/Quiz/t/controller_Ctca-Ctca.t (rev 0)
+++ trunk/examples/Quiz/t/controller_Ctca-Ctca.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+BEGIN { use_ok 'Catalyst::Test', 'Quiz' }
+BEGIN { use_ok 'Quiz::Controller::Ctca::Ctca' }
+
+ok( request('/ctca/ctca')->is_success, 'Request should succeed' );
+
+
Added: trunk/examples/Quiz/t/controller_quiz.t
===================================================================
--- trunk/examples/Quiz/t/controller_quiz.t (rev 0)
+++ trunk/examples/Quiz/t/controller_quiz.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+BEGIN { use_ok 'Catalyst::Test', 'Quiz' }
+BEGIN { use_ok 'Quiz::Controller::quiz' }
+
+ok( request('/quiz')->is_success, 'Request should succeed' );
+
+
Added: trunk/examples/Quiz/t/model_Ctca.t
===================================================================
--- trunk/examples/Quiz/t/model_Ctca.t (rev 0)
+++ trunk/examples/Quiz/t/model_Ctca.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Quiz::Model::Ctca' }
+
Added: trunk/examples/Quiz/t/model_Fitb.t
===================================================================
--- trunk/examples/Quiz/t/model_Fitb.t (rev 0)
+++ trunk/examples/Quiz/t/model_Fitb.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Quiz::Model::Fitb' }
+
Added: trunk/examples/Quiz/t/model_Quiz.t
===================================================================
--- trunk/examples/Quiz/t/model_Quiz.t (rev 0)
+++ trunk/examples/Quiz/t/model_Quiz.t 2007-12-23 17:54:21 UTC (rev 7329)
@@ -0,0 +1,6 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+BEGIN { use_ok 'Quiz::Model::Quiz' }
+
More information about the Catalyst-commits
mailing list