coding a module - must be attached to a course? more >>

coding a module - must be attached to a course? more >>

luke b -
回帖数:12

Hi 

 

I am coding up what will be a an activity log, and have chosen a module as the way to do this. 

The log will be for teachers to use only. They would pick a student from a list of all their students and then log how much time they have spent with them. Facetime etc. 

Does a module have to be attached to a course ? Is there another way I could do this so it was just there for a teacher when they login -

it would need to load any students that teacher had responsiblity for.

I'm using Moodle 2.1  and am a bit new to this, but good with CakePHP and deving stuff in PHP. Thankyou for your time! 

回复luke b

Re: coding a module - must be attached to a course? more >>

Jamie Pratt -

Hi Luke,

Moodle is sometimes referred to as a course management system. It is very much organised around courses. The basic structure of a Moodle sites is a bunch of different types of activities arranged into courses and assigned teachers and students for each course. It may be that you want to make your log a course activity, ie. something that a teacher can attach to a course to log the time they have spent with students in that course. Or you might want to look at producing a local/ plug in that would not necessarily be attached to a course.

 

It may be that what you want to do is available as a module already. Or you could reuse another module to do what you want to do. I think the assignmet module has an assigenment type that is an offline type, that you might look into. It can be used to grade interaction between a teacher and student offline and add notes about the interaction I believe.

 

Jamie

 

回复Jamie Pratt

Re: coding a module - must be attached to a course? more >>

luke b -

thanks Jamie, thats very helpful. Yes I had looked at possibly adapting a few modules - seems a good way to go - what you say about Assignment is very interesting!

Is there a way I could get a list of all students from the database if I used an activity module , so that I could show  a dropdown to the teacher and he could select that student? Or do you mean it will only have access to the students (particpants?) enrolled on that course.

Maybe I can make a special course "offline-activity". All students could be enrolled on it (maybe using new cohort feature). They wouldnt access it though and it might be hidden from them even.

Then a teacher could just pick the student they need to log for and fill out the contact-time they have had with that student.

Does it sound feasible? 

回复luke b

Re: coding a module - must be attached to a course? more >>

luke b -

Is there a way to make an module that I can therefore:

  • assign to all students + teachers can use only (I think yes) 
  • let a teacher put in the date, choose a student and save *multiple times* ?
  • show a list of students in a dropdown (yes)
回复luke b

Re: coding a module - must be attached to a course? more >>

Davo Smith -
Core developers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
If I was writing this I'd put it in a block and stick it on the front page. You can always link through to a separate page if a block is too small.
回复Davo Smith

Re: coding a module - must be attached to a course? more >>

Hubert Chathi -

Or stick it on the "My home" page.  You can detect if the block is in the centre column, and display extended information in that case.

回复Hubert Chathi

Re: coding a module - must be attached to a course? more >>

luke b -

hi thanks Hubert and Davo,

very helpful - getting the basic architecture right is key I think!

I was beginning to think of using the block way - since it will always need to be there as a regular feature for the teachers (its users basically).

I was looking at the local / plugin methods also, but havent got too far with that yet.

I am going to continue with the block way I think - I will need to work out how to interact with the databsae and then also provide some new table(s) to save these multiple records of teacher-student interactions.

If you know of any similar blocks for me to look at please shout! It's not a million miles from "Notes" I guess, either.

回复Hubert Chathi

Re: coding a module - must be attached to a course? more >>

luke b -

hi how do you detect if a block is in the centre? I am using moodle 2 so should be able to do this but cannot see how :/

回复luke b

Re: coding a module - must be attached to a course? more >>

Hubert Chathi -

I forget exactly.  I think there's something in $this->instance that tells you which region the block is in.

回复Davo Smith

Re: coding a module - must be attached to a course? more >>

luke b -

hi can you please expand on a separate page doing this? Can I from that page have a small set of pages Eg add.php and edit.php?id= etc that could make use of the core moodle data /functions API etc? 

Is there an example of this kind of thing? I am not sure would I need to put it in its own directory in the moodle directory?

 

Sorry for all the questions but I am finding it hard to do this the right way ...

回复luke b

Re: coding a module - must be attached to a course? more >>

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像

Yes. The rss_client block is an example of this. There are separate pages for managing the list of feeds, and editing a feed's settings.

回复luke b

Re: coding a module - must be attached to a course? more >>

Davo Smith -
Core developers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像

The easiest example for me to work with is one of my own blocks - the lesson objective block: https://github.com/davosmith/moodle-objectives 

The slight added complexity with this block is that I have created a 'lib.php' file that holds most of the code for the block (inside a block_objectives_class class), to try and keep it all neat and tidy. Essentially all the other PHP files do a little setting up, then call code in my lib.php file. With that in mind, I'll talk you through a few sections:

block_objectives.php - function get_content();

This calls my 'get_block_text' function, which, amongst other things, outputs an HTML link to 'block/objectives/edit.php' (teachers only) and 'block/objectives/view.php'.

If you now look inside view.php ( https://github.com/davosmith/moodle-objectives/blob/master/view.php ), this:

  1. includes the main Moodle config.php file (which gives access to all the standard Moodle function calls)
  2. gets the parameters passed to it (via required_param / optional_param)
  3. checks the paramaters (mostly via $DB->get_record calls)
  4. calls $PAGE->set_url() to define the correct URL for accessing the page (essential)
  5. calls require_login() to make sure the user is logged in and that the $USER global variable is set up (amongst other things)
  6. It then passes control to my lib.php file
Inside lib.php ( https://github.com/davosmith/moodle-objectives/blob/master/lib.php ), in the 'view_objective' function, I:
  1. use 'has_capability' to check the user is allowed to view the objectives (redirecting back to the course page if not)
  2. set up lots of data structures that are only relevant to my particular plugin
  3. use '$PAGE->set_title', '$PAGE->set_heading' and 'echo $OUTPUT->header()' to start the page off (this is hidden inside a separate function call, as I need the same title for several pages in my plugin).
  4. I then output all the content for the page (again, this is plugin-specific)
  5. Finally I call 'echo $OUTPUT->footer()' to finish off the page
I hope that is a good enough summary to get you started.
If you are creating this as a block, then it should go in the 'blocks/[name of your block]' folder, and you probably want to read through the documentation for the rest of the details ( http://docs.moodle.org/dev/Blocks )
回复Davo Smith

Re: coding a module - must be attached to a course? more >>

luke b -

immensely helpful and kind Davo - thanks! just looking at it now 微笑 cheers for the RSS tip also Tim...thanks all for getting back!