I am not sure about your data model as classes and students may well be a 
many to many relationship and you may be better with an intermediate table 
to support this.  Current setup each student can only belong to a single 
class.  With current setup there are still a number of ways that you could 
tackle this and you might want to in some way schedule the dates of your 
classes.  If you don't do this but are taking attendance real time with 
class meeting once per day then you could have a simple form to select a 
class and once submitted you would use update or insert method to create a 
record for each student in the attendance table with initial attendance set 
to absent.  After that I'd probably use an ajax function perhaps with a 
checkbox next to them that would update the absent or present when it was 
changed.  It would be a bit like the voting example in the web2py book on 
using ajax I think.

Regards
Donald

On Friday, May 5, 2017 at 10:02:36 PM UTC+1, Toe Khaing Oo wrote:
>
>
> I'm building student attendance app. It has 3 databases, *class*, *student 
> *and *attendance*. 
>
> db.define_table('classes',
>                 Field('name', notnull=True, requires=IS_NOT_EMPTY()),
>                 Field('created_on', 'datetime', default=request.now),
>                 format = '%(name)s')
>
> db.define_table('students',
>                 Field('name', notnull=True, requires=IS_NOT_EMPTY()),
>                 Field('class_id', db.classes),
>                 Field('created_on', 'datetime', default=request.now),
>                 format = '%(name)s'
>                 )
>
> db.define_table('attendance',
>                 Field('class_id', db.classes, default= db.classes.id),
>                 Field('student_id', db.students),
>                 Field('Attend', notnull=True, requires = IS_IN_SET([
> 'Absent', 'Present']), default='Present'),
>                 Field('created_on', 'datetime', default=request.now)
>                 )
>
> I wanna show specific class like this .. 
>
> Class - A 
> students list 
> 1. John Doe       [Absent/Present] <- which is selection option
> 2. Smith            [Absent/Present]
> [Submit] <- which is submit button 
>
> When user checks absent or present for a specific student and click 
> submit, all records will insert into attendance table. 
> How should I write controller function?
>
> Best Regards .. 
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to