Background: A reported problem with e-learning is sustaining students' motivation. We propose a framework explaining to what extent an e-learning task is motivating. This framework includes students' perceived Value of the task, Competence in executing the task, Autonomy over how to carry out the task, and Relatedness. Methods: To test this framework, students generated items in an online environment and answered questions developed by their fellow students. Motivation was measured by analyzing engagement with the task, with an open-ended questionnaire about engagement, and with the motivated strategies for learning questionnaire (MSLQ). Results: Students developed 59 questions and answered 1776 times on the questions. Differences between students who did or did not engage in the task are explained by the degree of self-regulation, time management, and effort regulation students report. There was a significant relationship between student engagement and achievement after controlling for previous academic achievement. Conclusions: This study proposes a way of explaining the motivational value of an e-learning task by looking at students' perceived competence, autonomy, value of the task, and relatedness. Student-generated items are considered of high task value, and help to perceive relatedness between students. With the right instruction, students feel competent to engage in the task.