Jump to content

File Drop documents display based on Roll Number / MIS ID


Graham Quince

Recommended Posts

I know we have Paul's excellent Exam Timetables widget, but I've just been helping a school who couldn't get it to work.  They're using SIMS Exam system for another purpose, and needed to display the PDFs to students.

I don't know the Exam timetabler all that well, but the school in question had a single PDF produced with 500 students on it.  They'd already begun the process of saving the individual pages as separate documents, so I suggested we use the File Drop widget to hold them and show only the matching PDF to the student:

<div class="File_PDF"></div>

<script>
    var File_PDF = arguments[0].find('.File_PDF');
    var baseURL = Frog.Utilities.getBaseUrl();
    var fileDropUUID = 'FILE_DROP_UUID';
    
    
    var user = FrogOS.getUser();
    Frog.Model.api('users.getDataInCategory', {
        user_uuid: user.uuid,
        uuid: '60A77B2B2004CAF8CA73CFFA7491B80E180635BCDD1AEDB7' // Users app category for additional information, where the roll number is stored
    }).done(function(response) {

        var data = response.data.fields;
        var MISID = '';
        $.each(data, function(index, field) {
            if (field.label == 'roll_number') {
                MISID = field.value;
                Frog.Model.api('filedrop.get', {
                    filedrop: fileDropUUID
                }).done(function(fileResponse) {
                    var files = fileResponse.data.resources;
                    $.each(files, function(ind,file) {
                        if (file.deleted == 0) {
                            if (file.file.name.indexOf('-'+MISID+'-') > -1) {
                                File_PDF.append(
                                    '<embed src="'+baseURL+'/app/file/resource/'+file.file.uuid+'" width="100%"  height="1500px" />'
                                );
                            }
                        }
                    })
                }).fail(function(e) {
                    console.log("failed to get file drop");
                });
            }
        });
    }).fail(function(e) {
        console.log("failed to get Roll Number");
    });

</script>   
        
        
        
        

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...