Video: Credit based on fraction watched

If you have created activities with embedded videos and tried to use the “Give credit based on fraction watched” code, you may have noticed that some videos will play all the way through, but not show as 100% watched.

I developed this alternative:

<video name="v1" youtube="_P7AI5nghyo"><shortDescription>A youtube video where Ash says "Pikachu, I choose you!"</shortDescription></video>
<setup> <number name="watch">$v1.secondsWatched/($v1.duration-1)</number><number name="percent">$v1.secondsWatched/($v1.duration-1)*100</number> </setup>
<p>Video credit achieved: 
<min>$percent 100</min><math>%</math></p>
<answer hide name="v1Credit">
  <award credit="$watch">
    <when>true</when>
  </award>
</answer>
  <callAction triggerWith="$v1" target="$v1Credit" actionName="submitAnswer" />

This works the same as the $v.fractionWatched, in that all you need to do is paste in the end of the YouTube URL. I think the problem with $v.fractionWatched is in how Youtube deals with the fractional part of the time in videos, as most videos are not an exact number of seconds long. It would give students full credit for a video if they pause it with less than a second left, but I’m not sure that I think that’s an issue.

I tested this with a few different videos to make sure that it showed the percentage correctly, AND that it is recording the score for the students accurately.

Hope this is helpful!

@Duane_Nykamp1, could this be made the default behavior for the code snippet?

We released a new version 0.7.30 yesterday that should have fixed the issue. Now, I hope, that <answer type="videoWatched" > or just using $v.fractionWatched should work correctly. If you can test it and let me know if it fixed the bugs, that’d be great!

Your workaround is great, but I’m hoping to not make people work so hard…

Good to hear 0.7.30 is out. For anyone testing, it would help to record the final seconds watched and total duration when a video finishes; if the gap is still around one second, the fractional-duration rounding may not be fully fixed. Otherwise, a quick reload after updating should rule out a cached older script.