$scope.saveScore = function () {
$scope.userScoreList =
new
Array();
angular.forEach ($scope.records, function (record, index) {
if
(record.score !=
null
) {
$scope.userScoreModel = {
'userAnswerId'
:
null
,
'score'
:
null
};
$scope.userScoreModel.userAnswerId = record.userAnswerId;
$scope.userScoreModel.score = record.score;
$scope.userScoreList.push($scope.userScoreModel);
debugger;
if
($scope.userScoreList !=
null
&& $scope.userScoreList.length >
0
) {
var fd =
new
FormData();
var userScoreRecords = angular.toJson($scope.userScoreList);
fd.append(
'userScoreRecords'
, userScoreRecords);
debugger;
$http.post(
'/reviewProcess/save'
, fd, {
transformRequest: angular.identity,
headers: {
'Content-Type'
: undefined
.success(function (data){
toastr.success(
"success"
);
.error(function (data) {
toastr.success(
"failed"
);
@ResponseBody
@RequestMapping
(value =
"/reviewProcess/save"
, method = RequestMethod.POST)
public
void
saveUserScore (
@RequestParam
(
"userScoreRecords"
) String userScoreRecords) {
System.out.println(userScoreRecords);
ObjectMapper mapper =
new
ObjectMapper();
UserScoreModel record =
null
;
try
{
JSONArray jsonArray =
new
JSONArray (userScoreRecords);
for
(
int
i =
0
; i < jsonArray.length(); i++) {
record = mapper.readValue(jsonArray.getJSONObject(i).toString(), UserScoreModel.
class
);
System.out.println(record);
}
catch
(Exception e) {
logger.error(e.getMessage(), e);