Hello
kcott and thanks,
maybe I'm too much confused, but the interesting module File::ShareDir you suggested to me does not solve my doubts. If I read it correctly (and just glanced it atm) it is used to share and expose pure data stored at install time somewhere in the filesystem and make the program to be able to find them at runtime. My situation is more complex, or I'm too blind to see a clean solution.
Maybe a rough piece of pseudocode will show it better:
#
# modules of my distribution:
#
Perl::Teacher
load_course (then in the program using this module I can call $course
+->get_description)
load_lesson (then in the program using this module I can call $lesson
+->get_steps)
Perl::Teacher::Course
new creates a slot for description and one for [lessons]
get_description
get_lessons
Perl::Teacher::Lesson
new creates a slot for abstract and one for [steps]
get_abstract
get_steps
#
# modules outside my distribution, intended to be written by someone e
+lse and installed separately
# (note that these modules should have their own tests under /t folder
+ as any module should)
#
Perl::Teacher::Course::EN::PerlIntro
isa Perl::Teacher::Course
$__PACKAGE__::description = 'a fair intro to perl',
$__PACKAGE__::lessons = [Perl::Teacher::Course::EN::PerlIntro::01_for
+eword , ...]
Perl::Teacher::Course::EN::PerlIntro::01_strictures
isa Perl::Teacher::Lesson
$__PACKAGE__::abstract = 'introducing the safety net'
$__PACKAGE__::steps = [
# a simple text
001=>{type=>text,content=>'We now introduce strictures'},
# check_script_compiles is a method exposed by Perl::Teacher
002=>{ name=>'script compiles', action=>\check_script_compiles() }
# a complex test to be run against student's code
003=>{type=>test,content=>{
name => 'strictures',
# select_child_of is a method exposed by Perl::Teacher
select_child_of => {
class => 'PPI::Statement::Include',
tests => [
['PPI::Token::Word', qr/^use$/],
['PPI::Token::Word', 'strict']
],
},
hint => "search perlintro for safety net",
docs => ['https://perldoc.perl.org/perlintro.html#Safet
+y-net'],
}
}
]
As you can see it is very ugly. I'd like to provide a nice and usable interface to course authors.
One solution I have is to abstract as much as possible the lesson content and provide an higher level language to define a lesson, probably YAML will be enough. I dont like very much this solution because it will force the author to write YAML instead of perl code. If I go for YAML then File::ShareDir can be an option: the Perl::Teacher::Course::EN::PerlIntro simply write 01_strictures.yaml to the disk then the Perl::Teacher object load the course and all its yaml from the disk.
Thanks for the help!
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.