How to Store and show the socre of a flash?

How to Store and show the socre of a flash?

Jason Kwok發表於
Number of replies: 15
I am s student who is creating a flash game for education purpose.
I have used a packaging tool to package a scorm package
i have added these code in my flash game
however, the score shown in the report after the game was played is still 0.

ExternalInterface.call("LMSInitialize");
ExternalInterface.call("LMSSetValue", "cmi.core.score.raw", "40");
ExternalInterface.call("LMSFinish");

Is there any bug i have made??

THX
評比平均分數: -
In reply to Jason Kwok

Re: How to Store and show the socre of a flash?

Matt Bury發表於
Particularly helpful Moodlers的相片 Plugin developers的相片
Hi Jason,

Here's a good place to look for developing Flash apps. to send scores to SCORM: http://pipwerks.com/

Also, make sure you've got the right version of SCORM for Moodle and you're using the right subset of commands. Every LMS interprets SCORM compliance guidelines slightly differently. SCORM can be quite a steep learning curve.

If you get fed up with SCORM and you only need to push a score into Moodle's grade book, the SWF Activity Module's a good option: http://code.google.com/p/swf-activity-module/ It also hooks into some of Moodle's APIs so you can safely send and retrieve user data, group data, etc. I'm developing it and I'm primarily a Flash developer so I'd like to hear back from you about it, i.e. about the documentation, the features, the code, ease of use, anything more it needs, etc.

Good luck! 微笑
In reply to Matt Bury

回應: Re: How to Store and show the socre of a flash?

Jason Kwok發表於

i would like to ask a little problem i have when i used the swf activity module

the system tells me that the module has been installed successfully

however, when i tried to upload a swf to the system

i found that the button "choose or upload a file" is not responding and there is no way for me to choose which file to be used

i have tried to upload the swf as a simple file share first and input the path at that field.

However, when i save it it give an error that "insert_record()" is not avaiable anymore.

the version of swf activity module that i downloaded is the version released on 2010-2-17

what should i do to handle this problem? THX

In reply to Jason Kwok

Re: How to Store and show the socre of a flash?

Wade Gemmell發表於
Hi Jason,

Here is some code I shared with another user on this forum using the pipwerks package. You can adapt to fit your needs. Matt's code does a good job too using the external interface if I recall.

import fl.controls.Button; // assumes you are using the components imports
import flash.events.MouseEvent;
import pipwerks.SCORM; // class file to track SCORM information

var lessonStatus:String; // checks the status of lesson complete or not complete
var lmsConnected:Boolean; // checks if LMS is available returns true is there is LMS available
var success:Boolean; // Hold value to tell if LMS is active
var scorm:SCORM = new SCORM();

test_btn.addEventListener(MouseEvent.CLICK, scormFinish)

lmsConnected = scorm.connect(); // tries to connect to SCORM and returns true if it does

if(lmsConnected) // if it is connected (true)
{
lessonStatus = scorm.get("cmi.core.lesson_status"); // gets the current status of the lesspm

if(lessonStatus == "completed") // is the lesson is already complete
{
scorm.disconnect(); //Course has already been completed. // disconnect from the system
}

else
{
success = scorm.set("cmi.core.lesson_status", "incomplete"); // else set the lesson to incomplete
//Must tell LMS course has not been completed yet.
}

}

else
{
trace("Could not connect to LMS."); // returns a message if lmsConnected is false (not connected)
}

function scormFinish (event:MouseEvent): void // used to finish upon a mouse click

{
success = scorm.set("cmi.core.score.raw", "5") //raw score
success = scorm.set("cmi.core.score.max", "10") // total score
success = scorm.set("cmi.core.score.min", "0"); // min score
success = scorm.set("cmi.core.lesson_status", "completed");// sets the project as having been compelted
scorm.disconnect(); // disconnects from the system
lmsConnected = false; // sets lmsConnected to false
}

The comments should help you work your way through it. Sticking to this naming convention should provide you with code hinting to help add your event listeners.

The numbers 5 ,10 & 0 could be replaced with variables that would be impacted by the actions of the users. Hope this helps.

Wade
In reply to Wade Gemmell

Re: How to Store and show the socre of a flash?

Matt Bury發表於
Particularly helpful Moodlers的相片 Plugin developers的相片
Hi Wade,

Thanks for helping out 微笑

Just a correction, the SWF Activity Module doesn't use ExternalInterface at all and therefore doesn't require a Javascript API wrapper.

It uses NetConnection to connect directly to a PHP gateway that translates between Actionscript 3.0 and PHP. It's almost completely seamless and preserves a wide variety of data types such as numbers, strings, arrays, objects and MySQL results. When you write Actionscript code it feels like you're calling PHP functions and passing objects back and forth directly, it's that easy.

Oh, did I mention that it's many times faster and lighter than using ExternalInterface (JSON)?

Here's a few database driven learning applications that use it: http://matbury.com/moodle/course/view.php?id=9 (Login as a guest) I'm actually going to change them to XML driven ones because that's what most people are comfortable with.

I hope this helps 微笑
In reply to Matt Bury

Re: How to Store and show the socre of a flash?

lawrence li發表於
Matt

Would like to know if I write a flash game and record its marks/records to students, can I do that using SWF Activity Module? Thanks
In reply to lawrence li

Re: How to Store and show the socre of a flash?

Matt Bury發表於
Particularly helpful Moodlers的相片 Plugin developers的相片
Hi Lawrence,

Yes, you can.

Please let me know if this documentation is helpful to you: http://code.google.com/p/swf-activity-module/wiki/SendingGrades

I look forward to your reply! 微笑
In reply to Matt Bury

Re: How to Store and show the socre of a flash?

lawrence li發表於

Thanks Matt the reply

based on the code I see (I know nothing on Flash) , I don't need to manually write the course id / activity id to the flash right? so the flow would be follows:

1. install sws activity / awfphp module into Moodle

2. write a flash with the code you provided

3. add swf activity in the course

4. after student played the flash, the final grade will send to course grade book

Pls see if my concept is correct? Thanks very much!!

Lawrence

In reply to lawrence li

Re: How to Store and show the socre of a flash?

Matt Bury發表於
Particularly helpful Moodlers的相片 Plugin developers的相片
Yes, the FlashVars static class (global) and the SWF Activity Module's infrastructure automatically handle all the Moodle IDs for you. Here's a list of the parameters passed in: http://code.google.com/p/swf-activity-module/wiki/FlashVars

The AMFPHP gateway and services can also access other Moodle APIs such as Groups, Users and messaging. If there's a Moodle chat API, you can make custom Flash chat clients 微笑
In reply to Matt Bury

Re: How to Store and show the socre of a flash?

lawrence li發表於

Thanks again for your reply, since I'm weak in flash programming, do there any tutorial /code how can make it work?

What do I need actually? swf_activity module installer, or amfphp? or both?

btw, if my flash game is for a student (not for a course), can I store the mark for the student (but not in the grade of the course) in moodle? thanks

In reply to lawrence li

Re: How to Store and show the socre of a flash?

lawrence li發表於
would like to have a flash content (for example have simple question in the flash, then calculate the grade, after finished the game the grade will write to database {course id, student id, activity id, grade} ),

is there any example / any people have done similar things by using swf_activity / awfphp? want to have a look how the flow (the code) is written to have a quick start...thanks
In reply to Jason Kwok

回應: How to Store and show the socre of a flash?

Jason Kwok發表於

Thx for all your replies.

As I have only studied externalinterface in flash for communication with javascript, it take me sometime to understand what you are talking about. But hopefully, i will make it.

Thx

In reply to Jason Kwok

Re: 回應: How to Store and show the socre of a flash?

Matt Bury發表於
Particularly helpful Moodlers的相片 Plugin developers的相片
Hi,

@Leslie, Student IDs, names, groups, etc. are all handled on the server for security reasons. You can call the Users.php and Groups.php services at: http://code.google.com/p/swf-activity-module/source/browse/#svn/trunk/src/moodle/lib/amfphp/services to retrieve specific data about specific users, depending on the users' capabilities as set by Moodle, i.e. only teachers can get other users' data, students only have access to their own, etc.

If you know Moodle's lib functions, you can create new services to access the messaging system and other functions so you can set up custom chat activities or send grades via email. Be sure to filter out any sensitive information before sending it client-side though!

@Jason, AMFPHP is much simpler to implement than JSON + ExternalInterface and easier to learn. I'm sure you'll wonder how you ever managed without it!

@Lawrence, if you want Flash to communicate with Moodle, then you need AMFPHP. The SWF Activity Module doesn't support JSON + ExternalInterface.

Students can store their grades locally if you wish. Just use a local SharedObject and you can store almost anything you like, even mini database files, in users' browser caches. The grade book is the easiest to implement though, and Moodle's grade book is flexible enough to allow you to store grades and feedback that doesn't count towards students' final grades.

I hope this helps! 微笑
In reply to Matt Bury

Re: 回應: How to Store and show the socre of a flash?

Niranjan eAbyas發表於

Hi , I installed the SWF activity module. And I kept the xml_word_search.swf in a course.I loged in as a  user i took the test . I can't see my grades once i come out of the course. I have seen database also but can't find the grades. Can any one tell me in which table the data is stored.

I think i should write the action script for this.. If so can any have that file.. and where should i keep that file.

And one more sendinggardes is also not working .. can any one suggest me where should i keep the action script files.

And last question... Can i create myown flash file and save the score in the database... if so can i use this module. please help me with this issues...